Просмотр исходного кода

发起投资金额判定设置

anderx лет назад: 3
Родитель
Сommit
955c212006

+ 14 - 4
src/main/java/com/goafanti/ambSystem/controller/AmbInvestApiController.java

@@ -95,16 +95,26 @@ public class AmbInvestApiController extends CertifyApiController {
 	@RequestMapping(value="/updateTransfer",method = RequestMethod.POST)
 	public Result updateTransfer(InputAmbInvest in){
 		Result res =new Result();
+		if(!TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)&&!TokenManager.hasRole(AFTConstants.APPROVAL_DECISION_AUDITOR)){
+			in.setRoleType(0);
+			if (in.getMyAmbId()==null){
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"发起部门","发起部门"));
+				return res;
+			}
+			if (in.getMyAmbId()!=null&&ambInvestService.checkMyAmb(in.getMyAmbId())){
+				res.getError().add(buildError("只有当前阿米巴负责人可以发起投资划拨。"));
+				return res;
+			}
+		}else {
+			in.setRoleType(1);
+		}
 		if (in.getStatus()==null){
 			in.setStatus(0);
 		} else if (in.getStatus()>1){
 			res.getError().add(buildError("状态不可大于发起。"));
 			return res;
 		}
-		if (in.getMyAmbId()!=null&&ambInvestService.checkMyAmb(in.getMyAmbId())){
-			res.getError().add(buildError("只有当前阿米巴负责人可以发起投资划拨。"));
-			return res;
-		}
+
 		res.data(ambInvestService.updateInvestTransfer(in));
 		return res;
 	}

+ 12 - 3
src/main/java/com/goafanti/ambSystem/service/Impl/AmbInvestServiceImpl.java

@@ -67,12 +67,19 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
         return 1;
     }
 
+    /**
+     *
+     * @param in 当前数据
+     * @param myAmb 发起方
+     */
     private void chekAmount(InputAmbInvest in, AmbSystem myAmb) {
         if (myAmb.getLvl()!=1){
             List<OutInvestList> outInvestLists = ambInvestMapper.selectAmbInvestDtailsList(in.getMyAmbId(), 0);
             BigDecimal count = new BigDecimal(0);
             for (OutInvestList outInvestList : outInvestLists) {
-                count=count.add(outInvestList.getAmount());
+                if (in.getId()!=null&&!in.getId().equals(outInvestList.getId())){
+                    count=count.add(outInvestList.getAmount());
+                }
             }
             count=count.add(in.getAmount());
             if (count.compareTo(myAmb.getSurplus())>0){
@@ -145,7 +152,9 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
     @Override
     public int updateInvestTransfer(InputAmbInvest in) {
         AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
-        chekAmount(in, myAmb);
+        if(in.getRoleType()==0){
+            chekAmount(in, myAmb);
+        }
         AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
         AmbInvest ambInvest=new AmbInvest();
         ambInvest.setId(in.getId());
@@ -176,7 +185,7 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
         if (in.getStatus()==2){
                 AmbSystem newMy=new AmbSystem();
                 newMy.setId(myAmb.getId());
-            if (!(myAmb.getId()==1L)){
+            if (myAmb.getId()==1L){
                 newMy.setForeign(myAmb.getForeign().add(ambInvest.getAmount()));
             }else {
                 newMy.setTotalAmount(myAmb.getTotalAmount().subtract(ambInvest.getAmount()));