From dd3a25856c368b5992d16d46bdaf0c52e80a250f Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Fri, 24 Oct 2025 17:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=88=9B=E5=BB=BA=E9=A1=BA?= =?UTF-8?q?=E4=B8=B0=E5=BA=97=E9=93=BA=E6=96=B9=E6=B3=95=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/EsignPlatformInfoService.java | 8 ++++ .../impl/EsignPlatformInfoServiceImpl.java | 44 ++++++++++++++++++- .../service/LklLedgerReceiverService.java | 1 + .../impl/LklLedgerReceiverServiceImpl.java | 8 +--- .../impl/ShopOrderInfoServiceImpl.java | 4 +- .../service/SFExpressApiService.java | 3 +- .../service/impl/SFExpressApiServiceImpl.java | 41 +++++++++++++---- .../impl/ShopStoreBaseServiceImpl.java | 7 ++- 8 files changed, 94 insertions(+), 22 deletions(-) diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java index 208ca9c5..1e3c8097 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java @@ -73,4 +73,12 @@ public interface EsignPlatformInfoService { * @return */ EsignPlatformInfo getMch2ndAgentWithShippingFee(Long mchId); + + /** + * 根据代理商ID获取供应商 商家ID + * + * @param agentId + * @return + */ + String getSupplierIdByAgentId(Long agentId); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java index f85c1fb4..d81b84c9 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java @@ -122,7 +122,7 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("id", agentId) + .eq("level", CommonConstant.Agent_Level_2nd) + .eq("status", CommonConstant.Enable) + .select("supplier_id"); + + // 查询记录 + EsignPlatformInfo result = getOne(queryWrapper); + + // 检查结果并返回 + if (result != null && StrUtil.isNotBlank(result.getSupplier_id())) { + log.debug("[获取供应商ID] 成功获取供应商ID,agentId={}, supplierId={}", agentId, result.getSupplier_id()); + return result.getSupplier_id(); + } else { + log.debug("[获取供应商ID] 未找到有效的供应商ID,agentId={}", agentId); + return ""; + } + } catch (Exception e) { + log.error("[获取供应商ID] 查询过程中发生异常,agentId={}", agentId, e); + return ""; + } + } + + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java index 00666ce8..5cf0ed62 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java @@ -115,4 +115,5 @@ public interface LklLedgerReceiverService extends IBaseService createSfExpressShop(Integer storeId, String shopName, String cityName, String shopAddress, String contactName, String contactPhone, String longitude, String latitude); + Pair createSfExpressShop(Long mchId, Integer storeId, String shopName, String cityName, String shopAddress, String contactName, String contactPhone, String longitude, String latitude); /** diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java index ea46e35d..19100a11 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java @@ -32,6 +32,7 @@ import com.suisung.mall.common.pojo.req.*; import com.suisung.mall.common.pojo.res.ThirdApiRes; import com.suisung.mall.common.pojo.to.AddressParseResultTO; import com.suisung.mall.common.utils.*; +import com.suisung.mall.shop.esign.service.EsignPlatformInfoService; import com.suisung.mall.shop.message.service.PushMessageService; import com.suisung.mall.shop.order.service.ShopOrderBaseService; import com.suisung.mall.shop.order.service.ShopOrderInfoService; @@ -119,6 +120,10 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { @Autowired private ShopProductItemService shopProductItemService; + @Lazy + @Autowired + private EsignPlatformInfoService esignPlatformInfoService; + /** * 创建顺丰同店铺-连锁店铺 * @@ -179,8 +184,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { logger.error("创建顺丰同店铺:联系人手机号不能为空"); return Pair.of(false, "联系人手机号不能为空"); } - - + AddressParseResultTO addressParseResultTO = AddressUtil.parseAddress(shopMchEntry.getStore_address()); // 解析城市名称 String cityName = "桂平市"; // 默认城市 @@ -212,6 +216,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { // 调用创建店铺方法 Pair result = createSfExpressShop( + mchId, Convert.toInt(shopMchEntry.getStore_id()), shopStoreName, cityName, @@ -228,8 +233,9 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { /** - * 创建顺丰同城(普通型)店铺 + * 创建顺丰同店铺-连锁店铺 * + * @param mchId 商家入驻编号 * @param storeId 商家门店ID * @param shopName 店名 * @param cityName 城市 @@ -238,18 +244,18 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { * @param contactPhone 店铺电话 * @param longitude 经度 * @param latitude 纬度 - * @return Pair 第一个元素表示是否成功,第二个元素表示结果信息或错误信息 + * @return */ @Override - public Pair createSfExpressShop(Integer storeId, String shopName, String cityName, + public Pair createSfExpressShop(Long mchId, Integer storeId, String shopName, String cityName, String shopAddress, String contactName, String contactPhone, String longitude, String latitude) { logger.info("开始创建顺丰同城店铺, storeId: {}", storeId); try { // 1. 验证必要参数 - if (CheckUtil.isEmpty(storeId) || StringUtils.isAnyBlank(shopName, shopAddress, contactName, contactPhone)) { - logger.error("创建顺丰店铺,缺少必要参数!storeId:{},shopName:{},shopAddress:{},contactName:{},contactPhone:{}", storeId, shopName, shopAddress, contactName, contactPhone); + if (CheckUtil.isEmpty(mchId) || CheckUtil.isEmpty(storeId) || StringUtils.isAnyBlank(shopName, shopAddress, contactName, contactPhone)) { + logger.error("创建顺丰店铺,缺少必要参数!mchId:{}, storeId:{},shopName:{},shopAddress:{},contactName:{},contactPhone:{}", mchId, storeId, shopName, shopAddress, contactName, contactPhone); return Pair.of(false, "创建顺丰店铺,缺少必要参数!"); } @@ -278,9 +284,28 @@ public class SFExpressApiServiceImpl implements SFExpressApiService { } } + ShopMchEntry shopMchEntry = shopMchEntryService.shopMerchEntryById(mchId); + if (shopMchEntry == null) { + logger.error("无法找到商家入驻信息!"); + return Pair.of(false, "无法找到商家入驻信息"); + } + + // 二级代理商的商家 Id + String sfSupplierId = ""; + // 获取创建店铺的商家Id(由店铺的县级代理商提供) + if (CheckUtil.isNotEmpty(shopMchEntry.getDistributor_id())) { + logger.debug("获取创建店铺的县级代理商Id: distributorId={}", shopMchEntry.getDistributor_id()); + sfSupplierId = esignPlatformInfoService.getSupplierIdByAgentId(shopMchEntry.getDistributor_id()); + } + + // 县级代理商如果没有商家Id,直接获取默认配置的商家Id + if (StrUtil.isBlank(sfSupplierId)) { + sfSupplierId = supplierId; + } + // 4. 构建请求参数 Map params = buildCommonParams(); - params.put("supplier_id", supplierId); // 店铺所属商家id + params.put("supplier_id", sfSupplierId); // 店铺所属商家id(应该由县级代理商提供) params.put("out_shop_id", storeId); // 外部店铺ID params.put("shop_name", shopName); // 店铺名称 params.put("city_name", cityName); // 城市名称 diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java index 5ca7fa9d..4a530238 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java @@ -190,8 +190,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl 0 ? areaNames[areaNames.length - 1] : storeArea.replace("/", ""); - sfExpressApiService.createSfExpressShop(storeId, shopMchEntry.getStore_name(), + + sfExpressApiService.createSfExpressShop(mchId, storeId, shopMchEntry.getStore_name(), cityName, shopMchEntry.getStore_address(), shopMchEntry.getContact_name(), contact_mobile, shopMchEntry.getStore_longitude(), shopMchEntry.getStore_latitude()); }