Эх сурвалжийг харах

其他收入、支出,加大编辑标识

fubin 1 жил өмнө
parent
commit
3681cfe09f

+ 1 - 1
src/main/java/com/dk/mdm/mapper/mac/RecPayHandleItemMapper.xml

@@ -42,7 +42,7 @@
             AND t.rp_id = #{rpId}::uuid
         </if>
         <if test="accItemId != null and accItemId != ''">
-            AND t.acc_item_id = #{accItemId}
+            AND t.acc_item_id = #{accItemId}::uuid
         </if>
         <if test="amtReceivableHandle != null">
             AND t.amt_receivable_handle = #{amtReceivableHandle}

+ 1 - 1
src/main/java/com/dk/mdm/mapper/mac/RecPayItemMapper.xml

@@ -50,7 +50,7 @@
                 AND t.rp_id = #{rpId}::uuid
             </if>
             <if test="macId != null and macId != ''">
-                AND t.mac_id = #{macId}
+                AND t.mac_id = #{macId}::uuid
             </if>
             <if test="amtRec != null">
                 AND t.amt_rec = #{amtRec}

+ 3 - 0
src/main/java/com/dk/mdm/model/response/mac/OtherPayableResponse.java

@@ -201,5 +201,8 @@ public class OtherPayableResponse extends PageInfo<OtherPayableResponse> impleme
     @ApiModelProperty(value = "合计付款")
     private BigDecimal sumAmtPay;
 
+    @ApiModelProperty(value = "大编辑标识")
+    private Boolean daEdit;
+
     private static final long serialVersionUID = 1L;
 }

+ 3 - 0
src/main/java/com/dk/mdm/model/response/mac/OtherReceivableResponse.java

@@ -211,6 +211,9 @@ public class OtherReceivableResponse extends PageInfo<OtherReceivableResponse> i
     @ApiModelProperty(value = "合计收款")
     private BigDecimal sumAmtRec;
 
+    @ApiModelProperty(value = "大编辑标识")
+    private Boolean daEdit;
+
     private static final long serialVersionUID = 1L;
 
 }

+ 38 - 17
src/main/java/com/dk/mdm/service/mac/OtherPayableService.java

@@ -23,11 +23,9 @@ import com.dk.mdm.model.pojo.mst.MoneyAccount;
 import com.dk.mdm.model.pojo.mst.MoneyAccountItem;
 import com.dk.mdm.model.query.mac.OtherPayableItemQuery;
 import com.dk.mdm.model.query.mac.OtherPayableQuery;
+import com.dk.mdm.model.query.mac.RecPayHandleItemQuery;
 import com.dk.mdm.model.query.mac.RecPayItemQuery;
-import com.dk.mdm.model.response.mac.OtherPayableItemResponse;
-import com.dk.mdm.model.response.mac.OtherPayableResponse;
-import com.dk.mdm.model.response.mac.RecPayItemResponse;
-import com.dk.mdm.model.response.mac.RecPayResponse;
+import com.dk.mdm.model.response.mac.*;
 import com.dk.mdm.model.vo.mac.OtherPayableItemVO;
 import com.dk.mdm.model.vo.mac.OtherPayableVO;
 import com.dk.mdm.model.vo.mac.RecPayItemVO;
@@ -148,7 +146,7 @@ public class OtherPayableService extends BaseService<OtherPayable> {
     )
     public ResponseResultVO<?> insert(OtherPayableVO otherPayableVO) {
         // 付款金额不能大于支出金额
-        if(otherPayableVO.getSumAmtPay().compareTo(otherPayableVO.getSumAmtPayable()) == 1){
+        if (otherPayableVO.getSumAmtPay().compareTo(otherPayableVO.getSumAmtPayable()) == 1) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PAYABLE_NO_LESS_PAYMENT.getMessage());
         }
 
@@ -268,9 +266,9 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 
             // 更新前的最后校验
             // 剩余应付为负数,则不能保存
-            if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
-            }
+//            if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
+//            }
             // 可用金额为负数,则不能保存
             if (accountUpdate.getPaymentResidue().compareTo(BigDecimal.ZERO) == -1) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
@@ -300,13 +298,13 @@ public class OtherPayableService extends BaseService<OtherPayable> {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVOICE_ISQICHU.getMessage());
         }
         // 付款金额不能大于支出金额
-        if(otherPayableVO.getSumAmtPay().compareTo(otherPayableVO.getSumAmtPayable()) == 1){
+        if (otherPayableVO.getSumAmtPay().compareTo(otherPayableVO.getSumAmtPayable()) == 1) {
             throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PAYABLE_NO_LESS_PAYMENT.getMessage());
         }
 
         /*******************************************  应付付款的处理 begin ********************************************/
         RecPay recPayForUpdate = recPayMapper.selectByBiznisIdForUpdate(otherPayableVO.getPayableId(), false);
-        if(recPayForUpdate != null && recPayForUpdate.getFlgValid()) {
+        if (recPayForUpdate != null && recPayForUpdate.getFlgValid()) {
             // 查出并锁定所有应付核销明细
             AccountItem accountItemForUpdate;
             List<RecPayHandleItem> recPayHandleItemForUpdateList = recPayHandleItemMapper.selectByZIdForUpdate(recPayForUpdate.getRpId());
@@ -339,9 +337,9 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 
             // 更新前的最后校验
             // 剩余应付为负数,则不能保存
-            if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
-            }
+//            if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
+//            }
             // 可用金额为负数,则不能保存
             if (accountUpdate.getPaymentResidue().compareTo(BigDecimal.ZERO) == -1) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
@@ -497,9 +495,9 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 
             // 更新前的最后校验
             // 剩余应付为负数,则不能保存
-            if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
-            }
+//            if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
+//            }
             // 可用金额为负数,则不能保存
             if (accountUpdate.getPaymentResidue().compareTo(BigDecimal.ZERO) == -1) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
@@ -518,6 +516,29 @@ public class OtherPayableService extends BaseService<OtherPayable> {
     public ResponseResultVO<?> getOtherPayableForUpdate(String id) {
         Map<String, Object> dataInfo = new HashMap<>();
         OtherPayableResponse otherPayableResponse = otherPayableMapper.selectById(id);
+
+        // 判断是否能大编辑
+        otherPayableResponse.setDaEdit(true);
+        if (otherPayableResponse.getAccItemId() != null) {
+            // 查出新建时是否付款了
+            RecPay recPayForUpdate = recPayMapper.selectByBiznisIdForUpdate(id, false);
+            // 查出有多少次付款
+            List<RecPayHandleItemResponse> RecPayHandleItemResponseList = recPayHandleItemMapper.selectByCond(new RecPayHandleItemQuery().setAccItemId(otherPayableResponse.getAccItemId()));
+            if (RecPayHandleItemResponseList != null && RecPayHandleItemResponseList.size() > 0) {
+                // 如果有付款,并且新建时没付款,则不能大编辑
+                if(recPayForUpdate == null){
+                    otherPayableResponse.setDaEdit(false);
+                }else{
+                    for(RecPayHandleItemResponse  recPayHandleItemResponse :RecPayHandleItemResponseList){
+                        // 如果核销id不是第一次付款id,不能大编辑
+                        if(!recPayHandleItemResponse.getRpId().equals(recPayForUpdate.getRpId())){
+                            otherPayableResponse.setDaEdit(false);
+                        }
+                    }
+                }
+            }
+        }
+        // 支出明细
         dataInfo.put("data", otherPayableResponse);
 
         // 商品明细
@@ -551,7 +572,7 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 
         /*******************************************  应付付款的处理 begin ********************************************/
         RecPay recPayForUpdate = recPayMapper.selectByBiznisIdForUpdate(id, false);
-        if(recPayForUpdate != null && recPayForUpdate.getFlgValid()) {
+        if (recPayForUpdate != null && recPayForUpdate.getFlgValid()) {
             // 查出并锁定所有应付核销明细
             AccountItem accountItemForUpdate;
             List<RecPayHandleItem> recPayHandleItemForUpdateList = recPayHandleItemMapper.selectByZIdForUpdate(recPayForUpdate.getRpId());

+ 33 - 13
src/main/java/com/dk/mdm/service/mac/OtherReceivableService.java

@@ -22,11 +22,9 @@ import com.dk.mdm.model.pojo.mst.MoneyAccount;
 import com.dk.mdm.model.pojo.mst.MoneyAccountItem;
 import com.dk.mdm.model.query.mac.OtherReceivableItemQuery;
 import com.dk.mdm.model.query.mac.OtherReceivableQuery;
+import com.dk.mdm.model.query.mac.RecPayHandleItemQuery;
 import com.dk.mdm.model.query.mac.RecPayItemQuery;
-import com.dk.mdm.model.response.mac.OtherReceivableItemResponse;
-import com.dk.mdm.model.response.mac.OtherReceivableResponse;
-import com.dk.mdm.model.response.mac.RecPayItemResponse;
-import com.dk.mdm.model.response.mac.RecPayResponse;
+import com.dk.mdm.model.response.mac.*;
 import com.dk.mdm.model.vo.mac.OtherReceivableItemVO;
 import com.dk.mdm.model.vo.mac.OtherReceivableVO;
 import com.dk.mdm.model.vo.mac.RecPayItemVO;
@@ -267,9 +265,9 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
 
             // 更新前的最后校验
             // 剩余应收为负数,则不能保存
-            if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
-            }
+//            if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
+//            }
             // 可用金额为负数,则不能保存
             if (accountUpdate.getReceiptResidue().compareTo(BigDecimal.ZERO) == -1) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
@@ -339,9 +337,9 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
 
             // 更新前的最后校验
             // 剩余应收为负数,则不能保存
-            if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
-            }
+//            if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
+//            }
             // 可用金额为负数,则不能保存
             if (accountUpdate.getReceiptResidue().compareTo(BigDecimal.ZERO) == -1) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
@@ -498,9 +496,9 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
 
             // 更新前的最后校验
             // 剩余应收为负数,则不能保存
-            if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
-            }
+//            if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
+//                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
+//            }
             // 可用金额为负数,则不能保存
             if (accountUpdate.getReceiptResidue().compareTo(BigDecimal.ZERO) == -1) {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
@@ -519,6 +517,28 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
     public ResponseResultVO<?> getOtherReceivableForUpdate(String id) {
         Map<String, Object> dataInfo = new HashMap<>();
         OtherReceivableResponse otherReceivableResponse = otherReceivableMapper.selectById(id);
+
+        // 判断是否能大编辑
+        otherReceivableResponse.setDaEdit(true);
+        if (otherReceivableResponse.getAccItemId() != null) {
+            // 查出新建时是否收款了
+            RecPay recPayForUpdate = recPayMapper.selectByBiznisIdForUpdate(id, false);
+            // 查出有多少次收款
+            List<RecPayHandleItemResponse> RecPayHandleItemResponseList = recPayHandleItemMapper.selectByCond(new RecPayHandleItemQuery().setAccItemId(otherReceivableResponse.getAccItemId()));
+            if (RecPayHandleItemResponseList != null && RecPayHandleItemResponseList.size() > 0) {
+                // 如果有收款,并且新建时没收款,则不能大编辑
+                if(recPayForUpdate == null){
+                    otherReceivableResponse.setDaEdit(false);
+                }else{
+                    for(RecPayHandleItemResponse  recPayHandleItemResponse :RecPayHandleItemResponseList){
+                        // 如果核销id不是第一次收款id,不能大编辑
+                        if(!recPayHandleItemResponse.getRpId().equals(recPayForUpdate.getRpId())){
+                            otherReceivableResponse.setDaEdit(false);
+                        }
+                    }
+                }
+            }
+        }
         dataInfo.put("data", otherReceivableResponse);
 
         // 收入明细