优化微信支付

This commit is contained in:
TinyAnts 2023-03-23 11:41:16 +08:00
parent 8475dc5324
commit 4d27c8c84d
2 changed files with 13 additions and 3 deletions

View File

@ -104,6 +104,16 @@ public class PayServiceImpl implements IPayService {
*/
public Object prepay(PaymentValidate params, Integer terminal) {
try {
String openId = null;
UserAuth userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
.eq("user_id", params.getUserId())
.eq("terminal", terminal)
.last("limit 1"));
if (StringUtils.isNotNull(userAuth)) {
openId = userAuth.getOpenid();
}
switch (params.getPayWay()) {
case 1: // 余额支付
String attach = params.getAttach();
@ -113,7 +123,7 @@ public class PayServiceImpl implements IPayService {
case 2: // 微信支付
PaymentRequestV3 requestV3 = new PaymentRequestV3();
requestV3.setTerminal(terminal);
requestV3.setOpenId("");
requestV3.setOpenId(openId);
requestV3.setAttach(params.getAttach());
requestV3.setOutTradeNo(params.getOutTradeNo());
requestV3.setOrderAmount(params.getOrderAmount());

View File

@ -15,11 +15,11 @@ public class PaymentValidate implements Serializable {
private static final long serialVersionUID = 1L;
@NotNull(message = "scene参数缺失")
@ApiModelProperty("支付场景")
@ApiModelProperty("支付场景: [recharge=充值,order=普通订单]")
private String scene;
@NotNull(message = "payWay参数缺失")
@ApiModelProperty("支付方式")
@ApiModelProperty("支付方式: [1=余额支付,2=微信支付,3=支付宝支付]")
private Integer payWay;
@NotNull(message = "orderId参数缺失")