Browse Source

新增董事长特批审核

anderx 3 years ago
parent
commit
08c24c0f3b

+ 71 - 43
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -745,7 +745,7 @@
     o.order_status orderStatus,a.project_type projectType,o.sales_type salesType,o.other ,o.delete_sign deleteSign,
     date_format(a.`final_Receivables_time`, '%Y-%m-%d %H:%i:%s')finalReceivablesTime,a.order_receivables orderReceivables,a.order_arrears orderArrears
 	from t_order_new o left join department d on o.order_dep = d.id left join `user` u on o.buyer_id = u.id left join t_order_mid a on o.order_no=a.order_no
-	left join (select * from  t_order_outsource where type=0) too on o.order_no=too.order_no where delete_sign in(0,2) and approval in(0,1,2)
+	left join (select * from  t_order_outsource where type=0) too on o.order_no=too.order_no where delete_sign in(0,2) and approval in(0,1,2,4,5)
     and outsource=   #{o.outsource,jdbcType=INTEGER}
     <if test="o.processStatus == 3">
       and o.process_status = #{o.processStatus,jdbcType=INTEGER}
@@ -798,11 +798,14 @@
         <if test="o.projectType != null and o.projectType != &quot;&quot;">
           and a.project_type = #{o.projectType}
         </if>
-        <if test="o.approval != null and o.approval &lt; 3">
-          and o.approval = #{o.approval}
-        </if>
+      <if test="o.approval != null and o.approval ==1">
+        and o.approval in (1,4)
+      </if>
+      <if test="o.approval != null and o.approval ==2">
+        and o.approval in (2,5)
+      </if>
         <if test="o.approval != null and o.approval ==4">
-          and o.approval in (1,2)
+          and o.approval in (1,2,4,5)
         </if>
 	  	<if test="o.buyerName != null and o.buyerName != &quot;&quot;">
 	  	<bind name="n" value="'%' + o.buyerName + '%'" />
@@ -878,11 +881,14 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
     <if test="o.projectType != null and o.projectType != &quot;&quot;">
       and a.project_type = #{o.projectType}
     </if>
-    <if test="o.approval != null and o.approval &lt; 3">
-      and o.approval = #{o.approval}
+    <if test="o.approval != null and o.approval ==1">
+      and o.approval in (1,4)
+    </if>
+    <if test="o.approval != null and o.approval ==2">
+      and o.approval in (2,5)
     </if>
     <if test="o.approval != null and o.approval ==4">
-      and o.approval in (1,2)
+      and o.approval in (1,2,4,5)
     </if>
 	  	<if test="o.buyerName != null and o.buyerName != &quot;&quot;">
 	  	<bind name="n" value="'%' + o.buyerName + '%'" />
@@ -958,7 +964,7 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	</if>
   	<if test="specially == 0">
   	  <if test="approval ==null">
-  	  and a.approval in(0,1,2)
+  	  and a.approval in(0,1,2,4,5)
       </if>
   	and a.order_status  in(0,1,2,4)
   	and a.salesman_id = #{aid,jdbcType=VARCHAR}
@@ -970,31 +976,42 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	and a.order_status in(3,5)
   	and a.salesman_id = #{aid,jdbcType=VARCHAR}
   	</if>
-  	<if test="specially == 3">
-  	 and  a.order_status=2 and a.process_status != 99
-  	<if test="approval ==0">
-  	and a.approval = 0
-  	</if>
-  	<if test="approval ==1">
-  	and a.process_status = 7
-  	and a.approval = 1
-  	</if>
-  	<if test="approval ==2">
-  	and a.approval &gt; 1
-  	</if>
-  	</if>
-  	  <if test="specially !=3">
+    <if test="specially == 3">
+      and  a.order_status=2 and a.process_status != 99
+      <if test="approval ==0">
+        and a.approval = 0
+      </if>
+      <if test="approval ==1">
+        and a.approval in
+            <if test="manageType ==0">
+            (1)
+            </if>
+          <if test="manageType ==1">
+            (4)
+          </if>
+      </if>
+      <if test="approval ==2">
+        and a.approval in
+        <if test="manageType ==0">
+          (2)
+        </if>
+        <if test="manageType ==1">
+          (5)
+        </if>
+      </if>
+    </if>
+  	  <if test="specially !=3 ">
         <if test="approval ==0">
           and a.approval = 0
         </if>
         <if test="approval ==1">
-          and a.approval =1
+          and a.approval in (1,4)
         </if>
         <if test="approval ==2">
-          and a.approval =2
+          and a.approval in (2,5)
         </if>
         <if test="approval ==4">
-          and a.approval in (1,2)
+          and a.approval in (1,2,4,5)
         </if>
       </if>
   	<if test="specially == 4">
@@ -1104,7 +1121,7 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	</if>
   	<if test="specially == 0">
       <if test="approval ==null">
-        and a.approval in(0,1,2)
+        and a.approval in(0,1,2,4,5)
       </if>
       and a.order_status  in(0,1,2,4)
       and a.salesman_id = #{aid,jdbcType=VARCHAR}
@@ -1116,31 +1133,42 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
   	and a.order_status in(3,5)
   	and a.salesman_id = #{aid,jdbcType=VARCHAR}
   	</if>
-  	<if test="specially == 3">
-  	 and  a.order_status=2 and a.process_status != 99
-  	<if test="approval ==0">
-  	and a.approval &gt; 0
-  	</if>
-  	<if test="approval ==1">
-  	and a.process_status = 7
-  	and a.approval = 1
-  	</if>
-  	<if test="approval ==2">
-  	and a.approval &gt; 1
-  	</if>
-  	</if>
+     <if test="specially == 3">
+       and  a.order_status=2 and a.process_status != 99
+       <if test="approval ==0">
+         and a.approval = 0
+       </if>
+       <if test="approval ==1">
+         and a.approval in
+         <if test="manageType ==0">
+           (1)
+         </if>
+         <if test="manageType ==1">
+           (4)
+         </if>
+       </if>
+       <if test="approval ==2">
+         and a.approval in
+         <if test="manageType ==0">
+           (2)
+         </if>
+         <if test="manageType ==1">
+           (5)
+         </if>
+       </if>
+     </if>
      <if test="specially !=3">
        <if test="approval ==0">
          and a.approval = 0
        </if>
        <if test="approval ==1">
-         and a.approval =1
+         and a.approval in (1,4)
        </if>
        <if test="approval ==2">
-         and a.approval =2
+         and a.approval in (2,5)
        </if>
        <if test="approval ==4">
-           and a.approval in (1,2)
+         and a.approval in (1,2,4,5)
        </if>
      </if>
   	<if test="specially == 4">

+ 1 - 1
src/main/java/com/goafanti/order/controller/AdminNewOrderApiController.java

@@ -476,7 +476,7 @@ public class AdminNewOrderApiController extends CertifyApiController {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "订单编号和审批","订单编号和审批"));
 			return res;
 		}
-		if (confirm==ApprovalNewState.BH.getCode()&&StringUtils.isBlank(reason)) {
+		if (confirm==ApprovalNewState.ZCBH.getCode()&&StringUtils.isBlank(reason)) {
 			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"驳回原因", "驳回原因"));
 			return res;
 		}

+ 14 - 7
src/main/java/com/goafanti/order/enums/ApprovalNewState.java

@@ -6,15 +6,22 @@ import java.util.Map;
 public enum ApprovalNewState {
 	/** 非特批 **/
 	FTP(0,"非特批"),
-	/** 待审核 **/
-	DSH(1,"待审核"),
-	/** 通过 **/
-	TG(2,"通过"),
-	/** 驳回 **/
-	BH(3,"驳回"),
+	/** 总裁待审核 **/
+	ZCDSH(1,"总裁待审核"),
+	/** 总裁通过 **/
+	ZCTG(2,"总裁通过"),
+	/** 总裁驳回 **/
+	ZCBH(3,"总裁驳回"),
+
+	/** 董事长待审核 **/
+	DSZDSH(4,"董事长待审核"),
+	/** 董事长通过 **/
+	DSZTG(5,"董事长通过"),
+	/** 董事长驳回 **/
+	DSZBH(6,"董事长驳回"),
 	/** 无效 **/
 	INVALID(10, "INVALID");
-	
+
 	private ApprovalNewState(Integer code, String desc) {
 		this.code = code;
 		this.desc = desc;

+ 10 - 4
src/main/java/com/goafanti/order/service/impl/FundManagerOrderServiceImpl.java

@@ -96,7 +96,7 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 	public Integer updateDistributionFinance(String orderNo, String financeId, Integer approval) {
 		// 先判断订单id和财务专员是否存在或者能够使用
 		//判断是不是特批的数据
-		if(approval != ApprovalNewState.TG.getCode() && approval != ApprovalNewState.FTP.getCode()){//特批未通过 2 0
+		if(approval != ApprovalNewState.ZCTG.getCode() && approval != ApprovalNewState.FTP.getCode()){//特批未通过 2 0
 			return -1;
 		}
 
@@ -488,13 +488,19 @@ public class FundManagerOrderServiceImpl extends BaseMybatisDao<TOrderNewMapper>
 			t.setBackStatus(0);
 		}
 		List<String> aids = new ArrayList<>();
-		if (new1.getApproval()==ApprovalNewState.DSH.getCode()||
-				new1.getApproval()==ApprovalNewState.BH.getCode()) {
+		if (new1.getApproval()==ApprovalNewState.ZCDSH.getCode()||
+				new1.getApproval()==ApprovalNewState.ZCBH.getCode()) {
 			t.setProcessStatus(ProcessStatus.YPTPSH.getCode());
 			for (Admin admin : adminMapper.getAdminRoleList("总裁")) {
 				aids.add(admin.getId());
 			}
-		}else {
+		}else if (new1.getApproval()==ApprovalNewState.DSZDSH.getCode()||
+				new1.getApproval()==ApprovalNewState.DSZBH.getCode()) {
+			t.setProcessStatus(ProcessStatus.YPTPSH.getCode());
+			for (Admin admin : adminMapper.getAdminRoleList("董事长")) {
+				aids.add(admin.getId());
+			}
+		}else  {
 			t.setProcessStatus(ProcessStatus.YPZXSGLY.getCode());
 			OrganizationListOut oo=departmentMapper.selectAllById(new1.getOrderDep());
 			t.setFinanceId(oo.getFinanceId());

+ 66 - 42
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -421,8 +421,9 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			contactBook.setMobile(t.getContactMobile());
 			organizationContactBookMapper.insertSelective(contactBook);
 		}
+		Admin admin = adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
 		if (StringUtils.isBlank(t.getOrderDep())) {
-			t.setOrderDep(adminMapper.selectByPrimaryKey(TokenManager.getAdminId()).getDepartmentId());
+			t.setOrderDep(admin.getDepartmentId());
 		}
 		if (isSubmit==1) {//订单提交
 			if(t2.getProcessStatus()<ProcessStatus.YPYXGLY.getCode()) {
@@ -431,8 +432,18 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			}else {
 				t.setOrderStatus(OrderNewState.QDSHTG.getCode());
 			}
-			if (t2.getApproval()==ApprovalNewState.BH.getCode()){
-				t.setApproval(ApprovalNewState.DSH.getCode());
+			//特批逻辑处理
+			if (t2.getApproval()==ApprovalNewState.ZCDSH.getCode()){
+				if (admin.getId().equals("734092ad-6564-4021-b7ab-aab5af3a1537")){
+					t.setApproval(ApprovalNewState.DSZDSH.getCode());
+				}else {
+					t.setApproval(ApprovalNewState.ZCDSH.getCode());
+				}
+			}
+			if (t2.getApproval()==ApprovalNewState.ZCBH.getCode()){
+				t.setApproval(ApprovalNewState.ZCDSH.getCode());
+			}else if (t2.getApproval()==ApprovalNewState.DSZBH.getCode()){
+				t.setApproval(ApprovalNewState.DSZDSH.getCode());
 			}
 			//生成流转
 			TOrderLog tl=new TOrderLog();
@@ -460,7 +471,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			pushGeneralSendNoticeAndEmail(aids, type,order, TokenManager.getAdminId(),t.getApproval());
 
 		}
-		if (t2.getApproval().equals(ApprovalNewState.BH.getCode()) ||
+		if (t2.getApproval().equals(ApprovalNewState.ZCBH.getCode()) ||
+				t2.getApproval().equals(ApprovalNewState.DSZBH.getCode()) ||
 				t2.getOrderStatus().equals(OrderNewState.QDSHJJ.getCode()) ||
 				t2.getOrderStatus().equals(OrderNewState.YBH.getCode())) {
 			t.setCreateTime(new Date());
@@ -675,9 +687,16 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 	@Override
 	public Pagination<TOrderNewBo> orderNewList(InputOrderNewListBo in) {
 		Map<String, Object> params = new HashMap<>();
-		if (in.getSpecially()!=null&&(in.getSpecially()==0||in.getSpecially()==1||in.getSpecially()==2||in.getSpecially()==4||in.getSpecially()==5||in.getSpecially()==7)) {
+		Pagination<TOrderNewBo> x = addParams(in, params);
+		if (x != null) return x;
+		Pagination<TOrderNewBo> p = (Pagination<TOrderNewBo>)findPage("selectOrderNewListByPage", "selectOrderNewListCount", params, in.getPageNo(), in.getPageSize());
+		return p;
+	}
+
+	private Pagination<TOrderNewBo> addParams(InputOrderNewListBo in, Map<String, Object> params) {
+		if (in.getSpecially()!=null&&(in.getSpecially()==0|| in.getSpecially()==1|| in.getSpecially()==2|| in.getSpecially()==4|| in.getSpecially()==5|| in.getSpecially()==7)) {
 			//0 个人 1 营销员管理 2 驳回 3 特批 4 咨询师管理 5部门订单查询
-			if (in.getSpecially()!=3&&in.getSpecially()!=4) {
+			if (in.getSpecially()!=3&& in.getSpecially()!=4) {
 				if (in.getAid() ==null){
 					params.put("aid", TokenManager.getAdminId()==null?"1":TokenManager.getAdminId());
 				}else{
@@ -686,7 +705,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			}
 			//(咨询师管理列表 0 未分配 1部分   2全部)
 			if(in.getSpecially()==4) {
-				params.put("distribution",in.getDistribution());
+				params.put("distribution", in.getDistribution());
 			}
 		}else if(in.getSpecially()==8){
 			if (StringUtils.isNotBlank(in.getUid())) {
@@ -697,12 +716,16 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 				params.put("aid", in.getAid());
 			}
 		}
-			params.put("specially",in.getSpecially());
+		if (in.getSpecially()==3){
+			if (TokenManager.hasRole(AFTConstants.CED))params.put("manageType",0);
+			else if (TokenManager.hasRole(AFTConstants.APPROVAL_DECISION_AUDITOR))params.put("manageType",1);
+		}
+		params.put("specially", in.getSpecially());
 		if (StringUtils.isNotBlank(in.getName())) {
 			params.put("name", in.getName());
 		}
 		// 计算出所有本部门及所属部门的ID
-		if(in.getSpecially()==1||in.getSpecially()==5) {
+		if(in.getSpecially()==1|| in.getSpecially()==5) {
 			List<String>departmentList=new ArrayList<>();
 			if (in.getDeps()!=null){
 				departmentList=departmentService.selectSubDeps(in.getDeps());
@@ -721,39 +744,38 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		if (StringUtils.isNotBlank(in.getContractNo())) {
 			params.put("contractNo", in.getContractNo());
 		}
-		if (null!=in.getLiquidationStatus()) {
+		if (null!= in.getLiquidationStatus()) {
 			params.put("liquidationStatus", in.getLiquidationStatus());
 		}
-			if (null !=in.getApproval()) {
-				params.put("approval", in.getApproval());
-			}
-			if(null != in.getAmountStatus()) {
-				params.put("amountStatus", in.getAmountStatus());
-			}
-			if (StringUtils.isNotBlank(in.getOrderNo())) {
-				params.put("orderNo", in.getOrderNo());
-			}
-			if (StringUtils.isNotBlank(in.getStarTime())) {
-				params.put("starTime", in.getStarTime());
-			}
-			if (StringUtils.isNotBlank(in.getEndTime())) {
-				params.put("endTime", in.getEndTime()+" 23:59:59");
-			}
-			if (StringUtils.isNotBlank(in.getContractStart())) {
-				params.put("contractStart", in.getContractStart());
-			}
-			if (StringUtils.isNotBlank(in.getContractEnd())) {
-				params.put("contractEnd", in.getContractEnd()+" 23:59:59");
-			}
-			if(null != in.getProjectType()) {
-				params.put("projectType",in.getProjectType());
-			}
-			if(null != in.getProcessStatus()) {
-				params.put("processStatus",in.getProcessStatus());
-			}
+		if (null != in.getApproval()) {
+			params.put("approval", in.getApproval());
+		}
+		if(null != in.getAmountStatus()) {
+			params.put("amountStatus", in.getAmountStatus());
+		}
+		if (StringUtils.isNotBlank(in.getOrderNo())) {
+			params.put("orderNo", in.getOrderNo());
+		}
+		if (StringUtils.isNotBlank(in.getStarTime())) {
+			params.put("starTime", in.getStarTime());
+		}
+		if (StringUtils.isNotBlank(in.getEndTime())) {
+			params.put("endTime", in.getEndTime()+" 23:59:59");
+		}
+		if (StringUtils.isNotBlank(in.getContractStart())) {
+			params.put("contractStart", in.getContractStart());
+		}
+		if (StringUtils.isNotBlank(in.getContractEnd())) {
+			params.put("contractEnd", in.getContractEnd()+" 23:59:59");
+		}
+		if(null != in.getProjectType()) {
+			params.put("projectType", in.getProjectType());
+		}
+		if(null != in.getProcessStatus()) {
+			params.put("processStatus", in.getProcessStatus());
+		}
 		params.put("outsource", in.getOutsource());
-		Pagination<TOrderNewBo> p = (Pagination<TOrderNewBo>)findPage("selectOrderNewListByPage", "selectOrderNewListCount", params, in.getPageNo(), in.getPageSize());
-		return p;
+		return null;
 	}
 
 
@@ -1184,8 +1206,10 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		Integer type=null;
 		TOrderLog tl=new TOrderLog();
 		tl.setOrderNo(orderNo);
+
 		if (confirm==2) {
-			t.setApproval(2);
+			if (t2.getApproval()==ApprovalNewState.ZCDSH.getCode())t.setApproval(ApprovalNewState.ZCTG.getCode());
+			else if (t2.getApproval()==ApprovalNewState.DSZDSH.getCode())t.setApproval(ApprovalNewState.DSZTG.getCode());
 				t.setProcessStatus(ProcessStatus.YPZXSGLY.getCode());
 				OrganizationListOut oo=departmentMapper.selectAllById(t2.getOrderDep());
 				t.setFinanceId(oo.getFinanceId());
@@ -1195,7 +1219,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			type=NoticeStatus.ORDER_APPROVA_YES.getCode();
 			tl.setProcess(OrderLogProcess.TP.getCode());
 		} else {
-			t.setApproval(3);
+			if (t2.getApproval()==ApprovalNewState.ZCDSH.getCode())t.setApproval(ApprovalNewState.ZCBH.getCode());
+			else if (t2.getApproval()==ApprovalNewState.DSZDSH.getCode())t.setApproval(ApprovalNewState.DSZBH.getCode());
 			t.setOrderStatus(OrderNewState.YBH.getCode());
 			t.setProcessStatus(ProcessStatus.YPYXY.getCode());
 			addBackOrder(orderNo, reason);
@@ -1207,7 +1232,6 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		TOrderNewBo order = tOrderNewMapper.getSaleIdByOno(orderNo);
 		pushGeneralSendNoticeAndEmail(aids, type,order, TokenManager.getAdminId(),t2.getApproval());
 		//新增特批催款信息
-
 		return tOrderNewMapper.updateByPrimaryKeySelective(t);
 	}