浏览代码

add:商城商品分类 二级

liujunchi 3 年之前
父节点
当前提交
30768b2a17

+ 8 - 1
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/component/CancelOrderReceiver.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.portal.component;
 
 import com.yonge.cooleshow.portal.service.OmsPortalOrderService;
+import com.yonge.toolset.base.exception.BizException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.amqp.rabbit.annotation.RabbitHandler;
@@ -20,7 +21,13 @@ public class CancelOrderReceiver {
     private OmsPortalOrderService portalOrderService;
     @RabbitHandler
     public void handle(Long orderId){
-        portalOrderService.cancelOrder(orderId, "超时取消", null);
+        try {
+            portalOrderService.cancelOrder(orderId, "超时取消", null);
+
+        } catch (BizException e) {
+            e.printStackTrace();
+            logger.warn(e.getLocalizedMessage());
+        }
         logger.info("process orderId:{}", orderId);
     }
 }

+ 26 - 0
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/dto/ProductCategorySmallVo.java

@@ -3,6 +3,9 @@ package com.yonge.cooleshow.portal.dto;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Description
  *
@@ -14,6 +17,9 @@ public class ProductCategorySmallVo {
 
     private Long id;
 
+    @ApiModelProperty("上级id")
+    private Long parentId;
+
     @ApiModelProperty("名称")
     private String name;
 
@@ -23,6 +29,26 @@ public class ProductCategorySmallVo {
     @ApiModelProperty(value = "描述")
     private String description;
 
+    @ApiModelProperty("下级类型")
+    private List<ProductCategorySmallVo> children = new ArrayList<>();
+
+
+    public Long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    public List<ProductCategorySmallVo> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<ProductCategorySmallVo> children) {
+        this.children = children;
+    }
+
     public Long getId() {
         return id;
     }

+ 24 - 9
cooleshow-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/service/impl/PmsPortalProductServiceImpl.java

@@ -20,7 +20,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * 前台订单管理Service实现类
@@ -200,22 +199,38 @@ public class PmsPortalProductServiceImpl implements PmsPortalProductService {
         }
         return pmsProductCategories;
     }
+
     private List<ProductCategorySmallVo> getProductCategoryList() {
         PmsProductCategoryExample example = new PmsProductCategoryExample();
         example.setOrderByClause("sort desc");
-        example.createCriteria().andParentIdEqualTo(0L)
+        example.createCriteria()
                .andShowStatusEqualTo(1);
         List<PmsProductCategory> pmsProductCategories = productCategoryMapper.selectByExample(example);
         if (CollectionUtils.isEmpty(pmsProductCategories)) {
             return new ArrayList<>();
         }
-        return pmsProductCategories.stream()
-                                   .map( pmsProductCategory ->  {
-                                       ProductCategorySmallVo productCategorySmallVo = new ProductCategorySmallVo();
-                                       BeanUtils.copyProperties(pmsProductCategory,productCategorySmallVo);
-                                       return productCategorySmallVo;
-                                   })
-                                   .collect(Collectors.toList());
+        List<ProductCategorySmallVo> collect = pmsProductCategories.stream().map(pmsProductCategory -> {
+            ProductCategorySmallVo productCategorySmallVo = new ProductCategorySmallVo();
+            BeanUtils.copyProperties(pmsProductCategory, productCategorySmallVo);
+            return productCategorySmallVo;
+        }).collect(Collectors.toList());
+
+        List<ProductCategorySmallVo> tree = new ArrayList<>();
+        for (ProductCategorySmallVo categorySmallVo : collect) {
+            if (categorySmallVo.getParentId() == null || categorySmallVo.getParentId() == 0) {
+                tree.add(categorySmallVo);
+            }
+            for (ProductCategorySmallVo tagVo : collect) {
+                if (tagVo.getParentId() != null && tagVo.getParentId() != 0 && tagVo.getParentId().equals(categorySmallVo.getId())) {
+                    if (categorySmallVo.getChildren() == null) {
+                        categorySmallVo.setChildren(new ArrayList<>());
+                    }
+                    categorySmallVo.getChildren().add(tagVo);
+                }
+
+            }
+        }
+        return tree;
     }
 
     private List<PmsBrand> getBrandList() {

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/MusicSheetServiceImpl.java

@@ -555,7 +555,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao,MusicSheet>
         musicSheetPurchaseRecord.setMusicSheetServiceFee(serviceFeeAmount);
         musicSheetPurchaseRecord.setOrderStatus(OrderStatusEnum.PAID);
         musicSheetPurchaseRecord.setStudentId(userOrderDetailVo.getUserId());
-        musicSheetPurchaseRecordService.save(musicSheetPurchaseRecord);
+        musicSheetPurchaseRecordService.saveOrUpdate(musicSheetPurchaseRecord);
     }
 
     /**
@@ -596,7 +596,7 @@ public class MusicSheetServiceImpl extends ServiceImpl<MusicSheetDao,MusicSheet>
         musicSheetPurchaseRecord.setOriginalPrice(userOrderDetailVo.getOriginalPrice());
         musicSheetPurchaseRecord.setOrderStatus(OrderStatusEnum.WAIT_PAY);
         musicSheetPurchaseRecord.setStudentId(userOrderDetailVo.getUserId());
-        musicSheetPurchaseRecordService.save(musicSheetPurchaseRecord);
+        musicSheetPurchaseRecordService.saveOrUpdate(musicSheetPurchaseRecord);
     }
 
     @Override