Browse Source

fix: 订单规则修复;feat: 商品分类统计

muti_db
Yen 11 months ago
parent
commit
d6e4d5399e
  1. 16
      src/main/java/com/qs/serve/common/model/dto/SimpleCountValue.java
  2. 20
      src/main/java/com/qs/serve/modules/goods/controller/GoodsCategoryController.java
  3. 2
      src/main/java/com/qs/serve/modules/goods/entity/bo/GoodsCategoryTreeVo.java
  4. 12
      src/main/java/com/qs/serve/modules/goods/mapper/GoodsCategoryMapper.java
  5. 25
      src/main/java/com/qs/serve/modules/oms/service/impl/OmsOrderServiceImpl.java

16
src/main/java/com/qs/serve/common/model/dto/SimpleCountValue.java

@ -0,0 +1,16 @@
package com.qs.serve.common.model.dto;
import lombok.Data;
/**
* @author YenHex
* @since 2024/8/29
*/
@Data
public class SimpleCountValue {
String id;
Long count;
}

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

@ -6,6 +6,7 @@ import com.qs.serve.common.config.DevEnvironmentConfig;
import com.qs.serve.common.model.annotation.SysLog; import com.qs.serve.common.model.annotation.SysLog;
import com.qs.serve.common.model.dto.PageVo; import com.qs.serve.common.model.dto.PageVo;
import com.qs.serve.common.model.dto.R; import com.qs.serve.common.model.dto.R;
import com.qs.serve.common.model.dto.SimpleCountValue;
import com.qs.serve.common.model.enums.BizType; import com.qs.serve.common.model.enums.BizType;
import com.qs.serve.common.model.enums.SystemModule; import com.qs.serve.common.model.enums.SystemModule;
import com.qs.serve.common.util.*; import com.qs.serve.common.util.*;
@ -14,6 +15,7 @@ import com.qs.serve.modules.goods.entity.GoodsSpu;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryBo; import com.qs.serve.modules.goods.entity.bo.GoodsCategoryBo;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryLevelBo; import com.qs.serve.modules.goods.entity.bo.GoodsCategoryLevelBo;
import com.qs.serve.modules.goods.entity.bo.GoodsCategoryTreeVo; import com.qs.serve.modules.goods.entity.bo.GoodsCategoryTreeVo;
import com.qs.serve.modules.goods.mapper.GoodsCategoryMapper;
import com.qs.serve.modules.goods.service.GoodsSpuService; import com.qs.serve.modules.goods.service.GoodsSpuService;
import com.qs.serve.modules.tbs.common.TbsGoodsType; import com.qs.serve.modules.tbs.common.TbsGoodsType;
import com.qs.serve.modules.tbs.entity.TbsActivityGoods; import com.qs.serve.modules.tbs.entity.TbsActivityGoods;
@ -43,6 +45,7 @@ import java.util.stream.Collectors;
@RequestMapping("goods/category") @RequestMapping("goods/category")
public class GoodsCategoryController { public class GoodsCategoryController {
private GoodsCategoryMapper goodsCategoryMapper;
private GoodsCategoryService goodsCategoryService; private GoodsCategoryService goodsCategoryService;
private GoodsSpuService goodsSpuService; private GoodsSpuService goodsSpuService;
private TbsActivityGoodsService activityGoodsService; private TbsActivityGoodsService activityGoodsService;
@ -141,6 +144,14 @@ public class GoodsCategoryController {
} }
List<GoodsCategory> list = goodsCategoryService.list(lqw); List<GoodsCategory> list = goodsCategoryService.list(lqw);
//统计Spu数量
List<SimpleCountValue> cateCountList = goodsCategoryMapper.selectCateCountFirst();
List<SimpleCountValue> cateCountSecond = goodsCategoryMapper.selectCateCountSecond();
List<SimpleCountValue> cateCountLast = goodsCategoryMapper.selectCateCountLast();
cateCountList.addAll(cateCountSecond);
cateCountList.addAll(cateCountLast);
List<GoodsCategoryTreeVo> treeVoList = list.stream().map(cate->{ List<GoodsCategoryTreeVo> treeVoList = list.stream().map(cate->{
GoodsCategoryTreeVo treeNode = CopierUtil.copy(cate,new GoodsCategoryTreeVo()); GoodsCategoryTreeVo treeNode = CopierUtil.copy(cate,new GoodsCategoryTreeVo());
if(param.getRelateBrandFlag()!=null&&param.getRelateBrandFlag().equals(1)){ if(param.getRelateBrandFlag()!=null&&param.getRelateBrandFlag().equals(1)){
@ -152,6 +163,15 @@ public class GoodsCategoryController {
treeNode.setCostFlag(cate.getCostFlag()); treeNode.setCostFlag(cate.getCostFlag());
treeNode.setSort(cate.getSort()==null ? 0 : cate.getSort()); treeNode.setSort(cate.getSort()==null ? 0 : cate.getSort());
treeNode.setEnable(cate.getEnable()+""); treeNode.setEnable(cate.getEnable()+"");
//绑定统计Spu数量
for (SimpleCountValue countValue : cateCountList) {
if(treeNode.getId().equals(countValue.getId())){
treeNode.setCountSpu(countValue.getCount());
break;
}
}
if(loadSpuData && cate.getLevel().equals(3)){ if(loadSpuData && cate.getLevel().equals(3)){
LambdaQueryWrapper<GoodsSpu> spuLqw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<GoodsSpu> spuLqw = new LambdaQueryWrapper<>();
spuLqw.eq(GoodsSpu::getCategoryThird,cate.getId( )); spuLqw.eq(GoodsSpu::getCategoryThird,cate.getId( ));

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

@ -64,4 +64,6 @@ public class GoodsCategoryTreeVo extends TreeNode {
/** 可投放费用标识 */ /** 可投放费用标识 */
private Integer costFlag; private Integer costFlag;
private long countSpu = 0;
} }

12
src/main/java/com/qs/serve/modules/goods/mapper/GoodsCategoryMapper.java

@ -2,11 +2,14 @@ package com.qs.serve.modules.goods.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qs.serve.common.model.dto.SimpleCountValue;
import com.qs.serve.modules.goods.entity.GoodsCategory; import com.qs.serve.modules.goods.entity.GoodsCategory;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import java.util.List;
/** /**
* 分类 Mapper * 分类 Mapper
* @author YenHex * @author YenHex
@ -14,6 +17,15 @@ import org.apache.ibatis.annotations.Update;
*/ */
public interface GoodsCategoryMapper extends BaseMapper<GoodsCategory> { public interface GoodsCategoryMapper extends BaseMapper<GoodsCategory> {
@Select("SELECT COUNT(1) as count ,category_last as id FROM `goods_spu` where del_flag = 0 group by category_last ")
List<SimpleCountValue> selectCateCountLast();
@Select("SELECT COUNT(1) as count ,category_second as id FROM `goods_spu` where del_flag = 0 group by category_second ")
List<SimpleCountValue> selectCateCountSecond();
@Select("SELECT COUNT(1) as count ,category_first as id FROM `goods_spu` where del_flag = 0 group by category_first ")
List<SimpleCountValue> selectCateCountFirst();
@Update("update goods_category set del_flag = 1 , `code`= #{obj.code} where id = #{obj.id}") @Update("update goods_category set del_flag = 1 , `code`= #{obj.code} where id = #{obj.id}")
int deleteByCate(@Param("obj") GoodsCategory entity); int deleteByCate(@Param("obj") GoodsCategory entity);

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

@ -431,10 +431,26 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
matchIgnoreCate(igcids, goodsSpu.getCategoryFirst(), goodsSpu); matchIgnoreCate(igcids, goodsSpu.getCategoryFirst(), goodsSpu);
matchIgnoreCate(igcids, goodsSpu.getCategorySecond(), goodsSpu); matchIgnoreCate(igcids, goodsSpu.getCategorySecond(), goodsSpu);
matchIgnoreCate(igcids, goodsSpu.getCategoryThird(), goodsSpu); matchIgnoreCate(igcids, goodsSpu.getCategoryThird(), goodsSpu);
matchRuleCate(cids, goodsSpu);
} }
} }
} }
private void matchRuleCate(List<String> cids, GoodsSpu goodsSpu) {
boolean isOk = false;
for (String cid : cids) {
if(cid.equals(goodsSpu.getCategoryFirst())||
cid.equals(goodsSpu.getCategorySecond())||
cid.equals(goodsSpu.getCategoryThird())){
isOk = true;
break;
}
}
if(!isOk){
Assert.throwEx("不符合下单规则:"+ goodsSpu.getSpuCode());
}
}
@Override @Override
public List<SimpleKeyValue> handleCategoryRule(List<Long> skuIds,GoodsCategoryRule categoryRule) { public List<SimpleKeyValue> handleCategoryRule(List<Long> skuIds,GoodsCategoryRule categoryRule) {
@ -484,6 +500,8 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
matchIgnoreCate(igcids, goodsSpu.getCategoryFirst(), goodsSpu); matchIgnoreCate(igcids, goodsSpu.getCategoryFirst(), goodsSpu);
matchIgnoreCate(igcids, goodsSpu.getCategorySecond(), goodsSpu); matchIgnoreCate(igcids, goodsSpu.getCategorySecond(), goodsSpu);
matchIgnoreCate(igcids, goodsSpu.getCategoryThird(), goodsSpu); matchIgnoreCate(igcids, goodsSpu.getCategoryThird(), goodsSpu);
matchRuleCate(cids, goodsSpu);
} }
} }
return errSkuIds; return errSkuIds;
@ -908,9 +926,9 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
Assert.throwEx("非制单人无法下单"); Assert.throwEx("非制单人无法下单");
} }
// 非临期品不走当前流程 // 非临期品不走当前流程
if(omsOrder.getOrderType().equals(3)){ // if(omsOrder.getOrderType().equals(3)){
Assert.throwEx("临期品需要审批方式下单"); // Assert.throwEx("临期品需要审批方式下单");
} // }
this.checkMsOrderStatus(omsOrder); this.checkMsOrderStatus(omsOrder);
if (!omsOrder.getStatus().equals(0) && !omsOrder.getStatus().equals(6)) { if (!omsOrder.getStatus().equals(0) && !omsOrder.getStatus().equals(6)) {
Assert.throwEx("订单状态不支持下单"); Assert.throwEx("订单状态不支持下单");
@ -927,6 +945,7 @@ public class OmsOrderServiceImpl extends ServiceImpl<OmsOrderMapper, OmsOrder> i
this.handleCategoryRule(categoryRule, orderItemList); this.handleCategoryRule(categoryRule, orderItemList);
String brands = Arrays.stream(categoryRule.getBrandNames()).collect(Collectors.joining(",")); String brands = Arrays.stream(categoryRule.getBrandNames()).collect(Collectors.joining(","));
//List<Long> spuIds = orderItemList.stream().map(OmsOrderItem::getSpuId).collect(Collectors.toList()); //List<Long> spuIds = orderItemList.stream().map(OmsOrderItem::getSpuId).collect(Collectors.toList());

Loading…
Cancel
Save