|
@ -29,6 +29,7 @@ import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
|
import com.qs.serve.modules.tbs.entity.*; |
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
import com.qs.serve.modules.tbs.entity.dto.TbsBudgetCostResult; |
|
|
import com.qs.serve.modules.tbs.service.*; |
|
|
import com.qs.serve.modules.tbs.service.*; |
|
|
|
|
|
import com.qs.serve.modules.third.entity.AptPolicyPayment; |
|
|
import com.qs.serve.modules.third.entity.ProcessCreateCostApplyBo; |
|
|
import com.qs.serve.modules.third.entity.ProcessCreateCostApplyBo; |
|
|
import com.qs.serve.modules.third.entity.ProcessCreatePolicyCostBo; |
|
|
import com.qs.serve.modules.third.entity.ProcessCreatePolicyCostBo; |
|
|
import com.qs.serve.modules.third.entity.ProcessGoodsItem; |
|
|
import com.qs.serve.modules.third.entity.ProcessGoodsItem; |
|
@ -93,14 +94,122 @@ public class PortalOfCostApplication { |
|
|
private VtbVerificationService verificationService; |
|
|
private VtbVerificationService verificationService; |
|
|
private VtbVerificationSubjectService verificationSubjectService; |
|
|
private VtbVerificationSubjectService verificationSubjectService; |
|
|
|
|
|
|
|
|
private TzcPolicyService policyService; |
|
|
|
|
|
private TzcPolicyItemService policyItemServiceService; |
|
|
private TzcPolicyItemService policyItemServiceService; |
|
|
private TzcPolicyItemLogService policyItemLogService; |
|
|
private TzcPolicyItemLogService policyItemLogService; |
|
|
private TzcPolicyGoodsSyncService tzcPolicyGoodsSyncService; |
|
|
private TzcPolicyGoodsSyncService tzcPolicyGoodsSyncService; |
|
|
private final XiaoLuTonService xiaoLuTonService; |
|
|
private final XiaoLuTonService xiaoLuTonService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void syncXltPolicyItemPayment(AptPolicyPayment createBo){ |
|
|
|
|
|
TzcPolicyItem policyItem = policyItemServiceService.getByPolicyItemCode(createBo.getPolicyItemCode()); |
|
|
|
|
|
if(policyItem==null){ |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
//发票号
|
|
|
|
|
|
String billNumber = createBo.getBillCode(); |
|
|
|
|
|
//拦截是否已保存
|
|
|
|
|
|
LambdaQueryWrapper<PayPayment> payLqw = new LambdaQueryWrapper<>(); |
|
|
|
|
|
payLqw.eq(PayPayment::getBillNumber,billNumber); |
|
|
|
|
|
long countPay = paymentService.count(payLqw); |
|
|
|
|
|
if(countPay>0){ |
|
|
|
|
|
//发票号已存在
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
BmsSupplier supplier = supplierService.getById(policyItem.getSupplierId()); |
|
|
|
|
|
BmsSubject subject = subjectService.getById(policyItem.getSubjectId()); |
|
|
|
|
|
//常用参数
|
|
|
|
|
|
LocalDateTime nowTime = LocalDateTime.now(); |
|
|
|
|
|
String erpCode = ""; |
|
|
|
|
|
Long supplierId = Long.parseLong(supplier.getId()); |
|
|
|
|
|
BigDecimal totalAmount = createBo.getAmount(); |
|
|
|
|
|
|
|
|
|
|
|
//修改预算日志,记录政策使用情况
|
|
|
|
|
|
TzcPolicyItemLog policyItemLog = TzcPolicyItemLog.toNewObject(policyItem,totalAmount); |
|
|
|
|
|
policyItemLogService.save(policyItemLog); |
|
|
|
|
|
|
|
|
|
|
|
//更新项使用情况
|
|
|
|
|
|
TzcPolicyItem policyItemParam = new TzcPolicyItem(); |
|
|
|
|
|
policyItemParam.setId(policyItem.getId()); |
|
|
|
|
|
policyItemParam.setUsedAmount(policyItem.getUsedAmount().add(totalAmount)); |
|
|
|
|
|
policyItemServiceService.updateById(policyItemParam); |
|
|
|
|
|
|
|
|
|
|
|
//保存核销申请
|
|
|
|
|
|
VtbVerification verification = new VtbVerification(); |
|
|
|
|
|
verification.setVerificationCode("HX"+ IdUtil.timeStampId()); |
|
|
|
|
|
verification.setFinishedTime(nowTime); |
|
|
|
|
|
verification.setVerificationState(VtbVerificationState.Finished.getCode()); |
|
|
|
|
|
verification.setPolicyItemId(policyItem.getId()); |
|
|
|
|
|
verification.setPolicyItemCode(policyItem.getPolicyItemCode()); |
|
|
|
|
|
verification.setSupplierId(supplierId); |
|
|
|
|
|
verification.setSupplierCode(supplier.getCode()); |
|
|
|
|
|
verification.setSupplierName(supplier.getName()); |
|
|
|
|
|
verification.setUserId("000"); |
|
|
|
|
|
verification.setUserCode("000"); |
|
|
|
|
|
verification.setUserName("ApiUser"); |
|
|
|
|
|
verification.setAmount(totalAmount); |
|
|
|
|
|
verification.setAmountRecord(totalAmount); |
|
|
|
|
|
verification.setPaymentState(ResultFlag.OK); |
|
|
|
|
|
verificationService.save(verification); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存核销费用结果
|
|
|
|
|
|
VtbVerificationSubject verificationSubject = new VtbVerificationSubject(); |
|
|
|
|
|
verificationSubject.setVerificationId(verification.getId()); |
|
|
|
|
|
verificationSubject.setVerificationSubCode(verification.getVerificationCode()+"_1"); |
|
|
|
|
|
verificationSubject.setPolicyItemId(policyItem.getId()); |
|
|
|
|
|
verificationSubject.setPolicyItemCode(policyItem.getPolicyItemCode()); |
|
|
|
|
|
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); |
|
|
|
|
|
verificationSubjectService.save(verificationSubject); |
|
|
|
|
|
|
|
|
|
|
|
//保存支付
|
|
|
|
|
|
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("000"); |
|
|
|
|
|
payPayment.setUserCode("000"); |
|
|
|
|
|
payPayment.setUserName("ApiUser"); |
|
|
|
|
|
payPayment.setPayTime(nowTime); |
|
|
|
|
|
payPayment.setErpCode(erpCode); |
|
|
|
|
|
payPayment.setBillNumber(billNumber); |
|
|
|
|
|
paymentService.save(payPayment); |
|
|
|
|
|
|
|
|
|
|
|
PayPaymentItem paymentItem = new PayPaymentItem(); |
|
|
|
|
|
paymentItem.setPaymentId(payPayment.getId()); |
|
|
|
|
|
paymentItem.setPayType(PaymentType.PAYMENT); |
|
|
|
|
|
paymentItem.setSupplierId(supplierId); |
|
|
|
|
|
paymentItem.setItemPayAmount(totalAmount); |
|
|
|
|
|
paymentItem.setVerificationId(verification.getId()); |
|
|
|
|
|
paymentItem.setVerificationSubjectId(verificationSubject.getId()); |
|
|
|
|
|
paymentItem.setPolicyItemId(policyItem.getId()); |
|
|
|
|
|
paymentItem.setPolicyItemCode(policyItem.getPolicyItemCode()); |
|
|
|
|
|
paymentItem.setSubjectId(subject.getId()); |
|
|
|
|
|
paymentItem.setSubjectCode(subject.getSubjectCode()); |
|
|
|
|
|
paymentItem.setSubjectName(subject.getSubjectName()); |
|
|
|
|
|
paymentItemService.save(paymentItem); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 已弃用,适用 syncXltPolicyItemPayment代替 |
|
|
|
|
|
* @param createBo |
|
|
|
|
|
*/ |
|
|
|
|
|
@Deprecated |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void createCostProcessByPolicy(ProcessCreatePolicyCostBo createBo){ |
|
|
public void createCostProcessByPolicy(ProcessCreatePolicyCostBo createBo){ |
|
|
SysUser user = userService.getByAccount(createBo.getUserCode()); |
|
|
SysUser user = userService.getByAccount(createBo.getUserCode()); |
|
@ -130,7 +239,12 @@ public class PortalOfCostApplication { |
|
|
} |
|
|
} |
|
|
//初始化sku列表
|
|
|
//初始化sku列表
|
|
|
List<ProcessGoodsItem> processGoodsItems = createBo.getGoodsList(); |
|
|
List<ProcessGoodsItem> processGoodsItems = createBo.getGoodsList(); |
|
|
List<GoodsSku> skuList = this.initSkuListOfProcess(createBo.getGoodsList()); |
|
|
List<String> invCodes = new ArrayList<>(); |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(createBo.getGoodsList())){ |
|
|
|
|
|
invCodes = createBo.getGoodsList().stream() |
|
|
|
|
|
.map(ProcessGoodsItem::getInventoryCode).distinct().collect(Collectors.toList());; |
|
|
|
|
|
} |
|
|
|
|
|
List<GoodsSku> skuList = this.initSkuListOfProcess(invCodes); |
|
|
//常用参数
|
|
|
//常用参数
|
|
|
final String GOODS_TYPE = "sku"; |
|
|
final String GOODS_TYPE = "sku"; |
|
|
final String CENTER_TYPE = "customer"; |
|
|
final String CENTER_TYPE = "customer"; |
|
@ -407,9 +521,6 @@ public class PortalOfCostApplication { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void createCostProcess(ProcessCreateCostApplyBo createBo){ |
|
|
public void createCostProcess(ProcessCreateCostApplyBo createBo){ |
|
|
SysUser user = userService.getByAccount(createBo.getUserCode()); |
|
|
SysUser user = userService.getByAccount(createBo.getUserCode()); |
|
@ -437,7 +548,12 @@ public class PortalOfCostApplication { |
|
|
} |
|
|
} |
|
|
//初始化sku列表
|
|
|
//初始化sku列表
|
|
|
List<ProcessGoodsItem> processGoodsItems = createBo.getGoodsList(); |
|
|
List<ProcessGoodsItem> processGoodsItems = createBo.getGoodsList(); |
|
|
List<GoodsSku> skuList = this.initSkuListOfProcess(createBo.getGoodsList()); |
|
|
List<String> invCodeList = new ArrayList<>(); |
|
|
|
|
|
if(CollectionUtil.isNotEmpty(createBo.getGoodsList())){ |
|
|
|
|
|
invCodeList = createBo.getGoodsList().stream() |
|
|
|
|
|
.map(ProcessGoodsItem::getInventoryCode).distinct().collect(Collectors.toList()); |
|
|
|
|
|
} |
|
|
|
|
|
List<GoodsSku> skuList = this.initSkuListOfProcess(invCodeList); |
|
|
//常用参数
|
|
|
//常用参数
|
|
|
final String GOODS_TYPE = "sku"; |
|
|
final String GOODS_TYPE = "sku"; |
|
|
final String CENTER_TYPE = "customer"; |
|
|
final String CENTER_TYPE = "customer"; |
|
@ -704,14 +820,12 @@ public class PortalOfCostApplication { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 创建流程中,初始化SKU列表 |
|
|
* 创建流程中,初始化SKU列表 |
|
|
* @param goodsList |
|
|
* @param invCodes |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
private List<GoodsSku> initSkuListOfProcess(List<ProcessGoodsItem> goodsList) { |
|
|
private List<GoodsSku> initSkuListOfProcess(List<String> invCodes) { |
|
|
List<GoodsSku> goodsSkus = null; |
|
|
List<GoodsSku> goodsSkus = null; |
|
|
if(CollectionUtil.isNotEmpty(goodsList)){ |
|
|
if(CollectionUtil.isNotEmpty(invCodes)){ |
|
|
List<String> invCodes = goodsList.stream() |
|
|
|
|
|
.map(ProcessGoodsItem::getInventoryCode).distinct().collect(Collectors.toList()); |
|
|
|
|
|
LambdaQueryWrapper<GoodsSku> skuLqw = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<GoodsSku> skuLqw = new LambdaQueryWrapper<>(); |
|
|
skuLqw.in(GoodsSku::getSkuCode,invCodes); |
|
|
skuLqw.in(GoodsSku::getSkuCode,invCodes); |
|
|
goodsSkus = goodsSkuService.list(skuLqw); |
|
|
goodsSkus = goodsSkuService.list(skuLqw); |
|
|