|
|
@@ -1,9 +1,12 @@
|
|
|
package com.dk.mdm.service.mac;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.dk.common.exception.BaseBusinessException;
|
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
|
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
|
|
|
import com.dk.common.model.pojo.PageList;
|
|
|
+import com.dk.common.response.ResponseCodeEnum;
|
|
|
import com.dk.common.response.ResponseResultUtil;
|
|
|
import com.dk.common.response.ResponseResultVO;
|
|
|
import com.dk.mdm.infrastructure.convert.mac.RecPayConvert;
|
|
|
@@ -177,7 +180,10 @@ public class RecPayService extends BaseService<RecPay> {
|
|
|
public ResponseResultVO<?> insertRefund(RecPayVO recPayVO) {
|
|
|
|
|
|
// 查总账,看可退金额是否满足
|
|
|
-
|
|
|
+ Account accountForUpdate = accountMapper.selectByIdForUpdate(recPayVO.getObjectId());
|
|
|
+ if (accountForUpdate == null || accountForUpdate.getReceiptResidue().compareTo(recPayVO.getSumAmtRec().abs()) == -1) {
|
|
|
+ throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.RESIDUE_NO_LESS.getMessage());
|
|
|
+ }
|
|
|
|
|
|
// 获取单号
|
|
|
Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.RECPAY.getName(), false);
|
|
|
@@ -210,17 +216,6 @@ public class RecPayService extends BaseService<RecPay> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 插入账款总表
|
|
|
- Account accountForUpdate = accountMapper.selectByIdForUpdate(recPayVO.getObjectId());
|
|
|
-
|
|
|
- // 没有账款对象,需要新建
|
|
|
- if (accountForUpdate == null) {
|
|
|
- accountForUpdate = new Account();
|
|
|
- accountForUpdate.setObjectId(recPayVO.getObjectId()).setObjectType(Constant.ObjectType.CUS.getName());
|
|
|
- accountMapper.insert(accountForUpdate);
|
|
|
- accountForUpdate = accountMapper.selectByIdForUpdate(recPayVO.getObjectId());
|
|
|
- }
|
|
|
-
|
|
|
// 更新账款总表上收款的相关字段
|
|
|
Account accountUpdate = new Account();
|
|
|
accountUpdate.setReceipt(accountForUpdate.getReceipt().add(recPayVO.getSumAmtRec()))// 总收款金额
|