From 8831aed8370239e7462765771fa0922bce0d4e02 Mon Sep 17 00:00:00 2001 From: Yen Date: Tue, 26 Mar 2024 14:58:17 +0800 Subject: [PATCH] =?UTF-8?q?opt:=E5=AE=A2=E6=88=B7=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E4=BB=B7=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BmsSupplierStatementController.java | 6 --- .../GoodsCustomerPriceController.java | 14 +++++- .../goods/entity/GoodsCustomerPrice.java | 24 ---------- .../entity/bo/GoodsCustomerPriceSingleBo.java | 30 ++++++++++++ .../modules/goods/mapper/GoodsRuleMapper.java | 6 +-- .../service/GoodsCustomerPriceService.java | 6 +++ .../impl/GoodsCustomerPriceServiceImpl.java | 48 +++++++++++++++++++ .../service/impl/GoodsRuleServiceImpl.java | 2 +- 8 files changed, 101 insertions(+), 35 deletions(-) create mode 100644 src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceSingleBo.java diff --git a/src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierStatementController.java b/src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierStatementController.java index 252938d2..5acae2cf 100644 --- a/src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierStatementController.java +++ b/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> getList(BmsSupplierStatement param){ LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(param); List list = bmsSupplierStatementService.list(lqw); @@ -52,7 +51,6 @@ public class BmsSupplierStatementController { * @return */ @GetMapping("/page") - //@PreAuthorize("hasRole('bms:supplierStatement:query')") public R> getPage(BmsSupplierStatement param){ LambdaQueryWrapper 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 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); diff --git a/src/main/java/com/qs/serve/modules/goods/controller/GoodsCustomerPriceController.java b/src/main/java/com/qs/serve/modules/goods/controller/GoodsCustomerPriceController.java index f8c35053..0c6ab76e 100644 --- a/src/main/java/com/qs/serve/modules/goods/controller/GoodsCustomerPriceController.java +++ b/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 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 diff --git a/src/main/java/com/qs/serve/modules/goods/entity/GoodsCustomerPrice.java b/src/main/java/com/qs/serve/modules/goods/entity/GoodsCustomerPrice.java index 795a9201..d0dc3de1 100644 --- a/src/main/java/com/qs/serve/modules/goods/entity/GoodsCustomerPrice.java +++ b/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; - } - } diff --git a/src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceSingleBo.java b/src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceSingleBo.java new file mode 100644 index 00000000..400d72ca --- /dev/null +++ b/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; + + +} + diff --git a/src/main/java/com/qs/serve/modules/goods/mapper/GoodsRuleMapper.java b/src/main/java/com/qs/serve/modules/goods/mapper/GoodsRuleMapper.java index 2e6c9337..bf649e08 100644 --- a/src/main/java/com/qs/serve/modules/goods/mapper/GoodsRuleMapper.java +++ b/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 { - @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); } diff --git a/src/main/java/com/qs/serve/modules/goods/service/GoodsCustomerPriceService.java b/src/main/java/com/qs/serve/modules/goods/service/GoodsCustomerPriceService.java index a900aba9..9fdc0cac 100644 --- a/src/main/java/com/qs/serve/modules/goods/service/GoodsCustomerPriceService.java +++ b/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 void saveBatch(GoodsCustomerPriceBo param); + GoodsCustomerPrice singleModify(GoodsCustomerPriceSingleBo param); + GoodsCustomerPrice getBySupplierIdAndCode(String supplierId,String skuCode); } 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 5e28cd1a..48151e65 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 @@ -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 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 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 diff --git a/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsRuleServiceImpl.java b/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsRuleServiceImpl.java index 5b44ea2d..60f64ed3 100644 --- a/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsRuleServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsRuleServiceImpl.java @@ -205,7 +205,7 @@ public class GoodsRuleServiceImpl extends ServiceImpl }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());