Browse Source

阿米巴发起划拨开发

anderx 3 years ago
parent
commit
eccf8dbe7a

+ 13 - 2
src/main/java/com/goafanti/ambSystem/controller/AmbInvestApiController.java

@@ -2,6 +2,7 @@ package com.goafanti.ambSystem.controller;
 
 import com.goafanti.ambSystem.bo.InputAmb;
 import com.goafanti.ambSystem.bo.InputAmbInvest;
+import com.goafanti.ambSystem.service.AmbInvestService;
 import com.goafanti.ambSystem.service.AmbService;
 import com.goafanti.common.bo.Result;
 import com.goafanti.common.constant.ErrorConstants;
@@ -21,7 +22,7 @@ import java.math.BigDecimal;
 @RequestMapping(value = "/api/admin/amb/Invest")
 public class AmbInvestApiController extends CertifyApiController {
 	@Autowired
-	private AmbService ambService;
+	private AmbInvestService ambInvestService;
 
 	/**
 	 * 划拨金额
@@ -38,7 +39,17 @@ public class AmbInvestApiController extends CertifyApiController {
 			res.getError().add(buildErrorMessageParams(ErrorConstants.PARAM_EMPTY_ERROR,"金额"));
 			return res;
 		}
-		res.data(ambService.pushInvestTransfer(in));
+		if (in.getStatus()==null){
+			in.setStatus(0);
+		} else if (in.getStatus()>1){
+			res.getError().add(buildError("状态不可大于发起。"));
+			return res;
+		}
+		if (ambInvestService.checkMyAmb(in.getMyAmbId())){
+			res.getError().add(buildError("只有当前阿米巴负责人可以发起投资划拨。"));
+			return res;
+		}
+		res.data(ambInvestService.pushInvestTransfer(in));
 		return res;
 	}
 

+ 9 - 0
src/main/java/com/goafanti/ambSystem/service/AmbInvestService.java

@@ -0,0 +1,9 @@
+package com.goafanti.ambSystem.service;
+
+import com.goafanti.ambSystem.bo.InputAmbInvest;
+
+public interface AmbInvestService {
+    int pushInvestTransfer(InputAmbInvest in);
+
+    boolean checkMyAmb(Long myAmbId);
+}

+ 0 - 1
src/main/java/com/goafanti/ambSystem/service/AmbService.java

@@ -30,5 +30,4 @@ public interface AmbService {
 
 
 
-    int pushInvestTransfer(InputAmbInvest in);
 }

+ 59 - 0
src/main/java/com/goafanti/ambSystem/service/Impl/AmbInvestServiceImpl.java

@@ -0,0 +1,59 @@
+package com.goafanti.ambSystem.service.Impl;
+
+import com.goafanti.ambSystem.bo.InputAmbInvest;
+import com.goafanti.ambSystem.service.AmbInvestService;
+import com.goafanti.ambSystem.service.AmbPaymentService;
+import com.goafanti.common.dao.AmbInvestLogMapper;
+import com.goafanti.common.dao.AmbInvestMapper;
+import com.goafanti.common.dao.AmbPaymentApplicationMapper;
+import com.goafanti.common.dao.AmbSystemMapper;
+import com.goafanti.common.error.BusinessException;
+import com.goafanti.common.model.AmbInvest;
+import com.goafanti.common.model.AmbInvestLog;
+import com.goafanti.common.model.AmbSystem;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.shiro.token.TokenManager;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implements AmbInvestService {
+    @Autowired
+    private AmbSystemMapper ambSystemMapper;
+    @Autowired
+    private AmbInvestMapper ambInvestMapper;
+    @Autowired
+    private AmbInvestLogMapper ambInvestLogMapper;
+
+
+
+    @Override
+    @Transactional
+    public int pushInvestTransfer(InputAmbInvest in) {
+        AmbInvest ambInvest=new AmbInvest();
+        ambInvest.setInitiateAmbId(in.getMyAmbId());
+        ambInvest.setAcceptAmbId(in.getOtherAmbId());
+        ambInvest.setAmount(in.getAmount());
+        ambInvest.setStatus(in.getStatus());
+        ambInvest.setOperator(TokenManager.getAdminId());
+        ambInvest.setComment(in.getComment());
+        ambInvestMapper.insertSelective(ambInvest);
+        AmbInvestLog log=new AmbInvestLog();
+        log.setAmbInvestId(ambInvest.getId());
+        log.setComment(in.getComment());
+        log.setOperator(TokenManager.getAdminId());
+        log.setStatus(1);
+        ambInvestLogMapper.insertSelective(log);
+        return 1;
+    }
+
+    @Override
+    public boolean checkMyAmb(Long myAmbId) {
+        AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(myAmbId);
+        if (!myAmb.getLeader().equals(TokenManager.getAdminId())){
+            return true;
+        }
+        return false;
+    }
+}

+ 1 - 23
src/main/java/com/goafanti/ambSystem/service/Impl/AmbServiceImpl.java

@@ -217,27 +217,5 @@ public class AmbServiceImpl extends BaseMybatisDao<AmbSystemMapper> implements A
     }
 
 
-    @Override
-    @Transactional
-    public int pushInvestTransfer(InputAmbInvest in) {
-        AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
-        if (!myAmb.getLeader().equals(TokenManager.getAdminId())){
-            throw new BusinessException("只有当前部门负责人可以发起投资划拨");
-        }
-        AmbInvest ambInvest=new AmbInvest();
-        ambInvest.setInitiateAmbId(in.getMyAmbId());
-        ambInvest.setAcceptAmbId(in.getOtherAmbId());
-        ambInvest.setAmount(in.getAmount());
-        ambInvest.setStatus(in.getStatus()==null?1:in.getStatus());
-        ambInvest.setOperator(TokenManager.getAdminId());
-        ambInvest.setComment(in.getComment());
-        ambInvestMapper.insertSelective(ambInvest);
-        AmbInvestLog log=new AmbInvestLog();
-        log.setAmbInvestId(ambInvest.getId());
-        log.setComment(in.getComment());
-        log.setOperator(TokenManager.getAdminId());
-        log.setStatus(1);
-        ambInvestLogMapper.insertSelective(log);
-        return 1;
-    }
+
 }