Bladeren bron

Merge branch 'test'

yangzian 3 jaren geleden
bovenliggende
commit
ae10f14ab9
37 gewijzigde bestanden met toevoegingen van 1400 en 251 verwijderingen
  1. 1 1
      jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java
  2. 147 34
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java
  3. 21 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsSaleAssistantInfoController.java
  4. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsPolicyApprovalLog.java
  5. 14 6
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsPolicyInfo.java
  6. 4 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsSaleAssistantInfo.java
  7. 8 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsCompanyApprovalUserMapper.java
  8. 9 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyApprovalLogMapper.java
  9. 4 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsSaleAssistantInfoMapper.java
  10. 14 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsCompanyApprovalUserMapper.xml
  11. 8 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyApprovalLogMapper.xml
  12. 2 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml
  13. 71 13
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsSaleAssistantInfoMapper.xml
  14. 23 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICreateSheetService.java
  15. 9 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsCompanyApprovalUserService.java
  16. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsPolicyApprovalLogService.java
  17. 7 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsSaleAssistantInfoService.java
  18. 467 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CreateSheetServiceImpl.java
  19. 17 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsCompanyApprovalUserServiceImpl.java
  20. 2 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyApprovalLogServiceImpl.java
  21. 0 2
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java
  22. 96 9
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsSaleAssistantInfoServiceImpl.java
  23. 42 17
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java
  24. 16 31
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java
  25. 1 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SettlementReportKuaiShouVo.java
  26. 47 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SheetBytedanceVo.java
  27. 65 0
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SheetKuaiShouVo.java
  28. 16 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java
  29. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java
  30. 193 18
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml
  31. 43 40
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml
  32. 1 1
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml
  33. 42 57
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java
  34. 2 4
      jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java
  35. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java
  36. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml
  37. 1 1
      jeecg-cloud-module/pom.xml

+ 1 - 1
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -217,7 +217,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/kuaishou/batch/*", "anon");
         filterChainDefinitionMap.put("/dimension/kuaiShouDimensionAccount/*", "anon");
         filterChainDefinitionMap.put("/ai/projectCreate/*", "anon");
-        filterChainDefinitionMap.put("/cwjsPolicyInfo/**", "anon");
+        //filterChainDefinitionMap.put("/cwjsPolicyInfo/**", "anon");
         filterChainDefinitionMap.put("/ruleIndicator/**", "anon");
         filterChainDefinitionMap.put("/explores/**", "anon");
         filterChainDefinitionMap.put("/estimatePeopleNumber/**", "anon");

+ 147 - 34
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsPolicyInfoController.java

@@ -5,6 +5,7 @@ import java.util.*;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
+import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -30,6 +31,7 @@ import org.jeecg.ctop.finance.policy.entity.*;
 import org.jeecg.ctop.finance.policy.mapper.CwjsCompanyApprovalUserMapper;
 import org.jeecg.ctop.finance.policy.mapper.CwjsCompanySubjectMapper;
 import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyApprovalLogMapper;
+import org.jeecg.ctop.finance.policy.mapper.CwjsSaleAssistantInfoMapper;
 import org.jeecg.ctop.finance.policy.service.*;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.extern.slf4j.Slf4j;
@@ -75,7 +77,7 @@ public class CwjsPolicyInfoController {
 	 IUserCompanyService userCompanyService;
 	 @Autowired
 	 ICwjsPolicyApprovalLogService policyApprovalLogService;
-	 @Autowired
+	 @Resource
 	 CwjsCompanyApprovalUserMapper companyApprovalUserMapper;
 	 @Resource
 	 CwjsCompanySubjectMapper companySubjectMapper;
@@ -94,10 +96,13 @@ public class CwjsPolicyInfoController {
      @Resource
      private ReportSettlementServiceImpl reportSettlementService;
 
+	 @Autowired
+	 private ICwjsSaleAssistantInfoService cwjsSaleAssistantInfoService;
+
 
 	 @GetMapping(value = "/queryApprovalRejectReason")
 	 public Result<CwjsPolicyApprovalLog> queryApprovalRejectReason(@RequestParam(name="id",required=true) Integer id){
-		 CwjsPolicyApprovalLog policyApprovalLog = policyApprovalLogService.getOneByPolicyId(id);
+		 CwjsPolicyApprovalLog policyApprovalLog = policyApprovalLogService.getOneByPolicyId(id,1);
 		 if(Check.isNull(policyApprovalLog)){
 			 return Result.successMsg("无审核拒绝的记录",null);
 		 }else{
@@ -106,6 +111,14 @@ public class CwjsPolicyInfoController {
 
 	 }
 
+	 /**
+	  * 审核
+	  * @param id 政策id
+	  * @param type 类型
+	  * @param userId 用户id
+	  * @param approvalContent 审核内容
+	  * @return
+	  */
 	 @GetMapping(value = "/policyApproval")
 	 public Result policyApproval(@RequestParam(name="id",required=true) Integer id,
 	 							@RequestParam(name="type",required=true) Integer type,
@@ -114,10 +127,14 @@ public class CwjsPolicyInfoController {
 //		LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
 		CwjsPolicyInfo cwjsPolicyInfoEntity = cwjsPolicyInfoService.getById(id);
 		 if(cwjsPolicyInfoEntity==null) {
-			 return Result.error("参数传递有误");
+			 return Result.error("政策不存在或已被删除,请重新选择要审核的政策。");
 		 }
+		 //获取 主体
 		 Integer companySubjectId= cwjsPolicyInfoEntity.getCompanySubjectId();
+
+		 // 当前用户是否是审核人
 		 CwjsCompanyApprovalUser cwjsCompanyApprovalUser = companyApprovalUserMapper.queryByCompanySubjectIdAndUserId(companySubjectId, userId);
+
 		 if(type == 1){	//审核提交	等于新增的时候
 			 List<CwjsCompanyApprovalUser> cwjsCompanyApprovalUsers = companyApprovalUserMapper.queryByCompanySubjectId(companySubjectId);
 			 if(Check.isNull(cwjsCompanyApprovalUsers)){
@@ -152,17 +169,17 @@ public class CwjsPolicyInfoController {
 			 corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
 		}
 		 if(type == 2){	//审核通过  是不是终审,不是就给当前的下一个人发企业微信
-			 CwjsCompanyApprovalUser nextApprovalUser = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser.getLevel() + 1);
-			 if(!Check.isNull(cwjsCompanyApprovalUser) && Check.isNull(nextApprovalUser)){//没有下一个审核人员,是终审
+			 CwjsCompanyApprovalUser nextApprovalUser = null;
+			 //查询 下一个 审核人
+		 	if(!Check.isNull(cwjsCompanyApprovalUser)){
+				nextApprovalUser = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser.getLevel() + 1);
+			}
+			 if(Check.isNull(nextApprovalUser)){//没有下一个审核人员,是终审
 				cwjsPolicyInfoEntity.setApprovedStatus(3);
-
 				 /**
 				  * 终审通过后 添加 起始时间
 				  */
-
 				 reportSettlementService.cwjsPRofit(cwjsPolicyInfoEntity);
-
-
 			}else{	//不是终审
 				cwjsPolicyInfoEntity.setApprovedStatus(2);
 				cwjsPolicyInfoEntity.setApprovedProgress(nextApprovalUser.getApprovalUserId());	//设置一下个人为审核人员
@@ -197,10 +214,46 @@ public class CwjsPolicyInfoController {
 			text.append(",请及时登录助手平台-销售政策页面进行政策修改,谢谢!");
 			corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
 		}
+
+	 	//转领导审批 只有审核人是最后一个人的时候 才可以转领导
+	 	if (type == 4){
+			//根据主体查询 最后一个审核人员
+			CwjsCompanyApprovalUser endApprovalUser = companyApprovalUserMapper.getEndApprovalUserBySub(companySubjectId);
+			if (!Check.isNull(endApprovalUser)){
+				if (!userId.equals(endApprovalUser.getApprovalUserId())){
+					return Result.errorMsg("当前所登录用户不是最后一个审核人员,无法转领导审批。");
+				}
+			}
+			cwjsPolicyInfoEntity.setApprovedStatus(2);
+			cwjsPolicyInfoEntity.setApprovedProgress("80e747cdea6f41dbbc8cde23046fd4e0");	//设置 boss 为审核人员
+			JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("80e747cdea6f41dbbc8cde23046fd4e0");
+			StringBuilder text = new StringBuilder();
+			text.append("您有一条销售政策需要审核,该客户为:");
+			text.append(cwjsPolicyInfoEntity.getCompanyName());
+			text.append(",请及时登录助手平台-销售政策页面进行审核,谢谢!");
+			corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
+
+			CwjsPolicyApprovalLog policyApprovalLog = new CwjsPolicyApprovalLog();
+			policyApprovalLog.setPolicyId(id);
+			policyApprovalLog.setCreateUserId(userId);
+			policyApprovalLog.setApprovalStatus(2);//0-审核通过  1-审核不通过 2-转给领导
+			policyApprovalLog.setApprovalContent(approvalContent);
+			policyApprovalLogService.save(policyApprovalLog);
+
+
+		}
+
+
+
+
+
 		cwjsPolicyInfoService.updateById(cwjsPolicyInfoEntity);
 	 	return Result.successMsg("成功",cwjsPolicyInfoEntity);
 	 }
 
+
+	 @Resource
+	 private CwjsSaleAssistantInfoMapper cwjsSaleAssistantInfoMapper;
 	/**
 	  * 分页列表查询
 	 * @param cwjsPolicyInfo
@@ -214,22 +267,45 @@ public class CwjsPolicyInfoController {
 	public Result<PageInfo<CwjsPolicyInfo>> queryPageList(CwjsPolicyInfo cwjsPolicyInfo,
 									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
-									  @RequestParam(name="userId",required=true) String userId,
+									  @RequestParam(name="userId") String userId,
 									  HttpServletRequest req) {
 
+		//查询用户角色
         String roleCode = roleService.getRoleCodeByUserId(userId);
+        //查看用户是否为审核人员
         List<CwjsCompanyApprovalUser> cwjsCompanyApprovalUserList = companyApprovalUserMapper.queryByUserId(userId);
+        //查询政策
 		List<CwjsPolicyInfo> cwjsPolicyInfoList = cwjsPolicyInfoService.queryPageList(cwjsPolicyInfo);
 		if(Check.isNull(cwjsPolicyInfoList)){
 			PageInfo<CwjsPolicyInfo> pageInfo = new PageInfo<>(cwjsPolicyInfoList);
-			return Result.successMsg("目前没有政策,请新增",pageInfo);
+			return Result.successMsg("目前没有政策",pageInfo);
 		}
         /**如果是管理员,就全部看,该搜索搜索,不搜索就全看*/
 
-        /**如果不是管理员,也不是审核人员。看自己和自己下属的所有政策。*/
+		List<String> res = new ArrayList<>();
+		if ("admin".equalsIgnoreCase(roleCode) || "finance".equalsIgnoreCase(roleCode) ){
+
+		}else if("saleDirector".equalsIgnoreCase(roleCode)){
+			//销售总监 看下属
+			res = cwjsPolicyInfoService.getAllSubordinate(userId);
+		}else {
+			//查询 对应的销售或 助理
+			res = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
+			if (Check.isNull(res)){
+				res.add(userId);
+			}
+		}
+
+		List<String> userIds = new ArrayList<>();
+
+		userIds.addAll(res);
+
+        /**如果不是管理员,也不是审核人员。
+		 * (看自己和自己下属的所有政策)  修改为 销售-助理 关联关系查看。
+		 * */
         if(!"admin".equalsIgnoreCase(roleCode) && !"finance".equalsIgnoreCase(roleCode) && Check.isNull(cwjsCompanyApprovalUserList)){
-//			Set<String> userIds= materialReportOverViewService.recursiveQuerySubordinate(userId);
-			List<String> userIds = cwjsPolicyInfoService.getAllSubordinate(userId);
+			//Set<String> userIds= materialReportOverViewService.recursiveQuerySubordinate(userId);
+			//List<String> userIds = cwjsPolicyInfoService.getAllSubordinate(userId);
 			List<CwjsPolicyInfo> removeList = new ArrayList<>();
             cwjsPolicyInfoList.forEach(cwjsPolicy -> {
                 if(!userIds.contains(cwjsPolicy.getCreateUserId())){
@@ -241,8 +317,7 @@ public class CwjsPolicyInfoController {
         /**如果不是管理员,是审核人员。看自己创建的和自己下属的所有政策、和该自己审核。*/
         if(!"admin".equalsIgnoreCase(roleCode) && !"finance".equalsIgnoreCase(roleCode) && !Check.isNull(cwjsCompanyApprovalUserList)){
 //			Set<String> userIds= materialReportOverViewService.recursiveQuerySubordinate(userId);
-			List<String> userIds = cwjsPolicyInfoService.getAllSubordinate(userId);
-
+			//List<String> userIds = cwjsPolicyInfoService.getAllSubordinate(userId);
 			List<CwjsPolicyInfo> removeList = new ArrayList<>();
             cwjsPolicyInfoList.forEach(cwjsPolicy -> {
                 if(!userIds.contains(cwjsPolicy.getCreateUserId()) && !userId.equalsIgnoreCase(cwjsPolicy.getApprovedProgress())){
@@ -252,29 +327,59 @@ public class CwjsPolicyInfoController {
             cwjsPolicyInfoList.removeAll(removeList);
         }
 
-
 		cwjsPolicyInfoList.sort((CwjsPolicyInfo o1, CwjsPolicyInfo o2) -> o2.getCreateTime().after(o1.getCreateTime()) ? 1 : -1 );
 		List<CwjsPolicyInfo> cwjsPolicyInfos = ListPageUtil.page(cwjsPolicyInfoList, pageSize, pageNo);
 
 		cwjsPolicyInfos.forEach(cwjsPolicy ->{
-			CwjsPolicyApprovalLog log = policyApprovalLogMapper.getOneByPolicyId(cwjsPolicy.getId());	//添加日志记录最新的第一条
+			CwjsPolicyApprovalLog log = policyApprovalLogMapper.getOneByPolicyId(cwjsPolicy.getId(),1);	// 查询 被拒 审核意见 最新的一条
 			if(!Check.isNull(log)){
 				cwjsPolicy.setApprovalContent(log.getApprovalContent());
 			}
-            cwjsPolicy.setOperation("查看");  //所有人只要能看到就能有查看的按钮
-			if(userId.equals(cwjsPolicy.getCreateUserId()) && cwjsPolicy.getApprovedStatus() == 4){ //创建人是自己且状态是审核拒绝的
+			CwjsPolicyApprovalLog bossContent = policyApprovalLogMapper.getOneByPolicyId(cwjsPolicy.getId(),2);	// 查询 转发领导的 审核意见 最新的一条
+			cwjsPolicy.setTheBossContent(Check.isNull(bossContent) ? "" : bossContent.getApprovalContent());
+
+			//根据主体查询 最后一个审核人员
+			CwjsCompanyApprovalUser approvalUser = companyApprovalUserMapper.getEndApprovalUserBySub(cwjsPolicy.getCompanySubjectId());
+			//政策当前审核人 = 最后一个审核人 = 当前用户   && 状态不为3 审核通过  && 状态不为4 审核拒绝  ||  当前用户 不是老板
+			// 则显示 转领导审批
+
+			if(cwjsPolicy.getApprovedStatus() != 3 && cwjsPolicy.getApprovedStatus() != 4){
+				if (cwjsPolicy.getApprovedProgress().equals(approvalUser.getApprovalUserId()) && approvalUser.getApprovalUserId().equals(userId)
+						&& !"80e747cdea6f41dbbc8cde23046fd4e0".equals(userId)){
+					cwjsPolicy.setTheBossRight("yes");
+				}
+			}else {
+				cwjsPolicy.setTheBossRight("no");
+			}
+
+
+
+
+			//所有人只要能看到就能有查看的按钮
+            cwjsPolicy.setOperation("查看");
+
+			//查询助理
+			//List <String> assistantList = cwjsSaleAssistantInfoMapper.getCwAssistantNameListPolicy(userId);
+			if((userIds.contains(userId) || userId.equals(cwjsPolicy.getCreateUserId())) && cwjsPolicy.getApprovedStatus() == 4){ //创建人是自己且状态是审核拒绝的
                 cwjsPolicy.setOperation("查看|编辑|提交审核");
             }
 
 			if(userId.equals(cwjsPolicy.getApprovedProgress()) && (cwjsPolicy.getApprovedStatus() == 1 || cwjsPolicy.getApprovedStatus() == 2)){
                 cwjsPolicy.setOperation("查看|审核通过|审核拒绝");
             }
+			if(userId.equals(cwjsPolicy.getApprovedProgress()) && cwjsPolicy.getApprovedStatus() == 4){
+                cwjsPolicy.setOperation("查看");
+            }
+
 
-			UserCompany userCompany = userCompanyService.getByUserId(cwjsPolicy.getCreateUserId());
 
+
+			// 用户 公司
+			UserCompany userCompany = userCompanyService.getByUserId(cwjsPolicy.getCreateUserId());
 			if(!Check.isNull(userCompany) && Check.isNull(cwjsPolicy.getCreateUserName())){
 				cwjsPolicy.setCreateUserName(userCompany.getUserName());
 			}
+			//主体 以及 区域
 			CwjsCompanySubject cwjsCompanySubject = companySubjectService.getById(cwjsPolicy.getCompanySubjectId());
 			cwjsPolicy.setCompanySubjectName(cwjsCompanySubject.getCompanySubjectName());
 			cwjsPolicy.setAreaInfo(cwjsCompanySubject.getAreaInfo());
@@ -316,7 +421,7 @@ public class CwjsPolicyInfoController {
 	}
 
 	 /**
-	  * 获取当前用户的公司、区域、和主体
+	  * 获取当前用户的公司、区域、和主体 修改
 	  * @param userId
 	  * @return
 	  */
@@ -367,25 +472,33 @@ public class CwjsPolicyInfoController {
 					cwjsPolicyInfo.setApprovedProgress(cwjsCompanyApprovalUser.getApprovalUserId());
 				}
 			});
-			//如果满足有审核人员等于当前创建的人,并且
-			cwjsCompanyApprovalUsers.forEach(cwjsCompanyApprovalUser -> {
-				if(cwjsCompanyApprovalUser.getApprovalUserId().equalsIgnoreCase(cwjsPolicyInfo.getCreateUserId())){
-					CwjsCompanyApprovalUser approvalUserNext = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser.getLevel()+1);
-					if(Check.isNull(approvalUserNext)){
-						cwjsPolicyInfo.setApprovedStatus(3);
-						cwjsPolicyInfo.setApprovedProgress(null);
-					}else{
-						cwjsPolicyInfo.setApprovedStatus(2);
-						cwjsPolicyInfo.setApprovedProgress(approvalUserNext.getApprovalUserId());
+			//如果满足有审核人员等于当前创建的人,
+			//当前用户 和 选择的销售(创建人) 相同
+			LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+			if(user.getId().equals(cwjsPolicyInfo.getCreateUserId())){
+				cwjsCompanyApprovalUsers.forEach(cwjsCompanyApprovalUser -> {
+					if(cwjsCompanyApprovalUser.getApprovalUserId().equalsIgnoreCase(cwjsPolicyInfo.getCreateUserId())){
+						CwjsCompanyApprovalUser approvalUserNext = companyApprovalUserMapper.queryByCompanySubjectIdAndLevel(companySubjectId, cwjsCompanyApprovalUser.getLevel()+1);
+						if(Check.isNull(approvalUserNext)){
+							cwjsPolicyInfo.setApprovedStatus(3);
+							cwjsPolicyInfo.setApprovedProgress(null);
+						}else{
+							cwjsPolicyInfo.setApprovedStatus(2);
+							cwjsPolicyInfo.setApprovedProgress(approvalUserNext.getApprovalUserId());
+						}
 					}
-				}
-			});
+				});
+			}
+
+
 
 			if(cwjsPolicyInfo.getAdvancePay() == 1){
 				cwjsPolicyInfo.setIsDianPay(null);
 				cwjsPolicyInfo.setDianPayCompanyName(null);
 				cwjsPolicyInfo.setDianPayCompanyRebateRate(null);
 			}
+			SysUser sysUser = sysUserService.getById(cwjsPolicyInfo.getCreateUserId());
+			cwjsPolicyInfo.setCreateUserName(sysUser.getRealname());
 
 			cwjsPolicyInfoService.save(cwjsPolicyInfo);
 			JSONArray products = cwjsPolicyInfo.getPolicyProductName();

+ 21 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/controller/CwjsSaleAssistantInfoController.java

@@ -12,6 +12,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.query.QueryRuleEnum;
 import org.jeecg.common.util.oConvertUtils;
 import java.util.Date;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -22,6 +23,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo;
 import org.jeecg.ctop.finance.policy.service.ICwjsSaleAssistantInfoService;
 import org.jeecg.ctop.finance.policy.utils.Check;
+import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.jeecg.modules.system.service.ISysRoleService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -74,6 +76,7 @@ public class CwjsSaleAssistantInfoController {
 															  HttpServletRequest req) {
 		Result<IPage<CwjsSaleAssistantInfo>> result = new Result<>();
 		QueryWrapper<CwjsSaleAssistantInfo> queryWrapper = QueryGenerator.initQueryWrapper(cwjsSaleAssistantInfo, req.getParameterMap());
+		queryWrapper.orderByDesc("update_time");
 		Page<CwjsSaleAssistantInfo> page = new Page<CwjsSaleAssistantInfo>(pageNo, pageSize);
 		IPage<CwjsSaleAssistantInfo> pageList = cwjsSaleAssistantInfoService.page(page, queryWrapper);
 		result.setSuccess(true);
@@ -91,6 +94,7 @@ public class CwjsSaleAssistantInfoController {
 	public Result<CwjsSaleAssistantInfo> add(@RequestBody CwjsSaleAssistantInfo cwjsSaleAssistantInfo) {
 		Result<CwjsSaleAssistantInfo> result = new Result<>();
 		try {
+			cwjsSaleAssistantInfo.setCreateTime(new Date());
 			cwjsSaleAssistantInfoService.save(cwjsSaleAssistantInfo);
 			result.success("添加成功!");
 		} catch (Exception e) {
@@ -185,7 +189,7 @@ public class CwjsSaleAssistantInfoController {
 	 	//查询用户角色
 		 String roleCode = roleService.getRoleCodeByUserId(userId);
 		 //管理员 查询全部
-		 if (StringUtils.equals("admin",roleCode)){
+		 if (StringUtils.equals("admin",roleCode) || StringUtils.equals("finance",roleCode)){
 		 	userId = null;
 		 }
 		return cwjsSaleAssistantInfoService.getSaleListByUserDepart(userId);
@@ -193,13 +197,26 @@ public class CwjsSaleAssistantInfoController {
 	 }
 
 
-
 	 @ApiOperation(value="政策新增-销售回显下拉框", notes="政策新增-销售回显下拉框")
 	 @GetMapping(value = "/getCwSaleAndAssistantList")
-	 public Result<IPage<CwjsSaleAssistantInfo>> getCwSaleAndAssistantList(@RequestParam(name="userId") String userId) {
-		return cwjsSaleAssistantInfoService.getCwSaleAndAssistantList(userId);
+	 public Result getCwSaleAndAssistantList(@RequestParam(name="userId") String userId) {
+		List<CwjsSaleAssistantInfo> list = cwjsSaleAssistantInfoService.getCwSaleAndAssistantList(userId);
+		return Result.successMsg("查询成功。",list);
+	 }
+
+
+
+
+	 @ApiOperation(value="政策-筛选广告主", notes="政策-筛选广告主")
+	 @GetMapping(value = "/cwjsParticipateList")
+	 public Result cwjsParticipateList(@RequestBody ProjectMember projectMember) {
+		 return  cwjsSaleAssistantInfoService.cwjsParticipateList(projectMember);
 
 	 }
 
 
+
+
+
+
 }

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsPolicyApprovalLog.java

@@ -38,7 +38,7 @@ public class CwjsPolicyApprovalLog {
 	private Integer policyId;
 	/**审核状态:0-审核通过  1-审核不通过*/
 	@Excel(name = "审核状态:0-审核通过  1-审核不通过", width = 15)
-    @ApiModelProperty(value = "审核状态:0-审核通过  1-审核不通过")
+    @ApiModelProperty(value = "审核状态:0-审核通过  1-审核不通过 2-转老板")
 	private Integer approvalStatus;
 	/**审核意见*/
 	@Excel(name = "审核意见", width = 15)

+ 14 - 6
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsPolicyInfo.java

@@ -14,10 +14,10 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
 
+
+
 /**
  * 政策信息表
  * @author jeecg-boot
@@ -29,7 +29,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
 @EqualsAndHashCode(callSuper = false)
 @Accessors(chain = true)
 @ApiModel(value="ctop_cwjs_policy_info对象", description="政策信息表")
-public class CwjsPolicyInfo {
+public class CwjsPolicyInfo implements Serializable{
     
 	/**自增主键*/
 	@TableId(type = IdType.AUTO)
@@ -56,10 +56,10 @@ public class CwjsPolicyInfo {
     @ApiModelProperty(value = "集团简称")
 	private String groupAbbreviation;
 	/**状态 0:待审核 1:审核中 2:审核通过3:审核拒绝*/
-	@Excel(name = "状态 0:待审核 1:审核中 2:审核通过3:审核拒绝", width = 15)
-    @ApiModelProperty(value = "状态 0:待审核 1:审核中 2:审核通过3:审核拒绝")
+	@Excel(name = "状态 0:草稿 1:待审核 2:审核中 3:审核通过4:审核拒绝", width = 15)
+    @ApiModelProperty(value = "0:草稿 1:待审核 2:审核中 3:审核通过4:审核拒绝")
 	private Integer approvedStatus;
-	@ApiModelProperty(value = "审核进度,当前该谁审核")
+	@ApiModelProperty(value = "审核进度,当前该谁审核,审核人")
 	private String approvedProgress;
 	/**是否预付:0:否  1:是 */
 	@Excel(name = "是否预付:0:否  1:是 ", width = 15)
@@ -149,4 +149,12 @@ public class CwjsPolicyInfo {
 	/**区域 华北,华南,华东*/
 	@TableField(exist = false)
 	private String areaInfo;
+
+
+	/* 是否显示老板审批的 操作 yes显示 no 不显示*/
+	@TableField(exist = false)
+	private String theBossRight;
+	/* 给老板审核的理由*/
+	@TableField(exist = false)
+	private String theBossContent;
 }

+ 4 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsSaleAssistantInfo.java

@@ -53,4 +53,8 @@ public class CwjsSaleAssistantInfo {
 	/**updateTime*/
     @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
+
+	@TableField(exist = false)
+    private String nickName;
+
 }

+ 8 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsCompanyApprovalUserMapper.java

@@ -20,4 +20,12 @@ public interface CwjsCompanyApprovalUserMapper extends BaseMapper<CwjsCompanyApp
     List<CwjsCompanyApprovalUser> queryByCompanySubjectId(Integer companySubjectId);
 
     CwjsCompanyApprovalUser queryByCompanySubjectIdAndLevel(Integer companySubjectId, Integer level);
+
+
+    /**
+     * 根据主体查询 最后一个审核人员
+     * @param companySubjectId
+     * @return
+     */
+    CwjsCompanyApprovalUser getEndApprovalUserBySub(Integer companySubjectId);
 }

+ 9 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyApprovalLogMapper.java

@@ -13,5 +13,13 @@ import org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog;
  * @version V1.0
  */
 public interface CwjsPolicyApprovalLogMapper extends BaseMapper<CwjsPolicyApprovalLog> {
-    CwjsPolicyApprovalLog getOneByPolicyId(Integer policyId);
+
+
+    /**
+     * 根据政策id 查询 审核意见记录
+     * @param policyId
+     * @param status 0-审核通过  1-审核不通过 2-转给领导'
+     * @return
+     */
+    CwjsPolicyApprovalLog getOneByPolicyId(@Param("policyId") Integer policyId,@Param("status") Integer status);
 }

+ 4 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsSaleAssistantInfoMapper.java

@@ -34,4 +34,8 @@ public interface CwjsSaleAssistantInfoMapper extends BaseMapper<CwjsSaleAssistan
      * @return
      */
     List <CwjsSaleAssistantInfo> getCwAssistantNameList(String userId);
+
+    List <CwjsSaleAssistantInfo> getAssistantList(String userId);
+
+    List <String> getCwAssistantNameListPolicy(String userId);
 }

+ 14 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsCompanyApprovalUserMapper.xml

@@ -8,9 +8,22 @@
         select * from ctop_cwjs_company_approval_user where approval_user_id = #{userId}
     </select>
     <select id="queryByCompanySubjectId" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
-        select * from ctop_cwjs_company_approval_user where company_subject_id = #{companySubjectId}
+        select * from ctop_cwjs_company_approval_user where company_subject_id = #{companySubjectId} ORDER BY level
     </select>
     <select id="queryByCompanySubjectIdAndLevel" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
         select * from ctop_cwjs_company_approval_user where company_subject_id = #{companySubjectId} and level = #{level}
     </select>
+
+
+
+<!-- 根据主体查询 最后一个审核人员-->
+    <select id="getEndApprovalUserBySub" resultType="org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser">
+        select * from ctop_cwjs_company_approval_user
+        where del_flag = 0
+        and company_subject_id = #{companySubjectId}
+        ORDER BY level DESC
+            limit 1
+    </select>
+
+
 </mapper>

+ 8 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyApprovalLogMapper.xml

@@ -1,7 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.ctop.finance.policy.mapper.CwjsPolicyApprovalLogMapper">
+
+
+    <!-- 根据政策id 查询 审核意见记录  -->
     <select id="getOneByPolicyId" resultType="org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog">
-        select * from ctop_cwjs_policy_approval_log where policy_id = #{policyId} and approval_status = 1 order by create_time desc LIMIT 1
+        select * from ctop_cwjs_policy_approval_log
+        where policy_id = #{policyId}
+          and approval_status = #{status}
+        order by create_time desc
+        LIMIT 1
     </select>
 </mapper>

+ 2 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsPolicyInfoMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper">
     <select id="selectPolicyInfos" resultType="org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo">
         select t1.policy_product_name as productName,t2.* from ctop_cwjs_policy_product t1 LEFT JOIN ctop_cwjs_policy_info t2 on t1.policy_id = t2.id
-        where 1=1
+        where t1.del_flag = 0 and t2.del_flag = 0
         <if test="companyName != null and companyName != ''">and t2.company_name like concat(concat('%',#{companyName}),'%')</if>
         <if test="advertiserName != null and advertiserName != ''">and t2.advertiser_name like concat(concat('%',#{advertiserName}),'%')</if>
         <if test="productName != null and productName != ''">and t1.policy_product_name like concat(concat('%',#{productName}),'%')</if>
@@ -103,7 +103,7 @@
 
     <select id="getAllSaleByUserId" resultType="com.alibaba.fastjson.JSONObject">
         SELECT distinct t1.create_user_id AS 'userId',
-	           t1.create_user_name AS 'userName'
+        (SELECT su.realname from sys_user su where su.id = t1.create_user_id) AS 'userName'
         FROM
             ctop_cwjs_policy_info t1
         WHERE

+ 71 - 13
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/xml/CwjsSaleAssistantInfoMapper.xml

@@ -6,14 +6,16 @@
     <!-- 根据用户部门查看该部门下的人员-->
     <select id="getSaleListByUserDepart" resultType="org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo">
         SELECT
-            id as saleId,
-            realname as saleName
+        us.id as saleId,
+        us.realname as saleName,
+        uc.nick_name as nickName
         FROM
-            sys_user
+            sys_user us
+        LEFT JOIN user_company uc on us.id = uc.user_id
         WHERE
-            STATUS = 1
-          AND del_flag = 0
-          AND org_code IN (
+        us.STATUS = 1
+        AND us.del_flag = 0
+        AND us.org_code IN (
             SELECT
                 u.org_code
             FROM
@@ -36,16 +38,18 @@
                 d.id
         )
         ORDER BY
-            create_time
+        us.create_time DESC;
     </select>
 
 <!--查询对应销售 -->
     <select id="getCwSaleNameList" resultType="org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo">
         SELECT
             u.id AS sale_id,
-            u.realname AS sale_name
+            u.realname AS sale_name,
+        uc.nick_name as nickName
         FROM
             sys_user u
+        LEFT JOIN user_company uc on u.id = uc.user_id
         WHERE
                 u.id IN ( SELECT s.sale_id FROM ctop_cwjs_sale_assistant_info s WHERE s.del_flag = 0
                             <if test="userId !=null and userId != ''">
@@ -53,19 +57,23 @@
                             </if>
                         )
         <if test="userId !=null and userId != ''">
-            OR u.id = #{userId};
+            OR u.id = #{userId}
         </if>
-        GROUP BY u.create_time DESC
+        GROUP BY u.create_time;
 
 
     </select>
+
+
     <!--查询对应销售助理 -->
     <select id="getCwAssistantNameList" resultType="org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo">
         SELECT
             u.id AS sale_id,
-            u.realname as sale_name
+            u.realname as sale_name,
+        uc.nick_name as nickName
         FROM
             sys_user u
+        LEFT JOIN user_company uc on u.id = uc.user_id
         WHERE
                 u.id IN ( SELECT s.sale_id FROM ctop_cwjs_sale_assistant_info s WHERE s.del_flag = 0
                             <if test="userId !=null and userId != ''">
@@ -73,9 +81,59 @@
                             </if>
                         )
         <if test="userId !=null and userId != ''">
-            OR u.id = #{userId};
+            OR u.id = #{userId}
         </if>
-        GROUP BY u.create_time DESC
+        GROUP BY u.create_time;
+    </select>
+
+    <!-- -->
+    <select id="getAssistantList" resultType="org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo">
+        SELECT
+        u.id AS sale_id,
+        u.realname as sale_name,
+        uc.nick_name as nickName
+        FROM
+        sys_user u
+        LEFT JOIN user_company uc on u.id = uc.user_id
+        WHERE
+        u.id IN (
+        SELECT
+        s.sale_id
+        FROM
+        ctop_cwjs_sale_assistant_info s
+        WHERE
+        s.del_flag = 0
+        <if test="userId !=null and userId != ''">
+            AND s.sale_id = #{userId} OR s.assistant_id = #{userId}
+        </if>
+        UNION
+        SELECT
+        s.assistant_id
+        FROM
+        ctop_cwjs_sale_assistant_info s
+        WHERE
+        s.del_flag = 0
+        <if test="userId !=null and userId != ''">
+            AND s.sale_id = #{userId} OR s.assistant_id = #{userId}
+        </if>
+            )
+    </select>
+
+
+    <!--查询对应销售助理 政策 -->
+    <select id="getCwAssistantNameListPolicy" resultType="java.lang.String">
+        SELECT
+            u.id AS sale_id
+        FROM
+            sys_user u
+        LEFT JOIN user_company uc on u.id = uc.user_id
+        WHERE
+                u.id IN ( SELECT s.sale_id FROM ctop_cwjs_sale_assistant_info s WHERE s.del_flag = 0
+                            <if test="userId !=null and userId != ''">
+                                AND s.assistant_id = #{userId}
+                            </if>
+                        )
+        GROUP BY u.create_time;
     </select>
 
 

+ 23 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICreateSheetService.java

@@ -0,0 +1,23 @@
+package org.jeecg.ctop.finance.policy.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ *
+ * @author jeecg-boot
+ * 2021-07-27
+ * @version V1.0
+ */
+public interface ICreateSheetService {
+
+    void createBytedance(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList,String uploadYears);
+
+    void createKuaiShou(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList,String uploadYears);
+}

+ 9 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsCompanyApprovalUserService.java

@@ -11,4 +11,13 @@ import org.jeecg.ctop.finance.policy.entity.CwjsCompanyApprovalUser;
  */
 public interface ICwjsCompanyApprovalUserService extends IService<CwjsCompanyApprovalUser> {
 
+
+    /**
+     * 根据主体查询 最后一个审核人员
+     * @param companySubjectId
+     * @return
+     */
+    CwjsCompanyApprovalUser getEndApprovalUserBySub(Integer companySubjectId);
+
+
 }

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsPolicyApprovalLogService.java

@@ -10,5 +10,5 @@ import org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog;
  * @version V1.0
  */
 public interface ICwjsPolicyApprovalLogService extends IService<CwjsPolicyApprovalLog> {
-    CwjsPolicyApprovalLog getOneByPolicyId(Integer policyId);
+    CwjsPolicyApprovalLog getOneByPolicyId(Integer policyId,Integer status);
 }

+ 7 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsSaleAssistantInfoService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
+import org.jeecg.modules.ctop.entity.ProjectMember;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
@@ -18,6 +19,11 @@ public interface ICwjsSaleAssistantInfoService extends IService<CwjsSaleAssistan
 
     Result getSaleListByUserDepart(String userId);
 
-    Result getCwSaleAndAssistantList(String userId);
+    List<CwjsSaleAssistantInfo> getCwSaleAndAssistantList(String userId);
+
+    List<String> getCwSaleAndAssistantListStr(String userId);
+
+
+    Result cwjsParticipateList(ProjectMember projectMember);
 
 }

+ 467 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CreateSheetServiceImpl.java

@@ -0,0 +1,467 @@
+package org.jeecg.ctop.finance.policy.service.impl;
+
+import cn.com.ctop.common.module.mapper.SysUserMapper;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.jeecg.common.system.entity.SysUser;
+import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
+import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
+import org.jeecg.ctop.finance.policy.service.ICreateSheetService;
+import org.jeecg.ctop.finance.policy.service.ICwjsPolicyInfoService;
+import org.jeecg.ctop.finance.policy.utils.Check;
+import org.jeecg.ctop.finance.settlement.entity.vo.*;
+import org.jeecg.ctop.finance.settlement.mapper.ReportSettlementMapper;
+import org.jeecg.ctop.finance.utils.SettlementUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ *
+ * @author jeecg-boot
+ * 2021-07-27
+ * @version V1.0
+ */
+@Service
+public class CreateSheetServiceImpl implements ICreateSheetService {
+
+    @Resource
+    private ReportSettlementMapper reportSettlementMapper;
+
+
+    public void createBytedance(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList,String uploadYears){
+        DecimalFormat sf  = new DecimalFormat("#.####");//保留四位小数
+        //2:创建sheet 设置sheet名称
+        HSSFSheet sheet = wb.createSheet("汇总页");
+        //3:添加 第一行单元格
+        HSSFRow row0 = sheet.createRow(0);
+        HSSFCell cell0 = row0.createCell(0);
+        //设置 第一行 表头
+        cell0.setCellValue(uploadYears+"-头条结算单汇总");
+        CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
+        sheet.addMergedRegion(region);//合并行
+        cell0.setCellStyle(style);
+        //4:添加表头2行
+        HSSFRow row = sheet.createRow(1);
+        //5:创建第2行的单元格
+        HSSFCell cell = row.createCell(0);     //第一个单元格
+        cell.setCellValue("日期");         //设定值
+        cell.setCellStyle(style);          //内容居中
+        cell = row.createCell(1);
+        cell.setCellValue("账户名称");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(2);
+        cell.setCellValue("账户ID");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(3);
+        cell.setCellValue("所属代理商名称");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(4);
+        cell.setCellValue("所属代理商ID");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(5);
+        cell.setCellValue("账户总支出(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(6);
+        cell.setCellValue("账户现金支出(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(7);
+        cell.setCellValue("账户赠款支出(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(8);
+        cell.setCellValue("账户总存入(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(9);
+        cell.setCellValue("账户总转入(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(10);
+        cell.setCellValue("账户总转出(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(11);
+        cell.setCellValue("账户日终结余(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(12);
+        cell.setCellValue("冻结(¥)");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(13);
+        cell.setCellValue("返点类型");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(14);
+        cell.setCellValue("返点比例");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(15);
+        cell.setCellValue("政策时间");
+        cell.setCellStyle(style);
+        sheet.autoSizeColumn(0, true);
+        List<SheetBytedanceVo> resultList = new ArrayList<>(accountIdList.size());
+        //查看账户数据
+        List<Map<String,Object>> list = reportSettlementMapper.getAccountTransactionDayBytedanceSheet(accountIdList,uploadYears);
+        for (Map<String,Object> map : list) {
+            SheetBytedanceVo voSource = new SheetBytedanceVo();
+            voSource.setAgentId(map.get("agentId")+"");
+            voSource.setAgentName(map.get("agentName")+"");
+            voSource.setAccountId(map.get("accountId")+"");
+            voSource.setAccountName(map.get("accountName")+"");
+
+            //政策所有时间点
+            List<String> policyDaysList = new ArrayList<>();
+            if (!Check.isNull(map.get("productName"))){
+                //查询 头条利润表  返点类型和比列
+                List<Map<String,Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName")+"",null,"1",uploadYears+"-01",uploadYears+"-31");
+                List listPolicyTIme = new ArrayList();
+                for (Map<String, Object> rate : rateMap) {
+                    listPolicyTIme.add(rate.get("policyStartDate"));
+                    listPolicyTIme.add(rate.get("policyEndDate"));
+                }
+                //政策时间 去重 排序
+                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.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
+                    i += 1;
+                    arrayList.add(mapTime);
+                }
+                for (Map<String, String> stringMap : arrayList) {
+                    SheetBytedanceVo vo = new SheetBytedanceVo();
+                    //使用政策 返点类型和比例
+                    Map<String,Object>  policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName")+"",null,"1",stringMap.get("startDate"),stringMap.get("endDate"));
+                    if (!Check.isNull(policyRateMap)){
+                        if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 0){
+                            vo.setRebateType("返现");//返点类型
+                        }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 1){
+                            vo.setRebateType("返货");
+                        }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 2){
+                            vo.setRebateType("返现+返货");
+                        }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                            vo.setRebateType("服务费");
+                        }
+                        vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"%");//返点比列
+                    }else {
+                        vo.setRebateType("");
+                    }
+                    // 时间段内 账户流水 信息
+                    List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(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","")+"");//现金消耗
+                    vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
+                    vo.setBalance(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("balance","")+"");//日终结余
+                    vo.setFrozen(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("frozen","")+"");//冻结
+                    vo.setIncome(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("income","")+"");//总存入
+                    vo.setSharedWalletCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("sharedWalletCost","")+"");//共享钱包支出
+                    vo.setTransferIn(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferIn","")+"");//总转入
+                    vo.setTransferOut(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferOut","")+"");//总转出
+                    BeanUtils.copyProperties(voSource,vo,SettlementUtil.getNullPropertyNames(voSource));
+                    vo.setTime(stringMap.get("startDate")+"----"+stringMap.get("endDate"));
+                    resultList.add(vo);
+                    policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"),stringMap.get("endDate")));
+                }
+
+            }
+
+            //不使用政策 的时间段
+            // 获取两个日期之间 所有的 时间 年-月-日
+            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(uploadYears+"-01",uploadYears+"-31");
+            // 时间差集(所有时间段 - 使用政策的时间段)
+            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) {
+                SheetBytedanceVo vo = new SheetBytedanceVo();
+                // 不使用 政策 则 返点为空
+                //政策 返点类型和比例
+                vo.setRebateType("");//返点类型
+                vo.setRebateRate("");//返点比列
+                //账户流水 信息
+                List<Map<String,Object>> listAccount = reportSettlementMapper.getProfitBytedanceCost(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","")+"");//现金消耗
+                vo.setRewardCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("rewardCost","")+"");//赠款消耗
+                vo.setBalance(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("balance","")+"");//日终结余
+                vo.setFrozen(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("frozen","")+"");//冻结
+                vo.setIncome(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("income","")+"");//总存入
+                vo.setSharedWalletCost(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("sharedWalletCost","")+"");//共享钱包支出
+                vo.setTransferIn(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferIn","")+"");//总转入
+                vo.setTransferOut(Check.isNull(listAccount) ? "0" : listAccount.get(0).getOrDefault("transferOut","")+"");//总转出
+                BeanUtils.copyProperties(voSource,vo, SettlementUtil.getNullPropertyNames(voSource));
+                vo.setTime((!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate")+"----"+stringMap.get("endDate") : ""));
+                resultList.add(vo);
+            }
+        }
+
+        for (int i = 0; i < resultList.size(); i++) {
+            SheetBytedanceVo vo = resultList.get(i);
+            //创建行 (表头占0-1行 所以 从 2开始)
+            row = sheet.createRow(i + 2);
+            sheet.autoSizeColumn(0, true);
+            sheet.autoSizeColumn(i + 1, true);
+            //创建单元格并且添加数据
+            row.createCell(0).setCellValue(uploadYears);
+            row.createCell(1).setCellValue(vo.getAccountName());
+            row.createCell(2).setCellValue(vo.getAccountId());
+            row.createCell(3).setCellValue(vo.getAgentName());
+            row.createCell(4).setCellValue(vo.getAgentId());
+            row.createCell(5).setCellValue(sf.format(new BigDecimal(vo.getCost())));
+            row.createCell(6).setCellValue(sf.format(new BigDecimal(vo.getCashCost())));
+            row.createCell(7).setCellValue(sf.format(new BigDecimal(vo.getRewardCost())));
+            row.createCell(8).setCellValue(sf.format(new BigDecimal(vo.getIncome())));
+            row.createCell(9).setCellValue(sf.format(new BigDecimal(vo.getTransferIn())));
+            row.createCell(10).setCellValue(sf.format(new BigDecimal(vo.getTransferOut())));
+            row.createCell(11).setCellValue(sf.format(new BigDecimal(vo.getBalance())));
+            row.createCell(12).setCellValue(sf.format(new BigDecimal(vo.getFrozen())));
+            row.createCell(13).setCellValue(vo.getRebateType());
+            row.createCell(14).setCellValue(vo.getRebateRate());
+            row.createCell(15).setCellValue(vo.getTime());
+           // row.setRowStyle(style);
+        }
+    }
+
+    @Override
+    public void createKuaiShou(HSSFWorkbook wb, HSSFCellStyle style, List<String> accountIdList, String uploadYears) {
+        DecimalFormat sf  = new DecimalFormat("#.####");//保留四位小数
+        //2:创建sheet 设置sheet名称
+        HSSFSheet sheet = wb.createSheet("汇总页");
+        //3:添加 第一行单元格
+        HSSFRow row0 = sheet.createRow(0);
+        HSSFCell cell0 = row0.createCell(0);
+        //设置 第一行 表头
+        cell0.setCellValue(uploadYears+"-快手结算单汇总");
+        CellRangeAddress region = new CellRangeAddress(0, 0, 0, 10);
+        sheet.addMergedRegion(region);//合并行
+        cell0.setCellStyle(style);
+        //4:添加表头2行
+        HSSFRow row = sheet.createRow(1);
+        //5:创建第2行的单元格
+        HSSFCell cell = row.createCell(0);     //第一个单元格
+        cell.setCellValue("日期");         //设定值
+        cell.setCellStyle(style);          //内容居中
+
+        cell = row.createCell(1);
+        cell.setCellValue("账户快手ID");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(2);
+        cell.setCellValue("广告主账户ID");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(3);
+        cell.setCellValue("广告主账户名称");
+        cell.setCellStyle(style);
+
+
+        cell = row.createCell(4);
+        cell.setCellValue("日总花费");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(5);
+        cell.setCellValue("充值花费");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(6);
+        cell.setCellValue("框返花费");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(7);
+        cell.setCellValue("激励花费");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(8);
+        cell.setCellValue("充值转入");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(9);
+        cell.setCellValue("框返转入");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(10);
+        cell.setCellValue("激励转入");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(11);
+        cell.setCellValue("总转入");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(12);
+        cell.setCellValue("转出");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(13);
+        cell.setCellValue("日终结余");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(14);
+        cell.setCellValue("返点类型");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(15);
+        cell.setCellValue("返点比例");
+        cell.setCellStyle(style);
+
+        cell = row.createCell(16);
+        cell.setCellValue("政策时间");
+        cell.setCellStyle(style);
+
+        sheet.autoSizeColumn(0, true);
+
+        List<SheetKuaiShouVo> resultList = new ArrayList<>(accountIdList.size());
+        //查询该时段 快手 数据
+        List<Map<String,Object>> accountList = reportSettlementMapper.getProfitKuaiShouAccountCostSheet(accountIdList,uploadYears+"-01",uploadYears+"-31");
+        for (Map<String,Object> map : accountList) {
+            SheetKuaiShouVo voSource = new SheetKuaiShouVo();
+            voSource.setAccountId(map.get("accountId")+"");
+            voSource.setKsId(map.get("ksId")+"");
+            voSource.setAccountName(map.get("accountName")+"");
+
+            //政策所有时间点
+            List<String> policyDaysList = new ArrayList<>();
+            if (!Check.isNull(map.get("productName"))) {
+                //查询 快手利润表  返点类型和比列
+                List<Map<String, Object>> rateMap = reportSettlementMapper.getProfitBytedance(map.get("advertiserName")+"",map.get("productName") + "", null,"2", uploadYears+"-01",uploadYears+"-31");
+                List listPolicyTIme = new ArrayList();
+                for (Map<String, Object> rate : rateMap) {
+                    listPolicyTIme.add(rate.get("policyStartDate"));
+                    listPolicyTIme.add(rate.get("policyEndDate"));
+                }
+
+                //政策时间 去重 排序
+                List<Object> times = SettlementUtil.sortlistTest(listPolicyTIme);
+                // 使用政策的时间段 拼接 开始 和 截至 时间
+                List<Map<String, String>> arrayList = new ArrayList<>();
+                if (!Check.isNull(times)){
+                    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.size() < 2 ? times.get(i).toString() : times.get(i + 1).toString());
+                        i += 1;
+                        arrayList.add(mapTime);
+                    }
+                }
+
+                for (Map<String, String> stringMap : arrayList) {
+                    SheetKuaiShouVo vo = new SheetKuaiShouVo();
+                    //使用政策 返点类型和比例
+                    Map<String, Object> policyRateMap = reportSettlementMapper.getProfitRebate(map.get("advertiserName")+"",map.get("productName") + "", null,"2",stringMap.get("startDate"), stringMap.get("endDate"));
+                    if (!Check.isNull(policyRateMap)) {
+                        if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 0) {
+                            vo.setRebateType("返现");//返点类型
+                        } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 1) {
+                            vo.setRebateType("返货");
+                        } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 2) {
+                            vo.setRebateType("返现+返货");
+                        }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                            vo.setRebateType("服务费");
+                        }
+                        vo.setRebateRate(policyRateMap.getOrDefault("rebateRate", "") + "%");//返点比列
+                    } else {
+                        vo.setRebateType("");
+                    }
+
+                    // 时间段内 账户流水 信息
+                    List<SheetKuaiShouVo>  listInfo = reportSettlementMapper.getTransactionDayKuaiShouSheet(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
+
+                    listInfo.removeAll(Collections.singleton(null));
+                    vo.setDailyCharge(listInfo.stream().filter(v -> !Check.isNull(v.getDailyCharge())).map(SheetKuaiShouVo::getDailyCharge).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setRealCharged(listInfo.stream().filter(v -> !Check.isNull(v.getRealCharged())).map(SheetKuaiShouVo::getRealCharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setContractRebateRealCharged(listInfo.stream().filter(v -> !Check.isNull(v.getContractRebateRealCharged())).map(SheetKuaiShouVo::getContractRebateRealCharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setDirectRebateRealCharged(listInfo.stream().filter(v -> !Check.isNull(v.getDirectRebateRealCharged())).map(SheetKuaiShouVo::getDirectRebateRealCharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setDailyTransferIn(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferIn())).map(SheetKuaiShouVo::getDailyTransferIn).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setDailyTransferOut(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferOut())).map(SheetKuaiShouVo::getDailyTransferOut).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setBalance(listInfo.stream().filter(v -> !Check.isNull(v.getBalance())).map(SheetKuaiShouVo::getBalance).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getRealRecharged())).map(SheetKuaiShouVo::getRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setContractRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getContractRebateRealRecharged())).map(SheetKuaiShouVo::getContractRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    vo.setDirectRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getDirectRebateRealRecharged())).map(SheetKuaiShouVo::getDirectRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                    BeanUtils.copyProperties(voSource, vo, SettlementUtil.getNullPropertyNames(voSource));
+                    vo.setTime(stringMap.get("startDate") + "----" + stringMap.get("endDate"));
+                    resultList.add(vo);
+                    policyDaysList.addAll(SettlementUtil.getAllDatesOfTwoTimes(stringMap.get("startDate"), stringMap.get("endDate")));
+                }
+            }
+
+            //不使用政策 的时间段
+            // 获取两个日期之间 所有的 时间 年-月-日
+            List<String> betweenDaysList = SettlementUtil.getAllDatesOfTwoTimes(uploadYears+"-01",uploadYears+"-31");
+            // 时间差集(所有时间段 - 使用政策的时间段)
+            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) {
+                SheetKuaiShouVo vo = new SheetKuaiShouVo();
+                // 不使用 政策 则 返点为空
+                //政策 返点类型和比例
+                vo.setRebateType("");//返点类型
+                vo.setRebateRate("");//返点比列
+                // 时间段内 账户流水 信息
+                List<SheetKuaiShouVo>  listInfo = reportSettlementMapper.getTransactionDayKuaiShouSheet(map.get("accountId") + "", stringMap.get("startDate"), stringMap.get("endDate"));
+                listInfo.removeAll(Collections.singleton(null));
+                vo.setDailyCharge(listInfo.stream().filter(v -> !Check.isNull(v.getDailyCharge())).map(SheetKuaiShouVo::getDailyCharge).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setRealCharged(listInfo.stream().filter(v -> !Check.isNull(v.getRealCharged())).map(SheetKuaiShouVo::getRealCharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setContractRebateRealCharged(listInfo.stream().filter(v -> !Check.isNull(v.getContractRebateRealCharged())).map(SheetKuaiShouVo::getContractRebateRealCharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setDirectRebateRealCharged(listInfo.stream().filter(v -> !Check.isNull(v.getDirectRebateRealCharged())).map(SheetKuaiShouVo::getDirectRebateRealCharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setDailyTransferIn(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferIn())).map(SheetKuaiShouVo::getDailyTransferIn).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setDailyTransferOut(listInfo.stream().filter(v -> !Check.isNull(v.getDailyTransferOut())).map(SheetKuaiShouVo::getDailyTransferOut).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setBalance(listInfo.stream().filter(v -> !Check.isNull(v.getBalance())).map(SheetKuaiShouVo::getBalance).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getRealRecharged())).map(SheetKuaiShouVo::getRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setContractRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getContractRebateRealRecharged())).map(SheetKuaiShouVo::getContractRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                vo.setDirectRebateRealRecharged(listInfo.stream().filter(v -> !Check.isNull(v.getDirectRebateRealRecharged())).map(SheetKuaiShouVo::getDirectRebateRealRecharged).reduce(BigDecimal.ZERO, BigDecimal::add));
+                BeanUtils.copyProperties(voSource, vo, SettlementUtil.getNullPropertyNames(voSource));
+                vo.setTime(!Check.isNull(vo.getRebateType()) ? stringMap.get("startDate") + "----" + stringMap.get("endDate") : "");
+                resultList.add(vo);
+            }
+        }
+
+        for (int i = 0; i < resultList.size(); i++) {
+            SheetKuaiShouVo vo = resultList.get(i);
+            //创建行 (表头占0-1行 所以 从 2开始)
+            row = sheet.createRow(i + 2);
+            sheet.autoSizeColumn(0, true);
+            sheet.autoSizeColumn(i + 1, true);
+            //创建单元格并且添加数据
+            row.createCell(0).setCellValue(uploadYears);
+            row.createCell(1).setCellValue(vo.getKsId());
+            row.createCell(2).setCellValue(vo.getAccountId());
+            row.createCell(3).setCellValue(vo.getAccountName());
+            row.createCell(4).setCellValue(sf.format(vo.getDailyCharge()));
+            row.createCell(5).setCellValue(sf.format(vo.getRealCharged()));
+            row.createCell(6).setCellValue(sf.format(vo.getContractRebateRealCharged()));
+            row.createCell(7).setCellValue(sf.format(vo.getDirectRebateRealCharged()));
+            row.createCell(8).setCellValue(sf.format(vo.getRealRecharged()));
+            row.createCell(9).setCellValue(sf.format(vo.getContractRebateRealRecharged()));
+            row.createCell(10).setCellValue(sf.format(vo.getDirectRebateRealRecharged()));
+            row.createCell(11).setCellValue(sf.format(vo.getDailyTransferIn()));
+            row.createCell(12).setCellValue(sf.format(vo.getDailyTransferOut()));
+            row.createCell(13).setCellValue(sf.format(vo.getBalance()));
+            row.createCell(14).setCellValue(vo.getRebateType());
+            row.createCell(15).setCellValue(vo.getRebateRate());
+            row.createCell(16).setCellValue(vo.getTime());
+        }
+    }
+
+
+}

+ 17 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsCompanyApprovalUserServiceImpl.java

@@ -7,6 +7,8 @@ import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
+import javax.annotation.Resource;
+
 /**
  * 政策审核人员配置
  * @author jeecg-boot
@@ -16,4 +18,19 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 @Service
 public class CwjsCompanyApprovalUserServiceImpl extends ServiceImpl<CwjsCompanyApprovalUserMapper, CwjsCompanyApprovalUser> implements ICwjsCompanyApprovalUserService {
 
+
+    @Resource
+    private CwjsCompanyApprovalUserMapper cwjsCompanyApprovalUserMapper;
+
+
+
+     /**
+     * 根据主体查询 最后一个审核人员
+     * @param companySubjectId
+     * @return
+     */
+    @Override
+    public CwjsCompanyApprovalUser getEndApprovalUserBySub(Integer companySubjectId) {
+        return cwjsCompanyApprovalUserMapper.getEndApprovalUserBySub(companySubjectId);
+    }
 }

+ 2 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyApprovalLogServiceImpl.java

@@ -21,8 +21,8 @@ public class CwjsPolicyApprovalLogServiceImpl extends ServiceImpl<CwjsPolicyAppr
     CwjsPolicyApprovalLogMapper policyApprovalLogMapper;
 
     @Override
-    public CwjsPolicyApprovalLog getOneByPolicyId(Integer policyId){
-        return policyApprovalLogMapper.getOneByPolicyId(policyId);
+    public CwjsPolicyApprovalLog getOneByPolicyId(Integer policyId,Integer status){
+        return policyApprovalLogMapper.getOneByPolicyId(policyId,status);
     }
 
 }

+ 0 - 2
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsPolicyInfoServiceImpl.java

@@ -60,8 +60,6 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
         for(Integer key : keys){
             result.add(map.get(key));
         }
-
-
         return result;
     }
 

+ 96 - 9
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/impl/CwjsSaleAssistantInfoServiceImpl.java

@@ -1,23 +1,28 @@
 package org.jeecg.ctop.finance.policy.service.impl;
 
+import cn.com.ctop.common.module.mapper.ProjectMapper;
 import cn.com.ctop.common.module.mapper.SysRoleMapper;
 import cn.com.ctop.common.module.mapper.SysUserMapper;
+import cn.com.ctop.common.module.utils.Check;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.ctop.finance.policy.entity.CwjsSaleAssistantInfo;
 import org.jeecg.ctop.finance.policy.mapper.CwjsSaleAssistantInfoMapper;
 import org.jeecg.ctop.finance.policy.service.ICwjsSaleAssistantInfoService;
-import org.jeecg.ctop.finance.policy.utils.Check;
+import org.jeecg.modules.ctop.entity.ProjectMember;
+import org.jeecg.modules.ctop.service.IProjectMemberService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.TreeSet;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -27,6 +32,7 @@ import java.util.stream.Collectors;
  * @version V1.0
  */
 @Service
+@Slf4j
 public class CwjsSaleAssistantInfoServiceImpl extends ServiceImpl<CwjsSaleAssistantInfoMapper, CwjsSaleAssistantInfo> implements ICwjsSaleAssistantInfoService {
 
 
@@ -43,8 +49,9 @@ public class CwjsSaleAssistantInfoServiceImpl extends ServiceImpl<CwjsSaleAssist
     }
 
 
+/*
 
-    public Result getCwSaleAndAssistantList(String userId){
+    public List<CwjsSaleAssistantInfo> getCwSaleAndAssistantList(String userId){
         List<CwjsSaleAssistantInfo> resultList = new ArrayList();
         String roleCode = roleMapper.getRoleCodeByUserId(userId);
         //管理员 查询全部
@@ -61,17 +68,97 @@ public class CwjsSaleAssistantInfoServiceImpl extends ServiceImpl<CwjsSaleAssist
             List <CwjsSaleAssistantInfo> assistantList = cwjsSaleAssistantInfoMapper.getCwAssistantNameList(userId);
             resultList.addAll(assistantList);
             resultList = resultList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CwjsSaleAssistantInfo :: getSaleId))),ArrayList :: new));
-            return Result.successMsg("查询成功-管理员。",resultList);
+            log.info("查询成功-管理员。");
+            return resultList;
         }
         //查询助理
         List <CwjsSaleAssistantInfo> assistantList = cwjsSaleAssistantInfoMapper.getCwAssistantNameList(userId);
         //如果该用户是 助理角色 则 对应的销售加自己的id list 必然 > 2
         if (assistantList.size() < 2){
-            return Result.successMsg("查询成功-销售。",cwjsSaleAssistantInfoMapper.getCwSaleNameList(userId));
+            log.info("查询成功-销售。");
+            return cwjsSaleAssistantInfoMapper.getCwSaleNameList(userId);
         }
-        return Result.successMsg("查询成功-助理。",assistantList);
+        log.info("查询成功-助理。");
+        return assistantList;
+    }
+*/
+
+
+
+    public List<CwjsSaleAssistantInfo> getCwSaleAndAssistantList(String userId){
+        List<CwjsSaleAssistantInfo> resultList = new ArrayList();
+        String roleCode = roleMapper.getRoleCodeByUserId(userId);
+        //管理员 查询全部
+        if (StringUtils.equals("admin",roleCode) || "finance".equals(roleCode)){
+            userId = null;
+        }
+        //查询 销售
+        List <CwjsSaleAssistantInfo> saleList = cwjsSaleAssistantInfoMapper.getAssistantList(userId);
+        return saleList;
+    }
+
+
+    /**
+     * 获取销售和助理的对应关系
+     * @param userId
+     * @return 人员id
+     */
+    @Override
+    public List<String> getCwSaleAndAssistantListStr(String userId) {
+        List<CwjsSaleAssistantInfo> list = getCwSaleAndAssistantList(userId);
+        List<String> userIds = list.stream().map(CwjsSaleAssistantInfo::getSaleId).collect(Collectors.toList());
+        return userIds;
+    }
+
+
+    @Resource
+    private SysRoleMapper sysRoleMapper;
 
+    @Resource
+    private ProjectMapper projectMapper;
+
+    @Resource
+    private IProjectMemberService projectMemberService;
 
+    @Override
+    public Result cwjsParticipateList(ProjectMember projectMember) {
+        String userId = projectMember.getUserId();
+        if (Check.isNull(userId)) {
+            return Result.error("未获取到关联用户信息");
+        }
+        String projectName = projectMember.getProjectName();
+        Long productId = projectMember.getProductId();
+
+        QueryWrapper<ProjectMember> queryWrapper = new QueryWrapper<>();
+        String roleCode = sysRoleMapper.getRoleCodeByUserId(userId);
+        if (!"admin".equals(roleCode)) {
+            List<String> userIds = getCwSaleAndAssistantListStr(projectMember.getUserId());
+            queryWrapper.in("user_id", userIds);
+        }
+        if (!Check.isNull(projectName)) {
+            queryWrapper.like("project_name", projectName);
+        }
+        if (!Check.isNull(productId)) {
+            List<Long> projectIds = projectMapper.getProjectIdsByProductId(productId);
+            if (Check.isNull(projectIds)) {
+                return Result.error("该产品下暂无关联项目");
+            }
+            queryWrapper.in("project_id", projectIds);
+        }
+        queryWrapper.groupBy("project_id");
+        queryWrapper.orderByDesc("create_time");
+        List<ProjectMember> projectMembers = projectMemberService.list(queryWrapper);
+        projectMembers = projectMemberService.getMapsByProjectList(projectMembers);
+        List<ProjectMember> resultList = new ArrayList<>();
+        if (!Check.isNull(projectMembers)) {
+                Map<String, List<ProjectMember>> groupByMedia = projectMembers.stream().filter(p -> (!Check.isNull(p.getMediaId()))).collect(Collectors.groupingBy(ProjectMember::getMediaId));
+                resultList = groupByMedia.get(projectMember.getMediaId());
+                if (!Check.isNull(resultList)) {
+                    resultList.stream().filter(p -> (!Check.isNull(p.getAdvertiserName()))).collect(Collectors.toList());
+                    resultList = resultList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ProjectMember::getAdvertiserId))), ArrayList::new));
+                }
+            }
+        return Result.successMsg("成功。", resultList);
     }
 
 

+ 42 - 17
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementController.java

@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.ctop.finance.policy.service.impl.CwjsPolicyInfoServiceImpl;
+import org.jeecg.ctop.finance.policy.service.impl.CwjsSaleAssistantInfoServiceImpl;
+import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 
 
@@ -14,10 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 /**
@@ -40,6 +39,10 @@ public class SettlementController {
     @Autowired
     private IMaterialReportOverViewService materialReportOverViewService;
 
+
+    @Autowired
+    private CwjsSaleAssistantInfoServiceImpl cwjsSaleAssistantInfoService;
+
     @ApiOperation(value="财务结算-账户列表查询", notes="财务结算-账户列表查询")
     @GetMapping(value = "/getSettlementList")
     public Result getSettlementList(CtopCwjsSettlementInfo settlementInfo,
@@ -47,18 +50,17 @@ public class SettlementController {
                                     @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
         //查询用户角色
         String roleCode = sysRoleService.getRoleCodeByUserId(settlementInfo.getCreateUserId());
-        //普通用户
-        settlementInfo.setUserIds(new HashSet<String>(){{
-            add(settlementInfo.getCreateUserId());
-        }});
-        if ("admin".equals(roleCode)){
-            settlementInfo.setUserIds(null);
-            //销售总监
-        }else if ("saleDirector".equals(roleCode)){
-            //查询所有包含自己的下级
-            Set<String> subordinates= materialReportOverViewService.recursiveQuerySubordinate(settlementInfo.getCreateUserId());
-            settlementInfo.setUserIds(subordinates);
+        //查询所有包含自己的下级
+        //Set<String> subordinates= materialReportOverViewService.recursiveQuerySubordinate(settlementInfo.getCreateUserId());
+        List<String> userIds = new ArrayList<>();
+        if (!"admin".equals(roleCode)){
+            //查询 销售及助理 关联对应的人员
+            userIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(settlementInfo.getCreateUserId());
+            if (Check.isNull(userIds)){
+                userIds.add(settlementInfo.getCreateUserId());
+            }
         }
+        settlementInfo.setUserIds(new HashSet<>(userIds));
        return settlementInfoService.getSettlementList(settlementInfo,pageNo,pageSize);
     }
 
@@ -100,7 +102,7 @@ public class SettlementController {
         Set<String> ids = new HashSet<String>(){{
             add(userId);
         }};
-        if ("admin".equals(roleCode)){
+        /*if ("admin".equals(roleCode)){
             //查询所有销售 && 媒介
             List allSaleList = cwjsPolicyInfoService.getAllSaleAndMeidaManager();
             return Result.successMsg("查询所有销售和媒介用户",allSaleList);
@@ -114,8 +116,31 @@ public class SettlementController {
                 "kuaishou_operations_manager".equals(roleCode) //快手运营经理
          ){
             //查询所有包含自己的下级
-            ids = materialReportOverViewService.recursiveQuerySubordinate(userId);
+           // ids = materialReportOverViewService.recursiveQuerySubordinate(userId);
+            //查询 销售及助理 关联对应的人员
+            List<String> saleIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
+            if (!Check.isNull(ids)){
+                ids.addAll(new HashSet<>(saleIds));
+            }
+
+        }*/
+        if ("admin".equals(roleCode)){
+            //查询所有销售 && 媒介
+            List allSaleList = cwjsPolicyInfoService.getAllSaleAndMeidaManager();
+            return Result.successMsg("查询所有销售和媒介用户",allSaleList);
+
+        }else {
+            //查询所有包含自己的下级
+            // ids = materialReportOverViewService.recursiveQuerySubordinate(userId);
+            //查询 销售及助理 关联对应的人员
+            List<String> saleIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
+            if (!Check.isNull(saleIds)){
+                ids.addAll(new HashSet<>(saleIds));
+            }
+
         }
+
+
         List<Map<String,Object>> list = settlementInfoService.getUserByIds(ids);
         return Result.successMsg("查询用户",list);
     }

+ 16 - 31
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/controller/SettlementFileController.java

@@ -8,6 +8,7 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.entity.SysUser;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.ctop.finance.policy.service.impl.CwjsSaleAssistantInfoServiceImpl;
 import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementFileInfo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
@@ -17,9 +18,7 @@ import org.jeecg.modules.system.service.ISysRoleService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 
 /**
@@ -38,6 +37,11 @@ public class SettlementFileController {
     @Autowired
     private IMaterialReportOverViewService materialReportOverViewService;
 
+
+    @Autowired
+    private CwjsSaleAssistantInfoServiceImpl cwjsSaleAssistantInfoService;
+
+
     @ApiOperation(value="结算单-结算单列表查询", notes="结算单-结算单列表查询")
     @GetMapping(value = "/getSettlementSheetList")
     public Result<PageInfo<Map<String,String>>> getSettlementSheetList(SettlementFileParamsVo paramsVo,
@@ -45,36 +49,17 @@ public class SettlementFileController {
                                                                        @RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
         //查询用户角色
         String roleCode = sysRoleService.getRoleCodeByUserId(paramsVo.getCreateUserId());
-
+        List<String> userIds = new ArrayList<>();
         //管理员 || 财务
         if ("admin".equals(roleCode) || "finance".equals(roleCode)){
-            paramsVo.setOperatorUserIds(null);
-            paramsVo.setSaleUserIds(null);
-         //运营经理
-        }else if ("kuaishou_operations_director".equals(roleCode) || //快手运营总监
-                "toutiao_operations_manager".equals(roleCode) || // 头条运营经理
-                "externalOperationManager".equals(roleCode) || //外部运营经理
-                "genera_manager_of_operations".equals(roleCode) || //运营总经理
-                "toutiao_operations_director".equals(roleCode) || //头条运营总监
-                "kuaishou_operations_manager".equals(roleCode)) //快手运营经理
-         {
-            //查询所有包含自己的下级
-            Set<String> operatorUserIds= materialReportOverViewService.recursiveQuerySubordinate(paramsVo.getCreateUserId());
-            paramsVo.setOperatorUserIds(operatorUserIds);
-        //运营助理 || 运营专员
-        }else if("operationAssistant".equals(roleCode) || "operator".equals(roleCode)){
-            paramsVo.setOperatorUserIds(new HashSet<String>(){{
-                add(paramsVo.getCreateUserId());
-            }});
-        //销售总监 || 销售支持经理
-        }else if("saleDirector".equals(roleCode) || "salesSupportManager".equals(roleCode)){
-            Set<String> saleUserIds= materialReportOverViewService.recursiveQuerySubordinate(paramsVo.getCreateUserId());
-            paramsVo.setSaleUserIds(saleUserIds);
-            //外部销售 || 销售AM || 销售助理 || 销售
-        }else if ("externalSale".equals(roleCode) || "saleAm".equals(roleCode) || "saleAssistant".equals(roleCode) || "sale".equals(roleCode)){
-            paramsVo.setSaleUserIds(new HashSet<String>(){{
-                add(paramsVo.getCreateUserId());
-            }});
+            paramsVo.setSaleUserIds(new HashSet<>(userIds));
+        }else {
+            //查询 销售及助理 关联对应的人员
+            userIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(paramsVo.getCreateUserId());
+            if (Check.isNull(userIds)){
+                userIds.add(paramsVo.getCreateUserId());
+            }
+            paramsVo.setSaleUserIds(new HashSet<>(userIds));
         }
        return settlementFileInfoService.getSettlementSheetList(paramsVo,pageNo,pageSize);
     }

+ 1 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SettlementReportKuaiShouVo.java

@@ -26,6 +26,7 @@ public class SettlementReportKuaiShouVo implements Serializable {
      */
     @ApiModelProperty(value = "账户ID")
     private String accountId;
+    private String accountName;
     /**
      * 时间
      */

+ 47 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SheetBytedanceVo.java

@@ -0,0 +1,47 @@
+package org.jeecg.ctop.finance.settlement.entity.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ *
+ * @description: 头条 结算单 汇总页
+ * @return:
+ * @author: zianY
+ */
+@Data
+public class SheetBytedanceVo implements Serializable {
+
+    private String time;
+
+    private String productName;
+
+    private String accountId;
+    private String accountName;
+
+    private String agentId;
+    private String agentName;
+
+
+    private String rebateType;
+    private String rebateRate;
+
+    private String balance;
+    private String cashCost;
+    private String cost;
+    private String frozen;
+    private String income;
+    private String rewardCost;
+    private String sharedWalletCost;
+    private String transferIn;
+    private String transferOut;
+
+
+
+
+
+
+
+}

+ 65 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/entity/vo/SheetKuaiShouVo.java

@@ -0,0 +1,65 @@
+package org.jeecg.ctop.finance.settlement.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ *
+ * @description: 头条 结算单 汇总页
+ * @return:
+ * @author: zianY
+ */
+@Data
+public class SheetKuaiShouVo implements Serializable {
+
+
+    @ApiModelProperty(value = "账户ID")
+    private String accountId;
+    private String accountName;
+
+
+    @ApiModelProperty(value = "总花费(元)")
+    private BigDecimal dailyCharge;
+
+    @ApiModelProperty(value = "充值花费(元)")
+    private BigDecimal realCharged;
+
+    @ApiModelProperty(value = "框返花费(元)")
+    private BigDecimal contractRebateRealCharged;
+
+    @ApiModelProperty(value = "激励花费(元)")
+    private BigDecimal directRebateRealCharged;
+
+    @ApiModelProperty(value = "转入(元)")
+    private BigDecimal dailyTransferIn;
+
+    @ApiModelProperty(value = "转出(元)")
+    private BigDecimal dailyTransferOut;
+
+    @ApiModelProperty(value = "日终结余(元)")
+    private BigDecimal balance;
+
+    @ApiModelProperty(value = "充值转入(元)")
+    private BigDecimal realRecharged;
+
+    @ApiModelProperty(value = "框返转入(元)")
+    private BigDecimal contractRebateRealRecharged;
+
+    @ApiModelProperty(value = "激励转入(元)")
+    private BigDecimal directRebateRealRecharged;
+
+    private String ksId;
+
+
+    private String rebateType;
+    private String rebateRate;
+
+    private String time;
+
+
+
+
+}

+ 16 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/ReportSettlementMapper.java

@@ -4,6 +4,7 @@ import io.lettuce.core.dynamic.annotation.Param;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementFileParamsVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportBytedanceVo;
 import org.jeecg.ctop.finance.settlement.entity.vo.SettlementReportKuaiShouVo;
+import org.jeecg.ctop.finance.settlement.entity.vo.SheetKuaiShouVo;
 
 import java.util.List;
 import java.util.Map;
@@ -27,6 +28,12 @@ public interface ReportSettlementMapper {
      */
     List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance(SettlementFileParamsVo paramsVo);
 
+    List<Map<String,Object>> getAccountTransactionDayBytedanceSheet(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
+
+
+
+
+
     /**
      * 获取快手 账户 日流水信息 根据账户id 和 年月 查询数据
      * @param paramsVo
@@ -38,12 +45,15 @@ public interface ReportSettlementMapper {
     // 获取快手 结算单 账户 和 代理商 维度
     List<SettlementReportKuaiShouVo> getTransactionDayKuaiShouAgentAndAccount(SettlementFileParamsVo paramsVo);
 
+    List<SheetKuaiShouVo> getTransactionDayKuaiShouSheet(@Param("accountId")String accountId, @Param("startTime")String startTime , @Param("endTime")String endTime);
+
+
 
     /**
      * 查询 账户id
      * @return
      */
-   List<String> getAccountIdBytedance(@Param("sales") Set<String> sales, @Param("mediaId")String mediaId, @Param("advertiserId")String advertiserId, @Param("productId")String productId);
+   List<String> getAccountIdBytedance(@Param("sales") Set<String> sales, @Param("mediaId")String mediaId, @Param("advertiserId")String advertiserId, @Param("productId")String productId,@Param("projectId")String projectId);
    List<String> getAccountIdBytedanceRepeat(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
    List<String> getAccountIdKuaiShouRepeat(@Param("accountIds") List<String> accountIds,@Param("uploadYears")String uploadYears);
 
@@ -71,9 +81,13 @@ public interface ReportSettlementMapper {
      */
     List<Map<String,Object>> getProfitKuaiShouAgentAccount(@Param("startTime")String startTime ,@Param("endTime")String endTime);
     Map<String,Object> getProfitKuaiShouAccountCost(@Param("accountId")String accountId,@Param("startTime")String startTime ,@Param("endTime")String endTime);
+    List<Map<String,Object>> getProfitKuaiShouAccountCostSheet(@Param("accountIds")List<String> accountIds,@Param("startTime")String startTime ,@Param("endTime")String endTime);
     //快手 利润表 账户 时间段内的数据信息
     List<Map<String,Object>> getProfitKuaiShouCost(@Param("accountId")String accountId,@Param("startTime")String startTime ,@Param("endTime")String endTime);
 
+
+
+
     /**
      * 查询 头条利润表  返点类型和比列
      * @param
@@ -94,6 +108,7 @@ public interface ReportSettlementMapper {
 
 
 
+
     /**
      * 查询 所有已绑定用户的运营人员id
      * @return

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/SettlementFileInfoMapper.java

@@ -36,7 +36,7 @@ public interface SettlementFileInfoMapper extends BaseMapper<CtopCwjsSettlementF
 
 
     /**
-     * 查询账户数量以及图片数量
+     * 查询图片数量
      * @param paramsVo
      * @return
      */

+ 193 - 18
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/ReportSettlementMapper.xml

@@ -10,24 +10,22 @@
         balance,cash_cost,cost,frozen,income,reward_cost,shared_wallet_cost,transfer_in,transfer_out,create_time,
         (
         SELECT
-        ag.agent_id
+        DISTINCT ag.agent_id
         from
         ctop_cwjs_agent_info ag
         LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
-        where ac.state = 0
-        and ag.`status` = 0
+        where ag.`status` = 0
         and ag.enabled = 0
-        and ac.account_id = #{accountId}) as agentId,
+        and ac.account_id = #{accountId} limit 1) as agentId,
         (
         SELECT
-        ag.name
+        DISTINCT ag.name
         from
         ctop_cwjs_agent_info ag
         LEFT JOIN ctop_agent_account ac on ag.agent_id = ac.agent_id
-        where ac.state = 0
-        and ag.`status` = 0
+        where ag.`status` = 0
         and ag.enabled = 0
-        and ac.account_id = #{accountId}) as agentName
+        and ac.account_id = #{accountId} limit 1) as agentName
          from
         ctop_account_transaction_day
         where cost >0
@@ -37,22 +35,76 @@
         where uploadYears = #{uploadYears}
         ORDER BY date
     </select>
+<!-- 获取头条 账户 日流水信息 汇总页数据 -->
+    <select id="getAccountTransactionDayBytedanceSheet" resultType="java.util.LinkedHashMap">
+        SELECT
+            t.advertiser_id accountId,
+        ua.auth_name accountName,
+        ROUND( SUM( t.balance ), 3 ) balance,
+            ROUND( SUM( t.cash_cost ), 3 ) cash_cost,
+            ROUND( SUM( t.cost ), 3 ) cost,
+            ROUND( SUM( t.frozen ), 3 ) frozen,
+            ROUND( SUM( t.income ), 3 ) income,
+            ROUND( SUM( t.reward_cost ), 3 ) reward_cost,
+            ROUND( SUM( t.shared_wallet_cost ), 3 ) shared_wallet_cost,
+            ROUND( SUM( t.transfer_in ), 3 ) transfer_in,
+            ROUND( SUM( t.transfer_out ), 3 ) transfer_out,
+            ag.agent_id agentId,
+            ag.NAME agentName,
+        ua.project_id,
+        (SELECT ad.id from ctop_advertiser ad WHERE ad.id = ua.advertiser_id) advertiserId,
+        (SELECT ad.name from ctop_advertiser ad WHERE ad.id = ua.advertiser_id) advertiserName,
+        (SELECT pd.id from ctop_project pr, ctop_product pd WHERE ua.project_id = pr.id and pr.product_id = pd.id) productId,
+        (SELECT pd.product_name from ctop_project pr, ctop_product pd WHERE ua.project_id = pr.id and pr.product_id = pd.id) productName
+
+
+        FROM
+            ctop_account_transaction_day t
+        LEFT JOIN (SELECT DISTINCT account_id,agent_id from ctop_agent_account where 1 = 1
+        <if test='accountIds != null and accountIds.size() > 0'>
+            AND account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+            ) ac ON t.advertiser_id = ac.account_id
+                LEFT JOIN ctop_cwjs_agent_info ag ON ag.agent_id = ac.agent_id
+                LEFT JOIN ctop_user_allocation ua on ua.account_id = t.advertiser_id
+        WHERE
+            t.cost > 0
+          AND DATE_FORMAT( t.date, '%Y-%m' ) = #{uploadYears}
+        <if test='accountIds != null and accountIds.size() > 0'>
+            AND t.advertiser_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY
+            t.advertiser_id
+    </select>
 
     <!-- 查询 头条 账户id-->
     <select id="getAccountIdBytedance" resultType="java.lang.String">
         SELECT
-         account_id as accountId
+        c.account_id AS accountId
         FROM
-        ctop_cwjs_settlement_info
-        where del_flag = 0
+        ctop_cwjs_settlement_info c
+        LEFT JOIN ctop_user_allocation u ON c.account_id = u.account_id
+        WHERE
+        del_flag = 0
         <if test="advertiserId !=null and advertiserId != ''">
-            AND advertiser_id = #{advertiserId}
+            AND c.advertiser_id = #{advertiserId}
         </if>
         <if test="productId !=null and productId != ''">
-            AND product_id = #{productId}
+            AND c.product_id = #{productId}
+        </if>
+        <if test="projectId !=null and projectId != ''">
+            AND u.project_id = #{projectId}
         </if>
         <if test="mediaId !=null and mediaId != ''">
-            AND media_id = #{mediaId}
+            AND c.media_id = #{mediaId}
         </if>
         <if test='sales !=null and sales.size() >0'>
             AND create_user_id in
@@ -296,9 +348,15 @@
     <select id="getProfitBytedanceCost" resultType="java.util.LinkedHashMap">
         SELECT
         d.advertiser_id AS accountId,
-        SUM( d.cost ) AS cost,
-        SUM( d.cash_cost ) AS cashCost,
-        SUM( d.reward_cost ) rewardCost
+        ROUND( SUM( d.balance ), 3 ) balance,
+        ROUND( SUM( d.cash_cost ), 3 ) cashCost,
+        ROUND( SUM( d.cost ), 3 ) cost,
+        ROUND( SUM( d.frozen ), 3 ) frozen,
+        ROUND( SUM( d.income ), 3 ) income,
+        ROUND( SUM( d.reward_cost ), 3 ) rewardCost,
+        ROUND( SUM( d.shared_wallet_cost ), 3 ) sharedWalletCost,
+        ROUND( SUM( d.transfer_in ), 3 ) transferIn,
+        ROUND( SUM( d.transfer_out ), 3 ) transferOut
         FROM
         ctop_account_transaction_day d
         <where>
@@ -338,7 +396,9 @@
         </if>
             AND r.advertiser_name = #{advertiserName}
             AND r.product_name = #{productName}
+        <if test="saleId !=null and saleId != ''">
             AND r.create_user_id = #{saleId}
+        </if>
         <if test="startTime !=null and startTime != ''">
             AND  r.policy_date &gt;= #{startTime}
         </if>
@@ -366,7 +426,10 @@
         </if>
         AND r.advertiser_name = #{advertiserName}
         AND r.product_name = #{productName}
-        AND r.create_user_id = #{saleId}
+          <if test="saleId !=null and saleId != ''">
+              AND r.create_user_id = #{saleId}
+          </if>
+
         <if test="startTime !=null and startTime != ''">
             AND  r.policy_date &gt;= #{startTime}
         </if>
@@ -472,6 +535,40 @@
 
     </select>
 
+    <!-- 查询 快手 利润表 总花费 结算单-->
+    <select id="getProfitKuaiShouAccountCostSheet" resultType="java.util.LinkedHashMap">
+        SELECT
+        d.account_id as accountId,
+        (SELECT ua.auth_name from ctop_user_allocation ua where ua.account_id = d.account_id) as accountName,
+        d.user_id AS ksId,
+        round(SUM(d.total_charged_in_yuan),3) AS cost,
+        round(SUM((d.real_charged_in_yuan + d.total_rebate_real_charged_in_yuan + d.credit_real_charged_in_yuan)),3) as cashCost,
+        IFNULL((SELECT a.name from ctop_user_allocation u,ctop_advertiser a where d.account_id = u.account_id and u.advertiser_id = a.id),(SELECT a.name
+        from ctop_cwjs_settlement_info c ,ctop_advertiser a where c.account_id = d.account_id and c.advertiser_id = a.id)) as advertiserName,
+        IFNULL((SELECT
+        p.product_name
+        FROM ctop_user_allocation u,ctop_project pj,ctop_product p where d.account_id = u.account_id and u.project_id = pj.id and pj.product_id = p.id
+        ),(SELECT p.product_name
+        FROM ctop_cwjs_settlement_info c,ctop_product p where d.account_id = c.account_id and c.product_id = p.id)) productName
+        FROM
+        ctop_kuaishou_daily_agent d
+        <where>
+            AND account_id in
+            <foreach collection="accountIds" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+            and d.total_charged_in_yuan > 0
+            <if test="startTime !=null and startTime != ''">
+                AND d.date_time &gt;= #{startTime}
+            </if>
+            <if test="endTime !=null and endTime != ''">
+                AND d.date_time &lt;= #{endTime}
+            </if>
+        </where>
+        GROUP BY d.account_id
+    </select>
+
     <!-- 查询 快手 利润表 总花费-->
     <select id="getProfitKuaiShouCost" resultType="java.util.LinkedHashMap">
         SELECT
@@ -565,4 +662,82 @@
 	AND c.user_id = #{userId}
     </select>
 
+
+
+
+
+    <!-- 获取快手 账户 日流水信息  代理商 和 账户 结算单 -汇总页-->
+    <select id="getTransactionDayKuaiShouSheet" resultType="org.jeecg.ctop.finance.settlement.entity.vo.SheetKuaiShouVo">
+        SELECT
+            *
+        FROM
+            (
+                SELECT
+                    t.*
+                FROM
+                    (
+                        SELECT
+                            date_time as date,
+                            account_id AS accountId,
+                            total_charged_in_yuan as dailyCharge,
+                            contract_rebate_real_charged_in_yuan as contractRebateRealCharged,
+                            direct_rebate_real_charged_in_yuan as directRebateRealCharged,
+                            ( real_charged_in_yuan + total_rebate_real_charged_in_yuan + credit_real_charged_in_yuan ) realCharged,
+                            account_name AS accountName,
+                            user_id AS ksId
+                        FROM
+                            ctop_kuaishou_daily_agent
+                        WHERE
+                            total_charged_in_yuan >0
+                          and account_id = #{accountId}
+                    ) t
+                WHERE
+                   t.date &gt;= #{startTime}
+                  AND t.date &lt;= #{endTime}
+                ORDER BY
+                    t.date
+                    LIMIT 31
+            ) a
+                LEFT JOIN (
+                SELECT
+                    t.*,
+                    c.auth_name AS accountNameF,
+                    base.user_id AS ksIdF
+                FROM
+                    (
+                        SELECT
+                            account_id AS accountIdF,
+                            date,
+                            daily_transfer_in as dailyTransferIn,
+                            daily_transfer_out as dailyTransferOut,
+                            balance as balance,
+                            real_recharged as realRecharged,
+                            contract_rebate_real_recharged as contractRebateRealRecharged,
+                            direct_rebate_real_recharged as directRebateRealRecharged
+                        FROM
+                            ctop_kuaishou_daily_flows
+                        WHERE
+                            account_id = #{accountId}
+                    ) t
+                        LEFT JOIN ctop_user_allocation c ON t.accountIdF = c.account_id
+                        LEFT JOIN ctop_kuaishou_advertiser_base_info base ON base.account_id = t.accountIdF
+                WHERE
+                   t.date &gt;= #{startTime}
+                  AND t.date &lt;= #{endTime}
+                ORDER BY
+                    date
+                    LIMIT 31
+            ) b ON a.accountId = b.accountIdF
+                AND a.date = b.date
+            LIMIT 31
+
+    </select>
+
+
+
+
+
+
+
+
 </mapper>

+ 43 - 40
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementFileInfoMapper.xml

@@ -142,21 +142,38 @@
             <if test="createUserName !=null and createUserName != ''">
                 AND operateUserId like concat ('%',#{createUserName},'%')
             </if>
-            <if test="operatorUserIds !=null and operatorUserIds != ''">
+            <!--
+            <if test="operatorUserIds !=null and operatorUserIds.size() >0 ">
                 AND operateUserId in
                 <foreach collection="operatorUserIds" item="item" separator=","
                          open="(" close=")">
                     #{item}
                 </foreach>
             </if>
-
-            <if test="saleUserIds !=null and saleUserIds != ''">
+            <if test="saleUserIds !=null and saleUserIds.size() > 0">
                 AND saleUserId in
                 <foreach collection="saleUserIds" item="item" separator=","
                          open="(" close=")">
                     #{item}
                 </foreach>
             </if>
+        -->
+            <if test="saleUserIds !=null and saleUserIds.size() >0 ">
+                AND (operateUserId in
+                <foreach collection="saleUserIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+                or saleUserId in
+                <foreach collection="saleUserIds" item="item" separator=","
+                         open="(" close=")">
+                    #{item}
+                </foreach>
+                )
+            </if>
+            <if test="createUserId !=null and createUserId != ''">
+                AND (operateUserId = #{createUserId} or saleUserId = #{createUserId})
+            </if>
         </where>
         ORDER BY t.update_time DESC,t.projectId
     </select>
@@ -177,43 +194,29 @@
 
     <!-- 查询账户数量以及图片数量 -->
     <select id="getAccountNumAndImgNum" resultType="java.util.Map">
-        SELECT * from
-                     (
-                    SELECT
-                    COUNT(c.account_id) as accountNum
-                    FROM
-                    ctop_cwjs_settlement_info c
-                    LEFT JOIN ctop_user_allocation u on c.account_id = u.account_id
-                    where del_flag = 0
-                        <if test="advertiserId !=null and advertiserId != ''">
-                            AND c.advertiser_id = #{advertiserId}
-                        </if>
-                        <if test="productId !=null and productId != ''">
-                            AND c.product_id = #{productId}
-                        </if>
-                        <if test="mediaId !=null and mediaId != ''">
-                            AND c.media_id = #{mediaId}
-                        </if>
-                         ) t1,
-                     (
-                         SELECT
-                                COUNT(DISTINCT account_id) as imageNum
-                            FROM
-                                 ctop_cwjs_settlement_file_info
-                         where del_flag = 0
-                        <if test="advertiserId !=null and advertiserId != ''">
-                            AND advertiser_id = #{advertiserId}
-                        </if>
-                        <if test="productId !=null and productId != ''">
-                            AND product_id = #{productId}
-                        </if>
-                        <if test="mediaId !=null and mediaId != ''">
-                            AND media_id = #{mediaId}
-                        </if>
-                           <if test="uploadYears !=null and uploadYears != ''">
-                            AND upload_years = #{uploadYears}
-                        </if>
-                     ) t2
+
+        SELECT
+        COUNT( DISTINCT c.account_id ) AS imageNum
+        FROM
+        ctop_cwjs_settlement_file_info c
+        LEFT JOIN ctop_user_allocation u ON c.account_id = u.account_id
+        WHERE
+        del_flag = 0
+        <if test="advertiserId !=null and advertiserId != ''">
+            AND c.advertiser_id = #{advertiserId}
+        </if>
+        <if test="productId !=null and productId != ''">
+            AND c.product_id = #{productId}
+        </if>
+        <if test="mediaId !=null and mediaId != ''">
+            AND c.media_id = #{mediaId}
+        </if>
+        <if test="projectId !=null and projectId != ''">
+            AND u.project_id = #{projectId}
+        </if>
+       <if test="uploadYears !=null and uploadYears != ''">
+            AND c.upload_years = #{uploadYears}
+        </if>
     </select>
 
 

+ 1 - 1
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/SettlementInfoMapper.xml

@@ -53,7 +53,7 @@
             <if test="endTime !=null and endTime != ''">
                 AND DATE_FORMAT(create_time,'%Y-%m-%d') &lt;= #{endTime}
             </if>
-            <if test="userIds !=null and userIds != ''">
+            <if test="userIds !=null and userIds.size() > 0">
                 AND create_user_id in
               <foreach collection="userIds" item="item" separator=","
                        open="(" close=")">

+ 42 - 57
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/ReportSettlementServiceImpl.java

@@ -30,6 +30,8 @@ import org.jeecg.ctop.finance.policy.entity.CwjsPolicyProduct;
 import org.jeecg.ctop.finance.policy.mapper.CwjsCompanySubjectMapper;
 import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
 import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyProductMapper;
+import org.jeecg.ctop.finance.policy.service.ICreateSheetService;
+import org.jeecg.ctop.finance.policy.service.impl.CwjsSaleAssistantInfoServiceImpl;
 import org.jeecg.ctop.finance.policy.utils.Check;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSettlementInfo;
 import org.jeecg.ctop.finance.settlement.entity.pojo.CtopCwjsSlettementReport;
@@ -82,6 +84,12 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
     @Resource
     private SysLogMapper sysLogMapper;
 
+    @Autowired
+    private CwjsSaleAssistantInfoServiceImpl cwjsSaleAssistantInfoService;
+
+    @Autowired
+    private ICreateSheetService createSheetService;
+
 
     @Override
     public List<SettlementReportBytedanceVo> getAccountTransactionDayBytedance() {
@@ -103,6 +111,10 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             font.setFontHeightInPoints((short) 12);//设置字体大小
             style.setFont(font);
 
+            HSSFDataFormat format = wb.createDataFormat();
+            style.setDataFormat(format.getFormat("@"));
+
+
             //查询 账户id
             List<String> accountIdList = this.getAccountId(paramsVo,user);
 
@@ -112,6 +124,13 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
 
             int num = 0;
 
+
+            //设置第一个sheet页 汇总页
+            createSheetService.createBytedance(wb,style,accountIdList,paramsVo.getUploadYears());
+
+
+
+
             for (int k = 0; k < accountIdList.size(); k++) {
                 String accountId = accountIdList.get(k);
                 paramsVo.setAccountId(accountId);
@@ -276,30 +295,33 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
         String uploadYears = paramsVo.getUploadYears();
         //1:区分媒体(头条:1 快手:2)
         Integer mediaId = paramsVo.getMediaId();
-
         String roleCode = roleMapper.getRoleCodeByUserId(user.getId());
         Set<String>sales = new HashSet<>();
+        List<String> userIds = new ArrayList<>();
         List<UserAllocation>allocations ;
         if("admin".equals(roleCode)|| "finance".equals(roleCode)){
             //查询所有可用的账户
-        }else if("saleDirector".equals(roleCode)){
-            //查询自己下辖的所有销售绑定的账户
-            sales = materialReportOverViewService.recursiveQuerySubordinate(paramsVo.getCreateUserId());
-        }else if("saleAssistant".equals(roleCode)|| "sale".equals(roleCode)|| "saleAm".equals(roleCode)){
-            //查询自己名绑定下的账户
-            sales.add(user.getId());
-        }
-        if(sales.isEmpty()){
             sales = null;
+        }else {
+            //查询 销售及助理 关联对应的人员
+            userIds = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(user.getId());
+            if (Check.isNull(userIds)){
+                userIds.add(user.getId());
+            }
+            sales.addAll(new HashSet<>(userIds));
         }
-        List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId());
-        allocations = userAllocationMapper.getAccountInfoBySalesId(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId());
+        //查询财务模块中已上传的账户
+        List<String> settlementAccountList = reportSettlementMapper.getAccountIdBytedance(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
+        //查询已绑定账户
+        allocations = userAllocationMapper.getAccountInfoBySalesId(sales,String.valueOf(mediaId),paramsVo.getAdvertiserId(),paramsVo.getProductId(),paramsVo.getProjectId());
         return mergeAccountId(settlementAccountList,allocations,uploadYears);
     }
 
+    //账户处理
     private List<String> mergeAccountId(List<String> settlementAccountList, List<UserAllocation> allocations,String downloadYear) {
         List<String>salesAccount = new ArrayList<>();
-        for(UserAllocation allocation:allocations){
+        // 账户状态 0 启动 1 禁用
+        for(UserAllocation allocation : allocations){
             if(allocation.getAccountStatus() == 0){
                 salesAccount.add(allocation.getAccountId()+"");
             }
@@ -313,6 +335,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                 }
             }
         }
+        //去重
         settlementAccountList.removeAll(salesAccount);
         settlementAccountList.addAll(salesAccount);
         return settlementAccountList;
@@ -340,21 +363,13 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             if (Check.isNull(accountIdList)){
                 return Result.errorMsg("该广告主和产品下无法查询到绑定的快手账户信息");
             }
-
+            //设置第一个sheet 汇总页-快手
+            createSheetService.createKuaiShou(wb,style,accountIdList,paramsVo.getUploadYears());
             int num = 0;
             for (int k = 0; k < accountIdList.size(); k++) {
                 String accountId = accountIdList.get(k);
                 paramsVo.setAccountId(accountId);
 
-                //获取账户 日流水数据  根据账户id 和 年月 查询数据
-               /* List<SettlementReportKuaiShouVo> settlementList = new ArrayList<>();
-                //查询账户维度
-                settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShou(paramsVo);
-                if (Check.isNull(settlementList)){
-                    //查询代理商维度
-                    settlementList = reportSettlementMapper.getAccountTransactionDayKuaiShouAgent(paramsVo);
-                }
-*/
                 List<SettlementReportKuaiShouVo> settlementList = reportSettlementMapper.getTransactionDayKuaiShouAgentAndAccount(paramsVo);
                 if (Check.isNull(settlementList)){
                     num++;
@@ -526,23 +541,7 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
             List<ProfitReportBytedanceVo> resultList = new ArrayList<>(list.size());
             for (Map<String, Object> mapList : list) {
-              //查看该账户 状态信息
-                /*QueryWrapper<SysLog> sysLogQw = new QueryWrapper<>();
-                sysLogQw.eq("log_type", 2);
-                //操作类型
-                sysLogQw.eq("operate_type", 10001);
-                sysLogQw.eq("log_content", "0");//0开 1关
-                sysLogQw.eq("request_param", mapList.get("accountId").toString());
-                sysLogQw.orderByDesc("create_time");
-                sysLogQw.last("limit 1");
-                SysLog sysLog = sysLogMapper.selectOne(sysLogQw);
-                if (!Check.isNull(sysLog)) {
-                    SimpleDateFormat m = new SimpleDateFormat("MM");
-                    String createMonth = m.format(sysLog.getCreateTime());
-                    int crate = Integer.valueOf(createMonth);
-                    Calendar cal = Calendar.getInstance();
-                    int month = cal.get(Calendar.MONTH) + 1;
-                }*/
+
                 //查看账户数据
                 Map<String,Object> map = reportSettlementMapper.getProfitBytedanceAccountCost(mapList.get("accountId").toString(),paramsVo.getStartTime(),paramsVo.getEndTime());
 
@@ -597,6 +596,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                                 vo.setRebateType("返货");
                             }else if (Integer.valueOf(policyRateMap.get("rebateType").toString())== 2){
                                 vo.setRebateType("返现+返货");
+                            }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                                vo.setRebateType("服务费");
                             }
                             vo.setRebateRate(policyRateMap.getOrDefault("rebateRate","")+"%");//返点比列
                         }else {
@@ -684,24 +685,6 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
             }
             List<ProfitReportKuaiShouVo> resultList = new ArrayList<>(list.size());
             for (Map<String, Object> mapList : list) {
-                //查看该账户 状态信息
-               /* QueryWrapper<SysLog> sysLogQw = new QueryWrapper<>();
-                sysLogQw.eq("log_type", 2);
-                //操作类型
-                sysLogQw.eq("operate_type", 10001);
-                sysLogQw.eq("log_content", "0");//0开 1关
-                sysLogQw.eq("request_param", mapList.get("account_id").toString());
-                sysLogQw.orderByDesc("create_time");
-                sysLogQw.last("limit 1");
-                SysLog sysLog = sysLogMapper.selectOne(sysLogQw);
-                if (!Check.isNull(sysLog)) {
-                    SimpleDateFormat m = new SimpleDateFormat("MM");
-                    String createMonth = m.format(sysLog.getCreateTime());
-                    int crate = Integer.parseInt(createMonth);
-                    Calendar cal = Calendar.getInstance();
-                    int month = cal.get(Calendar.MONTH) + 1;
-
-                }*/
 
                 //查询账户数据信息
                Map<String,Object> map = reportSettlementMapper.getProfitKuaiShouAccountCost(mapList.get("account_id").toString(),paramsVo.getStartTime(),paramsVo.getEndTime());
@@ -757,6 +740,8 @@ public class ReportSettlementServiceImpl implements IReportSettlementService {
                                 vo.setRebateType("返货");
                             } else if (Integer.valueOf(policyRateMap.get("rebateType").toString()) == 2) {
                                 vo.setRebateType("返现+返货");
+                            }else if(Integer.valueOf(policyRateMap.get("rebateType").toString())== 3){
+                                vo.setRebateType("服务费");
                             }
                             vo.setRebateRate(policyRateMap.getOrDefault("rebateRate", "") + "%");//返点比列
                         } else {

+ 2 - 4
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/service/serviceImpl/SettlementFileInfoServiceImpl.java

@@ -125,7 +125,6 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
             settlementFileInfoQw.eq("advertiser_id",map.get("advertiserId"));
             //产品id
             settlementFileInfoQw.eq("product_id",map.get("productId"));
-
             settlementFileInfoQw.eq("account_id",map.get("accountId"));
             //媒体类型 1-头条 2-快手 3-头条内广 4-快手内广
             settlementFileInfoQw.eq("media_id",map.get("mediaId"));
@@ -135,10 +134,7 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
             settlementFileInfoQw.eq("del_flag",0);
             List<CtopCwjsSettlementFileInfo> settlementFileList =  settlementFileInfoMapper.selectList(settlementFileInfoQw);
             map.put("imgNum",Check.isNull(settlementFileList) ? "0" : String.valueOf(settlementFileList.size()));
-
         }
-
-
         PageInfo<Map<String,String>> pageInfo = new PageInfo<>(list);
         return Result.successMsg("财务结算-结算单列表查询成功", pageInfo);
     }
@@ -197,7 +193,9 @@ public class SettlementFileInfoServiceImpl extends ServiceImpl<SettlementFileInf
      */
     @Override
     public Result getAccountNumAndImgNum(SettlementFileParamsVo paramsVo, SysUser user) {
+        //查询图片数量
         Map<String,String> map =  settlementFileInfoMapper.getAccountNumAndImgNum(paramsVo);
+        //查询账户数量
         List<String>accountIds = reportSettlementService.getAccountId(paramsVo,user);
         if (Check.isNull(accountIds)){
             map.put("accountNum","0");

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -68,7 +68,7 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
 
     void updCwjsSettlementStatus(@Param("id") String id, @Param("status") Integer status);
 
-    List<UserAllocation> getAccountInfoBySalesId(@Param("sales") Set<String> sales, @Param("mediaId") String mediaId, @Param("advertiserId") String advertiserId, @Param("productId") String productId);
+    List<UserAllocation> getAccountInfoBySalesId(@Param("sales") Set<String> sales, @Param("mediaId") String mediaId, @Param("advertiserId") String advertiserId, @Param("productId") String productId,@io.lettuce.core.dynamic.annotation.Param("projectId")String projectId);
 
     List<JSONObject> getAccountListByProjectListV2(@Param("list") List list);
 

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -290,6 +290,9 @@ ORDER BY
         <if test="productId!=null and productId!= '' ">
             and cp.product_id = #{productId}
         </if>
+        <if test="projectId!=null and projectId!= '' ">
+            and cp.id = #{projectId}
+        </if>
         <if test="sales !=null and sales.size() > 0">
             AND cp.sale_id in
             <foreach collection="sales" item="item" separator=","

+ 1 - 1
jeecg-cloud-module/pom.xml

@@ -21,4 +21,4 @@
 
 
 
-</project>
+</project>