|
|
@ -1,9 +1,11 @@ |
|
|
|
package com.qs.serve.modules.third.service; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.qs.serve.common.model.consts.BudgetLogOptFlag; |
|
|
|
import com.qs.serve.common.model.consts.ResultFlag; |
|
|
|
import com.qs.serve.common.util.Assert; |
|
|
|
import com.qs.serve.common.util.CollectionUtil; |
|
|
|
import com.qs.serve.common.util.IdUtil; |
|
|
|
import com.qs.serve.common.util.StringUtils; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsSubject; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
|
@ -16,6 +18,9 @@ import com.qs.serve.modules.goods.entity.dto.TbsCenterDto; |
|
|
|
import com.qs.serve.modules.goods.service.GoodsCategoryService; |
|
|
|
import com.qs.serve.modules.goods.service.GoodsSkuService; |
|
|
|
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.sys.entity.SysUser; |
|
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
@ -25,6 +30,9 @@ import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
|
import com.qs.serve.modules.tbs.service.*; |
|
|
|
import com.qs.serve.modules.third.entity.ProcessCreateBo; |
|
|
|
import com.qs.serve.modules.third.entity.ProcessGoodsItem; |
|
|
|
import com.qs.serve.modules.vtb.common.VtbVerificationState; |
|
|
|
import com.qs.serve.modules.vtb.entity.VtbVerification; |
|
|
|
import com.qs.serve.modules.vtb.entity.VtbVerificationSubject; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -53,15 +61,22 @@ public class PortalOfCostApplication { |
|
|
|
private TbsActivitySubjectService activitySubjectService; |
|
|
|
private TbsActivityGoodsService activityGoodsService; |
|
|
|
private TbsActivityCenterGoodsService activityCenterGoodsService; |
|
|
|
|
|
|
|
private BmsSupplierService supplierService; |
|
|
|
private BmsSubjectService subjectService; |
|
|
|
|
|
|
|
private SysUserService userService; |
|
|
|
|
|
|
|
private TbsBudgetLogService budgetLogService; |
|
|
|
private TbsBudgetApplicationService budgetApplicationService; |
|
|
|
private TbsCostApplyService costApplyService; |
|
|
|
|
|
|
|
private GoodsSkuService goodsSkuService; |
|
|
|
private GoodsSpuService goodsSpuService; |
|
|
|
private GoodsCategoryService goodsCategoryService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void createCostProcess(ProcessCreateBo createBo){ |
|
|
|
SysUser user = userService.getByAccount(createBo.getUserCode()); |
|
|
@ -225,10 +240,86 @@ public class PortalOfCostApplication { |
|
|
|
Arrays.asList(activitySubject), |
|
|
|
activityCenterGoodsList, |
|
|
|
Arrays.asList(activityCenter),true,false,false); |
|
|
|
List<TbsBudgetCostItem> matchBudgetItem = budgetCostResult.getBudgetMatchList(); |
|
|
|
//TODO 匹配列表生成预算日志
|
|
|
|
//不匹配的商品,保存到无预算表
|
|
|
|
List<TbsBudgetCostItem> unMatchBudgetItem = budgetCostResult.getBudgetUnMatchList(); |
|
|
|
//不匹配保存到无预算标
|
|
|
|
List<TbsCostUnItem> costUnItemList = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(unMatchBudgetItem)){ |
|
|
|
for (TbsBudgetCostItem budgetCostItem : unMatchBudgetItem) { |
|
|
|
TbsCostUnItem costUnItem = budgetCostItem.toTbsCostUnItem(activity); |
|
|
|
costUnItemList.add(costUnItem); |
|
|
|
} |
|
|
|
} |
|
|
|
//不匹配的商品,生成预算日志
|
|
|
|
List<TbsBudgetCostItem> matchBudgetItem = budgetCostResult.getBudgetMatchList(); |
|
|
|
List<TbsBudgetLog> budgetLogList = new ArrayList<>(); |
|
|
|
if(CollectionUtil.isNotEmpty(matchBudgetItem)){ |
|
|
|
for (TbsBudgetCostItem costItem : matchBudgetItem) { |
|
|
|
TbsBudget currBudget = null; |
|
|
|
for (TbsBudget budget : budgetCostResult.getBudgetList()) { |
|
|
|
if(costItem.getBudgetId().equals(budget.getId())){ |
|
|
|
currBudget = budget; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
TbsBudgetLog budgetLog = budgetLogService.buildTbsBudgetLog(BudgetLogOptFlag.State_1,user, costApply, costItem, currBudget,costItem.getCenterGoodsAmount().negate(),activity); |
|
|
|
budgetLogList.add(budgetLog); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
VtbVerification verification = new VtbVerification(); |
|
|
|
verification.setVerificationCode("HX"+ IdUtil.timeStampId()); |
|
|
|
verification.setFinishedTime(nowTime); |
|
|
|
verification.setVerificationState(VtbVerificationState.Finished.getCode()); |
|
|
|
verification.setActivityId(activity.getId()); |
|
|
|
verification.setSupplierId(activity.getSupplierId()); |
|
|
|
verification.setSupplierCode(activity.getSupplierCode()); |
|
|
|
verification.setSupplierName(activity.getSupplierName()); |
|
|
|
verification.setUserId(user.getId()); |
|
|
|
verification.setUserCode(user.getCode()); |
|
|
|
verification.setUserName(user.getName()); |
|
|
|
verification.setAmount(totalAmount); |
|
|
|
verification.setAmountRecord(totalAmount); |
|
|
|
verification.setPaymentState(ResultFlag.OK); |
|
|
|
|
|
|
|
|
|
|
|
//保存费用结果
|
|
|
|
VtbVerificationSubject verificationSubject = new VtbVerificationSubject(); |
|
|
|
verificationSubject.setVerificationSubCode(verification.getVerificationCode()+"_1"); |
|
|
|
verificationSubject.setCostApplyId(costApply.getId()); |
|
|
|
verificationSubject.setActivityId(activity.getId()); |
|
|
|
verificationSubject.setSubjectId(subject.getId()); |
|
|
|
verificationSubject.setSubjectCode(subject.getSubjectCode()); |
|
|
|
verificationSubject.setSubjectName(subject.getSubjectName()); |
|
|
|
verificationSubject.setSupplierId(Long.parseLong(supplier.getId())); |
|
|
|
verificationSubject.setSupplierCode(supplier.getCode()); |
|
|
|
verificationSubject.setSupplierName(supplier.getName()); |
|
|
|
verificationSubject.setPayFinishedFlag(ResultFlag.OK); |
|
|
|
verificationSubject.setUsedAmount(totalAmount); |
|
|
|
verificationSubject.setUsedAmountRecord(totalAmount); |
|
|
|
verificationSubject.setCountPerson(0); |
|
|
|
verificationSubject.setCountSession(0); |
|
|
|
|
|
|
|
PayPayment payPayment = new PayPayment(); |
|
|
|
payPayment.setPayType(PaymentType.PAYMENT); |
|
|
|
payPayment.setPayCode("PM"+ StringUtils.genShortId()); |
|
|
|
payPayment.setSupplierId(supplierId); |
|
|
|
payPayment.setSupplierCode(supplier.getCode()); |
|
|
|
payPayment.setSupplierName(supplier.getName()); |
|
|
|
payPayment.setPayAmount(totalAmount); |
|
|
|
payPayment.setUserId(user.getId()); |
|
|
|
payPayment.setUserCode(user.getCode()); |
|
|
|
payPayment.setUserName(user.getName()); |
|
|
|
payPayment.setPayTime(nowTime); |
|
|
|
payPayment.setErpCode(""); |
|
|
|
payPayment.setBillNumber(""); |
|
|
|
|
|
|
|
PayPaymentItem paymentItem = new PayPaymentItem(); |
|
|
|
paymentItem.setPaymentId(payPayment.getId()); |
|
|
|
paymentItem.setPayType(PaymentType.PAYMENT); |
|
|
|
paymentItem.setSupplierId(supplierId); |
|
|
|
paymentItem.setItemPayAmount(totalAmount); |
|
|
|
paymentItem.setVerificationId(verification.getId()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|