Browse Source

opt:客户特殊价调整

checkBack
Yen 1 year ago
parent
commit
8831aed837
  1. 6
      src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierStatementController.java
  2. 14
      src/main/java/com/qs/serve/modules/goods/controller/GoodsCustomerPriceController.java
  3. 24
      src/main/java/com/qs/serve/modules/goods/entity/GoodsCustomerPrice.java
  4. 30
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceSingleBo.java
  5. 6
      src/main/java/com/qs/serve/modules/goods/mapper/GoodsRuleMapper.java
  6. 6
      src/main/java/com/qs/serve/modules/goods/service/GoodsCustomerPriceService.java
  7. 48
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java
  8. 2
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsRuleServiceImpl.java

6
src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierStatementController.java

@ -39,7 +39,6 @@ public class BmsSupplierStatementController {
* @return
*/
@GetMapping("/list")
//@PreAuthorize("hasRole('bms:supplierStatement:query')")
public R<List<BmsSupplierStatement>> getList(BmsSupplierStatement param){
LambdaQueryWrapper<BmsSupplierStatement> lqw = new LambdaQueryWrapper<>(param);
List<BmsSupplierStatement> list = bmsSupplierStatementService.list(lqw);
@ -52,7 +51,6 @@ public class BmsSupplierStatementController {
* @return
*/
@GetMapping("/page")
//@PreAuthorize("hasRole('bms:supplierStatement:query')")
public R<PageVo<BmsSupplierStatement>> getPage(BmsSupplierStatement param){
LambdaQueryWrapper<BmsSupplierStatement> lqw = new LambdaQueryWrapper<>(param);
PageUtil.startPage();
@ -67,7 +65,6 @@ public class BmsSupplierStatementController {
*/
@GetMapping("/getById/{id}")
@SysLog(module = SystemModule.BASE, title = "客户货款对账单", biz = BizType.QUERY)
@PreAuthorize("hasRole('bms:supplierStatement:query')")
public R<BmsSupplierStatement> getById(@PathVariable("id") String id){
BmsSupplierStatement bmsSupplierStatement = bmsSupplierStatementService.getById(id);
return R.ok(bmsSupplierStatement);
@ -82,7 +79,6 @@ public class BmsSupplierStatementController {
*/
//@PostMapping("/updateById")
@SysLog(module = SystemModule.BASE, title = "客户货款对账单", biz = BizType.UPDATE)
//@PreAuthorize("hasRole('bms:supplierStatement:update')")
public R<?> updateById(@RequestBody @Valid BmsSupplierStatement param){
boolean result = bmsSupplierStatementService.updateById(param);
return R.isTrue(result);
@ -95,7 +91,6 @@ public class BmsSupplierStatementController {
*/
@PostMapping("/save")
@SysLog(module = SystemModule.BASE, title = "客户货款对账单", biz = BizType.INSERT)
//@PreAuthorize("hasRole('bms:supplierStatement:insert')")
public R<?> save(@RequestBody @Valid BmsSupplierStatement param){
boolean result = bmsSupplierStatementService.saveBmsSupplierStatement(param);
return R.isTrue(result);
@ -108,7 +103,6 @@ public class BmsSupplierStatementController {
*/
@DeleteMapping("/deleteById/{jslId}")
@SysLog(module = SystemModule.BASE, title = "客户货款对账单", biz = BizType.DELETE)
//@PreAuthorize("hasRole('bms:supplierStatement:delete')")
public R<?> deleteById(@PathVariable("jslId") String jslId){
boolean result = bmsSupplierStatementService.deleteBmsSupplierStatement(jslId);
return R.isTrue(result);

14
src/main/java/com/qs/serve/modules/goods/controller/GoodsCustomerPriceController.java

@ -10,6 +10,7 @@ import com.qs.serve.common.util.PageUtil;
import com.qs.serve.common.util.CopierUtil;
import com.qs.serve.common.util.StringUtils;
import com.qs.serve.modules.goods.entity.bo.GoodsCustomerPriceBo;
import com.qs.serve.modules.goods.entity.bo.GoodsCustomerPriceSingleBo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
@ -67,13 +68,24 @@ public class GoodsCustomerPriceController {
* @param id
* @return
*/
//@GetMapping("/getById/{id}")
@GetMapping("/getById/{id}")
@SysLog(module = SystemModule.GOODS, title = "客户价格关系表", biz = BizType.QUERY)
public R<GoodsCustomerPrice> getById(@PathVariable("id") String id){
GoodsCustomerPrice goodsCustomerPrice = goodsCustomerPriceService.getById(id);
return R.ok(goodsCustomerPrice);
}
/**
* 单个保存
* @param param
* @return
*/
@PostMapping("/singleModify")
@SysLog(module = SystemModule.GOODS, title = "单个保存", biz = BizType.INSERT)
public R<?> singleModify(@RequestBody @Valid GoodsCustomerPriceSingleBo param){
return R.ok(goodsCustomerPriceService.singleModify(param));
}
/**
* 批量保存
* @param param

24
src/main/java/com/qs/serve/modules/goods/entity/GoodsCustomerPrice.java

@ -115,29 +115,5 @@ public class GoodsCustomerPrice implements Serializable {
@JsonProperty
private Boolean delFlag;
public static GoodsCustomerPrice toNewObject(GoodsCustomerPrice source){
GoodsCustomerPrice customerPrice = new GoodsCustomerPrice();
customerPrice.setId(source.getId());
customerPrice.setSupplierId(source.getSupplierId());
customerPrice.setSupplierCode(source.getSupplierCode());
customerPrice.setSupplierName(source.getSupplierName());
customerPrice.setSkuCode(source.getSkuCode());
customerPrice.setSkuName(source.getSkuName());
customerPrice.setSkuUnit(source.getSkuUnit());
customerPrice.setInitPrice(source.getInitPrice());
customerPrice.setRealPrice(source.getRealPrice());
customerPrice.setMaker(source.getMaker());
customerPrice.setMakerCode(source.getMakerCode());
customerPrice.setMarkTime(source.getMarkTime());
customerPrice.setCreateTime(source.getCreateTime());
customerPrice.setCreateBy(source.getCreateBy());
customerPrice.setUpdateTime(source.getUpdateTime());
customerPrice.setUpdateBy(source.getUpdateBy());
customerPrice.setTenantId(source.getTenantId());
customerPrice.setDelFlag(source.getDelFlag());
return customerPrice;
}
}

30
src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceSingleBo.java

@ -0,0 +1,30 @@
package com.qs.serve.modules.goods.entity.bo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* 客户价格关系表 Bo
* @author YenHex
* @since 2024-01-08
*/
@Data
public class GoodsCustomerPriceSingleBo implements Serializable {
private static final long serialVersionUID = 1L;
/** 客户ID */
private String supplierId;
/** sku编码 */
private String skuCode;
/** 客户价格 */
private BigDecimal price;
}

6
src/main/java/com/qs/serve/modules/goods/mapper/GoodsRuleMapper.java

@ -13,13 +13,13 @@ import org.apache.ibatis.annotations.Update;
*/
public interface GoodsRuleMapper extends BaseMapper<GoodsRule> {
@Select("select * from goods_rule where supplier_id = #{supplierId}")
@Select("select * from goods_rule where supplier_id = #{supplierId} limit 1")
GoodsRule selectRuleBySupplierId(@Param("supplierId")Long supplierId);
@Select("select * from goods_rule where supplier_id = #{saleRegionId}")
@Select("select * from goods_rule where sale_region_id = #{saleRegionId} limit 1")
GoodsRule selectRuleBySaleRegionId(@Param("saleRegionId")String saleRegionId);
@Select("select * from goods_rule where supplier_id = #{bizRegionId}")
@Select("select * from goods_rule where biz_region_id = #{bizRegionId} limit 1 ")
GoodsRule selectRuleByBizRegionId(@Param("bizRegionId")String bizRegionId);
}

6
src/main/java/com/qs/serve/modules/goods/service/GoodsCustomerPriceService.java

@ -3,6 +3,10 @@ package com.qs.serve.modules.goods.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.goods.entity.GoodsCustomerPrice;
import com.qs.serve.modules.goods.entity.bo.GoodsCustomerPriceBo;
import com.qs.serve.modules.goods.entity.bo.GoodsCustomerPriceSingleBo;
import org.springframework.web.bind.annotation.RequestBody;
import javax.validation.Valid;
/**
* 客户价格关系表 服务接口
@ -14,6 +18,8 @@ public interface GoodsCustomerPriceService extends IService<GoodsCustomerPrice>
void saveBatch(GoodsCustomerPriceBo param);
GoodsCustomerPrice singleModify(GoodsCustomerPriceSingleBo param);
GoodsCustomerPrice getBySupplierIdAndCode(String supplierId,String skuCode);
}

48
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java

@ -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

2
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsRuleServiceImpl.java

@ -205,7 +205,7 @@ public class GoodsRuleServiceImpl extends ServiceImpl<GoodsRuleMapper,GoodsRule>
}else if (StringUtils.hasText(param.getSaleRegionId())){
BmsRegion region = saleRegionMapper.selectById(param.getSaleRegionId());
if(region!=null){
goodsRule = super.baseMapper.selectRuleBySaleRegionId(param.getBizRegionId());
goodsRule = super.baseMapper.selectRuleBySaleRegionId(param.getSaleRegionId());
if(goodsRule ==null){
goodsRule = new GoodsRule();
goodsRule.setSaleRegionId(param.getSaleRegionId());

Loading…
Cancel
Save