Browse Source

fix:客户特殊价异常修复

checkBack
Yen 1 year ago
parent
commit
37fd830393
  1. 62
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java
  2. 31
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsSkuServiceImpl.java
  3. 10
      src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java

62
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<GoodsCustomerPric
@Override
public void saveBatch(GoodsCustomerPriceBo param) {
// 移除历史记录
this.remove(new LambdaQueryWrapper<GoodsCustomerPrice>()
.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<Long> 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<GoodsCustomerPrice> 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<GoodsCustomerPric
customerPrice = new GoodsCustomerPrice();
customerPrice.setSupplierId(supplier.getId());
customerPrice.setSupplierCode(supplier.getCode());
customerPrice.setSupplierName(supplier.getSupplierName());
customerPrice.setSupplierName(supplier.getName());
customerPrice.setSkuId(goodsSku.getId()+"");
customerPrice.setSkuCode(goodsSku.getSkuCode());
customerPrice.setSkuName(goodsSku.getSkuName());
@ -112,6 +105,9 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl<GoodsCustomerPric
customerPrice.setMarkTime(nowTime);
this.save(customerPrice);
}else {
customerPrice.setSupplierId(supplier.getId());
customerPrice.setSupplierCode(supplier.getCode());
customerPrice.setSupplierName(supplier.getName());
customerPrice.setRealPrice(param.getPrice());
customerPrice.setMaker(sysUser.getName());
customerPrice.setMakerCode(sysUser.getCode());

31
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsSkuServiceImpl.java

@ -13,6 +13,7 @@ import com.qs.serve.modules.goods.entity.vo.GoodSkuVo;
import com.qs.serve.modules.goods.entity.vo.GoodsSkuSpecValueVo;
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper;
import com.qs.serve.modules.goods.mapper.GoodsSpuMapper;
import com.qs.serve.modules.goods.service.GoodsCustomerPriceService;
import com.qs.serve.modules.goods.service.GoodsSkuSpecValueService;
import com.qs.serve.modules.goods.service.GoodsSpecValueService;
import com.qs.serve.modules.seeyon.service.impl.SeeYonRequestBaseService;
@ -90,19 +91,29 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper,GoodsSku> im
query.setCusCode(supplierCode);
query.setInvCodes(codes);
try {
R<String> res = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价");
if(res.getStatus().equals(200)){
List<InventoryCusPrice> 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<GoodsCustomerPrice> 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<String> res = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价");
// if(res.getStatus().equals(200)){
// List<InventoryCusPrice> 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());
}

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

@ -329,6 +329,16 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im
List<String> skuCodes = newOrderItemList.stream().map(OmsOrderItem::getSkuCode).collect(Collectors.toList());
List<GoodsCustomerPrice> 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());

Loading…
Cancel
Save