feat 添加微信获取openid,微信支付调起接口

This commit is contained in:
lwh 2023-09-25 01:13:35 +08:00
parent ece0023cdc
commit 18365aa006

View File

@ -34,6 +34,7 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
_PaymentService = paymentService; _PaymentService = paymentService;
} }
#region #region
/// <summary> /// <summary>
/// 微信支付 /// 微信支付
@ -50,9 +51,15 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
// 获取金额 // 获取金额
var price = 1;//单位:分 var price = 1;//单位:分
var user = JwtUtil.GetLoginUser(App.HttpContext);
//var customer = await _CustomerService.GetFirstAsync(s => s.CustomerGuid == user.UserId);
//if (customer != null)
//{
// //parm.openId = customer.CustomerXcxOpenid;
//}
var orderNo = Common.Common.CreateNoQuery(); var orderNo = Common.Common.CreateNoQuery();
var payEntity = await pay.PrePay(parm.ProductGuid, parm.openId, orderNo, parm.type, price); var payEntity = await pay.PrePay(0, parm.openId, orderNo, parm.payType, price);
if (payEntity == null) if (payEntity == null)
{ {
@ -60,23 +67,23 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
} }
else else
{ {
var user = JwtUtil.GetLoginUser(App.HttpContext);
var userId = 1600478763014033408; var userId = 1600478763014033408;
Payment payment = new Payment Payment payment = new Payment
{ {
PaymentBusinessGuid = parm.ProductGuid, //PaymentBusinessGuid = parm.ProductGuid,
PaymentNumber = orderNo, PaymentNumber = orderNo,
PaymentBuytype = parm.type, PaymentBuytype = parm.payType,
CustomerGuid = userId, CustomerGuid = userId,
PaymentStatus = 1 PaymentStatus = 1
}; };
var response = _PaymentService.InsertReturnSnowflakeId(payment); var response = await _PaymentService.InsertReturnSnowflakeIdAsync(payment);
if (response == 0) if (response == 0)
throw new CustomException("数据加入失败"); throw new CustomException("数据加入失败");
var res = _PaymentService.GetFirst(s => s.PaymentGuid == response); var res = await _PaymentService.GetFirstAsync(s => s.PaymentGuid == response);
PayParams pay1 = new PayParams PayParams pay1 = new PayParams
{ {
@ -86,11 +93,10 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
OverTime = res.Create_time.AddMinutes(1) OverTime = res.Create_time.AddMinutes(1)
}; };
return new JsonResult(pay1); return SUCCESS(pay1);
} }
} }
/// <summary> /// <summary>