39 changed files with 820 additions and 354 deletions
@ -0,0 +1,101 @@ |
|||||
|
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.BmsFactory; |
||||
|
import com.qs.serve.modules.bms.service.BmsFactoryService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 基础档案 工厂产地 |
||||
|
* @author YenHex |
||||
|
* @since 2022-10-20 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("bms/factory") |
||||
|
public class BmsFactoryController { |
||||
|
|
||||
|
private BmsFactoryService bmsFactoryService; |
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
@PreAuthorize("hasRole('bms:factory:query')") |
||||
|
public R<PageVo<BmsFactory>> getPage(BmsFactory param){ |
||||
|
PageUtil.startPage(); |
||||
|
LambdaQueryWrapper<BmsFactory> factoryWrapper = new LambdaQueryWrapper<>(param); |
||||
|
List<BmsFactory> list = bmsFactoryService.list(factoryWrapper); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById/{id}") |
||||
|
@SysLog(module = SystemModule.BASE, title = "工厂产地", biz = BizType.QUERY) |
||||
|
@PreAuthorize("hasRole('bms:factory:query')") |
||||
|
public R<BmsFactory> getById(@PathVariable("id") String id){ |
||||
|
BmsFactory bmsFactory = bmsFactoryService.getById(id); |
||||
|
return R.ok(bmsFactory); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 更新 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/updateById") |
||||
|
@SysLog(module = SystemModule.BASE, title = "工厂产地", biz = BizType.UPDATE) |
||||
|
@PreAuthorize("hasRole('bms:factory:update')") |
||||
|
public R<?> updateById(@RequestBody @Valid BmsFactory param){ |
||||
|
boolean result = bmsFactoryService.updateById(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/save") |
||||
|
@SysLog(module = SystemModule.BASE, title = "工厂产地", biz = BizType.INSERT) |
||||
|
@PreAuthorize("hasRole('bms:factory:insert')") |
||||
|
public R<?> save(@RequestBody @Valid BmsFactory param){ |
||||
|
boolean result = bmsFactoryService.save(param); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/deleteById/{id}") |
||||
|
@SysLog(module = SystemModule.BASE, title = "工厂产地", biz = BizType.DELETE) |
||||
|
@PreAuthorize("hasRole('bms:factory:delete')") |
||||
|
public R<?> deleteById(@PathVariable("id") Long id){ |
||||
|
boolean result = bmsFactoryService.removeById(id); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,76 @@ |
|||||
|
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-10-20 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("bms_factory") |
||||
|
public class BmsFactory implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
private String id; |
||||
|
|
||||
|
/** 名称 */ |
||||
|
@NotBlank(message = "名称不能为空") |
||||
|
@Length(max = 20,message = "名称长度不能超过20字") |
||||
|
private String name; |
||||
|
|
||||
|
/** 编码 */ |
||||
|
@NotBlank(message = "编码不能为空") |
||||
|
@Length(max = 20,message = "编码长度不能超过20字") |
||||
|
private String code; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@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; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@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; |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,79 @@ |
|||||
|
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; |
||||
|
|
||||
|
/** |
||||
|
* 规则sku 实体类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-10-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("bms_rule_sku") |
||||
|
public class BmsRuleSku implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 规则id */ |
||||
|
@NotNull(message = "规则id不能为空") |
||||
|
private Long ruleId; |
||||
|
|
||||
|
/** skuId */ |
||||
|
@NotNull(message = "skuId不能为空") |
||||
|
private Long skuId; |
||||
|
|
||||
|
/** spuId */ |
||||
|
@NotNull(message = "spuId不能为空") |
||||
|
private Long spuId; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@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; |
||||
|
|
||||
|
/** 创建人 */ |
||||
|
@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; |
||||
|
|
||||
|
} |
||||
|
|
@ -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.BmsFactory; |
||||
|
|
||||
|
/** |
||||
|
* 工厂产地 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-20 |
||||
|
*/ |
||||
|
public interface BmsFactoryMapper extends BaseMapper<BmsFactory> { |
||||
|
|
||||
|
} |
||||
|
|
@ -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.BmsRuleRegion; |
||||
|
|
||||
|
/** |
||||
|
* 规则区域 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-21 |
||||
|
*/ |
||||
|
public interface BmsRuleRegionMapper extends BaseMapper<BmsRuleRegion> { |
||||
|
|
||||
|
} |
||||
|
|
@ -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.BmsRuleSku; |
||||
|
|
||||
|
/** |
||||
|
* 规则sku Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-21 |
||||
|
*/ |
||||
|
public interface BmsRuleSkuMapper extends BaseMapper<BmsRuleSku> { |
||||
|
|
||||
|
} |
||||
|
|
@ -1,27 +0,0 @@ |
|||||
package com.qs.serve.modules.bms.mapper; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore; |
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
||||
import com.qs.serve.modules.bms.entity.BmsSkuRegion; |
|
||||
import org.apache.ibatis.annotations.Param; |
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* 禁销区域 Mapper |
|
||||
* @author YenHex |
|
||||
* @date 2022-10-18 |
|
||||
*/ |
|
||||
public interface BmsSkuRegionMapper extends BaseMapper<BmsSkuRegion> { |
|
||||
|
|
||||
/** |
|
||||
* 查询 |
|
||||
* @param skuRegion |
|
||||
* @return |
|
||||
*/ |
|
||||
@InterceptorIgnore(tenantLine = "1") |
|
||||
List<BmsSkuRegion> listSkuRegions(@Param("query") BmsSkuRegion skuRegion); |
|
||||
|
|
||||
} |
|
||||
|
|
@ -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.BmsFactory; |
||||
|
|
||||
|
/** |
||||
|
* 工厂产地 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-20 |
||||
|
*/ |
||||
|
public interface BmsFactoryService extends IService<BmsFactory> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,21 @@ |
|||||
|
package com.qs.serve.modules.bms.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRuleRegion; |
||||
|
|
||||
|
/** |
||||
|
* 规则区域 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-21 |
||||
|
*/ |
||||
|
public interface BmsRuleRegionService extends IService<BmsRuleRegion> { |
||||
|
|
||||
|
/** |
||||
|
* 通过区域id删除 |
||||
|
* @param regionId |
||||
|
* @return |
||||
|
*/ |
||||
|
boolean removeByRegionId(Long regionId); |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,18 @@ |
|||||
|
package com.qs.serve.modules.bms.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRuleSku; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 规则sku 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-21 |
||||
|
*/ |
||||
|
public interface BmsRuleSkuService extends IService<BmsRuleSku> { |
||||
|
|
||||
|
List<BmsRuleSku> listSkuIdsByRuleId(Long ruleId); |
||||
|
|
||||
|
} |
||||
|
|
@ -1,46 +0,0 @@ |
|||||
package com.qs.serve.modules.bms.service; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
|
||||
import com.qs.serve.modules.bms.entity.BmsSkuRegion; |
|
||||
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|
||||
import com.qs.serve.modules.bms.entity.bo.BmsRuleBo; |
|
||||
import org.apache.ibatis.annotations.Param; |
|
||||
|
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* 禁销区域 服务接口 |
|
||||
* @author YenHex |
|
||||
* @date 2022-10-18 |
|
||||
*/ |
|
||||
public interface BmsSkuRegionService extends IService<BmsSkuRegion> { |
|
||||
|
|
||||
/** |
|
||||
* 编辑 |
|
||||
* @param ruleId |
|
||||
* @param skuRegionBo |
|
||||
*/ |
|
||||
void edit(Long ruleId,BmsRuleBo skuRegionBo); |
|
||||
|
|
||||
|
|
||||
/** |
|
||||
* 查询 |
|
||||
* @param skuRegion |
|
||||
* @return |
|
||||
*/ |
|
||||
List<BmsSkuRegion> listSkuRegions(BmsSkuRegion skuRegion); |
|
||||
|
|
||||
/** |
|
||||
* 检查规则 |
|
||||
* @param skuIds |
|
||||
* @param supplier |
|
||||
* @return |
|
||||
*/ |
|
||||
int checkSkuRule(List<Long> skuIds, BmsSupplier supplier); |
|
||||
|
|
||||
boolean removeByRegionId(Long regionId); |
|
||||
|
|
||||
} |
|
||||
|
|
@ -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.BmsFactory; |
||||
|
import com.qs.serve.modules.bms.service.BmsFactoryService; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsFactoryMapper; |
||||
|
|
||||
|
/** |
||||
|
* 工厂产地 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-10-20 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BmsFactoryServiceImpl extends ServiceImpl<BmsFactoryMapper,BmsFactory> implements BmsFactoryService { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,30 @@ |
|||||
|
package com.qs.serve.modules.bms.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
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.BmsRuleRegion; |
||||
|
import com.qs.serve.modules.bms.service.BmsRuleRegionService; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRuleRegionMapper; |
||||
|
|
||||
|
/** |
||||
|
* 规则区域 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-10-21 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BmsRuleRegionServiceImpl extends ServiceImpl<BmsRuleRegionMapper,BmsRuleRegion> implements BmsRuleRegionService { |
||||
|
|
||||
|
@Override |
||||
|
public boolean removeByRegionId(Long regionId) { |
||||
|
LambdaQueryWrapper<BmsRuleRegion> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(BmsRuleRegion::getRegionId,regionId); |
||||
|
return this.remove(lqw); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,32 @@ |
|||||
|
package com.qs.serve.modules.bms.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
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.BmsRuleSku; |
||||
|
import com.qs.serve.modules.bms.service.BmsRuleSkuService; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRuleSkuMapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 规则sku 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-10-21 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BmsRuleSkuServiceImpl extends ServiceImpl<BmsRuleSkuMapper,BmsRuleSku> implements BmsRuleSkuService { |
||||
|
|
||||
|
@Override |
||||
|
public List<BmsRuleSku> listSkuIdsByRuleId(Long ruleId) { |
||||
|
LambdaQueryWrapper<BmsRuleSku> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(BmsRuleSku::getRuleId,ruleId); |
||||
|
return this.list(lqw); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -1,115 +0,0 @@ |
|||||
package com.qs.serve.modules.bms.service.impl; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
||||
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.modules.bms.entity.BmsSupplier; |
|
||||
import com.qs.serve.modules.bms.entity.bo.BmsRuleBo; |
|
||||
import com.qs.serve.modules.goods.entity.GoodsSku; |
|
||||
import com.qs.serve.modules.goods.service.GoodsSkuService; |
|
||||
import lombok.AllArgsConstructor; |
|
||||
import lombok.extern.slf4j.Slf4j; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
import com.qs.serve.modules.bms.entity.BmsSkuRegion; |
|
||||
import com.qs.serve.modules.bms.service.BmsSkuRegionService; |
|
||||
import com.qs.serve.modules.bms.mapper.BmsSkuRegionMapper; |
|
||||
|
|
||||
import java.time.LocalDateTime; |
|
||||
import java.util.ArrayList; |
|
||||
import java.util.List; |
|
||||
import java.util.stream.Collectors; |
|
||||
|
|
||||
/** |
|
||||
* 禁销区域 服务实现类 |
|
||||
* @author YenHex |
|
||||
* @since 2022-10-18 |
|
||||
*/ |
|
||||
@Slf4j |
|
||||
@Service |
|
||||
@AllArgsConstructor |
|
||||
public class BmsSkuRegionServiceImpl extends ServiceImpl<BmsSkuRegionMapper,BmsSkuRegion> implements BmsSkuRegionService { |
|
||||
|
|
||||
private GoodsSkuService goodsSkuService; |
|
||||
|
|
||||
@Override |
|
||||
public void edit(Long ruleId,BmsRuleBo skuRegionBo) { |
|
||||
List<Long> banSaleRegionIds = skuRegionBo.getBanSaleRegionIds(); |
|
||||
List<Long> onlySaleRegionIds = skuRegionBo.getOnlySaleRegionIds(); |
|
||||
if (CollectionUtil.isEmpty(skuRegionBo.getSkuIds())){ |
|
||||
Assert.throwEx("请选择商品"); |
|
||||
} |
|
||||
List<GoodsSku> skuList = goodsSkuService.listByIds(skuRegionBo.getSkuIds()); |
|
||||
//移除旧数据
|
|
||||
this.deleteByRuleId(ruleId); |
|
||||
//去重
|
|
||||
if(CollectionUtil.isNotEmpty(banSaleRegionIds)&&CollectionUtil.isNotEmpty(onlySaleRegionIds)){ |
|
||||
onlySaleRegionIds = onlySaleRegionIds.stream().filter(id->!banSaleRegionIds.contains(id)).collect(Collectors.toList()); |
|
||||
} |
|
||||
List<BmsSkuRegion> skuRegionsList = new ArrayList<>(); |
|
||||
for (GoodsSku goodsSku : skuList) { |
|
||||
for (Long saleRegionId : banSaleRegionIds) { |
|
||||
BmsSkuRegion skuRegion = new BmsSkuRegion(); |
|
||||
skuRegion.setSpuId(goodsSku.getSpuId()); |
|
||||
skuRegion.setSkuId(goodsSku.getId()); |
|
||||
skuRegion.setRegionId(saleRegionId); |
|
||||
skuRegion.setRuleId(ruleId); |
|
||||
skuRegion.setTypeFlag(1); |
|
||||
skuRegionsList.add(skuRegion); |
|
||||
} |
|
||||
for (Long saleRegionId : onlySaleRegionIds) { |
|
||||
BmsSkuRegion skuRegion = new BmsSkuRegion(); |
|
||||
skuRegion.setSpuId(goodsSku.getSpuId()); |
|
||||
skuRegion.setSkuId(goodsSku.getId()); |
|
||||
skuRegion.setRegionId(saleRegionId); |
|
||||
skuRegion.setRuleId(ruleId); |
|
||||
skuRegion.setTypeFlag(0); |
|
||||
skuRegionsList.add(skuRegion); |
|
||||
} |
|
||||
} |
|
||||
if(CollectionUtil.isNotEmpty(skuRegionsList)){ |
|
||||
this.saveBatch(skuRegionsList); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public List<BmsSkuRegion> listSkuRegions(BmsSkuRegion skuRegion) { |
|
||||
return baseMapper.listSkuRegions(skuRegion); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public int checkSkuRule(List<Long> skuIds, BmsSupplier supplier) { |
|
||||
int result = 0; |
|
||||
BmsSkuRegion param = new BmsSkuRegion(); |
|
||||
List<BmsSkuRegion> skuRegionList = this.listSkuRegions(param); |
|
||||
for (BmsSkuRegion skuRegion : skuRegionList) { |
|
||||
String regionId = skuRegion.getRegionId()+""; |
|
||||
boolean isFirst = supplier.getRegionFirst().equals(regionId); |
|
||||
boolean isSecond = supplier.getRegionSecond()!=null && supplier.getRegionSecond().equals(regionId); |
|
||||
boolean isThird = supplier.getRegionThird()!=null && supplier.getRegionThird().equals(regionId); |
|
||||
if(isFirst||isSecond||isThird){ |
|
||||
result = skuRegion.getTypeFlag().equals(0)?1:2; |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public boolean removeByRegionId(Long regionId) { |
|
||||
LambdaQueryWrapper<BmsSkuRegion> lqw = new LambdaQueryWrapper<>(); |
|
||||
lqw.eq(BmsSkuRegion::getRegionId,regionId); |
|
||||
return this.remove(lqw); |
|
||||
} |
|
||||
|
|
||||
private void deleteByRuleId(Long ruleId){ |
|
||||
LambdaQueryWrapper<BmsSkuRegion> lqw = new LambdaQueryWrapper<>(); |
|
||||
lqw.eq(BmsSkuRegion::getRuleId,ruleId); |
|
||||
this.remove(lqw); |
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
||||
|
|
@ -0,0 +1,17 @@ |
|||||
|
package com.qs.serve.modules.goods.entity.vo; |
||||
|
|
||||
|
import com.qs.serve.modules.goods.entity.GoodsSku; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2022/10/20 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class GoodSkuVo extends GoodsSku { |
||||
|
|
||||
|
private String name; |
||||
|
|
||||
|
private Long spuId; |
||||
|
|
||||
|
} |
@ -1,63 +0,0 @@ |
|||||
<?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.BmsSkuRegionMapper"> |
|
||||
|
|
||||
<resultMap id="bmsSkuRegionMap" type="com.qs.serve.modules.bms.entity.BmsSkuRegion" > |
|
||||
<result property="id" column="id"/> |
|
||||
<result property="spuId" column="spu_id"/> |
|
||||
<result property="skuId" column="sku_id"/> |
|
||||
<result property="regionId" column="region_id"/> |
|
||||
<result property="ruleId" column="rule_id"/> |
|
||||
<result property="typeFlag" column="type_flag"/> |
|
||||
<result property="createTime" column="create_time"/> |
|
||||
<result property="createBy" column="create_by"/> |
|
||||
<result property="updateTime" column="update_time"/> |
|
||||
<result property="updateBy" column="update_by"/> |
|
||||
<result property="tenantId" column="tenant_id"/> |
|
||||
<result property="delFlag" column="del_flag"/> |
|
||||
</resultMap> |
|
||||
|
|
||||
<sql id="bmsSkuRegionSql"> |
|
||||
bms_sku_region.`id`, |
|
||||
bms_sku_region.`spu_id`, |
|
||||
bms_sku_region.`sku_id`, |
|
||||
bms_sku_region.`region_id`, |
|
||||
bms_sku_region.`rule_id`, |
|
||||
bms_sku_region.`type_flag`, |
|
||||
bms_sku_region.`create_time`, |
|
||||
bms_sku_region.`create_by`, |
|
||||
bms_sku_region.`update_time`, |
|
||||
bms_sku_region.`update_by`, |
|
||||
bms_sku_region.`tenant_id`, |
|
||||
bms_sku_region.`del_flag` </sql> |
|
||||
|
|
||||
<select id="listSkuRegions" parameterType="com.qs.serve.modules.bms.entity.BmsSkuRegion" resultMap="bmsSkuRegionMap"> |
|
||||
SELECT <include refid="bmsSkuRegionSql"/> FROM `bms_sku_region` `bms_sku_region` |
|
||||
LEFT JOIN bms_rule ON bms_sku_region.rule_id = bms_rule.id |
|
||||
<where> |
|
||||
<if test="query.id != null"> and `bms_sku_region`.`id` = #{query.id}</if> |
|
||||
<if test="query.spuId != null"> and `bms_sku_region`.`spu_id` = #{query.spuId}</if> |
|
||||
<if test="query.skuId != null"> and `bms_sku_region`.`sku_id` = #{query.skuId}</if> |
|
||||
<if test="query.regionId != null"> and `bms_sku_region`.`region_id` = #{query.regionId}</if> |
|
||||
<if test="query.ruleId != null"> and `bms_sku_region`.`rule_id` = #{query.ruleId}</if> |
|
||||
<if test="query.typeFlag != null"> and `bms_sku_region`.`type_flag` = #{query.typeFlag}</if> |
|
||||
<if test="query.createTime != null"> and `bms_sku_region`.`create_time` = #{query.createTime}</if> |
|
||||
<if test="query.createBy != null and query.createBy != ''"> and `bms_sku_region`.`create_by` = #{query.createBy}</if> |
|
||||
<if test="query.updateTime != null"> and `bms_sku_region`.`update_time` = #{query.updateTime}</if> |
|
||||
<if test="query.updateBy != null and query.updateBy != ''"> and `bms_sku_region`.`update_by` = #{query.updateBy}</if> |
|
||||
<if test="query.tenantId != null and query.tenantId != ''"> and `bms_sku_region`.`tenant_id` = #{query.tenantId}</if> |
|
||||
<if test="query.delFlag != null"> and `bms_sku_region`.`del_flag` = #{query.delFlag}</if> |
|
||||
<if test="query.skuIds!=null and query.skuIds.size > 0"> |
|
||||
and `bms_sku_region`.`sku_id` in |
|
||||
<foreach collection="query.skuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|
||||
#{selectId} |
|
||||
</foreach> |
|
||||
</if> |
|
||||
AND bms_rule.start_time >= now() |
|
||||
AND bms_rule.end_time <= now() |
|
||||
</where> |
|
||||
</select> |
|
||||
|
|
||||
</mapper> |
|
@ -0,0 +1,121 @@ |
|||||
|
<?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.GoodsSkuMapper"> |
||||
|
|
||||
|
<resultMap id="goodsSkuMap" type="com.qs.serve.modules.goods.entity.GoodsSku" > |
||||
|
<result property="id" column="id"/> |
||||
|
<result property="skuCode" column="sku_code"/> |
||||
|
<result property="spuId" column="spu_id"/> |
||||
|
<result property="picUrl" column="pic_url"/> |
||||
|
<result property="salesPrice" column="sales_price"/> |
||||
|
<result property="marketPrice" column="market_price"/> |
||||
|
<result property="costPrice" column="cost_price"/> |
||||
|
<result property="specInfos" column="spec_infos"/> |
||||
|
<result property="stock" column="stock"/> |
||||
|
<result property="unitId" column="unit_id"/> |
||||
|
<result property="unitName" column="unit_name"/> |
||||
|
<result property="weight" column="weight"/> |
||||
|
<result property="volume" column="volume"/> |
||||
|
<result property="enable" column="enable"/> |
||||
|
<result property="version" column="version"/> |
||||
|
<result property="remark" column="remark"/> |
||||
|
<result property="updateTime" column="update_time"/> |
||||
|
<result property="createTime" column="create_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"/> |
||||
|
</resultMap> |
||||
|
|
||||
|
<sql id="goodsSkuSql"> |
||||
|
goods_sku.`id`, |
||||
|
goods_sku.`sku_code`, |
||||
|
goods_sku.`spu_id`, |
||||
|
goods_sku.`pic_url`, |
||||
|
goods_sku.`sales_price`, |
||||
|
goods_sku.`market_price`, |
||||
|
goods_sku.`cost_price`, |
||||
|
goods_sku.`spec_infos`, |
||||
|
goods_sku.`stock`, |
||||
|
goods_sku.`unit_id`, |
||||
|
goods_sku.`unit_name`, |
||||
|
goods_sku.`weight`, |
||||
|
goods_sku.`volume`, |
||||
|
goods_sku.`enable`, |
||||
|
goods_sku.`version`, |
||||
|
goods_sku.`remark`, |
||||
|
goods_sku.`update_time`, |
||||
|
goods_sku.`create_time`, |
||||
|
goods_sku.`tenant_id`, |
||||
|
goods_sku.`del_flag`, |
||||
|
goods_sku.`create_by`, |
||||
|
goods_sku.`update_by` </sql> |
||||
|
|
||||
|
<select id="selectGoodsSkuList" parameterType="com.qs.serve.modules.goods.entity.GoodsSku" resultMap="goodsSkuMap"> |
||||
|
SELECT <include refid="goodsSkuSql"/> FROM `goods_sku` `goods_sku` |
||||
|
<where> |
||||
|
<if test="query.id != null"> and `goods_sku`.`id` = #{query.id}</if> |
||||
|
<if test="query.skuCode != null and query.skuCode != ''"> and `goods_sku`.`sku_code` = #{query.skuCode}</if> |
||||
|
<if test="query.spuId != null"> and `goods_sku`.`spu_id` = #{query.spuId}</if> |
||||
|
<if test="query.salesPrice != null"> and `goods_sku`.`sales_price` = #{query.salesPrice}</if> |
||||
|
<if test="query.marketPrice != null"> and `goods_sku`.`market_price` = #{query.marketPrice}</if> |
||||
|
<if test="query.costPrice != null"> and `goods_sku`.`cost_price` = #{query.costPrice}</if> |
||||
|
<if test="query.specInfos != null and query.specInfos != ''"> and `goods_sku`.`spec_infos` = #{query.specInfos}</if> |
||||
|
<if test="query.stock != null"> and `goods_sku`.`stock` = #{query.stock}</if> |
||||
|
<if test="query.unitId != null"> and `goods_sku`.`unit_id` = #{query.unitId}</if> |
||||
|
<if test="query.unitName != null and query.unitName != ''"> and `goods_sku`.`unit_name` = #{query.unitName}</if> |
||||
|
<if test="query.weight != null"> and `goods_sku`.`weight` = #{query.weight}</if> |
||||
|
<if test="query.volume != null"> and `goods_sku`.`volume` = #{query.volume}</if> |
||||
|
<if test="query.enable != null and query.enable != ''"> and `goods_sku`.`enable` = #{query.enable}</if> |
||||
|
<if test="query.version != null"> and `goods_sku`.`version` = #{query.version}</if> |
||||
|
<if test="query.remark != null and query.remark != ''"> and `goods_sku`.`remark` = #{query.remark}</if> |
||||
|
<if test="query.updateTime != null"> and `goods_sku`.`update_time` = #{query.updateTime}</if> |
||||
|
<if test="query.createTime != null"> and `goods_sku`.`create_time` = #{query.createTime}</if> |
||||
|
<if test="query.tenantId != null and query.tenantId != ''"> and `goods_sku`.`tenant_id` = #{query.tenantId}</if> |
||||
|
<if test="query.delFlag != null and query.delFlag != ''"> and `goods_sku`.`del_flag` = #{query.delFlag}</if> |
||||
|
<if test="query.createBy != null and query.createBy != ''"> and `goods_sku`.`create_by` = #{query.createBy}</if> |
||||
|
<if test="query.updateBy != null and query.updateBy != ''"> and `goods_sku`.`update_by` = #{query.updateBy}</if> |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
<select id="selectSkuVo" parameterType="com.qs.serve.modules.goods.entity.GoodsSku" resultMap="goodsSkuMap"> |
||||
|
SELECT |
||||
|
`goods_spu`.`spuId`, |
||||
|
`goods_spu`.`name`, |
||||
|
<include refid="goodsSkuSql"/> |
||||
|
FROM `goods_sku` `goods_sku` |
||||
|
LEFT JOIN `goods_spu` ON `goods_sku`.`spu_id` = `goods_spu`.id |
||||
|
<where> |
||||
|
<if test="query.id != null"> and `goods_sku`.`id` = #{query.id}</if> |
||||
|
<if test="query.skuCode != null and query.skuCode != ''"> and `goods_sku`.`sku_code` = #{query.skuCode}</if> |
||||
|
<if test="query.spuId != null"> and `goods_sku`.`spu_id` = #{query.spuId}</if> |
||||
|
<if test="query.salesPrice != null"> and `goods_sku`.`sales_price` = #{query.salesPrice}</if> |
||||
|
<if test="query.marketPrice != null"> and `goods_sku`.`market_price` = #{query.marketPrice}</if> |
||||
|
<if test="query.costPrice != null"> and `goods_sku`.`cost_price` = #{query.costPrice}</if> |
||||
|
<if test="query.specInfos != null and query.specInfos != ''"> and `goods_sku`.`spec_infos` = #{query.specInfos}</if> |
||||
|
<if test="query.stock != null"> and `goods_sku`.`stock` = #{query.stock}</if> |
||||
|
<if test="query.unitId != null"> and `goods_sku`.`unit_id` = #{query.unitId}</if> |
||||
|
<if test="query.unitName != null and query.unitName != ''"> and `goods_sku`.`unit_name` = #{query.unitName}</if> |
||||
|
<if test="query.weight != null"> and `goods_sku`.`weight` = #{query.weight}</if> |
||||
|
<if test="query.volume != null"> and `goods_sku`.`volume` = #{query.volume}</if> |
||||
|
<if test="query.enable != null and query.enable != ''"> and `goods_sku`.`enable` = #{query.enable}</if> |
||||
|
<if test="query.version != null"> and `goods_sku`.`version` = #{query.version}</if> |
||||
|
<if test="query.remark != null and query.remark != ''"> and `goods_sku`.`remark` = #{query.remark}</if> |
||||
|
<if test="query.updateTime != null"> and `goods_sku`.`update_time` = #{query.updateTime}</if> |
||||
|
<if test="query.createTime != null"> and `goods_sku`.`create_time` = #{query.createTime}</if> |
||||
|
<if test="query.tenantId != null and query.tenantId != ''"> and `goods_sku`.`tenant_id` = #{query.tenantId}</if> |
||||
|
<if test="query.delFlag != null and query.delFlag != ''"> and `goods_sku`.`del_flag` = #{query.delFlag}</if> |
||||
|
<if test="query.createBy != null and query.createBy != ''"> and `goods_sku`.`create_by` = #{query.createBy}</if> |
||||
|
<if test="query.updateBy != null and query.updateBy != ''"> and `goods_sku`.`update_by` = #{query.updateBy}</if> |
||||
|
<if test="query.selectSkuIds!=null and query.selectSkuIds.size > 0"> |
||||
|
and `goods_sku`.`id` in |
||||
|
<foreach collection="query.selectSkuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
||||
|
#{selectId} |
||||
|
</foreach> |
||||
|
</if> |
||||
|
</where> |
||||
|
</select> |
||||
|
|
||||
|
</mapper> |
Loading…
Reference in new issue