|
@@ -161,9 +161,9 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
|
|
|
|
|
// 插入账款明细
|
|
// 插入账款明细
|
|
|
AccountItem accountItem = new AccountItem();
|
|
AccountItem accountItem = new AccountItem();
|
|
|
- accountItem.setAccItemType(Constant.accItemType.SHOU_KUAN.getName())
|
|
|
|
|
|
|
+ accountItem.setAccItemType(Constant.accItemType.FU_KUAN.getName())
|
|
|
.setObjectId(recPayVO.getObjectId()).setOrgId(recPayVO.getOrgId()).setStaffId(recPayVO.getStaffId())
|
|
.setObjectId(recPayVO.getObjectId()).setOrgId(recPayVO.getOrgId()).setStaffId(recPayVO.getStaffId())
|
|
|
- .setAccDate(recPayVO.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName()).setAmtRec(recPayItem.getAmtRec())
|
|
|
|
|
|
|
+ .setAccDate(recPayVO.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName()).setAmtPay(recPayItem.getAmtPay())
|
|
|
.setBiznisType("t_mac_rec_pay_item").setBiznisId(recPayItem.getItemId()).setBiznisNo(recPayVO.getRpNo())
|
|
.setBiznisType("t_mac_rec_pay_item").setBiznisId(recPayItem.getItemId()).setBiznisNo(recPayVO.getRpNo())
|
|
|
.setMakeStaff(recPayVO.getMakeStaff()).setCpId(recPayVO.getCpId());
|
|
.setMakeStaff(recPayVO.getMakeStaff()).setCpId(recPayVO.getCpId());
|
|
|
accountItemMapper.insert(accountItem);
|
|
accountItemMapper.insert(accountItem);
|
|
@@ -176,14 +176,14 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
// 插入资金流水
|
|
// 插入资金流水
|
|
|
MoneyAccountItem moneyAccountItem = new MoneyAccountItem();
|
|
MoneyAccountItem moneyAccountItem = new MoneyAccountItem();
|
|
|
moneyAccountItem.setMacId(recPayItem.getMacId()).setFlowType(Constant.FlowType.SHOU_FU_KUAN.getName())
|
|
moneyAccountItem.setMacId(recPayItem.getMacId()).setFlowType(Constant.FlowType.SHOU_FU_KUAN.getName())
|
|
|
- .setInvoiceId(recPayItem.getItemId()).setAmtInflow(recPayItem.getAmtRec()).setAccDate(recPayVO.getAccDate())
|
|
|
|
|
|
|
+ .setInvoiceId(recPayItem.getItemId()).setAmtInflow(recPayItem.getAmtPay().negate()).setAccDate(recPayVO.getAccDate())
|
|
|
.setMakeStaff(recPayItem.getMakeStaff()).setCpId(recPayItem.getCpId());
|
|
.setMakeStaff(recPayItem.getMakeStaff()).setCpId(recPayItem.getCpId());
|
|
|
moneyAccountItemMapper.insert(moneyAccountItem);
|
|
moneyAccountItemMapper.insert(moneyAccountItem);
|
|
|
|
|
|
|
|
// 更新资金账户
|
|
// 更新资金账户
|
|
|
MoneyAccount moneyAccountForUpdate = moneyAccountMapper.selectByIdForUpdate(recPayItem.getMacId());
|
|
MoneyAccount moneyAccountForUpdate = moneyAccountMapper.selectByIdForUpdate(recPayItem.getMacId());
|
|
|
MoneyAccount moneyAccountUpdate = new MoneyAccount();
|
|
MoneyAccount moneyAccountUpdate = new MoneyAccount();
|
|
|
- moneyAccountUpdate.setBalance(moneyAccountForUpdate.getBalance().add(recPayItem.getAmtRec()))
|
|
|
|
|
|
|
+ moneyAccountUpdate.setBalance(moneyAccountForUpdate.getBalance().add(recPayItem.getAmtPay().negate()))
|
|
|
.setMacId(moneyAccountForUpdate.getMacId());
|
|
.setMacId(moneyAccountForUpdate.getMacId());
|
|
|
moneyAccountService.updateByUuid(moneyAccountUpdate);
|
|
moneyAccountService.updateByUuid(moneyAccountUpdate);
|
|
|
}
|
|
}
|
|
@@ -193,8 +193,8 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
Account accountForUpdate = accountService.getCusAccountForUpdate(recPayVO.getObjectId());
|
|
Account accountForUpdate = accountService.getCusAccountForUpdate(recPayVO.getObjectId());
|
|
|
// 更新账款总表上付款的相关字段
|
|
// 更新账款总表上付款的相关字段
|
|
|
Account accountUpdate = new Account();
|
|
Account accountUpdate = new Account();
|
|
|
- accountUpdate.setReceipt(accountForUpdate.getReceipt().add(recPayVO.getSumAmtRec()))// 总付款金额
|
|
|
|
|
- .setReceiptResidue(accountForUpdate.getReceiptResidue().add(recPayVO.getSumAmtRec()))// 可退金额
|
|
|
|
|
|
|
+ accountUpdate.setPayment(accountForUpdate.getPayment().add(recPayVO.getSumAmtPay()))// 总付款金额
|
|
|
|
|
+ .setPaymentResidue(accountForUpdate.getPaymentResidue().add(recPayVO.getSumAmtPay()))// 可退金额
|
|
|
.setObjectId(accountForUpdate.getObjectId());
|
|
.setObjectId(accountForUpdate.getObjectId());
|
|
|
accountService.updateByUuid(accountUpdate);
|
|
accountService.updateByUuid(accountUpdate);
|
|
|
/********************* 付款的处理 end **********************/
|
|
/********************* 付款的处理 end **********************/
|
|
@@ -202,8 +202,8 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
|
|
|
|
|
/********************* 应付付款的处理 begin **********************/
|
|
/********************* 应付付款的处理 begin **********************/
|
|
|
// 应付付款的处理
|
|
// 应付付款的处理
|
|
|
- if (recPayVO.getReceivableList() != null && recPayVO.getReceivableList().size() > 0) {
|
|
|
|
|
- for (RecPayHandleItemVO recPayHandleItemVO : recPayVO.getReceivableList()) {
|
|
|
|
|
|
|
+ if (recPayVO.getPayableList() != null && recPayVO.getPayableList().size() > 0) {
|
|
|
|
|
+ for (RecPayHandleItemVO recPayHandleItemVO : recPayVO.getPayableList()) {
|
|
|
RecPayHandleItem recPayHandleItem = recPayHandleItemConvert.convertToPo(recPayHandleItemVO);
|
|
RecPayHandleItem recPayHandleItem = recPayHandleItemConvert.convertToPo(recPayHandleItemVO);
|
|
|
recPayHandleItem.setItemId(null).setRpId(recPay.getRpId()).setCpId(recPay.getCpId()).setAccDate(recPay.getAccDate());
|
|
recPayHandleItem.setItemId(null).setRpId(recPay.getRpId()).setCpId(recPay.getCpId()).setAccDate(recPay.getAccDate());
|
|
|
recPayHandleItemMapper.insert(recPayHandleItem);
|
|
recPayHandleItemMapper.insert(recPayHandleItem);
|
|
@@ -212,10 +212,10 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
AccountItem accountItemForUpdate = accountItemMapper.selectByIdForUpdate(recPayHandleItem.getAccItemId());
|
|
AccountItem accountItemForUpdate = accountItemMapper.selectByIdForUpdate(recPayHandleItem.getAccItemId());
|
|
|
AccountItem accountItemUpdate = new AccountItem();
|
|
AccountItem accountItemUpdate = new AccountItem();
|
|
|
// 核销金额,超出剩余应付金额
|
|
// 核销金额,超出剩余应付金额
|
|
|
- if (accountItemForUpdate.getAmtResidue().compareTo(recPayHandleItem.getAmtReceivableHandle()) == -1) {
|
|
|
|
|
|
|
+ if (accountItemForUpdate.getAmtResidue().compareTo(recPayHandleItem.getAmtPayableHandle()) == -1) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
|
|
|
}
|
|
}
|
|
|
- accountItemUpdate.setAmtHandle(accountItemForUpdate.getAmtHandle().add(recPayHandleItem.getAmtReceivableHandle()))
|
|
|
|
|
|
|
+ accountItemUpdate.setAmtHandle(accountItemForUpdate.getAmtHandle().add(recPayHandleItem.getAmtPayableHandle()))
|
|
|
.setAmtWaive(accountItemForUpdate.getAmtWaive().add(recPayHandleItem.getAmtWaive()))
|
|
.setAmtWaive(accountItemForUpdate.getAmtWaive().add(recPayHandleItem.getAmtWaive()))
|
|
|
.setItemId(recPayHandleItem.getAccItemId());
|
|
.setItemId(recPayHandleItem.getAccItemId());
|
|
|
// 剩余金额 = 应付金额-应付付款金额
|
|
// 剩余金额 = 应付金额-应付付款金额
|
|
@@ -224,9 +224,9 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 计算明细的核销金额,优惠金额合计
|
|
// 计算明细的核销金额,优惠金额合计
|
|
|
- RecPayHandleItemVO recPayHandleItemVO = recPayVO.getReceivableList().stream().reduce((x, y) -> {
|
|
|
|
|
|
|
+ RecPayHandleItemVO recPayHandleItemVO = recPayVO.getPayableList().stream().reduce((x, y) -> {
|
|
|
RecPayHandleItemVO item = new RecPayHandleItemVO();
|
|
RecPayHandleItemVO item = new RecPayHandleItemVO();
|
|
|
- item.setAmtReceivableHandle(x.getAmtReceivableHandle().add(y.getAmtReceivableHandle()));
|
|
|
|
|
|
|
+ item.setAmtPayableHandle(x.getAmtPayableHandle().add(y.getAmtPayableHandle()));
|
|
|
item.setAmtWaive(x.getAmtWaive().add(y.getAmtWaive()));
|
|
item.setAmtWaive(x.getAmtWaive().add(y.getAmtWaive()));
|
|
|
return item;
|
|
return item;
|
|
|
}).get();
|
|
}).get();
|
|
@@ -234,21 +234,21 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
// 更新总账上
|
|
// 更新总账上
|
|
|
accountForUpdate = accountMapper.selectByIdForUpdate(recPayVO.getObjectId());
|
|
accountForUpdate = accountMapper.selectByIdForUpdate(recPayVO.getObjectId());
|
|
|
accountUpdate = new Account();
|
|
accountUpdate = new Account();
|
|
|
- accountUpdate.setReceivableHandle(accountForUpdate.getReceivableHandle().add(recPayHandleItemVO.getAmtReceivableHandle()))// 总应付付款金额
|
|
|
|
|
- .setReceivableWaive(accountForUpdate.getReceivableWaive().add(recPayHandleItemVO.getAmtWaive()))// 总应付优惠金额
|
|
|
|
|
|
|
+ accountUpdate.setPayableHandle(accountForUpdate.getPayableHandle().add(recPayHandleItemVO.getAmtPayableHandle()))// 总应付付款金额
|
|
|
|
|
+ .setPayableWaive(accountForUpdate.getPayableWaive().add(recPayHandleItemVO.getAmtWaive()))// 总应付优惠金额
|
|
|
.setObjectId(accountForUpdate.getObjectId());
|
|
.setObjectId(accountForUpdate.getObjectId());
|
|
|
// 剩余应付 = 总应付账款-总应付付款金额
|
|
// 剩余应付 = 总应付账款-总应付付款金额
|
|
|
- accountUpdate.setReceivableResidue(accountForUpdate.getReceivable().subtract(accountUpdate.getReceivableHandle()));
|
|
|
|
|
|
|
+ accountUpdate.setPayableResidue(accountForUpdate.getPayable().subtract(accountUpdate.getPayableHandle()));
|
|
|
// 可退金额 = 总付款金额-总应付付款金额+总应付优惠金额
|
|
// 可退金额 = 总付款金额-总应付付款金额+总应付优惠金额
|
|
|
- accountUpdate.setReceiptResidue(accountForUpdate.getReceipt().subtract(accountUpdate.getReceivableHandle()).add(accountUpdate.getReceivableWaive()));
|
|
|
|
|
|
|
+ accountUpdate.setPaymentResidue(accountForUpdate.getPayment().subtract(accountUpdate.getPayableHandle()).add(accountUpdate.getPayableWaive()));
|
|
|
|
|
|
|
|
// 更新前的最后校验
|
|
// 更新前的最后校验
|
|
|
// 剩余应付为负数,则不能保存
|
|
// 剩余应付为负数,则不能保存
|
|
|
- if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
|
|
|
|
+ if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
|
|
|
}
|
|
}
|
|
|
// 可用金额为负数,则不能保存
|
|
// 可用金额为负数,则不能保存
|
|
|
- if (accountUpdate.getReceiptResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
|
|
|
|
+ if (accountUpdate.getPaymentResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
|
|
|
}
|
|
}
|
|
|
accountService.updateByUuid(accountUpdate);
|
|
accountService.updateByUuid(accountUpdate);
|
|
@@ -277,7 +277,7 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
// 更新账款明细应付付款
|
|
// 更新账款明细应付付款
|
|
|
accountItemForUpdate = accountItemMapper.selectByIdForUpdate(recPayHandleItemForUpdate.getAccItemId());
|
|
accountItemForUpdate = accountItemMapper.selectByIdForUpdate(recPayHandleItemForUpdate.getAccItemId());
|
|
|
AccountItem accountItemUpdate = new AccountItem();
|
|
AccountItem accountItemUpdate = new AccountItem();
|
|
|
- accountItemUpdate.setAmtHandle(accountItemForUpdate.getAmtHandle().subtract(recPayHandleItemForUpdate.getAmtReceivableHandle()))
|
|
|
|
|
|
|
+ accountItemUpdate.setAmtHandle(accountItemForUpdate.getAmtHandle().subtract(recPayHandleItemForUpdate.getAmtPayableHandle()))
|
|
|
.setAmtWaive(accountItemForUpdate.getAmtWaive().subtract(recPayHandleItemForUpdate.getAmtWaive()))
|
|
.setAmtWaive(accountItemForUpdate.getAmtWaive().subtract(recPayHandleItemForUpdate.getAmtWaive()))
|
|
|
.setItemId(recPayHandleItemForUpdate.getAccItemId());
|
|
.setItemId(recPayHandleItemForUpdate.getAccItemId());
|
|
|
accountItemUpdate.setAmtResidue(accountItemForUpdate.getAmtShould().subtract(accountItemUpdate.getAmtHandle()).subtract(accountItemUpdate.getAmtWaive()));
|
|
accountItemUpdate.setAmtResidue(accountItemForUpdate.getAmtShould().subtract(accountItemUpdate.getAmtHandle()).subtract(accountItemUpdate.getAmtWaive()));
|
|
@@ -292,21 +292,21 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
// 把总帐上的钱加回来
|
|
// 把总帐上的钱加回来
|
|
|
Account accountForUpdate = accountMapper.selectByIdForUpdate(recPayForUpdate.getObjectId());
|
|
Account accountForUpdate = accountMapper.selectByIdForUpdate(recPayForUpdate.getObjectId());
|
|
|
Account accountUpdate = new Account();
|
|
Account accountUpdate = new Account();
|
|
|
- accountUpdate.setReceivableHandle(accountForUpdate.getReceivableHandle().subtract(recPayForUpdate.getSumAmtReceivableHandle()))// 总应付付款金额
|
|
|
|
|
- .setReceivableWaive(accountForUpdate.getReceivableWaive().subtract(recPayForUpdate.getSumWaiveAmt()))// 总应付优惠金额
|
|
|
|
|
|
|
+ accountUpdate.setPayableHandle(accountForUpdate.getPayableHandle().subtract(recPayForUpdate.getSumAmtPayableHandle()))// 总应付付款金额
|
|
|
|
|
+ .setPayableWaive(accountForUpdate.getPayableWaive().subtract(recPayForUpdate.getSumWaiveAmt()))// 总应付优惠金额
|
|
|
.setObjectId(accountForUpdate.getObjectId());
|
|
.setObjectId(accountForUpdate.getObjectId());
|
|
|
// 剩余应付 = 总应付账款-总应付付款金额
|
|
// 剩余应付 = 总应付账款-总应付付款金额
|
|
|
- accountUpdate.setReceivableResidue(accountForUpdate.getReceivable().subtract(accountUpdate.getReceivableHandle()));
|
|
|
|
|
|
|
+ accountUpdate.setPayableResidue(accountForUpdate.getPayable().subtract(accountUpdate.getPayableHandle()));
|
|
|
// 可退金额 = 总付款金额-总应付付款金额+总应付优惠金额
|
|
// 可退金额 = 总付款金额-总应付付款金额+总应付优惠金额
|
|
|
- accountUpdate.setReceiptResidue(accountForUpdate.getReceipt().subtract(accountUpdate.getReceivableHandle()).add(accountUpdate.getReceivableWaive()));
|
|
|
|
|
|
|
+ accountUpdate.setPaymentResidue(accountForUpdate.getPayment().subtract(accountUpdate.getPayableHandle()).add(accountUpdate.getPayableWaive()));
|
|
|
|
|
|
|
|
// 更新前的最后校验
|
|
// 更新前的最后校验
|
|
|
// 剩余应付为负数,则不能保存
|
|
// 剩余应付为负数,则不能保存
|
|
|
- if (accountUpdate.getReceivableResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
|
|
|
|
+ if (accountUpdate.getPayableResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.AMT_HANDLE_NO_LESS_AMT_SHOULD.getMessage());
|
|
|
}
|
|
}
|
|
|
// 可用金额为负数,则不能保存
|
|
// 可用金额为负数,则不能保存
|
|
|
- if (accountUpdate.getReceiptResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
|
|
|
|
+ if (accountUpdate.getPaymentResidue().compareTo(BigDecimal.ZERO) == -1) {
|
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
|
|
throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.MAC_BALANCE_NO_LESS.getMessage());
|
|
|
}
|
|
}
|
|
|
accountService.updateByUuid(accountUpdate);
|
|
accountService.updateByUuid(accountUpdate);
|
|
@@ -328,7 +328,7 @@ public class PaymentService extends BaseService<RecPay> {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
// 更新总账表的总付款额和可用额
|
|
// 更新总账表的总付款额和可用额
|
|
|
- accountService.updateReceipt(recPayForUpdate.getObjectId());
|
|
|
|
|
|
|
+ accountService.updatePayment(recPayForUpdate.getObjectId());
|
|
|
// 更新账户余额
|
|
// 更新账户余额
|
|
|
for (String macId : macList) {
|
|
for (String macId : macList) {
|
|
|
accountService.updateMac(macId);
|
|
accountService.updateMac(macId);
|