7 changed files with 673 additions and 0 deletions
@ -0,0 +1,204 @@ |
|||
package com.qs.serve.modules.goods.controller.api; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.qs.serve.common.config.DevEnvironmentConfig; |
|||
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.*; |
|||
import com.qs.serve.modules.bms.common.BookAccountUtil; |
|||
import com.qs.serve.modules.bms.entity.BmsSupplier; |
|||
import com.qs.serve.modules.bms.service.BmsSupplierService; |
|||
import com.qs.serve.modules.erp.mapper.ErpDispatchDataMapper; |
|||
import com.qs.serve.modules.goods.entity.*; |
|||
import com.qs.serve.modules.goods.entity.bo.GoodsImminentBatchBo; |
|||
import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto; |
|||
import com.qs.serve.modules.goods.entity.dto.GoodsRuleItemDTO; |
|||
import com.qs.serve.modules.goods.entity.so.GoodsImminentBatchQuery; |
|||
import com.qs.serve.modules.goods.entity.vo.GoodsImminentBatchVo; |
|||
import com.qs.serve.modules.goods.mapper.GoodsSkuMapper; |
|||
import com.qs.serve.modules.goods.mapper.GoodsSpuMapper; |
|||
import com.qs.serve.modules.goods.service.*; |
|||
import com.qs.serve.modules.seeyon.service.impl.SeeYonRequestBaseService; |
|||
import com.qs.serve.modules.tbs.service.TbsActivityGoodsService; |
|||
import com.qs.serve.modules.tbs.service.TbsBudgetConditionService; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.security.access.prepost.PreAuthorize; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.validation.Valid; |
|||
import java.util.*; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 商品 临期批次 |
|||
* @author YenHex |
|||
* @since 2024-06-11 |
|||
*/ |
|||
@Slf4j |
|||
@AllArgsConstructor |
|||
@RestController |
|||
@RequestMapping("my/imminentBatch") |
|||
public class GoodsImminentBatchApi { |
|||
|
|||
private GoodsRuleService goodsRuleService; |
|||
private GoodsCategoryRuleService goodsCategoryRuleService; |
|||
private BmsSupplierService bmsSupplierService; |
|||
private GoodsCategoryService goodsCategoryService; |
|||
private GoodsAccreditService goodsAccreditService; |
|||
private GoodsImminentBatchService goodsImminentBatchService; |
|||
|
|||
|
|||
/** |
|||
* 翻页 |
|||
* @param param |
|||
* @return |
|||
*/ |
|||
@GetMapping("/page") |
|||
public R<PageVo<GoodsImminentBatchVo>> getPage(GoodsImminentBatchQuery param){ |
|||
GoodsCategoryRule categoryRule = goodsCategoryRuleService.getById(param.getSearchCateRuleId()); |
|||
if(categoryRule!=null&&categoryRule.getIgnoreBrandIds()!=null&&categoryRule.getIgnoreBrandIds().length>0){ |
|||
param.setSelectNotIntCateIds(Arrays.asList(categoryRule.getIgnoreBrandIds())); |
|||
log.info("setSelectNotIntCateIds {}", JsonUtil.objectToJson(param)); |
|||
} |
|||
BmsSupplier supplier = bmsSupplierService.getByNameOrCode(param.getSupplierCode()); |
|||
if(supplier==null){ |
|||
return R.error("供应商不存在或停用"); |
|||
} |
|||
|
|||
//客户规则设置
|
|||
String userId = AuthContextUtils.getSysUserId(); |
|||
this.toSetSpuParam(param, supplier,userId); |
|||
//产品规则设置
|
|||
this.tiSetSpuParam2(param, supplier); |
|||
|
|||
if(DevEnvironmentConfig.OPEN_TENANT_BOOK){ |
|||
param.setBookCodeList(BookAccountUtil.getCurrentUserAccount()); |
|||
} |
|||
long total = goodsImminentBatchService.countVoList(param); |
|||
if(total<1){ |
|||
return R.byEmptyList(); |
|||
} |
|||
List<GoodsImminentBatchVo> list = goodsImminentBatchService.selectVoList(param); |
|||
return R.byPageList(total,list); |
|||
} |
|||
|
|||
/** |
|||
* ID查询 |
|||
* @param id |
|||
* @return |
|||
*/ |
|||
@GetMapping("/getById/{id}") |
|||
@SysLog(module = SystemModule.GOODS, title = "临期批次", biz = BizType.QUERY) |
|||
public R<GoodsImminentBatch> getById(@PathVariable("id") String id){ |
|||
GoodsImminentBatch goodsImminentBatch = goodsImminentBatchService.getById(id); |
|||
return R.ok(goodsImminentBatch); |
|||
} |
|||
|
|||
|
|||
private void tiSetSpuParam2(GoodsImminentBatchQuery param, BmsSupplier supplier) { |
|||
GoodsAccrIdsDto accrIdsDto = goodsAccreditService |
|||
.listIgnoreAcc2(supplier.getId(), supplier.listBizRegionIds(), supplier.listSaleRegionIds()); |
|||
param.setSubAccInfo(accrIdsDto); |
|||
} |
|||
|
|||
/** |
|||
* 设置Spu查询条件 |
|||
* @param param |
|||
* @param supplier |
|||
*/ |
|||
private void toSetSpuParam(GoodsImminentBatchQuery param, BmsSupplier supplier, String userId) { |
|||
|
|||
//用户维度的客户规则
|
|||
List<GoodsRuleItem> userRules = goodsRuleService.listByUserId(userId); |
|||
List<GoodsRuleItem> ruleItems = goodsRuleService.listBySupplierId(supplier.getId()); |
|||
if(userRules!=null){ |
|||
if(ruleItems!=null){ |
|||
ruleItems.addAll(userRules); |
|||
}else { |
|||
ruleItems = userRules; |
|||
} |
|||
} |
|||
GoodsRuleItemDTO ruleItemDTO = goodsRuleService.buildGoodsRuleItemDTO(ruleItems); |
|||
if(ruleItemDTO!=null){ |
|||
|
|||
if(ruleItemDTO.getNotInCategoryIds()!=null){ |
|||
if(CollUtil.isEmpty(param.getSelectNotIntCateIds())){ |
|||
param.setSelectNotIntCateIds(ruleItemDTO.getNotInCategoryIds()); |
|||
}else{ |
|||
param.getSelectNotIntCateIds().addAll(ruleItemDTO.getNotInCategoryIds()); |
|||
} |
|||
} |
|||
|
|||
if(CollUtil.isNotEmpty(ruleItemDTO.getOnlyCategoryIds())){ |
|||
if (CollUtil.isEmpty(param.getSelectCateIds())){ |
|||
param.setSelectCateIds(ruleItemDTO.getOnlyCategoryIds()); |
|||
}else{ |
|||
List<String> onlyIds = ruleItemDTO.getOnlyCategoryIds(); |
|||
List<GoodsCategory> onlyCategoryList = goodsCategoryService.listByIds(onlyIds); |
|||
for (GoodsCategory category : onlyCategoryList) { |
|||
List<GoodsCategory> childList = goodsCategoryService.list(new LambdaQueryWrapper<GoodsCategory>() |
|||
.likeRight(GoodsCategory::getLevelPath,category.getLevelPath()+"_")); |
|||
if(CollUtil.isNotEmpty(childList)){ |
|||
List<String> childIds = childList.stream().map(a->a.getId().toString()).collect(Collectors.toList()); |
|||
onlyIds.addAll(childIds); |
|||
} |
|||
} |
|||
List<String> selectCateIds = param.getSelectCateIds(); |
|||
List<GoodsCategory> goodsCategoryList = goodsCategoryService.listByIds(selectCateIds); |
|||
for (GoodsCategory category : goodsCategoryList) { |
|||
List<GoodsCategory> childList = goodsCategoryService.list(new LambdaQueryWrapper<GoodsCategory>() |
|||
.likeRight(GoodsCategory::getLevelPath,category.getLevelPath()+"_")); |
|||
if(CollUtil.isNotEmpty(childList)){ |
|||
List<String> childIds = childList.stream().map(a->a.getId().toString()).collect(Collectors.toList()); |
|||
selectCateIds.addAll(childIds); |
|||
} |
|||
} |
|||
//交集
|
|||
Collection<String> ids = cn.hutool.core.collection.CollectionUtil |
|||
.intersection(onlyIds, selectCateIds); |
|||
List<String> idsList = new ArrayList<>(); |
|||
idsList.addAll(ids); |
|||
idsList.add("#"); |
|||
param.setSelectCateIds(idsList); |
|||
} |
|||
} |
|||
|
|||
if(CollUtil.isNotEmpty(ruleItemDTO.getOnlySpuIds())){ |
|||
if (CollUtil.isEmpty(param.getSelectSpuIds())){ |
|||
List<Long> ids = ruleItemDTO.getOnlySpuIds().stream() |
|||
.filter(Objects::nonNull).map(Long::parseLong).collect(Collectors.toList()); |
|||
param.setSelectSpuIds(ids); |
|||
}else{ |
|||
List<Long> ids = ruleItemDTO.getOnlySpuIds().stream() |
|||
.filter(Objects::nonNull).map(Long::parseLong).collect(Collectors.toList()); |
|||
//交集
|
|||
Collection<Long> id2s = cn.hutool.core.collection.CollectionUtil |
|||
.intersection(ids, param.getSelectSpuIds()); |
|||
List<Long> idsList = new ArrayList<>(); |
|||
idsList.addAll(id2s); |
|||
idsList.add(-1L); |
|||
param.setSelectSpuIds(idsList); |
|||
} |
|||
} |
|||
|
|||
if(CollUtil.isNotEmpty(ruleItemDTO.getNotInSpuIds())){ |
|||
if (CollUtil.isEmpty(param.getSelectNotInSpuIds())){ |
|||
List<Long> ids = ruleItemDTO.getNotInSpuIds().stream() |
|||
.filter(Objects::nonNull).map(Long::parseLong).collect(Collectors.toList()); |
|||
param.setSelectNotInSpuIds(ids); |
|||
}else{ |
|||
List<Long> ids = ruleItemDTO.getNotInSpuIds().stream() |
|||
.filter(Objects::nonNull).map(Long::parseLong).collect(Collectors.toList()); |
|||
param.getSelectNotInSpuIds().addAll(ids); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
|
@ -0,0 +1,42 @@ |
|||
package com.qs.serve.modules.goods.entity.so; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.qs.serve.modules.goods.entity.dto.GoodsAccrIdsDto; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2024/6/12 |
|||
*/ |
|||
@Data |
|||
public class GoodsImminentBatchQuery { |
|||
|
|||
/** 关键字查询 */ |
|||
private String skuName; |
|||
private String skuCode; |
|||
private String spuName; |
|||
private String spuCode; |
|||
private String skuAddCode; |
|||
|
|||
/** 供应商编码 */ |
|||
private String supplierCode; |
|||
|
|||
/** 选中的商品规则 */ |
|||
private String searchCateRuleId; |
|||
|
|||
private Integer selectSpecialFlag; |
|||
private Integer orderFlag; |
|||
private String belong; |
|||
|
|||
/** 账套编码列表 */ |
|||
private List<String> bookCodeList; |
|||
private GoodsAccrIdsDto subAccInfo; |
|||
private List<Long> notInSkuIds; |
|||
private List<Long> selectSpuIds; |
|||
private List<Long> selectNotInSpuIds; |
|||
private List<String> selectCateIds; |
|||
private List<String> selectNotIntCateIds; |
|||
|
|||
} |
@ -0,0 +1,126 @@ |
|||
package com.qs.serve.modules.goods.entity.vo; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.SqlCondition; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
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.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.math.BigDecimal; |
|||
import java.time.LocalDate; |
|||
|
|||
/** |
|||
* @author YenHex |
|||
* @since 2024/6/12 |
|||
*/ |
|||
@Data |
|||
public class GoodsImminentBatchVo { |
|||
|
|||
/** 批次skuId */ |
|||
private Long id; |
|||
|
|||
private String batchCode; |
|||
|
|||
/** 数量 */ |
|||
private Integer quantity; |
|||
|
|||
/** 已下单数量 */ |
|||
private Integer orderQuantity; |
|||
|
|||
/** 截止销售时间 */ |
|||
@DateTimeFormat(pattern = "yyyy-MM-dd") |
|||
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") |
|||
private LocalDate endDate; |
|||
|
|||
/** 批次备注 */ |
|||
private String remark; |
|||
|
|||
private String spuId; |
|||
|
|||
private String spuCode; |
|||
|
|||
private String spuName; |
|||
|
|||
private String skuId; |
|||
|
|||
private String skuCode; |
|||
|
|||
private String skuName; |
|||
|
|||
private String skuAddCode; |
|||
|
|||
/** 图片 */ |
|||
private String picUrl; |
|||
|
|||
/** 销售价格 */ |
|||
private BigDecimal salesPrice; |
|||
|
|||
/** 市场价 */ |
|||
private BigDecimal marketPrice; |
|||
|
|||
/** 成本价 */ |
|||
private BigDecimal costPrice; |
|||
|
|||
/** 规格值 */ |
|||
private String specInfos; |
|||
|
|||
/** 库存 */ |
|||
private Integer stock; |
|||
|
|||
/** 重量(kg) */ |
|||
private BigDecimal weight; |
|||
|
|||
/** 体积(m³) */ |
|||
private BigDecimal volume; |
|||
|
|||
/** 净重 */ |
|||
private BigDecimal invUnitWeight; |
|||
|
|||
/** 最低起批数(0->不限制) */ |
|||
private Integer minPurchase; |
|||
|
|||
/** 是否可以下单 1、是;0否 */ |
|||
private Integer orderFlag; |
|||
|
|||
private Integer specialFlag; |
|||
|
|||
/** 在线下单 */ |
|||
private Integer orderOnlineFlag; |
|||
|
|||
/** 线下下单 */ |
|||
private Integer orderOfflineFlag; |
|||
|
|||
/** 单位id */ |
|||
private Long unitId; |
|||
|
|||
/** 单位 */ |
|||
private String unitName; |
|||
|
|||
/** 账套编码 */ |
|||
private String bookBelong; |
|||
|
|||
/** 账套名称 */ |
|||
private String bookName; |
|||
|
|||
/** 产地 */ |
|||
private String belong; |
|||
|
|||
/** 包装 */ |
|||
private String wrapVal; |
|||
|
|||
/** 口味 */ |
|||
private String tasteVal; |
|||
|
|||
/** 一级类目:品牌名称 */ |
|||
private String cateFirstLabel; |
|||
|
|||
/** 二级类目:类目名称 */ |
|||
private String cateSecondLabel; |
|||
|
|||
/** 三级类目:系列名称 */ |
|||
private String cateThirdLabel; |
|||
|
|||
} |
@ -0,0 +1,270 @@ |
|||
<?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.GoodsImminentBatchMapper"> |
|||
|
|||
<resultMap id="goodsImminentBatchMap" type="com.qs.serve.modules.goods.entity.GoodsImminentBatch" > |
|||
<result property="id" column="id"/> |
|||
<result property="skuId" column="sku_id"/> |
|||
<result property="skuCode" column="sku_code"/> |
|||
<result property="skuName" column="sku_name"/> |
|||
<result property="batchCode" column="batch_code"/> |
|||
<result property="quantity" column="quantity"/> |
|||
<result property="endDate" column="end_date"/> |
|||
<result property="remark" column="remark"/> |
|||
<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"/> |
|||
</resultMap> |
|||
|
|||
<sql id="goodsImminentBatchSql"> |
|||
goods_imminent_batch.`id`, |
|||
goods_imminent_batch.`batch_code`, |
|||
goods_imminent_batch.`quantity`, |
|||
goods_imminent_batch.`order_quantity`, |
|||
goods_imminent_batch.`end_date`, |
|||
goods_imminent_batch.`remark` |
|||
</sql> |
|||
|
|||
<select id="countVoList" resultType="java.lang.Long"> |
|||
select |
|||
count(1) |
|||
from goods_imminent_batch |
|||
left join goods_sku on goods_imminent_batch.sku_id = goods_sku.id |
|||
left join goods_spu on goods_sku.spu_id = goods_spu.id |
|||
LEFT JOIN `goods_category` `cate1` ON `cate1`.`id` = `goods_spu`.`category_first` |
|||
LEFT JOIN `goods_category` `cate2` ON `cate2`.`id` = `goods_spu`.`category_second` |
|||
LEFT JOIN `goods_category` `cate3` ON `cate3`.`id` = `goods_spu`.`category_third` |
|||
<where> |
|||
and goods_imminent_batch.del_flag = 0 |
|||
and goods_sku.del_flag = 0 |
|||
and goods_spu.del_flag = 0 |
|||
and goods_sku.order_flag = 1 |
|||
and goods_sku.`enable` = 1 |
|||
<include refid="spuWherePart"></include> |
|||
<include refid="skuWherePart"></include> |
|||
</where> |
|||
</select> |
|||
|
|||
<select id="selectVoList" resultType="com.qs.serve.modules.goods.entity.vo.GoodsImminentBatchVo"> |
|||
SELECT |
|||
`cate1`.`name` AS `cate_first_label`, |
|||
`cate2`.`name` AS `cate_second_label`, |
|||
`cate3`.`name` AS `cate_third_label`, |
|||
goods_sku.id as `sku_id`, |
|||
<include refid="goodsImminentBatchSql"/>, |
|||
<include refid="goodsSpuSql"/>, |
|||
<include refid="goodsSkuSql"/> |
|||
from goods_imminent_batch |
|||
left join goods_sku on goods_imminent_batch.sku_id = goods_sku.id |
|||
left join goods_spu on goods_sku.spu_id = goods_spu.id |
|||
LEFT JOIN `goods_category` `cate1` ON `cate1`.`id` = `goods_spu`.`category_first` |
|||
LEFT JOIN `goods_category` `cate2` ON `cate2`.`id` = `goods_spu`.`category_second` |
|||
LEFT JOIN `goods_category` `cate3` ON `cate3`.`id` = `goods_spu`.`category_third` |
|||
<where> |
|||
and goods_imminent_batch.del_flag = 0 |
|||
and goods_sku.del_flag = 0 |
|||
and goods_spu.del_flag = 0 |
|||
and goods_sku.order_flag = 1 |
|||
and goods_sku.`enable` = 1 |
|||
<include refid="spuWherePart"></include> |
|||
<include refid="skuWherePart"></include> |
|||
</where> |
|||
limit #{pageInfo.startIndex},#{pageInfo.size} |
|||
</select> |
|||
|
|||
<sql id="goodsSkuSql"> |
|||
goods_sku.`sku_name`, |
|||
goods_sku.`sku_code`, |
|||
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.`inv_unit_weight`, |
|||
goods_sku.`min_purchase`, |
|||
goods_sku.`cost_flag`, |
|||
goods_sku.`belong`, |
|||
goods_sku.`belong_sort`, |
|||
goods_sku.`wrap_val`, |
|||
goods_sku.`taste_val`, |
|||
goods_sku.`order_flag`, |
|||
goods_sku.`special_flag`, |
|||
goods_sku.`abct`, |
|||
goods_sku.`order_online_flag`, |
|||
goods_sku.`order_offline_flag`, |
|||
goods_sku.`book_belong`, |
|||
goods_sku.`book_name` |
|||
</sql> |
|||
|
|||
<sql id="goodsSpuSql"> |
|||
goods_spu.`spu_code`, |
|||
goods_spu.`name` as `spu_name`, |
|||
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.`cost_flag`, |
|||
goods_spu.`order_flag`, |
|||
goods_spu.`book_belong`, |
|||
goods_spu.`book_name`, |
|||
goods_spu.`special_sku_id`, |
|||
goods_spu.`spu_cunhuo_flag`, |
|||
goods_spu.`sku_num_val` |
|||
</sql> |
|||
|
|||
|
|||
<sql id="spuWherePart"> |
|||
<if test="query.spuName != null and query.spuName != ''"> and `goods_spu`.`name` like concat('%',#{query.spuName},'%') </if> |
|||
<if test="query.skuCode != null and query.skuCode != ''"> and `goods_spu`.`goods_spu` like concat('%',#{query.skuCode},'%') </if> |
|||
<if test="query.bookCodeList!=null and query.bookCodeList.size > 0"> |
|||
and `goods_spu`.`book_belong` in |
|||
<foreach collection="query.bookCodeList" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
</if> |
|||
|
|||
<if test="query.selectSpuIds!=null and query.selectSpuIds.size > 0"> |
|||
and `goods_spu`.`id` in |
|||
<foreach collection="query.selectSpuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
</if> |
|||
<if test="query.selectNotInSpuIds!=null and query.selectNotInSpuIds.size > 0"> |
|||
and `goods_spu`.`id` not in |
|||
<foreach collection="query.selectNotInSpuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
</if> |
|||
<if test="query.selectCateIds!=null and query.selectCateIds.size > 0"> |
|||
and (`goods_spu`.`category_first` in |
|||
<foreach collection="query.selectCateIds" item="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
or `goods_spu`.`category_second` in |
|||
<foreach collection="query.selectCateIds" item="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
or `goods_spu`.`category_third` in |
|||
<foreach collection="query.selectCateIds" item="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach>) |
|||
</if> |
|||
<if test="query.selectNotIntCateIds!=null and query.selectNotIntCateIds.size > 0"> |
|||
and (`goods_spu`.`category_first` not in |
|||
<foreach collection="query.selectNotIntCateIds" item="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
and `goods_spu`.`category_second` not in |
|||
<foreach collection="query.selectNotIntCateIds" item="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
and `goods_spu`.`category_third` not in |
|||
<foreach collection="query.selectNotIntCateIds" item="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach>) |
|||
</if> |
|||
</sql> |
|||
|
|||
<sql id="skuWherePart"> |
|||
<if test="query.belong != null"> and (`goods_sku`.`belong` = #{query.belong} or goods_sku.special_flag=1) </if> |
|||
|
|||
<if test="query.selectSpecialFlag != null and query.selectSpecialFlag != -1"> |
|||
and `goods_sku`.`special_flag` = #{query.selectSpecialFlag} |
|||
</if> |
|||
<if test="query.skuAddCode != null and query.skuAddCode != ''"> |
|||
and `goods_sku`.`sku_add_code` like concat('%', #{query.skuAddCode},'%') |
|||
</if> |
|||
<if test="query.orderFlag != null "> |
|||
and (`goods_sku`.`order_flag` = #{query.orderFlag} or `goods_sku`.`special_flag` = 1) |
|||
</if> |
|||
|
|||
<if test="query.skuName != null and query.skuName != '' "> |
|||
and `goods_sku`.`sku_name` like concat('%', #{query.skuName},'%') |
|||
</if> |
|||
<if test="query.skuCode != null and query.skuCode != '' "> |
|||
and `goods_sku`.`sku_code` like concat('%', #{query.skuCode},'%') |
|||
</if> |
|||
<if test="query.notInSkuIds!=null and query.notInSkuIds.size > 0"> |
|||
and `goods_sku`.`id` not in |
|||
<foreach collection="query.notInSkuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
</if> |
|||
<if test="query.subAccInfo!=null"> |
|||
and `goods_sku`.`id` not in( |
|||
select sku.id FROM goods_sku sku |
|||
left join goods_spu spu on sku.spu_id = spu.id |
|||
left join goods_category cate1 on cate1.id = spu.category_first |
|||
left join goods_category cate2 on cate2.id = spu.category_second |
|||
left join goods_category cate3 on cate3.id = spu.category_third |
|||
where |
|||
( |
|||
sku.id in |
|||
<foreach collection="query.subAccInfo.skuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
or spu.id in |
|||
<foreach collection="query.subAccInfo.spuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
or cate1.id in |
|||
<foreach collection="query.subAccInfo.cateIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
or cate2.id in |
|||
<foreach collection="query.subAccInfo.cateIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
or cate3.id in |
|||
<foreach collection="query.subAccInfo.cateIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
) and |
|||
sku.id not in |
|||
<foreach collection="query.subAccInfo.notInSkuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
and |
|||
spu.id not in |
|||
<foreach collection="query.subAccInfo.notInSpuIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
and |
|||
cate1.id not in |
|||
<foreach collection="query.subAccInfo.notInCateIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
and |
|||
cate2.id not in |
|||
<foreach collection="query.subAccInfo.notInCateIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
and |
|||
cate3.id not in |
|||
<foreach collection="query.subAccInfo.notInCateIds" item ="selectId" index="i" open="(" close=")" separator=","> |
|||
#{selectId} |
|||
</foreach> |
|||
) |
|||
</if> |
|||
</sql> |
|||
</mapper> |
|||
|
Loading…
Reference in new issue