|
|
|
@@ -130,7 +130,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
// 2. check 是否有支付订单 |
|
|
|
Date currentDate = new Date(); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); |
|
|
|
List<WxPayOrder> list = wxPayOrderMapper.findList(record); |
|
|
|
String payOrderNo = ""; |
|
|
|
if (list.size() <= 0) { |
|
|
|
@@ -148,7 +148,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
record.setPayOrderNo(payOrderNo); |
|
|
|
record.setPayAmount(order.getPayment()); |
|
|
|
record.setPayVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); |
|
|
|
record.setShare(isShare.getCode()); |
|
|
|
if (isShare == EnumPayShare.YES) { |
|
|
|
// 分账金额 |
|
|
|
@@ -388,7 +388,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
// 2. check 是否有支付订单 |
|
|
|
Date currentDate = new Date(); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); |
|
|
|
List<WxPayOrder> list = wxPayOrderMapper.findList(record); |
|
|
|
String payOrderNo = ""; |
|
|
|
if (list.size() <= 0) { |
|
|
|
@@ -406,7 +406,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
record.setPayOrderNo(payOrderNo); |
|
|
|
record.setPayAmount(order.getPayment()); |
|
|
|
record.setPayVendor(EnumPayWay.PAY_WAY_WEAPP.getCode()); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); |
|
|
|
record.setShare(isShare.getCode()); |
|
|
|
if (isShare == EnumPayShare.YES) { |
|
|
|
// 分账金额 |
|
|
|
@@ -491,8 +491,18 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String errMsg = returnMap.get("return_msg"); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("pay order update error: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, "刷卡支付异常", returnMap); |
|
|
|
} else { |
|
|
|
// 统一下单 // 服务商模式 |
|
|
|
String noncestr = Utility.generate32UUID(); |
|
|
|
@@ -564,8 +574,18 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String errMsg = returnMap.get("return_msg"); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("pay order update error: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
return new ResultData(Result.ERROR, "刷卡支付异常", returnMap); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 虚拟支付 |
|
|
|
@@ -656,37 +676,63 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
|
|
|
|
logger.info("pay order query, " + record.toString() + ", response: " + response); |
|
|
|
Map<String, String> returnMap = WxPayment.xmlToMap(response); |
|
|
|
String return_code = returnMap.get("return_code"); |
|
|
|
String result_code = returnMap.get("result_code"); |
|
|
|
if ("SUCCESS".equals(result_code)) { |
|
|
|
String trade_state = returnMap.get("trade_state"); |
|
|
|
//SUCCESS—支付成功 |
|
|
|
//REFUND—转入退款 |
|
|
|
//NOTPAY—未支付 |
|
|
|
//CLOSED—已关闭 |
|
|
|
//REVOKED—已撤销(刷卡支付) |
|
|
|
//USERPAYING--用户支付中 |
|
|
|
//PAYERROR--支付失败(其他原因,如银行返回失败) |
|
|
|
if ("SUCCESS".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} else if ("USERPAYING".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
if("SUCCESS".equalsIgnoreCase(return_code)) { |
|
|
|
if ("SUCCESS".equals(result_code)) { |
|
|
|
String trade_state = returnMap.get("trade_state"); |
|
|
|
//SUCCESS—支付成功 |
|
|
|
//REFUND—转入退款 |
|
|
|
//NOTPAY—未支付 |
|
|
|
//CLOSED—已关闭 |
|
|
|
//REVOKED—已撤销(刷卡支付) |
|
|
|
//USERPAYING--用户支付中 |
|
|
|
//PAYERROR--支付失败(其他原因,如银行返回失败) |
|
|
|
if ("SUCCESS".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} else if ("REFUND".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REFUND.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} else if ("NOTPAY".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} else if ("CLOSED".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_CLOSE.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} else if ("REVOKED".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_REVERSE.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} else if ("USERPAYING".equals(trade_state)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} else { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_ERR.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
} |
|
|
|
return new ResultData(Result.SUCCESS, "订单查询成功", returnMap); |
|
|
|
} else { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_FAIL.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
String errMsg = ""; |
|
|
|
JSONObject errObj = errorMapQuery.getJSONObject(result_code); |
|
|
|
if (errObj != null) { |
|
|
|
errMsg = errObj.toJSONString(); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
} else { |
|
|
|
errMsg = returnMap.get("return_msg"); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
} |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("pay order update error: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
return new ResultData(Result.SUCCESS, "订单查询成功", returnMap); |
|
|
|
} else { |
|
|
|
String errMsg = ""; |
|
|
|
JSONObject errObj = errorMapQuery.getJSONObject(result_code); |
|
|
|
if (errObj != null) { |
|
|
|
errMsg = errObj.toJSONString(); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
} else { |
|
|
|
errMsg = returnMap.get("return_msg"); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
} |
|
|
|
String errMsg = returnMap.get("return_msg"); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(record); |
|
|
|
@@ -722,6 +768,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); |
|
|
|
map = BeanUtils.toStringMap(payOrderC); |
|
|
|
String response = WxPay.closeOrder(map); |
|
|
|
logger.info("request:" + map.toString() + "\nresponse:" + response); |
|
|
|
return response; |
|
|
|
} catch (RuntimeException e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
@@ -745,6 +792,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); |
|
|
|
map = BeanUtils.toStringMap(payOrderSC); |
|
|
|
String response = WxPay.closeOrder(map); |
|
|
|
logger.info("request:" + map.toString() + "\nresponse:" + response); |
|
|
|
return response; |
|
|
|
} catch (RuntimeException e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
@@ -765,19 +813,139 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
|
|
|
|
logger.info("pay order close, " + record.toString() + ", response: " + response); |
|
|
|
Map<String, String> returnMap = WxPayment.xmlToMap(response); |
|
|
|
String return_code = returnMap.get("return_code"); |
|
|
|
String result_code = returnMap.get("result_code"); |
|
|
|
if ("SUCCESS".equals(result_code)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_WAY_CANCEL.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); |
|
|
|
if("SUCCESS".equalsIgnoreCase(return_code)) { |
|
|
|
if ("SUCCESS".equals(result_code)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_CANCEL.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); |
|
|
|
} else { |
|
|
|
String errMsg = ""; |
|
|
|
JSONObject errObj = errorMapClose.getJSONObject(result_code); |
|
|
|
if (errObj != null) { |
|
|
|
errMsg = errObj.toJSONString(); |
|
|
|
} else { |
|
|
|
errMsg = returnMap.get("return_msg"); |
|
|
|
} |
|
|
|
record.setFailReason(errMsg); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("pay order update error: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String errMsg = ""; |
|
|
|
JSONObject errObj = errorMapClose.getJSONObject(result_code); |
|
|
|
if (errObj != null) { |
|
|
|
errMsg = errObj.toJSONString(); |
|
|
|
String errMsg = returnMap.get("return_msg"); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("pay order update error: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
} catch (RuntimeException e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String wechatPayOrderReverse(WxAppinfo appInfo, WxPayOrder record) { |
|
|
|
// get payAccount |
|
|
|
WxPayAccount payAccount = wxPayAccountMapper.selectByPrimaryKey(appInfo.getPayId()); |
|
|
|
if (payAccount.getType() == EnumPayMode.MCH.getCode()) { |
|
|
|
// 普通商户号模式 |
|
|
|
WxPayOrderQ payOrderC = new WxPayOrderQ(); |
|
|
|
String noncestr = Utility.generate32UUID(); |
|
|
|
payOrderC.setAppid(appInfo.getAppId()); |
|
|
|
payOrderC.setMch_id(payAccount.getMchId()); |
|
|
|
payOrderC.setNonce_str(noncestr); |
|
|
|
payOrderC.setOut_trade_no(record.getPayOrderNo()); |
|
|
|
|
|
|
|
try { |
|
|
|
Map map = BeanUtils.toStringMap(payOrderC); |
|
|
|
payOrderC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); |
|
|
|
map = BeanUtils.toStringMap(payOrderC); |
|
|
|
String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); |
|
|
|
logger.info("request:" + map.toString() + "\nresponse:" + response); |
|
|
|
return response; |
|
|
|
} catch (RuntimeException e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 服务商模式 |
|
|
|
WxPayOrderSQ payOrderSC = new WxPayOrderSQ(); |
|
|
|
String noncestr = Utility.generate32UUID(); |
|
|
|
payOrderSC.setAppid(appInfo.getParentAppId()); |
|
|
|
payOrderSC.setSub_appid(appInfo.getAppId()); |
|
|
|
payOrderSC.setMch_id(payAccount.getMchId()); |
|
|
|
payOrderSC.setSub_mch_id(payAccount.getSubMchId()); |
|
|
|
payOrderSC.setNonce_str(noncestr); |
|
|
|
payOrderSC.setOut_trade_no(record.getPayOrderNo()); |
|
|
|
payOrderSC.setSign_type("HMAC-SHA256"); |
|
|
|
|
|
|
|
try { |
|
|
|
Map map = BeanUtils.toStringMap(payOrderSC); |
|
|
|
payOrderSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); |
|
|
|
map = BeanUtils.toStringMap(payOrderSC); |
|
|
|
String response = WxPay.orderReverse(map, payAccount.getCertPath(), payAccount.getMchId()); |
|
|
|
logger.info("request:" + map.toString() + "\nresponse:" + response); |
|
|
|
return response; |
|
|
|
} catch (RuntimeException e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 微信刷卡支付撤销订单 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ResultData payOrderReverse(WxAppinfo appInfo, WxPayOrder record) { |
|
|
|
|
|
|
|
try { |
|
|
|
String response = wechatPayOrderReverse(appInfo, record); |
|
|
|
|
|
|
|
logger.info("pay order reverse, " + record.toString() + ", response: " + response); |
|
|
|
Map<String, String> returnMap = WxPayment.xmlToMap(response); |
|
|
|
String return_code = returnMap.get("return_code"); |
|
|
|
String result_code = returnMap.get("result_code"); |
|
|
|
if("SUCCESS".equalsIgnoreCase(return_code)) { |
|
|
|
if ("SUCCESS".equals(result_code)) { |
|
|
|
record.setPayOrderStatus(EnumPayStatus.PAY_STATUS_CANCEL.getCode()); |
|
|
|
handlePayOrderStatusUpdate(record); |
|
|
|
return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); |
|
|
|
} else { |
|
|
|
errMsg = returnMap.get("return_msg"); |
|
|
|
String errMsg = ""; |
|
|
|
JSONObject errObj = errorMapClose.getJSONObject(result_code); |
|
|
|
if (errObj != null) { |
|
|
|
errMsg = errObj.toJSONString(); |
|
|
|
} else { |
|
|
|
errMsg = returnMap.get("return_msg"); |
|
|
|
} |
|
|
|
record.setFailReason(errMsg); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(record); |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("pay order update error: " + record.toString()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL); |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
} else { |
|
|
|
String errMsg = returnMap.get("return_msg"); |
|
|
|
record.setFailReason(errMsg); |
|
|
|
record.setUpdateTime(new Date()); |
|
|
|
try { |
|
|
|
@@ -788,6 +956,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); |
|
|
|
} |
|
|
|
|
|
|
|
} catch (RuntimeException e) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); |
|
|
|
} catch (Exception e) { |
|
|
|
@@ -920,7 +1089,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
Date currentDate = new Date(); |
|
|
|
EnumPayStatus payStatus = EnumPayStatus.getEnum(record.getPayOrderStatus()); |
|
|
|
// 判断支付状态 |
|
|
|
if (payStatus == EnumPayStatus.PAY_WAY_SUCCESS) { |
|
|
|
if (payStatus == EnumPayStatus.PAY_STATUS_SUCCESS) { |
|
|
|
// 已经是成功状态,只更新transactionId |
|
|
|
try { |
|
|
|
record.setUpdateTime(currentDate); |
|
|
|
@@ -932,8 +1101,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
if (payStatus != EnumPayStatus.PAY_WAY_WAIT) { |
|
|
|
logger.error("pay success handle, payOrder " + record.getPayOrderNo() + |
|
|
|
if (payStatus != EnumPayStatus.PAY_STATUS_WAIT) { |
|
|
|
logger.info("pay success handle, payOrder " + record.getPayOrderNo() + |
|
|
|
"is paid success , orderId : " + record.getOrderId()); |
|
|
|
return; |
|
|
|
} |
|
|
|
@@ -949,7 +1118,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
updateOrder.setId(record.getId()); |
|
|
|
updateOrder.setOrderId(record.getOrderId()); |
|
|
|
updateOrder.setUpdateTime(currentDate); |
|
|
|
updateOrder.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); |
|
|
|
updateOrder.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); |
|
|
|
updateOrder.setTransactionId(transactionId); |
|
|
|
try { |
|
|
|
wxPayOrderMapper.updateByPrimaryKeySelective(updateOrder); |
|
|
|
@@ -988,7 +1157,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public void handlePayOrderStatusUpdate(WxPayOrder record) { |
|
|
|
// 判断支付状态 |
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_WAIT.getCode()) { |
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_STATUS_WAIT.getCode()) { |
|
|
|
logger.error("pay handle, payOrder " + record.getPayOrderNo() + |
|
|
|
"is complete, orderId : " + record.getOrderId()); |
|
|
|
return; |
|
|
|
@@ -1038,13 +1207,13 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); |
|
|
|
} |
|
|
|
|
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_CANCEL.getCode()) { |
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_STATUS_CANCEL.getCode()) { |
|
|
|
// 支付订单取消 |
|
|
|
if (record.getPayAmount() > 0) { |
|
|
|
payOrderQ = new WxPayOrder(); |
|
|
|
payOrderQ.setTenantId(order.getTenantId()); |
|
|
|
payOrderQ.setOrderId(record.getOrderId()); |
|
|
|
payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_WAY_WAIT.getCode()); |
|
|
|
payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); |
|
|
|
List<WxPayOrder> payOrders = wxPayOrderMapper.select(payOrderQ); |
|
|
|
for (WxPayOrder payOrder : payOrders) { |
|
|
|
payOrderClose(appInfo, payOrder); |
|
|
|
@@ -1052,7 +1221,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 支付订单成功? |
|
|
|
if (updateOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_WAY_SUCCESS.getCode())) { |
|
|
|
if (updateOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_STATUS_SUCCESS.getCode())) { |
|
|
|
if (StringUtils.isBlank(updateOrder.getTransactionId())) { |
|
|
|
// 回调已设置成功 |
|
|
|
// 继续修改订单状态 |
|
|
|
@@ -1060,7 +1229,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
// 回调异常 |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "transactionId未获取"); |
|
|
|
} |
|
|
|
} else if (updateOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_WAY_WAIT.getCode())) { |
|
|
|
} else if (updateOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_STATUS_WAIT.getCode())) { |
|
|
|
// 回调未返回,主动检查支付订单状态 |
|
|
|
try { |
|
|
|
record.setPayOrderNo(String.valueOf(record.getId())); |
|
|
|
@@ -1098,7 +1267,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
|
|
|
|
// 修改订单状态 |
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_SUCCESS.getCode()) { |
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_STATUS_SUCCESS.getCode()) { |
|
|
|
try { |
|
|
|
int _count = wxOrderService.orderSuccess(order); |
|
|
|
if (_count > 1) { |
|
|
|
@@ -1108,7 +1277,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
logger.error(e.getMessage()); |
|
|
|
throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "订单更新"); |
|
|
|
} |
|
|
|
} else if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_CANCEL.getCode()) { |
|
|
|
} else if (record.getPayOrderStatus() == EnumPayStatus.PAY_STATUS_CANCEL.getCode()) { |
|
|
|
try { |
|
|
|
int _count = wxOrderService.updateOrderStatus(order, EnumOrderStatus.ORDER_STATUS_OVERTIME_CANCEL); |
|
|
|
if (_count > 1) { |
|
|
|
|