33 changed files with 704 additions and 163 deletions
@ -0,0 +1,90 @@ |
|||||
|
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.bo.BmsRuleBo; |
||||
|
import com.qs.serve.modules.bms.service.BmsSkuRegionService; |
||||
|
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.BmsRule; |
||||
|
import com.qs.serve.modules.bms.service.BmsRuleService; |
||||
|
|
||||
|
import javax.validation.Valid; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 基础档案 规则 |
||||
|
* @author YenHex |
||||
|
* @since 2022-10-19 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@AllArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("bms/rule") |
||||
|
public class BmsRuleController { |
||||
|
|
||||
|
private BmsRuleService bmsRuleService; |
||||
|
|
||||
|
/** |
||||
|
* 翻页 |
||||
|
* @param param |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/page") |
||||
|
@PreAuthorize("hasRole('bms:rule:query')") |
||||
|
public R<PageVo<BmsRule>> getPage(BmsRule param){ |
||||
|
PageUtil.startPage(); |
||||
|
LambdaQueryWrapper<BmsRule> ruleWrapper = new LambdaQueryWrapper<>(param); |
||||
|
List<BmsRule> list = bmsRuleService.list(ruleWrapper); |
||||
|
return R.byPageHelperList(list); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* ID查询 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@GetMapping("/getById/{id}") |
||||
|
@SysLog(module = SystemModule.BASE, title = "规则", biz = BizType.QUERY) |
||||
|
@PreAuthorize("hasRole('bms:rule:query')") |
||||
|
public R<BmsRule> getById(@PathVariable("id") String id){ |
||||
|
BmsRule bmsRule = bmsRuleService.getById(id); |
||||
|
return R.ok(bmsRule); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑 |
||||
|
* @param skuRegionBo |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/edit") |
||||
|
@SysLog(module = SystemModule.BASE, title = "规则", biz = BizType.UPDATE) |
||||
|
@PreAuthorize("hasRole('bms:rule:update')") |
||||
|
public R<?> updateById(@RequestBody @Valid BmsRuleBo skuRegionBo){ |
||||
|
bmsRuleService.edit(skuRegionBo); |
||||
|
return R.ok(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除 |
||||
|
* @param id |
||||
|
* @return |
||||
|
*/ |
||||
|
@DeleteMapping("/deleteById/{id}") |
||||
|
@SysLog(module = SystemModule.BASE, title = "规则", biz = BizType.DELETE) |
||||
|
@PreAuthorize("hasRole('bms:rule:delete')") |
||||
|
public R<?> deleteById(@PathVariable("id") Long id){ |
||||
|
boolean result = bmsRuleService.removeById(id); |
||||
|
return R.isTrue(result); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -1,101 +0,0 @@ |
|||||
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.BmsSkuRegion; |
|
||||
import com.qs.serve.modules.bms.service.BmsSkuRegionService; |
|
||||
|
|
||||
import javax.validation.Valid; |
|
||||
import java.util.List; |
|
||||
|
|
||||
/** |
|
||||
* 基础档案 sku销售区域 |
|
||||
* @author YenHex |
|
||||
* @since 2022-10-17 |
|
||||
*/ |
|
||||
@Slf4j |
|
||||
@AllArgsConstructor |
|
||||
@RestController |
|
||||
@RequestMapping("bms/skuRegion") |
|
||||
public class BmsSkuRegionController { |
|
||||
|
|
||||
private BmsSkuRegionService bmsSkuRegionService; |
|
||||
|
|
||||
/** |
|
||||
* 翻页查询 |
|
||||
* @param param |
|
||||
* @return |
|
||||
*/ |
|
||||
@GetMapping("/page") |
|
||||
@PreAuthorize("hasRole('bms:skuRegion:query')") |
|
||||
public R<PageVo<BmsSkuRegion>> getPage(BmsSkuRegion param){ |
|
||||
PageUtil.startPage(); |
|
||||
LambdaQueryWrapper<BmsSkuRegion> skuRegionWrapper = new LambdaQueryWrapper<>(param); |
|
||||
List<BmsSkuRegion> list = bmsSkuRegionService.list(skuRegionWrapper); |
|
||||
return R.byPageHelperList(list); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 根据ID查询 |
|
||||
* @param id |
|
||||
* @return |
|
||||
*/ |
|
||||
@GetMapping("/getById/{id}") |
|
||||
@SysLog(module = SystemModule.BASE, title = "sku销售区域", biz = BizType.QUERY) |
|
||||
@PreAuthorize("hasRole('bms:skuRegion:query')") |
|
||||
public R<BmsSkuRegion> getById(@PathVariable("id") String id){ |
|
||||
BmsSkuRegion bmsSkuRegion = bmsSkuRegionService.getById(id); |
|
||||
return R.ok(bmsSkuRegion); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 根据ID更新 |
|
||||
* @param param |
|
||||
* @return |
|
||||
*/ |
|
||||
@PostMapping("/updateById") |
|
||||
@SysLog(module = SystemModule.BASE, title = "sku销售区域", biz = BizType.UPDATE) |
|
||||
@PreAuthorize("hasRole('bms:skuRegion:update')") |
|
||||
public R<?> updateById(@RequestBody @Valid BmsSkuRegion param){ |
|
||||
boolean result = bmsSkuRegionService.updateById(param); |
|
||||
return R.isTrue(result); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 新增sku销售区域 |
|
||||
* @param param |
|
||||
* @return |
|
||||
*/ |
|
||||
@PostMapping("/save") |
|
||||
@SysLog(module = SystemModule.BASE, title = "sku销售区域", biz = BizType.INSERT) |
|
||||
@PreAuthorize("hasRole('bms:skuRegion:insert')") |
|
||||
public R<?> save(@RequestBody @Valid BmsSkuRegion param){ |
|
||||
boolean result = bmsSkuRegionService.save(param); |
|
||||
return R.isTrue(result); |
|
||||
} |
|
||||
|
|
||||
/** |
|
||||
* 删除sku销售区域 |
|
||||
* @param id |
|
||||
* @return |
|
||||
*/ |
|
||||
@DeleteMapping("/deleteById/{id}") |
|
||||
@SysLog(module = SystemModule.BASE, title = "sku销售区域", biz = BizType.DELETE) |
|
||||
@PreAuthorize("hasRole('bms:skuRegion:delete')") |
|
||||
public R<?> deleteById(@PathVariable("id") String id){ |
|
||||
boolean result = bmsSkuRegionService.removeById(id); |
|
||||
return R.isTrue(result); |
|
||||
} |
|
||||
|
|
||||
} |
|
||||
|
|
@ -0,0 +1,88 @@ |
|||||
|
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-19 |
||||
|
*/ |
||||
|
@Data |
||||
|
@TableName("bms_rule") |
||||
|
public class BmsRule implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** id */ |
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Long id; |
||||
|
|
||||
|
/** 规则名称 */ |
||||
|
@NotBlank(message = "规则名称不能为空") |
||||
|
@Length(max = 255,message = "规则名称长度不能超过255字") |
||||
|
private String name; |
||||
|
|
||||
|
/** 状态:0->关闭;1->启用; */ |
||||
|
@NotNull(message = "状态:0->关闭;1->启用;不能为空") |
||||
|
private Integer status; |
||||
|
|
||||
|
/** 开始时间 */ |
||||
|
@Length(max = 0,message = "开始时间长度不能超过0字") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime startTime; |
||||
|
|
||||
|
/** 结束时间 */ |
||||
|
@Length(max = 0,message = "结束时间长度不能超过0字") |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime endTime; |
||||
|
|
||||
|
/** 备注 */ |
||||
|
@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,47 @@ |
|||||
|
package com.qs.serve.modules.bms.entity.bo; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import lombok.Data; |
||||
|
import org.hibernate.validator.constraints.Length; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import javax.validation.constraints.NotNull; |
||||
|
|
||||
|
import java.time.LocalDateTime; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2022/10/17 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BmsRuleBo { |
||||
|
|
||||
|
private Long id; |
||||
|
|
||||
|
@NotNull |
||||
|
private String title; |
||||
|
|
||||
|
private String remark; |
||||
|
|
||||
|
/** skuId */ |
||||
|
@NotNull |
||||
|
private List<Long> skuIds; |
||||
|
|
||||
|
/** 只售区域id */ |
||||
|
private List<Long> onlySaleRegionIds; |
||||
|
|
||||
|
/** 禁售区域id */ |
||||
|
private List<Long> banSaleRegionIds; |
||||
|
|
||||
|
/** 开始时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime startTime; |
||||
|
|
||||
|
/** 结束时间 */ |
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private LocalDateTime endTime; |
||||
|
|
||||
|
} |
@ -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.BmsRule; |
||||
|
|
||||
|
/** |
||||
|
* 规则 Mapper |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-19 |
||||
|
*/ |
||||
|
public interface BmsRuleMapper extends BaseMapper<BmsRule> { |
||||
|
|
||||
|
} |
||||
|
|
@ -1,14 +1,27 @@ |
|||||
package com.qs.serve.modules.bms.mapper; |
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.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 com.qs.serve.modules.bms.entity.BmsSkuRegion; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
import java.util.List; |
||||
|
|
||||
/** |
/** |
||||
* sku销售区域 Mapper |
* 禁销区域 Mapper |
||||
* @author YenHex |
* @author YenHex |
||||
* @date 2022-10-17 |
* @date 2022-10-18 |
||||
*/ |
*/ |
||||
public interface BmsSkuRegionMapper extends BaseMapper<BmsSkuRegion> { |
public interface BmsSkuRegionMapper extends BaseMapper<BmsSkuRegion> { |
||||
|
|
||||
|
/** |
||||
|
* 查询 |
||||
|
* @param skuRegion |
||||
|
* @return |
||||
|
*/ |
||||
|
@InterceptorIgnore(tenantLine = "1") |
||||
|
List<BmsSkuRegion> listSkuRegions(@Param("query") BmsSkuRegion skuRegion); |
||||
|
|
||||
} |
} |
||||
|
|
||||
|
@ -0,0 +1,82 @@ |
|||||
|
package com.qs.serve.modules.bms.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSkuSupplier; |
||||
|
import com.qs.serve.modules.bms.entity.BmsSupplier; |
||||
|
import com.qs.serve.modules.goods.entity.GoodsSku; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSkuService; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSkuSpecValueService; |
||||
|
import com.qs.serve.modules.goods.service.GoodsSpuService; |
||||
|
import com.qs.serve.modules.oms.service.OmsShoppingCartService; |
||||
|
import com.qs.serve.modules.wx.service.WxUserService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.*; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
/** |
||||
|
* @author YenHex |
||||
|
* @since 2022/10/20 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BmsRuleMainService { |
||||
|
|
||||
|
private BmsSkuSupplierService bmsSkuSupplierService; |
||||
|
private BmsSkuRegionService bmsSkuRegionService; |
||||
|
|
||||
|
public boolean check(BmsSupplier supplier,List<GoodsSku> goodsSkus){ |
||||
|
List<Long> skuIds = goodsSkus.stream().map(GoodsSku::getId).collect(Collectors.toList()); |
||||
|
List<Long> spuIds = goodsSkus.stream().map(GoodsSku::getSpuId).collect(Collectors.toList()); |
||||
|
List<BmsSkuSupplier> skuSupplierRules = this.getSkuSupplierRules(supplier.getId(),skuIds); |
||||
|
if(skuSupplierRules.size()>0){ |
||||
|
boolean isBaned = skuSupplierRules.stream().anyMatch(skuSupplier -> skuSupplier.getBanStatus().equals(1)); |
||||
|
if(isBaned){return false;} |
||||
|
//过来设置允许的sku
|
||||
|
skuIds = skuIds.stream().filter(skuId-> |
||||
|
skuSupplierRules.stream().noneMatch(rule-> rule.getSkuId().equals(skuId)) |
||||
|
).collect(Collectors.toList()); |
||||
|
} |
||||
|
List<BmsSkuSupplier> spuSupplierRules = this.getSpuSupplierRules(supplier.getId(),spuIds); |
||||
|
if(spuSupplierRules.size()>0){ |
||||
|
boolean isBaned = spuSupplierRules.stream().anyMatch(spuSupplier -> spuSupplier.getBanStatus().equals(1)); |
||||
|
if(isBaned){return false;} |
||||
|
//过来设置允许的sku
|
||||
|
spuIds = skuIds.stream().filter(skuId-> |
||||
|
skuSupplierRules.stream().noneMatch(rule-> rule.getSkuId().equals(skuId)) |
||||
|
).collect(Collectors.toList()); |
||||
|
} |
||||
|
//过滤通行spu的sku
|
||||
|
final List<Long> spuIdsTemp = spuIds; |
||||
|
List<Long> passSkuIds = goodsSkus.stream() |
||||
|
.filter(goodsSku -> spuIdsTemp.stream().anyMatch(spuId->goodsSku.getSpuId().equals(spuId))) |
||||
|
.map(GoodsSku::getId) |
||||
|
.collect(Collectors.toList()); |
||||
|
skuIds = skuIds.stream().filter(skuId-> |
||||
|
passSkuIds.stream().noneMatch(passSkuId-> passSkuId.equals(skuId)) |
||||
|
).collect(Collectors.toList()); |
||||
|
//检验区域拦截 0默认 1可售 2禁售
|
||||
|
int rs3 = bmsSkuRegionService.checkSkuRule(skuIds,supplier); |
||||
|
return rs3 < 2; |
||||
|
} |
||||
|
|
||||
|
public List<BmsSkuSupplier> getSkuSupplierRules(String supplierId, List<Long> skuIds) { |
||||
|
LambdaQueryWrapper<BmsSkuSupplier> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.eq(BmsSkuSupplier::getSkuId,skuIds); |
||||
|
lqw.eq(BmsSkuSupplier::getSupplierId,supplierId); |
||||
|
return bmsSkuSupplierService.list(lqw); |
||||
|
} |
||||
|
|
||||
|
public List<BmsSkuSupplier> getSpuSupplierRules(String supplierId, List<Long> spuIds) { |
||||
|
LambdaQueryWrapper<BmsSkuSupplier> lqw = new LambdaQueryWrapper<>(); |
||||
|
lqw.in(BmsSkuSupplier::getSpuId,spuIds); |
||||
|
lqw.eq(BmsSkuSupplier::getSkuId,0); |
||||
|
lqw.eq(BmsSkuSupplier::getSupplierId,supplierId); |
||||
|
return bmsSkuSupplierService.list(lqw); |
||||
|
} |
||||
|
|
||||
|
} |
@ -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.BmsRule; |
||||
|
import com.qs.serve.modules.bms.entity.bo.BmsRuleBo; |
||||
|
|
||||
|
/** |
||||
|
* 规则 服务接口 |
||||
|
* @author YenHex |
||||
|
* @date 2022-10-19 |
||||
|
*/ |
||||
|
public interface BmsRuleService extends IService<BmsRule> { |
||||
|
|
||||
|
/** |
||||
|
* 编辑 |
||||
|
* @param skuRegionBo |
||||
|
*/ |
||||
|
void edit(BmsRuleBo skuRegionBo); |
||||
|
|
||||
|
} |
||||
|
|
@ -1,14 +1,46 @@ |
|||||
package com.qs.serve.modules.bms.service; |
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.baomidou.mybatisplus.extension.service.IService; |
||||
import com.qs.serve.modules.bms.entity.BmsSkuRegion; |
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; |
||||
|
|
||||
/** |
/** |
||||
* sku销售区域 服务接口 |
* 禁销区域 服务接口 |
||||
* @author YenHex |
* @author YenHex |
||||
* @date 2022-10-17 |
* @date 2022-10-18 |
||||
*/ |
*/ |
||||
public interface BmsSkuRegionService extends IService<BmsSkuRegion> { |
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,38 @@ |
|||||
|
package com.qs.serve.modules.bms.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.qs.serve.modules.bms.entity.bo.BmsRuleBo; |
||||
|
import com.qs.serve.modules.bms.service.BmsSkuRegionService; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import com.qs.serve.modules.bms.entity.BmsRule; |
||||
|
import com.qs.serve.modules.bms.service.BmsRuleService; |
||||
|
import com.qs.serve.modules.bms.mapper.BmsRuleMapper; |
||||
|
|
||||
|
/** |
||||
|
* 规则 服务实现类 |
||||
|
* @author YenHex |
||||
|
* @since 2022-10-19 |
||||
|
*/ |
||||
|
@Slf4j |
||||
|
@Service |
||||
|
@AllArgsConstructor |
||||
|
public class BmsRuleServiceImpl extends ServiceImpl<BmsRuleMapper,BmsRule> implements BmsRuleService { |
||||
|
|
||||
|
private BmsSkuRegionService skuRegionService; |
||||
|
|
||||
|
@Override |
||||
|
public void edit(BmsRuleBo skuRegionBo) { |
||||
|
BmsRule bmsRule = new BmsRule(); |
||||
|
bmsRule.setId(skuRegionBo.getId()); |
||||
|
bmsRule.setName(skuRegionBo.getTitle()); |
||||
|
bmsRule.setRemark(skuRegionBo.getRemark()); |
||||
|
bmsRule.setStartTime(skuRegionBo.getStartTime()); |
||||
|
bmsRule.setEndTime(skuRegionBo.getEndTime()); |
||||
|
this.saveOrUpdate(bmsRule); |
||||
|
skuRegionService.edit(bmsRule.getId(),skuRegionBo); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,63 @@ |
|||||
|
<?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> |
Loading…
Reference in new issue