Browse Source

投资成功修改

anderx 3 years ago
parent
commit
e6c61c56fe

+ 10 - 2
src/main/java/com/goafanti/ambSystem/bo/InputAmbInvest.java

@@ -8,8 +8,7 @@ import java.math.BigDecimal;
 
 public class InputAmbInvest {
     private Long id;
-    @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
-    @Param(name = "发起阿米巴编号")
+
     private Long myAmbId;
     @NotNull(message = "{"+ ErrorConstants.PARAM_EMPTY_ERROR+"}")
     @Param(name = "接收阿米巴编号")
@@ -19,7 +18,16 @@ public class InputAmbInvest {
     private BigDecimal amount;
     private String comment;
     private Integer status;
+    /** 0其他 1董事长或助理*/
+    private Integer roleType;
 
+    public Integer getRoleType() {
+        return roleType;
+    }
+
+    public void setRoleType(Integer roleType) {
+        this.roleType = roleType;
+    }
 
     public Long getId() {
         return id;

+ 12 - 0
src/main/java/com/goafanti/ambSystem/bo/InputInvestList.java

@@ -3,6 +3,18 @@ package com.goafanti.ambSystem.bo;
 public class InputInvestList {
     private Integer pageSize;
     private Integer pageNo;
+    /**
+     * 0 巴主发起列表 1财务审核列表
+     */
+    private Integer roleType;
+
+    public Integer getRoleType() {
+        return roleType;
+    }
+
+    public void setRoleType(Integer roleType) {
+        this.roleType = roleType;
+    }
 
     public Integer getPageSize() {
         return pageSize;

+ 9 - 0
src/main/java/com/goafanti/ambSystem/controller/AmbInvestApiController.java

@@ -6,10 +6,12 @@ import com.goafanti.ambSystem.bo.InputInvestList;
 import com.goafanti.ambSystem.service.AmbInvestService;
 import com.goafanti.ambSystem.service.AmbService;
 import com.goafanti.common.bo.Result;
+import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.constant.ErrorConstants;
 import com.goafanti.common.controller.CertifyApiController;
 import com.goafanti.common.enums.ActivityFields;
 import com.goafanti.common.utils.ParamUtils;
+import com.goafanti.core.shiro.token.TokenManager;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.validation.annotation.Validated;
@@ -39,6 +41,13 @@ public class AmbInvestApiController extends CertifyApiController {
 					ParamUtils.getParamName(in,bindingResult.getFieldError().getField())));
 			return res;
 		}
+		if(!TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)&&!TokenManager.hasRole(AFTConstants.APPROVAL_DECISION_AUDITOR)){
+			in.setRoleType(1);
+			if (in.getMyAmbId()==null){
+				res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR,"发起部门","发起部门"));
+				return res;
+			}
+		}
 		if (in.getStatus()==null){
 			in.setStatus(0);
 		} else if (in.getStatus()>1){

+ 19 - 10
src/main/java/com/goafanti/ambSystem/service/Impl/AmbInvestServiceImpl.java

@@ -45,10 +45,16 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
     @Override
     @Transactional
     public int pushInvestTransfer(InputAmbInvest in) {
-        AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
+        AmbSystem myAmb =null;
+        if (in.getRoleType()==1){
+            myAmb= ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
+        }else {
+            myAmb=ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
+
+        }
         AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
         AmbInvest ambInvest=new AmbInvest();
-        ambInvest.setInitiateAmbId(in.getMyAmbId());
+        ambInvest.setInitiateAmbId(myAmb.getId());
         ambInvest.setAcceptAmbId(in.getOtherAmbId());
         ambInvest.setAmount(in.getAmount());
         ambInvest.setStatus(in.getStatus());
@@ -104,8 +110,9 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
     @Override
     public Pagination<?> InvestList(InputInvestList in) {
         Map<String,Object> params=new HashMap<>();
-        if (TokenManager.hasRole(AFTConstants.FINANCE_ADMIN)){
-            params.put("roleType",1);
+        if (in.getRoleType()!=null){
+            params.put("roleType",in.getRoleType());
+            params.put("aid",TokenManager.getAdminId());
         }
 
         return findPage("selectInvestList","selectInvestCount",params,in.getPageNo(),in.getPageSize());
@@ -147,17 +154,19 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
         newAmbInvest.setStatus(in.getStatus());
         newAmbInvest.setAmount(ambInvest.getAmount());
         if (in.getStatus()==2){
-            AmbSystem newMy=new AmbSystem();
-            newMy.setId(myAmb.getId());
-            newMy.setTotalAmount(myAmb.getTotalAmount().subtract(ambInvest.getAmount()));
-            newMy.setSurplus(myAmb.getSurplus().subtract(ambInvest.getAmount()));
-            newMy.setForeign(myAmb.getForeign().add(ambInvest.getAmount()));
+            if (!(myAmb.getId()==1L)){
+                AmbSystem newMy=new AmbSystem();
+                newMy.setId(myAmb.getId());
+                newMy.setTotalAmount(myAmb.getTotalAmount().subtract(ambInvest.getAmount()));
+                newMy.setSurplus(myAmb.getSurplus().subtract(ambInvest.getAmount()));
+                newMy.setForeign(myAmb.getForeign().add(ambInvest.getAmount()));
+                ambSystemMapper.updateByPrimaryKeySelective(newMy);
+            }
             AmbSystem newOther=new AmbSystem();
             newOther.setId(other.getId());
             newOther.setReceived(other.getReceived().add(ambInvest.getAmount()));
             newOther.setSurplus(other.getSurplus().add(ambInvest.getAmount()));
             newOther.setTotalAmount(other.getTotalAmount().add(ambInvest.getAmount()));
-            ambSystemMapper.updateByPrimaryKeySelective(newMy);
             ambSystemMapper.updateByPrimaryKeySelective(newOther);
             sumCountAmount(newOther.getId(), newAmbInvest);
         }

+ 6 - 0
src/main/java/com/goafanti/common/mapper/AmbInvestMapper.xml

@@ -140,6 +140,9 @@
     left join admin d on a.operator =d.id
     where 1=1
     <if test="roleType==1">
+      and a.operator= #{aid}
+    </if>
+    <if test="roleType==2">
       and a.status in (1,2,3)
     </if>
     order by a.create_time desc
@@ -153,6 +156,9 @@
     from amb_invest a
     where 1=1
     <if test="roleType==1">
+      and a.operator= #{aid}
+    </if>
+    <if test="roleType==2">
       and a.status in (1,2,3)
     </if>
   </select>