修改微信回调和支付

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

@ -19,15 +19,17 @@
</ItemGroup> </ItemGroup>
<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>
<ItemGroup> <ItemGroup>
<Folder Include="Service\WXPay\Dto\" /> <ProjectReference Include="..\GDZZ.Core\GDZZ.Core.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Senparc.Weixin.TenPayV3" Version="0.6.8.13" /> <Folder Include="Service\WXPay\Dto\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -214,6 +214,51 @@
跳转链接 跳转链接
</summary> </summary>
</member> </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"> <member name="T:GDZZ.Application.Entity.MiniResume">
<summary> <summary>
小程序招聘列表 小程序招聘列表
@ -314,32 +359,62 @@
地区级别 1-省、自治区、直辖市 2-地级市、地区、自治州、盟 3-市辖区、县级市、县 地区级别 1-省、自治区、直辖市 2-地级市、地区、自治州、盟 3-市辖区、县级市、县
</summary> </summary>
</member> </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>
</summary> </summary>
</member> </member>
<member name="T:GDZZ.Application.Enum.SystemConst"> <member name="T:GDZZ.Application.SystemConst">
<summary> <summary>
redis枚举配置 redis枚举配置
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_HISTORYLIST"> <member name="F:GDZZ.Application.SystemConst.LIVE_HISTORYLIST">
<summary> <summary>
聊天历史列表 聊天历史列表
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_MESSAGE"> <member name="F:GDZZ.Application.SystemConst.LIVE_MESSAGE">
<summary> <summary>
聊天详情 聊天详情
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Application.Enum.SystemConst.LIVE_UNREAD"> <member name="F:GDZZ.Application.SystemConst.LIVE_UNREAD">
<summary> <summary>
聊天详情 聊天详情
</summary> </summary>
</member> </member>
<member name="F:GDZZ.Application.Enum.SystemConst.MINI_USERINFO"> <member name="F:GDZZ.Application.SystemConst.MINI_USERINFO">
<summary> <summary>
小程序用户信息 小程序用户信息
</summary> </summary>
@ -421,21 +496,6 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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"> <member name="F:GDZZ.Application.Service.Auth.AuthService._oauthConfig">
<summary> <summary>
获取配置文件 获取配置文件
@ -453,19 +513,13 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </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>
微信支付 微信支付
</summary> </summary>
<param name="productId"></param> <param name="productId"></param>
<returns></returns> <returns></returns>
</member> </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"> <member name="T:GDZZ.Application.Service.Auth.IAuthService">
<summary> <summary>
业务权限控制 业务权限控制
@ -505,7 +559,12 @@
微信支付 微信支付
</summary> </summary>
</member> </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>
微信小程序支付 微信小程序支付
</summary> </summary>
@ -518,6 +577,11 @@
</summary> </summary>
<returns></returns> <returns></returns>
</member> </member>
<member name="P:GDZZ.Application.AuthUserInput.Discount">
<summary>
折扣
</summary>
</member>
<member name="P:GDZZ.Application.AuthUserOut.UserId"> <member name="P:GDZZ.Application.AuthUserOut.UserId">
<summary> <summary>
用户ID 用户ID

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

@ -14,11 +14,17 @@ using Senparc.CO2NET.Extensions;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Senparc.Weixin.TenPay.V3; using Senparc.Weixin.TenPay.V3;
using Senparc.Weixin.TenPay; using Senparc.Weixin.TenPay;
using Furion.DependencyInjection;
using Furion.DynamicApiController;
namespace GDZZ.Application.Service.WXPay 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<BaseUser> Baseuser; // wx用户仓储
private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储 private readonly SqlSugarRepository<SysUser> _sysUserRep; // 用户表仓储
private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储 private readonly SqlSugarRepository<SysTenant> _sysTenantRep; //租户仓储
@ -86,7 +92,7 @@ namespace GDZZ.Application.Service.WXPay
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
[AllowAnonymous] [AllowAnonymous]
[Route("api/v1/wxpay/{productId}")] [Route("api/v1/wxpay")]
public async Task<dynamic> WxPay(AuthUserInput authUserInput) public async Task<dynamic> WxPay(AuthUserInput authUserInput)
{ {
var recharge = await this.rechargeRep.InsertReturnEntityAsync(new MiniRecharge() var recharge = await this.rechargeRep.InsertReturnEntityAsync(new MiniRecharge()
@ -115,7 +121,7 @@ namespace GDZZ.Application.Service.WXPay
(int)authUserInput.Money * 100, (int)authUserInput.Money * 100,
"127.0.0.1", "127.0.0.1",
Config.SenparcWeixinSetting.TenPayV3_WxOpenTenpayNotify, TenPayV3Type.JSAPI, authUserInput.OpenID.ToString(), 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); //调用统一订单接口 UnifiedorderResult result = await TenPayV3.UnifiedorderAsync(xmlDataInfo); //调用统一订单接口
string packageStr = "prepay_id=" + result.prepay_id; string packageStr = "prepay_id=" + result.prepay_id;
@ -145,34 +151,25 @@ namespace GDZZ.Application.Service.WXPay
{ {
try try
{ {
_logger.LogError("NotifyUrl");
ResponseHandler resHandler = new ResponseHandler(_httpContextAccessor.HttpContext); ResponseHandler resHandler = new ResponseHandler(_httpContextAccessor.HttpContext);
string returnCode = resHandler.GetParameter("return_code"); string returnCode = resHandler.GetParameter("return_code");
resHandler.SetKey(TenPayKey); resHandler.SetKey(TenPayKey);
if (resHandler.IsTenpaySign() && returnCode.ToUpper() == "SUCCESS") if (resHandler.IsTenpaySign() && returnCode.ToUpper() == "SUCCESS")
{ {
//attach //attach
string paymentId = resHandler.GetParameter("attach"); var paymentId =long.Parse(resHandler.GetParameter("attach"));
//业务处理 //业务处理
PaymentRecordEntity paymentRecord = await _paymentRecordRepository.GetAsync(paymentId.ToLong()); var paytake = await this.payTakeRep.Where(x => x.OrderId == paymentId).SingleAsync();
if (paymentRecord.IsNotNull()) if (paytake.IsNullOrZero())
{ {
paymentRecord.PayStatus = (int)PayStatusEnum.Paying; paytake.PayStatus =(int)PayStatusEnum.Paying;
await _paymentRecordRepository.UpdateAsync(paymentRecord); this.payTakeRep.Update(paytake);
//order }
OrderEntity order = await _orderRepository.GetAsync(paymentRecord.OrderId); var recharge = await this.rechargeRep.Where(x=>x.Id == paymentId).SingleAsync();
if (order.IsNotNull()) if(recharge.IsNullOrZero())
{ {
order.OrderStatus = (int)OrderStatusEnum.Paying; recharge.Status = (int)RechargeEnum.Finish;
await _orderRepository.UpdateAsync(order); this.rechargeRep.Update(recharge);
//积分操作
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);
}
} }
} }
@ -184,7 +181,7 @@ namespace GDZZ.Application.Service.WXPay
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, ex.Message);
string xml = "<xml>" string xml = "<xml>"
+ "<return_code>FAIL</return_code>" + "<return_code>FAIL</return_code>"

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

Loading…
Cancel
Save