Pre Merge pull request !230 from wuKong/fix(social)-应对支付回调与订单信息上传之间的时间差

pull/230/MERGE
wuKong 2026-01-18 07:28:37 +00:00 committed by Gitee
commit 154f6ab130
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 20 additions and 0 deletions

View File

@ -65,6 +65,8 @@ import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
@ -371,6 +373,24 @@ public class SocialClientServiceImpl implements SocialClientService {
try { try {
WxMaOrderShippingInfoBaseResponse response = service.getWxMaOrderShippingService().upload(request); WxMaOrderShippingInfoBaseResponse response = service.getWxMaOrderShippingService().upload(request);
if (response.getErrCode() != 0) { if (response.getErrCode() != 0) {
if (ObjUtil.equals(response.getErrCode(),10060001)) {
// 错误代码10060001, 错误信息:支付单不存在
// 收到支付回调时同步订单到微信很大概率会出现10060001
// 应对支付回调与订单信息上传之间的时间差
CompletableFuture.delayedExecutor(1000, TimeUnit.MILLISECONDS).execute(() -> {
try {
WxMaOrderShippingInfoBaseResponse delayedResponse = service.getWxMaOrderShippingService().upload(request);
if (delayedResponse.getErrCode() != 0) {
log.error("[uploadWxaOrderShippingInfo][上传微信小程序发货信息失败request({}) response({})]", request, delayedResponse);
return;
}
log.info("[uploadWxaOrderShippingInfo][上传微信小程序发货信息成功request({}) response({})]", request, delayedResponse);
} catch (WxErrorException ex) {
log.error("[uploadWxaOrderShippingInfo][上传微信小程序发货信息失败request({})]", request, ex);
}
});
return;
}
log.error("[uploadWxaOrderShippingInfo][上传微信小程序发货信息失败request({}) response({})]", request, response); log.error("[uploadWxaOrderShippingInfo][上传微信小程序发货信息失败request({}) response({})]", request, response);
throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_ORDER_UPLOAD_SHIPPING_INFO_ERROR, response.getErrMsg()); throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_ORDER_UPLOAD_SHIPPING_INFO_ERROR, response.getErrMsg());
} }