Browse Source

refactor: 重构商品维度规则查询

checkBack
Yen 1 year ago
parent
commit
4bc0b71b0d
  1. 7
      src/main/java/com/qs/serve/modules/bir/controller/BirActivityCenterGoodsController.java
  2. 4
      src/main/java/com/qs/serve/modules/bir/entity/BirActivityCenterGoods.java
  3. 23
      src/main/java/com/qs/serve/modules/bir/service/impl/BirActivityCenterGoodsServiceImpl.java
  4. 36
      src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java
  5. 2
      src/main/java/com/qs/serve/modules/goods/entity/GoodsAccredit.java
  6. 3
      src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java
  7. 25
      src/main/java/com/qs/serve/modules/goods/entity/dto/GoodsAccrIdsDto.java
  8. 19
      src/main/java/com/qs/serve/modules/goods/mapper/GoodsSkuMapper.java
  9. 14
      src/main/java/com/qs/serve/modules/goods/service/GoodsAccreditService.java
  10. 120
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java
  11. 4
      src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java
  12. 22
      src/main/java/com/qs/serve/modules/sys/service/impl/SysDeleteLogServiceImpl.java
  13. 11
      src/main/java/com/qs/serve/modules/third/PortalOfCostController.java
  14. 21
      src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java
  15. 3
      src/main/java/com/qs/serve/modules/vtb/service/impl/VtbVerificationServiceImpl.java
  16. 55
      src/main/resources/mapper/goods/GoodsSkuMapper.xml
  17. 6
      src/main/resources/mapper/goods/GoodsSpuMapper.xml

7
src/main/java/com/qs/serve/modules/bir/controller/BirActivityCenterGoodsController.java

@ -77,13 +77,12 @@ public class BirActivityCenterGoodsController {
@GetMapping("/toSyncDev")
public R<?> syncBir(Integer idType){
LambdaQueryWrapper<TbsCostApply> lqw = new LambdaQueryWrapper<>();
lqw.notIn(TbsCostApply::getChargeState,0)
.select(TbsCostApply::getId)
lqw
.select(TbsCostApply::getId).ne(TbsCostApply::getChargeState,0)
.eq(TbsCostApply::getCancelFlag,0)
.eq(TbsCostApply::getTmpState,0)
.gt(TbsCostApply::getTotalActivity,0)
.ge(TbsCostApply::getSubmitTime, LocalDate.of(2024,1,1).atStartOfDay())
.last(" limit 100");
.ge(TbsCostApply::getCreateTime, LocalDate.of(2023,1,1).atStartOfDay()) ;
boolean ex = extracted(lqw);
while (!ex){
ex = extracted(lqw);

4
src/main/java/com/qs/serve/modules/bir/entity/BirActivityCenterGoods.java

@ -325,6 +325,10 @@ public class BirActivityCenterGoods implements Serializable {
private Long templateId;
private Long budgetId;
private Long scheduleItemBudgetId;
@TableField(condition = SqlCondition.LIKE)
private String templateTitle;

23
src/main/java/com/qs/serve/modules/bir/service/impl/BirActivityCenterGoodsServiceImpl.java

@ -24,14 +24,12 @@ import com.qs.serve.modules.bms.mapper.BmsRegionMapper;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.tbs.common.TbsActivityState;
import com.qs.serve.modules.tbs.common.TbsCostApplyState;
import com.qs.serve.modules.tbs.entity.TbsActivity;
import com.qs.serve.modules.tbs.entity.TbsActivityCenter;
import com.qs.serve.modules.tbs.entity.TbsActivityCenterGoods;
import com.qs.serve.modules.tbs.entity.TbsCostApply;
import com.qs.serve.modules.tbs.entity.*;
import com.qs.serve.modules.tbs.mapper.TbsActivityCenterGoodsMapper;
import com.qs.serve.modules.tbs.mapper.TbsActivityMapper;
import com.qs.serve.modules.tbs.mapper.TbsCostApplyMapper;
import com.qs.serve.modules.tbs.service.TbsActivityCenterGoodsService;
import com.qs.serve.modules.tbs.service.TbsBudgetCostItemService;
import com.qs.serve.modules.vtb.common.VtbFundFlowType;
import com.qs.serve.modules.vtb.entity.VtbFundFlow;
import com.qs.serve.modules.vtb.entity.dto.VtbFundFlowSumAmtDTO;
@ -81,6 +79,8 @@ public class BirActivityCenterGoodsServiceImpl extends ServiceImpl<BirActivityCe
private final BirBaseActivityService birBaseActivityService;
private final TbsBudgetCostItemService budgetCostItemService;
@Override
public void rebuildBir(List<Long> costApplyIds) {
if(CollectionUtil.isEmpty(costApplyIds)){
@ -148,7 +148,6 @@ public class BirActivityCenterGoodsServiceImpl extends ServiceImpl<BirActivityCe
List<BmsRegion> saleRegionList = regionMapper.selectList(regionLqw);
Map<String,BmsRegion> saleRegionMap = saleRegionList.stream().collect(Collectors.toMap(BmsRegion::getId,a->a));
LambdaQueryWrapper<BmsRegion2> region2Lqw = new LambdaQueryWrapper<>();
region2Lqw.in(BmsRegion2::getId,bmsSupplierList.stream().map(a->a.getRegion2Last()).collect(Collectors.toList()));
List<BmsRegion2> bizRegionList = region2Mapper.selectList(region2Lqw);
@ -186,6 +185,12 @@ public class BirActivityCenterGoodsServiceImpl extends ServiceImpl<BirActivityCe
List<TbsActivityCenterGoods> activityCenterGoodsList = collectMap.get(activityId);
for (TbsActivityCenterGoods activityCenterGoods : activityCenterGoodsList) {
//绑定预算信息
TbsBudgetCostItem costItem = budgetCostItemService.getOne(
new LambdaQueryWrapper<TbsBudgetCostItem>()
.eq(TbsBudgetCostItem::getCenterGoodItemId,activityCenterGoods.getId()),false);
LocalDate actStartDate = activityCenterGoods.getPreStartDate();
LocalDate actEndDate = activityCenterGoods.getPreEndDate();
int currentActDays = (int) (actEndDate.toEpochDay()-actStartDate.toEpochDay()+1);
@ -198,6 +203,10 @@ public class BirActivityCenterGoodsServiceImpl extends ServiceImpl<BirActivityCe
//创建底表对象
BirActivityCenterGoods entity = createBirActivityCenterGoodsEntity(costCenterList,
activityCenterGoods, currentActDays, currDateSplit, goodSplitDTO,supplierMap,saleRegionMap,bizRegionMap,costApply);
if(costItem!=null){
entity.setBudgetId(costItem.getBudgetId());
entity.setScheduleItemBudgetId(costItem.getScheduleItemBudgetId());
}
bacgList.add(entity);
}
}else if (dateSplitList.size()==1){
@ -208,6 +217,10 @@ public class BirActivityCenterGoodsServiceImpl extends ServiceImpl<BirActivityCe
//创建底表对象
BirActivityCenterGoods entity = createBirActivityCenterGoodsEntity(costCenterList,
activityCenterGoods, currentActDays, currDateSplit, goodSplitDTO,supplierMap,saleRegionMap,bizRegionMap,costApply);
if(costItem!=null){
entity.setBudgetId(costItem.getBudgetId());
entity.setScheduleItemBudgetId(costItem.getScheduleItemBudgetId());
}
bacgList.add(entity);
}
}

36
src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java

@ -10,18 +10,19 @@ import com.qs.serve.common.model.enums.BizType;
import com.qs.serve.common.model.enums.SystemModule;
import com.qs.serve.common.util.*;
import com.qs.serve.modules.bms.entity.BmsSupplier;
import com.qs.serve.modules.bms.service.BmsSubjectService;
import com.qs.serve.modules.bms.service.BmsSupplierService;
import com.qs.serve.modules.erp.mapper.ErpDispatchDataMapper;
import com.qs.serve.modules.goods.common.GoodsConst;
import com.qs.serve.modules.goods.entity.*;
import com.qs.serve.modules.goods.entity.bo.*;
import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto;
import com.qs.serve.modules.goods.entity.dto.GoodsRuleItemDTO;
import com.qs.serve.modules.goods.entity.dto.InventoryCusPrice;
import com.qs.serve.modules.goods.entity.so.GoodsHisOrderQuery;
import com.qs.serve.modules.goods.entity.so.InventoryCusPriceQuery;
import com.qs.serve.modules.goods.entity.vo.GoodsSpuExportVo;
import com.qs.serve.modules.goods.entity.vo.GoodsSpuVo;
import com.qs.serve.modules.goods.mapper.GoodsSkuMapper;
import com.qs.serve.modules.goods.mapper.GoodsSpuMapper;
import com.qs.serve.modules.goods.service.*;
import com.qs.serve.modules.oms.entity.dto.OmsSpuToSkuKey;
@ -56,6 +57,7 @@ import java.util.stream.Collectors;
public class GoodsSpuController {
private GoodsSpuMapper goodsSpuMapper;
private GoodsSkuMapper goodsSkuMapper;
private GoodsRuleService goodsRuleService;
private GoodsSkuService goodsSkuService;
private GoodsSpuService goodsSpuService;
@ -154,26 +156,18 @@ public class GoodsSpuController {
}
private void tiSetSpuParam2(GoodsSpu param, BmsSupplier supplier) {
List<GoodsAccredit> goodsAccreditList = goodsAccreditService
.listIgnoreAcc(supplier.getId(), supplier.listBizRegionIds(), supplier.listSaleRegionIds());
Set<Long> spuIds = goodsAccreditList.stream().map(GoodsAccredit::getSpuId).filter(Objects::nonNull).collect(Collectors.toSet());
Set<String> cateIds = goodsAccreditList.stream().map(GoodsAccredit::getCategoryId).filter(Objects::nonNull).collect(Collectors.toSet());
if(CollUtil.isNotEmpty(cateIds)){
log.debug("SelectNotIntCateIds() {}",JsonUtil.objectToJson(cateIds));
if(CollUtil.isEmpty(param.getSelectNotIntCateIds())){
param.setSelectNotIntCateIds(new ArrayList<>(cateIds));
}else{
param.getSelectNotIntCateIds().addAll(cateIds);
}
}
if(CollUtil.isNotEmpty(spuIds)){
log.debug("getSelectNotInIds() {}",JsonUtil.objectToJson(spuIds));
if (CollUtil.isEmpty(param.getSelectNotInIds())){
param.setSelectNotInIds(new ArrayList<>(spuIds));
}else{
param.getSelectNotInIds().addAll(spuIds);
}
}
GoodsAccrIdsDto accrIdsDto = goodsAccreditService
.listIgnoreAcc2(supplier.getId(), supplier.listBizRegionIds(), supplier.listSaleRegionIds());
List<Long> ids = goodsSkuMapper.listByOtherIds(
accrIdsDto.getCateIds(),
accrIdsDto.getSpuIds(),
accrIdsDto.getSkuIds(),
accrIdsDto.getNotInCateIds(),
accrIdsDto.getNotInSpuIds(),
accrIdsDto.getNotInSkuIds()
);
param.setNotInSkuIds(ids);
}
/**

2
src/main/java/com/qs/serve/modules/goods/entity/GoodsAccredit.java

@ -34,6 +34,8 @@ public class GoodsAccredit implements Serializable {
/** 客户id */
private Long spuId;
private Long skuId;
/** 销售区域id */
@Length(max = 32,message = "销售区域id长度不能超过32字")
private String categoryId;

3
src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java

@ -178,6 +178,9 @@ public class GoodsSpu implements Serializable {
@TableField(exist = false)
private Integer selectSpecialFlag;
@TableField(exist = false)
private List<Long> notInSkuIds;
@TableField(exist = false)
private BigDecimal skuPrice;

25
src/main/java/com/qs/serve/modules/goods/entity/dto/GoodsAccrIdsDto.java

@ -0,0 +1,25 @@
package com.qs.serve.modules.goods.entity.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
/**
* @author YenHex
* @since 2024/4/7
*/
@Data
@AllArgsConstructor
public class GoodsAccrIdsDto {
private List<Long> skuIds;
private List<Long> spuIds;
private List<String> cateIds;
private List<Long> notInSkuIds;
private List<Long> notInSpuIds;
private List<String> notInCateIds;
}

19
src/main/java/com/qs/serve/modules/goods/mapper/GoodsSkuMapper.java

@ -43,5 +43,24 @@ public interface GoodsSkuMapper extends BaseMapper<GoodsSku> {
@Select("select * from goods_sku where sku_code = #{skuCode} and del_flag = 0 limit 1 ")
GoodsSku selectBySkuCode(@Param("skuCode")String skuCode);
/**
* 列出skuId
* @param cateIds
* @param spuIds
* @param skuIds
* @param notInCateIds
* @param notInSpuIds
* @param notInSkuIds
* @return
*/
@InterceptorIgnore(tenantLine = "1")
List<Long> listByOtherIds(@Param("cateIds") List<String> cateIds,
@Param("spuIds") List<Long> spuIds,
@Param("skuIds") List<Long> skuIds,
@Param("notInCateIds") List<String> notInCateIds,
@Param("notInSpuIds") List<Long> notInSpuIds,
@Param("notInSkuIds") List<Long> notInSkuIds);
}

14
src/main/java/com/qs/serve/modules/goods/service/GoodsAccreditService.java

@ -3,10 +3,13 @@ package com.qs.serve.modules.goods.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.goods.entity.GoodsAccredit;
import com.qs.serve.modules.goods.entity.GoodsAccreditItem;
import com.qs.serve.modules.goods.entity.GoodsRuleItem;
import com.qs.serve.modules.goods.entity.bo.GoodsAccreditBo;
import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto;
import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo;
import java.util.List;
import java.util.Map;
/**
* 规则 服务接口
@ -31,5 +34,16 @@ public interface GoodsAccreditService extends IService<GoodsAccredit> {
*/
List<GoodsAccredit> listIgnoreAcc(String supplierId,List<String> bizRegionIds,List<String> saleRegionIds);
GoodsAccrIdsDto listIgnoreAcc2(String supplierId, List<String> bizRegionIds, List<String> saleRegionIds);
/**
* 检测sku是否符合规则
* @param spuIds
* @param accreditList
* @param throwEx 不判断数量拦截只条件拦截
* @return
*/
boolean checkSkuCode(List<Long> spuIds, List<GoodsAccredit> accreditList, boolean throwEx);
}

120
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsAccreditServiceImpl.java

@ -13,21 +13,16 @@ import com.qs.serve.modules.bms.mapper.BmsRegionMapper;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.goods.entity.*;
import com.qs.serve.modules.goods.entity.bo.GoodsAccreditBo;
import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto;
import com.qs.serve.modules.goods.entity.vo.GoodsAccreditVo;
import com.qs.serve.modules.goods.mapper.GoodsAccreditItemMapper;
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper;
import com.qs.serve.modules.goods.mapper.GoodsSpuMapper;
import com.qs.serve.modules.goods.mapper.*;
import com.qs.serve.modules.goods.service.GoodsAccreditItemService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.qs.serve.modules.goods.service.GoodsAccreditService;
import com.qs.serve.modules.goods.mapper.GoodsAccreditMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -42,10 +37,12 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
private final GoodsCategoryMapper categoryMapper;
private final GoodsSpuMapper goodsSpuMapper;
private final GoodsSkuMapper goodsSkuMapper;
private final BmsRegionMapper regionMapper;
private final BmsRegion2Mapper region2Mapper;
private final BmsSupplierMapper supplierMapper;
private final GoodsSpuMapper spuMapper;
private final GoodsAccreditItemService goodsAccreditItemService;
@ -326,6 +323,105 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
return this.listByIds(accIds);
}
@Override
public GoodsAccrIdsDto listIgnoreAcc2(String supplierId, List<String> bizRegionIds, List<String> saleRegionIds) {
//查询自身所有
LambdaQueryWrapper<GoodsAccreditItem> lqw = new LambdaQueryWrapper<>();
lqw.select(GoodsAccreditItem::getId,GoodsAccreditItem::getAccType)
.or(a->a.eq(GoodsAccreditItem::getTargetType,"supplier").eq(GoodsAccreditItem::getTargetId,supplierId))
.or(a->a.eq(GoodsAccreditItem::getTargetType,"saleRegion").in(GoodsAccreditItem::getTargetId,saleRegionIds))
.or(a->a.eq(GoodsAccreditItem::getTargetType,"bizRegion").in(GoodsAccreditItem::getTargetId,bizRegionIds));
List<Long> selfNotInIds = goodsAccreditItemService.list(lqw).stream()
.filter(a->a.getAccType().equals(1)).map(GoodsAccreditItem::getId).collect(Collectors.toList());
List<Long> selfInIds = goodsAccreditItemService.list(lqw).stream()
.filter(a->a.getAccType().equals(0)).map(GoodsAccreditItem::getId).collect(Collectors.toList());
//查询其它维度所有in
LambdaQueryWrapper<GoodsAccreditItem> lqw2 = new LambdaQueryWrapper<>();
lqw2.select(GoodsAccreditItem::getId)
.eq(GoodsAccreditItem::getAccType,0).and(
qw->{
qw.or(a->a.eq(GoodsAccreditItem::getTargetType,"supplier").ne(GoodsAccreditItem::getTargetId,supplierId))
.or(a->a.eq(GoodsAccreditItem::getTargetType,"saleRegion").notIn(GoodsAccreditItem::getTargetId,saleRegionIds))
.or(a->a.eq(GoodsAccreditItem::getTargetType,"bizRegion").notIn(GoodsAccreditItem::getTargetId,bizRegionIds));
}
);
List<Long> otherInIds = goodsAccreditItemService.list(lqw2)
.stream().map(GoodsAccreditItem::getId).collect(Collectors.toList());
selfNotInIds.addAll(otherInIds);
List<Long> skuIds = new ArrayList<>();
List<Long> spuIds = new ArrayList<>();
List<String> cateIds = new ArrayList<>();
List<Long> skuNotInIds = new ArrayList<>();
List<Long> spuNotInIds = new ArrayList<>();
List<String> cateNotInIds = new ArrayList<>();
//设置默认值 防止空in
skuIds.add(-1000L);
spuIds.add(-1000L);
cateIds.add("-999");
skuNotInIds.add(-1000L);
spuNotInIds.add(-1000L);
cateNotInIds.add("-999");
if(CollUtil.isNotEmpty(selfNotInIds)){
List<GoodsAccredit> notInList = this.listByIds(selfNotInIds);
Set<Long> spuIds2 = notInList.stream().map(GoodsAccredit::getSpuId).filter(Objects::nonNull).collect(Collectors.toSet());
Set<Long> skuIds2 = notInList.stream().map(GoodsAccredit::getSkuId).filter(Objects::nonNull).collect(Collectors.toSet());
Set<String> cateIds2 = notInList.stream().map(GoodsAccredit::getCategoryId).filter(Objects::nonNull).collect(Collectors.toSet());
skuIds.addAll(skuIds2);
spuIds.addAll(spuIds2);
cateIds.addAll(cateIds2);
}
if(CollUtil.isNotEmpty(selfInIds)){
List<GoodsAccredit> inList = this.listByIds(selfInIds);
Set<Long> spuIds2 = inList.stream().map(GoodsAccredit::getSpuId).filter(Objects::nonNull).collect(Collectors.toSet());
Set<Long> skuIds2 = inList.stream().map(GoodsAccredit::getSkuId).filter(Objects::nonNull).collect(Collectors.toSet());
Set<String> cateIds2 = inList.stream().map(GoodsAccredit::getCategoryId).filter(Objects::nonNull).collect(Collectors.toSet());
skuNotInIds.addAll(skuIds2);
spuNotInIds.addAll(spuIds2);
cateNotInIds.addAll(cateIds2);
}
return new GoodsAccrIdsDto(skuIds,spuIds,cateIds,skuNotInIds,spuNotInIds,cateNotInIds);
}
@Override
public boolean checkSkuCode(List<Long> spuIds, List<GoodsAccredit> accreditList, boolean throwEx) {
if(CollUtil.isEmpty(spuIds)){
return false;
}
List<GoodsSpu> spuList = spuMapper.selectBatchIds(spuIds);
for (GoodsAccredit accredit : accreditList) {
if(accredit.getSpuId()!=null){
for (GoodsSpu spu : spuList) {
if(spu.getId().equals(accredit.getSpuId())){
if(throwEx){
Assert.throwEx("SKU["+spu.getSpuCode()+"]不可下单");
}
return false;
}
}
}else if (accredit.getCategoryId()!=null){
for (GoodsSpu spu : spuList) {
for (String categoryId : spu.listCategoryIds()) {
if(categoryId.equals(accredit.getCategoryId())){
if(throwEx){
Assert.throwEx("SKU["+spu.getSpuCode()+"]不可下单");
}
return false;
}
}
}
}
}
return false;
}
private GoodsAccredit getGoodsAccredit(GoodsAccreditBo param){
GoodsAccredit accredit = null;
if(param.getCategoryId()!=null){
@ -344,6 +440,14 @@ public class GoodsAccreditServiceImpl extends ServiceImpl<GoodsAccreditMapper,Go
accredit = new GoodsAccredit();
accredit.setSpuId(spu.getId());
}
}else if (param.getSkuId()!=null){
accredit = this.getOne( new LambdaQueryWrapper<GoodsAccredit>()
.eq(GoodsAccredit::getSkuId,param.getSkuId()),false);
if(accredit==null){
GoodsSku sku = goodsSkuMapper.selectById(param.getSkuId());
accredit = new GoodsAccredit();
accredit.setSkuId(sku.getId());
}
}
return accredit;
}

4
src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java

@ -12,6 +12,7 @@ import com.qs.serve.modules.bms.mapper.BmsRegionMapper;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.bms.service.BmsSupplierAddressService;
import com.qs.serve.modules.goods.common.GoodsConst;
import com.qs.serve.modules.goods.entity.GoodsAccredit;
import com.qs.serve.modules.goods.entity.GoodsCategoryRule;
import com.qs.serve.modules.goods.entity.GoodsSku;
import com.qs.serve.modules.goods.entity.GoodsSpu;
@ -330,7 +331,8 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im
//拦截商品授权维度规则
if(supplier!=null){
goodsAccreditService.listIgnoreAcc(supplier.getId(),supplier.getSelectBizRegionIds(),supplier.getSelectSaleRegionIds());
List<GoodsAccredit> accredits = goodsAccreditService.listIgnoreAcc(supplier.getId(),supplier.getSelectBizRegionIds(),supplier.getSelectSaleRegionIds());
goodsAccreditService.checkSkuCode(spuIds,accredits,true);
}
//拦截客户维度规则

22
src/main/java/com/qs/serve/modules/sys/service/impl/SysDeleteLogServiceImpl.java

@ -66,17 +66,17 @@ public class SysDeleteLogServiceImpl extends ServiceImpl<SysDeleteLogMapper,SysD
}
//远程删除ERP
String url = "http://59.37.164.96:2505/api/cms/cost/deletion";
CostDeletion costDeletion = new CostDeletion();
costDeletion.setEmpNo(costApply.getUserCode());
String bookCode = ThirtyVerification.getInitBookCode(supplier.getBookCode(),supplier.getCode());
costDeletion.setCacc(bookCode);
costDeletion.setVerificationCode(costApply.getCode());
String rs = HttpUtil.doPost(url, JsonUtil.objectToJson(costDeletion),null);
if(!rs.contains("200")){
Assert.throwEx("远程删除失败");
}
// String url = "http://59.37.164.96:2505/api/cms/cost/deletion";
// CostDeletion costDeletion = new CostDeletion();
// costDeletion.setEmpNo(costApply.getUserCode());
// String bookCode = ThirtyVerification.getInitBookCode(supplier.getBookCode(),supplier.getCode());
// costDeletion.setCacc(bookCode);
// costDeletion.setVerificationCode(costApply.getCode());
// String rs = HttpUtil.doPost(url, JsonUtil.objectToJson(costDeletion),null);
//
// if(!rs.contains("200")){
// Assert.throwEx("远程删除失败");
// }
tbsCostApplyRemoveMapper.tbs_cost_apply(costApplyId);

11
src/main/java/com/qs/serve/modules/third/PortalOfCostController.java

@ -113,6 +113,17 @@ public class PortalOfCostController {
return R.error("支付异常");
}
/**
* 回调补偿因事务导致数据错误的数据
* @param costId
* @return
*/
@GetMapping("/checkContractCheck")
public R<?> checkContractCheck(Long costId){
portalOfCostApplication.updateCostUsedAmount(costId);
return R.ok();
}
/**
* 协议类费用 释放接口
* @param contractBo

21
src/main/java/com/qs/serve/modules/third/service/PortalOfCostApplication.java

@ -1,5 +1,6 @@
package com.qs.serve.modules.third.service;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qs.serve.common.config.properties.ProjectApisProperties;
@ -1071,7 +1072,7 @@ public class PortalOfCostApplication {
* 协议类费用 核销支付记录
* @param createBo
*/
@Transactional(rollbackFor = Exception.class)
@DSTransactional
public void createByContractCheck(ProcessCreateContractCheckBo createBo){
TbsCostApply costApply = costApplyService.getByCode(createBo.getCostCode());
if(!costApply.getChargeState().equals(2)){
@ -1229,17 +1230,25 @@ public class PortalOfCostApplication {
}
//判断金额是否用完,用完直接更新状态
//根据ActivitySubject更新活动金额
List<TbsActivitySubject> subjectNewList = activitySubjectService.listByActivityId(activity.getId());
Map<Long,List<TbsActivitySubject>> groupActSubject= subjectNewList.stream()
.collect(Collectors.groupingBy(TbsActivitySubject::getActivityId));
this.updateCostUsedAmount(costApply.getId());
}
public void updateCostUsedAmount(Long costId) {
TbsCostApply costApply = costApplyService.getById(costId);
List<VtbVerificationSubject> subjectNewList = verificationSubjectService.list(
new LambdaQueryWrapper<VtbVerificationSubject>()
.eq(VtbVerificationSubject::getCostApplyId,costId));
Map<Long,List<VtbVerificationSubject>> groupActSubject= subjectNewList.stream()
.collect(Collectors.groupingBy(VtbVerificationSubject::getActivityId));
//统计费用申请
BigDecimal totalCostAmt = BigDecimal.ZERO;
for (Long actId : groupActSubject.keySet()) {
TbsActivity tbsActivity = activityService.getById(actId);
List<TbsActivitySubject> activitySubjects = groupActSubject.get(actId);
List<VtbVerificationSubject> activitySubjects = groupActSubject.get(actId);
//统计活动
BigDecimal totalActAmt = BigDecimal.ZERO;
for (TbsActivitySubject actSubject : activitySubjects) {
for (VtbVerificationSubject actSubject : activitySubjects) {
if(actSubject.getUsedAmount()==null){
continue;
}

3
src/main/java/com/qs/serve/modules/vtb/service/impl/VtbVerificationServiceImpl.java

@ -473,6 +473,9 @@ public class VtbVerificationServiceImpl extends ServiceImpl<VtbVerificationMappe
}
log.warn("费用释放 activityId:{} url:{}",activityId,url);
SysUser sysUser = sysUserService.getByAccount(userCode);
if(sysUser==null){
Assert.throwEx("用户编码不存在:"+userCode);
}
TbsActivity activity = activityService.getById(activityId);
if(!activity.getActivityState().equals(TbsActivityState.STATE_0_Todo)){
if(!throwEx){

55
src/main/resources/mapper/goods/GoodsSkuMapper.xml

@ -206,4 +206,59 @@
SELECT `belong` FROM `goods_sku` where `belong` is not null GROUP BY `belong`
</select>
<select id="listByOtherIds" resultType="java.lang.Long">
select sku.id FROM goods_sku sku
left join goods_spu spu on sku.spu_id = spu.id
left join goods_category cate1 on cate1.id = spu.category_first
left join goods_category cate2 on cate2.id = spu.category_second
left join goods_category cate3 on cate3.id = spu.category_third
where
(
sku.id in
<foreach collection="skuIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
or spu.id in
<foreach collection="spuIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
or cate1.id in
<foreach collection="cateIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
or cate2.id in
<foreach collection="cateIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
or cate3.id in
<foreach collection="cateIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
) and
sku.id not in
<foreach collection="notInSkuIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
and
spu.id not in
<foreach collection="notInSpuIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
and
cate1.id not in
<foreach collection="cateIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
and
cate2.id not in
<foreach collection="cateIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
and
cate3.id not in
<foreach collection="cateIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</select>
</mapper>

6
src/main/resources/mapper/goods/GoodsSpuMapper.xml

@ -89,6 +89,12 @@
`goods_sku`.`sku_name` like concat('%', #{query.keyword},'%')
)
</if>
<if test="query.notInSkuIds!=null and query.notInSkuIds.size > 0">
and `goods_spu`.`id` in
<foreach collection="query.notInSkuIds" item ="selectId" index="i" open="(" close=")" separator=",">
#{selectId}
</foreach>
</if>
</sql>
<sql id="spuWherePart">

Loading…
Cancel
Save