|
|
@ -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()); |
|
|
|