|
|
@@ -54,6 +54,9 @@ public class WxMicroPayController extends BaseController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
WxAppinfoService wxAppinfoService; |
|
|
WxAppinfoService wxAppinfoService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
WxPayAccountService wxPayAccountService; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
WxCouponOrderService wxCouponOrderService; |
|
|
WxCouponOrderService wxCouponOrderService; |
|
|
|
|
|
|
|
|
@@ -70,14 +73,15 @@ public class WxMicroPayController extends BaseController { |
|
|
@PostMapping("order_create") |
|
|
@PostMapping("order_create") |
|
|
public ResultData saveMicopayOrder(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { |
|
|
public ResultData saveMicopayOrder(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { |
|
|
logger.info("saveMicopayOrder: " + paramMap.toString()); |
|
|
logger.info("saveMicopayOrder: " + paramMap.toString()); |
|
|
|
|
|
String ipStr = IPUtil.getIpAddr(request); |
|
|
//Assert.notNull(wxOrders.getName(), "角色名不能为空"); |
|
|
//Assert.notNull(wxOrders.getName(), "角色名不能为空"); |
|
|
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); |
|
|
//Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); |
|
|
String authCode = paramMap.get("authCode"); |
|
|
String authCode = paramMap.get("authCode"); |
|
|
String totalFeeStr = paramMap.get("totalFee"); |
|
|
String totalFeeStr = paramMap.get("totalFee"); |
|
|
return saveMicopayOrder(authCode, totalFeeStr, EnumPayWay.PAY_WAY_WECHAT_MA,EnumPayVersion.WX_PAY_V2, request); |
|
|
|
|
|
|
|
|
return saveMicopayOrder(authCode, totalFeeStr, EnumPayWay.PAY_WAY_WECHAT_MA, ipStr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ResultData saveMicopayOrder(String authCode,String totalFeeStr,EnumPayWay payWay,EnumPayVersion payVersion,HttpServletRequest request) { |
|
|
|
|
|
|
|
|
private ResultData saveMicopayOrder(String authCode,String totalFeeStr,EnumPayWay payWay,String ipStr) { |
|
|
if (StringUtils.isBlank(authCode)) { |
|
|
if (StringUtils.isBlank(authCode)) { |
|
|
logger.error("authCode不能为空"); |
|
|
logger.error("authCode不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "authCode不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "authCode不能为空"); |
|
|
@@ -90,11 +94,18 @@ public class WxMicroPayController extends BaseController { |
|
|
logger.error("totalFee不能为空"); |
|
|
logger.error("totalFee不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "totalFee不能为空"); |
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "totalFee不能为空"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
String ipStr = IPUtil.getIpAddr(request); |
|
|
|
|
|
|
|
|
|
|
|
WxMerchantBUser user = getLoginBUser(); |
|
|
WxMerchantBUser user = getLoginBUser(); |
|
|
|
|
|
|
|
|
|
|
|
WxPayAccount payAccount = wxPayAccountService.getPayAccount(user, payWay.getPlat()); |
|
|
|
|
|
if(payAccount == null){ |
|
|
|
|
|
return new ResultData(ErrorCode.API_KEY_NOT_FOUND.getCode(), "未找到支付配置"); |
|
|
|
|
|
} |
|
|
|
|
|
EnumPayVersion payVersion = EnumPayVersion.getEnum(payAccount.getPayVersion()); |
|
|
|
|
|
if(payVersion == null){ |
|
|
|
|
|
return new ResultData(ErrorCode.MCH_INFO_NOT_EQUAL.getCode(), "支付配置错误"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WxOrder order = null; |
|
|
WxOrder order = null; |
|
|
try { |
|
|
try { |
|
|
order = wxOrderService.saveMicroPayOrder(user, totalFeeStr,payWay,payVersion); |
|
|
order = wxOrderService.saveMicroPayOrder(user, totalFeeStr,payWay,payVersion); |
|
|
@@ -382,16 +393,18 @@ public class WxMicroPayController extends BaseController { |
|
|
@PostMapping("pay_order_create_v2") |
|
|
@PostMapping("pay_order_create_v2") |
|
|
public ResultData saveMicopayPayOrder(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { |
|
|
public ResultData saveMicopayPayOrder(@RequestBody Map<String, String> paramMap, HttpServletRequest request) { |
|
|
logger.info("saveMicopayPayOrder: " + paramMap.toString()); |
|
|
logger.info("saveMicopayPayOrder: " + paramMap.toString()); |
|
|
|
|
|
String ipStr = IPUtil.getIpAddr(request); |
|
|
|
|
|
|
|
|
String orderIdStr = paramMap.get("orderId"); |
|
|
String orderIdStr = paramMap.get("orderId"); |
|
|
String couponOrderIdStr = paramMap.get("couponOrderId"); |
|
|
String couponOrderIdStr = paramMap.get("couponOrderId"); |
|
|
String authCode = paramMap.get("authCode"); |
|
|
String authCode = paramMap.get("authCode"); |
|
|
String payPriceStr = paramMap.get("payPrice"); |
|
|
String payPriceStr = paramMap.get("payPrice"); |
|
|
return saveMicopayPayOrder(orderIdStr, couponOrderIdStr, authCode, payPriceStr, EnumPayWay.PAY_WAY_WECHAT_MA,EnumPayVersion.WX_PAY_V2, request); |
|
|
|
|
|
|
|
|
return saveMicopayPayOrder(orderIdStr, couponOrderIdStr, authCode, payPriceStr, EnumPayWay.PAY_WAY_WECHAT_MA,ipStr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private ResultData saveMicopayPayOrder(String orderIdStr,String couponOrderIdStr,String authCode,String payPriceStr, |
|
|
private ResultData saveMicopayPayOrder(String orderIdStr,String couponOrderIdStr,String authCode,String payPriceStr, |
|
|
EnumPayWay payWay,EnumPayVersion payVersion, HttpServletRequest request) { |
|
|
|
|
|
WxMerchantBUser user = getLoginBUser(); |
|
|
|
|
|
|
|
|
EnumPayWay payWay,String ipStr) { |
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(orderIdStr)) { |
|
|
if (StringUtils.isBlank(orderIdStr)) { |
|
|
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不能为空"); |
|
|
@@ -407,12 +420,22 @@ public class WxMicroPayController extends BaseController { |
|
|
return new ResultData(ErrorCode.MICRO_PAY_ERR_AUTHCODE.getCode(), "请扫描微信收款码"); |
|
|
return new ResultData(ErrorCode.MICRO_PAY_ERR_AUTHCODE.getCode(), "请扫描微信收款码"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
WxMerchantBUser user = getLoginBUser(); |
|
|
|
|
|
|
|
|
|
|
|
WxPayAccount payAccount = wxPayAccountService.getPayAccount(user, payWay.getPlat()); |
|
|
|
|
|
if(payAccount == null){ |
|
|
|
|
|
return new ResultData(ErrorCode.API_KEY_NOT_FOUND.getCode(), "未找到支付配置"); |
|
|
|
|
|
} |
|
|
|
|
|
EnumPayVersion payVersion = EnumPayVersion.getEnum(payAccount.getPayVersion()); |
|
|
|
|
|
if(payVersion == null){ |
|
|
|
|
|
return new ResultData(ErrorCode.MCH_INFO_NOT_EQUAL.getCode(), "支付配置错误"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
BigDecimal totalFee = new BigDecimal(payPriceStr); |
|
|
BigDecimal totalFee = new BigDecimal(payPriceStr); |
|
|
totalFee.setScale(2, BigDecimal.ROUND_HALF_UP); // 第一个变量是小数位数,第二个变量是取舍方法(四舍五入) |
|
|
totalFee.setScale(2, BigDecimal.ROUND_HALF_UP); // 第一个变量是小数位数,第二个变量是取舍方法(四舍五入) |
|
|
Integer payPrice = totalFee.multiply(new BigDecimal(100)).intValue(); |
|
|
Integer payPrice = totalFee.multiply(new BigDecimal(100)).intValue(); |
|
|
|
|
|
|
|
|
String ipStr = IPUtil.getIpAddr(request); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WxMerchantBUser wxMerchantBUser = wxMerchantBUserService.getById(user.getId()); |
|
|
WxMerchantBUser wxMerchantBUser = wxMerchantBUserService.getById(user.getId()); |
|
|
if (wxMerchantBUser == null) { |
|
|
if (wxMerchantBUser == null) { |
|
|
|