|
|
|
@ -45,6 +45,7 @@ import com.cyl.tencent.OrderMessageModel; |
|
|
|
import com.cyl.wechat.WechatPayData; |
|
|
|
import com.cyl.wechat.WechatPayService; |
|
|
|
import com.cyl.wechat.WechatPayUtil; |
|
|
|
import com.cyl.wechat.pay.MpWxPayService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.ruoyi.common.constant.Constants; |
|
|
|
@ -91,6 +92,9 @@ public class H5OrderService { |
|
|
|
@Autowired |
|
|
|
private MemberAddressMapper memberAddressMapper; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private MpWxPayService mpWxPayService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private H5MemberAddressService h5MemberAddressService; |
|
|
|
|
|
|
|
@ -1084,7 +1088,7 @@ public class H5OrderService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public OrderPayResponse orderCreateAndPay(Order order, Member member, String openId) { |
|
|
|
public Object orderCreateAndPay(Order order, Member member, String openId) { |
|
|
|
log.info("【支付】开始组装支付参数"); |
|
|
|
QueryWrapper<OrderItem> orderItemQw = new QueryWrapper<>(); |
|
|
|
orderItemQw.eq("order_id", order.getId()); |
|
|
|
@ -1120,48 +1124,63 @@ public class H5OrderService { |
|
|
|
String appId = WechatPayData.miniProgramAppId; |
|
|
|
|
|
|
|
//TODO |
|
|
|
String payAmount = order.getPayAmount().multiply(new BigDecimal(100)).stripTrailingZeros().toPlainString(); |
|
|
|
int payAmount = order.getPayAmount().multiply(new BigDecimal(100)).intValueExact(); |
|
|
|
// String payAmount = order.getPayAmount().multiply(new BigDecimal(100)).stripTrailingZeros().toPlainString(); |
|
|
|
|
|
|
|
if (payMangeDev){ |
|
|
|
payAmount = "1";//支付一分钱 |
|
|
|
payAmount = 1;//支付一分钱 |
|
|
|
} |
|
|
|
|
|
|
|
String prepayId = wechatPayService.jsapiPay( |
|
|
|
String.valueOf(order.getPayId()), |
|
|
|
Object order1 = mpWxPayService.createOrder( |
|
|
|
orderDesc, |
|
|
|
Integer.valueOf(payAmount), |
|
|
|
"127.0.0.1", |
|
|
|
String.valueOf(order.getPayId()), |
|
|
|
payAmount, |
|
|
|
String.valueOf(order.getPayId()), |
|
|
|
openId, |
|
|
|
member.getId(), |
|
|
|
appId |
|
|
|
"{}", |
|
|
|
WechatPayData.notifyUrl, |
|
|
|
String.valueOf(member.getId()) |
|
|
|
); |
|
|
|
// String prepayId = "TODO"; |
|
|
|
|
|
|
|
log.info("【支付】jsapiPay支付成功,预付单ID:" + prepayId); |
|
|
|
OrderPayResponse response = new OrderPayResponse(); |
|
|
|
response.setPayType(2); |
|
|
|
String nonceStr = WechatPayUtil.generateNonceStr(); |
|
|
|
long timeStamp = WechatPayUtil.getCurrentTimestamp(); |
|
|
|
prepayId = "prepay_id=" + prepayId; |
|
|
|
String signType = "RSA"; |
|
|
|
String paySign = null; |
|
|
|
String signatureStr = Stream.of(appId, String.valueOf(timeStamp), nonceStr, prepayId) |
|
|
|
.collect(Collectors.joining("\n", "", "\n")); |
|
|
|
//TODO |
|
|
|
// paySign = "TODO"; |
|
|
|
try { |
|
|
|
paySign = WechatPayUtil.getSign(signatureStr, WechatPayData.privateKeyPath); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("获取签名失败,"); |
|
|
|
throw new RuntimeException("支付失败"); |
|
|
|
} |
|
|
|
response.setAppId(appId); |
|
|
|
response.setTimeStamp(String.valueOf(timeStamp)); |
|
|
|
response.setNonceStr(nonceStr); |
|
|
|
response.setSignType(signType); |
|
|
|
response.setPackage_(prepayId); |
|
|
|
response.setPaySign(paySign); |
|
|
|
response.setOrderId(order.getId()); |
|
|
|
return response; |
|
|
|
return order1; |
|
|
|
|
|
|
|
// String prepayId = wechatPayService.jsapiPay( |
|
|
|
// String.valueOf(order.getPayId()), |
|
|
|
// orderDesc, |
|
|
|
// Integer.valueOf(payAmount), |
|
|
|
// openId, |
|
|
|
// member.getId(), |
|
|
|
// appId |
|
|
|
// ); |
|
|
|
//// String prepayId = "TODO"; |
|
|
|
// |
|
|
|
// log.info("【支付】jsapiPay支付成功,预付单ID:" + prepayId); |
|
|
|
// OrderPayResponse response = new OrderPayResponse(); |
|
|
|
// response.setPayType(2); |
|
|
|
// String nonceStr = WechatPayUtil.generateNonceStr(); |
|
|
|
// long timeStamp = WechatPayUtil.getCurrentTimestamp(); |
|
|
|
// prepayId = "prepay_id=" + prepayId; |
|
|
|
// String signType = "RSA"; |
|
|
|
// String paySign = null; |
|
|
|
// String signatureStr = Stream.of(appId, String.valueOf(timeStamp), nonceStr, prepayId) |
|
|
|
// .collect(Collectors.joining("\n", "", "\n")); |
|
|
|
// //TODO |
|
|
|
//// paySign = "TODO"; |
|
|
|
// try { |
|
|
|
// paySign = WechatPayUtil.getSign(signatureStr, WechatPayData.privateKeyPath); |
|
|
|
// } catch (Exception e) { |
|
|
|
// log.error("获取签名失败,"); |
|
|
|
// throw new RuntimeException("支付失败"); |
|
|
|
// } |
|
|
|
// response.setAppId(appId); |
|
|
|
// response.setTimeStamp(String.valueOf(timeStamp)); |
|
|
|
// response.setNonceStr(nonceStr); |
|
|
|
// response.setSignType(signType); |
|
|
|
// response.setPackage_(prepayId); |
|
|
|
// response.setPaySign(paySign); |
|
|
|
// response.setOrderId(order.getId()); |
|
|
|
// return response; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|