抖店消息自动任务时传accesstoken去获取订单信息

20230922-ljl-fixBug
wangchaoxu 1 year ago
parent 7358dfdcdb
commit fb624cbc88

@ -2,6 +2,7 @@ package com.ms.api.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.doudian.open.api.order_logisticsAddMultiPack.data.OrderLogisticsAddMultiPackData; 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.bo.ShopBO;
import com.ms.api.common.ApiResult; import com.ms.api.common.ApiResult;
import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO; import com.ms.api.dto.order.OrderMultiPackageOutstorageDTO;
@ -43,7 +44,7 @@ public interface OpOrderService {
List<OpOrder> getListByOrderIds(List<String> orderIds); List<OpOrder> getListByOrderIds(List<String> orderIds);
JSONObject rsyncOpOrderByOrderIds(String shopId, List<String> orderIds, Map<String, String> orderIdAndDdMsgOrderStatusMap JSONObject rsyncOpOrderByOrderIds(String shopId, List<String> orderIds, AccessToken accessToken, Map<String, String> orderIdAndDdMsgOrderStatusMap
, boolean fromDyCloud); , boolean fromDyCloud);
/** /**

@ -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.OrderSearchListData;
import com.doudian.open.api.order_searchList.data.ShopOrderListItem; import com.doudian.open.api.order_searchList.data.ShopOrderListItem;
import com.doudian.open.api.order_searchList.param.OrderSearchListParam; 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.bo.ShopBO;
import com.ms.api.common.ApiResult; import com.ms.api.common.ApiResult;
import com.ms.api.consts.AfterSaleConst; import com.ms.api.consts.AfterSaleConst;
@ -334,7 +335,7 @@ public class OpOrderServiceImpl implements OpOrderService {
} }
@Override @Override
public JSONObject rsyncOpOrderByOrderIds(String shopId, List<String> orderIds, Map<String, String> orderIdAndDdMsgOrderStatusMap public JSONObject rsyncOpOrderByOrderIds(String shopId, List<String> orderIds, AccessToken accessToken, Map<String, String> orderIdAndDdMsgOrderStatusMap
, boolean fromDyCloud) { , boolean fromDyCloud) {
if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(orderIds)) { if (ObjectUtil.isEmpty(shopId) || ObjectUtil.isEmpty(orderIds)) {
throw new RuntimeException("参数错误"); throw new RuntimeException("参数错误");
@ -352,7 +353,7 @@ public class OpOrderServiceImpl implements OpOrderService {
if (ObjectUtil.isNull(orderRet) || !orderRet.isSuccess() || (ObjectUtil.isEmpty(orderIdAndDdMsgOrderStatusMap) && (orderIdAndDdMsgOrderStatusMap.containsKey(orderId) if (ObjectUtil.isNull(orderRet) || !orderRet.isSuccess() || (ObjectUtil.isEmpty(orderIdAndDdMsgOrderStatusMap) && (orderIdAndDdMsgOrderStatusMap.containsKey(orderId)
&& !dyCloudOrderStatus.equals(orderIdAndDdMsgOrderStatusMap.get(orderId))))) { && !dyCloudOrderStatus.equals(orderIdAndDdMsgOrderStatusMap.get(orderId))))) {
log.info("start getOrderDetailFromDdV2"); log.info("start getOrderDetailFromDdV2");
orderRet = getOrderDetailFromDdV2(orderId, 1); orderRet = getOrderDetailFromDdV2(orderId, accessToken, 1);
} }
if (!orderRet.isSuccess()) { if (!orderRet.isSuccess()) {
orderIdAndFailReasonMap.put(orderId, String.format(" orderId:【%s】reason【%s】", orderId, orderRet.getMsg())); 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); return opOrderMapper.selectByOrderId(orderId);
} }
private ApiResult<ShopOrderDetail> getOrderDetailFromDdV2(String orderId, Integer isSearchable) { private ApiResult<ShopOrderDetail> getOrderDetailFromDdV2(String orderId, AccessToken accessToken, Integer isSearchable) {
if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(isSearchable)) { if (ObjectUtil.isEmpty(orderId) || ObjectUtil.isEmpty(isSearchable)) {
return ApiResult.fail("参数错误"); return ApiResult.fail("参数错误");
} }
OrderOrderDetailParam param = new OrderOrderDetailParam(); OrderOrderDetailParam param = new OrderOrderDetailParam();
param.setShopOrderId(orderId); param.setShopOrderId(orderId);
param.setIsSearchable(isSearchable == 1); param.setIsSearchable(isSearchable == 1);
return DdRequestUtil.orderOrderDetailRequest(param); return DdRequestUtil.orderOrderDetailRequest(param, accessToken);
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -1730,7 +1731,7 @@ public class OpOrderServiceImpl implements OpOrderService {
OrderOrderDetailParam param = new OrderOrderDetailParam(); OrderOrderDetailParam param = new OrderOrderDetailParam();
param.setShopOrderId(orderId); param.setShopOrderId(orderId);
param.setIsSearchable(true); param.setIsSearchable(true);
ApiResult<ShopOrderDetail> apiResult = DdRequestUtil.orderOrderDetailRequest(param); ApiResult<ShopOrderDetail> apiResult = DdRequestUtil.orderOrderDetailRequest(param, null);
ShopOrderDetail shopOrderDetail = apiResult.getData(); ShopOrderDetail shopOrderDetail = apiResult.getData();
if (apiResult.isSuccess() && shopOrderDetail != null) { if (apiResult.isSuccess() && shopOrderDetail != null) {
orderList.add(shopOrderDetail); orderList.add(shopOrderDetail);
@ -2416,6 +2417,8 @@ public class OpOrderServiceImpl implements OpOrderService {
} }
JSONObject msgData = StringUtils.isEmpty(doudianMsgInfo.getData()) ? new JSONObject() : JSONObject.parseObject(doudianMsgInfo.getData()); 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"); String pId = !StringUtils.isEmpty(msgData.getString("p_id")) ? msgData.getString("p_id") : msgData.getString("shop_order_id");
Integer tagVal = Integer.valueOf(doudianMsgInfo.getTag()); Integer tagVal = Integer.valueOf(doudianMsgInfo.getTag());
@ -2428,7 +2431,7 @@ public class OpOrderServiceImpl implements OpOrderService {
Map<String, String> orderIdAndDdMsgOrderStatusMap = new HashMap<>(); Map<String, String> orderIdAndDdMsgOrderStatusMap = new HashMap<>();
log.info("start rsyncOpOrderByOrderIds"); 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")) { if (ret.containsKey("orderIdAndFailReasonMap")) {
Map<String, String> orderIdAndFailReasonMap = (Map<String, String>) JSON.parseObject(ret.getString("orderIdAndFailReasonMap"), Map.class); Map<String, String> orderIdAndFailReasonMap = (Map<String, String>) JSON.parseObject(ret.getString("orderIdAndFailReasonMap"), Map.class);
if (orderIdAndFailReasonMap.containsKey(orderId)) { if (orderIdAndFailReasonMap.containsKey(orderId)) {

@ -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())); throw new RuntimeException(String.format("抖店请求错误:msg:%s,code:%s,subCode:%s,subMsg:%s,", response.getMsg(), response.getCode(), response.getSubCode(), response.getSubMsg()));
} }
public static ApiResult<ShopOrderDetail> orderOrderDetailRequest(OrderOrderDetailParam param) { public static ApiResult<ShopOrderDetail> orderOrderDetailRequest(OrderOrderDetailParam param, AccessToken accessToken) {
String activeProfile = System.getenv("sys-deploy-env"); String activeProfile = System.getenv("sys-deploy-env");
if (!"Prod".equals(activeProfile)) { if (!"Prod".equals(activeProfile)) {
AuthThreadLocalUtil.set(AppConst.TEST_SHOP_ID); AuthThreadLocalUtil.set(AppConst.TEST_SHOP_ID);
@ -113,7 +113,7 @@ public class DdRequestUtil {
OrderOrderDetailRequest request = new OrderOrderDetailRequest(); OrderOrderDetailRequest request = new OrderOrderDetailRequest();
request.setParam(param); request.setParam(param);
log.info("=============Dd请求餐素:{}===================", JSONObject.toJSONString(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)); log.info("=============Dd请求返回:{}===================", JSONObject.toJSONString(response));
boolean success = CommonTool.checkDdApiRequestIsSuccess(response); boolean success = CommonTool.checkDdApiRequestIsSuccess(response);
if (success && ObjectUtil.isNotEmpty(response.getData())) { if (success && ObjectUtil.isNotEmpty(response.getData())) {

@ -49,7 +49,7 @@ public class OrderUtil {
// if (ObjectUtil.isEmpty(shopInfo)) { // if (ObjectUtil.isEmpty(shopInfo)) {
// return ApiResult.fail("请检查用户是否购买了软件"); // 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")) { if (ret.containsKey("orderIdAndFailReasonMap")) {
Map<String, String> orderIdAndFailReasonMap = (Map<String, String>) JSON.parseObject(ret.getString("orderIdAndFailReasonMap"), Map.class); Map<String, String> orderIdAndFailReasonMap = (Map<String, String>) JSON.parseObject(ret.getString("orderIdAndFailReasonMap"), Map.class);
if (ObjectUtil.isEmpty(orderIdAndFailReasonMap)) { if (ObjectUtil.isEmpty(orderIdAndFailReasonMap)) {

Loading…
Cancel
Save