|
@@ -581,45 +581,108 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
|
|
|
public Result porfitReportKuaiShou(SettlementFileParamsVo paramsVo, HttpServletResponse response) {
|
|
|
|
|
|
try {
|
|
|
- //查询 快手利润表 总花费
|
|
|
- List<Map<String,Object>> list = reportSettlementMapper.getProfitKuaiShou(paramsVo.getUploadYears());
|
|
|
+ //查询 快手利润表 时间段内的 所有账户
|
|
|
+ List<Map<String,Object>> list = reportSettlementMapper.getProfitKuaiShouAccountCost(null,paramsVo.getStartTime(),paramsVo.getEndTime());
|
|
|
if (Check.isNull(list)){
|
|
|
return Result.errorMsg("暂无数据。");
|
|
|
}
|
|
|
List<ProfitReportKuaiShouVo> resultList = new ArrayList<>(list.size());
|
|
|
for (Map<String, Object> map : list) {
|
|
|
- ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
|
|
|
- vo.setAccountId(map.getOrDefault("accountId","")+"");//账户id
|
|
|
- vo.setCost(map.getOrDefault("cost","")+"");//总消耗
|
|
|
- vo.setCashCost(map.getOrDefault("cashCost","")+"");//现金消耗
|
|
|
- vo.setProductName(map.getOrDefault("productName","")+"");//产品名称
|
|
|
+ //查看该账户 状态信息
|
|
|
+ QueryWrapper<CtopCwjsSettlementInfo> settlementAccountQw = new QueryWrapper<>();
|
|
|
+ settlementAccountQw.eq("account_id",map.get("accountId"));
|
|
|
+ //账户状态 0-开 1-关
|
|
|
+ settlementAccountQw.eq("status",0);
|
|
|
+ //(0,正常,1已删除)
|
|
|
+ settlementAccountQw.eq("del_flag",0);
|
|
|
+ List<CtopCwjsSettlementInfo> settlementAccountList = settlementInfoMapper.selectList(settlementAccountQw);
|
|
|
+ if (Check.isNull(settlementAccountList)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ ProfitReportKuaiShouVo voSource = new ProfitReportKuaiShouVo();
|
|
|
|
|
|
//查询销售
|
|
|
Map<String,Object> slaeMap = reportSettlementMapper.getProfitBytedanceSale(map.get("accountId")+"");
|
|
|
- vo.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName","")+"");//销售
|
|
|
-
|
|
|
- //查询 销售人员姓名 以及 返点类型和比列
|
|
|
- List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("productId")+"","2",paramsVo.getStartTime(),paramsVo.getEndTime());
|
|
|
- /* if (!Check.isNull(slaeMap)){
|
|
|
-
|
|
|
- // 当前查询时间 与 销售政策 开始 截至时间 是否匹配
|
|
|
- if (SettlementUtil.isEffectiveDate(paramsVo.getUploadYears(),rateMap.get("policyStart")+"",rateMap.get("policyEnd")+"")){
|
|
|
- //销售政策状态 为 通过 显示 返点类型 和 返点比列
|
|
|
- if (StringUtils.equals(rateMap.getOrDefault("approvedStatus","")+"","3")){
|
|
|
- vo.setRebateType(rateMap.getOrDefault("rebateType","")+"");//返点类型
|
|
|
- vo.setRebateRate(rateMap.getOrDefault("rebateRate","")+"");//返点比列
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
+ voSource.setSaleName(Check.isNull(slaeMap) ? "" : slaeMap.getOrDefault("saleName","")+"");//销售
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ voSource.setAccountId(map.getOrDefault("accountId","")+"");//账户id
|
|
|
+
|
|
|
+ voSource.setProductName(map.getOrDefault("productName","")+"");//产品名称
|
|
|
+
|
|
|
|
|
|
Map<String,Object> operateMap = reportSettlementMapper.getProfitKuaiShouOperate(map.get("accountId")+"");
|
|
|
if (!Check.isNull(operateMap)){
|
|
|
- vo.setKsId(operateMap.getOrDefault("ksId","")+"");//快手id
|
|
|
- vo.setAdvertiserName(operateMap.getOrDefault("advertiserName","")+"");//广告主名称
|
|
|
- vo.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
|
|
|
- vo.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
|
|
|
+ voSource.setKsId(operateMap.getOrDefault("ksId","")+"");//快手id
|
|
|
+ voSource.setAdvertiserName(operateMap.getOrDefault("advertiserName","")+"");//广告主名称
|
|
|
+ voSource.setOperateName(operateMap.getOrDefault("operateName","")+"");//运营
|
|
|
+ voSource.setOperateArea(operateMap.getOrDefault("operateArea","")+"");//运营所属区域
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询 快手利润表 返点类型和比列
|
|
|
+ List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("productName")+"","2",paramsVo.getStartTime(),paramsVo.getEndTime());
|
|
|
+ List listPolicyTIme = new ArrayList();
|
|
|
+ for (Map<String, Object> rate : rateMap) {
|
|
|
+ listPolicyTIme.add(rate.get("policyStartDate"));
|
|
|
+ listPolicyTIme.add(rate.get("policyEndDate"));
|
|
|
}
|
|
|
- resultList.add(vo);
|
|
|
+
|
|
|
+ //政策时间 去重 排序
|
|
|
+ List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
|
|
|
+ // 使用政策的时间段 拼接 开始 和 截至 时间
|
|
|
+ List<Map<String, String>> arrayList = new ArrayList<>();
|
|
|
+ for ( int i = 0; i < times.size(); i++) {
|
|
|
+ HashMap<String, String> mapTime = new HashMap<>();
|
|
|
+ mapTime.put("startDate", times.get(i).toString());
|
|
|
+ mapTime.put("endDate", times.get(i+1).toString());
|
|
|
+ i += 1;
|
|
|
+ arrayList.add(mapTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ //政策所有时间点
|
|
|
+ List<String> policyDaysList = new ArrayList<>();
|
|
|
+ for (Map<String, String> stringMap : arrayList) {
|
|
|
+ ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
|
|
|
+ //使用政策 返点类型和比例
|
|
|
+ Map<String,Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName")+"",stringMap.get("startDate"),stringMap.get("endDate"));
|
|
|
+ vo.setRebateType(policyRateMap.getOrDefault("rebateType","")+"");//返点类型
|
|
|
+ vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"");//返点比列
|
|
|
+ // 时间段内 账户流水 信息
|
|
|
+ List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitKuaiShouCost(map.get("accountId")+"",stringMap.get("startDate"),stringMap.get("endDate"));
|
|
|
+ listAccount.removeAll(Collections.singleton(null));
|
|
|
+ vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost","")+"");//总消耗
|
|
|
+ vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
|
|
|
+ BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
|
|
|
+ resultList.add(vo);
|
|
|
+ policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"),stringMap.get("endDate")));
|
|
|
+ }
|
|
|
+
|
|
|
+ //不使用政策 的时间段
|
|
|
+ // 获取两个日期之间 所有的 时间 年-月-日
|
|
|
+ List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(paramsVo.getStartTime(),paramsVo.getEndTime());
|
|
|
+ // 时间差集(所有时间段 - 使用政策的时间段)
|
|
|
+ List<String> reduceList = betweenDaysList.stream().filter(item -> !policyDaysList.contains(item)).collect(Collectors.toList());
|
|
|
+ //差集拼接 开始 和 结束时间
|
|
|
+ List<Map<String, String>> stringList = SettlementUtil.getTime(reduceList);
|
|
|
+ for (Map<String, String> stringMap : stringList) {
|
|
|
+ ProfitReportKuaiShouVo vo = new ProfitReportKuaiShouVo();
|
|
|
+ // 不使用 政策 则 返点为空
|
|
|
+ //政策 返点类型和比例
|
|
|
+ /* Map<String,Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("productName")+"",stringMap.get("startDate"),stringMap.get("endDate"));
|
|
|
+ */
|
|
|
+ vo.setRebateType("");//返点类型
|
|
|
+ vo.setRebateRate("");//返点比列
|
|
|
+ //账户流水 信息
|
|
|
+ List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitKuaiShouCost(map.get("accountId")+"",stringMap.get("startDate"),stringMap.get("endDate"));
|
|
|
+ listAccount.removeAll(Collections.singleton(null));
|
|
|
+ vo.setCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cost","")+"");//总消耗
|
|
|
+ vo.setCashCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("cashCost","")+"");//现金消耗
|
|
|
+ BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
|
|
|
+ resultList.add(vo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("快手利润单", "快手利润单"), ProfitReportKuaiShouVo.class, resultList);
|