|
|
@@ -365,15 +365,17 @@ public class WxMicroPayController extends BaseController { |
|
|
logger.error("orderId不能为空"); |
|
|
logger.error("orderId不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); |
|
|
} |
|
|
} |
|
|
if (StringUtils.isBlank(authCode)) { |
|
|
|
|
|
logger.error("authCode不能为空"); |
|
|
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "authCode不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
if (StringUtils.isBlank(payPriceStr)) { |
|
|
if (StringUtils.isBlank(payPriceStr)) { |
|
|
logger.error("payPrice不能为空"); |
|
|
logger.error("payPrice不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payPrice不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payPrice不能为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal totalFee = new BigDecimal(payPriceStr); |
|
|
|
|
|
totalFee.setScale(2, BigDecimal.ROUND_HALF_UP); // 第一个变量是小数位数,第二个变量是取舍方法(四舍五入) |
|
|
|
|
|
Integer payPrice = totalFee.multiply(new BigDecimal(100)).intValue(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String ipStr = IPUtil.getIpAddr(request); |
|
|
String ipStr = IPUtil.getIpAddr(request); |
|
|
|
|
|
|
|
|
WxMerchantBUser wxMerchantBUser = wxMerchantBUserService.getById(user.getId()); |
|
|
WxMerchantBUser wxMerchantBUser = wxMerchantBUserService.getById(user.getId()); |
|
|
@@ -384,9 +386,7 @@ public class WxMicroPayController extends BaseController { |
|
|
wxMerchantBUser.setBuserId(getBuserId()); |
|
|
wxMerchantBUser.setBuserId(getBuserId()); |
|
|
|
|
|
|
|
|
Long couponOrderId = 0L, orderId = 0L; |
|
|
Long couponOrderId = 0L, orderId = 0L; |
|
|
BigDecimal totalFee = new BigDecimal(payPriceStr); |
|
|
|
|
|
totalFee.setScale(2, BigDecimal.ROUND_HALF_UP); // 第一个变量是小数位数,第二个变量是取舍方法(四舍五入) |
|
|
|
|
|
Integer payPrice = totalFee.multiply(new BigDecimal(100)).intValue(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
orderId = Long.valueOf(orderIdStr); |
|
|
orderId = Long.valueOf(orderIdStr); |
|
|
} catch (NumberFormatException e) { |
|
|
} catch (NumberFormatException e) { |
|
|
@@ -424,22 +424,49 @@ public class WxMicroPayController extends BaseController { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
WxPayOrder record = new WxPayOrder(); |
|
|
|
|
|
record.setTenantId(user.getTenantId()); |
|
|
|
|
|
record.setOrderId(microOrder.getId()); |
|
|
|
|
|
record.setCUserId(microOrder.getCUserId()); |
|
|
|
|
|
record.setAuthCode(authCode); |
|
|
|
|
|
record.setPayAmount(remainPrice); |
|
|
|
|
|
record.setIp(ipStr); |
|
|
|
|
|
|
|
|
if (remainPrice > 0) { |
|
|
|
|
|
if (StringUtils.isBlank(authCode)) { |
|
|
|
|
|
logger.error("authCode不能为空"); |
|
|
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "authCode不能为空"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
return wxPayOrderService.createMicroPayOrder(user, record, EnumPayWay.PAY_WAY_WECHAT); |
|
|
|
|
|
} catch (MallinkException e) { |
|
|
|
|
|
logger.error("payment wechat, order create error, req 2: " + record.toString() + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("payment wechat, order create error, req 3: " + record.toString() + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR, e.getMessage()); |
|
|
|
|
|
|
|
|
WxPayOrder record = new WxPayOrder(); |
|
|
|
|
|
record.setTenantId(user.getTenantId()); |
|
|
|
|
|
record.setOrderId(microOrder.getId()); |
|
|
|
|
|
record.setCUserId(microOrder.getCUserId()); |
|
|
|
|
|
record.setAuthCode(authCode); |
|
|
|
|
|
record.setPayAmount(remainPrice); |
|
|
|
|
|
record.setIp(ipStr); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
return wxPayOrderService.createMicroPayOrder(user, record, EnumPayWay.PAY_WAY_WECHAT); |
|
|
|
|
|
} catch (MallinkException e) { |
|
|
|
|
|
logger.error("payment wechat, order create error, req 2: " + record.toString() + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("payment wechat, order create error, req 3: " + record.toString() + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR, e.getMessage()); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
// 支付完成 |
|
|
|
|
|
WxPayOrder record = new WxPayOrder(); |
|
|
|
|
|
record.setTenantId(user.getTenantId()); |
|
|
|
|
|
record.setOrderId(microOrder.getId()); |
|
|
|
|
|
record.setCUserId(microOrder.getCUserId()); |
|
|
|
|
|
record.setPayAmount(remainPrice); |
|
|
|
|
|
record.setIp(ipStr); |
|
|
|
|
|
try { |
|
|
|
|
|
wxPayOrderService.handleMicroOrderPaySuccessForVerify(user, record); |
|
|
|
|
|
Map map = new HashMap(); |
|
|
|
|
|
map.put("end", "1"); |
|
|
|
|
|
return new ResultData(map); |
|
|
|
|
|
} catch (MallinkException e) { |
|
|
|
|
|
logger.error("payment wechat, order create error, req 2: " + record.toString() + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(e.getErrorCode(), e.getMessage()); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("payment wechat, order create error, req 3: " + record.toString() + ", e:" + e.getMessage()); |
|
|
|
|
|
return new ResultData(ErrorCode.PAY_ORDER_ERROR, e.getMessage()); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |