|
|
@ -2,11 +2,13 @@ package com.qs.serve.modules.goods.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
import com.qs.serve.common.util.Assert; |
|
|
|
import com.qs.serve.common.util.AuthContextUtils; |
|
|
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
|
|
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper; |
|
|
|
import com.qs.serve.modules.goods.entity.GoodsSku; |
|
|
|
import com.qs.serve.modules.goods.entity.bo.GoodsCustomerPriceBo; |
|
|
|
import com.qs.serve.modules.goods.entity.bo.GoodsCustomerPriceSingleBo; |
|
|
|
import com.qs.serve.modules.goods.mapper.GoodsSkuMapper; |
|
|
|
import com.qs.serve.modules.sys.entity.SysUser; |
|
|
|
import com.qs.serve.modules.sys.mapper.SysUserMapper; |
|
|
@ -18,6 +20,8 @@ import com.qs.serve.modules.goods.service.GoodsCustomerPriceService; |
|
|
|
import com.qs.serve.modules.goods.mapper.GoodsCustomerPriceMapper; |
|
|
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* 客户价格关系表 服务实现类 |
|
|
@ -38,6 +42,7 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl<GoodsCustomerPric |
|
|
|
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){ |
|
|
@ -58,7 +63,9 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl<GoodsCustomerPric |
|
|
|
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()); |
|
|
@ -66,6 +73,47 @@ public class GoodsCustomerPriceServiceImpl extends ServiceImpl<GoodsCustomerPric |
|
|
|
this.updateById(customerPrice); |
|
|
|
} |
|
|
|
} |
|
|
|
//移除历史记录
|
|
|
|
LambdaQueryWrapper<GoodsCustomerPrice> rmLqw = new LambdaQueryWrapper<>(); |
|
|
|
rmLqw.eq(GoodsCustomerPrice::getSupplierId,supplier.getId()); |
|
|
|
rmLqw.notIn(GoodsCustomerPrice::getId,existIds); |
|
|
|
this.remove(rmLqw); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public GoodsCustomerPrice singleModify(GoodsCustomerPriceSingleBo param) { |
|
|
|
BmsSupplier supplier = bmsSupplierMapper.selectById(param.getSupplierId()); |
|
|
|
SysUser sysUser = sysUserMapper.selectById(AuthContextUtils.getSysUserId()); |
|
|
|
LocalDateTime nowTime = LocalDateTime.now(); |
|
|
|
|
|
|
|
GoodsCustomerPrice customerPrice = this.getBySupplierIdAndCode(param.getSupplierId(),param.getSkuCode()); |
|
|
|
if(customerPrice==null){ |
|
|
|
GoodsSku goodsSku = goodsSkuMapper.selectBySkuCode(param.getSkuCode()); |
|
|
|
if(goodsSku==null){ |
|
|
|
Assert.throwEx("存货不存在"); |
|
|
|
} |
|
|
|
customerPrice = new GoodsCustomerPrice(); |
|
|
|
customerPrice.setSupplierId(supplier.getId()); |
|
|
|
customerPrice.setSupplierCode(supplier.getCode()); |
|
|
|
customerPrice.setSupplierName(supplier.getSupplierName()); |
|
|
|
customerPrice.setSkuId(goodsSku.getId()+""); |
|
|
|
customerPrice.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
customerPrice.setSkuName(goodsSku.getSkuName()); |
|
|
|
customerPrice.setSkuUnit(goodsSku.getUnitName()); |
|
|
|
customerPrice.setInitPrice(goodsSku.getSalesPrice()); |
|
|
|
customerPrice.setRealPrice(param.getPrice()); |
|
|
|
customerPrice.setMaker(sysUser.getName()); |
|
|
|
customerPrice.setMakerCode(sysUser.getCode()); |
|
|
|
customerPrice.setMarkTime(nowTime); |
|
|
|
this.save(customerPrice); |
|
|
|
}else { |
|
|
|
customerPrice.setRealPrice(param.getPrice()); |
|
|
|
customerPrice.setMaker(sysUser.getName()); |
|
|
|
customerPrice.setMakerCode(sysUser.getCode()); |
|
|
|
customerPrice.setMarkTime(nowTime); |
|
|
|
this.updateById(customerPrice); |
|
|
|
} |
|
|
|
return customerPrice; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|