Эх сурвалжийг харах

Merge remote-tracking branch 'origin/master'

wangming 2 өдөр өмнө
parent
commit
52041445c1

+ 4 - 4
yami-shop-bean/src/main/java/com/yami/shop/bean/app/dto/ApiOrderRefundDto.java

@@ -41,7 +41,7 @@ public class ApiOrderRefundDto {
     private Integer goodsNum;
 
     @ApiModelProperty("退款金额")
-    private Double refundAmount;
+    private Double refundAmount=0.0;
 
     @ApiModelProperty("退还积分")
     private Integer refundScore;
@@ -116,13 +116,13 @@ public class ApiOrderRefundDto {
     private Double freightAmount;
 
     @ApiModelProperty("积分")
-    private Long offsetPoints;
+    private Long offsetPoints=0L;
 
     @ApiModelProperty("商品总额")
-    private Double goodsTotal;
+    private Double goodsTotal=0.0;
 
     @ApiModelProperty("过期的积分")
-    private Long refundExpiredScore;;
+    private Long refundExpiredScore=0L;
     /*
 ac
     @ApiModelProperty("物流公司名称")

+ 1 - 1
yami-shop-bean/src/main/java/com/yami/shop/bean/model/ShopCategory.java

@@ -92,7 +92,7 @@ public class ShopCategory implements Serializable {
     /**
      * 标签
      */
-    private String label;
+    private Long label;
 
     /**
      * 子类名称(导入时处理需要)

+ 11 - 0
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/hb/FrontCategoryController.java

@@ -1,12 +1,15 @@
 package com.yami.shop.platform.controller.hb;
 
 import com.alibaba.fastjson.JSONObject;
+import com.yami.shop.bean.model.FrontCategory;
 import com.yami.shop.common.util.hb.HBR;
 import com.yami.shop.service.hb.IHBFrontCategoryService;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * 海博-前台类目管理
  *
@@ -60,4 +63,12 @@ public class FrontCategoryController {
     }
 
 
+    /**
+     * 通过门店shopId和hbShopId同步全部前台类目
+     */
+    @GetMapping("/sync")
+    public void sync(Long shopId, Long hbShopId) {
+        frontCategoryService.sync(shopId, hbShopId);
+    }
+
 }

+ 14 - 0
yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBFrontCategoryService.java

@@ -1,6 +1,7 @@
 package com.yami.shop.service.hb;
 
 import com.alibaba.fastjson.JSONObject;
+import com.yami.shop.bean.model.FrontCategory;
 import com.yami.shop.common.util.hb.HBR;
 
 /**
@@ -26,4 +27,17 @@ public interface IHBFrontCategoryService {
      * @param hbRequest
      */
     void deleteFrontCategory(JSONObject hbRequest);
+
+    /**
+     * 添加门店分类
+     * @param frontCategory 前台分类
+     * @param shopId 门店id
+     * @param hbShopId 海博门店id
+     */
+    void addShopCategory(FrontCategory frontCategory, Long shopId, Long hbShopId);
+
+    /**
+     * 同步对应门店
+     */
+    void sync( Long shopId, Long hbShopId);
 }

+ 70 - 9
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBFrontCategoryService.java

@@ -35,7 +35,6 @@ import static com.yami.shop.common.util.HttpUtil.post;
 @Slf4j
 @Service
 @AllArgsConstructor
-@Transactional(readOnly = true)
 public class HBFrontCategoryService implements IHBFrontCategoryService {
     private final FrontCategoryMapper frontCategoryMapper;
     private final ShopCategoryMapper shopCategoryMapper;
@@ -80,22 +79,20 @@ public class HBFrontCategoryService implements IHBFrontCategoryService {
                         .eq(FrontCategory::getIsDelete, 0));
                 if (frontCategory1 == null) {
                     frontCategoryMapper.insert(frontCategory);
+
+                    //添加门店分类
+                    addShopCategory(frontCategory, 1L, 5104238L);
                 } else {
                     frontCategory.setId(frontCategory1.getId());
                     frontCategoryMapper.updateById(frontCategory);
-
-                    //修改门店分类里面对应的
-                    List<ShopCategory> shopCategory = shopCategoryMapper.selectList(new LambdaQueryWrapper<ShopCategory>().eq(ShopCategory::getCode, frontCategory.getCode())
-                    .eq(ShopCategory::getIsDelete, 0));
+                    List<ShopCategory> shopCategory = shopCategoryMapper.selectList(new LambdaQueryWrapper<ShopCategory>()
+                            .eq(ShopCategory::getCode, frontCategory.getCode())
+                            .eq(ShopCategory::getIsDelete, 0));
                     for (ShopCategory shopCategory1 : shopCategory) {
                         shopCategory1.setName(frontCategory.getName());
                         shopCategoryMapper.updateById(shopCategory1);
                     }
-
-
                 }
-                // 3. 保存门店信息
-//                frontCategoryMapper.insert(frontCategory);
             }
             log.info("前台分类成功");
             // 4. 构建响应
@@ -106,6 +103,70 @@ public class HBFrontCategoryService implements IHBFrontCategoryService {
         }
     }
 
+    /**
+     * 添加门店分类
+     *
+     * @param frontCategory 前台分类
+     * @param shopId        门店id
+     * @return
+     */
+    @Override
+    //添加事务
+    @Transactional(rollbackFor = Exception.class)
+    public void addShopCategory(FrontCategory frontCategory, Long shopId, Long hbShopId) {
+        ShopCategory shopCategoryByCode = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
+                .eq(ShopCategory::getCode, frontCategory.getCode())
+                .eq(ShopCategory::getShopId, shopId)
+                .eq(ShopCategory::getIsDelete, 0));
+
+        if (shopCategoryByCode != null) {
+            return;
+        }
+        ShopCategory shopCategory = new ShopCategory();
+        shopCategory.setCode(frontCategory.getCode());
+        shopCategory.setName(frontCategory.getName());
+        if (frontCategory.getParentCode() == null || frontCategory.getParentCode().equals("0")) {
+            shopCategory.setPid(0L);
+            shopCategory.setParentCode("0");
+        } else {
+            ShopCategory shopCategoryByCode1 = shopCategoryMapper.selectOne(new LambdaQueryWrapper<ShopCategory>()
+                    .eq(ShopCategory::getCode, frontCategory.getParentCode())
+                    .eq(ShopCategory::getShopId, shopId)
+                    .eq(ShopCategory::getIsDelete, 0));
+            if (shopCategoryByCode1 == null) {
+                //不存在父类目添加
+                FrontCategory frontCategoryParent = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
+                        .eq(FrontCategory::getCode, frontCategory.getParentCode())
+                        .eq(FrontCategory::getIsDelete, 0));
+                addShopCategory(frontCategoryParent, shopId, hbShopId);
+            }
+            shopCategory.setPid(shopCategoryByCode1.getId());
+            shopCategory.setParentCode(shopCategoryByCode1.getCode());
+        }
+
+        shopCategory.setShopId(shopId);
+        shopCategory.setHbShopId(String.valueOf(hbShopId));
+        shopCategory.setLabel(frontCategory.getLabel());
+        shopCategory.setIcon(frontCategory.getIcon());
+        shopCategory.setPic(frontCategory.getPic());
+        shopCategory.setLevel(frontCategory.getLevel());
+        shopCategory.setIsDelete(0);
+        shopCategory.setOperateUser("admin");
+        shopCategory.setNum(frontCategory.getNum());
+        shopCategory.setIsLeaves(frontCategory.getIsLeaves());
+
+        shopCategoryMapper.insert(shopCategory);
+    }
+
+    @Override
+    public void sync(Long shopId, Long hbShopId) {
+        List<FrontCategory> frontCategoryList = frontCategoryMapper.selectList(new LambdaQueryWrapper<FrontCategory>()
+        .eq(FrontCategory::getIsDelete, 0));
+        for (FrontCategory frontCategory : frontCategoryList) {
+            addShopCategory(frontCategory, shopId, hbShopId);
+        }
+    }
+
     public String selectHBFrontCategory(List<String> resultList) {
         HBBaseReq<Object> build = HBBaseReq.create();
         build.setAppId(hbSignUtil.getAppId());

+ 5 - 9
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBGoodsService.java

@@ -527,10 +527,10 @@ public class HBGoodsService implements IHBGoodsService {
             String ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCodeLevel2");
             if (StringUtils.isEmpty(ztFrontCategoryCodeLevel)) {
                 ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
-            } else {
-                //如果是二级,一级对应商品不存在也需要添加
-                addCategoryProd(spuId, ztFrontCategoryCodeLevel);
-                ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
+//            } else {
+//                //如果是二级,一级对应商品不存在也需要添加
+//                addCategoryProd(spuId, ztFrontCategoryCodeLevel);
+//                ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
             }
             addCategoryProd(spuId, ztFrontCategoryCodeLevel);
 
@@ -547,11 +547,7 @@ public class HBGoodsService implements IHBGoodsService {
                 .eq(CategoryProd::getProdId, spuId)
                 .eq(CategoryProd::getIsDelete, 0)
                 .eq(CategoryProd::getCode, ztFrontCategoryCodeLevel));
-        if (integer != null) {
-            categoryProd.setId(integer.getId());
-            categoryProdMapper.updateById(categoryProd);
-            log.info("商品对应分类已存在{}", categoryProd);
-        } else {
+        if (integer == null) {
             categoryProdMapper.insert(categoryProd);
         }
     }

+ 2 - 2
yami-shop-service/src/main/java/com/yami/shop/service/impl/ShopCategoryServiceImpl.java

@@ -173,9 +173,9 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryMapper, Sho
             category.setPic(sc.getPic());
             category.setSeq(sc.getNum());
             category.setGrade(sc.getLevel());
-            if (null != sc.getLabel() && !sc.getLabel().isEmpty()) {
+            if (ObjectUtils.isNotEmpty(sc.getLabel())) {
                 Label label = labelMapper.selectOne(new LambdaQueryWrapper<Label>()
-                        .eq(Label::getId, Long.valueOf(sc.getLabel()))
+                        .eq(Label::getId, sc.getLabel())
                         .eq(Label::getIsDelete, 0)
                         .eq(Label::getType, 0));
                 if (null != label && null != label.getName()) {