优化创建顺丰店铺方法的参数

This commit is contained in:
Jack 2025-10-24 17:43:52 +08:00
parent 3ed0363ef1
commit dd3a25856c
8 changed files with 94 additions and 22 deletions

View File

@ -73,4 +73,12 @@ public interface EsignPlatformInfoService {
* @return
*/
EsignPlatformInfo getMch2ndAgentWithShippingFee(Long mchId);
/**
* 根据代理商ID获取供应商 商家ID
*
* @param agentId
* @return
*/
String getSupplierIdByAgentId(Long agentId);
}

View File

@ -122,7 +122,7 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
} else {
log.debug("[获取平台和代理商信息] 未找到一级代理parent_id: {}", agent2nd.getParent_id());
}
log.debug("[获取平台和代理商信息] 查询完成,共获取 {} 条记录", esignPlatformInfos.size());
return esignPlatformInfos;
}
@ -294,4 +294,46 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
return null;
}
/**
* 根据代理商ID获取供应商商家ID
*
* @param agentId 代理商ID
* @return 供应商商家ID未找到时返回空字符串
*/
@Override
public String getSupplierIdByAgentId(Long agentId) {
// 参数校验
if (agentId == null || agentId <= 0) {
log.warn("[获取供应商ID] 参数校验失败代理商ID为空或无效agentId={}", agentId);
return "";
}
try {
log.debug("[获取供应商ID] 开始查询供应商信息agentId={}", agentId);
// 构建查询条件
QueryWrapper<EsignPlatformInfo> 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] 成功获取供应商IDagentId={}, supplierId={}", agentId, result.getSupplier_id());
return result.getSupplier_id();
} else {
log.debug("[获取供应商ID] 未找到有效的供应商IDagentId={}", agentId);
return "";
}
} catch (Exception e) {
log.error("[获取供应商ID] 查询过程中发生异常agentId={}", agentId, e);
return "";
}
}
}

View File

@ -115,4 +115,5 @@ public interface LklLedgerReceiverService extends IBaseService<LklLedgerReceiver
* @return
*/
LklLedgerReceiver getMch2ndAgent(Long mchId);
}

View File

@ -25,7 +25,6 @@ import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.esign.service.EsignPlatformInfoService;
import com.suisung.mall.shop.lakala.mapper.LklLedgerReceiverMapper;
import com.suisung.mall.shop.lakala.service.LakalaApiService;
import com.suisung.mall.shop.lakala.service.LklLedgerMemberService;
import com.suisung.mall.shop.lakala.service.LklLedgerReceiverService;
import com.suisung.mall.shop.store.service.ShopMchEntryService;
import lombok.extern.slf4j.Slf4j;
@ -49,10 +48,6 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
@Resource
private LakalaApiService lakalaApiService;
@Lazy
@Resource
private LklLedgerMemberService lklLedgerMemberService;
@Autowired
private ShopMchEntryService shopMchEntryService;
@ -481,7 +476,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
result = findOne(queryWrapper);
log.debug("[获取二级代理] 使用区域信息查询districtId={}", shopMchEntry.getStore_district());
}
if (result == null) {
log.info("[获取二级代理] 未找到匹配的二级代理信息mchId={}", mchId);
} else {
@ -495,4 +490,5 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl<LklLedgerRecei
return null;
}
}
}

View File

@ -909,8 +909,8 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
return Pair.of(false, "[预约订单校验] 请在店铺营业时间内预约下单");
}
// 7. 预约时间范围检查 - 仅能预约50分钟后的订单
Date fortyFiveMinutesLater = DateUtil.offsetMinute(new Date(), 50);
// 7. 预约时间范围检查 - 仅能预约50分钟后的订单防止用户在下单页面停留太长45分钟也是可以通过的
Date fortyFiveMinutesLater = DateUtil.offsetMinute(new Date(), 45);
if (!bookingBeginTime.after(fortyFiveMinutesLater)) {
return Pair.of(false, "[预约订单校验] 请预约50分后的订单");
}

View File

@ -29,6 +29,7 @@ public interface SFExpressApiService {
/**
* 创建顺丰同店铺-连锁店铺
*
* @param mchId 商家入驻编号
* @param storeId 商家门店ID
* @param shopName 店名
* @param cityName 城市
@ -39,7 +40,7 @@ public interface SFExpressApiService {
* @param latitude 纬度
* @return
*/
Pair<Boolean, String> createSfExpressShop(Integer storeId, String shopName, String cityName, String shopAddress, String contactName, String contactPhone, String longitude, String latitude);
Pair<Boolean, String> createSfExpressShop(Long mchId, Integer storeId, String shopName, String cityName, String shopAddress, String contactName, String contactPhone, String longitude, String latitude);
/**

View File

@ -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<Boolean, String> 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<Boolean, String> 第一个元素表示是否成功第二个元素表示结果信息或错误信息
* @return
*/
@Override
public Pair<Boolean, String> createSfExpressShop(Integer storeId, String shopName, String cityName,
public Pair<Boolean, String> 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<String, Object> 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); // 城市名称

View File

@ -190,8 +190,6 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
@Lazy
@Autowired
private WxQrCodeService wxQrCodeService;
@Autowired
private I18nUtil i18nUtil;
/**
@ -3288,7 +3286,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
shopStoreInfo.setStore_close_hours("21:30");
shopStoreInfo.setStore_discount(BigDecimal.valueOf(10));
shopStoreInfo.setStore_banner(storeFacadeImage);
shopStoreInfo.setStore_tel(contact_mobile);
shopStoreInfo.setContact_mobile(contact_mobile);
shopStoreInfo.setContact_name(shopMchEntry.getContact_name());
@ -3432,7 +3430,8 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
if (storeArea != null) {
String[] areaNames = storeArea.split("/");
String cityName = areaNames.length > 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());
}