|
|
|
@@ -263,6 +263,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
futureDate.setTime(currentDate.getTime() + 15 * 60 * 1000); |
|
|
|
wxPayOrderSP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(futureDate)); // 15分钟后结束 |
|
|
|
wxPayOrderSP.setSign_type("HMAC-SHA256"); |
|
|
|
wxPayOrderSP.setProfit_sharing(null); |
|
|
|
if (isShare == EnumPayShare.YES) { |
|
|
|
wxPayOrderSP.setProfit_sharing("Y"); |
|
|
|
} |
|
|
|
@@ -406,6 +407,8 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
@Override |
|
|
|
public ResultData payOrderQuery(WxAppinfo appInfo, WxPayOrder record) { |
|
|
|
try { |
|
|
|
if (StringUtils.isBlank(record.getPayOrderNo())) |
|
|
|
record.setPayOrderNo(String.valueOf(record.getId())); |
|
|
|
String response = wechatPayOrderQuery(appInfo, record); |
|
|
|
|
|
|
|
logger.info("pay order query, " + record.toString() + ", response: " + response); |
|
|
|
@@ -738,7 +741,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
@Override |
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
public void handlePayOrderStatusUpdate(WxPayOrder record) { |
|
|
|
// 只支持取消 payOrder |
|
|
|
// 判断支付状态 |
|
|
|
if (record.getPayOrderStatus() == EnumPayStatus.PAY_WAY_WAIT.getCode()) { |
|
|
|
logger.error("pay handle, payOrder " + record.getPayOrderNo() + |
|
|
|
@@ -755,23 +757,33 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
logger.error("pay handle, order " + record.getOrderId() + " not found , payOrderGid : " + record.getPayOrderNo()); |
|
|
|
throw new MallinkException(ErrorCode.USER_IS_EMPTY); |
|
|
|
} |
|
|
|
// 1. get appinfo |
|
|
|
WxAppinfo appInfo = null; |
|
|
|
WxAppinfo appinfoQ = new WxAppinfo(); |
|
|
|
appinfoQ.setTenantId(order.getTenantId()); |
|
|
|
appinfoQ.setType(EnumAppType.C.getCode()); |
|
|
|
List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); |
|
|
|
if (appList.size() > 0) { |
|
|
|
appInfo = appList.get(0); |
|
|
|
|
|
|
|
|
|
|
|
if (order.getPayment() > 0) { |
|
|
|
// 订单金额不为0时, 支付订单未创建, 返回异常 |
|
|
|
if (!(record.getId() >0)) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Date currentDate = new Date(); |
|
|
|
if (record.getId() > 0) { |
|
|
|
// 1. get appinfo |
|
|
|
WxAppinfo appInfo = null; |
|
|
|
WxAppinfo appinfoQ = new WxAppinfo(); |
|
|
|
appinfoQ.setTenantId(order.getTenantId()); |
|
|
|
appinfoQ.setType(EnumAppType.C.getCode()); |
|
|
|
List<WxAppinfo> appList = wxAppinfoMapper.select(appinfoQ); |
|
|
|
if (appList.size() > 0) { |
|
|
|
appInfo = appList.get(0); |
|
|
|
} |
|
|
|
|
|
|
|
WxPayOrder updateOrder = null; |
|
|
|
|
|
|
|
// 检查支付订单状态 |
|
|
|
WxPayOrder payOrderQ = new WxPayOrder(); |
|
|
|
payOrderQ.setId(record.getId()); |
|
|
|
payOrderQ.setTenantId(order.getTenantId()); |
|
|
|
payOrderQ.setOrderId(record.getOrderId()); |
|
|
|
try { |
|
|
|
updateOrder = wxPayOrderMapper.selectOne(payOrderQ); |
|
|
|
@@ -805,6 +817,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} else if (updateOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_WAY_WAIT.getCode())) { |
|
|
|
// 回调未返回,主动检查支付订单状态 |
|
|
|
try { |
|
|
|
record.setPayOrderNo(String.valueOf(record.getId())); |
|
|
|
String response = wechatPayOrderQuery(appInfo, record); |
|
|
|
|
|
|
|
logger.info("pay order query, " + record.toString() + ", response: " + response); |
|
|
|
@@ -836,11 +849,6 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 支付订单未创建, 订单金额不为0时, 返回异常 |
|
|
|
if (order.getPayment() > 0) { |
|
|
|
throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 修改订单状态 |
|
|
|
|