diff --git a/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java b/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java index 40fac3e1..b87da564 100644 --- a/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java @@ -22,6 +22,7 @@ import com.qs.serve.modules.goods.mapper.GoodsCustomerPriceMapper; import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * 客户价格关系表 服务实现类 @@ -44,45 +45,37 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl() + .eq(GoodsCustomerPrice::getSupplierId,param.getSupplierId()) + .in(GoodsCustomerPrice::getSkuCode, + param.getSkuPriceItemList().stream().map(GoodsCustomerPriceBo.SkuPriceItem::getSkuCode).collect(Collectors.toList()) + ) + ); + BmsSupplier supplier = bmsSupplierMapper.selectById(param.getSupplierId()); SysUser sysUser = sysUserMapper.selectById(AuthContextUtils.getSysUserId()); LocalDateTime nowTime = LocalDateTime.now(); - List existIds = new ArrayList<>(); for (GoodsCustomerPriceBo.SkuPriceItem item : param.getSkuPriceItemList()) { GoodsCustomerPrice customerPrice = this.getBySupplierIdAndCode(param.getSupplierId(),item.getSkuCode()); - if(customerPrice==null){ - GoodsSku goodsSku = goodsSkuMapper.selectBySkuCode(item.getSkuCode()); - if(goodsSku==null){ - continue; - } - customerPrice = new GoodsCustomerPrice(); - customerPrice.setSupplierId(supplier.getId()); - customerPrice.setSupplierCode(supplier.getCode()); - customerPrice.setSupplierName(supplier.getSupplierName()); - customerPrice.setSkuCode(goodsSku.getSkuCode()); - customerPrice.setSkuName(goodsSku.getSkuName()); - customerPrice.setSkuUnit(goodsSku.getUnitName()); - customerPrice.setInitPrice(goodsSku.getSalesPrice()); - customerPrice.setRealPrice(item.getPrice()); - customerPrice.setMaker(sysUser.getName()); - customerPrice.setMakerCode(sysUser.getCode()); - customerPrice.setMarkTime(nowTime); - this.save(customerPrice); - existIds.add(customerPrice.getId()); - }else { - existIds.add(customerPrice.getId()); - customerPrice.setRealPrice(item.getPrice()); - customerPrice.setMaker(sysUser.getName()); - customerPrice.setMakerCode(sysUser.getCode()); - customerPrice.setMarkTime(nowTime); - this.updateById(customerPrice); + GoodsSku goodsSku = goodsSkuMapper.selectBySkuCode(item.getSkuCode()); + if(goodsSku==null){ + continue; } + customerPrice = new GoodsCustomerPrice(); + customerPrice.setSupplierId(supplier.getId()); + customerPrice.setSupplierCode(supplier.getCode()); + customerPrice.setSupplierName(supplier.getSupplierName()); + customerPrice.setSkuCode(goodsSku.getSkuCode()); + customerPrice.setSkuName(goodsSku.getSkuName()); + customerPrice.setSkuUnit(goodsSku.getUnitName()); + customerPrice.setInitPrice(goodsSku.getSalesPrice()); + customerPrice.setRealPrice(item.getPrice()); + customerPrice.setMaker(sysUser.getName()); + customerPrice.setMakerCode(sysUser.getCode()); + customerPrice.setMarkTime(nowTime); + this.save(customerPrice); } - //移除历史记录 - LambdaQueryWrapper rmLqw = new LambdaQueryWrapper<>(); - rmLqw.eq(GoodsCustomerPrice::getSupplierId,supplier.getId()); - rmLqw.notIn(GoodsCustomerPrice::getId,existIds); - this.remove(rmLqw); } @Override @@ -100,7 +93,7 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl im query.setCusCode(supplierCode); query.setInvCodes(codes); try { - R res = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价"); - if(res.getStatus().equals(200)){ - List inventoryCusPrices = JsonUtil.jsonToList(res.getData(), InventoryCusPrice.class); - assert inventoryCusPrices != null; - for (InventoryCusPrice cusPrice : inventoryCusPrices) { - for (GoodsSku sku : skus) { - if(sku.getSkuCode().equals(cusPrice.getInvCode())){ - sku.setSalesPrice(cusPrice.getPrice()); - break; - } + GoodsCustomerPriceService goodsCustomerPriceService = SpringUtils.getBean(GoodsCustomerPriceService.class); + List customerPrices = goodsCustomerPriceService.getBySupplierCodeAndCode(supplierCode,codes); + for (GoodsCustomerPrice customerPrice : customerPrices) { + for (GoodsSku sku : skus) { + if(sku.getSkuCode().equals(customerPrice.getSkuCode())){ + sku.setSalesPrice(customerPrice.getRealPrice()); + break; } } } +// R res = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价"); +// if(res.getStatus().equals(200)){ +// List inventoryCusPrices = JsonUtil.jsonToList(res.getData(), InventoryCusPrice.class); +// assert inventoryCusPrices != null; +// for (InventoryCusPrice cusPrice : inventoryCusPrices) { +// for (GoodsSku sku : skus) { +// if(sku.getSkuCode().equals(cusPrice.getInvCode())){ +// sku.setSalesPrice(cusPrice.getPrice()); +// break; +// } +// } +// } +// } } catch (Exception e) { log.error("客户特殊价异常:{}",e.getMessage()); } diff --git a/src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java b/src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java index 3c6e1433..f15fb763 100644 --- a/src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java @@ -329,6 +329,16 @@ public class OmsOrderServiceImpl extends ServiceImpl im List skuCodes = newOrderItemList.stream().map(OmsOrderItem::getSkuCode).collect(Collectors.toList()); + List customerPrices = goodsCustomerPriceService.getBySupplierCodeAndCode(supplier.getCode(),skuCodes); + for (OmsOrderItem orderItem : newOrderItemList) { + for (GoodsCustomerPrice customerPrice : customerPrices) { + if(orderItem.getSkuCode().equals(customerPrice.getSkuCode())){ + orderItem.setSalesPrice(customerPrice.getRealPrice()); + break; + } + } + } + //拦截商品授权维度规则 if(supplier!=null){ GoodsAccrIdsDto accrIdsDto = goodsAccreditService.listIgnoreAcc2(supplier.getId(),supplier.listBizRegionIds(),supplier.listSaleRegionIds());