Commit dfe3145b authored by 王亚雷's avatar 王亚雷

报告单独收费

parent 8ed8a405
package com.tanpu.fund.api;
import com.tanpu.common.model.fund.req.IncReportDownloadTimesReq;
import com.tanpu.common.model.product.resp.Net;
import com.tanpu.common.resp.CommonResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
......@@ -27,4 +30,12 @@ public interface ProductForPcApi {
@ApiOperation("增加标准会员的下载次数")
@GetMapping("/pdf/standard/add")
CommonResp<Void> addStandardVipCount(String userId);
/**
* 增加报告下载次数
* @param req 请求参数
* @return 总次数
*/
@PostMapping("/inner/incReportDownloadTimes")
CommonResp<Integer> incReportDownloadTimes(@RequestBody IncReportDownloadTimesReq req);
}
package com.tanpu.fund.controller;
import com.tanpu.common.auth.mapping.TanpuInterfaceLoginAuth;
import com.tanpu.common.model.fund.req.IncReportDownloadTimesReq;
import com.tanpu.common.model.product.resp.Net;
import com.tanpu.common.resp.CommonResp;
import com.tanpu.fund.api.ProductForPcApi;
......@@ -41,4 +43,17 @@ public class ProductForPcController implements ProductForPcApi {
downloadPdfService.addStandardVipCount(userId);
return CommonResp.success();
}
/**
* 增加报告下载次数
*
* @param req 请求参数
* @return 总次数
*/
@Override
@TanpuInterfaceLoginAuth
public CommonResp<Integer> incReportDownloadTimes(IncReportDownloadTimesReq req) {
int totalTimes = downloadPdfService.incReportDownloadTimes(req);
return CommonResp.success(totalTimes);
}
}
......@@ -2,6 +2,8 @@ package com.tanpu.fund.mapper.generator;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanpu.fund.entity.generator.ReportDownloadSummary;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ReportDownloadSummaryMapper extends BaseMapper<ReportDownloadSummary> {
}
\ No newline at end of file
package com.tanpu.fund.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tanpu.common.model.fund.req.IncReportDownloadTimesReq;
import com.tanpu.fund.entity.generator.ReportDownloadSummary;
import com.tanpu.fund.mapper.generator.ReportDownloadSummaryMapper;
import org.apache.commons.collections4.CollectionUtils;
......@@ -47,8 +49,33 @@ public class DownloadPdfService {
entity.setStdVipLimit(entity.getStdVipLimit() + onceAddTimes);
reportDownloadSummaryMapper.updateById(entity);
}
}
/**
* 增加报告下载次数
*
* @param req 请求参数
* @return 总次数
*/
@Transactional(rollbackFor = Exception.class)
public int incReportDownloadTimes(IncReportDownloadTimesReq req) {
ReportDownloadSummary record = reportDownloadSummaryMapper.selectOne(
Wrappers.<ReportDownloadSummary>lambdaQuery().eq(ReportDownloadSummary::getUserId, req.getUserId()));
if (record == null) {
reportDownloadSummaryMapper.insert(
ReportDownloadSummary.builder()
.userId(req.getUserId())
.reportTimesBuy(req.getIncTimes())
.build()
);
} else {
reportDownloadSummaryMapper.updateById(
ReportDownloadSummary.builder()
.id(record.getId())
.reportTimesBuy(record.getReportTimesBuy() + req.getIncTimes())
.build()
);
}
return record == null ? req.getIncTimes() : record.getReportTimesBuy() + req.getIncTimes();
}
}
......@@ -15,6 +15,7 @@
<result column="hold_fund_report_std" jdbcType="INTEGER" property="holdFundReportStd" />
<result column="free_total_limit" jdbcType="INTEGER" property="freeTotalLimit" />
<result column="std_vip_limit" jdbcType="INTEGER" property="stdVipLimit" />
<result column="report_times_buy" jdbcType="INTEGER" property="reportTimesBuy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
......@@ -22,6 +23,6 @@
<!--@mbg.generated-->
id, user_id, deep_report, deep_report_std, cumulative_profit_report, cumulative_profit_report_std,
weekly_monthly_report, hold_fund_report, hold_fund_report_std, free_total_limit,
std_vip_limit, create_time, update_time
std_vip_limit, report_times_buy, create_time, update_time
</sql>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment