顺丰配置 商家id
This commit is contained in:
parent
f87242a929
commit
3e9688f21d
@ -1838,8 +1838,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
||||
|
||||
// 10. 检查商户绑定状态是否完成, 更改总的审核状态
|
||||
shopMchEntryService.checkMerchEntryFinished(mchId);
|
||||
|
||||
|
||||
|
||||
// 11. 日志记录并返回成功响应
|
||||
log.info("商家绑定分账接收方异步通知处理完成,mchId:{} merCupNo:{}", mchId, merCupNo);
|
||||
return JSONUtil.createObj().set("code", "SUCCESS").set("message", "分账接收方绑定成功");
|
||||
|
||||
@ -184,7 +184,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
logger.error("创建顺丰同店铺:联系人手机号不能为空");
|
||||
return Pair.of(false, "联系人手机号不能为空");
|
||||
}
|
||||
|
||||
|
||||
AddressParseResultTO addressParseResultTO = AddressUtil.parseAddress(shopMchEntry.getStore_address());
|
||||
// 解析城市名称
|
||||
String cityName = "桂平市"; // 默认城市
|
||||
@ -244,7 +244,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
* @param contactPhone 店铺电话
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @return
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示结果信息或错误信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> createSfExpressShop(Long mchId, Integer storeId, String shopName, String cityName,
|
||||
@ -254,12 +254,33 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
try {
|
||||
// 1. 验证必要参数
|
||||
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);
|
||||
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, "创建顺丰店铺,缺少必要参数!");
|
||||
}
|
||||
|
||||
// 2. 获取或初始化商家配送信息
|
||||
// 2. 获取商家入驻信息
|
||||
ShopMchEntry shopMchEntry;
|
||||
if (CheckUtil.isNotEmpty(mchId)) {
|
||||
shopMchEntry = shopMchEntryService.shopMerchEntryById(mchId);
|
||||
if (shopMchEntry == null) {
|
||||
logger.error("无法找到商家入驻信息!mchId: {}", mchId);
|
||||
return Pair.of(false, "无法找到商家入驻信息");
|
||||
}
|
||||
|
||||
storeId = Convert.toInt(shopMchEntry.getStore_id());
|
||||
|
||||
} else {
|
||||
shopMchEntry = shopMchEntryService.getShopMerchEntryByStoreId(storeId);
|
||||
if (shopMchEntry == null) {
|
||||
logger.error("无法找到商家入驻信息!storeId: {}", storeId);
|
||||
return Pair.of(false, "无法找到商家入驻信息");
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 获取或初始化商家配送信息
|
||||
ShopStoreSameCityTransportBase transportBase = shopStoreSameCityTransportBaseService
|
||||
.getShopStoreSameCityTransportBaseById(Long.valueOf(storeId));
|
||||
|
||||
@ -270,27 +291,21 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
}
|
||||
|
||||
if (transportBase == null) {
|
||||
logger.error("创建商家配送信息失败!");
|
||||
logger.error("创建商家配送信息失败!storeId: {}", storeId);
|
||||
return Pair.of(false, "创建商家配送信息失败");
|
||||
}
|
||||
|
||||
// 3. 如果已存在顺丰店铺ID,验证其有效性
|
||||
// 4. 如果已存在顺丰店铺ID,验证其有效性
|
||||
if (CheckUtil.isNotEmpty(transportBase.getShop_id())) {
|
||||
logger.debug("如果存在店铺Id,从顺丰同城平台查询店铺ID,开始验证其有效性!");
|
||||
logger.debug("检测到已存在店铺Id,开始验证其有效性!shopId: {}", transportBase.getShop_id());
|
||||
ThirdApiRes shopInfo = getSfShopInfo(transportBase.getShop_id());
|
||||
if (shopInfo != null && shopInfo.getError_code().equals(0)) {
|
||||
logger.info("已成功创建顺丰同城店铺!");
|
||||
logger.info("已成功创建顺丰同城店铺!shopId: {}", transportBase.getShop_id());
|
||||
return Pair.of(true, transportBase.getShop_id());
|
||||
}
|
||||
}
|
||||
|
||||
ShopMchEntry shopMchEntry = shopMchEntryService.shopMerchEntryById(mchId);
|
||||
if (shopMchEntry == null) {
|
||||
logger.error("无法找到商家入驻信息!");
|
||||
return Pair.of(false, "无法找到商家入驻信息");
|
||||
}
|
||||
|
||||
// 二级代理商的商家 Id
|
||||
// 5. 获取供应商ID
|
||||
String sfSupplierId = "";
|
||||
// 获取创建店铺的商家Id(由店铺的县级代理商提供)
|
||||
if (CheckUtil.isNotEmpty(shopMchEntry.getDistributor_id())) {
|
||||
@ -303,32 +318,28 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
sfSupplierId = supplierId;
|
||||
}
|
||||
|
||||
// 4. 构建请求参数
|
||||
// 6. 构建请求参数
|
||||
Map<String, Object> params = buildCommonParams();
|
||||
params.put("supplier_id", sfSupplierId); // 店铺所属商家id(应该由县级代理商提供)
|
||||
params.put("out_shop_id", storeId); // 外部店铺ID
|
||||
params.put("shop_name", shopName); // 店铺名称
|
||||
params.put("city_name", cityName); // 城市名称
|
||||
|
||||
// RMK 1:快餐 2:药品 3:百货 4:脏衣服收 5:干净衣服派 6:生鲜 8:高端饮品 9:现场勘验 10:快递 12:文件 13:蛋糕 14:鲜花 15:数码 16:服装 17:
|
||||
//汽配 18:珠宝 20:披萨 21:中餐 22:水产 27:专人直送 32:中端饮品 33:便利店 34:面包糕点 35:火锅 36:证照 40:烧烤小龙虾 41:外部落地配 47:烟酒
|
||||
//行 48:成人用品 99:其他
|
||||
// 经营类型: 快餐,百货,生鲜,高端饮品,蛋糕,鲜花,数码,服装,披萨,水产,中端饮品,便利店,面包糕点,烟酒,其他
|
||||
params.put("shop_product_types", "33"); //"1,3,6,8,13,14,15,16,20,22,32,33,34,47,99"
|
||||
params.put("shop_type", 1); // 店铺类型: 1-普通型 2-平台型
|
||||
params.put("shop_address", shopAddress); // 店铺地址
|
||||
params.put("longitude", longitude); // 经度
|
||||
params.put("latitude", latitude); // 纬度
|
||||
params.put("shop_contact_name", contactName); // 联系人姓名
|
||||
params.put("shop_contact_phone", contactPhone); // 联系电话
|
||||
params.put("supplier_id", sfSupplierId); // 店铺所属商家id(应该由县级代理商提供)
|
||||
params.put("out_shop_id", storeId); // 外部店铺ID
|
||||
params.put("shop_name", shopName); // 店铺名称
|
||||
params.put("city_name", cityName); // 城市名称
|
||||
params.put("shop_product_types", "33"); // 经营类型: 33-便利店
|
||||
params.put("shop_type", 1); // 店铺类型: 1-普通型 2-平台型
|
||||
params.put("shop_address", shopAddress); // 店铺地址
|
||||
params.put("longitude", longitude); // 经度
|
||||
params.put("latitude", latitude); // 纬度
|
||||
params.put("shop_contact_name", contactName); // 联系人姓名
|
||||
params.put("shop_contact_phone", contactPhone); // 联系电话
|
||||
|
||||
logger.debug("开始创建顺丰店铺,参数:{}", params);
|
||||
|
||||
// 5. 发送请求到顺丰接口
|
||||
// 7. 发送请求到顺丰接口
|
||||
String paramJSON = JsonUtil.toJSONString(params);
|
||||
String sendUrl = buildUrl("createShop", paramJSON);
|
||||
String responseStr = HttpUtil.post(sendUrl, paramJSON);
|
||||
logger.debug("创建顺丰店铺结果:{}", responseStr);
|
||||
logger.debug("创建顺丰店铺结果: {}", responseStr);
|
||||
|
||||
if (StrUtil.isBlank(responseStr)) {
|
||||
logger.error("创建顺丰店铺异常,无返回值!");
|
||||
return Pair.of(false, "创建顺丰店铺异常,无返回值!");
|
||||
@ -340,18 +351,24 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
return Pair.of(false, "创建顺丰店铺异常,返回值有误!");
|
||||
}
|
||||
|
||||
// 6. 检查接口调用结果
|
||||
// 8. 检查接口调用结果
|
||||
if (!apiRes.getError_code().equals(0) || apiRes.getResult() == null) {
|
||||
String errMsg = apiRes.getError_code().equals(0) ? "创建顺丰店铺失败!" : "创建顺丰店铺失败: " + apiRes.getError_msg();
|
||||
String errMsg = StrUtil.isBlank(apiRes.getError_msg()) ?
|
||||
"创建顺丰店铺失败。" : "创建顺丰店铺失败: " + apiRes.getError_msg();
|
||||
logger.error("创建顺丰店铺失败: {}", errMsg);
|
||||
return Pair.of(false, errMsg);
|
||||
}
|
||||
|
||||
// 7. 提取顺丰店铺ID并更新数据库
|
||||
// 9. 提取顺丰店铺ID并更新数据库
|
||||
JSONObject result = (JSONObject) apiRes.getResult();
|
||||
String sfShopId = result.getStr("shop_id");
|
||||
if (StrUtil.isBlank(sfShopId)) {
|
||||
logger.error("创建顺丰店铺失败,返回的店铺ID为空");
|
||||
return Pair.of(false, "创建顺丰店铺失败,返回的店铺ID为空");
|
||||
}
|
||||
|
||||
transportBase.setShop_id(sfShopId);
|
||||
transportBase.setShop_state(CommonConstant.Enable);// 顺丰同城快递商品特惠
|
||||
transportBase.setShop_state(CommonConstant.Enable); // 顺丰同城快递商品特惠
|
||||
transportBase.setDelivery_brand(CommonConstant.DELIVERY_BRAND_SF);
|
||||
|
||||
Pair<Long, String> updateResult = shopStoreSameCityTransportBaseService
|
||||
@ -371,6 +388,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建顺丰同城(普通型)店铺(直调顺丰同城的接口,脱离我们的业务)
|
||||
*
|
||||
|
||||
@ -1762,8 +1762,8 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
}
|
||||
|
||||
UpdateWrapper<ShopMchEntry> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", mchId).eq("status", CommonConstant.Enable)
|
||||
.ne("approval_status", CommonConstant.MCH_APPR_STA_PASS);
|
||||
updateWrapper.eq("id", mchId).eq("status", CommonConstant.Enable);
|
||||
//.ne("approval_status", CommonConstant.MCH_APPR_STA_PASS);
|
||||
updateWrapper.set("approval_status", CommonConstant.MCH_APPR_STA_PASS);
|
||||
updateWrapper.set("approval_remark", "恭喜您,入驻流程已全部完成!");
|
||||
boolean updateResult = update(updateWrapper); // 更新商户入驻信息
|
||||
@ -1887,6 +1887,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
|
||||
approvalRemark = "入驻资料正在审核中,请耐心等待";
|
||||
}
|
||||
|
||||
|
||||
updateWrapper.set("approval_remark", approvalRemark);
|
||||
|
||||
// 4. 构建需要更新的字段和值的映射关系
|
||||
|
||||
@ -184,8 +184,8 @@ feieyun:
|
||||
sf-express:
|
||||
# 顺丰同城 api 接口配置
|
||||
dev_id: 1715091463
|
||||
# 桂平顺丰平台商家id 2273453450129
|
||||
supplier_id: 2269768012593
|
||||
# 桂平顺丰平台商家id 2273453450129 2269768012593
|
||||
supplier_id: 2281834525297
|
||||
appid: 1715091463
|
||||
appkey: 47466ae69c530f831395e1bc405639fb
|
||||
# dev_id: 1715091463
|
||||
|
||||
Loading…
Reference in New Issue
Block a user