From fb624cbc88d12117f363c45569c624f34e873abb Mon Sep 17 00:00:00 2001 From: wangchaoxu Date: Thu, 14 Sep 2023 16:56:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=96=E5=BA=97=E6=B6=88=E6=81=AF=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=BB=BB=E5=8A=A1=E6=97=B6=E4=BC=A0accesstoken?= =?UTF-8?q?=E5=8E=BB=E8=8E=B7=E5=8F=96=E8=AE=A2=E5=8D=95=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/ms/api/service/OpOrderService.java | 3 ++- .../ms/api/service/impl/OpOrderServiceImpl.java | 15 +++++++++------ .../main/java/com/ms/api/util/DdRequestUtil.java | 4 ++-- .../src/main/java/com/ms/api/util/OrderUtil.java | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java b/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java index 2d56dcd5..6832d43b 100644 --- a/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java +++ b/ms-biz/src/main/java/com/ms/api/service/OpOrderService.java @@ -2,6 +2,7 @@ package com.ms.api.service; import com.alibaba.fastjson.JSONObject; import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData; +import com.doudian.open.core.AccessToken; import com.ms.api.bo.ShopBO; import com.ms.api.common.ApiResult; import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO; @@ -43,7 +44,7 @@ public interface OpOrderService { List getListByOrderIds(List orderIds); - JSONObject rsyncOpOrderByOrderIds(String shopId, List orderIds, Map orderIdAndDdMsgOrderStatusMap + JSONObject rsyncOpOrderByOrderIds(String shopId, List orderIds, AccessToken accessToken, Map orderIdAndDdMsgOrderStatusMap , boolean fromDyCloud); /** diff --git a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java index 81b157f5..90d382dd 100644 --- a/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/api/service/impl/OpOrderServiceImpl.java @@ -48,6 +48,7 @@ import com.doudian.open.api.order_searchList.OrderSearchListResponse; import com.doudian.open.api.order_searchList.data.OrderSearchListData; import com.doudian.open.api.order_searchList.data.ShopOrderListItem; import com.doudian.open.api.order_searchList.param.OrderSearchListParam; +import com.doudian.open.core.AccessToken; import com.ms.api.bo.ShopBO; import com.ms.api.common.ApiResult; import com.ms.api.consts.AfterSaleConst; @@ -334,7 +335,7 @@ public class OpOrderServiceImpl implements OpOrderService { } @Override - public JSONObject rsyncOpOrderByOrderIds(String shopId, List orderIds, Map orderIdAndDdMsgOrderStatusMap + public JSONObject rsyncOpOrderByOrderIds(String shopId, List orderIds, AccessToken accessToken, Map orderIdAndDdMsgOrderStatusMap , boolean fromDyCloud) { if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(orderIds)) { throw new RuntimeException("参数错误"); @@ -352,7 +353,7 @@ public class OpOrderServiceImpl implements OpOrderService { if (ObjectUtil.isNull(orderRet) || !orderRet.isSuccess() || (ObjectUtil.isEmpty(orderIdAndDdMsgOrderStatusMap) && (orderIdAndDdMsgOrderStatusMap.containsKey(orderId) && !dyCloudOrderStatus.equals(orderIdAndDdMsgOrderStatusMap.get(orderId))))) { log.info("start getOrderDetailFromDdV2"); - orderRet = getOrderDetailFromDdV2(orderId, 1); + orderRet = getOrderDetailFromDdV2(orderId, accessToken, 1); } if (!orderRet.isSuccess()) { orderIdAndFailReasonMap.put(orderId, String.format(" orderId:【%s】,reason:【%s】", orderId, orderRet.getMsg())); @@ -1480,14 +1481,14 @@ public class OpOrderServiceImpl implements OpOrderService { return opOrderMapper.selectByOrderId(orderId); } - private ApiResult getOrderDetailFromDdV2(String orderId, Integer isSearchable) { + private ApiResult getOrderDetailFromDdV2(String orderId, AccessToken accessToken, Integer isSearchable) { if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(isSearchable)) { return ApiResult.fail("参数错误"); } OrderOrderDetailParam param = new OrderOrderDetailParam(); param.setShopOrderId(orderId); param.setIsSearchable(isSearchable == 1); - return DdRequestUtil.orderOrderDetailRequest(param); + return DdRequestUtil.orderOrderDetailRequest(param, accessToken); } @Transactional(rollbackFor = Exception.class) @@ -1730,7 +1731,7 @@ public class OpOrderServiceImpl implements OpOrderService { OrderOrderDetailParam param = new OrderOrderDetailParam(); param.setShopOrderId(orderId); param.setIsSearchable(true); - ApiResult apiResult = DdRequestUtil.orderOrderDetailRequest(param); + ApiResult apiResult = DdRequestUtil.orderOrderDetailRequest(param, null); ShopOrderDetail shopOrderDetail = apiResult.getData(); if (apiResult.isSuccess() && shopOrderDetail != null) { orderList.add(shopOrderDetail); @@ -2416,6 +2417,8 @@ public class OpOrderServiceImpl implements OpOrderService { } JSONObject msgData = StringUtils.isEmpty(doudianMsgInfo.getData()) ? new JSONObject() : JSONObject.parseObject(doudianMsgInfo.getData()); + ShopBO shopInfo = shopService.getShopInfo(Long.valueOf(msgData.getString("shop_id"))); + String pId = !StringUtils.isEmpty(msgData.getString("p_id")) ? msgData.getString("p_id") : msgData.getString("shop_order_id"); Integer tagVal = Integer.valueOf(doudianMsgInfo.getTag()); @@ -2428,7 +2431,7 @@ public class OpOrderServiceImpl implements OpOrderService { Map orderIdAndDdMsgOrderStatusMap = new HashMap<>(); log.info("start rsyncOpOrderByOrderIds"); - JSONObject ret = rsyncOpOrderByOrderIds(msgData.getString("shop_id"), orderIds, orderIdAndDdMsgOrderStatusMap, true); + JSONObject ret = rsyncOpOrderByOrderIds(msgData.getString("shop_id"), orderIds, shopInfo.getShopAccessToken(), orderIdAndDdMsgOrderStatusMap, true); if (ret.containsKey("orderIdAndFailReasonMap")) { Map orderIdAndFailReasonMap = (Map) JSON.parseObject(ret.getString("orderIdAndFailReasonMap"), Map.class); if (orderIdAndFailReasonMap.containsKey(orderId)) { diff --git a/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java b/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java index e42816c2..d30eb6e1 100644 --- a/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java +++ b/ms-biz/src/main/java/com/ms/api/util/DdRequestUtil.java @@ -105,7 +105,7 @@ public class DdRequestUtil { throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg())); } - public static ApiResult orderOrderDetailRequest(OrderOrderDetailParam param) { + public static ApiResult orderOrderDetailRequest(OrderOrderDetailParam param, AccessToken accessToken) { String activeProfile = System.getenv("sys-deploy-env"); if (!"Prod".equals(activeProfile)) { AuthThreadLocalUtil.set(AppConst.TEST_SHOP_ID); @@ -113,7 +113,7 @@ public class DdRequestUtil { OrderOrderDetailRequest request = new OrderOrderDetailRequest(); request.setParam(param); log.info("=============Dd请求餐素:{}===================", JSONObject.toJSONString(param)); - OrderOrderDetailResponse response = request.execute(); + OrderOrderDetailResponse response = ObjectUtil.isNull(accessToken) ? request.execute() : request.execute(accessToken); log.info("=============Dd请求返回:{}===================", JSONObject.toJSONString(response)); boolean success = CommonTool.checkDdApiRequestIsSuccess(response); if (success && ObjectUtil.isNotEmpty(response.getData())) { diff --git a/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java b/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java index c521d1ac..9e1fdf30 100644 --- a/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java +++ b/ms-biz/src/main/java/com/ms/api/util/OrderUtil.java @@ -49,7 +49,7 @@ public class OrderUtil { // if (ObjectUtil.isEmpty(shopInfo)) { // return ApiResult.fail("请检查用户是否购买了软件"); // } - JSONObject ret = opOrderService.rsyncOpOrderByOrderIds(targetShopId, orderIds, new HashMap<>(), false); + JSONObject ret = opOrderService.rsyncOpOrderByOrderIds(targetShopId, orderIds, null, new HashMap<>(), false); if (ret.containsKey("orderIdAndFailReasonMap")) { Map orderIdAndFailReasonMap = (Map) JSON.parseObject(ret.getString("orderIdAndFailReasonMap"), Map.class); if (ObjectUtil.isEmpty(orderIdAndFailReasonMap)) {