Browse Source

Merge remote-tracking branch 'origin/muti_db' into muti_db

checkBack
15989082884@163.com 1 year ago
parent
commit
c330966f26
  1. 21
      src/main/java/com/qs/serve/modules/goods/controller/GoodsImminentBatchController.java
  2. 204
      src/main/java/com/qs/serve/modules/goods/controller/api/GoodsImminentBatchApi.java
  3. 4
      src/main/java/com/qs/serve/modules/goods/entity/GoodsImminentBatch.java
  4. 2
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsImminentBatchBo.java
  5. 42
      src/main/java/com/qs/serve/modules/goods/entity/so/GoodsImminentBatchQuery.java
  6. 126
      src/main/java/com/qs/serve/modules/goods/entity/vo/GoodsImminentBatchVo.java
  7. 13
      src/main/java/com/qs/serve/modules/goods/mapper/GoodsImminentBatchMapper.java
  8. 10
      src/main/java/com/qs/serve/modules/goods/service/GoodsImminentBatchService.java
  9. 24
      src/main/java/com/qs/serve/modules/goods/service/impl/GoodsImminentBatchServiceImpl.java
  10. 36
      src/main/java/com/qs/serve/modules/oms/controller/api/OmsOrderApi.java
  11. 2
      src/main/java/com/qs/serve/modules/oms/entity/OmsOrder.java
  12. 11
      src/main/java/com/qs/serve/modules/oms/entity/OmsOrderItem.java
  13. 58
      src/main/java/com/qs/serve/modules/oms/entity/bo/OmsOrderImminentBo.java
  14. 12
      src/main/java/com/qs/serve/modules/oms/service/OmsOrderService.java
  15. 214
      src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java
  16. 4
      src/main/java/com/qs/serve/modules/tbs/controller/TbsActivityController2.java
  17. 270
      src/main/resources/mapper/goods/GoodsImminentBatchMapper.xml

21
src/main/java/com/qs/serve/modules/goods/controller/GoodsImminentBatchController.java

@ -12,6 +12,8 @@ import com.qs.serve.common.util.StringUtils;
import com.qs.serve.modules.goods.entity.GoodsSku;
import com.qs.serve.modules.goods.entity.bo.GoodsImminentBatchBo;
import com.qs.serve.modules.goods.service.GoodsSkuService;
import com.qs.serve.modules.oms.entity.OmsOrderItem;
import com.qs.serve.modules.oms.service.OmsOrderItemService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
@ -34,6 +36,7 @@ import java.util.List;
@RequestMapping("goods/imminentBatch")
public class GoodsImminentBatchController {
private OmsOrderItemService orderItemService;
private GoodsImminentBatchService goodsImminentBatchService;
private GoodsSkuService goodsSkuService;
@ -67,12 +70,24 @@ public class GoodsImminentBatchController {
* @param param
* @return
*/
@PostMapping("/updateById")
@PostMapping("/update")
@SysLog(module = SystemModule.GOODS, title = "临期批次", biz = BizType.UPDATE)
public R<?> updateById(@RequestBody @Valid GoodsImminentBatchBo param){
//param.setBatchCode(null);
param.setSkuId(null);
GoodsImminentBatch entity = CopierUtil.copy(param,new GoodsImminentBatch());
if(goodsImminentBatchService.checkExist(param.getBatchCode(),param.getSkuId(),entity.getId())){
return R.error("已重复");
}
GoodsImminentBatch org = goodsImminentBatchService.getById(param.getId());
if(!org.getBatchCode().equals(entity.getBatchCode())){
long count = orderItemService.count(
new LambdaQueryWrapper<OmsOrderItem>()
.eq(OmsOrderItem::getSkuBatchId,param.getId())
);
if(count>0){
return R.error("已存在订单,无法修改批号");
}
}
boolean result = goodsImminentBatchService.updateById(entity);
return R.isTrue(result);
}
@ -89,7 +104,7 @@ public class GoodsImminentBatchController {
GoodsSku goodsSku = goodsSkuService.getById(param.getSkuId());
entity.setSkuCode(goodsSku.getSkuCode());
entity.setSkuName(goodsSku.getSkuName());
if(goodsImminentBatchService.checkExist(param.getBatchCode(),param.getSkuId())){
if(goodsImminentBatchService.checkExist(param.getBatchCode(),param.getSkuId(),0L)){
return R.error("已重复");
}
boolean result = goodsImminentBatchService.save(entity);

204
src/main/java/com/qs/serve/modules/goods/controller/api/GoodsImminentBatchApi.java

@ -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);
}
}
}
}
}

4
src/main/java/com/qs/serve/modules/goods/entity/GoodsImminentBatch.java

@ -28,7 +28,7 @@ public class GoodsImminentBatch implements Serializable {
private static final long serialVersionUID = 1L;
/** id */
private Integer id;
private Long id;
/** skuID */
@NotBlank(message = "skuID不能为空")
@ -99,11 +99,13 @@ public class GoodsImminentBatch implements Serializable {
/** 查询开始 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
@TableField(exist = false)
private LocalDate queryStartDate;
/** 查询结束 */
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
@TableField(exist = false)
private LocalDate queryEndDate;
}

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

@ -26,7 +26,7 @@ public class GoodsImminentBatchBo implements Serializable {
private static final long serialVersionUID = 1L;
/** id */
private Integer id;
private Long id;
/** skuID */
@NotBlank(message = "skuID不能为空")

42
src/main/java/com/qs/serve/modules/goods/entity/so/GoodsImminentBatchQuery.java

@ -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;
}

126
src/main/java/com/qs/serve/modules/goods/entity/vo/GoodsImminentBatchVo.java

@ -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;
}

13
src/main/java/com/qs/serve/modules/goods/mapper/GoodsImminentBatchMapper.java

@ -1,7 +1,14 @@
package com.qs.serve.modules.goods.mapper;
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.common.model.dto.RowParam;
import com.qs.serve.modules.goods.entity.GoodsImminentBatch;
import com.qs.serve.modules.goods.entity.so.GoodsImminentBatchQuery;
import com.qs.serve.modules.goods.entity.vo.GoodsImminentBatchVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 临期批次 Mapper
@ -10,5 +17,11 @@ import com.qs.serve.modules.goods.entity.GoodsImminentBatch;
*/
public interface GoodsImminentBatchMapper extends BaseMapper<GoodsImminentBatch> {
@InterceptorIgnore(tenantLine = "1")
long countVoList(@Param("query") GoodsImminentBatchQuery query);
@InterceptorIgnore(tenantLine = "1")
List<GoodsImminentBatchVo> selectVoList(@Param("query") GoodsImminentBatchQuery query, @Param("pageInfo") RowParam rowParam);
}

10
src/main/java/com/qs/serve/modules/goods/service/GoodsImminentBatchService.java

@ -2,6 +2,10 @@ package com.qs.serve.modules.goods.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.goods.entity.GoodsImminentBatch;
import com.qs.serve.modules.goods.entity.so.GoodsImminentBatchQuery;
import com.qs.serve.modules.goods.entity.vo.GoodsImminentBatchVo;
import java.util.List;
/**
* 临期批次 服务接口
@ -10,7 +14,11 @@ import com.qs.serve.modules.goods.entity.GoodsImminentBatch;
*/
public interface GoodsImminentBatchService extends IService<GoodsImminentBatch> {
boolean checkExist(String batchCode,String skuId);
boolean checkExist(String batchCode,String skuId,Long rowId);
long countVoList(GoodsImminentBatchQuery query);
List<GoodsImminentBatchVo> selectVoList(GoodsImminentBatchQuery query);
}

24
src/main/java/com/qs/serve/modules/goods/service/impl/GoodsImminentBatchServiceImpl.java

@ -2,6 +2,9 @@ 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.model.dto.RowParam;
import com.qs.serve.modules.goods.entity.so.GoodsImminentBatchQuery;
import com.qs.serve.modules.goods.entity.vo.GoodsImminentBatchVo;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -9,6 +12,8 @@ import com.qs.serve.modules.goods.entity.GoodsImminentBatch;
import com.qs.serve.modules.goods.service.GoodsImminentBatchService;
import com.qs.serve.modules.goods.mapper.GoodsImminentBatchMapper;
import java.util.List;
/**
* 临期批次 服务实现类
* @author YenHex
@ -20,9 +25,24 @@ import com.qs.serve.modules.goods.mapper.GoodsImminentBatchMapper;
public class GoodsImminentBatchServiceImpl extends ServiceImpl<GoodsImminentBatchMapper,GoodsImminentBatch> implements GoodsImminentBatchService {
@Override
public boolean checkExist(String batchCode, String skuId) {
long count = this.count(new LambdaQueryWrapper<GoodsImminentBatch>().eq(GoodsImminentBatch::getBatchCode,batchCode).eq(GoodsImminentBatch::getSkuId,skuId));
public boolean checkExist(String batchCode, String skuId,Long rowId) {
long count = this.count(new LambdaQueryWrapper<GoodsImminentBatch>()
.eq(GoodsImminentBatch::getBatchCode,batchCode)
.eq(GoodsImminentBatch::getSkuId,skuId)
.ne(GoodsImminentBatch::getId,rowId)
);
return count>0;
}
@Override
public long countVoList(GoodsImminentBatchQuery query) {
return baseMapper.countVoList(query);
}
@Override
public List<GoodsImminentBatchVo> selectVoList(GoodsImminentBatchQuery query) {
return baseMapper.selectVoList(query,new RowParam(true));
}
}

36
src/main/java/com/qs/serve/modules/oms/controller/api/OmsOrderApi.java

@ -14,18 +14,17 @@ import com.qs.serve.modules.bms.entity.BmsSupplierAddress;
import com.qs.serve.modules.bms.mapper.BmsSupplierMapper;
import com.qs.serve.modules.bms.service.BmsSupplierAddressService;
import com.qs.serve.modules.goods.entity.GoodsCategory;
import com.qs.serve.modules.goods.entity.GoodsImminentBatch;
import com.qs.serve.modules.goods.entity.GoodsSku;
import com.qs.serve.modules.goods.entity.GoodsSpu;
import com.qs.serve.modules.goods.mapper.GoodsImminentBatchMapper;
import com.qs.serve.modules.goods.service.GoodsCategoryRuleService;
import com.qs.serve.modules.goods.service.GoodsCategoryService;
import com.qs.serve.modules.goods.service.GoodsSkuService;
import com.qs.serve.modules.goods.service.GoodsSpuService;
import com.qs.serve.modules.oms.entity.OmsOrder;
import com.qs.serve.modules.oms.entity.OmsOrderItem;
import com.qs.serve.modules.oms.entity.bo.OmsCancelOrder;
import com.qs.serve.modules.oms.entity.bo.OmsOrderBo;
import com.qs.serve.modules.oms.entity.bo.OmsOrderModifyParam;
import com.qs.serve.modules.oms.entity.bo.OmsOrderSkuBo;
import com.qs.serve.modules.oms.entity.bo.*;
import com.qs.serve.modules.oms.entity.vo.OmsConfirmOrderResult;
import com.qs.serve.modules.oms.service.OmsOrderItemService;
import com.qs.serve.modules.oms.service.OmsOrderService;
@ -43,8 +42,6 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static com.qs.serve.modules.tbs.common.TbsSeeYonConst.ERP_ORDER_STATUS;
/**
* API订单模块 订单
* @author YenHex
@ -67,6 +64,7 @@ public class OmsOrderApi {
private GoodsCategoryService goodsCategoryService;
private SysPostUserService postUserService;
private SeeYonRequestBaseService seeYonRequestBaseService;
private GoodsImminentBatchMapper goodsImminentBatchMapper;
/**
* 确认订单
@ -263,6 +261,9 @@ public class OmsOrderApi {
orderItem.setSkuBelong(goodsSku.getBelong());
orderItem.setSkuAddCode(goodsSku.getSkuAddCode());
}
if(orderItem.getSkuBatchId()!=null){
orderItem.setBatchInfo(goodsImminentBatchMapper.selectById(orderItem.getSkuBatchId()));
}
}
omsOrder.setOrderItems(list);
return R.ok(omsOrder);
@ -301,7 +302,7 @@ public class OmsOrderApi {
}
/**
* 删除
* 删除订单
* @param id
* @return
*/
@ -317,5 +318,26 @@ public class OmsOrderApi {
return R.error("当前状态无法删除");
}
/**
* 创建临期品订单
* @param omsOrderBo
* @return
*/
@PostMapping("/createImminentOrder")
public R<OmsOrder> createImminentOrder(@RequestBody @Valid OmsOrderImminentBo omsOrderBo){
return R.ok(omsOrderService.modifyImminentOrder(omsOrderBo));
}
/**
* 修改临期品的订单
* @param param
* @return
*/
@PostMapping("/modifyImminentOrder")
public R<OmsOrder> modifyImminentOrder(@RequestBody @Valid OmsOrderImminentBo param){
omsOrderService.modifyImminentOrder(param);
return R.ok();
}
}

2
src/main/java/com/qs/serve/modules/oms/entity/OmsOrder.java

@ -39,7 +39,7 @@ public class OmsOrder implements Serializable {
@TableField(condition = SqlCondition.LIKE)
private String orderSn;
/** 订单类型:0->普通订单;1->赠品;2->试吃品 */
/** 订单类型:0->普通订单;1->赠品;2->试吃品;3->临期品 */
private Integer orderType;
private String orderSource;

11
src/main/java/com/qs/serve/modules/oms/entity/OmsOrderItem.java

@ -51,7 +51,12 @@ public class OmsOrderItem implements Serializable {
private String skuTitle;
/** skuId */
/** skuBatchId */
private Long skuBatchId;
/** skuBatchCode */
private String skuBatchCode;
private Long skuId;
/** sku编码 */
@ -141,6 +146,10 @@ public class OmsOrderItem implements Serializable {
@TableField(exist = false)
private Object categoryInfo;
/** 分类 */
@TableField(exist = false)
private Object batchInfo;
@TableField(exist = false)
private Integer skuSpecialFlag;
}

58
src/main/java/com/qs/serve/modules/oms/entity/bo/OmsOrderImminentBo.java

@ -0,0 +1,58 @@
package com.qs.serve.modules.oms.entity.bo;
import lombok.Data;
import java.util.List;
/**
* @author YenHex
* @since 2022/10/14
*/
@Data
public class OmsOrderImminentBo {
/** 编辑时必填 */
private String id;
private String supplierId;
private String orderSource;
/** SKU下单列表 */
private List<OmsOrderImminentBo.ItemParam> itemList;
/** 品牌规则ID */
private Long brandRuleId;
/** 立刻下单标识 */
private Integer instantFlag;
/** CD单据备注 */
private String cdOrderRemark;
/** 收货地址 */
private Long addressId;
/** 发票类型:0->普通发票;1->增值税发票; */
private Integer billType;
/** 是否加急 */
private Integer urgentFlag;
/** 备注 */
private String remark;
@Data
public static class ItemParam{
private Long batchSkuId;
/** 数量 */
private Integer qty;
private String remark;
}
}

12
src/main/java/com/qs/serve/modules/oms/service/OmsOrderService.java

@ -2,10 +2,7 @@ package com.qs.serve.modules.oms.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.qs.serve.modules.oms.entity.OmsOrder;
import com.qs.serve.modules.oms.entity.bo.OmsOrderBo;
import com.qs.serve.modules.oms.entity.bo.OmsOrderModifyParam;
import com.qs.serve.modules.oms.entity.bo.OmsOrderSkuBo;
import com.qs.serve.modules.oms.entity.bo.OmsSpuAssesInfoBo;
import com.qs.serve.modules.oms.entity.bo.*;
import com.qs.serve.modules.oms.entity.vo.OmsConfirmOrderResult;
import com.qs.serve.modules.oms.entity.vo.OmsSpuAssesInfo;
@ -74,5 +71,12 @@ public interface OmsOrderService extends IService<OmsOrder> {
*/
void buildPriceOrder(String id,String amount);
/**
* 临期品订单
* @param param
* @return
*/
OmsOrder modifyImminentOrder(OmsOrderImminentBo param);
}

214
src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java

@ -46,6 +46,7 @@ import com.qs.serve.modules.oms.mapper.OmsOrderMapper;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
@ -82,6 +83,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im
private SeeYonRequestBaseService seeYonRequestBaseService;
private GoodsRuleService goodsRuleService;
private GoodsAccreditService goodsAccreditService;
private GoodsImminentBatchService goodsImminentBatchService;
@Override
@ -333,35 +335,11 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im
//防止空指针
skuCodes.add("NULL");
List<GoodsCustomerPrice> customerPrices = goodsCustomerPriceService.getBySupplierCodeAndCode(supplier.getCode(),skuCodes);
for (OmsOrderItem orderItem : newOrderItemList) {
for (GoodsCustomerPrice customerPrice : customerPrices) {
if(orderItem.getSkuCode().equals(customerPrice.getSkuCode())){
orderItem.setSalesPrice(customerPrice.getRealPrice());
break;
}
}
}
//商品特殊价
this.buildSkuSpecPrice(supplier, newOrderItemList, skuCodes);
//拦截商品授权维度规则
GoodsAccrIdsDto accrIdsDto = goodsAccreditService.listIgnoreAcc2(supplier.getId(),supplier.listBizRegionIds(),supplier.listSaleRegionIds());
if(accrIdsDto!=null){
List<Long> skuIds = goodsSkuMapper.listByOtherIds(
accrIdsDto.getCateIds(),
accrIdsDto.getSpuIds(),
accrIdsDto.getSkuIds(),
accrIdsDto.getNotInCateIds(),
accrIdsDto.getNotInSpuIds(),
accrIdsDto.getNotInSkuIds()
);
for (OmsOrderItem orderItem : newOrderItemList) {
for (Long skuId : skuIds) {
if(orderItem.getSkuId().equals(skuId)){
Assert.throwEx("商品未授权:"+orderItem.getSkuCode());
}
}
}
}
this.checkGoodsRule(supplier, newOrderItemList);
//拦截客户维度规则
goodsRuleService.checkSkuCode(skuCodes,goodsRuleService.listBySupplierId(order.getSupplierId().toString()),true);
@ -382,6 +360,27 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im
}
}
private void checkGoodsRule(BmsSupplier supplier, List<OmsOrderItem> newOrderItemList) {
GoodsAccrIdsDto accrIdsDto = goodsAccreditService.listIgnoreAcc2(supplier.getId(), supplier.listBizRegionIds(), supplier.listSaleRegionIds());
if(accrIdsDto!=null){
List<Long> skuIds = goodsSkuMapper.listByOtherIds(
accrIdsDto.getCateIds(),
accrIdsDto.getSpuIds(),
accrIdsDto.getSkuIds(),
accrIdsDto.getNotInCateIds(),
accrIdsDto.getNotInSpuIds(),
accrIdsDto.getNotInSkuIds()
);
for (OmsOrderItem orderItem : newOrderItemList) {
for (Long skuId : skuIds) {
if(orderItem.getSkuId().equals(skuId)){
Assert.throwEx("商品未授权:"+orderItem.getSkuCode());
}
}
}
}
}
/**
* 拦截规则
* @param categoryRule
@ -640,6 +639,164 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im
return spuAssesInfoList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public OmsOrder modifyImminentOrder(OmsOrderImminentBo param) {
SysUser user = sysUserService.getById(AuthContextUtils.getSysUserId());
GoodsCategoryRule categoryRule = goodsCategoryRuleMapper.selectById(param.getBrandRuleId());
BmsSupplier supplier = bmsSupplierMapper.selectById(param.getSupplierId());
BmsSupplierAddress supplierDefaultAddress = bmsSupplierAddressService.getDefault(Long.parseLong(supplier.getId()));
OmsOrder order;
if(param.getId()!=null){
order = this.getById(param.getId());
if(!order.getOrderType().equals(3)){
Assert.throwEx("订单类型不支持混用");
}
}else {
order = new OmsOrder();
order.setOrderSn("SP"+CodeGenUtil.generate(CodeGenUtil.SourceKey.OmsOrder));
}
order.setLatitudeFrom("sp");
order.setCdOrderRemark(param.getCdOrderRemark());
order.setOrderType(3);
order.setSupplierId(Long.parseLong(supplier.getId()));
order.setSupplierCode(supplier.getCode());
order.setSupplierName(supplier.getName());
order.setSupplierAddrId(supplierDefaultAddress!=null?supplierDefaultAddress.getId():0);
order.setBrandRuleId(param.getBrandRuleId());
order.setUserId(user.getId());
order.setUserName(user.getName());
order.setUserCode(user.getCode());
order.setUserPhone(user.getMobile());
order.setBillType(param.getBillType());
order.setUrgentFlag(param.getUrgentFlag());
order.setRemark(param.getRemark());
this.saveOrUpdate(order);
if(order.getStatus()==null||order.getStatus().equals(0)){
if(CollectionUtil.isEmpty(param.getItemList())){
return order;
}
}
Set<Long> batchSkuIds = param.getItemList().stream().map(OmsOrderImminentBo.ItemParam::getBatchSkuId)
.collect(Collectors.toSet());
if(CollectionUtil.isEmpty(param.getItemList())){
Assert.throwEx("请选择商品");
}
List<GoodsImminentBatch> imminentBatches = goodsImminentBatchService
.list(
new LambdaQueryWrapper<GoodsImminentBatch>()
.in(GoodsImminentBatch::getId,batchSkuIds)
.ge(GoodsImminentBatch::getEndDate, LocalDate.now())
);
if(CollectionUtil.isEmpty(imminentBatches)){
Assert.throwEx("参数过期或无效,请重新选择商品");
}
Set<String> skuIds = imminentBatches.stream()
.map(GoodsImminentBatch::getSkuId).collect(Collectors.toSet());
if(skuIds.size()!=imminentBatches.size()){
Assert.throwEx("不同批次相同产品,请分开下单");
}
List<GoodsSku> goodsSkuList = goodsSkuService.listByIds(skuIds);
List<Long> spuIds = goodsSkuList.stream().map(GoodsSku::getSpuId).collect(Collectors.toList());
spuIds.add(0L);
List<GoodsSpu> spuList = goodsSpuService.listByIds(spuIds);
List<OmsOrderItem> orderItems = new ArrayList<>();
for (OmsOrderImminentBo.ItemParam item : param.getItemList()) {
for (GoodsImminentBatch batch : imminentBatches) {
if(item.getBatchSkuId().equals(batch.getId())){
for (GoodsSku sku : goodsSkuList) {
if(sku.getId().toString().equals(batch.getSkuId())){
//创建OrderItem
OmsOrderItem orderItem = createImminentOrderItem(order, spuList, item, batch, sku);
orderItems.add(orderItem);
}
}
}
}
}
List<String> skuCodes = orderItems.stream()
.map(OmsOrderItem::getSkuCode).collect(Collectors.toList());
//商品特殊价
buildSkuSpecPrice(supplier, orderItems, skuCodes);
//拦截商品授权维度规则
this.checkGoodsRule(supplier, orderItems);
//拦截客户维度规则
goodsRuleService.checkSkuCode(skuCodes,goodsRuleService.listBySupplierId(order.getSupplierId().toString()),true);
//拦截品类下单规则
this.handleCategoryRule(categoryRule,orderItems);
this.updateById(order);
//移除已有的ITEM
LambdaQueryWrapper<OmsOrderItem> rmItemLqw = new LambdaQueryWrapper<>();
rmItemLqw.eq(OmsOrderItem::getOrderId,param.getId());
omsOrderItemService.remove(rmItemLqw);
//重新保存item
omsOrderItemService.saveBatch(orderItems);
//立即下单
if(param.getInstantFlag()!=null&&param.getInstantFlag().equals(1)){
this.buildPriceOrder(order.getId()+"",null);
}
return order;
}
@NotNull
private OmsOrderItem createImminentOrderItem(OmsOrder order, List<GoodsSpu> spuList, OmsOrderImminentBo.ItemParam item, GoodsImminentBatch batch, GoodsSku sku) {
OmsOrderItem orderItem = new OmsOrderItem();
orderItem.setRemark(item.getRemark());
orderItem.setQuantity(item.getQty());
orderItem.setOrderId(order.getId());
orderItem.setOrderSn(order.getOrderSn());
orderItem.setSpuId(sku.getSpuId());
for (GoodsSpu spu : spuList) {
if(sku.getSpuId().equals(spu.getId())){
orderItem.setSpuCode(spu.getSpuCode());
orderItem.setSpuTitle(spu.getName());
break;
}
}
orderItem.setWeight(sku.getWeight());
orderItem.setVolume(sku.getVolume());
orderItem.setSkuBatchId(batch.getId());
orderItem.setSkuBatchCode(batch.getBatchCode());
orderItem.setSkuId(sku.getId());
orderItem.setSkuTitle(sku.getSkuName());
orderItem.setSkuCode(sku.getSkuCode());
orderItem.setSpecValues(sku.getSpecInfos());
orderItem.setSkuUnit(sku.getUnitName());
orderItem.setSkuImg(sku.getPicUrl());
orderItem.setSalesPrice(sku.getSalesPrice());
orderItem.setCusPrice(sku.getSalesPrice());
orderItem.setMarketPrice(sku.getMarketPrice());
return orderItem;
}
private void buildSkuSpecPrice(BmsSupplier supplier, List<OmsOrderItem> orderItems, List<String> skuCodes) {
List<GoodsCustomerPrice> customerPrices = goodsCustomerPriceService.getBySupplierCodeAndCode(supplier.getCode(), skuCodes);
for (OmsOrderItem orderItem : orderItems) {
for (GoodsCustomerPrice customerPrice : customerPrices) {
if (orderItem.getSkuCode().equals(customerPrice.getSkuCode())) {
orderItem.setSalesPrice(customerPrice.getRealPrice());
break;
}
}
}
}
@Override
public void buildPriceOrder(String id,String amount) {
OmsOrder omsOrder = super.getById(id);
@ -655,6 +812,9 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper,OmsOrder> im
if(!omsOrder.getStatus().equals(0)&&!omsOrder.getStatus().equals(6)){
Assert.throwEx("订单状态不支持下单");
}
if(omsOrder.getOrderType().equals(3)){
Assert.throwEx("临期品订单不支持该接口修改");
}
LambdaQueryWrapper<OmsOrderItem> iteLqw = new LambdaQueryWrapper<>();
iteLqw.eq(OmsOrderItem::getOrderId,id);
List<OmsOrderItem> orderItemList = omsOrderItemService.list(iteLqw);

4
src/main/java/com/qs/serve/modules/tbs/controller/TbsActivityController2.java

@ -76,7 +76,7 @@ public class TbsActivityController2 {
* @param param
* @return
*/
@PostMapping("/getByIds/{ids}")
@PostMapping("/getByIds")
public R<List<TbsActivity>> getByIds(@RequestBody CommonIdsParam param){
List<TbsActivity> activityList = tbsActivityService.listByIds(param.getIds());
for (TbsActivity activity : activityList) {
@ -94,7 +94,7 @@ public class TbsActivityController2 {
@GetMapping("/flushAmount/{id}")
@SysLog(module = SystemModule.Budget, title = "费用活动", biz = BizType.DELETE)
public R<?> flushActivityAmount(@PathVariable("id") Long id){
Long[] ids = new Long[]{};
Long[] ids = new Long[]{id};
List<Long> errorIds = new ArrayList<>();
for (Long aLong : ids) {
try {

270
src/main/resources/mapper/goods/GoodsImminentBatchMapper.xml

@ -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…
Cancel
Save