修改微信回调和支付

development
温天培 2 years ago
parent b2516f8014
commit 38a9bceb82

@ -19,15 +19,17 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GDZZ.Core\GDZZ.Core.csproj" />
<PackageReference Include="Senparc.Weixin.MP" Version="16.12.501.1" />
<PackageReference Include="Senparc.Weixin.TenPay" Version="1.7.501" />
<PackageReference Include="Senparc.Weixin.WxOpen" Version="3.11.501" />
</ItemGroup>
<ItemGroup>
<Folder Include="Service\WXPay\Dto\" />
<ProjectReference Include="..\GDZZ.Core\GDZZ.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Senparc.Weixin.TenPayV3" Version="0.6.8.13" />
<Folder Include="Service\WXPay\Dto\" />
</ItemGroup>
</Project>

@ -214,6 +214,51 @@
跳转链接
</summary>
</member>
<member name="T:GDZZ.Application.Entity.MiniPayTake">
<summary>
支付记录
</summary>
</member>
<member name="P:GDZZ.Application.Entity.MiniPayTake.OrderId">
<summary>
订单ID
</summary>
</member>
<member name="P:GDZZ.Application.Entity.MiniPayTake.PaySn">
<summary>
流水号
</summary>
</member>
<member name="P:GDZZ.Application.Entity.MiniPayTake.PayStatus">
<summary>
支付状态
</summary>
</member>
<member name="P:GDZZ.Application.Entity.MiniPayTake.PaymentMoney">
<summary>
金额
</summary>
</member>
<member name="T:GDZZ.Application.Entity.MiniRecharge">
<summary>
充值表
</summary>
</member>
<member name="P:GDZZ.Application.Entity.MiniRecharge.TotalPrice">
<summary>
总价格
</summary>
</member>
<member name="P:GDZZ.Application.Entity.MiniRecharge.PaymentMoney">
<summary>
支付金额
</summary>
</member>
<member name="P:GDZZ.Application.Entity.MiniRecharge.Status">
<summary>
充值状态
</summary>
</member>
<member name="T:GDZZ.Application.Entity.MiniResume">
<summary>
小程序招聘列表
@ -314,32 +359,62 @@
地区级别 1-省、自治区、直辖市 2-地级市、地区、自治州、盟 3-市辖区、县级市、县
</summary>
</member>
<member name="T:GDZZ.Application.Enum.SalaryEnum">
<member name="F:GDZZ.Application.PayStatusEnum.Cancel">
<summary>
已取消
</summary>
</member>
<member name="F:GDZZ.Application.PayStatusEnum.NotPaying">
<summary>
未成功
</summary>
</member>
<member name="F:GDZZ.Application.PayStatusEnum.Paying">
<summary>
已成功
</summary>
</member>
<member name="F:GDZZ.Application.RechargeEnum.Cancel">
<summary>
取消
</summary>
</member>
<member name="F:GDZZ.Application.RechargeEnum.NoFinis">
<summary>
未完成
</summary>
</member>
<member name="F:GDZZ.Application.RechargeEnum.Finish">
<summary>
完成
</summary>
</member>
<member name="T:GDZZ.Application.SalaryEnum">
<summary>
</summary>
</member>
<member name="T:GDZZ.Application.Enum.SystemConst">
<member name="T:GDZZ.Application.SystemConst">
<summary>
redis枚举配置
</summary>
</member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_HISTORYLIST">
<member name="F:GDZZ.Application.SystemConst.LIVE_HISTORYLIST">
<summary>
聊天历史列表
</summary>
</member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_MESSAGE">
<member name="F:GDZZ.Application.SystemConst.LIVE_MESSAGE">
<summary>
聊天详情
</summary>
</member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_UNREAD">
<member name="F:GDZZ.Application.SystemConst.LIVE_UNREAD">
<summary>
聊天详情
</summary>
</member>
<member name="F:GDZZ.Application.Enum.SystemConst.MINI_USERINFO">
<member name="F:GDZZ.Application.SystemConst.MINI_USERINFO">
<summary>
小程序用户信息
</summary>
@ -421,21 +496,6 @@
</summary>
<returns></returns>
</member>
<member name="T:GDZZ.Application.Help.TenPayHelper">
<summary>
微信支付帮助
</summary>
</member>
<member name="M:GDZZ.Application.Help.TenPayHelper.UniOrderAsync(System.String,System.String,System.Int32,System.Int64)">
<summary>
小程序统一支付
</summary>
<param name="openId"></param>
<param name="body"></param>
<param name="price">//单位:分</param>
<param name="paymentId"></param>
<returns></returns>
</member>
<member name="F:GDZZ.Application.Service.Auth.AuthService._oauthConfig">
<summary>
获取配置文件
@ -453,19 +513,13 @@
</summary>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.Auth.AuthService.WxPay(System.Int64)">
<member name="M:GDZZ.Application.Service.Auth.AuthService.WxPay(GDZZ.Application.AuthUserInput)">
<summary>
微信支付
</summary>
<param name="productId"></param>
<returns></returns>
</member>
<member name="M:GDZZ.Application.Service.Auth.AuthService.PayNotifyUrl">
<summary>
JS-SDK支付回调地址在下单接口中设置的 notify_url
</summary>
<returns></returns>
</member>
<member name="T:GDZZ.Application.Service.Auth.IAuthService">
<summary>
业务权限控制
@ -505,7 +559,12 @@
微信支付
</summary>
</member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.WxPay(System.Int64)">
<member name="F:GDZZ.Application.Service.WXPay.WXPayService._oauthConfig">
<summary>
获取配置文件
</summary>
</member>
<member name="M:GDZZ.Application.Service.WXPay.WXPayService.WxPay(GDZZ.Application.AuthUserInput)">
<summary>
微信小程序支付
</summary>
@ -518,6 +577,11 @@
</summary>
<returns></returns>
</member>
<member name="P:GDZZ.Application.AuthUserInput.Discount">
<summary>
折扣
</summary>
</member>
<member name="P:GDZZ.Application.AuthUserOut.UserId">
<summary>
用户ID

@ -1,8 +1,6 @@
using Furion;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
using GDZZ.Application.Entity;
using GDZZ.Application.Enum;
using GDZZ.Core;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;

@ -14,11 +14,17 @@ using Senparc.CO2NET.Extensions;
using Microsoft.AspNetCore.Http;
using Senparc.Weixin.TenPay.V3;
using Senparc.Weixin.TenPay;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
namespace GDZZ.Application.Service.WXPay
{
public class WXPayService:IWXPayService
[ApiDescriptionSettings("Application", Name = "WXPay", Order = 1)]
public class WXPayService: IWXPayService, IDynamicApiController, ITransient
{
public static readonly string TenPayKey = Config.SenparcWeixinSetting.TenPayV3_Key; //与微信小程序后台的AppId设置保持一致区分大小写。
private readonly SqlSugarRepository<BaseUser> Baseuser; // wx用户仓储
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储
@ -86,7 +92,7 @@ namespace GDZZ.Application.Service.WXPay
/// <returns></returns>
[HttpGet]
[AllowAnonymous]
[Route("api/v1/wxpay/{productId}")]
[Route("api/v1/wxpay")]
public async Task<dynamic> WxPay(AuthUserInput authUserInput)
{
var recharge = await this.rechargeRep.InsertReturnEntityAsync(new MiniRecharge()
@ -115,7 +121,7 @@ namespace GDZZ.Application.Service.WXPay
(int)authUserInput.Money * 100,
"127.0.0.1",
Config.SenparcWeixinSetting.TenPayV3_WxOpenTenpayNotify, TenPayV3Type.JSAPI, authUserInput.OpenID.ToString(),
Config.SenparcWeixinSetting.TenPayV3_Key, nonceStr, null, null, null, null, payTake.Id.ToString());
Config.SenparcWeixinSetting.TenPayV3_Key, nonceStr, null, null, null, null, payTake.OrderId.ToString());
UnifiedorderResult result = await TenPayV3.UnifiedorderAsync(xmlDataInfo); //调用统一订单接口
string packageStr = "prepay_id=" + result.prepay_id;
@ -145,34 +151,25 @@ namespace GDZZ.Application.Service.WXPay
{
try
{
_logger.LogError("NotifyUrl");
ResponseHandler resHandler = new ResponseHandler(_httpContextAccessor.HttpContext);
string returnCode = resHandler.GetParameter("return_code");
resHandler.SetKey(TenPayKey);
if (resHandler.IsTenpaySign() && returnCode.ToUpper() == "SUCCESS")
{
//attach
string paymentId = resHandler.GetParameter("attach");
var paymentId =long.Parse(resHandler.GetParameter("attach"));
//业务处理
PaymentRecordEntity paymentRecord = await _paymentRecordRepository.GetAsync(paymentId.ToLong());
if (paymentRecord.IsNotNull())
{
paymentRecord.PayStatus = (int)PayStatusEnum.Paying;
await _paymentRecordRepository.UpdateAsync(paymentRecord);
//order
OrderEntity order = await _orderRepository.GetAsync(paymentRecord.OrderId);
if (order.IsNotNull())
{
order.OrderStatus = (int)OrderStatusEnum.Paying;
await _orderRepository.UpdateAsync(order);
//积分操作
OrderDetailEntity orderDetail = await _orderDetailRepository.Select.Where(x => x.OrderId == order.Id)
.ToOneAsync();
//ProductInfoEntity productInfo = await _productInfoRepository.GetAsync(orderDetail.ProductId);
RechargeIntroEntity entity = await _rechargeIntroRepository.GetAsync(orderDetail.ProductId);
await _currencyService.AddCurrencyByCharge(order.UserId, order.Id,
entity.AllValue);
var paytake = await this.payTakeRep.Where(x => x.OrderId == paymentId).SingleAsync();
if (paytake.IsNullOrZero())
{
paytake.PayStatus =(int)PayStatusEnum.Paying;
this.payTakeRep.Update(paytake);
}
var recharge = await this.rechargeRep.Where(x=>x.Id == paymentId).SingleAsync();
if(recharge.IsNullOrZero())
{
recharge.Status = (int)RechargeEnum.Finish;
this.rechargeRep.Update(recharge);
}
}
@ -184,7 +181,7 @@ namespace GDZZ.Application.Service.WXPay
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
string xml = "<xml>"
+ "<return_code>FAIL</return_code>"

@ -15,10 +15,6 @@
<Content Include="GDZZ.Web.Core.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Senparc.Weixin.TenPayV3" Version="0.6.8.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GDZZ.Application\GDZZ.Application.csproj" />
<ProjectReference Include="..\GDZZ.FlowCenter\GDZZ.FlowCenter.csproj" />

Loading…
Cancel
Save