diff --git a/src/main/java/com/qs/serve/modules/goods/entity/GoodsSku.java b/src/main/java/com/qs/serve/modules/goods/entity/GoodsSku.java index 96367a91..6b3fbd1b 100644 --- a/src/main/java/com/qs/serve/modules/goods/entity/GoodsSku.java +++ b/src/main/java/com/qs/serve/modules/goods/entity/GoodsSku.java @@ -129,5 +129,6 @@ public class GoodsSku implements Serializable { @TableField(exist = false) private List specValueList; + } diff --git a/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java b/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java index 83821022..a6a38cf5 100644 --- a/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/pay/service/impl/PayPaymentServiceImpl.java @@ -81,18 +81,15 @@ public class PayPaymentServiceImpl extends ServiceImpl0){ historyItem = new PayHistoryItem(); + historyItem.setPayType(payType); + historyItem.setSupplierId(paymentBo.getSupplierId()); + historyItem.setRemark(paymentBo.getRemark()); if(supplierHisAmount.compareTo(currentAmount)>=0){ - historyItem.setPayType(payType); - historyItem.setSupplierId(paymentBo.getSupplierId()); historyItem.setItemPayAmount(currentAmount); - historyItem.setRemark(paymentBo.getRemark()); supplier.setInitCurAmount(supplierHisAmount.subtract(currentAmount)); currentBalance = BigDecimal.ZERO; }else { - historyItem.setPayType(payType); - historyItem.setSupplierId(paymentBo.getSupplierId()); historyItem.setItemPayAmount(supplierHisAmount); - historyItem.setRemark(paymentBo.getRemark()); supplier.setInitCurAmount(BigDecimal.ZERO); currentBalance = currentAmount.subtract(supplierHisAmount); } diff --git a/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java b/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java index 0ab52087..673d21f4 100644 --- a/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java +++ b/src/main/java/com/qs/serve/modules/third/entity/ProcessCreateBo.java @@ -32,6 +32,12 @@ public class ProcessCreateBo { @NotNull(message = "客户编码 不能为空") private String customerCode; + /** 暂无异于,记录在支付表(可为空) */ + private String erpCode; + + @NotNull(message = "发票号 不能为空") + private String billNumber; + /** 客户所属 */ private String customerBelong; diff --git a/src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java b/src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java index 21f2f86e..0044555b 100644 --- a/src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java +++ b/src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java @@ -21,6 +21,8 @@ import com.qs.serve.modules.goods.service.GoodsSpuService; import com.qs.serve.modules.pay.common.PaymentType; import com.qs.serve.modules.pay.entity.PayPayment; import com.qs.serve.modules.pay.entity.PayPaymentItem; +import com.qs.serve.modules.pay.service.PayPaymentItemService; +import com.qs.serve.modules.pay.service.PayPaymentService; import com.qs.serve.modules.sys.entity.SysUser; import com.qs.serve.modules.sys.service.SysUserService; import com.qs.serve.modules.tbs.common.TbsActivityState; @@ -38,6 +40,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.RoundingMode; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -67,6 +70,7 @@ public class PortalOfCostApplication { private SysUserService userService; + private TbsCostUnItemService costUnItemService; private TbsBudgetLogService budgetLogService; private TbsBudgetApplicationService budgetApplicationService; private TbsCostApplyService costApplyService; @@ -75,6 +79,9 @@ public class PortalOfCostApplication { private GoodsSpuService goodsSpuService; private GoodsCategoryService goodsCategoryService; + private PayPaymentService paymentService; + private PayPaymentItemService paymentItemService; + @Transactional(rollbackFor = Exception.class) @@ -86,6 +93,7 @@ public class PortalOfCostApplication { BmsSubject subject = subjectService.getByCode(createBo.getSubjectCode()); if(subject==null){Assert.throwEx("科目不存在,请重新编辑");} //初始化sku列表 + List processGoodsItems = createBo.getGoodsList(); List skuList = this.initSkuListOfProcess(createBo); //常用参数 final String GOODS_TYPE = "sku"; @@ -93,6 +101,8 @@ public class PortalOfCostApplication { final BigDecimal OneHundred = new BigDecimal("100"); LocalDateTime nowTime = LocalDateTime.now(); LocalDate nowDate = LocalDate.now(); + String billNumber = createBo.getBillNumber(); + String erpCode = createBo.getErpCode(); Long supplierId = Long.parseLong(supplier.getId()); BigDecimal totalAmount = createBo.getTotalAmount(); String costCode = createBo.getCostCode(); @@ -193,10 +203,6 @@ public class PortalOfCostApplication { centerGoods.setSubjectId(subject.getId()); centerGoods.setSubjectCode(subject.getSubjectCode()); centerGoods.setSubjectName(subject.getSubjectName()); - //TODO 分配 - centerGoods.setCenterGoodsAmount(BigDecimal.ZERO); - centerGoods.setCenterGoodsRate(BigDecimal.ZERO); - centerGoods.setUsedAmount(BigDecimal.ZERO); //设置活动时间 centerGoods.setActEndDate(nowDate); centerGoods.setActStartDate(nowDate); @@ -209,6 +215,16 @@ public class PortalOfCostApplication { centerGoods.setTargetName(activityGoods.getTargetName()); centerGoods.setTargetLevelPathIds(activityGoods.getTargetLevelPathIds()); centerGoods.setTargetLevelPathNames(activityGoods.getTargetLevelPathNames()); + // 分配金额 + for (ProcessGoodsItem goodsItem : processGoodsItems) { + if(goodsItem.getInventoryCode().equals(activityGoods.getTargetCode())){ + BigDecimal rate = goodsItem.getAmount().divide(totalAmount, RoundingMode.UP); + centerGoods.setCenterGoodsAmount(goodsItem.getAmount()); + centerGoods.setCenterGoodsRate(rate); + centerGoods.setUsedAmount(goodsItem.getAmount()); + break; + } + } activityCenterGoodsList.add(centerGoods); } @@ -240,6 +256,7 @@ public class PortalOfCostApplication { Arrays.asList(activitySubject), activityCenterGoodsList, Arrays.asList(activityCenter),true,false,false); + //不匹配的商品,保存到无预算表 List unMatchBudgetItem = budgetCostResult.getBudgetUnMatchList(); List costUnItemList = new ArrayList<>(); @@ -249,6 +266,8 @@ public class PortalOfCostApplication { costUnItemList.add(costUnItem); } } + costUnItemService.saveBatch(costUnItemList); + //不匹配的商品,生成预算日志 List matchBudgetItem = budgetCostResult.getBudgetMatchList(); List budgetLogList = new ArrayList<>(); @@ -265,7 +284,9 @@ public class PortalOfCostApplication { budgetLogList.add(budgetLog); } } + budgetLogService.saveBatch(budgetLogList); + //保存核销申请 VtbVerification verification = new VtbVerification(); verification.setVerificationCode("HX"+ IdUtil.timeStampId()); verification.setFinishedTime(nowTime); @@ -281,8 +302,7 @@ public class PortalOfCostApplication { verification.setAmountRecord(totalAmount); verification.setPaymentState(ResultFlag.OK); - - //保存费用结果 + //保存核销费用结果 VtbVerificationSubject verificationSubject = new VtbVerificationSubject(); verificationSubject.setVerificationSubCode(verification.getVerificationCode()+"_1"); verificationSubject.setCostApplyId(costApply.getId()); @@ -299,6 +319,7 @@ public class PortalOfCostApplication { verificationSubject.setCountPerson(0); verificationSubject.setCountSession(0); + //保存支付 PayPayment payPayment = new PayPayment(); payPayment.setPayType(PaymentType.PAYMENT); payPayment.setPayCode("PM"+ StringUtils.genShortId()); @@ -310,8 +331,9 @@ public class PortalOfCostApplication { payPayment.setUserCode(user.getCode()); payPayment.setUserName(user.getName()); payPayment.setPayTime(nowTime); - payPayment.setErpCode(""); - payPayment.setBillNumber(""); + payPayment.setErpCode(erpCode); + payPayment.setBillNumber(billNumber); + paymentService.save(payPayment); PayPaymentItem paymentItem = new PayPaymentItem(); paymentItem.setPaymentId(payPayment.getId()); @@ -319,7 +341,14 @@ public class PortalOfCostApplication { paymentItem.setSupplierId(supplierId); paymentItem.setItemPayAmount(totalAmount); paymentItem.setVerificationId(verification.getId()); - + paymentItem.setVerificationSubjectId(verificationSubject.getId()); + paymentItem.setCostApplyId(costApply.getId()); + paymentItem.setActivityId(activity.getId()); + paymentItem.setActivityCode(activity.getActivityCode()); + paymentItem.setSubjectId(subject.getId()); + paymentItem.setSubjectCode(subject.getSubjectCode()); + paymentItem.setSubjectName(subject.getSubjectName()); + paymentItemService.save(paymentItem); }