|
@ -1,6 +1,7 @@ |
|
|
package com.qs.serve.modules.third.service; |
|
|
package com.qs.serve.modules.third.service; |
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
import com.qs.serve.common.config.properties.ProjectApisProperties; |
|
|
import com.qs.serve.common.model.enums.BudgetLogOptFlag; |
|
|
import com.qs.serve.common.model.enums.BudgetLogOptFlag; |
|
|
import com.qs.serve.common.model.consts.ResultFlag; |
|
|
import com.qs.serve.common.model.consts.ResultFlag; |
|
|
import com.qs.serve.common.util.*; |
|
|
import com.qs.serve.common.util.*; |
|
@ -23,6 +24,7 @@ import com.qs.serve.modules.seeyon.entity.XltApticlaim; |
|
|
import com.qs.serve.modules.seeyon.entity.XltPaymentRecord; |
|
|
import com.qs.serve.modules.seeyon.entity.XltPaymentRecord; |
|
|
import com.qs.serve.modules.seeyon.service.XiaoLuTonService; |
|
|
import com.qs.serve.modules.seeyon.service.XiaoLuTonService; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
|
|
|
import com.qs.serve.modules.sys.mapper.SysUserCodeMathMapper; |
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
import com.qs.serve.modules.sys.service.SysUserService; |
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
import com.qs.serve.modules.tbs.common.TbsActivityState; |
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
|
import com.qs.serve.modules.tbs.common.TbsCostApplyState; |
|
@ -30,10 +32,7 @@ import com.qs.serve.modules.tbs.common.util.TbsBudgetLogBuildUtil; |
|
|
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.*; |
|
|
import com.qs.serve.modules.third.entity.ProcessCreateCostApplyBo; |
|
|
|
|
|
import com.qs.serve.modules.third.entity.ProcessCreatePolicyCostBo; |
|
|
|
|
|
import com.qs.serve.modules.third.entity.ProcessGoodsItem; |
|
|
|
|
|
import com.qs.serve.modules.tzc.common.TzPolicyItemStatus; |
|
|
import com.qs.serve.modules.tzc.common.TzPolicyItemStatus; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyGoodsSync; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyGoodsSync; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyItem; |
|
|
import com.qs.serve.modules.tzc.entity.TzcPolicyItem; |
|
@ -52,6 +51,7 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
import java.math.RoundingMode; |
|
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
@ -67,6 +67,8 @@ import java.util.stream.Collectors; |
|
|
@AllArgsConstructor |
|
|
@AllArgsConstructor |
|
|
public class PortalOfCostApplication { |
|
|
public class PortalOfCostApplication { |
|
|
|
|
|
|
|
|
|
|
|
private SysUserCodeMathMapper userCodeMathMapper; |
|
|
|
|
|
|
|
|
private TbsActivityService activityService; |
|
|
private TbsActivityService activityService; |
|
|
private TbsActivityCenterService activityCenterService; |
|
|
private TbsActivityCenterService activityCenterService; |
|
|
private TbsActivitySubjectService activitySubjectService; |
|
|
private TbsActivitySubjectService activitySubjectService; |
|
@ -98,6 +100,8 @@ public class PortalOfCostApplication { |
|
|
private TzcPolicyGoodsSyncService tzcPolicyGoodsSyncService; |
|
|
private TzcPolicyGoodsSyncService tzcPolicyGoodsSyncService; |
|
|
private final XiaoLuTonService xiaoLuTonService; |
|
|
private final XiaoLuTonService xiaoLuTonService; |
|
|
|
|
|
|
|
|
|
|
|
private ProjectApisProperties projectApisProperties; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void syncXltPolicyItemPayment(AptPolicyPayment createBo){ |
|
|
public void syncXltPolicyItemPayment(AptPolicyPayment createBo){ |
|
@ -523,6 +527,12 @@ 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()); |
|
|
|
|
|
if(user==null){ |
|
|
|
|
|
String newUcode = userCodeMathMapper.getNewCode(createBo.getUserCode()); |
|
|
|
|
|
if(newUcode!=null){ |
|
|
|
|
|
user = userService.getByAccount(newUcode); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if(user==null){Assert.throwEx("用户不存在,请重新编辑");} |
|
|
if(user==null){Assert.throwEx("用户不存在,请重新编辑");} |
|
|
BmsSupplier supplier = supplierService.getByCode(createBo.getCustomerCode(),createBo.getCustomerBelong()); |
|
|
BmsSupplier supplier = supplierService.getByCode(createBo.getCustomerCode(),createBo.getCustomerBelong()); |
|
|
if(supplier==null){Assert.throwEx("客户不存在,请重新编辑");} |
|
|
if(supplier==null){Assert.throwEx("客户不存在,请重新编辑");} |
|
@ -565,8 +575,7 @@ public class PortalOfCostApplication { |
|
|
String costCode = createBo.getCostCode(); |
|
|
String costCode = createBo.getCostCode(); |
|
|
String costTheme = createBo.getCostTheme(); |
|
|
String costTheme = createBo.getCostTheme(); |
|
|
|
|
|
|
|
|
String random = String.format("%03d",new Random().nextInt(999)); |
|
|
String activityCode = costCode; |
|
|
String activityCode = "G"+ StringUtils.genShortId() + random; |
|
|
|
|
|
|
|
|
|
|
|
String activityTitle = createBo.getActivityTitle(); |
|
|
String activityTitle = createBo.getActivityTitle(); |
|
|
if(!StringUtils.hasText(activityTitle)){ |
|
|
if(!StringUtils.hasText(activityTitle)){ |
|
@ -720,6 +729,9 @@ public class PortalOfCostApplication { |
|
|
|
|
|
|
|
|
//不匹配的商品,保存到无预算表
|
|
|
//不匹配的商品,保存到无预算表
|
|
|
List<TbsBudgetCostItem> unMatchBudgetItem = budgetCostResult.getBudgetUnMatchList(); |
|
|
List<TbsBudgetCostItem> unMatchBudgetItem = budgetCostResult.getBudgetUnMatchList(); |
|
|
|
|
|
if(unMatchBudgetItem.size()>0){ |
|
|
|
|
|
Assert.throwEx("未能匹配到预算"); |
|
|
|
|
|
} |
|
|
List<TbsCostUnItem> costUnItemList = new ArrayList<>(); |
|
|
List<TbsCostUnItem> costUnItemList = new ArrayList<>(); |
|
|
if(CollectionUtil.isNotEmpty(unMatchBudgetItem)){ |
|
|
if(CollectionUtil.isNotEmpty(unMatchBudgetItem)){ |
|
|
for (TbsBudgetCostItem budgetCostItem : unMatchBudgetItem) { |
|
|
for (TbsBudgetCostItem budgetCostItem : unMatchBudgetItem) { |
|
@ -729,7 +741,6 @@ public class PortalOfCostApplication { |
|
|
} |
|
|
} |
|
|
costUnItemService.saveBatch(costUnItemList); |
|
|
costUnItemService.saveBatch(costUnItemList); |
|
|
|
|
|
|
|
|
//TODO 修改预算日志,记录政策使用情况
|
|
|
|
|
|
//匹配的商品,生成预算日志
|
|
|
//匹配的商品,生成预算日志
|
|
|
List<TbsBudgetCostItem> matchBudgetItem = budgetCostResult.getBudgetMatchList(); |
|
|
List<TbsBudgetCostItem> matchBudgetItem = budgetCostResult.getBudgetMatchList(); |
|
|
List<TbsBudgetLog> budgetLogList = new ArrayList<>(); |
|
|
List<TbsBudgetLog> budgetLogList = new ArrayList<>(); |
|
@ -784,36 +795,61 @@ public class PortalOfCostApplication { |
|
|
verificationSubject.setCountSession(0); |
|
|
verificationSubject.setCountSession(0); |
|
|
verificationSubjectService.save(verificationSubject); |
|
|
verificationSubjectService.save(verificationSubject); |
|
|
|
|
|
|
|
|
|
|
|
//保存支付信息
|
|
|
|
|
|
String timeString = nowTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
|
|
|
|
|
|
|
ThirtyVerification tv = new ThirtyVerification(); |
|
|
|
|
|
tv.setVerificationCode(verificationSubject.getVerificationSubCode()); |
|
|
|
|
|
tv.setActivityTitle(activityTitle); |
|
|
|
|
|
tv.setActivityCode(activityCode); |
|
|
|
|
|
tv.setCreateDate(timeString); |
|
|
|
|
|
tv.setStartDate(timeString); |
|
|
|
|
|
tv.setEndDate(timeString); |
|
|
|
|
|
tv.setSubjectCode(subject.getSubjectCode()); |
|
|
|
|
|
tv.setSubjectName(subject.getSubjectName()); |
|
|
|
|
|
tv.setMoney(totalAmount); |
|
|
|
|
|
//tv.setCreateUser();
|
|
|
|
|
|
tv.setCreateTime(timeString); |
|
|
|
|
|
tv.setCheckUser(user.getName()); |
|
|
|
|
|
tv.setCheckTime(timeString); |
|
|
|
|
|
tv.setCusCode(supplier.getCode()); |
|
|
|
|
|
tv.setCusName(supplier.getName()); |
|
|
|
|
|
tv.setRecId(verificationSubject.getVerificationSubCode()); |
|
|
|
|
|
String COST_TO_PAY_API = projectApisProperties.getCostToPay(); |
|
|
|
|
|
String json = JsonUtil.objectToJson(tv); |
|
|
|
|
|
log.info("COST_TO_PAY_API 支付单信息:{} 数据:{}",verificationSubject.getVerificationSubCode(),json); |
|
|
|
|
|
String rs = HttpUtil.doPost(COST_TO_PAY_API,json,null); |
|
|
|
|
|
log.info("COST_TO_PAY_API 支付单信息:{},结果:{}",verificationSubject.getVerificationSubCode(),rs); |
|
|
//保存支付
|
|
|
//保存支付
|
|
|
PayPayment payPayment = new PayPayment(); |
|
|
// PayPayment payPayment = new PayPayment();
|
|
|
payPayment.setPayType(PaymentType.PAYMENT); |
|
|
// payPayment.setPayType(PaymentType.PAYMENT);
|
|
|
payPayment.setPayCode("PM"+ StringUtils.genShortId()); |
|
|
// payPayment.setPayCode("PM"+ StringUtils.genShortId());
|
|
|
payPayment.setSupplierId(supplierId); |
|
|
// payPayment.setSupplierId(supplierId);
|
|
|
payPayment.setSupplierCode(supplier.getCode()); |
|
|
// payPayment.setSupplierCode(supplier.getCode());
|
|
|
payPayment.setSupplierName(supplier.getName()); |
|
|
// payPayment.setSupplierName(supplier.getName());
|
|
|
payPayment.setPayAmount(totalAmount); |
|
|
// payPayment.setPayAmount(totalAmount);
|
|
|
payPayment.setUserId(user.getId()); |
|
|
// payPayment.setUserId(user.getId());
|
|
|
payPayment.setUserCode(user.getCode()); |
|
|
// payPayment.setUserCode(user.getCode());
|
|
|
payPayment.setUserName(user.getName()); |
|
|
// payPayment.setUserName(user.getName());
|
|
|
payPayment.setPayTime(nowTime); |
|
|
// payPayment.setPayTime(nowTime);
|
|
|
payPayment.setErpCode(erpCode); |
|
|
// payPayment.setErpCode(erpCode);
|
|
|
payPayment.setBillNumber(billNumber); |
|
|
// payPayment.setBillNumber(billNumber);
|
|
|
paymentService.save(payPayment); |
|
|
// paymentService.save(payPayment);
|
|
|
|
|
|
//
|
|
|
PayPaymentItem paymentItem = new PayPaymentItem(); |
|
|
// PayPaymentItem paymentItem = new PayPaymentItem();
|
|
|
paymentItem.setPaymentId(payPayment.getId()); |
|
|
// paymentItem.setPaymentId(payPayment.getId());
|
|
|
paymentItem.setPayType(PaymentType.PAYMENT); |
|
|
// paymentItem.setPayType(PaymentType.PAYMENT);
|
|
|
paymentItem.setSupplierId(supplierId); |
|
|
// paymentItem.setSupplierId(supplierId);
|
|
|
paymentItem.setItemPayAmount(totalAmount); |
|
|
// paymentItem.setItemPayAmount(totalAmount);
|
|
|
paymentItem.setVerificationId(verification.getId()); |
|
|
// paymentItem.setVerificationId(verification.getId());
|
|
|
paymentItem.setVerificationSubjectId(verificationSubject.getId()); |
|
|
// paymentItem.setVerificationSubjectId(verificationSubject.getId());
|
|
|
paymentItem.setCostApplyId(costApply.getId()); |
|
|
// paymentItem.setCostApplyId(costApply.getId());
|
|
|
paymentItem.setActivityId(activity.getId()); |
|
|
// paymentItem.setActivityId(activity.getId());
|
|
|
paymentItem.setActivityCode(activity.getActivityCode()); |
|
|
// paymentItem.setActivityCode(activity.getActivityCode());
|
|
|
paymentItem.setSubjectId(subject.getId()); |
|
|
// paymentItem.setSubjectId(subject.getId());
|
|
|
paymentItem.setSubjectCode(subject.getSubjectCode()); |
|
|
// paymentItem.setSubjectCode(subject.getSubjectCode());
|
|
|
paymentItem.setSubjectName(subject.getSubjectName()); |
|
|
// paymentItem.setSubjectName(subject.getSubjectName());
|
|
|
paymentItemService.save(paymentItem); |
|
|
// paymentItemService.save(paymentItem);
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|