Merge remote-tracking branch 'origin/main'
# Conflicts: # mall-shop/src/main/java/com/suisung/mall/shop/sfexpress/service/impl/SFExpressApiServiceImpl.java
This commit is contained in:
commit
c3a3b2800a
@ -339,85 +339,6 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建顺丰同城(普通型)店铺(直调顺丰同城的接口,脱离我们的业务)
|
||||
*
|
||||
* @param storeId 商家门店ID
|
||||
* @param shopName 店名
|
||||
* @param cityName 城市
|
||||
* @param shopAddress 店铺详细地址
|
||||
* @param contactName 店铺联系人
|
||||
* @param contactPhone 店铺电话
|
||||
* @param longitude 经度
|
||||
* @param latitude 纬度
|
||||
* @return Pair<Boolean, String> 第一个元素表示是否成功,第二个元素表示结果信息或错误信息
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> createSfExpressShopInner(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);
|
||||
return Pair.of(false, "创建顺丰店铺,缺少必要参数!");
|
||||
}
|
||||
|
||||
// 4. 构建请求参数
|
||||
Map<String, Object> params = buildCommonParams();
|
||||
params.put("supplier_id", supplierId); // 店铺所属商家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. 发送请求到顺丰接口
|
||||
String paramJSON = JsonUtil.toJSONString(params);
|
||||
String sendUrl = buildUrl("createShop", paramJSON);
|
||||
String responseStr = HttpUtil.post(sendUrl, paramJSON);
|
||||
logger.debug("创建顺丰店铺结果:{}", responseStr);
|
||||
if (StrUtil.isBlank(responseStr)) {
|
||||
logger.error("创建顺丰店铺异常,无返回值!");
|
||||
return Pair.of(false, "创建顺丰店铺异常,无返回值!");
|
||||
}
|
||||
|
||||
ThirdApiRes apiRes = JSONUtil.toBean(responseStr, ThirdApiRes.class);
|
||||
if (apiRes == null) {
|
||||
logger.error("创建顺丰店铺异常,返回值有误!!");
|
||||
return Pair.of(false, "创建顺丰店铺异常,返回值有误!");
|
||||
}
|
||||
|
||||
// 6. 检查接口调用结果
|
||||
if (!apiRes.getError_code().equals(0) || apiRes.getResult() == null) {
|
||||
String errMsg = apiRes.getError_code().equals(0) ? "创建顺丰店铺失败!" : "创建顺丰店铺失败: " + apiRes.getError_msg();
|
||||
logger.error("创建顺丰店铺失败: {}", errMsg);
|
||||
return Pair.of(false, errMsg);
|
||||
}
|
||||
|
||||
// 7. 提取顺丰店铺ID并更新数据库
|
||||
JSONObject result = (JSONObject) apiRes.getResult();
|
||||
String sfShopId = result.getStr("shop_id");
|
||||
|
||||
logger.info("成功创建顺丰店铺,店铺ID: {}", sfShopId);
|
||||
return Pair.of(true, sfShopId);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("创建顺丰同城店铺时发生异常: ", e);
|
||||
return Pair.of(false, "创建顺丰同城店铺时发生异常: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建顺丰同城店铺异步通知回调
|
||||
*
|
||||
@ -1245,18 +1166,17 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
/**
|
||||
* 自行发货
|
||||
*
|
||||
* @param orderId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CommonResult selDelivery(String orderId) {
|
||||
ShopOrderBase shopOrderBase = checkedOrder(orderId);
|
||||
if (!shopOrderBase.getOperate_flag().equals("0")) {
|
||||
if(!shopOrderBase.getOperate_flag().equals("0")){
|
||||
return CommonResult.failed("该状态不允许发货操作");
|
||||
}
|
||||
Pair<Boolean, String> pair = wxOrderShippingService.uploadShippingInfoToWx(2, shopOrderBase.getOrder_id());
|
||||
if (pair.getFirst()) {
|
||||
Pair<Boolean, String> pair= wxOrderShippingService.uploadShippingInfoToWx(2,shopOrderBase.getOrder_id());
|
||||
if(pair.getFirst()){
|
||||
//完成订单后修改订单异常操作流程进入完成订单环节
|
||||
shopOrderBase.setOperate_flag("1");
|
||||
shopOrderBaseService.updateById(shopOrderBase);
|
||||
@ -1265,11 +1185,11 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
||||
itemQueryWrapper.eq("order_id", orderId);
|
||||
List<ShopOrderItem> order_item_rows = shopOrderItemService.find(itemQueryWrapper);
|
||||
if (!order_item_rows.isEmpty()) {
|
||||
if(!order_item_rows.isEmpty()){
|
||||
for (ShopOrderItem shopOrderItem : order_item_rows) {
|
||||
Map<String, Integer> stockDeltaMap = new HashMap<>();
|
||||
String item_src_id = shopOrderItem.getItem_src_id();
|
||||
Integer order_item_quantity = shopOrderItem.getOrder_item_quantity();
|
||||
String item_src_id= shopOrderItem.getItem_src_id();
|
||||
Integer order_item_quantity=shopOrderItem.getOrder_item_quantity();
|
||||
stockDeltaMap.put(item_src_id + "-" + shopOrderItem.getOrder_id(), -order_item_quantity);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
}
|
||||
@ -1281,13 +1201,12 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
/**
|
||||
* 商家自行配送完成订单
|
||||
*
|
||||
* @param shopOrderId
|
||||
*/
|
||||
public CommonResult selFinishOrder(String shopOrderId) {
|
||||
Integer orderStatus = StateCode.ORDER_STATE_RECEIVED; //已签收
|
||||
ShopOrderBase shopOrderBase = checkedOrder(shopOrderId);
|
||||
if (!shopOrderBase.getOperate_flag().equals("1")) {
|
||||
if(!shopOrderBase.getOperate_flag().equals("1")){
|
||||
return CommonResult.failed("该状态不允许完成订单操作");
|
||||
}
|
||||
// 送达后,发出催促微信用户确认收货通知 (同城配送不能调用微信的确认收货)
|
||||
@ -1304,28 +1223,27 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
||||
|
||||
/**
|
||||
* 校验订单是否正确
|
||||
*
|
||||
* @param shopOrderId
|
||||
* @return
|
||||
*/
|
||||
private ShopOrderBase checkedOrder(String shopOrderId) {
|
||||
if (StringUtils.isBlank(shopOrderId)) {
|
||||
private ShopOrderBase checkedOrder(String shopOrderId){
|
||||
if(StringUtils.isBlank(shopOrderId)){
|
||||
logger.info("订单号不能为空");
|
||||
throw new ApiException("订单号不能为空");
|
||||
}
|
||||
UserDto userDto = ContextUtil.getCurrentUser();
|
||||
if (userDto == null) {
|
||||
UserDto userDto= ContextUtil.getCurrentUser();
|
||||
if(userDto==null){
|
||||
logger.info("用户不能为空");
|
||||
throw new ApiException("用户不能为空");
|
||||
}
|
||||
if (userDto.getRole_id() != 2) {
|
||||
if(userDto.getRole_id()!=2){
|
||||
throw new ApiException("用户无权限");
|
||||
}
|
||||
QueryWrapper<ShopOrderBase> shopOrderBaseQueryWrapper = new QueryWrapper<>();
|
||||
shopOrderBaseQueryWrapper.eq("order_id", shopOrderId);
|
||||
shopOrderBaseQueryWrapper.eq("store_id", Integer.valueOf(userDto.getStore_id()));
|
||||
List<ShopOrderBase> shopOrderBaseList = shopOrderBaseService.list(shopOrderBaseQueryWrapper);
|
||||
if (shopOrderBaseList.isEmpty()) {
|
||||
List<ShopOrderBase> shopOrderBaseList= shopOrderBaseService.list(shopOrderBaseQueryWrapper);
|
||||
if(shopOrderBaseList.isEmpty()){
|
||||
logger.info("订单号不存在");
|
||||
throw new ApiException("订单号不存在");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user