소스 검색

Merge remote-tracking branch 'origin/test' into test

zhaoxian 3 년 전
부모
커밋
30614c5390

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

@@ -145,7 +145,7 @@ public class CwjsPolicyInfoController {
 		 String approvalUser = cwjsPolicyInfo.getApprovedProgress();
 
 		 //政策所属销售的部门 和 上级
-		 JSONObject examineUser = cwjsPolicyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getSaleId(),"分公司总经理");
+		 JSONObject examineUser = cwjsPolicyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getCreateUserId(),"分公司总经理");
 		 String firstAudit = "";//第一次审核人
 
 		 // 提交 - 待审核
@@ -384,7 +384,12 @@ public class CwjsPolicyInfoController {
 			cwjsPolicyInfo.setSaleIds(userIds);
 		}
 
-
+		// 1:待审核 2:审核中 3:审核通过4:审核拒绝 5-作废 默认不显示作废
+		if (Check.isNull(cwjsPolicyInfo.getApprovedStatus())){
+			cwjsPolicyInfo.setStatusList(Arrays.asList(1, 2, 3, 4));
+		}else {
+			cwjsPolicyInfo.setStatusList(Arrays.asList(cwjsPolicyInfo.getApprovedStatus()));
+		}
 
 
         //查询政策
@@ -485,6 +490,17 @@ public class CwjsPolicyInfoController {
 				}
 			}
 
+			//审核通过
+			if (cwjsPolicy.getApprovedStatus() == 3){
+				//有 销售-助理 关联的人员 都可以 作废
+				if(!"admin".equalsIgnoreCase(roleCode) && !"finance".equalsIgnoreCase(roleCode)){
+					List <String> saleOrAssis = cwjsSaleAssistantInfoService.getCwSaleAndAssistantListStr(userId);
+					if(saleOrAssis.contains(cwjsPolicy.getSaleId())){
+						stringBuilder.append("作废").append("|");
+					}
+				}
+			}
+
 
 
 
@@ -578,7 +594,7 @@ public class CwjsPolicyInfoController {
 
 
 			//政策所属销售的部门 和 上级
-			JSONObject examineUser = cwjsPolicyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getSaleId(),"分公司总经理");
+			JSONObject examineUser = cwjsPolicyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getCreateUserId(),"分公司总经理");
 			String firstAudit = "";//第一次审核人
 
 			//普通销售,新增都是1,审核进度的人都是等级为0的审核人i
@@ -590,11 +606,11 @@ public class CwjsPolicyInfoController {
 				firstAudit = "legalAffairs";
 
 				//助理给销售总监创建
-			}else if (StringUtils.equals(roleCode,"saleDirector")){
-				//审核人是销售总监自己
-				firstAudit = cwjsPolicyInfo.getSaleId();
+			}else if (StringUtils.equals(cwjsPolicyInfo.getSaleId(),cwjsPolicyInfo.getCreateUserId()) && StringUtils.equals(roleCode,"saleDirector")){
+				//审核人是 销售的 上级
+				firstAudit = examineUser.getString("leaderId");
 			}else {
-				//销售的 上级
+				//创建人的 上级
 				firstAudit = examineUser.getString("leaderId");
 			}
 
@@ -909,6 +925,17 @@ public class CwjsPolicyInfoController {
 	 }
 
 
+	 @ApiOperation(value="政策作废", notes="政策作废")
+	 @GetMapping(value = "/toVoidpolicy")
+	 public Result toVoidpolicy(@RequestParam(name="policyId") String policyId,
+								@RequestParam(name="delReason") String delReason) {
+  		if (Check.isNull(delReason)){
+  			return Result.errorMsg("请输入政策作废的理由。");
+		}
+		 return cwjsPolicyInfoService.toVoidpolicy(policyId,delReason);
+	 }
+
+
 
 
 

+ 7 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/entity/CwjsPolicyInfo.java

@@ -62,6 +62,10 @@ public class CwjsPolicyInfo implements Serializable{
 	@Excel(name = "状态 0:草稿 1:待审核 2:审核中 3:审核通过4:审核拒绝", width = 15)
     @ApiModelProperty(value = "0:草稿 1:待审核 2:审核中 3:审核通过4:审核拒绝")
 	private Integer approvedStatus;
+
+	@TableField(exist = false)
+	private List<Integer> statusList;
+
 	@ApiModelProperty(value = "审核进度,当前该谁审核,审核人")
 	private String approvedProgress;
 	/**是否预付:0:否  1:是 */
@@ -135,6 +139,9 @@ public class CwjsPolicyInfo implements Serializable{
 	@ApiModelProperty(value = "销售姓名")
 	private String saleName;
 
+	@ApiModelProperty(value = "作废原因")
+	private String delReason;
+
 	/**创建时间*/
     @ApiModelProperty(value = "创建时间")
 	private Date createTime;

+ 3 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/mapper/CwjsPolicyInfoMapper.java

@@ -71,6 +71,9 @@ public interface CwjsPolicyInfoMapper extends BaseMapper<CwjsPolicyInfo> {
      //查询 法务人员
      List<JSONObject> getLegalAffairsUsers();
 
+     //政策作废 修改状态
+     void updatePolicyToVOidById(@Param("policyId") String policyId,@Param("delReason") String delReason);
+
 
 
 

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

@@ -54,7 +54,16 @@
 
 
         <if test="promotionType != null">and t2.promotion_type = #{promotionType}</if>
-        <if test="approvedStatus != null and approvedStatus != ''">and t2.approved_status = #{approvedStatus}</if>
+
+        <if test="statusList != null and statusList.size() > 0">
+            and t2.approved_status in
+            <foreach item="item" index="index" collection="statusList" open="(" separator="," close=")">
+                #{item}
+            </foreach>
+
+        </if>
+
+
         <if test="startTime != null and startTime != ''">and t2.create_time &gt;= #{startTime}</if>
         <if test="endTime != null and endTime != ''">and t2.create_time &lt;= concat(#{endTime},' 23:59:59')</if>
 
@@ -437,6 +446,17 @@
 
 
 
+    <!-- 政策作废 修改状态-->
+    <update id="updatePolicyToVOidById">
+        update ctop_cwjs_policy_info set
+            approved_status = 5,
+            del_reason = #{delReason}
+        where id = #{policyId}
+    </update>
+
+
+
+
 
 
 

+ 3 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/policy/service/ICwjsPolicyInfoService.java

@@ -47,4 +47,7 @@ public interface ICwjsPolicyInfoService extends IService<CwjsPolicyInfo> {
 
 
 
+    Result toVoidpolicy(String policyId,String delReason);
+
+
 }

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

@@ -1,6 +1,8 @@
 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.utils.CorpWexinUtils;
 import com.alibaba.fastjson.JSONArray;
@@ -12,8 +14,10 @@ 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;
+import org.jeecg.ctop.finance.policy.mapper.CwjsPolicyProductMapper;
 import org.jeecg.ctop.finance.policy.service.ICwjsPolicyInfoService;
 import org.jeecg.ctop.finance.policy.utils.Check;
+import org.jeecg.ctop.finance.settlement.mapper.CwjsProfitMapper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -42,6 +46,13 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     @Resource
     private CwjsPolicyApprovalLogServiceImpl policyApprovalLogService;
 
+    @Resource
+    private CwjsPolicyProductMapper cwjsPolicyProductMapper;
+
+
+    @Resource
+    private CwjsProfitMapper cwjsProfitMapper;
+
     /**
      *
      * @description: 查看政策列表
@@ -112,7 +123,7 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
     }
 
 
-    @Autowired
+    @Resource
     private SysUserMapper userMapper;
 
     @Override
@@ -225,6 +236,42 @@ public class CwjsPolicyInfoServiceImpl extends ServiceImpl<CwjsPolicyInfoMapper,
 
 
 
+    /**
+     * 政策作废
+     * @param policyId 政策id
+     * @param delReason 作废原因
+     * @return
+     */
+    @Override
+    public Result toVoidpolicy(String policyId,String delReason) {
+        CwjsPolicyInfo cwjsPolicyInfo = policyInfoMapper.selectById(policyId);
+        // 1:待审核 2:审核中 3:审核通过4:审核拒绝
+        if (Check.isNull(cwjsPolicyInfo) || cwjsPolicyInfo.getApprovedStatus() !=3){
+            return Result.errorMsg("政策不存在或政策还在审核,审核中的政策无法作废。");
+        }
+        //修改政策状态及作废原因
+        policyInfoMapper.updatePolicyToVOidById(policyId,delReason);
+        //删除政策关联的产品信息
+        cwjsPolicyProductMapper.deleteProductsByPolicyId(Integer.valueOf(policyId));
+        //删除该政策利润表记录
+        cwjsProfitMapper.delSlettmentReportByPolicyId(policyId);
+
+        JSONObject examineUser = policyInfoMapper.getUserLeaderAndDirectorByRoleName(cwjsPolicyInfo.getCreateUserId(),"分公司总经理");
+        List<String> userList = new ArrayList<>();
+        userList.add(examineUser.getString("leaderId"));
+        userList.add(examineUser.getString("directorId"));
+
+        for (String userId : userList) {
+            //给销售总监发送
+            JSONObject wChatIdByUserId = mailLogMapper.getWChatIdByUserId("80e747cdea6f41dbbc8cde23046fd4e0");
+            StringBuilder text = new StringBuilder();
+            text.append(cwjsPolicyInfo.getCreateUserName()+"创建的政策,客户为:"+cwjsPolicyInfo.getCompanyName());
+            text.append(",该销售政策已作废。");
+            corpWexinUtils.sendMessageByWeChatId(wChatIdByUserId,text.toString());
+        }
+
+        return Result.successMsg("政策作废成功",null);
+    }
 
 
 }

+ 3 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/CwjsProfitMapper.java

@@ -22,6 +22,9 @@ public interface CwjsProfitMapper {
 
     void replaceCwjsSlettementProfit(List<CtopCwjsSlettementReport> list);
 
+    //删除 政策利润表统计信息 根据政策id
+    void delSlettmentReportByPolicyId(@Param("policyId") String policyId);
+
 
 
 

+ 7 - 0
jeecg-boot-finance/src/main/java/org/jeecg/ctop/finance/settlement/mapper/xml/CwjsProfitMapper.xml

@@ -29,4 +29,11 @@
     </insert>
 
 
+    <!-- 删除 政策利润表统计信息 根据政策id -->
+    <delete id="delSlettmentReportByPolicyId">
+        delete from ctop_cwjs_slettement_report where policy_id = #{policyIid}
+    </delete>
+
+
+
 </mapper>