|
@@ -1,18 +1,16 @@
|
|
|
package org.jeecg.ctop.finance.policy.service.impl;
|
|
|
|
|
|
-import android.widget.RelativeLayout;
|
|
|
import cn.com.ctop.common.module.mapper.MailLogMapper;
|
|
|
-import cn.com.ctop.common.module.mapper.ProductMapper;
|
|
|
import cn.com.ctop.common.module.mapper.SysUserMapper;
|
|
|
import cn.com.ctop.common.module.service.ISysUserService;
|
|
|
import cn.com.ctop.common.module.utils.CorpWexinUtils;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.system.entity.SysUser;
|
|
|
-import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.ctop.finance.policy.entity.CwjsPolicyApprovalLog;
|
|
|
import org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo;
|
|
|
import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyInfoMapper;
|
|
@@ -26,13 +24,17 @@ import org.jeecg.ctop.finance.settlement.service.IReportSettlementService;
|
|
|
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.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* 政策信息表
|
|
|
+ *
|
|
|
* @author jeecg-boot
|
|
|
* 2021-07-27
|
|
|
* @version V1.0
|
|
@@ -59,23 +61,21 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
private CwjsProfitMapper cwjsProfitMapper;
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- * @description: 查看政策列表
|
|
|
- * 已通过的政策 按照 产品名称 拆分多条
|
|
|
- *
|
|
|
* @param policyInfo
|
|
|
+ * @description: 查看政策列表
|
|
|
+ * 已通过的政策 按照 产品名称 拆分多条
|
|
|
* @return: java.util.List<org.jeecg.ctop.finance.policy.entity.CwjsPolicyInfo>
|
|
|
* @author: zianY
|
|
|
* @time: 2022/3/29
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CwjsPolicyInfo> queryPageList(CwjsPolicyInfo policyInfo){
|
|
|
+ public List<CwjsPolicyInfo> queryPageList(CwjsPolicyInfo policyInfo) {
|
|
|
|
|
|
List<CwjsPolicyInfo> policyInfoList = policyInfoMapper.selectPolicyInfos(policyInfo);
|
|
|
List<CwjsPolicyInfo> result = new ArrayList<>();
|
|
|
//1.过滤所有已通过审核的政策到结果表中
|
|
|
- policyInfoList.forEach(policy->{
|
|
|
- if(policy.getApprovedStatus() == 3){
|
|
|
+ policyInfoList.forEach(policy -> {
|
|
|
+ if (policy.getApprovedStatus() == 3) {
|
|
|
JSONArray policyProductName = new JSONArray();
|
|
|
policyProductName.add(policy.getProductName());
|
|
|
policy.setPolicyProductName(policyProductName);
|
|
@@ -83,47 +83,48 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
}
|
|
|
});
|
|
|
policyInfoList.removeAll(result);
|
|
|
- Map<Integer,CwjsPolicyInfo> map = new HashMap<>();
|
|
|
+ Map<Integer, CwjsPolicyInfo> map = new HashMap<>();
|
|
|
//2.未通过审核的政策需要通过政策id来进行聚合,把产品名称放到同一个列表里
|
|
|
- policyInfoList.forEach(policy->{
|
|
|
- if(map.containsKey(policy.getId())){
|
|
|
+ policyInfoList.forEach(policy -> {
|
|
|
+ if (map.containsKey(policy.getId())) {
|
|
|
map.get(policy.getId()).getPolicyProductName().add(policy.getProductName());
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
JSONArray policyProductName = new JSONArray();
|
|
|
policyProductName.add(policy.getProductName());
|
|
|
policy.setPolicyProductName(policyProductName);
|
|
|
- map.put(policy.getId(),policy);
|
|
|
+ map.put(policy.getId(), policy);
|
|
|
}
|
|
|
});
|
|
|
//3.遍历聚合完成后的map,每一个key对应一条不通过的政策的数据,放入到结果集返回
|
|
|
Set<Integer> keys = map.keySet();
|
|
|
- for(Integer key : keys){
|
|
|
+ for (Integer key : keys) {
|
|
|
result.add(map.get(key));
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<JSONObject> getAllSale(){
|
|
|
+ public List<JSONObject> getAllSale() {
|
|
|
return policyInfoMapper.getAllSale();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<JSONObject> getAllSaleAndMeidaManager(){
|
|
|
+ public List<JSONObject> getAllSaleAndMeidaManager() {
|
|
|
return policyInfoMapper.getAllSaleAndMeidaManager();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询 所有 运营
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Map<String,Object>> getAllOperationUser(){
|
|
|
+ public List<Map<String, Object>> getAllOperationUser() {
|
|
|
return policyInfoMapper.getAllOperationUser();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<JSONObject> getAllSaleByUserId(String userId){
|
|
|
+ public List<JSONObject> getAllSaleByUserId(String userId) {
|
|
|
return policyInfoMapper.getAllSaleByUserId(userId);
|
|
|
}
|
|
|
|
|
@@ -132,14 +133,14 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
private SysUserMapper userMapper;
|
|
|
|
|
|
@Override
|
|
|
- public List<JSONObject> getAllSubordinate2(String userId){
|
|
|
+ public List<JSONObject> getAllSubordinate2(String userId) {
|
|
|
List<SysUser> allList = userMapper.selectAllUser();
|
|
|
List<SysUser> mulUserList = treeCategoryData(allList, userId);
|
|
|
List<JSONObject> users = new ArrayList<>();
|
|
|
mulUserList.forEach(mulUser -> {
|
|
|
JSONObject jo = new JSONObject();
|
|
|
- jo.put("userId",mulUser.getId());
|
|
|
- jo.put("userName",mulUser.getRealname());
|
|
|
+ jo.put("userId", mulUser.getId());
|
|
|
+ jo.put("userName", mulUser.getRealname());
|
|
|
users.add(jo);
|
|
|
});
|
|
|
return users;
|
|
@@ -147,7 +148,7 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public List<String> getAllSubordinate(String userId){
|
|
|
+ public List<String> getAllSubordinate(String userId) {
|
|
|
List<SysUser> allList = userMapper.selectAllUser();
|
|
|
List<SysUser> mulUserList = treeCategoryData(allList, userId);
|
|
|
List<String> userIds = new ArrayList<>();
|
|
@@ -155,12 +156,13 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
mulUserList.forEach(mulUser -> userIds.add(mulUser.getId()));
|
|
|
return userIds;
|
|
|
}
|
|
|
+
|
|
|
public List<SysUser> treeCategoryData(List<SysUser> allList, String leaderId) {
|
|
|
List<SysUser> mapList = new ArrayList<>();
|
|
|
for (SysUser vo : allList) {
|
|
|
- if (leaderId.equals(vo.getLeaderId())){
|
|
|
+ if (leaderId.equals(vo.getLeaderId())) {
|
|
|
mapList.add(vo);
|
|
|
- mapList.addAll(treeCategoryData(allList,vo.getId()));
|
|
|
+ mapList.addAll(treeCategoryData(allList, vo.getId()));
|
|
|
}
|
|
|
}
|
|
|
return mapList;
|
|
@@ -168,7 +170,7 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean isExistCwjsPolicyInfo(CwjsPolicyInfo policyInfo){
|
|
|
+ public boolean isExistCwjsPolicyInfo(CwjsPolicyInfo policyInfo) {
|
|
|
CwjsPolicyInfo cwjsPolicyInfoEntity = new CwjsPolicyInfo();
|
|
|
cwjsPolicyInfoEntity.setAdvertiserName(policyInfo.getAdvertiserName());
|
|
|
cwjsPolicyInfoEntity.setProductName(policyInfo.getProductName());
|
|
@@ -177,30 +179,29 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
cwjsPolicyInfoEntity.setPolicyStartDate(policyInfo.getPolicyStartDate());
|
|
|
cwjsPolicyInfoEntity.setPolicyEndDate(policyInfo.getPolicyEndDate());
|
|
|
List<CwjsPolicyInfo> cwjsPolicyInfos = policyInfoMapper.selectPolicyInfos(policyInfo);
|
|
|
- if(Check.isNull(cwjsPolicyInfos)){
|
|
|
+ if (Check.isNull(cwjsPolicyInfos)) {
|
|
|
return false;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updatePolicyInfoById(CwjsPolicyInfo policyInfo){
|
|
|
+ public void updatePolicyInfoById(CwjsPolicyInfo policyInfo) {
|
|
|
policyInfoMapper.updatePolicyInfoById(policyInfo);
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void automaticConveyBossExamine(CwjsPolicyInfo cwjsPolicyInfo) {
|
|
|
cwjsPolicyInfo.setApprovedStatus(2);
|
|
|
- cwjsPolicyInfo.setApprovedProgress("4aba62011120ac565c7f2b9f8f4aa96b"); //设置 boss 为审核人员
|
|
|
+ cwjsPolicyInfo.setApprovedProgress("4aba62011120ac565c7f2b9f8f4aa96b"); //设置 boss 为审核人员
|
|
|
JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("4aba62011120ac565c7f2b9f8f4aa96b");
|
|
|
StringBuilder text = new StringBuilder();
|
|
|
text.append("您有一条销售政策需要审核,该客户为:");
|
|
|
text.append(cwjsPolicyInfo.getCompanyName());
|
|
|
text.append(",请及时登录助手平台-销售政策页面进行审核,谢谢!");
|
|
|
- corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
|
|
|
+ corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId, text.toString());
|
|
|
CwjsPolicyApprovalLog policyApprovalLog = new CwjsPolicyApprovalLog();
|
|
|
policyApprovalLog.setPolicyId(cwjsPolicyInfo.getId());
|
|
|
policyApprovalLog.setCreateUserId(cwjsPolicyInfo.getLoginUserId());
|
|
@@ -212,6 +213,7 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
|
|
|
/**
|
|
|
* 查询 政策审核记录
|
|
|
+ *
|
|
|
* @param policyId
|
|
|
* @return
|
|
|
*/
|
|
@@ -220,12 +222,12 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
List<JSONObject> policyApprovalList = policyInfoMapper.getPolicyApprovalLogByPolicyId(policyId);
|
|
|
//不显示审核意见
|
|
|
for (JSONObject object : policyApprovalList) {
|
|
|
- if (object.getString("approvalContent").length() > 4){
|
|
|
- object.put("approvalContent","审核"+(object.getString("approvalStatus").equals("0") ? "成功" : "失败"));
|
|
|
+ if (object.getString("approvalContent").length() > 4) {
|
|
|
+ object.put("approvalContent", "审核" + (object.getString("approvalStatus").equals("0") ? "成功" : "失败"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return Result.successMsg("政策审核记录查询成功",policyApprovalList);
|
|
|
+ return Result.successMsg("政策审核记录查询成功", policyApprovalList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -240,28 +242,28 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 政策作废
|
|
|
- * @param policyId 政策id
|
|
|
+ *
|
|
|
+ * @param policyId 政策id
|
|
|
* @param delReason 作废原因
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public Result toVoidpolicy(String policyId,String delReason) {
|
|
|
+ public Result toVoidpolicy(String policyId, String delReason) {
|
|
|
CwjsPolicyInfo cwjsPolicyInfo = policyInfoMapper.selectById(policyId);
|
|
|
// 1:待审核 2:审核中 3:审核通过4:审核拒绝
|
|
|
- if (Check.isNull(cwjsPolicyInfo) || cwjsPolicyInfo.getApprovedStatus() !=3){
|
|
|
+ if (Check.isNull(cwjsPolicyInfo) || cwjsPolicyInfo.getApprovedStatus() != 3) {
|
|
|
return Result.errorMsg("政策不存在或政策还在审核,审核中的政策无法作废。");
|
|
|
}
|
|
|
//修改政策状态及作废原因
|
|
|
- policyInfoMapper.updatePolicyToVOidById(policyId,delReason);
|
|
|
+ policyInfoMapper.updatePolicyToVOidById(policyId, delReason);
|
|
|
//删除政策关联的产品信息
|
|
|
//cwjsPolicyProductMapper.deleteProductsByPolicyId(Integer.valueOf(policyId));
|
|
|
//删除该政策利润表记录
|
|
|
cwjsProfitMapper.delSlettmentReportByPolicyId(policyId);
|
|
|
|
|
|
- JSONObject examineUser = policyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getCreateUserId(),"分公司总经理");
|
|
|
+ JSONObject examineUser = policyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getCreateUserId(), "分公司总经理");
|
|
|
List<String> userList = new ArrayList<>();
|
|
|
userList.add(examineUser.getString("leaderId"));
|
|
|
userList.add(examineUser.getString("directorId"));
|
|
@@ -270,12 +272,12 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
//给销售总监发送
|
|
|
JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId(userId);
|
|
|
StringBuilder text = new StringBuilder();
|
|
|
- text.append(cwjsPolicyInfo.getCreateUserName()+"创建的政策,客户为:"+cwjsPolicyInfo.getCompanyName());
|
|
|
+ text.append(cwjsPolicyInfo.getCreateUserName() + "创建的政策,客户为:" + cwjsPolicyInfo.getCompanyName());
|
|
|
text.append(",该销售政策已作废。");
|
|
|
- corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
|
|
|
+ corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId, text.toString());
|
|
|
}
|
|
|
|
|
|
- return Result.successMsg("政策作废成功",null);
|
|
|
+ return Result.successMsg("政策作废成功", null);
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -287,33 +289,29 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
|
|
|
@Resource
|
|
|
private ReportSettlementMapper reportSettlementMapper;
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
public Result getSettlementNoPictureAccountList(SettlementFileParamsVo paramsVo) {
|
|
|
- SysUser user = userService.getById(paramsVo.getUserId());
|
|
|
- //查询账户数量
|
|
|
- List<String>accountIds = reportSettlementService.getAccountId(paramsVo,user);
|
|
|
-
|
|
|
- if (Check.isNull(accountIds)){
|
|
|
- return Result.errorMsg("未上传结算单账户列表查询为空。");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //过滤消耗为0 的账户 1-头条 2-快手
|
|
|
- if (paramsVo.getMediaId().equals(1)){
|
|
|
- accountIds = reportSettlementMapper.getAccountIdBytedanceRepeat(accountIds,paramsVo.getUploadYears());
|
|
|
- }else if (paramsVo.getMediaId().equals(2)){
|
|
|
- accountIds = reportSettlementMapper.getAccountIdKuaiShouRepeat(accountIds,paramsVo.getUploadYears());
|
|
|
- }
|
|
|
-
|
|
|
- //过滤以上传的账户
|
|
|
- //List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountList(productId,projectId,uploadYears,mediaIds);
|
|
|
+ SysUser user = userService.getById(paramsVo.getUserId());
|
|
|
+ //查询账户数量
|
|
|
+ List<String> accountIds = reportSettlementService.getAccountId(paramsVo, user);
|
|
|
|
|
|
+ if (Check.isNull(accountIds)) {
|
|
|
+ return Result.errorMsg("未上传结算单账户列表查询为空。");
|
|
|
+ }
|
|
|
+ //过滤消耗为0 的账户 1-头条 2-快手
|
|
|
+ if (paramsVo.getMediaId().equals(1)) {
|
|
|
+ accountIds = reportSettlementMapper.getAccountIdBytedanceRepeat(accountIds, paramsVo.getStartTime(), paramsVo.getEndTime());
|
|
|
+ } else if (paramsVo.getMediaId().equals(2)) {
|
|
|
+ accountIds = reportSettlementMapper.getAccountIdKuaiShouRepeat(accountIds, paramsVo.getStartTime(), paramsVo.getEndTime());
|
|
|
+ }
|
|
|
+ //过滤以上传的账户
|
|
|
+ //List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountList(productId,projectId,uploadYears,mediaIds);
|
|
|
|
|
|
|
|
|
- PageHelper.startPage(paramsVo.getPageNo(), paramsVo.getPageSize());
|
|
|
- List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountAgentList(paramsVo.getProductId(),paramsVo.getProjectId(),paramsVo.getUploadYears(),accountIds);
|
|
|
- PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
|
|
|
- return Result.successMsg("未上传结算单账户查询成功。",pageInfo);
|
|
|
+ PageHelper.startPage(paramsVo.getPageNo(), paramsVo.getPageSize());
|
|
|
+ List<JSONObject> list = policyInfoMapper.getSettlementNoPictureAccountAgentList(paramsVo.getProductId(), paramsVo.getProjectId(), paramsVo.getEndTime(), accountIds);
|
|
|
+ PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
|
|
|
+ return Result.successMsg("未上传结算单账户查询成功。", pageInfo);
|
|
|
}
|
|
|
|
|
|
@Override
|