fubojin 1 тиждень тому
батько
коміт
df8d545dcd
19 змінених файлів з 417 додано та 89 видалено
  1. 6 1
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/CategoryProd.java
  2. 2 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/ChannelProd.java
  3. 6 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/Order.java
  4. 71 0
      yami-shop-bean/src/main/java/com/yami/shop/bean/model/OrderRiderLocation.java
  5. 5 2
      yami-shop-common/src/main/java/com/yami/shop/common/util/HttpUtil.java
  6. 1 1
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ChannelProdController.java
  7. 12 1
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/hb/GoodsController.java
  8. 34 13
      yami-shop-platform/src/main/java/com/yami/shop/platform/controller/hb/HBOrderController.java
  9. 0 4
      yami-shop-platform/src/main/resources/application-dev.yml
  10. 11 0
      yami-shop-service/src/main/java/com/yami/shop/dao/OrderRiderLocationMapper.java
  11. 6 0
      yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBGoodsService.java
  12. 28 0
      yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBOrderService.java
  13. 24 1
      yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBFrontCategoryService.java
  14. 80 35
      yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBGoodsService.java
  15. 101 13
      yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBOrderService.java
  16. 3 3
      yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/StoreManagementService.java
  17. 23 12
      yami-shop-service/src/main/java/com/yami/shop/service/impl/ChannelProdServiceImpl.java
  18. 1 0
      yami-shop-service/src/main/java/com/yami/shop/service/impl/ShopCategoryServiceImpl.java
  19. 3 3
      yami-shop-service/src/main/java/com/yami/shop/utils/HBSignUtil.java

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

@@ -31,7 +31,12 @@ public class CategoryProd implements Serializable {
      * 商品属性id即表tz_prod_prop中的prop_id
      */
 
-    private Long propId;
+    private Long prodId;
 
+    private String code;
+
+    /**
+     * 0 正常,1 删除
+     */
     private Integer isDelete;
 }

+ 2 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/ChannelProd.java

@@ -40,6 +40,7 @@ public class ChannelProd implements Serializable {
      * 渠道ID
      */
     private Long channelId;
+
     @TableField(exist = false)
     private String channelName;
 
@@ -59,6 +60,7 @@ public class ChannelProd implements Serializable {
     /**
      * 门店名称
      */
+    @TableField(exist = false)
     private String shopName;
 
     /**

+ 6 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/Order.java

@@ -90,6 +90,12 @@ public class Order implements Serializable {
      */
     private Integer hbOrderStatus;
 
+    /**
+     * 海博物流状态
+     * 20:已抢单,30:配送员到店,40:取货完成,50:配送单取消,100:已送达
+     */
+    private Integer hbLogisticStatus;
+
     /**
      * 配送类型(1:快递 2:自提 3:及时配送)
      */

+ 71 - 0
yami-shop-bean/src/main/java/com/yami/shop/bean/model/OrderRiderLocation.java

@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2018-2999 广州亚米信息科技有限公司 All rights reserved.
+ *
+ * https://www.gz-yami.com/
+ *
+ * 未经允许,不可做商业用途!
+ *
+ * 版权所有,侵权必究!
+ */
+
+package com.yami.shop.bean.model;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @author Hasee
+ */
+@Data
+@TableName("tz_order_rider_location")
+public class OrderRiderLocation implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 骑手位置ID
+     */
+    @TableId
+    private Long id;
+
+    /**
+     * 订单号
+     */
+    private String orderNumber;
+
+    /**
+     * 骑手姓名
+     */
+    private String courierName;
+
+    /**
+     * 骑手电话
+     */
+    private String courierPhone;
+
+    /**
+     * 纬度
+     */
+    private Double latitude;
+
+    /**
+     * 经度
+     */
+    private Double longitude;
+
+    /**
+     * 推送时间
+     */
+    private Long pushTime;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+}
+
+

+ 5 - 2
yami-shop-common/src/main/java/com/yami/shop/common/util/HttpUtil.java

@@ -2,6 +2,7 @@ package com.yami.shop.common.util;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpResponse;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
@@ -29,6 +30,7 @@ import java.util.Objects;
  * @author 王坚
  * @since 2021-06-10
  */
+@Slf4j
 public class HttpUtil {
 
     /**
@@ -118,6 +120,7 @@ public class HttpUtil {
      */
     public static String post(String url, Map<String, String> headers, Object params) {
         HttpPost post = new HttpPost(url);
+        log.info("请求路径{}",post);
         StringEntity entity = new StringEntity(JSON.toJSONString(params), ContentType.APPLICATION_JSON);
         post.setEntity(entity);
         return getRespString(post, headers);
@@ -317,8 +320,8 @@ public class HttpUtil {
      */
     private static String getRespString(HttpUriRequest request, Map<String, String> headers) {
 
-        System.err.println("=================请求对象=====================");
-        System.err.println(JSONObject.toJSONString(request));
+        log.info("=================请求对象=====================");
+        log.info(JSONObject.toJSONString(request));
         byte[] bytes = new byte[BYTE_ARRAY_LENGTH];
         int len = 0;
         try (InputStream in = getRespInputStream(request, headers);

+ 1 - 1
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/ChannelProdController.java

@@ -148,7 +148,7 @@ public class ChannelProdController {
     }
 
     @PostMapping("/import")
-    @ApiOperation(value = "导入渠道商品数据")
+    @ApiOperation(value = "导入渠道商品价格数据")
     public R<String> importChannelProds(@RequestParam("file") MultipartFile file) {
         String result = channelProdService.importChannelProds(file);
         return R.SUCCESS(result);

+ 12 - 1
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/hb/GoodsController.java

@@ -34,7 +34,9 @@ public class GoodsController {
     @ApiOperation(value = "添加商品信息", notes = "海博新增商品信息回调接口")
     public HBR addGoods(@RequestBody JSONObject HBRequest) {
         log.info("海博新增商品{}",HBRequest);
-        return goodsService.addHBGoods(HBRequest);
+        HBR hbr = goodsService.addHBGoods(HBRequest);
+        log.info("海博新增商品返回信息:{}",hbr);
+        return hbr;
     }
     /**
      * 海博修改商品信息-回调
@@ -107,6 +109,15 @@ public class GoodsController {
     }
 
 
+    /**
+     * 海博商品信息(商品主档信息查询接口 - 对应的是海博商品里面“线上商品管理”)
+     *
+     * @return 商品响应
+     */
+    @GetMapping("/selectHBGoodsSpuInfo")
+    public HBR selectHBGoodsSpuInfo(String spuId) {
+        return HBR.success(goodsService.selectHBGoodsSpuInfo(spuId));
+    }
 
 
 }

+ 34 - 13
yami-shop-platform/src/main/java/com/yami/shop/platform/controller/hb/HBOrderController.java

@@ -35,8 +35,6 @@ public class HBOrderController {
         return orderService.createOrderAsync(channelOrderId);
     }
 
-
-
     /**
      * 订单配送-回调
      *
@@ -49,7 +47,6 @@ public class HBOrderController {
         return null;
     }
 
-
     /**
      * 海博订单完成-回调
      * @param HBRequest 海博订单完成请求参数
@@ -59,6 +56,7 @@ public class HBOrderController {
         log.info("海博订单完成{}",HBRequest);
         return null;
     }
+
     /**
      * 海博查询订单详情-回调
      * @param HBRequest 海博查询订单详情请求参数
@@ -82,17 +80,17 @@ public class HBOrderController {
         return null;
     }
 
-
     /**
-     * 海博修改订单状态-回调
+     * 订单状态变更接口-回调
      *
-     * @param HBRequest 海博修改订单状态请求参数
+     * @param hBRequest 订单状态变更接口请求参数
      * @return 订单响应
      */
     @PostMapping("/updateStatus")
-    public HBR updateStatus(@RequestBody JSONObject HBRequest) {
-        log.info("海博修改订单状态{}",HBRequest);
-        return null;
+    public HBR updateStatus(@RequestBody JSONObject hBRequest) {
+        log.info("海博修改订单状态{}",hBRequest);
+        orderService.orderStatusNotify(hBRequest);
+        return HBR.success();
     }
 
     /**
@@ -110,14 +108,37 @@ public class HBOrderController {
     /**
      * 海博订单物流状态-回调
      *
-     * @param HBRequest 海博订单物流状态请求参数
+     * @param hBRequest 海博订单物流状态请求参数
      * @return 订单响应
      */
     @PostMapping("/logisticsStatus")
-    public HBR logisticsStatus(@RequestBody JSONObject HBRequest) {
-        log.info("海博订单物流状态请求参数{}",HBRequest);
-        return null;
+    public HBR logisticsStatus(@RequestBody JSONObject hBRequest) {
+        log.info("海博订单物流状态通知{}",hBRequest);
+        orderService.updateLogisticStatus(hBRequest);
+        return HBR.success();
+    }
+
+    /**
+     * 订单状态变更通知(下行)
+     */
+    @PostMapping("/orderStatusNotify")
+    public HBR orderStatusNotify(@RequestBody JSONObject hBRequest) {
+        orderService.orderStatusNotify(hBRequest);
+        log.info("海博订单状态变更通知{}",hBRequest);
+        return HBR.success();
     }
 
 
+    /**
+     * 骑手经纬度接口
+     * @param hBRequest 海博骑手经纬度请求参数
+     * @return 订单响应
+     */
+    @PostMapping("/riderLocation")
+    public HBR riderLocation(@RequestBody JSONObject hBRequest) {
+        log.info("海博骑手经纬度{}",hBRequest);
+        orderService.riderLocation(hBRequest);
+        return HBR.success();
+    }
+
 }

+ 0 - 4
yami-shop-platform/src/main/resources/application-dev.yml

@@ -19,7 +19,3 @@ spring:
 logging:
   config: classpath:logback/logback-dev.xml
 
-hb:
-  host: https://p-open.hiboos.com
-  appId: 5347a7077e65428bb9a87510ca7e1ea1
-  secret: 67899367b17e4a8d8a7d10ebe8449b90

+ 11 - 0
yami-shop-service/src/main/java/com/yami/shop/dao/OrderRiderLocationMapper.java

@@ -0,0 +1,11 @@
+package com.yami.shop.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.yami.shop.bean.model.AdvertInfo;
+import com.yami.shop.bean.model.OrderRiderLocation;
+
+/**
+ * @author fbj
+ */
+public interface OrderRiderLocationMapper extends BaseMapper<OrderRiderLocation> {
+}

+ 6 - 0
yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBGoodsService.java

@@ -58,4 +58,10 @@ public interface IHBGoodsService {
     void deleteGoods(JSONObject hbRequest);
 
 
+    /**
+     * 获取海博商品spu信息
+     * @param spuId spuId
+     * @return spu信息
+     */
+    String selectHBGoodsSpuInfo(String spuId);
 }

+ 28 - 0
yami-shop-service/src/main/java/com/yami/shop/service/hb/IHBOrderService.java

@@ -29,6 +29,15 @@ public interface IHBOrderService {
      */
     String createOrderAsync(String channelOrderId);
 
+    /**
+     * 海博订单修改状态接口-推送接口
+     *
+     * @param channelOrderId 海博订单请求参数
+     * 订单类型 (20:订单已接单 30:订单待配送 60:订单已取消 80:订单已完成)
+     * @return 订单详情响应
+     */
+    String changeOrderStatus(String channelOrderId, Integer type);
+
     /**
      * 海博订单创建接口-结果接口
      *
@@ -36,4 +45,23 @@ public interface IHBOrderService {
      * @return 订单结果响应
      */
     HBR createOrderResult(JSONObject hBRequest);
+
+    /**
+     * 海博订单创建接口-结果接口
+     *
+     * @param hBRequest 海博订单结果请求参数
+     */
+    void orderStatusNotify(JSONObject hBRequest);
+
+    /**
+     * 订单物流状态接口-结果接口
+     * @param hBRequest 海博订单结果请求参数
+     */
+    void updateLogisticStatus(JSONObject hBRequest);
+
+    /**
+     * 配送员位置接口-结果接口
+     * @param hBRequest 海博订单结果请求参数
+     */
+    void riderLocation(JSONObject hBRequest);
 }

+ 24 - 1
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBFrontCategoryService.java

@@ -12,6 +12,7 @@ import com.yami.shop.service.hb.IHBFrontCategoryService;
 import com.yami.shop.utils.HBSignUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -70,8 +71,30 @@ public class HBFrontCategoryService implements IHBFrontCategoryService {
                 frontCategory.setIcon(jsonObjectInfo.getString("https://zswl-shop.oss-cn-chengdu.aliyuncs.com/2025/09/fe56414a161b498b8f263d3e6afdab92.png"));
                 frontCategory.setPic(jsonObjectInfo.getString("https://zswl-shop.oss-cn-chengdu.aliyuncs.com/2025/09/fe56414a161b498b8f263d3e6afdab92.png"));
                 log.info("添加前台类目信息{}",frontCategory);
+
+//                if (ObjectUtils.isNotEmpty(jsonObjectInfo.getString("parentCode")) && !jsonObjectInfo.getString("parentCode").equals("0")) {
+//                    frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>().
+//                            eq(FrontCategory::getParentCode, frontCategory.getParentCode())
+//                            .eq(FrontCategory::getIsDelete, 0));
+//                    if (frontCategory.getParentCode() == null) {
+//                        FrontCategory frontCategory1 = new FrontCategory();
+//                        frontCategory1.setCode(jsonObjectInfo.getString("parentCode"));
+//                        frontCategory1.setName(jsonObjectInfo.getString("parentName"));
+//                        frontCategory1.setIsDelete(0);
+//                        frontCategoryMapper.insert(frontCategory1);
+//                    }
+//                }
+                FrontCategory frontCategory1 = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>().
+                        eq(FrontCategory::getCode, frontCategory.getCode())
+                        .eq(FrontCategory::getIsDelete, 0));
+                if (frontCategory1 == null) {
+                    frontCategoryMapper.insert(frontCategory);
+                } else {
+                    frontCategory.setId(frontCategory1.getId());
+                    frontCategoryMapper.updateById(frontCategory);
+                }
                 // 3. 保存门店信息
-                frontCategoryMapper.insert(frontCategory);
+//                frontCategoryMapper.insert(frontCategory);
             }
             log.info("前台分类成功");
             // 4. 构建响应

+ 80 - 35
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBGoodsService.java

@@ -4,17 +4,13 @@ import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.yami.shop.bean.dto.hb.HBBaseReq;
-import com.yami.shop.bean.model.Product;
-import com.yami.shop.bean.model.ShopDetail;
-import com.yami.shop.bean.model.ShopSku;
-import com.yami.shop.bean.model.Sku;
+import com.yami.shop.bean.model.*;
 import com.yami.shop.common.util.hb.HBR;
-import com.yami.shop.dao.ProductMapper;
-import com.yami.shop.dao.ShopDetailMapper;
-import com.yami.shop.dao.ShopSkuMapper;
-import com.yami.shop.dao.SkuMapper;
+import com.yami.shop.dao.*;
 import com.yami.shop.service.hb.IHBGoodsService;
+import com.yami.shop.service.impl.FrontCategoryService;
 import com.yami.shop.utils.HBSignUtil;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
@@ -45,6 +41,8 @@ public class HBGoodsService implements IHBGoodsService {
     private final SkuMapper skuMapper;
     private final ShopSkuMapper shopSkuMapper;
     private final ShopDetailMapper shopDetailMapper;
+    private final FrontCategoryMapper frontCategoryMapper;
+    private final CategoryProdMapper categoryProdMapper;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -75,25 +73,33 @@ public class HBGoodsService implements IHBGoodsService {
 
                     // 创建并填充Product对象
                     hbSpuId = productInfo.getString("spuId");
+                    Product productAdd = createProductFromProductInfo(productInfo);
+                    setSpuMapper(productInfo, productAdd);
                     Product productInfoById = productMapper.selectByHbSpuId(hbSpuId);
+
                     if (ObjectUtil.isNotEmpty(productInfoById) && productInfoById.getIsDelete() == 0) {
                         prodId = productInfoById.getProdId();
-                        log.info("商品spuID={},spuName={}已经存在无需添加", productInfo.getLong("spuId"), productInfo.getString("spuName"));
+                        log.info("商品spuID={},spuName={}已经存在,修改商品", productInfo.getLong("spuId"), productInfo.getString("spuName"));
+                        productAdd.setProdId(productInfoById.getProdId());
+                        productMapper.updateById(productAdd);
                     } else {
-                        Product productAdd = createProductFromProductInfo(productInfo);
-                        setSpuMapper(productInfo, productAdd);
                         //添加到数据库
+                        log.info("创建商品spu: {}", productAdd);
                         productMapper.insert(productAdd);
                         prodId = productAdd.getProdId();
                         log.info("SPU创建成功: prodId={}, hbSpuId={}, spuName={}", productAdd.getProdId(), productAdd.getProdId(), productAdd.getProdName());
                     }
 
+                    convertCategoryCodeToId(productInfo.getJSONArray("relationFrontCategories"), productAdd.getProdId()); // 一品多类目
+
+
                     Sku skuId = skuMapper.selectByHbSkuId(productInfo.getString("skuId"));
                     if (ObjectUtil.isNotEmpty(skuId) && skuId.getIsDelete() == 0) {
-                        log.info("商品skuId={},skuName={}已经存在无需添加", productInfo.getString("skuId"), productInfo.getString("skuName"));
+                        skuId.setSkuId(skuId.getSkuId());
+                        skuMapper.updateById(skuId);
+                        log.info("商品skuId={},skuName={}已经存在,修改数据", productInfo.getString("skuId"), productInfo.getString("skuName"));
                     } else {
                         // 创建并填充Sku对象
-
                         Sku sku = createSkuFromProductInfo(productInfo);
                         sku.setProdId(prodId);
                         sku.setHbSpuId(hbSpuId);
@@ -114,38 +120,42 @@ public class HBGoodsService implements IHBGoodsService {
                 for (Object productHostInfoDTO : productHostInfoDTOS) {
                     JSONObject productInfo = JSON.parseObject(productHostInfoDTO.toString());
                     // 创建并填充Product对象
+                    Product productAdd = createProductFromProductInfo(productInfo);
+                    setSpuSpecMapper(productInfo, productAdd);
+                    // 创建并填充Product对象
                     Product productInfoById = productMapper.selectByHbSpuId(hbSpuId);
                     if (ObjectUtil.isNotEmpty(productInfoById) && productInfoById.getIsDelete() == 0) {
-                        log.info("商品spuID={},spuName={}已经存在无需添加", productInfo.getLong("spuId"), productInfo.getString("spuName"));
                         prodId = productInfoById.getProdId();
+                        log.info("商品spuID={},spuName={}已经存在,修改商品", productInfo.getLong("spuId"), productInfo.getString("spuName"));
+                        productAdd.setProdId(productInfoById.getProdId());
+                        productMapper.updateById(productAdd);
                     } else {
-                        // 创建并填充Product对象
-                        Product productAdd = createProductFromProductInfo(productInfo);
-                        setSpuSpecMapper(productInfo, productAdd);
                         //添加到数据库
                         productMapper.insert(productAdd);
                         prodId = productAdd.getProdId();
                         log.info("生成的商品ID: {}", productAdd.getProdId());
                     }
+                    convertCategoryCodeToId(productInfo.getJSONArray("relationFrontCategories"), productAdd.getProdId()); // 一品多类目
 
                     JSONArray skuList = productInfo.getJSONArray("skuList");
                     for (Object o : skuList) {
                         JSONObject jsonObjectSku = JSON.parseObject(o.toString());
-
+                        Sku sku = createSkuFromProductInfo(jsonObjectSku);
+                        sku.setProdId(prodId);
+                        sku.setHbSpuId(hbSpuId);
                         Sku skuId = skuMapper.selectByHbSkuId(jsonObjectSku.getString("skuId"));
                         if (ObjectUtil.isNotEmpty(skuId) && skuId.getIsDelete() == 0) {
+                            skuId.setSkuId(skuId.getSkuId());
+                            skuMapper.updateById(skuId);
                             log.info("商品skuId={},skuName={}已经存在无需添加", productInfo.getLong("skuId"), productInfo.getString("skuName"));
                         } else {
-                            Sku sku = createSkuFromProductInfo(jsonObjectSku);
-                            sku.setProdId(prodId);
-                            sku.setHbSpuId(hbSpuId);
                             skuMapper.insert(sku);
                         }
                     }
                 }
             }
         }
-        return HBR.success("商品信息处理成功");
+        return HBR.success();
     }
 
     @Override
@@ -174,7 +184,8 @@ public class HBGoodsService implements IHBGoodsService {
             String stationId = bodyJson.getString("stationId");
 
             String selfSkuStatus = getSelfSkuStatus(skuId, stationId);
-
+            log.info("商品状态变更查询:{}", selfSkuStatus);
+            //处理商品状态
 
 
         } catch (Exception e) {
@@ -217,6 +228,7 @@ public class HBGoodsService implements IHBGoodsService {
                     shopSkuInfo.setShopId(shopDetail.getShopId());
                     shopSkuInfo.setShopSkuPrice(currentPrice == null ? 0.0 : currentPrice);
                     shopSkuInfo.setSkuId(sku.getSkuId());
+                    shopSkuInfo.setSpuId(sku.getProdId());
                     shopSkuInfo.setIsDelete(0);
                     shopSkuInfo.setRecTime(new Date());
                     shopSkuMapper.insert(shopSkuInfo);
@@ -225,7 +237,7 @@ public class HBGoodsService implements IHBGoodsService {
                     shopSku.setShopSkuPrice(currentPrice == null ? 0.0 : currentPrice);
                     shopSku.setUpdateTime(new Date());
                     shopSkuMapper.updateById(shopSku);
-                    log.info("库存更改成功");
+                    log.info("价格更改成功");
                 }
             }
         } catch (Exception e) {
@@ -339,6 +351,7 @@ public class HBGoodsService implements IHBGoodsService {
      *
      * @param spuId 海博多规格商品编码
      */
+    @Override
     public String selectHBGoodsSpuInfo(String spuId) {
 
         HBBaseReq<Object> build = HBBaseReq.create();
@@ -366,6 +379,7 @@ public class HBGoodsService implements IHBGoodsService {
 
     /**
      * 商品-门店品售卖状态查询接口
+     *
      * @return 门店品售卖状态信息
      */
     public String getSelfSkuStatus(String skuId, String stationId) {
@@ -391,6 +405,7 @@ public class HBGoodsService implements IHBGoodsService {
     private Product createProductFromProductInfo(JSONObject productInfo) {
         Product product = new Product();
 
+        log.info("productInfo:{}", productInfo);
         // 直接映射字段
         product.setHbSpuId(productInfo.getLong("spuId"));
         product.setProdName(productInfo.getString("spuName"));
@@ -406,19 +421,24 @@ public class HBGoodsService implements IHBGoodsService {
         product.setBrandId(productInfo.getLong("brandId"));
         //品牌名称
         product.setBrandName(productInfo.getString("brandName"));
+        product.setBrandName(productInfo.getString("brandName"));
+        String descText = productInfo.getString("descText");
+        if (StringUtils.isEmpty(descText)) {
+            product.setContent("<p>暂无商品详情</p>");
+        } else {
+            product.setContent(descText);
+        }
         // 分类转换
         product.setCategoryId(productInfo.getLong("frontCategoryCode"));
         //后台类目平台对应ID
 //        product.setHbFrontCategoryId(productInfo.getLong("frontCategoryCode"));
-        product.setPic(productInfo.getString("spuMainImage"));
-        product.setImgs(productInfo.getString("spuImages"));
+//        product.setPic(productInfo.getString("spuMainImage"));
+//        product.setImgs(productInfo.getString("spuImages"));
         // 需要转换或默认值的字段
 //        Product.setTotalStocks(productInfo.getString(""));//总库存
 //        Product.setDeliveryMode(productInfo.getString(""));//配送方式
 //        Product.setDeliveryTemplateId(productInfo.getString(""));//运费模板id
 
-        convertCategoryCodeToId(productInfo.getJSONArray("relationFrontCategories")); // 一品多类目
-
         log.info("商品数据详情{}", product);
         return product;
     }
@@ -427,18 +447,20 @@ public class HBGoodsService implements IHBGoodsService {
      * 海博(普通)商品
      */
     private void setSpuMapper(JSONObject productInfo, Product product) {
-        product.setPic(productInfo.getString("spuMainImage"));//商品主图
+        product.setPic(productInfo.getString("mainImage"));//商品主图
         product.setHbStatus(1);//海博商品类型(1-普通商品,2-多规格商品)
-        product.setImgs(productInfo.getString("spuImages"));//商品图片,以,分割
+        product.setImgs(productInfo.getString("images"));//商品图片,以,分割
     }
 
     /**
      * 海博(多规格)商品
      */
     private void setSpuSpecMapper(JSONObject productInfo, Product product) {
-        product.setPic(productInfo.getString("mainImage"));//商品主图
+
+        product.setPic(productInfo.getString("spuMainImage"));//商品主图
         product.setHbStatus(2);//海博商品类型(1-普通商品,2-多规格商品)
-        product.setImgs(productInfo.getString("images"));//商品图片,以,分割
+        product.setImgs(productInfo.getString("spuImages"));//商品图片,以,分割
+
     }
 
     /**
@@ -460,8 +482,8 @@ public class HBGoodsService implements IHBGoodsService {
         sku.setStatus(1);
         sku.setIsDelete(0);
         sku.setVersion(0);
-        String images = StringUtils.isEmpty(productInfo.getString("images")) ? productInfo.getString("skuMainImage") : productInfo.getString("images");
-        sku.setPic(images);//sku图片
+//        String images = StringUtils.isEmpty(productInfo.getString("images")) ? productInfo.getString("skuMainImage") : productInfo.getString("images");
+        sku.setPic(productInfo.getString("mainImage"));//sku图片
         sku.setWeightUnit(productInfo.getString("unit"));//单位
         // 商品原价
         sku.setOriPrice(productInfo.getDouble("basicPrice") != null ?
@@ -487,10 +509,33 @@ public class HBGoodsService implements IHBGoodsService {
     /**
      * 分类处理
      */
-    private void convertCategoryCodeToId(JSONArray categoryCode) {
+    private void convertCategoryCodeToId(JSONArray categoryCode, Long spuId) {
+        log.info("新增商品分类处理{}", categoryCode);
         for (Object o : categoryCode) {
             JSONObject jsonObject = JSON.parseObject(o.toString());
 
+            String ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCodeLevel2");
+            if (StringUtils.isEmpty(ztFrontCategoryCodeLevel)) {
+                ztFrontCategoryCodeLevel = jsonObject.getString("ztFrontCategoryCode");
+            }
+//            FrontCategory frontCategory = frontCategoryMapper.selectOne(new LambdaQueryWrapper<FrontCategory>()
+//                    .eq(FrontCategory::getCode, ztFrontCategoryCodeLevel));
+
+            CategoryProd categoryProd = new CategoryProd();
+            categoryProd.setCode(ztFrontCategoryCodeLevel);
+            categoryProd.setProdId(spuId);
+            categoryProd.setIsDelete(0);
+            CategoryProd integer = categoryProdMapper.selectOne(new LambdaQueryWrapper<CategoryProd>()
+                    .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 {
+                categoryProdMapper.insert(categoryProd);
+            }
 
         }
     }

+ 101 - 13
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/HBOrderService.java

@@ -3,6 +3,7 @@ package com.yami.shop.service.hb.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.yami.shop.bean.dto.hb.*;
 import com.yami.shop.bean.enums.DvyType;
 import com.yami.shop.bean.model.*;
@@ -36,7 +37,6 @@ import static com.yami.shop.common.util.HttpUtil.post;
 @Slf4j
 @Service
 @AllArgsConstructor
-@Transactional(readOnly = true)
 public class HBOrderService implements IHBOrderService {
     private final HBSignUtil hbSignUtil;
     private final OrderMapper orderMapper;
@@ -47,6 +47,7 @@ public class HBOrderService implements IHBOrderService {
     private final UserAddrService userAddrService;
     private final ProductMapper productMapper;
     private final SkuMapper skuMapper;
+    private final OrderRiderLocationMapper orderRiderLocationMapper;
 
     public HBR addHBGoods(JSONObject hbRequest) {
         try {
@@ -131,12 +132,95 @@ public class HBOrderService implements IHBOrderService {
     }
 
     @Override
-    public HBR createOrderResult(JSONObject hBRequest) {
-        log.info("海博订单创建完成结果通知请求参数{}",hBRequest);
+    public String changeOrderStatus(String channelOrderId, Integer type) {
+
+        HBBaseReq<Object> build = HBBaseReq.create();
+        build.setAppId(hbSignUtil.getAppId());
+
+        // 3. 构建外层请求体
+        JSONObject requestBody = new JSONObject();
+        requestBody.put("channelOrderId", channelOrderId);
+        requestBody.put("operator", channelOrderId);
+        // 订单操作时间戳毫秒数
+        requestBody.put("operatorTime", System.currentTimeMillis());
+        //操作类型 (20:订单已接单 30:订单待配送 60:订单已取消 80:订单已完成)
+        requestBody.put("operatorType", type);
+        // 4. 将整个JSON对象序列化为字符串并设置
+        build.setBody(JSON.toJSONString(requestBody));
 
+        build.setSign(hbSignUtil.signMd5(build));
+        log.info("post 订单推送单号参数:{}", JSON.toJSONString(build));
+        String post = post(hbSignUtil.getHBHost() + "/api/order/changeOrderStatus", build);
+        log.info("post 订单推送结果:{}", post);
+        return post;
+    }
+
+    @Override
+    public HBR createOrderResult(JSONObject hBRequest) {
+        log.info("海博订单创建完成结果通知请求参数{}", hBRequest);
+        JSONObject body = hBRequest.getJSONObject("body");
+        String code = body.getString("code");
+        if (!"0".equals(code)) {
+            log.error("海博订单创建失败:{}", body.getString("message"));
+        }
         return HBR.success();
     }
 
+    @Override
+    public void orderStatusNotify(JSONObject hBRequest) {
+        log.info("海博订单状态变更通知请求参数{}", hBRequest);
+        String bodyStr = hBRequest.getString("body");
+        log.info("订单信息,body:{}", bodyStr);
+        JSONObject bodyJson = JSON.parseObject(bodyStr);
+        Order order = orderMapper.getOrderAndOrderItemByOrderNumber(bodyJson.getString("channelOrderId"));
+        order.setHbOrderStatus(bodyJson.getInteger("operatorType"));
+        orderMapper.updateById(order);
+    }
+
+    @Override
+    public void updateLogisticStatus(JSONObject hBRequest) {
+        log.info("海博订单更新通知请求参数{}", hBRequest);
+        JSONObject body = hBRequest.getJSONObject("body");
+        String channelOrderId = body.getString("channelOrderId");
+        Long changeTime = body.getLong("changeTime");
+        Integer logisticStatus = body.getInteger("logisticStatus");
+        String operator = body.getString("operator");
+        Order order = orderMapper.getOrderAndOrderItemByOrderNumber(channelOrderId);
+        order.setHbLogisticStatus(logisticStatus);
+        order.setUpdateTime(new Date(changeTime));
+        orderMapper.updateById(order);
+    }
+
+    @Override
+    public void riderLocation(JSONObject hBRequest) {
+        String bodyStr = hBRequest.getString("body");
+        log.info("订单信息,body:{}", bodyStr);
+        JSONObject bodyJson = JSON.parseObject(bodyStr);
+//        Order order = orderMapper.getOrderAndOrderItemByOrderNumber(bodyJson.getString("channelOrderId"));
+        String channelOrderId = bodyJson.getString("channelOrderId");
+        String courierName = bodyJson.getString("courierName");
+        String courierPhone = bodyJson.getString("courierPhone");
+        Double latitude = bodyJson.getDouble("latitude");
+        Double longitude = bodyJson.getDouble("longitude");
+        Long pushTime = bodyJson.getLong("pushTime");
+        OrderRiderLocation orderRiderLocation = new OrderRiderLocation();
+        orderRiderLocation.setOrderNumber(channelOrderId);
+        orderRiderLocation.setCourierName(courierName);
+        orderRiderLocation.setCourierPhone(courierPhone);
+        orderRiderLocation.setLatitude(latitude);
+        orderRiderLocation.setLongitude(longitude);
+        orderRiderLocation.setPushTime(pushTime);
+        orderRiderLocation.setCreateTime(new Date());
+
+        OrderRiderLocation orderRiderLocation1 = orderRiderLocationMapper.selectOne(new LambdaQueryWrapper<OrderRiderLocation>().eq(OrderRiderLocation::getOrderNumber, channelOrderId));
+        if (orderRiderLocation1 != null) {
+            orderRiderLocation.setId(orderRiderLocation1.getId());
+            orderRiderLocationMapper.updateById(orderRiderLocation);
+        } else {
+            orderRiderLocationMapper.insert(orderRiderLocation);
+        }
+    }
+
 
     @Override
     public HBR details(JSONObject hbRequest) {
@@ -179,19 +263,24 @@ public class HBOrderService implements IHBOrderService {
         }
 
         int dvyType = 80;
-        if (order.getDvyType() == 2) {
+        if (order.getDvyType() == 1) {
+            dvyType = 10;
+        } else if (order.getDvyType() == 2) {
             dvyType = 40;
         }
 
         createOrderRequest.setLogisticsType(dvyType);
-//        createOrderRequest.setCarrierNo(Order.getCarrierNo());运单号,快递单号
-//        createOrderRequest.setLogisticsDispatcherName(Order.getLogisticsDispatcherName()); 骑士姓名
-//        createOrderRequest.setLogisticsDispatcherMobile(Order.getLogisticsDispatcherMobile());骑士电话
-        createOrderRequest.setOrderAgingType(0);
+
+        OrderRiderLocation orderRiderLocation = orderRiderLocationMapper.selectOne(new LambdaQueryWrapper<OrderRiderLocation>().eq(OrderRiderLocation::getOrderNumber, order.getOrderNumber()));
+        if (orderRiderLocation != null) {
+            createOrderRequest.setCarrierNo(orderRiderLocation.getOrderNumber());//运单号,快递单号
+            createOrderRequest.setLogisticsDispatcherName(orderRiderLocation.getCourierName());// 骑士姓名
+            createOrderRequest.setLogisticsDispatcherMobile(orderRiderLocation.getCourierPhone());//骑士电话
 //        createOrderRequest.setLogisticsStationTips(Order.getLogisticsStationTips());配送小费
+        }
+        createOrderRequest.setOrderAgingType(0);
         createOrderRequest.setOrderConfirmTime(order.getCreateTime().getTime());
 
-//        createOrderRequest.setLogisticsPreEndTime(Order.getLogisticsPreEndTime());//配送预计送达时间
         if (order.getPayTime() != null) {
             createOrderRequest.setOrderPayTime(order.getPayTime().getTime());
             //配送预计开始时间
@@ -200,7 +289,7 @@ public class HBOrderService implements IHBOrderService {
             time += 60 * 60 * 1000;
             createOrderRequest.setLogisticsPreEndTime(time);
         }
-//        createOrderRequest.setOrderPickTime(order.getOrderPickTime());实际拣货完成时间
+//        createOrderRequest.setOrderPickTime(order.getUpdateTime().getTime());//实际拣货完成时间
 //        createOrderRequest.setOrderPickPreEndTime(order.getOrderPickPreEndTime());
         if (order.getDvyTime() != null) {
             createOrderRequest.setOrderOutStockTime(order.getDvyTime().getTime());
@@ -219,7 +308,6 @@ public class HBOrderService implements IHBOrderService {
 //        createOrderRequest.setExtra(order.getExtra());
 
         //订单费用信息
-
         OrderFee orderFee = new OrderFee();
         long totalPrice = (long) (order.getTotal() * 100);
         orderFee.setOriginalPrice(totalPrice);
@@ -264,8 +352,8 @@ public class HBOrderService implements IHBOrderService {
             orderProduct.setSkuWeight(sku.getWeight());
             orderProduct.setUnit(sku.getWeightUnit());
             orderProduct.setCount((long) orderItem.getProdCount());
-            orderProduct.setOriginSkuPrice((long)(orderItem.getPrice()*100));
-            orderProduct.setActivitySkuPrice((long)(orderItem.getPrice()*100));
+            orderProduct.setOriginSkuPrice((long) (orderItem.getPrice() * 100));
+            orderProduct.setActivitySkuPrice((long) (orderItem.getPrice() * 100));
             orderProduct.setSkuBasicSpec(sku.getSpec());
 //            orderProduct.setSkuImg(sku.getPic());
             orderProduct.setBusinessSingleProductSubsidy(0L);

+ 3 - 3
yami-shop-service/src/main/java/com/yami/shop/service/hb/impl/StoreManagementService.java

@@ -169,13 +169,13 @@ public class StoreManagementService implements IStoreManagementService {
 
             ShopDetail shopDetail = shopDetailMapper.selectByHbStationId(resultData.getString("stationId"));
             if (shopDetail != null) {
-                log.info("存在门店不需要新增直接修改{}", outStationNo);
+                log.info("存在门店不需要新增直接修改{}", outStationNo);
                 shopDetailInfo.setShopId(shopDetail.getShopId());
                 shopDetailMapper.updateById(shopDetailInfo);
+                log.info("门店变更成功{}", shopDetailInfo);
             }else {
                 shopDetailMapper.insert(shopDetailInfo);
-                log.info("门店变更成功{}", shopDetailInfo);
-
+                log.info("门店新增成功{}", shopDetailInfo);
                 //添加默认配送模板
                 Transport2 transport2 = new Transport2();
                 //所有数据设置默认值

+ 23 - 12
yami-shop-service/src/main/java/com/yami/shop/service/impl/ChannelProdServiceImpl.java

@@ -272,14 +272,14 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
                 channelProd.setChannelProdPrice(importVO.getChannelProdPrice());
                 channelProd.setRecTime(new Date());
 
-                // 检查是否已存在
-                int count = channelProdMapper.selectCount(
-                        new LambdaQueryWrapper<ChannelProd>().eq(ChannelProd::getChannelId, channel.getId())
-                                .eq(ChannelProd::getSkuId, sku.getSkuId()));
-                if (count > 0) {
-                    log.error("渠道:{},在系统中已存在商品ID:{}", importVO.getChannelName(), importVO.getSkuId());
-                    throw new GlobalException(String.format("第%d行数据导入失败! 失败原因: 渠道=%s,在系统中已存在 商品ID=%s", i + 1, importVO.getChannelName(), importVO.getSkuId()));
-                }
+//                // 检查是否已存在
+//                int count = channelProdMapper.selectCount(
+//                        new LambdaQueryWrapper<ChannelProd>().eq(ChannelProd::getChannelId, channel.getId())
+//                                .eq(ChannelProd::getSkuId, sku.getSkuId()));
+//                if (count > 0) {
+//                    log.error("渠道:{},在系统中已存在商品ID:{}", importVO.getChannelName(), importVO.getSkuId());
+//                    throw new GlobalException(String.format("第%d行数据导入失败! 失败原因: 渠道=%s,在系统中已存在 商品ID=%s", i + 1, importVO.getChannelName(), importVO.getSkuId()));
+//                }
 
                 //检查门店是否存在
                 ShopDetail shopDetail = shopDetailMapper.selectOne(new LambdaQueryWrapper<ShopDetail>().eq(ShopDetail::getShopName, importVO.getShopName()));
@@ -287,10 +287,21 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
                     log.error("门店:{},在系统中不存在", importVO.getShopName());
                     throw new GlobalException(String.format("第%d行数据导入失败! 失败原因: 门店=%s,在系统中不存在", i + 1, importVO.getShopName()));
                 }
+                channelProd.setShopId(shopDetail.getShopId());
 
                 // 新增操作
-                channelProdMapper.insert(channelProd);
-                log.info("添加渠道门店商品数据成功");
+                ChannelProd channelProdCount = channelProdMapper.selectOne(new LambdaQueryWrapper<ChannelProd>()
+                        .eq(ChannelProd::getShopId, shopDetail.getShopId())
+                        .eq(ChannelProd::getIsDelete, 0)
+                        .eq(ChannelProd::getSkuId, channelProd.getSkuId())
+                        .eq(ChannelProd::getChannelId, channelProd.getChannelId()));
+                if (channelProdCount == null) {
+                    channelProdMapper.insert(channelProd);
+                    log.info("添加渠道门店商品数据成功");
+                }else {
+                    channelProd.setId(channelProdCount.getId());
+                    channelProdMapper.updateById(channelProd);
+                }
                 //添加渠道门店关联数据
                 //检查门店是否已存在
                 int channelShopCount = channelShopMapper.selectCount(new LambdaQueryWrapper<ChannelShop>()
@@ -300,7 +311,7 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
                 if (channelShopCount == 0) {
                     ChannelShop channelShop = new ChannelShop();
                     channelShop.setIsDelete(0);
-                    channelShop.setChannelId(channelProd.getId());
+                    channelShop.setChannelId(channel.getId());
                     channelShop.setShopId(shopDetail.getShopId());
                     channelShopMapper.insert(channelShop);
                     log.info("添加渠道门店关联数据成功");
@@ -308,7 +319,7 @@ public class ChannelProdServiceImpl extends ServiceImpl<ChannelProdMapper, Chann
                 successCount++;
             } catch (Exception e) {
                 log.error("导入数据失败,行号:{},错误:{}", i + 1, e.getMessage());
-                throw new GlobalException(String.format("第%s行数据导入失败!", i + 1));
+                throw new GlobalException(String.format("第%s行数据导入失败:%s", i + 1,e.getMessage()));
             }
         }
         return String.format("导入完成,成功:%d条", successCount);

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

@@ -183,6 +183,7 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryMapper, Sho
         shopCategory.setIsDelete(0);
         shopCategory.setOperateUser("admin");
         shopCategory.setIsLeaves(1);
+        shopCategory.setIcon("https://zswl-shop.oss-cn-chengdu.aliyuncs.com/2025/09/eae85a85269045f6ba484bd1edf5f975.jpg");
 
         shopCategory.setHbShopId(hbShopId);
         shopCategory.setShopId(shopId);

+ 3 - 3
yami-shop-service/src/main/java/com/yami/shop/utils/HBSignUtil.java

@@ -20,12 +20,12 @@ import static cn.hutool.crypto.SecureUtil.md5;
 @Configuration
 public class HBSignUtil {
     @Getter
-    @Value("${hb.host:def}")
+    @Value("${hb.host}")
     private String hBHost;
     @Getter
-    @Value("${hb.appId:def}")
+    @Value("${hb.appId}")
     private String appId;
-    @Value("${hb.secret:def}")
+    @Value("${hb.secret}")
     private String secret;
 
     /**