|
|
@ -55,6 +55,7 @@ import com.qs.serve.modules.vtb.service.VtbVerificationService; |
|
|
|
import com.qs.serve.modules.vtb.service.VtbVerificationSubjectService; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -248,7 +249,7 @@ public class PortalOfCostApplication { |
|
|
|
//发票号
|
|
|
|
String billNumber = createBo.getBillNumber(); |
|
|
|
//校验商品信息
|
|
|
|
List<String> skuCodes = createBo.getGoodsList().stream().map(ProcessGoodsItem::getInventoryCode).collect(Collectors.toList()); |
|
|
|
//List<String> skuCodes = createBo.getGoodsList().stream().map(ProcessGoodsItem::getInventoryCode).collect(Collectors.toList());
|
|
|
|
//初始化sku列表
|
|
|
|
List<ProcessGoodsItem> processGoodsItems = createBo.getGoodsList(); |
|
|
|
List<String> invCodes = new ArrayList<>(); |
|
|
@ -257,6 +258,7 @@ public class PortalOfCostApplication { |
|
|
|
.map(ProcessGoodsItem::getInventoryCode).distinct().collect(Collectors.toList()); |
|
|
|
} |
|
|
|
List<GoodsSku> skuList = this.initSkuListOfProcess(invCodes); |
|
|
|
skuList = this.filterRepSku(invCodes, skuList); |
|
|
|
//常用参数
|
|
|
|
final String GOODS_TYPE = "sku"; |
|
|
|
final BigDecimal OneHundred = new BigDecimal("100"); |
|
|
@ -268,8 +270,17 @@ public class PortalOfCostApplication { |
|
|
|
String costApplyCode = "CA"+CodeGenUtil.generate(CodeGenUtil.SourceKey.CostApply); |
|
|
|
String activityCode = costApplyCode + "_1"; |
|
|
|
String activityTitle = "由政策"+policyItem.getPolicyItemCode()+"核销一站式API生成的活动"; |
|
|
|
|
|
|
|
LambdaQueryWrapper<TbsCostApply> checkLqw = new LambdaQueryWrapper<>(); |
|
|
|
checkLqw.eq(TbsCostApply::getBillNumber,billNumber); |
|
|
|
checkLqw.eq(TbsCostApply::getPolicyItemId,policyItem.getId()); |
|
|
|
if(costApplyService.count(checkLqw)>0L){ |
|
|
|
Assert.throwEx("记录已存在"); |
|
|
|
} |
|
|
|
//构建费用申请
|
|
|
|
TbsCostApply costApply = new TbsCostApply(); |
|
|
|
//2024年1月23日,添加
|
|
|
|
costApply.setBillNumber(billNumber); |
|
|
|
costApply.setCode(costApplyCode); |
|
|
|
costApply.setChargeTheme(costTheme); |
|
|
|
costApply.setChargeState(TbsCostApplyState.State_3_finished.getCode()); |
|
|
@ -283,6 +294,7 @@ public class PortalOfCostApplication { |
|
|
|
costApply.setTotalActivityAmount(totalAmount); |
|
|
|
costApply.setTotalActivityUsedAmount(totalAmount); |
|
|
|
costApply.setPolicyItemId(policyItem.getId()); |
|
|
|
costApply.setPolicyItemCode(policyItem.getPolicyItemCode()); |
|
|
|
costApply.setSubmitTime(LocalDateTime.now()); |
|
|
|
//2024年1月17日,添加
|
|
|
|
costApply.setRemark(createBo.getErpCode()); |
|
|
@ -620,19 +632,8 @@ public class PortalOfCostApplication { |
|
|
|
Assert.throwEx("请选择存货提交"); |
|
|
|
} |
|
|
|
List<GoodsSku> skuList = this.initSkuListOfProcess(invCodeList); |
|
|
|
if(skuList.size()!=invCodeList.size()){ |
|
|
|
Set<String> missCodes = new HashSet<>(); |
|
|
|
for (String code : invCodeList) { |
|
|
|
boolean anyMatch = skuList.stream().anyMatch(a->a.getSkuCode().equals(code)); |
|
|
|
if(!anyMatch){ |
|
|
|
missCodes.add(code); |
|
|
|
} |
|
|
|
} |
|
|
|
Assert.throwEx("品类缺失("+skuList.size()+"-"+invCodeList.size()+"-"+missCodes.size()+"):"+missCodes.stream().collect(Collectors.joining(","))); |
|
|
|
} |
|
|
|
if(skuList.size()<1){ |
|
|
|
Assert.throwEx("请选择品类再提交"); |
|
|
|
} |
|
|
|
//排除重复的sku
|
|
|
|
skuList = this.filterRepSku(invCodeList, skuList); |
|
|
|
//常用参数
|
|
|
|
final String GOODS_TYPE = "sku"; |
|
|
|
final BigDecimal OneHundred = new BigDecimal("100"); |
|
|
@ -974,6 +975,40 @@ public class PortalOfCostApplication { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@NotNull |
|
|
|
private List<GoodsSku> filterRepSku(List<String> invCodeList, List<GoodsSku> skuList) { |
|
|
|
if (skuList.size() > invCodeList.size()){ |
|
|
|
List<GoodsSku> skuList1 = new ArrayList<>(); |
|
|
|
Set<String> codes = new HashSet<>(); |
|
|
|
for (String invCode : invCodeList) { |
|
|
|
for (GoodsSku goodsSku : skuList) { |
|
|
|
if(goodsSku.getSkuCode().equals(invCode)){ |
|
|
|
if(codes.contains(invCode)){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
codes.add(invCode); |
|
|
|
skuList1.add(goodsSku); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
skuList = skuList1; |
|
|
|
} |
|
|
|
if(skuList.size() < invCodeList.size()){ |
|
|
|
Set<String> missCodes = new HashSet<>(); |
|
|
|
for (String code : invCodeList) { |
|
|
|
boolean anyMatch = skuList.stream().anyMatch(a->a.getSkuCode().equals(code)); |
|
|
|
if(!anyMatch){ |
|
|
|
missCodes.add(code); |
|
|
|
} |
|
|
|
} |
|
|
|
Assert.throwEx("品类缺失("+ skuList.size()+"-"+ invCodeList.size()+"-"+missCodes.size()+"):"+missCodes.stream().collect(Collectors.joining(","))); |
|
|
|
} |
|
|
|
if(skuList.size()<1){ |
|
|
|
Assert.throwEx("请选择品类再提交"); |
|
|
|
} |
|
|
|
return skuList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 协议类费用 核销支付记录 |
|
|
|
* @param createBo |
|
|
|