Browse Source

调整

mssql
Yen 3 years ago
parent
commit
d392e7b4cd
  1. 13
      src/main/java/com/qs/serve/common/framework/exception/UnifiedExceptionHandler.java
  2. 18
      src/main/java/com/qs/serve/modules/base/controller/JslApiController.java
  3. 103
      src/main/java/com/qs/serve/modules/bms/controller/BmsChannelController.java
  4. 119
      src/main/java/com/qs/serve/modules/bms/controller/BmsChannelPointController.java
  5. 4
      src/main/java/com/qs/serve/modules/bms/controller/BmsFactoryController.java
  6. 113
      src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierChannelController.java
  7. 33
      src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierController.java
  8. 72
      src/main/java/com/qs/serve/modules/bms/entity/BmsChannel.java
  9. 80
      src/main/java/com/qs/serve/modules/bms/entity/BmsChannelPoint.java
  10. 83
      src/main/java/com/qs/serve/modules/bms/entity/BmsSupplierChannel.java
  11. 12
      src/main/java/com/qs/serve/modules/bms/entity/vo/BmsSupplierTreeVo.java
  12. 14
      src/main/java/com/qs/serve/modules/bms/mapper/BmsChannelMapper.java
  13. 14
      src/main/java/com/qs/serve/modules/bms/mapper/BmsChannelPointMapper.java
  14. 17
      src/main/java/com/qs/serve/modules/bms/mapper/BmsSupplierChannelMapper.java
  15. 14
      src/main/java/com/qs/serve/modules/bms/service/BmsChannelPointService.java
  16. 14
      src/main/java/com/qs/serve/modules/bms/service/BmsChannelService.java
  17. 19
      src/main/java/com/qs/serve/modules/bms/service/BmsSupplierChannelService.java
  18. 22
      src/main/java/com/qs/serve/modules/bms/service/impl/BmsChannelPointServiceImpl.java
  19. 22
      src/main/java/com/qs/serve/modules/bms/service/impl/BmsChannelServiceImpl.java
  20. 28
      src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierChannelServiceImpl.java
  21. 1
      src/main/java/com/qs/serve/modules/goods/common/GoodsConst.java
  22. 52
      src/main/java/com/qs/serve/modules/goods/controller/GoodsCategoryController.java
  23. 38
      src/main/java/com/qs/serve/modules/goods/controller/GoodsSkuController.java
  24. 5
      src/main/java/com/qs/serve/modules/goods/controller/GoodsSpecValueController.java
  25. 27
      src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java
  26. 9
      src/main/java/com/qs/serve/modules/goods/entity/GoodsCategory.java
  27. 2
      src/main/java/com/qs/serve/modules/goods/entity/GoodsSku.java
  28. 1
      src/main/java/com/qs/serve/modules/goods/entity/GoodsSpecValue.java
  29. 15
      src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java
  30. 36
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCategoryBo.java
  31. 33
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCategoryLevelBo.java
  32. 2
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCategoryTreeVo.java
  33. 3
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsSkuBo.java
  34. 63
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsSpuBo.java
  35. 6
      src/main/java/com/qs/serve/modules/goods/entity/vo/GoodSkuVo.java
  36. 5
      src/main/java/com/qs/serve/modules/goods/service/GoodsCategoryService.java
  37. 3
      src/main/java/com/qs/serve/modules/goods/service/GoodsSpuService.java
  38. 77
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCategoryServiceImpl.java
  39. 2
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsSkuServiceImpl.java
  40. 16
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsSpuServiceImpl.java
  41. 61
      src/main/resources/mapper/bms/BmsSupplierChannelMapper.xml
  42. 10
      src/main/resources/mapper/bms/BmsSupplierMapper.xml
  43. 85
      src/main/resources/mapper/bms/GoodsSpuMapper.xml

13
src/main/java/com/qs/serve/common/framework/exception/UnifiedExceptionHandler.java

@ -83,17 +83,22 @@ public class UnifiedExceptionHandler {
return R.error();
}
@ExceptionHandler(value = DuplicateKeyException.class)
@ResponseBody
public R handleDuplicateKeyException(DuplicateKeyException e) {
e.printStackTrace();
return R.error("限制重复数据,请联系管理员");
}
@ExceptionHandler({
DuplicateKeyException.class,
SQLIntegrityConstraintViolationException.class,
})
@ResponseBody
public R handleSqlIntegrityException(Exception e) {
String msg = e.getMessage();
e.printStackTrace();
String[] tmps = msg.split("\\n");
String msg2 = tmps.length>1?tmps[1]:null;
return new R(500,"数据库拦截"+(msg2==null?"":" : "+msg2));
return new R(500,"数据库拦截,请联系管理员");
}
/**

18
src/main/java/com/qs/serve/modules/base/controller/JslApiController.java

@ -9,9 +9,12 @@ import com.qs.serve.common.model.enums.BizType;
import com.qs.serve.common.model.enums.SystemModule;
import com.qs.serve.common.util.AuthContextUtils;
import com.qs.serve.common.util.CopierUtil;
import com.qs.serve.common.util.ValidateTools;
import com.qs.serve.modules.bms.entity.bo.BmsSupplierBatchBo;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.bms.service.BmsSupplierService;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBatchTasteBo;
import com.qs.serve.modules.goods.service.GoodsSpuService;
import com.qs.serve.modules.sys.entity.SysUser;
import com.qs.serve.modules.sys.entity.bo.SysUserBatchBo;
import com.qs.serve.modules.sys.entity.bo.SysUserBo;
@ -44,6 +47,7 @@ public class JslApiController {
private SysRoleService sysRoleService;
private BmsSupplierService bmsSupplierService;
private SysUserSalesService sysUserSalesService;
private GoodsSpuService goodsSpuService;
/**
* 客户档案
@ -101,4 +105,18 @@ public class JslApiController {
return R.ok();
}
/**
* (批量)编辑口味品类SPU,建议每次小于50条
* @param param
* @return
*/
@PostMapping("/saveBatchTasteSpu")
@SysLog(module = SystemModule.GOODS, title = "spu", biz = BizType.INSERT)
@PreAuthorize("hasRole('goods:spu:insert')")
public R<?> saveBatchTasteSpu(@RequestBody GoodsSpuBatchTasteBo param){
ValidateTools.valid(param.getTasteProducts());
return R.ok(goodsSpuService.saveBatchTasteSpu(param));
}
}

103
src/main/java/com/qs/serve/modules/bms/controller/BmsChannelController.java

@ -0,0 +1,103 @@
package com.qs.serve.modules.bms.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 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.bms.entity.BmsChannel;
import com.qs.serve.modules.bms.service.BmsChannelService;
import javax.validation.Valid;
import java.util.List;
/**
* 基础档案 渠道
* @author YenHex
* @since 2022-11-03
*/
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("bms/channel")
public class BmsChannelController {
private BmsChannelService bmsChannelService;
/**
* 翻页
* @param param
* @return
*/
@GetMapping("/page")
@PreAuthorize("hasRole('bms:channel:query')")
public R<PageVo<BmsChannel>> getPage(BmsChannel param){
PageUtil.startPage();
LambdaQueryWrapper<BmsChannel> channelWrapper = new LambdaQueryWrapper<>(param);
List<BmsChannel> list = bmsChannelService.list(channelWrapper);
return R.byPageHelperList(list);
}
/**
* ID查询
* @param id
* @return
*/
@GetMapping("/getById/{id}")
@SysLog(module = SystemModule.BASE, title = "渠道", biz = BizType.QUERY)
@PreAuthorize("hasRole('bms:channel:query')")
public R<BmsChannel> getById(@PathVariable("id") String id){
BmsChannel bmsChannel = bmsChannelService.getById(id);
return R.ok(bmsChannel);
}
/**
* 更新
* @param param
* @return
*/
@PostMapping("/updateById")
@SysLog(module = SystemModule.BASE, title = "渠道", biz = BizType.UPDATE)
@PreAuthorize("hasRole('bms:channel:update')")
public R<?> updateById(@RequestBody @Valid BmsChannel param){
boolean result = bmsChannelService.updateById(param);
return R.isTrue(result);
}
/**
* 新增
* @param param
* @return
*/
@PostMapping("/save")
@SysLog(module = SystemModule.BASE, title = "渠道", biz = BizType.INSERT)
@PreAuthorize("hasRole('bms:channel:insert')")
public R<?> save(@RequestBody @Valid BmsChannel param){
boolean result = bmsChannelService.save(param);
return R.isTrue(result);
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/deleteById/{id}")
@SysLog(module = SystemModule.BASE, title = "渠道", biz = BizType.DELETE)
@PreAuthorize("hasRole('bms:channel:delete')")
public R<?> deleteById(@PathVariable("id") Long id){
boolean result = bmsChannelService.removeById(id);
return R.isTrue(result);
}
}

119
src/main/java/com/qs/serve/modules/bms/controller/BmsChannelPointController.java

@ -0,0 +1,119 @@
package com.qs.serve.modules.bms.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.modules.bms.entity.BmsChannel;
import com.qs.serve.modules.bms.service.BmsChannelService;
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.bms.entity.BmsChannelPoint;
import com.qs.serve.modules.bms.service.BmsChannelPointService;
import javax.validation.Valid;
import java.util.List;
import java.util.stream.Collectors;
/**
* 基础档案 渠道站点
* @author YenHex
* @since 2022-11-03
*/
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("bms/channelPoint")
public class BmsChannelPointController {
private BmsChannelPointService bmsChannelPointService;
private BmsChannelService bmsChannelService;
/**
* 翻页
* @param param
* @return
*/
@GetMapping("/page")
@PreAuthorize("hasRole('bms:channelPoint:query')")
public R<PageVo<BmsChannelPoint>> getPage(BmsChannelPoint param){
PageUtil.startPage();
LambdaQueryWrapper<BmsChannelPoint> channelPointWrapper = new LambdaQueryWrapper<>(param);
List<BmsChannelPoint> list = bmsChannelPointService.list(channelPointWrapper);
if(list.size()>0){
List<Long> channelIds = list.stream().map(BmsChannelPoint::getChannelId).distinct().collect(Collectors.toList());
List<BmsChannel> channels = bmsChannelService.listByIds(channelIds);
for (BmsChannelPoint channelPoint : list) {
for (BmsChannel channel : channels) {
if(channelPoint.getChannelId().equals(channel.getId())){
channelPoint.setChannelName(channel.getChannelName());
break;
}
}
}
}
return R.byPageHelperList(list);
}
/**
* ID查询
* @param id
* @return
*/
@GetMapping("/getById/{id}")
@SysLog(module = SystemModule.BASE, title = "渠道站点", biz = BizType.QUERY)
@PreAuthorize("hasRole('bms:channelPoint:query')")
public R<BmsChannelPoint> getById(@PathVariable("id") String id){
BmsChannelPoint bmsChannelPoint = bmsChannelPointService.getById(id);
BmsChannel channel = bmsChannelService.getById(bmsChannelPoint.getChannelId());
bmsChannelPoint.setChannelName(channel.getChannelName());
return R.ok(bmsChannelPoint);
}
/**
* 更新
* @param param
* @return
*/
@PostMapping("/updateById")
@SysLog(module = SystemModule.BASE, title = "渠道站点", biz = BizType.UPDATE)
@PreAuthorize("hasRole('bms:channelPoint:update')")
public R<?> updateById(@RequestBody @Valid BmsChannelPoint param){
boolean result = bmsChannelPointService.updateById(param);
return R.isTrue(result);
}
/**
* 新增
* @param param
* @return
*/
@PostMapping("/save")
@SysLog(module = SystemModule.BASE, title = "渠道站点", biz = BizType.INSERT)
@PreAuthorize("hasRole('bms:channelPoint:insert')")
public R<?> save(@RequestBody @Valid BmsChannelPoint param){
boolean result = bmsChannelPointService.save(param);
return R.isTrue(result);
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/deleteById/{id}")
@SysLog(module = SystemModule.BASE, title = "渠道站点", biz = BizType.DELETE)
@PreAuthorize("hasRole('bms:channelPoint:delete')")
public R<?> deleteById(@PathVariable("id") Long id){
boolean result = bmsChannelPointService.removeById(id);
return R.isTrue(result);
}
}

4
src/main/java/com/qs/serve/modules/bms/controller/BmsFactoryController.java

@ -7,6 +7,7 @@ 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.modules.goods.service.GoodsSpecValueService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
@ -30,6 +31,7 @@ import java.util.List;
public class BmsFactoryController {
private BmsFactoryService bmsFactoryService;
private GoodsSpecValueService goodsSpecValueService;
/**
* 翻页
@ -67,6 +69,8 @@ public class BmsFactoryController {
@SysLog(module = SystemModule.BASE, title = "工厂产地", biz = BizType.UPDATE)
@PreAuthorize("hasRole('bms:factory:update')")
public R<?> updateById(@RequestBody @Valid BmsFactory param){
param.setCode(null);
param.setName(null);
boolean result = bmsFactoryService.updateById(param);
return R.isTrue(result);
}

113
src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierChannelController.java

@ -0,0 +1,113 @@
package com.qs.serve.modules.bms.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.modules.bms.entity.BmsChannel;
import com.qs.serve.modules.bms.entity.BmsSupplier;
import com.qs.serve.modules.bms.service.BmsChannelService;
import com.qs.serve.modules.bms.service.BmsSupplierService;
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.bms.entity.BmsSupplierChannel;
import com.qs.serve.modules.bms.service.BmsSupplierChannelService;
import javax.validation.Valid;
import java.util.List;
/**
* 基础档案 客户渠道关系
* @author YenHex
* @since 2022-11-03
*/
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("bms/supplierChannel")
public class BmsSupplierChannelController {
private BmsSupplierChannelService bmsSupplierChannelService;
private BmsChannelService bmsChannelService;
private BmsSupplierService bmsSupplierService;
/**
* 翻页
* @param param
* @return
*/
@GetMapping("/page")
@PreAuthorize("hasRole('bms:supplierChannel:query')")
public R<PageVo<BmsSupplierChannel>> getPage(BmsSupplierChannel param){
PageUtil.startPage();
List<BmsSupplierChannel> list = bmsSupplierChannelService.selectSupplierChannelList(param);
return R.byPageHelperList(list);
}
/**
* ID查询
* @param id
* @return
*/
@GetMapping("/getById/{id}")
@SysLog(module = SystemModule.BASE, title = "客户渠道关系", biz = BizType.QUERY)
@PreAuthorize("hasRole('bms:supplierChannel:query')")
public R<BmsSupplierChannel> getById(@PathVariable("id") String id){
BmsSupplierChannel bmsSupplierChannel = bmsSupplierChannelService.getById(id);
BmsChannel channel = bmsChannelService.getById(bmsSupplierChannel.getChannelId());
bmsSupplierChannel.setChannelName(channel.getChannelName());
BmsSupplier supplier = bmsSupplierService.getById(bmsSupplierChannel.getSupplierId().toString());
bmsSupplierChannel.setSupplierCode(supplier.getCode());
bmsSupplierChannel.setSupplierName(supplier.getName());
return R.ok(bmsSupplierChannel);
}
/**
* 更新
* @param param
* @return
*/
@PostMapping("/updateById")
@SysLog(module = SystemModule.BASE, title = "客户渠道关系", biz = BizType.UPDATE)
@PreAuthorize("hasRole('bms:supplierChannel:update')")
public R<?> updateById(@RequestBody @Valid BmsSupplierChannel param){
boolean result = bmsSupplierChannelService.updateById(param);
return R.isTrue(result);
}
/**
* 新增
* @param param
* @return
*/
@PostMapping("/save")
@SysLog(module = SystemModule.BASE, title = "客户渠道关系", biz = BizType.INSERT)
@PreAuthorize("hasRole('bms:supplierChannel:insert')")
public R<?> save(@RequestBody @Valid BmsSupplierChannel param){
boolean result = bmsSupplierChannelService.save(param);
return R.isTrue(result);
}
/**
* 删除
* @param id
* @return
*/
@DeleteMapping("/deleteById/{id}")
@SysLog(module = SystemModule.BASE, title = "客户渠道关系", biz = BizType.DELETE)
@PreAuthorize("hasRole('bms:supplierChannel:delete')")
public R<?> deleteById(@PathVariable("id") Long id){
boolean result = bmsSupplierChannelService.removeById(id);
return R.isTrue(result);
}
}

33
src/main/java/com/qs/serve/modules/bms/controller/BmsSupplierController.java

@ -19,7 +19,6 @@ import com.qs.serve.modules.sys.entity.SysUser;
import com.qs.serve.modules.sys.entity.bo.SysRelateSuppliersParam;
import com.qs.serve.modules.sys.entity.bo.SysRelateSuppliersParam2;
import com.qs.serve.modules.sys.entity.dto.SysUserSimpleVo;
import com.qs.serve.modules.sys.entity.dto.SysUserVo;
import com.qs.serve.modules.sys.service.SysUserService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -83,11 +82,11 @@ public class BmsSupplierController {
@PreAuthorize("hasRole('bms:supplier:query')")
public R<PageVo<BmsSupplier>> getPage(BmsSupplier param){
PageUtil.startPage();
LambdaQueryWrapper<BmsSupplier> supplierWrapper = new LambdaQueryWrapper<>(param);
if(CollectionUtil.isNotEmpty(param.getRegionIds())){
supplierWrapper.in(BmsSupplier::getRegionLast,param.getRegionIds());
}
List<BmsSupplier> list = bmsSupplierService.list(supplierWrapper);
// LambdaQueryWrapper<BmsSupplier> supplierWrapper = new LambdaQueryWrapper<>(param);
// if(CollectionUtil.isNotEmpty(param.getRegionIds())){
// supplierWrapper.in(BmsSupplier::getRegionLast,param.getRegionIds());
// }
List<BmsSupplier> list = bmsSupplierService.selectSupplierList(param);
initSupplierList(list);
initParentList(list);
return R.byPageHelperList(list);
@ -101,28 +100,8 @@ public class BmsSupplierController {
@GetMapping("/tree")
@PreAuthorize("hasRole('bms:supplier:query')")
public R<List<BmsSupplierTreeVo>> getTree(BmsSupplier param){
LambdaQueryWrapper<BmsSupplier> supplierWrapper = new LambdaQueryWrapper<>(param);
if(CollectionUtil.isNotEmpty(param.getRegionIds())){
supplierWrapper.in(BmsSupplier::getRegionLast,param.getRegionIds());
}
List<BmsSupplier> list = bmsSupplierService.list(supplierWrapper);
List<BmsSupplier> list = bmsSupplierService.selectSupplierList(param);
initSupplierList(list);
for (BmsSupplier supplier : list) {
String regionId = supplier.getRegionLast();
if(regionId!=null&&!regionId.equals("0")){
BmsRegion bmsRegion2 = bmsRegionService.getById(regionId);
if(bmsRegion2!=null){
supplier.setRegionLabel(bmsRegion2.getName());
}
}
String region2Id = supplier.getRegion2Last();
if(region2Id!=null&&!region2Id.equals("0")){
BmsRegion2 bmsRegion2 = bmsRegion2Service.getById(regionId);
if(bmsRegion2!=null){
supplier.setRegion2Label(bmsRegion2.getName());
}
}
}
List<BmsSupplierTreeVo> list2 = list.stream().map(supplier->{
BmsSupplierTreeVo treeNode = CopierUtil.copy(supplier,new BmsSupplierTreeVo());
treeNode.setId(supplier.getId());

72
src/main/java/com/qs/serve/modules/bms/entity/BmsChannel.java

@ -0,0 +1,72 @@
package com.qs.serve.modules.bms.entity;
import java.time.LocalDateTime;
import java.io.Serializable;
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 2022-11-03
*/
@Data
@TableName("bms_channel")
public class BmsChannel implements Serializable {
private static final long serialVersionUID = 1L;
/** id */
@TableId(type = IdType.AUTO)
private Long id;
/** 渠道名称 */
@NotBlank(message = "渠道名称不能为空")
@Length(max = 30,message = "渠道名称长度不能超过30字")
private String channelName;
/** 备注 */
@Length(max = 255,message = "备注长度不能超过255字")
private String remark;
/** 创建时间 */
@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;
/** 最后更新时间 */
@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;
/** 所属租户 */
@JsonIgnore
@JsonProperty
private String tenantId;
/** 逻辑删除标记(0:显示;1:隐藏) */
@JsonIgnore
@JsonProperty
private String delFlag;
/** 创建人 */
@TableField(fill = FieldFill.INSERT)
private String createBy;
/** 更新人 */
@TableField(fill = FieldFill.UPDATE)
private String updateBy;
}

80
src/main/java/com/qs/serve/modules/bms/entity/BmsChannelPoint.java

@ -0,0 +1,80 @@
package com.qs.serve.modules.bms.entity;
import java.time.LocalDateTime;
import java.io.Serializable;
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 2022-11-03
*/
@Data
@TableName("bms_channel_point")
public class BmsChannelPoint implements Serializable {
private static final long serialVersionUID = 1L;
/** id */
@TableId(type = IdType.AUTO)
private Long id;
/** 渠道名称 */
@NotNull(message = "渠道名称不能为空")
private Long channelId;
/** 站点名称 */
@NotBlank(message = "站点名称不能为空")
@Length(max = 30,message = "站点名称长度不能超过30字")
private String pointName;
/** 备注 */
@Length(max = 255,message = "备注长度不能超过255字")
private String remark;
/** 创建时间 */
@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;
/** 最后更新时间 */
@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;
/** 所属租户 */
@JsonIgnore
@JsonProperty
private String tenantId;
/** 逻辑删除标记(0:显示;1:隐藏) */
@JsonIgnore
@JsonProperty
private String delFlag;
/** 创建人 */
@TableField(fill = FieldFill.INSERT)
private String createBy;
/** 更新人 */
@TableField(fill = FieldFill.UPDATE)
private String updateBy;
/** 渠道名称 */
@TableField(exist = false)
private String channelName;
}

83
src/main/java/com/qs/serve/modules/bms/entity/BmsSupplierChannel.java

@ -0,0 +1,83 @@
package com.qs.serve.modules.bms.entity;
import java.time.LocalDateTime;
import java.io.Serializable;
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 2022-11-03
*/
@Data
@TableName("bms_supplier_channel")
public class BmsSupplierChannel implements Serializable {
private static final long serialVersionUID = 1L;
/** id */
@TableId(type = IdType.AUTO)
private Long id;
/** 渠道id */
@NotNull(message = "渠道id不能为空")
private Long channelId;
/** 客户id */
@NotNull(message = "客户id不能为空")
private Long supplierId;
/** 创建时间 */
@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;
/** 最后更新时间 */
@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;
/** 所属租户 */
@JsonIgnore
@JsonProperty
private String tenantId;
/** 逻辑删除标记(0:显示;1:隐藏) */
@JsonIgnore
@JsonProperty
private String delFlag;
/** 创建人 */
@TableField(fill = FieldFill.INSERT)
private String createBy;
/** 更新人 */
@TableField(fill = FieldFill.UPDATE)
private String updateBy;
/** 渠道名称 */
@TableField(exist = false)
private String channelName;
/** 客户名称 */
@TableField(exist = false)
private String supplierName;
/** 客户编码 */
@TableField(exist = false)
private String supplierCode;
}

12
src/main/java/com/qs/serve/modules/bms/entity/vo/BmsSupplierTreeVo.java

@ -65,6 +65,18 @@ public class BmsSupplierTreeVo extends TreeNode {
@NotBlank(message = "客户编码不能为空")
private String belong;
/** 行政一级区域ID */
private String region2First;
/** 行政二级区域ID */
private String region2Second;
/** 行政三级区域ID */
private String region2Third;
/** 行政最子级区域ID */
private String region2Last;
/** 行政标题 */
private String region2Label;
}

14
src/main/java/com/qs/serve/modules/bms/mapper/BmsChannelMapper.java

@ -0,0 +1,14 @@
package com.qs.serve.modules.bms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.modules.bms.entity.BmsChannel;
/**
* 渠道 Mapper
* @author YenHex
* @date 2022-11-03
*/
public interface BmsChannelMapper extends BaseMapper<BmsChannel> {
}

14
src/main/java/com/qs/serve/modules/bms/mapper/BmsChannelPointMapper.java

@ -0,0 +1,14 @@
package com.qs.serve.modules.bms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.modules.bms.entity.BmsChannelPoint;
/**
* 渠道站点 Mapper
* @author YenHex
* @date 2022-11-03
*/
public interface BmsChannelPointMapper extends BaseMapper<BmsChannelPoint> {
}

17
src/main/java/com/qs/serve/modules/bms/mapper/BmsSupplierChannelMapper.java

@ -0,0 +1,17 @@
package com.qs.serve.modules.bms.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.modules.bms.entity.BmsSupplierChannel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 客户渠道关系 Mapper
* @author YenHex
* @date 2022-11-03
*/
public interface BmsSupplierChannelMapper extends BaseMapper<BmsSupplierChannel> {
List<BmsSupplierChannel> selectSupplierChannelList(@Param("query") BmsSupplierChannel supplierChannel);
}

14
src/main/java/com/qs/serve/modules/bms/service/BmsChannelPointService.java

@ -0,0 +1,14 @@
package com.qs.serve.modules.bms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.bms.entity.BmsChannelPoint;
/**
* 渠道站点 服务接口
* @author YenHex
* @date 2022-11-03
*/
public interface BmsChannelPointService extends IService<BmsChannelPoint> {
}

14
src/main/java/com/qs/serve/modules/bms/service/BmsChannelService.java

@ -0,0 +1,14 @@
package com.qs.serve.modules.bms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.bms.entity.BmsChannel;
/**
* 渠道 服务接口
* @author YenHex
* @date 2022-11-03
*/
public interface BmsChannelService extends IService<BmsChannel> {
}

19
src/main/java/com/qs/serve/modules/bms/service/BmsSupplierChannelService.java

@ -0,0 +1,19 @@
package com.qs.serve.modules.bms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.bms.entity.BmsSupplierChannel;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 客户渠道关系 服务接口
* @author YenHex
* @date 2022-11-03
*/
public interface BmsSupplierChannelService extends IService<BmsSupplierChannel> {
List<BmsSupplierChannel> selectSupplierChannelList(BmsSupplierChannel supplierChannel);
}

22
src/main/java/com/qs/serve/modules/bms/service/impl/BmsChannelPointServiceImpl.java

@ -0,0 +1,22 @@
package com.qs.serve.modules.bms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.qs.serve.modules.bms.entity.BmsChannelPoint;
import com.qs.serve.modules.bms.service.BmsChannelPointService;
import com.qs.serve.modules.bms.mapper.BmsChannelPointMapper;
/**
* 渠道站点 服务实现类
* @author YenHex
* @since 2022-11-03
*/
@Slf4j
@Service
@AllArgsConstructor
public class BmsChannelPointServiceImpl extends ServiceImpl<BmsChannelPointMapper,BmsChannelPoint> implements BmsChannelPointService {
}

22
src/main/java/com/qs/serve/modules/bms/service/impl/BmsChannelServiceImpl.java

@ -0,0 +1,22 @@
package com.qs.serve.modules.bms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.qs.serve.modules.bms.entity.BmsChannel;
import com.qs.serve.modules.bms.service.BmsChannelService;
import com.qs.serve.modules.bms.mapper.BmsChannelMapper;
/**
* 渠道 服务实现类
* @author YenHex
* @since 2022-11-03
*/
@Slf4j
@Service
@AllArgsConstructor
public class BmsChannelServiceImpl extends ServiceImpl<BmsChannelMapper,BmsChannel> implements BmsChannelService {
}

28
src/main/java/com/qs/serve/modules/bms/service/impl/BmsSupplierChannelServiceImpl.java

@ -0,0 +1,28 @@
package com.qs.serve.modules.bms.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import com.qs.serve.modules.bms.entity.BmsSupplierChannel;
import com.qs.serve.modules.bms.service.BmsSupplierChannelService;
import com.qs.serve.modules.bms.mapper.BmsSupplierChannelMapper;
import java.util.List;
/**
* 客户渠道关系 服务实现类
* @author YenHex
* @since 2022-11-03
*/
@Slf4j
@Service
@AllArgsConstructor
public class BmsSupplierChannelServiceImpl extends ServiceImpl<BmsSupplierChannelMapper,BmsSupplierChannel> implements BmsSupplierChannelService {
@Override
public List<BmsSupplierChannel> selectSupplierChannelList(BmsSupplierChannel supplierChannel) {
return baseMapper.selectSupplierChannelList(supplierChannel);
}
}

1
src/main/java/com/qs/serve/modules/goods/common/GoodsConst.java

@ -10,5 +10,6 @@ public class GoodsConst {
* 规格数量
*/
public static final Integer SPEC_COUNT = 3;
public static final Integer CATE_MAX_LEVEL = 3;
}

52
src/main/java/com/qs/serve/modules/goods/controller/GoodsCategoryController.java

@ -9,6 +9,8 @@ import com.qs.serve.common.model.enums.SystemModule;
import com.qs.serve.common.util.CopierUtil;
import com.qs.serve.common.util.PageUtil;
import com.qs.serve.common.util.TreeUtil;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryBo;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryLevelBo;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryTreeVo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -36,28 +38,31 @@ public class GoodsCategoryController {
private GoodsCategoryService goodsCategoryService;
/**
*列表
* 翻页查询
* @param param
* @return
*/
@GetMapping("/list")
public R<List<GoodsCategory>> getList(GoodsCategory param){
@GetMapping("/page")
@PreAuthorize("hasRole('goods:category:query')")
public R<PageVo<GoodsCategory>> getPage(GoodsCategory param){
PageUtil.startPage();
LambdaQueryWrapper<GoodsCategory> categoryWrapper = new LambdaQueryWrapper<>(param);
List<GoodsCategory> list = goodsCategoryService.list(categoryWrapper);
return R.ok(list);
return R.byPageHelperList(list);
}
/**
* 翻页查询
* 查询
* @param param
* @return
*/
@GetMapping("/page")
public R<PageVo<GoodsCategory>> getPage(GoodsCategory param){
@GetMapping("/list")
@PreAuthorize("hasRole('goods:category:query')")
public R<List<GoodsCategory>> getList(GoodsCategory param){
PageUtil.startPage();
LambdaQueryWrapper<GoodsCategory> categoryWrapper = new LambdaQueryWrapper<>(param);
List<GoodsCategory> list = goodsCategoryService.list(categoryWrapper);
return R.byPageHelperList(list);
return R.ok(list);
}
/**
@ -91,22 +96,37 @@ public class GoodsCategoryController {
@PreAuthorize("hasRole('goods:category:query')")
public R<GoodsCategory> getById(@PathVariable("id") String id){
GoodsCategory goodsCategory = goodsCategoryService.getById(id);
if(!goodsCategory.getParentId().equals(0L)){
goodsCategory.setParentInfo(goodsCategoryService.getById(goodsCategory.getParentId()));
}
return R.ok(goodsCategory);
}
/**
* 根据ID更新
* 根据ID更新基本信息
* @param param
* @return
*/
@PostMapping("/updateById")
@SysLog(module = SystemModule.GOODS, title = "分类", biz = BizType.UPDATE)
@PreAuthorize("hasRole('goods:category:update')")
public R<?> updateById(@RequestBody @Valid GoodsCategory param){
boolean result = goodsCategoryService.updateById(param);
return R.isTrue(result);
public R<?> updateById(@RequestBody @Valid GoodsCategoryBo param){
GoodsCategory category = CopierUtil.copy(param,new GoodsCategory());
goodsCategoryService.updateById(category);
return R.ok();
}
/**
* 迁移leve
* @param param
* @return
*/
@PostMapping("/updateLevel")
@SysLog(module = SystemModule.GOODS, title = "分类", biz = BizType.UPDATE)
@PreAuthorize("hasRole('goods:category:update')")
public R<?> updateById(@RequestBody @Valid GoodsCategoryLevelBo param){
goodsCategoryService.modifyLevel(param);
return R.ok();
}
/**
@ -118,8 +138,8 @@ public class GoodsCategoryController {
@SysLog(module = SystemModule.GOODS, title = "分类", biz = BizType.INSERT)
@PreAuthorize("hasRole('goods:category:insert')")
public R<?> save(@RequestBody @Valid GoodsCategory param){
boolean result = goodsCategoryService.save(param);
return R.isTrue(result);
goodsCategoryService.add(param);
return R.ok();
}
/**

38
src/main/java/com/qs/serve/modules/goods/controller/GoodsSkuController.java

@ -10,6 +10,7 @@ import com.qs.serve.common.util.PageUtil;
import com.qs.serve.modules.goods.entity.GoodsSkuSpecValue;
import com.qs.serve.modules.goods.entity.bo.GoodsSkuBo;
import com.qs.serve.modules.goods.entity.vo.GoodSkuVo;
import com.qs.serve.modules.goods.entity.vo.GoodsSkuSpecValueVo;
import com.qs.serve.modules.goods.service.GoodsSkuSpecValueService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -37,20 +38,7 @@ public class GoodsSkuController {
private GoodsSkuSpecValueService goodsSkuSpecValueService;
/**
* 翻页
* @param param
* @return
*/
//@GetMapping("/page")
@PreAuthorize("hasRole('goods:sku:query')")
public R<PageVo<GoodSkuVo>> getPage(GoodsSku param){
PageUtil.startPage();
List<GoodSkuVo> list = goodsSkuService.selectSkuVo(param);
return R.byPageHelperList(list);
}
/**
* 列表
* 列表(传入spuId获取spu规格列表)
* @param param
* @return
*/
@ -58,6 +46,10 @@ public class GoodsSkuController {
@PreAuthorize("hasRole('goods:sku:query')")
public R<List<GoodSkuVo>> getList(GoodsSku param){
List<GoodSkuVo> list = goodsSkuService.selectSkuVo(param);
for (GoodSkuVo goodSkuVo : list) {
List<GoodsSkuSpecValueVo> skuSpecValueVos = goodsSkuSpecValueService.listSpecValueBySkuId(goodSkuVo.getId());
goodSkuVo.setSpecValueList(skuSpecValueVos);
}
return R.ok(list);
}
@ -82,7 +74,23 @@ public class GoodsSkuController {
@PostMapping("/update")
@SysLog(module = SystemModule.GOODS, title = "sku", biz = BizType.UPDATE)
@PreAuthorize("hasRole('goods:sku:update')")
public R<?> update(@RequestBody @Valid GoodsSkuBo param){
public R<?> update(@RequestBody GoodsSkuBo param){
if(param.getSkuId()==null){
return R.error();
}
goodsSkuService.editSku(param);
return R.ok();
}
/**
* 编辑
* @param param
* @return
*/
@PostMapping("/save")
@SysLog(module = SystemModule.GOODS, title = "sku", biz = BizType.UPDATE)
@PreAuthorize("hasRole('goods:sku:update')")
public R<?> save(@RequestBody GoodsSkuBo param){
goodsSkuService.editSku(param);
return R.ok();
}

5
src/main/java/com/qs/serve/modules/goods/controller/GoodsSpecValueController.java

@ -101,8 +101,6 @@ public class GoodsSpecValueController {
return R.ok(goodsSpecValue);
}
/**
* 规格值 ID更新
* @param param
@ -125,6 +123,9 @@ public class GoodsSpecValueController {
@SysLog(module = SystemModule.GOODS, title = "规格值", biz = BizType.INSERT)
@PreAuthorize("hasRole('goods:specValue:insert')")
public R<?> save(@RequestBody @Valid GoodsSpecValue param){
if(param.getSpecId().equals(3L)){
return R.error("产地规格不支持新增");
}
boolean result = goodsSpecValueService.save(param);
return R.isTrue(result);
}

27
src/main/java/com/qs/serve/modules/goods/controller/GoodsSpuController.java

@ -12,6 +12,7 @@ import com.qs.serve.modules.goods.entity.GoodsSku;
import com.qs.serve.modules.goods.entity.GoodsSkuSpecValue;
import com.qs.serve.modules.goods.entity.GoodsSpuSpec;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBatchTasteBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuEditBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuTasteBo;
import com.qs.serve.modules.goods.entity.vo.GoodsSpuVo;
@ -77,7 +78,7 @@ public class GoodsSpuController {
* @param param
* @return
*/
@PostMapping("/edit")
//@PostMapping("/edit")
@SysLog(module = SystemModule.GOODS, title = "spu", biz = BizType.UPDATE)
@PreAuthorize("hasRole('goods:spu:update')")
public R<?> updateById(@RequestBody @Valid GoodsSpuEditBo param){
@ -114,29 +115,35 @@ public class GoodsSpuController {
}
/**
* 编辑口味品类SPU
* 保存 口味品类SPU
* @param param
* @return
*/
@PostMapping("/saveTasteSpu")
@SysLog(module = SystemModule.GOODS, title = "spu", biz = BizType.INSERT)
@PreAuthorize("hasRole('goods:spu:insert')")
public R<?> saveBatchTasteSpu(@RequestBody GoodsSpuTasteBo param){
return R.ok(goodsSpuService.editTasteBo(param));
public R<?> saveTasteSpu(@RequestBody @Valid GoodsSpuBo param){
param.setId(null);
goodsSpuService.editTasteSpu(param);
return R.ok();
}
/**
* (批量)编辑口味品类SPU,建议每次小于50条
* 编辑 口味品类SPU
* @param param
* @return
*/
@PostMapping("/saveBatchTasteSpu")
@PostMapping("/updTasteSpu")
@SysLog(module = SystemModule.GOODS, title = "spu", biz = BizType.INSERT)
@PreAuthorize("hasRole('goods:spu:insert')")
public R<?> saveBatchTasteSpu(@RequestBody GoodsSpuBatchTasteBo param){
ValidateTools.valid(param.getTasteProducts());
return R.ok(goodsSpuService.saveBatchTasteSpu(param));
@PreAuthorize("hasRole('goods:spu:update')")
public R<?> updTasteSpu(@RequestBody @Valid GoodsSpuBo param){
if(param.getId()==null){
return R.error();
}
goodsSpuService.editTasteSpu(param);
return R.ok();
}
}

9
src/main/java/com/qs/serve/modules/goods/entity/GoodsCategory.java

@ -42,6 +42,12 @@ public class GoodsCategory implements Serializable {
@Length(max = 16,message = "名称长度不能超过16字")
private String name;
/** 排序 */
private Integer level;
/** 排序 */
private String levelPath;
/** 描述 */
@Length(max = 255,message = "描述长度不能超过255字")
private String description;
@ -83,5 +89,8 @@ public class GoodsCategory implements Serializable {
@TableField(fill = FieldFill.UPDATE)
private String updateBy;
@TableField(exist = false)
private Object parentInfo;
}

2
src/main/java/com/qs/serve/modules/goods/entity/GoodsSku.java

@ -117,7 +117,7 @@ public class GoodsSku implements Serializable {
@TableField(exist = false)
private List<Long> selectSkuIds;
/** 是否上架(1是 0否) */
/** 查询:是否上架(1是 0否) */
@TableField(exist = false)
private Integer querySpuShelf;
}

1
src/main/java/com/qs/serve/modules/goods/entity/GoodsSpecValue.java

@ -68,5 +68,6 @@ public class GoodsSpecValue implements Serializable {
@TableField(exist = false)
private String specName;
}

15
src/main/java/com/qs/serve/modules/goods/entity/GoodsSpu.java

@ -74,9 +74,6 @@ public class GoodsSpu implements Serializable {
/** 销量 */
private Integer saleNum;
/** 0统一规格;1多规格 */
@Length(max = 2,message = "0统一规格;1多规格长度不能超过2字")
private String specType;
/** 产品口味(非sku规格值) */
private String tasteValue;
@ -109,5 +106,17 @@ public class GoodsSpu implements Serializable {
@JsonProperty
private String delFlag;
/** 一级类目:品牌名称 */
@TableField(exist = false)
private String cateFirstLabel;
/** 二级类目:类目名称 */
@TableField(exist = false)
private String cateSecondLabel;
/** 三级类目:系列名称 */
@TableField(exist = false)
private String cateThirdLabel;
}

36
src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCategoryBo.java

@ -0,0 +1,36 @@
package com.qs.serve.modules.goods.entity.bo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
/**
* @author YenHex
* @since 2022/11/3
*/
@Data
public class GoodsCategoryBo {
/** PK */
@TableId(type = IdType.AUTO)
private Long id;
/** 名称 */
@Length(max = 16,message = "名称长度不能超过16字")
private String name;
/** 描述 */
@Length(max = 255,message = "描述长度不能超过255字")
private String description;
/** 图片 */
@Length(max = 255,message = "图片长度不能超过255字")
private String picUrl;
/** 排序 */
private Integer sort;
}

33
src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCategoryLevelBo.java

@ -0,0 +1,33 @@
package com.qs.serve.modules.goods.entity.bo;
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.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 分类 实体类
* @author YenHex
* @since 2022-10-09
*/
@Data
public class GoodsCategoryLevelBo implements Serializable {
private static final long serialVersionUID = 1L;
/** PK */
@TableId(type = IdType.AUTO)
private Long id;
/** 父分类编号 */
private Long parentId;
}

2
src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCategoryTreeVo.java

@ -46,4 +46,6 @@ public class GoodsCategoryTreeVo extends TreeNode {
/** 排序 */
private Integer sort;
/** 等级 */
private Integer level;
}

3
src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsSkuBo.java

@ -25,8 +25,9 @@ public class GoodsSkuBo implements Serializable {
private static final long serialVersionUID = 1L;
private Long skuId;
/** sku编码 */
@Length(max = 32,message = "sku编码长度不能超过32字")
private String skuCode;
/** 商品Id */

63
src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsSpuBo.java

@ -0,0 +1,63 @@
package com.qs.serve.modules.goods.entity.bo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.qs.serve.common.framework.mybatis.handler.meta.SplitStringTypeHandler;
import lombok.Data;
import org.apache.ibatis.type.JdbcType;
import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
/**
* 口味品类
* @author YenHex
* @since 2022/10/10
*/
@Data
public class GoodsSpuBo {
/** PK */
@TableId(type = IdType.AUTO)
private Long id;
/** 商品编码 */
private String spuCode;
/** 商品名字 */
private String name;
/** 品牌id */
private Long brandId;
/** 系列id */
private Long seriesId;
/** 最后一级分类 */
private String categoryId;
/** 商品图片 */
@TableField(typeHandler = SplitStringTypeHandler.class,jdbcType= JdbcType.VARCHAR)
private String[] picUrls;
/** 是否上架(1是 0否) */
//private Integer shelf;
/** 排序字段 */
@NotNull(message = "排序字段不能为空")
private Integer sort;
/** 销量 */
//private Integer saleNum;
/** 0统一规格;1多规格 */
//@Length(max = 2,message = "0统一规格;1多规格长度不能超过2字")
//private String specType;
/** 产品口味(非sku规格值) */
private String tasteValue;
}

6
src/main/java/com/qs/serve/modules/goods/entity/vo/GoodSkuVo.java

@ -1,8 +1,11 @@
package com.qs.serve.modules.goods.entity.vo;
import com.qs.serve.modules.goods.entity.GoodsSku;
import com.qs.serve.modules.goods.entity.GoodsSpecValue;
import lombok.Data;
import java.util.List;
/**
* @author YenHex
* @since 2022/10/20
@ -19,4 +22,7 @@ public class GoodSkuVo extends GoodsSku {
/** 是否上架(1是 0否) */
private Integer shelf;
/** 规格值信息 */
private List<GoodsSkuSpecValueVo> specValueList;
}

5
src/main/java/com/qs/serve/modules/goods/service/GoodsCategoryService.java

@ -2,6 +2,7 @@ package com.qs.serve.modules.goods.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.goods.entity.GoodsCategory;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryLevelBo;
/**
* 分类 服务接口
@ -12,5 +13,9 @@ public interface GoodsCategoryService extends IService<GoodsCategory> {
GoodsCategory getByCode(String code);
void add(GoodsCategory category);
void modifyLevel(GoodsCategoryLevelBo category);
}

3
src/main/java/com/qs/serve/modules/goods/service/GoodsSpuService.java

@ -3,6 +3,7 @@ package com.qs.serve.modules.goods.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.goods.entity.GoodsSpu;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBatchTasteBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuEditBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuTasteBo;
import com.qs.serve.modules.goods.entity.vo.GoodSkuBatchResult;
@ -25,6 +26,8 @@ public interface GoodsSpuService extends IService<GoodsSpu> {
void edit(GoodsSpuEditBo spuEditBo);
void editTasteSpu(GoodsSpuBo param);
GoodSkuBatchResult editTasteBo(GoodsSpuTasteBo tasteProduct);
}

77
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsCategoryServiceImpl.java

@ -2,6 +2,12 @@ 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.CollectionUtil;
import com.qs.serve.common.util.CopierUtil;
import com.qs.serve.modules.goods.common.GoodsConst;
import com.qs.serve.modules.goods.entity.GoodsSpu;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryLevelBo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -9,6 +15,9 @@ import com.qs.serve.modules.goods.entity.GoodsCategory;
import com.qs.serve.modules.goods.service.GoodsCategoryService;
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper;
import java.util.ArrayList;
import java.util.List;
/**
* 分类 服务实现类
* @author YenHex
@ -26,5 +35,73 @@ public class GoodsCategoryServiceImpl extends ServiceImpl<GoodsCategoryMapper,Go
return this.getOne(lqw,false);
}
@Override
public void add(GoodsCategory category) {
category.setId(null);
if(category.getParentId()==null||category.getParentId().equals(0L)){
category.setLevel(1);
this.save(category);
category.setLevelPath(category.getId().toString());
this.updateById(category);
}else {
GoodsCategory parent = this.getById(category.getParentId());
this.updateLevel(parent,category);
}
}
@Override
public void modifyLevel(GoodsCategoryLevelBo categoryLevelBo) {
GoodsCategory category = CopierUtil.copy(categoryLevelBo,new GoodsCategory());
if(category.getParentId()!=null){
GoodsCategory dbCategory = this.getById(category.getId());
if(!dbCategory.getParentId().equals(category.getParentId())){
//只能同级迁移
GoodsCategory parent = this.getById(category.getParentId());
GoodsCategory oldParent = this.getById(dbCategory.getParentId());
if(!parent.getLevel().equals(oldParent.getLevel())){
Assert.throwEx("只能同级迁移");
}
this.updateLevel(parent,category);
if(parent.getLevel()==1){
//更新子类目
LambdaQueryWrapper<GoodsCategory> lqw = new LambdaQueryWrapper<>();
lqw.eq(GoodsCategory::getParentId,category.getId());
List<GoodsCategory> childCategories = this.list(lqw);
for (GoodsCategory childCategory : childCategories) {
childCategory.setLevelPath(category.getLevelPath()+"_"+childCategory.getId());
}
if(CollectionUtil.isNotEmpty(childCategories)){
this.updateBatchById(childCategories);
}
}
//更新商品树
updateSpuCategory(category,parent,oldParent);
}
}
}
/**
* todo 更新商品树
* @param category
* @param parent
* @param oldParent
*/
private void updateSpuCategory(GoodsCategory category,GoodsCategory parent,GoodsCategory oldParent){
if(parent.getLevel()==2){
}
}
private void updateLevel(GoodsCategory parent,GoodsCategory category){
if(parent.getLevel()>= GoodsConst.CATE_MAX_LEVEL){
Assert.throwEx("最高支持3级类目");
}
category.setLevel(parent.getLevel()+1);
this.save(category);
category.setLevelPath(parent.getLevelPath()+"_"+category.getId().toString());
this.updateById(category);
}
}

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

@ -58,7 +58,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper,GoodsSku> im
@Override
@Transactional(rollbackFor = Exception.class)
public void editSku(GoodsSkuBo goodSkuVo) {
GoodsSku dbGoodSku = this.getByCode(goodSkuVo.getSkuCode());
GoodsSku dbGoodSku = this.getById(goodSkuVo.getSkuId());
GoodsSku goodsSku = CopierUtil.copy(goodSkuVo,new GoodsSku());
if(dbGoodSku!=null){
if(goodsSku.getSpuId()!=null&&goodsSku.getSpuId().equals(dbGoodSku.getSpuId())){

16
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsSpuServiceImpl.java

@ -8,6 +8,7 @@ import com.qs.serve.modules.bms.entity.BmsFactory;
import com.qs.serve.modules.bms.service.BmsFactoryService;
import com.qs.serve.modules.goods.entity.*;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBatchTasteBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuEditBo;
import com.qs.serve.modules.goods.entity.bo.GoodsSpuTasteBo;
import com.qs.serve.modules.goods.entity.vo.*;
@ -98,7 +99,17 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im
}
}
@Override
public void editTasteSpu(GoodsSpuBo param) {
GoodsSpu spu = CopierUtil.copy(param,new GoodsSpu());
if(param.getId()!=null){
spu.setSpuCode(null);
}
GoodsCategory category = goodsCategoryService.getById(param.getCategoryId());
relateCate(spu,category);
this.saveOrUpdate(spu);
insertSpuSpec(spu.getId());
}
@Override
public List<GoodSkuBatchResult> saveBatchTasteSpu(GoodsSpuBatchTasteBo batchTasteBo) {
@ -149,7 +160,6 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im
if(goodsSeries!=null){
spu.setSeriesId(goodsSeries.getId());
}
spu.setSpecType("1");
spu.setTasteValue(tasteProduct.getProductTasteValue());
if(spu.getId()==null){
this.save(spu);
@ -254,7 +264,7 @@ public class GoodsSpuServiceImpl extends ServiceImpl<GoodsSpuMapper,GoodsSpu> im
spuSpec3.setSpecId(3L);
spuSpec3.setSort(1);
spuSpecList.add(spuSpec3);
goodsSpuSpecService.saveBatch(spuSpecList);
goodsSpuSpecService.saveOrUpdateBatch(spuSpecList);
}
}

61
src/main/resources/mapper/bms/BmsSupplierChannelMapper.xml

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qs.serve.modules.bms.mapper.BmsSupplierChannelMapper">
<resultMap id="bmsSupplierChannelMap" type="com.qs.serve.modules.bms.entity.BmsSupplierChannel" >
<result property="id" column="id"/>
<result property="channelId" column="channel_id"/>
<result property="supplierId" column="supplier_id"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="tenantId" column="tenant_id"/>
<result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="channelName" column="channel_name"/>
<result property="supplierName" column="supplier_name"/>
<result property="supplierCode" column="supplier_code"/>
</resultMap>
<sql id="bmsSupplierChannelSql">
bms_supplier_channel.`id`,
bms_supplier_channel.`channel_id`,
bms_supplier_channel.`supplier_id`,
bms_supplier_channel.`create_time`,
bms_supplier_channel.`update_time`,
bms_supplier_channel.`tenant_id`,
bms_supplier_channel.`del_flag`,
bms_supplier_channel.`create_by`,
bms_supplier_channel.`update_by` </sql>
<select id="selectSupplierChannelList" parameterType="com.qs.serve.modules.bms.entity.BmsSupplierChannel" resultMap="bmsSupplierChannelMap">
SELECT
`bms_channel`.`channel_name`,
`bms_supplier`.`name` as `supplier_name`,
`bms_supplier`.`code` as `supplier_code`,
<include refid="bmsSupplierChannelSql"/>
FROM `bms_supplier_channel` `bms_supplier_channel`
LEFT JOIN `bms_channel` ON `bms_supplier_channel`.`channel_id` = `bms_channel`.`id`
LEFT JOIN `bms_supplier` ON `bms_supplier_channel`.`supplier_id` = `bms_supplier`.id
<where>
<if test="query.id != null"> and `bms_supplier_channel`.`id` = #{query.id}</if>
<if test="query.channelId != null"> and `bms_supplier_channel`.`channel_id` = #{query.channelId}</if>
<if test="query.supplierId != null"> and `bms_supplier_channel`.`supplier_id` = #{query.supplierId}</if>
<if test="query.createTime != null"> and `bms_supplier_channel`.`create_time` = #{query.createTime}</if>
<if test="query.updateTime != null"> and `bms_supplier_channel`.`update_time` = #{query.updateTime}</if>
<if test="query.tenantId != null and query.tenantId != ''"> and `bms_supplier_channel`.`tenant_id` = #{query.tenantId}</if>
<if test="query.delFlag != null and query.delFlag != ''"> and `bms_supplier_channel`.`del_flag` = #{query.delFlag}</if>
<if test="query.createBy != null and query.createBy != ''"> and `bms_supplier_channel`.`create_by` = #{query.createBy}</if>
<if test="query.updateBy != null and query.updateBy != ''"> and `bms_supplier_channel`.`update_by` = #{query.updateBy}</if>
<if test="query.channelName != null and query.channelName != ''"> and `bms_channel`.`channel_name` LIKE CONCAT('%',#{query.channelName},'%') </if>
<if test="query.supplierName != null and query.supplierName != ''"> and `bms_supplier`.`name` LIKE CONCAT('%',#{query.supplierName},'%') </if>
<if test="query.supplierCode != null and query.supplierCode != ''"> and `bms_supplier`.`code` LIKE CONCAT('%',#{query.supplierCode},'%')</if>
</where>
</select>
</mapper>

10
src/main/resources/mapper/bms/BmsSupplierMapper.xml

@ -11,6 +11,11 @@
<result property="regionFirst" column="region_first"/>
<result property="regionSecond" column="region_second"/>
<result property="regionThird" column="region_third"/>
<result property="regionLast" column="region_last"/>
<result property="region2First" column="region2_first"/>
<result property="region2Second" column="region2_second"/>
<result property="region2Third" column="region2_third"/>
<result property="region2Last" column="region2_last"/>
<result property="address" column="address"/>
<result property="name" column="name"/>
<result property="code" column="code"/>
@ -38,6 +43,11 @@
bms_supplier.`region_first`,
bms_supplier.`region_second`,
bms_supplier.`region_third`,
bms_supplier.`region_last`,
bms_supplier.`region2_first`,
bms_supplier.`region2_second`,
bms_supplier.`region2_third`,
bms_supplier.`region2_last`,
bms_supplier.`address`,
bms_supplier.`name`,
bms_supplier.`code`,

85
src/main/resources/mapper/bms/GoodsSpuMapper.xml

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qs.serve.modules.goods.mapper.GoodsSpuMapper">
<resultMap id="goodsSpuMap" type="com.qs.serve.modules.goods.entity.GoodsSpu" >
<result property="id" column="id"/>
<result property="spuCode" column="spu_code"/>
<result property="name" column="name"/>
<result property="brandId" column="brand_id"/>
<result property="seriesId" column="series_id"/>
<result property="categoryFirst" column="category_first"/>
<result property="categorySecond" column="category_second"/>
<result property="categoryThird" column="category_third"/>
<result property="categoryLast" column="category_last"/>
<result property="picUrls" column="pic_urls" typeHandler="com.qs.serve.common.framework.mybatis.handler.meta.SplitStringTypeHandler" />
<result property="shelf" column="shelf"/>
<result property="sort" column="sort"/>
<result property="saleNum" column="sale_num"/>
<result property="tasteValue" column="taste_value"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="tenantId" column="tenant_id"/>
<result property="delFlag" column="del_flag"/>
</resultMap>
<sql id="goodsSpuSql">
goods_spu.`id`,
goods_spu.`spu_code`,
goods_spu.`name`,
goods_spu.`brand_id`,
goods_spu.`series_id`,
goods_spu.`category_first`,
goods_spu.`category_second`,
goods_spu.`category_third`,
goods_spu.`category_last`,
goods_spu.`pic_urls`,
goods_spu.`shelf`,
goods_spu.`sort`,
goods_spu.`sale_num`,
goods_spu.`spec_type`,
goods_spu.`taste_value`,
goods_spu.`create_time`,
goods_spu.`update_time`,
goods_spu.`create_by`,
goods_spu.`update_by`,
goods_spu.`tenant_id`,
goods_spu.`del_flag` </sql>
<select id="selectGoodsSpuList" parameterType="com.qs.serve.modules.goods.entity.GoodsSpu" resultMap="goodsSpuMap">
SELECT
`goods_brand`.`name` AS `brand_name`,
`goods_series`.`name` AS `series_name`,
<include refid="goodsSpuSql"/>
FROM `goods_spu` `goods_spu`
<where>
<if test="query.id != null"> and `goods_spu`.`id` = #{query.id}</if>
<if test="query.spuCode != null and query.spuCode != ''"> and `goods_spu`.`spu_code` = #{query.spuCode}</if>
<if test="query.name != null and query.name != ''"> and `goods_spu`.`name` = #{query.name}</if>
<if test="query.brandId != null"> and `goods_spu`.`brand_id` = #{query.brandId}</if>
<if test="query.seriesId != null"> and `goods_spu`.`series_id` = #{query.seriesId}</if>
<if test="query.categoryFirst != null"> and `goods_spu`.`category_first` = #{query.categoryFirst}</if>
<if test="query.categorySecond != null"> and `goods_spu`.`category_second` = #{query.categorySecond}</if>
<if test="query.categoryThird != null"> and `goods_spu`.`category_third` = #{query.categoryThird}</if>
<if test="query.categoryLast != null"> and `goods_spu`.`category_last` = #{query.categoryLast}</if>
<if test="query.shelf != null and query.shelf != ''"> and `goods_spu`.`shelf` = #{query.shelf}</if>
<if test="query.sort != null"> and `goods_spu`.`sort` = #{query.sort}</if>
<if test="query.saleNum != null"> and `goods_spu`.`sale_num` = #{query.saleNum}</if>
<if test="query.specType != null and query.specType != ''"> and `goods_spu`.`spec_type` = #{query.specType}</if>
<if test="query.tasteValue != null and query.tasteValue != ''"> and `goods_spu`.`taste_value` = #{query.tasteValue}</if>
<if test="query.createTime != null"> and `goods_spu`.`create_time` = #{query.createTime}</if>
<if test="query.updateTime != null"> and `goods_spu`.`update_time` = #{query.updateTime}</if>
<if test="query.createBy != null and query.createBy != ''"> and `goods_spu`.`create_by` = #{query.createBy}</if>
<if test="query.updateBy != null and query.updateBy != ''"> and `goods_spu`.`update_by` = #{query.updateBy}</if>
<if test="query.tenantId != null and query.tenantId != ''"> and `goods_spu`.`tenant_id` = #{query.tenantId}</if>
<if test="query.delFlag != null and query.delFlag != ''"> and `goods_spu`.`del_flag` = #{query.delFlag}</if>
</where>
</select>
</mapper>
Loading…
Cancel
Save