分账逻辑的调整
This commit is contained in:
parent
846cc94c0d
commit
1eae2007c3
@ -185,9 +185,9 @@ public interface PayService {
|
|||||||
/**
|
/**
|
||||||
* 更改交易订单的订单状态和付款状态
|
* 更改交易订单的订单状态和付款状态
|
||||||
*
|
*
|
||||||
* @param orderId
|
* @param orderId 订单Id
|
||||||
* @param orderStateId 空值或0将不更新
|
* @param orderStateId 订单状态,空值或0将不更新
|
||||||
* @param tradeIsPaid 空值或0将不更新
|
* @param tradeIsPaid 支付付款状态(ENUM):3010-未付款;3011-付款待审核;3012-部分付款;3013-已付款;空值或0将不更新
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/admin/pay/pay-consume-trade/change/state")
|
@PostMapping(value = "/admin/pay/pay-consume-trade/change/state")
|
||||||
|
|||||||
@ -86,7 +86,6 @@ secure:
|
|||||||
- "/shop/sf-express/cancel-order/notify"
|
- "/shop/sf-express/cancel-order/notify"
|
||||||
- "/shop/sf-express/rider-order-status/notify"
|
- "/shop/sf-express/rider-order-status/notify"
|
||||||
- "/shop/sf-express/order-complete/notify"
|
- "/shop/sf-express/order-complete/notify"
|
||||||
- "/mobile/shop/lakala/trans/receive/completeNotify"
|
|
||||||
- "/shop/sync/third/**"
|
- "/shop/sync/third/**"
|
||||||
- "/esProduct/**"
|
- "/esProduct/**"
|
||||||
- "/admin/oss/upload/**"
|
- "/admin/oss/upload/**"
|
||||||
|
|||||||
@ -20,9 +20,7 @@ import com.lkl.laop.sdk.LKLSDK;
|
|||||||
import com.lkl.laop.sdk.exception.SDKException;
|
import com.lkl.laop.sdk.exception.SDKException;
|
||||||
import com.lkl.laop.sdk.request.V2MmsOpenApiUploadFileRequest;
|
import com.lkl.laop.sdk.request.V2MmsOpenApiUploadFileRequest;
|
||||||
import com.lkl.laop.sdk.request.V3LabsRelationRefundRequest;
|
import com.lkl.laop.sdk.request.V3LabsRelationRefundRequest;
|
||||||
import com.lkl.laop.sdk.request.V3LabsTransPreorderRequest;
|
|
||||||
import com.lkl.laop.sdk.request.model.V3LabsTradeLocationInfo;
|
import com.lkl.laop.sdk.request.model.V3LabsTradeLocationInfo;
|
||||||
import com.lkl.laop.sdk.request.model.V3LabsTradePreorderWechatBus;
|
|
||||||
import com.suisung.mall.common.constant.CommonConstant;
|
import com.suisung.mall.common.constant.CommonConstant;
|
||||||
import com.suisung.mall.common.exception.ApiException;
|
import com.suisung.mall.common.exception.ApiException;
|
||||||
import com.suisung.mall.common.feignService.ShopService;
|
import com.suisung.mall.common.feignService.ShopService;
|
||||||
@ -110,102 +108,6 @@ public class LakalaPayServiceImpl implements LakalaPayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拉卡拉预下单(废弃)
|
|
||||||
* 参考:https://o.lakala.com/#/home/document/detail?id=110
|
|
||||||
*
|
|
||||||
* @param merchantNo 商户号
|
|
||||||
* @param termNo 终端号
|
|
||||||
* @param xcxAppId 小程序appid
|
|
||||||
* @param openId openid
|
|
||||||
* @param storeId 店铺号
|
|
||||||
* @param orderId 订单号
|
|
||||||
* @param subject 订单标题
|
|
||||||
* @param totalAmount 订单金额
|
|
||||||
* @param notifyURL 回调地址
|
|
||||||
* @param requestIP 请求ip
|
|
||||||
* @param remark 备注
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// @Override
|
|
||||||
public JSONObject lklTransPreOrderBak(String merchantNo, String termNo, String xcxAppId, String openId, String storeId, String orderId, String subject, String totalAmount, String notifyURL, String requestIP, String remark) {
|
|
||||||
// 1. 配置初始化
|
|
||||||
initLKLSDK();
|
|
||||||
|
|
||||||
if (StrUtil.isBlank(merchantNo) || StrUtil.isBlank(termNo)) {
|
|
||||||
log.warn("[拉卡拉预下单] 参数校验失败:缺少商户号或终端号, merchantNo={}, termNo={}", merchantNo, termNo);
|
|
||||||
throw new ApiException(I18nUtil._("缺少商户号或终端号!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("[拉卡拉预下单] 开始处理请求, merchantNo={}, termNo={}, orderId={}", merchantNo, termNo, orderId);
|
|
||||||
|
|
||||||
//2. 装配数据
|
|
||||||
/*** 微信主扫场景示例 */
|
|
||||||
V3LabsTransPreorderRequest v3LabsTransPreorderRequest = new V3LabsTransPreorderRequest();
|
|
||||||
v3LabsTransPreorderRequest.setMerchantNo(merchantNo);
|
|
||||||
v3LabsTransPreorderRequest.setTermNo(termNo);
|
|
||||||
v3LabsTransPreorderRequest.setOutTradeNo(orderId);
|
|
||||||
v3LabsTransPreorderRequest.setSubject(subject);
|
|
||||||
//微信:WECHAT 支付宝:ALIPAY 银联:UQRCODEPAY 翼支付: BESTPAY 苏宁易付宝: SUNING 拉卡拉支付账户:LKLACC 网联小钱包:NUCSPAY 京东钱包:JD
|
|
||||||
v3LabsTransPreorderRequest.setAccountType("WECHAT");
|
|
||||||
// 41:NATIVE((ALIPAY,云闪付支持,京东白条分期)51:JSAPI(微信公众号支付,支付宝服务窗支付,银联JS支付,翼支付JS支付、拉卡拉钱包支付)71:微信小程序支付 61:APP支付(微信APP支付)
|
|
||||||
v3LabsTransPreorderRequest.setTransType("51");
|
|
||||||
v3LabsTransPreorderRequest.setTotalAmount(totalAmount); // 应支付金额,单位:分
|
|
||||||
v3LabsTransPreorderRequest.setSettleType("1"); //“0”或者空,常规结算方式,如需接拉卡拉分账通需传“1”,商户未开通分账之前切记不用上送此参数。;
|
|
||||||
v3LabsTransPreorderRequest.setNotifyUrl(notifyURL);
|
|
||||||
v3LabsTransPreorderRequest.setRemark(remark);
|
|
||||||
// v3LabsTransPreorderRequest.setCompleteNotifyUrl("https://mall.gpxscs.cn/api/mobile/shop/lakala/trans/receive/completeNotify");
|
|
||||||
|
|
||||||
//地址位置信息
|
|
||||||
V3LabsTradeLocationInfo v3LabsTradePreorderLocationInfo = new V3LabsTradeLocationInfo(requestIP);
|
|
||||||
v3LabsTransPreorderRequest.setLocationInfo(v3LabsTradePreorderLocationInfo);
|
|
||||||
|
|
||||||
//微信主扫场景下 acc_busi_fields 域内容
|
|
||||||
V3LabsTradePreorderWechatBus wechatBus = new V3LabsTradePreorderWechatBus();
|
|
||||||
wechatBus.setSubAppid(xcxAppId); // 小程序appId
|
|
||||||
wechatBus.setUserId(openId); // 微信 openId
|
|
||||||
wechatBus.setDeviceInfo("WEB"); // 终端设备号(门店号或收银设备ID),注意:PC网页或JSAPI支付请传”WEB”
|
|
||||||
// wechatBus.setAttach(storeId); // 附加数据,商户自定义数据,在查询交易结果时原样返回。
|
|
||||||
v3LabsTransPreorderRequest.setAccBusiFields(wechatBus);
|
|
||||||
|
|
||||||
JSONObject reqParams = JSONUtil.parseObj(v3LabsTransPreorderRequest);
|
|
||||||
reqParams.set("complete_notify_url", "https://mall.gpxscs.cn/api/mobile/shop/lakala/trans/receive/completeNotify");
|
|
||||||
|
|
||||||
try {
|
|
||||||
log.info("[拉卡拉预下单] 请求参数: {}", JSONUtil.toJsonStr(reqParams));
|
|
||||||
|
|
||||||
//3. 发送请求
|
|
||||||
String reqUrl = serverUrl + "/api/v3/labs/trans/preorder";
|
|
||||||
log.debug("[拉卡拉预下单] 请求URL: {}", reqUrl);
|
|
||||||
String responseStr = LKLSDK.httpPost(reqUrl, reqParams.toString(), appId);
|
|
||||||
log.info("[拉卡拉预下单] 响应数据: {}", responseStr);
|
|
||||||
if (StrUtil.isBlank(responseStr)) {
|
|
||||||
log.warn("[拉卡拉预下单] 响应为空, orderId={}", orderId);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject lakalaRespJSON = JSONUtil.parseObj(responseStr);
|
|
||||||
|
|
||||||
if (lakalaRespJSON != null && lakalaRespJSON.getStr("code").equals("BBS00000")) {
|
|
||||||
log.debug("[拉卡拉预下单] 支付成功,保存订单记录, orderId={}", orderId);
|
|
||||||
// 新增一个拉卡拉订单记录 shop_order_lkl 表
|
|
||||||
JSONObject lklPayReqAndRespJson = new JSONObject();
|
|
||||||
lklPayReqAndRespJson.put("req", JSONUtil.parseObj(v3LabsTransPreorderRequest));
|
|
||||||
lklPayReqAndRespJson.put("resp", lakalaRespJSON);
|
|
||||||
shopService.lklPayAddShopOrderLkl(lklPayReqAndRespJson);
|
|
||||||
}
|
|
||||||
//4. 响应
|
|
||||||
log.info("[拉卡拉预下单] 处理完成, orderId={}, responseCode={}", orderId, lakalaRespJSON != null ? lakalaRespJSON.getStr("code") : "NULL");
|
|
||||||
return lakalaRespJSON;
|
|
||||||
} catch (SDKException e) {
|
|
||||||
log.error("[拉卡拉预下单] SDK异常, orderId=" + orderId, e);
|
|
||||||
throw new ApiException(I18nUtil._("支付失败!"), e);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("[拉卡拉预下单] 系统异常, orderId=" + orderId, e);
|
|
||||||
throw new ApiException(I18nUtil._("系统异常!"), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拉卡拉预下单
|
* 拉卡拉预下单
|
||||||
* 参考:https://o.lakala.com/#/home/document/detail?id=110
|
* 参考:https://o.lakala.com/#/home/document/detail?id=110
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -35,6 +35,7 @@ import com.suisung.mall.shop.lakala.service.*;
|
|||||||
import com.suisung.mall.shop.lakala.utils.LakalaUtil;
|
import com.suisung.mall.shop.lakala.utils.LakalaUtil;
|
||||||
import com.suisung.mall.shop.message.service.PushMessageService;
|
import com.suisung.mall.shop.message.service.PushMessageService;
|
||||||
import com.suisung.mall.shop.message.service.ShopMessageTemplateService;
|
import com.suisung.mall.shop.message.service.ShopMessageTemplateService;
|
||||||
|
import com.suisung.mall.shop.order.service.ShopOrderBaseService;
|
||||||
import com.suisung.mall.shop.order.service.ShopOrderLklService;
|
import com.suisung.mall.shop.order.service.ShopOrderLklService;
|
||||||
import com.suisung.mall.shop.page.service.OssService;
|
import com.suisung.mall.shop.page.service.OssService;
|
||||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||||
@ -140,6 +141,10 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
@Resource
|
@Resource
|
||||||
private LklOrderSeparateService lklOrderSeparateService;
|
private LklOrderSeparateService lklOrderSeparateService;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Resource
|
||||||
|
private ShopOrderBaseService shopOrderBaseService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Resource
|
@Resource
|
||||||
private PushMessageService pushMessageService;
|
private PushMessageService pushMessageService;
|
||||||
@ -729,7 +734,7 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
return JSONUtil.createObj().set("code", "FAIL").set("message", "关键编号返回空值!");
|
return JSONUtil.createObj().set("code", "FAIL").set("message", "关键编号返回空值!");
|
||||||
}
|
}
|
||||||
|
|
||||||
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByMerchantNoAndTradeNoAndSubLogNo(merchantNo, originTradeNo, originLogNo);
|
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByLklMchNoAndTradeNoAndSubLogNo(merchantNo, originTradeNo, originLogNo);
|
||||||
if (shopOrderLkl == null) {
|
if (shopOrderLkl == null) {
|
||||||
log.warn("[确认收货通知] 订单不存在: merchantNo={}, originTradeNo={}, originLogNo={}",
|
log.warn("[确认收货通知] 订单不存在: merchantNo={}, originTradeNo={}, originLogNo={}",
|
||||||
merchantNo, originTradeNo, originLogNo);
|
merchantNo, originTradeNo, originLogNo);
|
||||||
@ -760,6 +765,9 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
return JSONUtil.createObj().set("code", "FAIL").set("message", "发起分账指令失败:" + separateResult.getSecond());
|
return JSONUtil.createObj().set("code", "FAIL").set("message", "发起分账指令失败:" + separateResult.getSecond());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 调用内部的确认收货
|
||||||
|
shopOrderBaseService.receive(shopOrderLkl.getOrder_id(), null);
|
||||||
|
|
||||||
log.info("[确认收货通知] 处理完成: orderId={}, log_no={}", shopOrderLkl.getOrder_id(), shopOrderLkl.getLkl_receive_log_no());
|
log.info("[确认收货通知] 处理完成: orderId={}, log_no={}", shopOrderLkl.getOrder_id(), shopOrderLkl.getLkl_receive_log_no());
|
||||||
JSONObject respData = JSONUtil.createObj();
|
JSONObject respData = JSONUtil.createObj();
|
||||||
respData.set("code", "SUCCESS");
|
respData.set("code", "SUCCESS");
|
||||||
@ -1736,12 +1744,12 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
if (existingSeparateRecord != null) {
|
if (existingSeparateRecord != null) {
|
||||||
String status = existingSeparateRecord.getStatus();
|
String status = existingSeparateRecord.getStatus();
|
||||||
if ("SUCCESS".equals(status)) {
|
if ("SUCCESS".equals(status)) {
|
||||||
log.info("[分账操作] 订单[{}]子订单[{}]已完成分账,跳过处理", orderId, shopOrderLkl.getLkl_log_no());
|
log.info("[分账操作] 订单[{}]交易对账流水号[{}]已完成分账,跳过处理", orderId, shopOrderLkl.getLkl_sub_log_no());
|
||||||
successCount++;
|
successCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ("PROCESSING".equals(status) || "ACCEPTED".equals(status)) {
|
if ("PROCESSING".equals(status) || "ACCEPTED".equals(status)) {
|
||||||
log.info("[分账操作] 订单[{}]子订单[{}]分账处理中或已受理,跳过处理", orderId, shopOrderLkl.getLkl_log_no());
|
log.info("[分账操作] 订单[{}]交易对账流水号[{}]分账处理中或已受理,跳过处理", orderId, shopOrderLkl.getLkl_sub_log_no());
|
||||||
successCount++;
|
successCount++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1969,19 +1977,19 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
public Pair<Boolean, String> innerDoOrderSeparateByMerchantAndLogNo(String lklMerchantNo, String receiveTradeNo, String receiveLogNo) {
|
public Pair<Boolean, String> innerDoOrderSeparateByMerchantAndLogNo(String lklMerchantNo, String receiveTradeNo, String receiveLogNo) {
|
||||||
// 1. 输入参数校验
|
// 1. 输入参数校验
|
||||||
if (StrUtil.isBlank(lklMerchantNo) || StrUtil.isBlank(receiveTradeNo) || StrUtil.isBlank(receiveLogNo)) {
|
if (StrUtil.isBlank(lklMerchantNo) || StrUtil.isBlank(receiveTradeNo) || StrUtil.isBlank(receiveLogNo)) {
|
||||||
log.warn("[分账操作] 参数校验失败:缺少必要参数, merchantNo={}, tradeNo={}, logNo={}",
|
log.warn("[分账操作] 参数校验失败:缺少必要参数, lklMerchantNo={}, receiveTradeNo={}, receiveLogNo={}",
|
||||||
lklMerchantNo, receiveTradeNo, receiveLogNo);
|
lklMerchantNo, receiveTradeNo, receiveLogNo);
|
||||||
return Pair.of(false, "缺少必要参数");
|
return Pair.of(false, "缺少必要参数");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.info("[分账操作] 开始处理分账请求, merchantNo={}, tradeNo={}, logNo={}",
|
log.info("[分账操作] 开始处理分账请求, lklMerchantNo={}, receiveTradeNo={}, receiveLogNo={}",
|
||||||
lklMerchantNo, receiveTradeNo, receiveLogNo);
|
lklMerchantNo, receiveTradeNo, receiveLogNo);
|
||||||
|
|
||||||
// TODO 检查可分账余额是否足够?
|
// TODO 检查可分账余额是否足够?
|
||||||
|
|
||||||
// 2. 查询订单信息
|
// 2. 查询订单信息
|
||||||
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByMerchantNoAndTradeNoAndSubLogNo(lklMerchantNo, receiveTradeNo, receiveLogNo);
|
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByLklMchNoAndReceiveTradeNoAndReceiveLogNo(lklMerchantNo, receiveTradeNo, receiveLogNo);
|
||||||
if (shopOrderLkl == null) {
|
if (shopOrderLkl == null) {
|
||||||
log.warn("[分账操作] 失败:对账流水号[{}]不存在", receiveLogNo);
|
log.warn("[分账操作] 失败:对账流水号[{}]不存在", receiveLogNo);
|
||||||
return Pair.of(false, "订单不存在");
|
return Pair.of(false, "订单不存在");
|
||||||
@ -1990,11 +1998,9 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
String orderId = shopOrderLkl.getOrder_id();
|
String orderId = shopOrderLkl.getOrder_id();
|
||||||
log.info("[分账操作] 开始处理订单[{}]的分账", orderId);
|
log.info("[分账操作] 开始处理订单[{}]的分账", orderId);
|
||||||
|
|
||||||
log.debug("[分账操作] 处理子订单:storeId={}, receive_log_no={}", shopOrderLkl.getStore_id(), shopOrderLkl.getLkl_receive_log_no());
|
|
||||||
|
|
||||||
// 3. 检查是否已确认收货
|
// 3. 检查是否已确认收货
|
||||||
if (!CommonConstant.Enable.equals(shopOrderLkl.getReceive_status()) || StrUtil.isBlank(shopOrderLkl.getLkl_receive_log_no())) {
|
if (!CommonConstant.Enable.equals(shopOrderLkl.getReceive_status())) {
|
||||||
log.warn("[分账操作] 订单[{}]对账流水号[{}]未被确认收货,跳过处理", orderId, shopOrderLkl.getLkl_receive_log_no());
|
log.warn("[分账操作] 订单[{}]交易流水号[{}]未被确认收货,跳过处理", orderId, receiveTradeNo);
|
||||||
return Pair.of(false, "订单未确认收货");
|
return Pair.of(false, "订单未确认收货");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2003,11 +2009,11 @@ public class LakalaApiServiceImpl implements LakalaApiService {
|
|||||||
if (existingSeparateRecord != null) {
|
if (existingSeparateRecord != null) {
|
||||||
String status = existingSeparateRecord.getStatus();
|
String status = existingSeparateRecord.getStatus();
|
||||||
if ("SUCCESS".equals(status)) {
|
if ("SUCCESS".equals(status)) {
|
||||||
log.info("[分账操作] 订单[{}]子订单[{}]已完成分账,跳过处理", orderId, shopOrderLkl.getLkl_log_no());
|
log.info("[分账操作] 订单[{}]交易对账流水号[{}]已完成分账,跳过处理", orderId, shopOrderLkl.getLkl_sub_log_no());
|
||||||
return Pair.of(true, "订单已处理");
|
return Pair.of(true, "订单已处理");
|
||||||
}
|
}
|
||||||
if ("PROCESSING".equals(status) || "ACCEPTED".equals(status)) {
|
if ("PROCESSING".equals(status) || "ACCEPTED".equals(status)) {
|
||||||
log.info("[分账操作] 订单[{}]子订单[{}]分账处理中或已受理,跳过处理", orderId, shopOrderLkl.getLkl_log_no());
|
log.info("[分账操作] 订单[{}]交易对账流水号[{}]分账处理中或已受理,跳过处理", orderId, shopOrderLkl.getLkl_sub_log_no());
|
||||||
return Pair.of(true, "订单已处理中或已受理");
|
return Pair.of(true, "订单已处理中或已受理");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -262,6 +262,9 @@ public class LakalaUtil {
|
|||||||
try {
|
try {
|
||||||
log.debug("拉卡拉 Authorization 内容:{}", authorization);
|
log.debug("拉卡拉 Authorization 内容:{}", authorization);
|
||||||
Map<String, String> headerMap = getLakalaAuthorizationMap(authorization);
|
Map<String, String> headerMap = getLakalaAuthorizationMap(authorization);
|
||||||
|
if (headerMap == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String timestamp = headerMap.get("timestamp");
|
String timestamp = headerMap.get("timestamp");
|
||||||
String nonceStr = headerMap.get("nonce_str");
|
String nonceStr = headerMap.get("nonce_str");
|
||||||
String signature = headerMap.get("signature");
|
String signature = headerMap.get("signature");
|
||||||
@ -304,6 +307,12 @@ public class LakalaUtil {
|
|||||||
*/
|
*/
|
||||||
public static Map<String, String> getLakalaAuthorizationMap(String authorization) {
|
public static Map<String, String> getLakalaAuthorizationMap(String authorization) {
|
||||||
Map<String, String> map = new HashMap();
|
Map<String, String> map = new HashMap();
|
||||||
|
if (StrUtil.isBlank(authorization)) {
|
||||||
|
log.error("请求头中无 Authorization 授权信息");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
authorization = authorization.trim();
|
authorization = authorization.trim();
|
||||||
int bpos = authorization.indexOf(" ");
|
int bpos = authorization.indexOf(" ");
|
||||||
String authType = authorization.substring(0, bpos);
|
String authType = authorization.substring(0, bpos);
|
||||||
@ -465,14 +474,14 @@ public class LakalaUtil {
|
|||||||
if (passVerifySign) {
|
if (passVerifySign) {
|
||||||
// 如果不需要验签,直接返回请求体内容
|
// 如果不需要验签,直接返回请求体内容
|
||||||
String requestBody = getBody(request);
|
String requestBody = getBody(request);
|
||||||
log.debug("###{} 异步回调通知请求过来的参数:{}###", request.getRequestURL(), requestBody);
|
log.debug("###{} 异步回调通知返回的数据:{}###", request.getRequestURL(), requestBody);
|
||||||
return Pair.of(true, requestBody);
|
return Pair.of(true, requestBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验签
|
// 验签
|
||||||
String authorization = request.getHeader("Authorization");
|
String authorization = request.getHeader("Authorization");
|
||||||
String requestBody = getBody(request);
|
String requestBody = getBody(request);
|
||||||
log.info("###{} 异步回调通知请求过来的参数:{}\n authorization参数:{}###", request.getRequestURL(), requestBody, authorization);
|
log.info("###{} 异步回调通知返回的数据:{}\n authorization参数:{}###", request.getRequestURL(), requestBody, authorization);
|
||||||
|
|
||||||
boolean checkSuccess = LakalaUtil.verify(authorization, requestBody, lklNotifyCerPath);
|
boolean checkSuccess = LakalaUtil.verify(authorization, requestBody, lklNotifyCerPath);
|
||||||
if (!checkSuccess) {
|
if (!checkSuccess) {
|
||||||
|
|||||||
@ -64,13 +64,34 @@ public interface ShopOrderLklService extends IBaseService<ShopOrderLkl> {
|
|||||||
*/
|
*/
|
||||||
List<ShopOrderLkl> selectByOrderId(String orderId, String lklLogNo, String storeId);
|
List<ShopOrderLkl> selectByOrderId(String orderId, String lklLogNo, String storeId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据商户号、商户订单号、子商户订单号查询一条记录
|
* 根据店铺Id、订单编号查询一条记录
|
||||||
|
*
|
||||||
|
* @param storeId
|
||||||
|
* @param orderId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ShopOrderLkl getByStoreIdAndOrderId(Integer storeId, String orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商户号、交易流水号、对账单流水号查询一条记录
|
||||||
*
|
*
|
||||||
* @param lklMerchantNo
|
* @param lklMerchantNo
|
||||||
* @param lklTradeNo
|
* @param lklTradeNo
|
||||||
* @param lklSubLogNo
|
* @param lklSubLogNo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ShopOrderLkl getByMerchantNoAndTradeNoAndSubLogNo(String lklMerchantNo, String lklTradeNo, String lklSubLogNo);
|
ShopOrderLkl getByLklMchNoAndTradeNoAndSubLogNo(String lklMerchantNo, String lklTradeNo, String lklSubLogNo);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商户号、确认收货交易流水号、确认收货对账单流水号查询一条记录
|
||||||
|
*
|
||||||
|
* @param lklMerchantNo 拉卡拉商户号
|
||||||
|
* @param lklReceiveTradeNo 拉卡拉确认收货交易流水号
|
||||||
|
* @param lklReceiveLogNo 拉卡拉确认收货对账单流水号
|
||||||
|
* @return ShopOrderLkl 拉卡拉订单记录
|
||||||
|
*/
|
||||||
|
ShopOrderLkl getByLklMchNoAndReceiveTradeNoAndReceiveLogNo(String lklMerchantNo, String lklReceiveTradeNo, String lklReceiveLogNo);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -331,6 +331,10 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ShopDistributionPlantformUserService shopDistributionPlantformUserService;
|
private ShopDistributionPlantformUserService shopDistributionPlantformUserService;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
|
private ShopOrderLklService shopOrderLklService;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private MessageService messageService;
|
private MessageService messageService;
|
||||||
@ -585,7 +589,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (StrUtil.isNotBlank(order_key)) {
|
if (StrUtil.isNotBlank(order_key)) {
|
||||||
if (order_key.startsWith("DD-")) {
|
if (order_key.startsWith("DD_") || order_key.startsWith("DD-")) {
|
||||||
params.put("order_id:eq", order_key);
|
params.put("order_id:eq", order_key);
|
||||||
} else {
|
} else {
|
||||||
params.put("order_title:like", order_key);
|
params.put("order_title:like", order_key);
|
||||||
@ -720,6 +724,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
|
|
||||||
data.put("remain_autofinish_time", remain_autofinish_time); // 修复以分钟扫描清除订单导致的误差
|
data.put("remain_autofinish_time", remain_autofinish_time); // 修复以分钟扫描清除订单导致的误差
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(I18nUtil._("无该订单访问权限!"));
|
throw new ApiException(I18nUtil._("无该订单访问权限!"));
|
||||||
}
|
}
|
||||||
@ -755,6 +760,14 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
if (CollUtil.isNotEmpty(order_info)) base_row.putAll(order_info);
|
if (CollUtil.isNotEmpty(order_info)) base_row.putAll(order_info);
|
||||||
if (CollUtil.isNotEmpty(order_data)) base_row.putAll(order_data);
|
if (CollUtil.isNotEmpty(order_data)) base_row.putAll(order_data);
|
||||||
|
|
||||||
|
// update 2025-09-10 增加KLK支付信息
|
||||||
|
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByStoreIdAndOrderId(shopOrderInfo.getStore_id(), order_id);
|
||||||
|
if (shopOrderLkl != null) {
|
||||||
|
base_row.put("lkl_trade_no", shopOrderLkl.getLkl_trade_no());
|
||||||
|
base_row.put("lkl_merchant_no", shopOrderLkl.getLkl_merchant_no());
|
||||||
|
base_row.put("lkl_sub_log_no", shopOrderLkl.getLkl_sub_log_no());
|
||||||
|
}
|
||||||
|
|
||||||
// 是否为虚拟商品
|
// 是否为虚拟商品
|
||||||
ShopOrderChainCode shopOrderChainCode = orderChainCodeService.get(order_id);
|
ShopOrderChainCode shopOrderChainCode = orderChainCodeService.get(order_id);
|
||||||
Map order_chain_code = Convert.toMap(String.class, Object.class, shopOrderChainCode);
|
Map order_chain_code = Convert.toMap(String.class, Object.class, shopOrderChainCode);
|
||||||
@ -4902,87 +4915,145 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单确认收货
|
* 确认收货处理
|
||||||
*
|
*
|
||||||
* @param order_ids 订单id
|
* @param order_ids 订单ID列表
|
||||||
* @param order_rows 订单数据
|
* @param order_rows 订单数据列表
|
||||||
|
* @return 是否处理成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean receive(List<String> order_ids, List<ShopOrderBase> order_rows) {
|
public boolean receive(List<String> order_ids, List<ShopOrderBase> order_rows) {
|
||||||
// 检测数据是否合法,过滤允许修改的数据
|
// 检测数据是否合法,过滤允许修改的数据
|
||||||
if (CollUtil.isEmpty(order_ids)) {
|
if (CollUtil.isEmpty(order_ids)) {
|
||||||
|
log.warn("[确认收货] 参数校验失败:订单ID列表为空");
|
||||||
throw new ApiException(I18nUtil._("请选择需要确认收货的订单!"));
|
throw new ApiException(I18nUtil._("请选择需要确认收货的订单!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollUtil.isEmpty(order_rows)) {
|
if (CollUtil.isEmpty(order_rows)) {
|
||||||
|
log.debug("[确认收货] 订单数据列表为空,根据订单ID列表查询订单数据");
|
||||||
order_rows = gets(order_ids);
|
order_rows = gets(order_ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> receive_id_row = new ArrayList<>();
|
// 检查订单数据是否存在
|
||||||
|
if (CollUtil.isEmpty(order_rows)) {
|
||||||
|
log.warn("[确认收货] 无法获取订单数据: orderIds={}", order_ids);
|
||||||
|
throw new ApiException(I18nUtil._("无法获取订单数据!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> receive_id_row = new ArrayList<>();
|
||||||
|
List<String> not_eligible_orders = new ArrayList<>(); // 记录不符合条件的订单
|
||||||
|
|
||||||
|
// 遍历订单列表,处理满足收货条件的订单
|
||||||
for (ShopOrderBase order_row : order_rows) {
|
for (ShopOrderBase order_row : order_rows) {
|
||||||
// 是否允许确认收货?
|
// 判断订单是否可以确认收货
|
||||||
if (ifReceive(order_row.getOrder_state_id())) {
|
if (ifReceive(order_row.getOrder_state_id())) {
|
||||||
receive_id_row.add(order_row.getOrder_id());
|
receive_id_row.add(order_row.getOrder_id());
|
||||||
|
log.info("[确认收货] 处理订单: orderId={}, currentState={}", order_row.getOrder_id(), order_row.getOrder_state_id());
|
||||||
// 增加积分和经验
|
} else {
|
||||||
// todo 目前付款支付积分,此处为收货后发放
|
not_eligible_orders.add(order_row.getOrder_id());
|
||||||
Integer user_id = order_row.getBuyer_user_id();
|
log.warn("[确认收货] 订单状态不满足收货条件: orderId={}, currentState={}", order_row.getOrder_id(), order_row.getOrder_state_id());
|
||||||
String order_id = order_row.getOrder_id();
|
|
||||||
Integer store_id = order_row.getStore_id();
|
|
||||||
|
|
||||||
ShopOrderData order_data_row = shopOrderDataService.get(order_id);
|
|
||||||
BigDecimal order_points_add = order_data_row.getOrder_points_add();
|
|
||||||
|
|
||||||
BigDecimal order_points_add_all = order_points_add.add(order_data_row.getOrder_double_points_add());
|
|
||||||
|
|
||||||
if (CheckUtil.isNotEmpty(order_points_add_all)) {
|
|
||||||
String desc = String.format(I18nUtil._("购物获取积分 %s,订单号 %s"), order_points_add_all, order_id);
|
|
||||||
if (!payService.points(user_id, order_points_add_all, PointsType.POINTS_TYPE_CONSUME, desc, store_id, null, order_id)) {
|
|
||||||
throw new ApiException(I18nUtil._("积分操作失败!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo 根据送花郎插件是否开启显示是否需要分钱给不同商户
|
|
||||||
/*
|
|
||||||
boolean hall_enable = accountBaseConfigService.getConfig("hall_enable", false);
|
|
||||||
if (hall_enable) {
|
|
||||||
BigDecimal order_commission_fee = order_data_row.getOrder_commission_fee();
|
|
||||||
sendMoneyForTransfer(order_row, order_commission_fee);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// todo 目前付款成功发放佣金,此处为收货后发放
|
|
||||||
// 分销功能。
|
|
||||||
String fx_settle_type = accountBaseConfigService.getConfig("fx_settle_type", "receive");
|
|
||||||
if (StrUtil.equals(fx_settle_type, "receive")) {
|
|
||||||
// todo settleDistributionUserOrder
|
|
||||||
shopDistributionUserOrderService.settleDistributionUserOrder(order_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重要;拉卡拉给平台和代理商分账
|
|
||||||
// Pair<Boolean, String> retOrderSeparateRet = lakalaApiService.innerDoOrderSeparate(order_row.getOrder_id(), Convert.toStr(order_row.getStore_id()));
|
|
||||||
// if (!retOrderSeparateRet.getFirst()) {
|
|
||||||
// throw new ApiException(I18nUtil._("平台或代理商分账失败: " + retOrderSeparateRet.getSecond()));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// 统计总营业额
|
|
||||||
ShopStoreAnalytics analytics_row = shopStoreAnalyticsService.get(store_id);
|
|
||||||
BigDecimal order_payment_amount = order_row.getOrder_payment_amount();
|
|
||||||
analytics_row.setStore_trade_amount(NumberUtil.add(analytics_row.getStore_trade_amount(), order_payment_amount));
|
|
||||||
if (!shopStoreAnalyticsService.edit(analytics_row)) {
|
|
||||||
throw new ApiException(ResultCode.FAILED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否有符合条件的订单
|
||||||
if (CollUtil.isEmpty(receive_id_row)) {
|
if (CollUtil.isEmpty(receive_id_row)) {
|
||||||
throw new ApiException(I18nUtil._("无符合确认收货条件的订单!"));
|
log.warn("[确认收货] 无符合确认收货条件的订单,总订单数={},不符合条件订单数={}", order_rows.size(), not_eligible_orders.size());
|
||||||
|
// 记录所有订单的详细状态信息
|
||||||
|
for (ShopOrderBase order_row : order_rows) {
|
||||||
|
log.warn("[确认收货] 订单状态详情: orderId={}, currentState={}", order_row.getOrder_id(), order_row.getOrder_state_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果是通过顺丰通知触发的收货,且订单已经是完成状态,则直接返回成功
|
||||||
|
if (order_rows.size() == 1 && not_eligible_orders.size() == 1) {
|
||||||
|
ShopOrderBase order = order_rows.get(0);
|
||||||
|
// 如果订单已经是完成状态,则认为收货成功
|
||||||
|
if (ObjectUtil.equal(order.getOrder_state_id(), StateCode.ORDER_STATE_FINISH)) {
|
||||||
|
log.info("[确认收货] 订单已经是完成状态,直接返回成功: orderId={}", order.getOrder_id());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// throw new ApiException(I18nUtil._("无符合确认收货条件的订单!"));
|
||||||
|
log.info("[确认收货] 无符合确认收货条件的订单!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("[确认收货] 符合条件的订单数量: eligibleCount={}, totalChecked={}", receive_id_row.size(), order_rows.size());
|
||||||
|
|
||||||
|
// 处理符合条件的订单
|
||||||
|
for (ShopOrderBase order_row : order_rows) {
|
||||||
|
// 只处理符合条件的订单
|
||||||
|
if (!receive_id_row.contains(order_row.getOrder_id())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 增加积分和经验
|
||||||
|
// todo 目前付款支付积分,此处为收货后发放
|
||||||
|
Integer user_id = order_row.getBuyer_user_id();
|
||||||
|
String order_id = order_row.getOrder_id();
|
||||||
|
Integer store_id = order_row.getStore_id();
|
||||||
|
|
||||||
|
ShopOrderData order_data_row = shopOrderDataService.get(order_id);
|
||||||
|
if (order_data_row == null) {
|
||||||
|
log.warn("[确认收货] 无法获取订单数据: orderId={}", order_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal order_points_add = order_data_row.getOrder_points_add();
|
||||||
|
BigDecimal order_double_points_add = order_data_row.getOrder_double_points_add();
|
||||||
|
BigDecimal order_points_add_all = order_points_add != null ? order_points_add : BigDecimal.ZERO;
|
||||||
|
order_points_add_all = order_points_add_all.add(order_double_points_add != null ? order_double_points_add : BigDecimal.ZERO);
|
||||||
|
|
||||||
|
// 发放购物积分
|
||||||
|
if (CheckUtil.isNotEmpty(order_points_add_all) && order_points_add_all.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
String desc = String.format(I18nUtil._("购物获取积分 %s,订单号 %s"), order_points_add_all, order_id);
|
||||||
|
log.debug("[确认收货] 发放购物积分: userId={}, points={}, desc={}", user_id, order_points_add_all, desc);
|
||||||
|
if (!payService.points(user_id, order_points_add_all, PointsType.POINTS_TYPE_CONSUME, desc, store_id, null, order_id)) {
|
||||||
|
log.error("[确认收货] 积分操作失败: userId={}, points={}, orderId={}", user_id, order_points_add_all, order_id);
|
||||||
|
// throw new ApiException(I18nUtil._("积分操作失败!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// todo 根据送花郎插件是否开启显示是否需要分钱给不同商户
|
||||||
|
/*
|
||||||
|
boolean hall_enable = accountBaseConfigService.getConfig("hall_enable", false);
|
||||||
|
if (hall_enable) {
|
||||||
|
BigDecimal order_commission_fee = order_data_row.getOrder_commission_fee();
|
||||||
|
sendMoneyForTransfer(order_row, order_commission_fee);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// todo 目前付款成功发放佣金,此处为收货后发放
|
||||||
|
// 分销功能。
|
||||||
|
String fx_settle_type = accountBaseConfigService.getConfig("fx_settle_type", "receive");
|
||||||
|
if (StrUtil.equals(fx_settle_type, "receive")) {
|
||||||
|
log.debug("[确认收货] 处理分销订单: orderId={}", order_id);
|
||||||
|
// todo settleDistributionUserOrder
|
||||||
|
shopDistributionUserOrderService.settleDistributionUserOrder(order_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 统计总营业额
|
||||||
|
ShopStoreAnalytics analytics_row = shopStoreAnalyticsService.get(store_id);
|
||||||
|
if (analytics_row != null) {
|
||||||
|
BigDecimal order_payment_amount = order_row.getOrder_payment_amount();
|
||||||
|
log.debug("[确认收货] 更新店铺营业额: storeId={}, amount={}", store_id, order_payment_amount);
|
||||||
|
analytics_row.setStore_trade_amount(NumberUtil.add(analytics_row.getStore_trade_amount(), order_payment_amount != null ? order_payment_amount : BigDecimal.ZERO));
|
||||||
|
if (!shopStoreAnalyticsService.edit(analytics_row)) {
|
||||||
|
log.error("[确认收货] 更新店铺营业额失败: storeId={}", store_id);
|
||||||
|
// throw new ApiException(ResultCode.FAILED);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("[确认收货] 无法获取店铺统计信息: storeId={}", store_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改订单状态, 随机去一个订单获取店铺编号
|
// 修改订单状态, 随机去一个订单获取店铺编号
|
||||||
ShopOrderBase shopOrderBase = order_rows.get(0);
|
ShopOrderBase shopOrderBase = order_rows.stream()
|
||||||
|
.filter(order -> receive_id_row.contains(order.getOrder_id()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(order_rows.get(0));
|
||||||
Integer store_id = shopOrderBase.getStore_id();
|
Integer store_id = shopOrderBase.getStore_id();
|
||||||
|
log.debug("[确认收货] 修改订单状态: storeId={}", store_id);
|
||||||
editNextState(receive_id_row, store_id, StateCode.ORDER_STATE_SHIPPED, order_rows, 0);
|
editNextState(receive_id_row, store_id, StateCode.ORDER_STATE_SHIPPED, order_rows, 0);
|
||||||
|
|
||||||
// 如果是商家,且启用供应商,则商家看到供应商店铺商品 store_type = 2
|
// 如果是商家,且启用供应商,则商家看到供应商店铺商品 store_type = 2
|
||||||
@ -4990,7 +5061,9 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
UserDto user = getCurrentUser();
|
UserDto user = getCurrentUser();
|
||||||
store_id = user != null ? Convert.toInt(user.getStore_id(), 0) : 0;
|
store_id = user != null ? Convert.toInt(user.getStore_id(), 0) : 0;
|
||||||
|
|
||||||
|
// 处理供应商市场的库存增加逻辑
|
||||||
if (ifSupplierMarket && CheckUtil.isNotEmpty(store_id)) {
|
if (ifSupplierMarket && CheckUtil.isNotEmpty(store_id)) {
|
||||||
|
log.debug("[确认收货] 处理供应商市场库存: storeId={}", store_id);
|
||||||
// 供应商商品,增加商家库存
|
// 供应商商品,增加商家库存
|
||||||
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopOrderItem> itemQueryWrapper = new QueryWrapper<>();
|
||||||
itemQueryWrapper.in("order_id", receive_id_row);
|
itemQueryWrapper.in("order_id", receive_id_row);
|
||||||
@ -5002,30 +5075,39 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
productItemQueryWrapper.in("item_src_id", item_src_ids).eq("store_id", store_id);
|
productItemQueryWrapper.in("item_src_id", item_src_ids).eq("store_id", store_id);
|
||||||
List<ShopProductItem> product_item_rows = shopProductItemService.find(productItemQueryWrapper);
|
List<ShopProductItem> product_item_rows = shopProductItemService.find(productItemQueryWrapper);
|
||||||
|
|
||||||
|
// 更新供应商商品库存
|
||||||
|
log.debug("[确认收货] 更新供应商商品库存: itemsCount={}", product_item_rows.size());
|
||||||
for (ShopProductItem product_item_row : product_item_rows) {
|
for (ShopProductItem product_item_row : product_item_rows) {
|
||||||
String item_src_id = product_item_row.getItem_src_id();
|
String item_src_id = product_item_row.getItem_src_id();
|
||||||
Optional<ShopOrderItem> orderItemOpl = order_item_rows.stream().filter(s -> ObjectUtil.equal(s.getItem_id(), item_src_id)).findFirst();
|
Optional<ShopOrderItem> orderItemOpl = order_item_rows.stream().filter(s -> ObjectUtil.equal(s.getItem_id(), item_src_id)).findFirst();
|
||||||
if (orderItemOpl.isPresent()) {
|
if (orderItemOpl.isPresent()) {
|
||||||
ShopOrderItem shopOrderItem = orderItemOpl.get();
|
ShopOrderItem shopOrderItem = orderItemOpl.get();
|
||||||
Integer order_item_quantity = shopOrderItem.getOrder_item_quantity();
|
Integer order_item_quantity = shopOrderItem.getOrder_item_quantity();
|
||||||
product_item_row.setItem_quantity(product_item_row.getItem_quantity() + order_item_quantity);
|
if (order_item_quantity != null && order_item_quantity > 0) {
|
||||||
if (!shopProductItemService.edit(product_item_row)) {
|
log.debug("[确认收货] 更新商品库存: itemId={}, oldQuantity={}, addQuantity={}",
|
||||||
throw new ApiException(ResultCode.FAILED);
|
item_src_id, product_item_row.getItem_quantity(), order_item_quantity);
|
||||||
|
product_item_row.setItem_quantity(product_item_row.getItem_quantity() + order_item_quantity);
|
||||||
|
if (!shopProductItemService.edit(product_item_row)) {
|
||||||
|
log.error("[确认收货] 更新商品库存失败: itemId={}", item_src_id);
|
||||||
|
// throw new ApiException(ResultCode.FAILED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.info("[确认收货] 处理完成: processedOrders={}", receive_id_row.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单确认收货(定时任务用途)
|
* 订单确认收货(定时任务用途)
|
||||||
*
|
*
|
||||||
* @param order_id 订单id
|
* @param order_id 订单id
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public boolean receive(String order_id, ShopOrderBase orderBase) {
|
public boolean receive(String order_id, ShopOrderBase orderBase) {
|
||||||
return receive(Collections.singletonList(order_id), null);
|
return receive(Collections.singletonList(order_id), null);
|
||||||
}
|
}
|
||||||
@ -7847,12 +7929,13 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
/**
|
/**
|
||||||
* 是否可以确认收货
|
* 是否可以确认收货
|
||||||
*
|
*
|
||||||
* @param order_state_id 订单状态
|
* @param orderStateId 订单状态
|
||||||
* @return boolean true-可,false-不可
|
* @return boolean true-可确认收货,false-不可确认收货
|
||||||
* @access public
|
|
||||||
*/
|
*/
|
||||||
private boolean ifReceive(Integer order_state_id) {
|
private boolean ifReceive(Integer orderStateId) {
|
||||||
return ObjectUtil.equal(order_state_id, StateCode.ORDER_STATE_SHIPPED);
|
// 只有已发货已签收状态的订单才能确认收货
|
||||||
|
return ObjectUtil.equal(orderStateId, StateCode.ORDER_STATE_SHIPPED) ||
|
||||||
|
ObjectUtil.equal(orderStateId, StateCode.ORDER_STATE_RECEIVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8005,6 +8088,14 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
|||||||
order_info_row.putAll(order_data_row);
|
order_info_row.putAll(order_data_row);
|
||||||
order_info_row.put("item", order_item_temp_rows.get(order_id));
|
order_info_row.put("item", order_item_temp_rows.get(order_id));
|
||||||
|
|
||||||
|
// update 2025-09-10 增加KLK支付信息
|
||||||
|
ShopOrderLkl shopOrderLkl = shopOrderLklService.getByStoreIdAndOrderId(store_id, order_id);
|
||||||
|
if (shopOrderLkl != null) {
|
||||||
|
order_info_row.put("lkl_trade_no", shopOrderLkl.getLkl_trade_no());
|
||||||
|
order_info_row.put("lkl_merchant_no", shopOrderLkl.getLkl_merchant_no());
|
||||||
|
order_info_row.put("lkl_sub_log_no", shopOrderLkl.getLkl_sub_log_no());
|
||||||
|
}
|
||||||
|
|
||||||
Optional<Map> store_row_Opl = store_rows.stream().filter(s -> ObjectUtil.equal(store_id, Convert.toInt(s.get("store_id")))).findFirst();
|
Optional<Map> store_row_Opl = store_rows.stream().filter(s -> ObjectUtil.equal(store_id, Convert.toInt(s.get("store_id")))).findFirst();
|
||||||
Map store_row = store_row_Opl.orElseGet(HashMap::new);
|
Map store_row = store_row_Opl.orElseGet(HashMap::new);
|
||||||
order_info_row.put("self_support", store_row.get("store_is_selfsupport"));
|
order_info_row.put("self_support", store_row.get("store_is_selfsupport"));
|
||||||
|
|||||||
@ -229,81 +229,127 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
|||||||
/**
|
/**
|
||||||
* 更改商家订单的状态,出库状态,发货状态,并写入订单状态更改日志
|
* 更改商家订单的状态,出库状态,发货状态,并写入订单状态更改日志
|
||||||
*
|
*
|
||||||
* @param orderId
|
* @param orderId 订单ID
|
||||||
* @param orderStatus 约定0值不更改
|
* @param orderStatus 订单状态,约定0值不更改
|
||||||
* @param orderIsOutStatus 出库状态,约定0值不更改
|
* @param orderIsOutStatus 出库状态,约定0值不更改
|
||||||
* @param orderIsShippedStatus 发货状态,约定0值不更改
|
* @param orderIsShippedStatus 发货状态,约定0值不更改
|
||||||
* @return
|
* @return Boolean 是否更新成功
|
||||||
*/
|
*/
|
||||||
@Transactional
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean changeOrderStatus(String orderId, Integer orderStatus, Integer orderIsOutStatus, Integer orderIsShippedStatus) {
|
public Boolean changeOrderStatus(String orderId, Integer orderStatus, Integer orderIsOutStatus, Integer orderIsShippedStatus) {
|
||||||
if (orderId == null || orderStatus == null) {
|
try {
|
||||||
return false;
|
// 参数校验
|
||||||
}
|
if (orderId == null || orderStatus == null) {
|
||||||
|
logger.warn("[订单状态变更] 参数校验失败: orderId或orderStatus为空, orderId={}, orderStatus={}", orderId, orderStatus);
|
||||||
ShopOrderInfo shopOrderInfo = getById(orderId);
|
|
||||||
if (shopOrderInfo == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer preOrderStatus = shopOrderInfo.getOrder_state_id();
|
|
||||||
|
|
||||||
int paramsCnt = 0;
|
|
||||||
UpdateWrapper<ShopOrderInfo> updateWrapper = new UpdateWrapper<>();
|
|
||||||
updateWrapper.eq("order_id", orderId);
|
|
||||||
if (orderStatus > 0) {
|
|
||||||
updateWrapper.set("order_state_id", orderStatus);
|
|
||||||
paramsCnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orderIsOutStatus > 0 && !shopOrderInfo.getOrder_is_out().equals(orderIsOutStatus)) {
|
|
||||||
updateWrapper.set("order_is_out", orderStatus);
|
|
||||||
paramsCnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (orderStatus > 0 && !shopOrderInfo.getOrder_is_shipped().equals(orderIsShippedStatus)) {
|
|
||||||
updateWrapper.set("order_is_shipped", orderIsShippedStatus);
|
|
||||||
paramsCnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paramsCnt <= 0) {
|
|
||||||
// 无修改的状态
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!update(updateWrapper)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateWrapper<ShopOrderBase> updateShopOrderBaseWrapper = new UpdateWrapper<>();
|
|
||||||
updateShopOrderBaseWrapper.eq("order_id", orderId);
|
|
||||||
if (orderStatus > 0) {
|
|
||||||
updateShopOrderBaseWrapper.set("order_state_id", orderStatus);
|
|
||||||
if (!shopOrderBaseService.update(updateShopOrderBaseWrapper)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// 远程调用 更改交易订单状态
|
// 获取订单信息
|
||||||
if (!payService.changePayConsumeTradeState(orderId, orderStatus, 0)) {
|
ShopOrderInfo shopOrderInfo = getById(orderId);
|
||||||
logger.error("远程调用更改交易订单状态失败!");
|
if (shopOrderInfo == null) {
|
||||||
|
logger.warn("[订单状态变更] 未找到订单信息: orderId={}", orderId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("[订单状态变更] 开始处理订单状态变更: orderId={}, currentStatus={}, newStatus={}, outStatus={}, shippedStatus={}",
|
||||||
|
orderId, shopOrderInfo.getOrder_state_id(), orderStatus, orderIsOutStatus, orderIsShippedStatus);
|
||||||
|
|
||||||
|
Integer preOrderStatus = shopOrderInfo.getOrder_state_id();
|
||||||
|
|
||||||
|
int paramsCnt = 0;
|
||||||
|
UpdateWrapper<ShopOrderInfo> updateWrapper = new UpdateWrapper<>();
|
||||||
|
updateWrapper.eq("order_id", orderId);
|
||||||
|
|
||||||
|
// 更新订单状态
|
||||||
|
if (orderStatus > 0) {
|
||||||
|
updateWrapper.set("order_state_id", orderStatus);
|
||||||
|
|
||||||
|
// 已签收或已完成,更改两个时间
|
||||||
|
if (StateCode.ORDER_STATE_RECEIVED == orderStatus.intValue() || orderStatus == StateCode.ORDER_STATE_FINISH) {
|
||||||
|
updateWrapper.set("order_deal_time", System.currentTimeMillis());
|
||||||
|
updateWrapper.set("order_qs_time", new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
paramsCnt++;
|
||||||
|
logger.debug("[订单状态变更] 添加订单状态更新条件: orderId={}, status={}", orderId, orderStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新出库状态
|
||||||
|
if (orderIsOutStatus != null && orderIsOutStatus > 0 &&
|
||||||
|
!ObjectUtil.equal(shopOrderInfo.getOrder_is_out(), orderIsOutStatus)) {
|
||||||
|
updateWrapper.set("order_is_out", orderIsOutStatus);
|
||||||
|
paramsCnt++;
|
||||||
|
logger.debug("[订单状态变更] 添加出库状态更新条件: orderId={}, outStatus={}", orderId, orderIsOutStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新发货状态
|
||||||
|
if (orderIsShippedStatus != null && orderIsShippedStatus > 0 &&
|
||||||
|
!ObjectUtil.equal(shopOrderInfo.getOrder_is_shipped(), orderIsShippedStatus)) {
|
||||||
|
updateWrapper.set("order_is_shipped", orderIsShippedStatus);
|
||||||
|
paramsCnt++;
|
||||||
|
logger.debug("[订单状态变更] 添加发货状态更新条件: orderId={}, shippedStatus={}", orderId, orderIsShippedStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有需要更新的字段
|
||||||
|
if (paramsCnt <= 0) {
|
||||||
|
logger.info("[订单状态变更] 无需要更新的字段: orderId={}", orderId);
|
||||||
|
// 无修改的状态
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 执行订单信息更新
|
||||||
|
logger.debug("[订单状态变更] 执行订单信息更新: orderId={}, updateFields={}", orderId, paramsCnt);
|
||||||
|
if (!update(updateWrapper)) {
|
||||||
|
logger.error("[订单状态变更] 订单信息更新失败: orderId={}", orderId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新订单基础信息中的状态
|
||||||
|
UpdateWrapper<ShopOrderBase> updateShopOrderBaseWrapper = new UpdateWrapper<>();
|
||||||
|
updateShopOrderBaseWrapper.eq("order_id", orderId);
|
||||||
|
if (orderStatus > 0) {
|
||||||
|
updateShopOrderBaseWrapper.set("order_state_id", orderStatus);
|
||||||
|
logger.debug("[订单状态变更] 执行订单基础信息更新: orderId={}, status={}", orderId, orderStatus);
|
||||||
|
if (!shopOrderBaseService.update(updateShopOrderBaseWrapper)) {
|
||||||
|
logger.error("[订单状态变更] 订单基础信息更新失败: orderId={}", orderId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 写入订单状态更改日志
|
||||||
|
logger.debug("[订单状态变更] 写入订单状态变更日志: orderId={}, preStatus={}, newStatus={}", orderId, preOrderStatus, orderStatus);
|
||||||
|
ShopOrderStateLog shopOrderStateLog = new ShopOrderStateLog();
|
||||||
|
shopOrderStateLog.setOrder_id(orderId);
|
||||||
|
shopOrderStateLog.setOrder_state_is_sync(0);
|
||||||
|
shopOrderStateLog.setOrder_state_id(orderStatus);
|
||||||
|
shopOrderStateLog.setOrder_state_time(new Date());
|
||||||
|
shopOrderStateLog.setOrder_state_pre_id(preOrderStatus);
|
||||||
|
shopOrderStateLog.setOrder_state_type(shopBaseStateCodeService.getText(orderStatus, null));
|
||||||
|
shopOrderStateLog.setOrder_state_note(CommonUtil.getOrderStateNote(preOrderStatus, orderStatus));
|
||||||
|
shopOrderStateLog.setUser_id(0);
|
||||||
|
shopOrderStateLog.setUser_nickname("SfExpress");
|
||||||
|
|
||||||
|
boolean logResult = shopOrderStateLogService.add(shopOrderStateLog);
|
||||||
|
if (logResult) {
|
||||||
|
logger.info("[订单状态变更] 订单状态变更成功: orderId={}, preStatus={}, newStatus={}", orderId, preOrderStatus, orderStatus);
|
||||||
|
|
||||||
|
// 远程调用 更改交易订单状态
|
||||||
|
logger.debug("[订单状态变更] 调用支付服务更新交易订单状态: orderId={}, status={}", orderId, orderStatus);
|
||||||
|
if (!payService.changePayConsumeTradeState(orderId, orderStatus, 0)) {
|
||||||
|
logger.error("[订单状态变更] 远程调用更改交易订单状态失败: orderId={}", orderId);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
logger.error("[订单状态变更] 订单状态日志写入失败: orderId={}", orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return logResult;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("[订单状态变更] 处理过程中发生异常: orderId={}, orderStatus={}, outStatus={}, shippedStatus={}",
|
||||||
|
orderId, orderStatus, orderIsOutStatus, orderIsShippedStatus, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入订单状态更改日志
|
|
||||||
ShopOrderStateLog shopOrderStateLog = new ShopOrderStateLog();
|
|
||||||
shopOrderStateLog.setOrder_id(orderId);
|
|
||||||
shopOrderStateLog.setOrder_state_is_sync(0);
|
|
||||||
shopOrderStateLog.setOrder_state_id(orderStatus);
|
|
||||||
shopOrderStateLog.setOrder_state_time(new Date());
|
|
||||||
shopOrderStateLog.setOrder_state_pre_id(preOrderStatus);
|
|
||||||
shopOrderStateLog.setOrder_state_type(shopBaseStateCodeService.getText(orderStatus, null));
|
|
||||||
shopOrderStateLog.setOrder_state_note(CommonUtil.getOrderStateNote(preOrderStatus, orderStatus));
|
|
||||||
shopOrderStateLog.setUser_id(0);
|
|
||||||
shopOrderStateLog.setUser_nickname("SfExpress");
|
|
||||||
|
|
||||||
return shopOrderStateLogService.add(shopOrderStateLog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -295,15 +295,43 @@ public class ShopOrderLklServiceImpl extends BaseServiceImpl<ShopOrderLklMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据商户号、商户订单号、子商户订单号查询一条记录
|
* 根据店铺Id、订单编号查询一条记录
|
||||||
|
*
|
||||||
|
* @param storeId
|
||||||
|
* @param orderId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ShopOrderLkl getByStoreIdAndOrderId(Integer storeId, String orderId) {
|
||||||
|
if (CheckUtil.isEmpty(storeId) || StringUtils.isBlank(orderId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
QueryWrapper<ShopOrderLkl> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("store_id", storeId).eq("order_id", orderId).orderByAsc("id");
|
||||||
|
|
||||||
|
if (CheckUtil.isEmpty(storeId)) {
|
||||||
|
queryWrapper.eq("store_id", storeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return findOne(queryWrapper);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("getByStoreIdAndOrderId 查询异常, orderId: {}, storeId: {}", orderId, storeId, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商户号、交易流水号、对账单流水号查询一条记录
|
||||||
*
|
*
|
||||||
* @param lklMerchantNo 拉卡拉商户号
|
* @param lklMerchantNo 拉卡拉商户号
|
||||||
* @param lklTradeNo 拉卡拉交易号
|
* @param lklTradeNo 原拉卡拉交易流水号
|
||||||
* @param lklSubLogNo 拉卡拉子订单流水号
|
* @param lklSubLogNo 原拉卡拉对账单流水号
|
||||||
* @return ShopOrderLkl 拉卡拉订单记录
|
* @return ShopOrderLkl 拉卡拉订单记录
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ShopOrderLkl getByMerchantNoAndTradeNoAndSubLogNo(String lklMerchantNo, String lklTradeNo, String lklSubLogNo) {
|
public ShopOrderLkl getByLklMchNoAndTradeNoAndSubLogNo(String lklMerchantNo, String lklTradeNo, String lklSubLogNo) {
|
||||||
// 检查参数是否全部为空
|
// 检查参数是否全部为空
|
||||||
if (StringUtils.isAllBlank(lklMerchantNo, lklTradeNo, lklSubLogNo)) {
|
if (StringUtils.isAllBlank(lklMerchantNo, lklTradeNo, lklSubLogNo)) {
|
||||||
log.warn("[拉卡拉订单查询] 参数校验失败:所有查询条件均为空");
|
log.warn("[拉卡拉订单查询] 参数校验失败:所有查询条件均为空");
|
||||||
@ -311,7 +339,7 @@ public class ShopOrderLklServiceImpl extends BaseServiceImpl<ShopOrderLklMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log.debug("[拉卡拉订单查询] 开始查询, merchantNo={}, tradeNo={}, subLogNo={}",
|
log.debug("[拉卡拉订单查询] 开始查询, 商户号={}, 交易号={}, 子订单流水号={}",
|
||||||
lklMerchantNo, lklTradeNo, lklSubLogNo);
|
lklMerchantNo, lklTradeNo, lklSubLogNo);
|
||||||
|
|
||||||
QueryWrapper<ShopOrderLkl> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopOrderLkl> queryWrapper = new QueryWrapper<>();
|
||||||
@ -335,14 +363,66 @@ public class ShopOrderLklServiceImpl extends BaseServiceImpl<ShopOrderLklMapper,
|
|||||||
|
|
||||||
ShopOrderLkl result = findOne(queryWrapper);
|
ShopOrderLkl result = findOne(queryWrapper);
|
||||||
|
|
||||||
log.debug("[拉卡拉订单查询] 查询完成, merchantNo={}, tradeNo={}, subLogNo={}, found={}",
|
log.debug("[拉卡拉订单查询] 查询完成, 商户号={}, 交易号={}, 子订单流水号={}, 查询结果={}",
|
||||||
lklMerchantNo, lklTradeNo, lklSubLogNo, result != null);
|
lklMerchantNo, lklTradeNo, lklSubLogNo, result != null);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[拉卡拉订单查询] 系统异常, merchantNo={}, tradeNo={}, subLogNo={}",
|
log.error("[拉卡拉订单查询] 系统异常, 商户号={}, 交易号={}, 子订单流水号={}",
|
||||||
lklMerchantNo, lklTradeNo, lklSubLogNo, e);
|
lklMerchantNo, lklTradeNo, lklSubLogNo, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商户号、交易流水号、对账单流水号查询一条记录
|
||||||
|
*
|
||||||
|
* @param lklMerchantNo 拉卡拉商户号
|
||||||
|
* @param lklReceiveTradeNo 拉卡拉确认收货交易流水号
|
||||||
|
* @param lklReceiveLogNo 拉卡拉确认收货对账单流水号
|
||||||
|
* @return ShopOrderLkl 拉卡拉订单记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ShopOrderLkl getByLklMchNoAndReceiveTradeNoAndReceiveLogNo(String lklMerchantNo, String lklReceiveTradeNo, String lklReceiveLogNo) {
|
||||||
|
// 检查参数是否全部为空
|
||||||
|
if (StringUtils.isAllBlank(lklMerchantNo, lklReceiveTradeNo, lklReceiveLogNo)) {
|
||||||
|
log.warn("[拉卡拉订单查询] 参数校验失败:所有查询条件均为空");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
log.debug("[拉卡拉订单查询] 开始查询, 商户号={}, 确认收货交易号={}, 确认收货对账流水号={}",
|
||||||
|
lklMerchantNo, lklReceiveTradeNo, lklReceiveLogNo);
|
||||||
|
|
||||||
|
QueryWrapper<ShopOrderLkl> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.orderByAsc("id");
|
||||||
|
|
||||||
|
// 根据非空参数构建查询条件
|
||||||
|
if (StrUtil.isNotBlank(lklMerchantNo)) {
|
||||||
|
queryWrapper.eq("lkl_merchant_no", lklMerchantNo);
|
||||||
|
log.debug("[拉卡拉订单查询] 添加商户号查询条件: lklMerchantNo={}", lklMerchantNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(lklReceiveTradeNo)) {
|
||||||
|
queryWrapper.eq("lkl_receive_trade_no", lklReceiveTradeNo);
|
||||||
|
log.debug("[拉卡拉订单查询] 添加交易号查询条件: lklReceiveTradeNo={}", lklReceiveTradeNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotBlank(lklReceiveLogNo)) {
|
||||||
|
queryWrapper.eq("lkl_receive_log_no", lklReceiveLogNo);
|
||||||
|
log.debug("[拉卡拉订单查询] 添加收货流水号查询条件: lklReceiveLogNo={}", lklReceiveLogNo);
|
||||||
|
}
|
||||||
|
|
||||||
|
ShopOrderLkl result = findOne(queryWrapper);
|
||||||
|
|
||||||
|
log.debug("[拉卡拉订单查询] 查询完成, 商户号={}, 交易号={}, 流水号={}, 查询结果={}",
|
||||||
|
lklMerchantNo, lklReceiveTradeNo, lklReceiveLogNo, result != null);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[拉卡拉订单查询] 系统异常, 商户号={}, 交易号={}, 流水号={}",
|
||||||
|
lklMerchantNo, lklReceiveTradeNo, lklReceiveLogNo, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -936,7 +936,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
|||||||
pushRemark = "配送员已接单。";
|
pushRemark = "配送员已接单。";
|
||||||
|
|
||||||
// 上传发货信息到微信
|
// 上传发货信息到微信
|
||||||
wxOrderShippingService.uploadShippingInfoToWx(2, shopStoreSfOrder.getShop_order_id());
|
wxOrderShippingService.uploadShippingInfoToWx(2, shopOrderId);
|
||||||
|
|
||||||
} else if (shopStoreSfOrder.getOrder_status().equals(StateCode.SF_ORDER_STATUS_ARRIVED)) {
|
} else if (shopStoreSfOrder.getOrder_status().equals(StateCode.SF_ORDER_STATUS_ARRIVED)) {
|
||||||
// 顺丰同城状态:12-配送员到店;
|
// 顺丰同城状态:12-配送员到店;
|
||||||
@ -947,7 +947,7 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
|||||||
pushRemark = "配送员已到店。";
|
pushRemark = "配送员已到店。";
|
||||||
|
|
||||||
// 上传发货信息到微信
|
// 上传发货信息到微信
|
||||||
wxOrderShippingService.uploadShippingInfoToWx(2, shopStoreSfOrder.getShop_order_id());
|
wxOrderShippingService.uploadShippingInfoToWx(2, shopOrderId);
|
||||||
} else if (shopStoreSfOrder.getOrder_status().equals(StateCode.SF_ORDER_STATUS_RECEIVED)) {
|
} else if (shopStoreSfOrder.getOrder_status().equals(StateCode.SF_ORDER_STATUS_RECEIVED)) {
|
||||||
// 顺丰同城状态:15-配送员配送中(已取货)
|
// 顺丰同城状态:15-配送员配送中(已取货)
|
||||||
// 商城订单状态:从 2030-待发货 到 2040-已发货/待收货确认
|
// 商城订单状态:从 2030-待发货 到 2040-已发货/待收货确认
|
||||||
@ -957,24 +957,22 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
|||||||
pushRemark = "配送员已取货。";
|
pushRemark = "配送员已取货。";
|
||||||
} else if (shopStoreSfOrder.getOrder_status().equals(StateCode.SF_ORDER_STATUS_FINISH)) {
|
} else if (shopStoreSfOrder.getOrder_status().equals(StateCode.SF_ORDER_STATUS_FINISH)) {
|
||||||
// 顺丰同城状态:17-配送员妥投完单;
|
// 顺丰同城状态:17-配送员妥投完单;
|
||||||
|
// orderStatus = StateCode.ORDER_STATE_FINISH;
|
||||||
pushRemark = "已完成配送";
|
pushRemark = "已完成配送";
|
||||||
|
orderStatus = StateCode.ORDER_STATE_RECEIVED;
|
||||||
|
|
||||||
// 通知微信用户确认收货(同城配送不能调用微信的确认收货)
|
// 通知微信用户确认收货(同城配送不能调用微信的确认收货)
|
||||||
// wxOrderShippingService.notifyConfirmReceive(shopStoreSfOrder.getShop_order_id());
|
// wxOrderShippingService.notifyConfirmReceive(shopStoreSfOrder.getShop_order_id());
|
||||||
// 订单确认收货
|
// 不要提前 订单确认收货,等微信拉卡拉确认通知
|
||||||
shopOrderBaseService.receive(shopStoreSfOrder.getShop_order_id(), null);
|
// try {
|
||||||
|
// shopOrderBaseService.receive(shopOrderId, null);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// logger.error("订单确认收货失败!", e);
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
success = shopOrderInfoService.changeOrderStatus(shopStoreSfOrder.getShop_order_id(), orderStatus, orderIsOutStatus, orderIsShippedStatus);
|
shopOrderInfoService.changeOrderStatus(shopOrderId, orderStatus, orderIsOutStatus, orderIsShippedStatus);
|
||||||
if (!success) {
|
|
||||||
throw new ApiException(I18nUtil._("状态处理失败!"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 注:状态更改之后,给 SSE 监听服务发送更改的数据
|
|
||||||
// logger.debug("准备发送SSE消息...");
|
|
||||||
// SseEmitterUtil.sendMessage(shopStoreSfOrder.getSf_order_id(), jsonData);
|
|
||||||
// logger.debug("向 SSE 通道 {} 发送了:{}", shopStoreSfOrder.getSf_order_id(), jsonData);
|
|
||||||
|
|
||||||
// 消息推送
|
// 消息推送
|
||||||
JSONObject payload = new JSONObject();
|
JSONObject payload = new JSONObject();
|
||||||
@ -1051,21 +1049,18 @@ public class SFExpressApiServiceImpl implements SFExpressApiService {
|
|||||||
|
|
||||||
// 更改商城订单状态为:已完成,注意事务问题
|
// 更改商城订单状态为:已完成,注意事务问题
|
||||||
// 配送员已取单配送中
|
// 配送员已取单配送中
|
||||||
// 商城订单状态:从 040-已发货/待收货确认 到 2060-已完成/已签收
|
// 商城订单状态:从 040-已发货/待收货确认 到 2060-已完成/已签收 (RMK 这里可能有点问题,需要等待用户确认收货,才能设置订单已完成)
|
||||||
success = shopOrderInfoService.changeOrderStatus(shopStoreSfOrder.getShop_order_id(), StateCode.ORDER_STATE_FINISH, 0, 0);
|
// success = shopOrderInfoService.changeOrderStatus(shopStoreSfOrder.getShop_order_id(), StateCode.ORDER_STATE_FINISH, 0, 0);
|
||||||
|
success = shopOrderInfoService.changeOrderStatus(shopStoreSfOrder.getShop_order_id(), StateCode.ORDER_STATE_RECEIVED, 0, 0);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw new ApiException(I18nUtil._("状态处理失败!"));
|
throw new ApiException(I18nUtil._("状态处理失败!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注:状态更改之后,给 SSE 监听服务发送更改的数据
|
|
||||||
// logger.debug("准备发送SSE消息...");
|
|
||||||
// SseEmitterUtil.sendMessage(shopStoreSfOrder.getSf_order_id(), jsonData);
|
|
||||||
|
|
||||||
// 通知微信用户确认收货(同城配送不能调用该微信接口)
|
// 通知微信用户确认收货(同城配送不能调用该微信接口)
|
||||||
// wxOrderShippingService.notifyConfirmReceive(shopStoreSfOrder.getShop_order_id());
|
// wxOrderShippingService.notifyConfirmReceive(shopStoreSfOrder.getShop_order_id());
|
||||||
|
|
||||||
// 订单确认收货
|
// 订单确认收货
|
||||||
shopOrderBaseService.receive(shopStoreSfOrder.getShop_order_id(), null);
|
// shopOrderBaseService.receive(shopStoreSfOrder.getShop_order_id(), null);
|
||||||
|
|
||||||
String orderId = shopStoreSfOrder.getShop_order_id();
|
String orderId = shopStoreSfOrder.getShop_order_id();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user