From 1537c711a1fb7c4562e0c25c9ea055bdc0eef88d Mon Sep 17 00:00:00 2001 From: Yen Date: Tue, 9 Jan 2024 11:30:28 +0800 Subject: [PATCH] =?UTF-8?q?SKU=E5=AE=A2=E6=88=B7=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GoodsCustomerPriceController.java | 103 +++++++++++++ .../goods/entity/GoodsCustomerPrice.java | 143 ++++++++++++++++++ .../goods/entity/bo/GoodsCustomerPriceBo.java | 46 ++++++ .../mapper/GoodsCustomerPriceMapper.java | 14 ++ .../modules/goods/mapper/GoodsSkuMapper.java | 5 + .../service/GoodsCustomerPriceService.java | 20 +++ .../impl/GoodsCustomerPriceServiceImpl.java | 79 ++++++++++ .../service/impl/TbsCostApplyServiceImpl.java | 5 - 8 files changed, 410 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/qs/serve/modules/goods/controller/GoodsCustomerPriceController.java create mode 100644 src/main/java/com/qs/serve/modules/goods/entity/GoodsCustomerPrice.java create mode 100644 src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceBo.java create mode 100644 src/main/java/com/qs/serve/modules/goods/mapper/GoodsCustomerPriceMapper.java create mode 100644 src/main/java/com/qs/serve/modules/goods/service/GoodsCustomerPriceService.java create mode 100644 src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java 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 new file mode 100644 index 00000000..f8c35053 --- /dev/null +++ b/src/main/java/com/qs/serve/modules/goods/controller/GoodsCustomerPriceController.java @@ -0,0 +1,103 @@ +package com.qs.serve.modules.goods.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.qs.serve.common.model.annotation.SysLog; +import com.qs.serve.common.model.dto.PageVo; +import com.qs.serve.common.model.dto.R; +import com.qs.serve.common.model.enums.BizType; +import com.qs.serve.common.model.enums.SystemModule; +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 lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import com.qs.serve.modules.goods.entity.GoodsCustomerPrice; +import com.qs.serve.modules.goods.service.GoodsCustomerPriceService; + +import javax.validation.Valid; +import java.util.List; + +/** + * 商品 客户价格关系表 + * @author YenHex + * @since 2024-01-08 + */ +@Slf4j +@AllArgsConstructor +@RestController +@RequestMapping("goods/customerPrice") +public class GoodsCustomerPriceController { + + private GoodsCustomerPriceService goodsCustomerPriceService; + + /** + * 列表 + * @param param + * @return + */ + @GetMapping("/list") + public R> getList(GoodsCustomerPrice param){ + if(param.getSupplierId()==null){ + return R.error("请选择客户"); + } + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(param); + List list = goodsCustomerPriceService.list(lqw); + return R.ok(list); + } + + /** + * 翻页 + * @param param + * @return + */ + @GetMapping("/page") + public R> getPage(GoodsCustomerPrice param){ + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(param); + PageUtil.startPage(); + List list = goodsCustomerPriceService.list(lqw); + return R.byPageHelperList(list); + } + + /** + * ID查询 + * @param id + * @return + */ + //@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("/saveBatch") + @SysLog(module = SystemModule.GOODS, title = "批量保存", biz = BizType.INSERT) + public R saveBatch(@RequestBody @Valid GoodsCustomerPriceBo param){ + goodsCustomerPriceService.saveBatch(param); + return R.ok(); + } + + /** + * 删除 + * @param ids + * @return + */ + @DeleteMapping("/deleteById/{ids}") + @SysLog(module = SystemModule.GOODS, title = "客户价格关系表", biz = BizType.DELETE) + public R deleteById(@PathVariable("ids") String ids){ + List idsLong = StringUtils.splitIdLong(ids); + boolean result = goodsCustomerPriceService.removeByIds(idsLong); + return R.isTrue(result); + } + +} + 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 new file mode 100644 index 00000000..795a9201 --- /dev/null +++ b/src/main/java/com/qs/serve/modules/goods/entity/GoodsCustomerPrice.java @@ -0,0 +1,143 @@ +package com.qs.serve.modules.goods.entity; + +import java.time.LocalDate; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotBlank; + +/** + * 客户价格关系表 实体类 + * @author YenHex + * @since 2024-01-08 + */ +@Data +@TableName("goods_customer_price") +public class GoodsCustomerPrice implements Serializable { + + private static final long serialVersionUID = 1L; + + /** */ + @TableId(type = IdType.AUTO) + private Long id; + + /** 客户ID */ + private String supplierId; + + /** 客户编号 */ + @NotNull(message = "客户编号不能为空") + @TableField(condition = SqlCondition.LIKE) + private String supplierCode; + + /** 客户名称(冗余) */ + @Length(max = 50,message = "客户名称(冗余)长度不能超过50字") + @TableField(condition = SqlCondition.LIKE) + private String supplierName; + + /** 存货编码 */ + @NotNull(message = "存货编码不能为空") + private String skuId; + + /** 存货编码 */ + @NotNull(message = "存货编码不能为空") + @TableField(condition = SqlCondition.LIKE) + private String skuCode; + + /** 存货名称(冗余) */ + @Length(max = 255,message = "存货名称(冗余)长度不能超过255字") + @TableField(condition = SqlCondition.LIKE) + private String skuName; + + /** 计量单位 */ + @Length(max = 50,message = "计量单位长度不能超过50字") + private String skuUnit; + + /** 初始价格 */ + private BigDecimal initPrice; + + /** 真实价格 */ + @NotNull(message = "真实价格不能为空") + private BigDecimal realPrice; + + /** 定价人 */ + @Length(max = 50,message = "定价人长度不能超过50字") + @TableField(condition = SqlCondition.LIKE) + private String maker; + + /** 定价人编号 */ + @Length(max = 50,message = "定价人编号长度不能超过50字") + @TableField(condition = SqlCondition.LIKE) + private String makerCode; + + /** 定价时间 */ + @Length(max = 0,message = "定价时间长度不能超过0字") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime markTime; + + /** 创建时间 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + @TableField(fill = FieldFill.INSERT) + private LocalDateTime createTime; + + /** 创建人 */ + @TableField(fill = FieldFill.INSERT) + private String createBy; + + /** 更新时间 */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + @TableField(fill = FieldFill.UPDATE) + private LocalDateTime updateTime; + + /** 更新人 */ + @TableField(fill = FieldFill.UPDATE) + private String updateBy; + + /** 租户id */ + @JsonIgnore + @JsonProperty + private String tenantId; + + /** 删除标识 */ + @JsonIgnore + @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/GoodsCustomerPriceBo.java b/src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceBo.java new file mode 100644 index 00000000..be1c65fd --- /dev/null +++ b/src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCustomerPriceBo.java @@ -0,0 +1,46 @@ +package com.qs.serve.modules.goods.entity.bo; + +import java.time.LocalDate; +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import org.hibernate.validator.constraints.Length; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.NotBlank; + +/** + * 客户价格关系表 Bo + * @author YenHex + * @since 2024-01-08 + */ +@Data +public class GoodsCustomerPriceBo implements Serializable { + + private static final long serialVersionUID = 1L; + + /** 客户ID */ + private String supplierId; + + private List skuPriceItemList; + + @Data + public static class SkuPriceItem{ + + /** sku编码 */ + private String skuCode; + + /** 客户价格 */ + private BigDecimal price; + + } + +} + diff --git a/src/main/java/com/qs/serve/modules/goods/mapper/GoodsCustomerPriceMapper.java b/src/main/java/com/qs/serve/modules/goods/mapper/GoodsCustomerPriceMapper.java new file mode 100644 index 00000000..46bff20e --- /dev/null +++ b/src/main/java/com/qs/serve/modules/goods/mapper/GoodsCustomerPriceMapper.java @@ -0,0 +1,14 @@ +package com.qs.serve.modules.goods.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.qs.serve.modules.goods.entity.GoodsCustomerPrice; + +/** + * 客户价格关系表 Mapper + * @author YenHex + * @date 2024-01-08 + */ +public interface GoodsCustomerPriceMapper extends BaseMapper { + +} + diff --git a/src/main/java/com/qs/serve/modules/goods/mapper/GoodsSkuMapper.java b/src/main/java/com/qs/serve/modules/goods/mapper/GoodsSkuMapper.java index 10c514e0..31b3e4f1 100644 --- a/src/main/java/com/qs/serve/modules/goods/mapper/GoodsSkuMapper.java +++ b/src/main/java/com/qs/serve/modules/goods/mapper/GoodsSkuMapper.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.qs.serve.modules.goods.entity.GoodsSku; import com.qs.serve.modules.goods.entity.vo.GoodSkuVo; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import java.util.List; @@ -29,5 +30,9 @@ public interface GoodsSkuMapper extends BaseMapper { @InterceptorIgnore(tenantLine = "1") List selectByCategoryIds(@Param("categoryIds")List categoryIds,@Param("tenantId")String tenantId); + + @Select("select * from goods_sku where sku_code = #{skuCode} and del_flag = 0 limit 1 ") + GoodsSku selectBySkuCode(@Param("skuCode")String skuCode); + } 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 new file mode 100644 index 00000000..a900aba9 --- /dev/null +++ b/src/main/java/com/qs/serve/modules/goods/service/GoodsCustomerPriceService.java @@ -0,0 +1,20 @@ +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; + +/** + * 客户价格关系表 服务接口 + * @author YenHex + * @date 2024-01-08 + */ +public interface GoodsCustomerPriceService extends IService { + + + void saveBatch(GoodsCustomerPriceBo 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 new file mode 100644 index 00000000..5e28cd1a --- /dev/null +++ b/src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCustomerPriceServiceImpl.java @@ -0,0 +1,79 @@ +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.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.mapper.GoodsSkuMapper; +import com.qs.serve.modules.sys.entity.SysUser; +import com.qs.serve.modules.sys.mapper.SysUserMapper; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import com.qs.serve.modules.goods.entity.GoodsCustomerPrice; +import com.qs.serve.modules.goods.service.GoodsCustomerPriceService; +import com.qs.serve.modules.goods.mapper.GoodsCustomerPriceMapper; + +import java.time.LocalDateTime; + +/** + * 客户价格关系表 服务实现类 + * @author YenHex + * @since 2024-01-08 + */ +@Slf4j +@Service +@AllArgsConstructor +public class GoodsCustomerPriceServiceImpl extends ServiceImpl implements GoodsCustomerPriceService { + + private final BmsSupplierMapper bmsSupplierMapper; + private final GoodsSkuMapper goodsSkuMapper; + private final SysUserMapper sysUserMapper; + + @Override + public void saveBatch(GoodsCustomerPriceBo param) { + BmsSupplier supplier = bmsSupplierMapper.selectById(param.getSupplierId()); + SysUser sysUser = sysUserMapper.selectById(AuthContextUtils.getSysUserId()); + LocalDateTime nowTime = LocalDateTime.now(); + 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); + }else { + customerPrice.setRealPrice(item.getPrice()); + customerPrice.setMaker(sysUser.getName()); + customerPrice.setMakerCode(sysUser.getCode()); + customerPrice.setMarkTime(nowTime); + this.updateById(customerPrice); + } + } + } + + @Override + public GoodsCustomerPrice getBySupplierIdAndCode(String supplierId, String skuCode) { + LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); + lqw.eq(GoodsCustomerPrice::getSupplierId,supplierId) + .eq(GoodsCustomerPrice::getSkuCode,skuCode); + return this.getOne(lqw,false); + } +} + diff --git a/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java b/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java index 3dd6fb9b..77270fae 100644 --- a/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java +++ b/src/main/java/com/qs/serve/modules/tbs/service/impl/TbsCostApplyServiceImpl.java @@ -178,11 +178,6 @@ public class TbsCostApplyServiceImpl extends ServiceImpl rmLogLqw = new LambdaQueryWrapper<>(); rmLogLqw.eq(TbsBudgetLog::getCostApplyId,id); budgetLogService.remove(rmLogLqw); - //删除BIR -// LambdaQueryWrapper birActivityCenterGoodsLqw = new LambdaQueryWrapper<>(); -// birActivityCenterGoodsLqw.eq(BirActivityCenterGoods::getCostApplyId,id); -// birActivityCenterGoodsMapper.delete(birActivityCenterGoodsLqw); - //命中预算 budgetCostItemService.removeByCostApplyId(id);