|
|
@@ -106,14 +106,78 @@ public class RecPayService extends BaseService<RecPay> {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc : 新建方法
|
|
|
+ * @desc : 新建收款
|
|
|
* @author : 付斌
|
|
|
* @date : 2023/1/9 10:49
|
|
|
*/
|
|
|
@Transactional(
|
|
|
rollbackFor = {Exception.class}
|
|
|
)
|
|
|
- public ResponseResultVO<?> insert(RecPayVO recPayVO) {
|
|
|
+ public ResponseResultVO<?> insertReceipt(RecPayVO recPayVO) {
|
|
|
+
|
|
|
+ // 获取单号
|
|
|
+ Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.RECPAY.getName(), false);
|
|
|
+ recPayVO.setRpId(codeMap.get("outId").toString()).setRpNo(codeMap.get("outNote").toString());
|
|
|
+ // 转化实体
|
|
|
+ RecPay recPay = recPayConvert.convertToPo(recPayVO);
|
|
|
+ // 总单保存
|
|
|
+ super.insert(recPay);
|
|
|
+
|
|
|
+ // 明细保存
|
|
|
+ if (recPayVO.getItemList() != null && recPayVO.getItemList().size() > 0) {
|
|
|
+ for (RecPayItemVO recPayItemVO : recPayVO.getItemList()) {
|
|
|
+ RecPayItem recPayItem = recPayItemConvert.convertToPo(recPayItemVO);
|
|
|
+ recPayItem.setRpId(recPay.getRpId()).setCpId(recPay.getCpId()).setMakeStaff(recPay.getMakeStaff()).setAccDate(recPay.getAccDate());
|
|
|
+ recPayItemMapper.insert(recPayItem);
|
|
|
+
|
|
|
+ // 插入账款明细
|
|
|
+ AccountItem accountItem = new AccountItem();
|
|
|
+ accountItem.setAccItemType(Constant.accItemType.SHOU_KUAN.getName())
|
|
|
+ .setObjectId(recPayVO.getObjectId()).setOrgId(recPayVO.getOrgId()).setStaffId(recPayVO.getStaffId())
|
|
|
+ .setAccDate(recPayVO.getAccDate()).setRecStatus(Constant.recStatuse.QUE_DING.getName()).setAmtRec(recPayItemVO.getAmtRec())
|
|
|
+ .setBiznisType("t_mac_rec_pay_item").setBiznisId(recPayItem.getItemId()).setBiznisNo(recPayVO.getRpNo())
|
|
|
+ .setMakeStaff(recPayVO.getMakeStaff()).setCpId(recPayVO.getCpId());
|
|
|
+ accountItemMapper.insert(accountItem);
|
|
|
+
|
|
|
+ // 更新收款单上的应收账款
|
|
|
+ RecPayItem recPayItemUpdate = new RecPayItem();
|
|
|
+ recPayItemUpdate.setAccItemId(accountItem.getItemId()).setRpId(recPayVO.getRpId());
|
|
|
+ recPayItemService.updateByUuid(recPayItemUpdate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 插入账款总表
|
|
|
+ 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()))// 总收款金额
|
|
|
+ .setReceiptResidue(accountForUpdate.getReceiptResidue().add(recPayVO.getSumAmtRec()))// 可退金额
|
|
|
+ .setObjectId(accountForUpdate.getObjectId());
|
|
|
+ accountService.updateByUuid(accountUpdate);
|
|
|
+ return ResponseResultUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 新建退款
|
|
|
+ * @author : 付斌
|
|
|
+ * @date : 2023/1/9 10:49
|
|
|
+ */
|
|
|
+ @Transactional(
|
|
|
+ rollbackFor = {Exception.class}
|
|
|
+ )
|
|
|
+ public ResponseResultVO<?> insertRefund(RecPayVO recPayVO) {
|
|
|
+
|
|
|
+ // 查总账,看可退金额是否满足
|
|
|
+
|
|
|
|
|
|
// 获取单号
|
|
|
Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.RECPAY.getName(), false);
|