From 39cdde64a0b1ea454ce8e8563bf7faf41997ad50 Mon Sep 17 00:00:00 2001
From: lwh <2679599887@qq.com>
Date: Wed, 27 Sep 2023 22:44:48 +0800
Subject: [PATCH] =?UTF-8?q?feat=20=E8=B0=83=E5=BC=8F=E5=BE=AE=E4=BF=A1?=
=?UTF-8?q?=E6=94=AF=E4=BB=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs | 46 +++++
ARW.Model/Dto/Api/Pay/GoodsRequest.cs | 46 +++++
.../Business/Custom/Customers/CustomerDto.cs | 3 +-
ARW.Service/ARW.Service.csproj | 1 -
.../PayManage/PayServiceApi.cs | 167 ++++++++++++++++++
.../PayManage/IPayServiceApi.cs | 24 +++
.../Api/Wechat/WeChatLoginController.cs | 58 +++++-
.../Api/Wechat/WxPay/WxPayController.cs | 65 ++-----
ARW.WebApi/Program.cs | 6 +-
ARW.WebApi/appsettings.json | 27 +--
Infrastructure/WeChat/TenPay/Pay.cs | 30 +++-
Infrastructure/WeChat/TenPay/PayParameters.cs | 2 +-
12 files changed, 393 insertions(+), 82 deletions(-)
create mode 100644 ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs
create mode 100644 ARW.Model/Dto/Api/Pay/GoodsRequest.cs
create mode 100644 ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs
create mode 100644 ARW.Service/Api/IBusinessService/PayManage/IPayServiceApi.cs
diff --git a/ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs b/ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs
new file mode 100644
index 0000000..0d59678
--- /dev/null
+++ b/ARW.Model/Dto/Api/Pay/CommitPayDtoApi.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using ARW.Model.Models.Business.Carts;
+
+namespace ARW.Model.Dto.Api.Carts
+{
+
+ ///
+ /// 下单信息Dto对象Api
+ ///
+ /// @author lwh
+ /// @date 2023-09-24
+ ///
+ public class CommitPayDtoApi
+ {
+ ///
+ /// 客户guid
+ ///
+ public long CustomerGuid { get; set; }
+
+ ///
+ /// 支付类型
+ ///
+ public int type { get; set; }
+
+ ///
+ /// 小程序用户OpenId
+ ///
+ public string openId { get; set; }
+
+
+ ///
+ /// 待结算的商品集合
+ ///
+ public string goodsRequestList { get; set; }
+
+
+ ///
+ /// 发票信息
+ ///
+ public string invoiceRequest { get; set; }
+
+
+ }
+}
diff --git a/ARW.Model/Dto/Api/Pay/GoodsRequest.cs b/ARW.Model/Dto/Api/Pay/GoodsRequest.cs
new file mode 100644
index 0000000..3f4a5b4
--- /dev/null
+++ b/ARW.Model/Dto/Api/Pay/GoodsRequest.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using ARW.Model.Models.Business.Carts;
+
+namespace ARW.Model.Dto.Api.Carts
+{
+
+ ///
+ /// 待结算的商品对象Api
+ ///
+ /// @author lwh
+ /// @date 2023-09-24
+ ///
+ public class GoodsRequest
+ {
+ ///
+ /// 购物车ID
+ ///
+ public int CartId { get; set; }
+
+ ///
+ /// 购物车加入时间
+ ///
+ public DateTime JoinCartTime { get; set; }
+
+ ///
+ /// 小程序用户OpenId
+ ///
+ public string openId { get; set; }
+
+
+ ///
+ /// 待结算的商品集合
+ ///
+ public string goodsRequestList { get; set; }
+
+
+ ///
+ /// 发票信息
+ ///
+ public string invoiceRequest { get; set; }
+
+
+ }
+}
diff --git a/ARW.Model/Dto/Business/Custom/Customers/CustomerDto.cs b/ARW.Model/Dto/Business/Custom/Customers/CustomerDto.cs
index 55eb007..d0fbad0 100644
--- a/ARW.Model/Dto/Business/Custom/Customers/CustomerDto.cs
+++ b/ARW.Model/Dto/Business/Custom/Customers/CustomerDto.cs
@@ -102,13 +102,12 @@ namespace ARW.Model.Dto.Business.Custom.Customers
///
/// 手机号Code
///
- [Required(ErrorMessage = "Code不能为空")]
public string Code { get; set; }
///
/// OpenId
///
- public string CustomerXcxOpenid { get; set; }
+ public string CustomerXcxOpenidCode { get; set; }
}
diff --git a/ARW.Service/ARW.Service.csproj b/ARW.Service/ARW.Service.csproj
index 96fad4d..8e8e26e 100644
--- a/ARW.Service/ARW.Service.csproj
+++ b/ARW.Service/ARW.Service.csproj
@@ -18,7 +18,6 @@
-
diff --git a/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs b/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs
new file mode 100644
index 0000000..614361a
--- /dev/null
+++ b/ARW.Service/Api/BusinessService/PayManage/PayServiceApi.cs
@@ -0,0 +1,167 @@
+using Infrastructure.Attribute;
+using Microsoft.AspNetCore.Http;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ARW.Model;
+using ARW.Repository;
+using ARW.Repository.Business.ShopManager.Shops;
+using ARW.Service.Api.IBusinessService.ShopManager.Shops;
+using ARW.Model.Dto.Api.ShopManager.Shops;
+using ARW.Model.Models.Business.ShopManager.Shops;
+using ARW.Model.Vo.Api.ShopManager.Shops;
+using ARW.Model.Vo.Business.GoodsManager.GoodsCategorys;
+using ARW.Repository.Business.GoodsManager.GoodsCategorys;
+using ARW.Repository.Business.Custom.Customers;
+using ARW.Model.Models.Business.Custom.Customers;
+using ARW.Repository.Business.LogisticsManage.Deliverys;
+using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys;
+using ARW.Service.Business.IBusinessService.GoodsManager.Goodss;
+using ARW.Model.Models.Business.LogisticsManage.Deliverys;
+using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
+using ARW.Service.Business.IBusinessService.GoodsManager.GoodsServicess;
+using ARW.Model.Models.Business.GoodsManager.GoodsServicess;
+using ARW.Model.Models.Business.Payments;
+using Aliyun.OSS;
+using ARW.Service.Business.IBusinessService.Payments;
+using Infrastructure;
+using static Infrastructure.WeChat.TenPay.Pay;
+using Infrastructure.WeChat.TenPay;
+using System.Net.Http;
+using Senparc.CO2NET.HttpUtility;
+using ARW.Service.Api.IBusinessService.PayManage;
+using ARW.Repository.Business.Payments;
+using ARW.Repository.Business.OrderManage.Orders;
+
+namespace ARW.Service.Api.BusinessService.PaymentManage
+{
+ ///
+ /// 店铺接口实现类Api
+ ///
+ /// @author lwh
+ /// @date 2023-06-12
+ ///
+ [AppService(ServiceType = typeof(IShopServiceApi), ServiceLifetime = LifeTime.Transient)]
+ public class PayServiceApi : BaseService, IPayServiceApi
+ {
+ private readonly ShopRepository _ShopRepository;
+ private readonly GoodsCategoryRepository _GoodsCategoryRepository;
+ private readonly CustomerRepository _CustomerRepository;
+ private readonly OrderRepository _OrderRepository;
+ private readonly PaymentRepository _PaymentRepository;
+ private readonly SenparcHttpClient _httpClient;
+
+
+ public PayServiceApi(ShopRepository ShopRepository, GoodsCategoryRepository goodsCategoryRepository, CustomerRepository customerRepository)
+ {
+ this._ShopRepository = ShopRepository;
+ _GoodsCategoryRepository = goodsCategoryRepository;
+ _CustomerRepository = customerRepository;
+ }
+
+ #region Api接口代码
+
+
+ public async Task HandelPrePay(PayDto parm)
+ {
+ // 获取金额
+ var price = 1;//单位:分
+ // 生成订单号
+ var orderNo = Common.Common.CreateNoQuery();
+ // 调用统一下单(接口)
+ Pay pay = new Pay(_httpClient);
+ var payEntity = await pay.PrePay(parm.OpenId, orderNo, parm.PayType, price);
+
+
+ if (payEntity == null)
+ {
+ throw new CustomException("下单失败!");
+ }
+ else
+ {
+ #region 业务处理
+
+ /* 添加订单流水 */
+ var paymentGuid = await AddPayment(parm.UserId, orderNo, parm.PayType, parm.BeforeMoney, parm.Money);
+
+
+
+ #endregion
+
+ // 返回拼接好的支付调起信息
+ var res = await _PaymentRepository.GetFirstAsync(s => s.PaymentGuid == paymentGuid);
+ PayParams payRes = new()
+ {
+ jsApiUiPackage = payEntity,
+ outTradeNo = orderNo,
+ CreateTime = res.Create_time,
+ OverTime = res.Create_time.AddMinutes(1)
+ };
+ return payRes;
+
+ }
+ }
+
+
+ #region 业务方法调用
+ ///
+ /// 添加订单流水
+ ///
+ /// 客户id
+ /// 订单号
+ /// 支付类型
+ /// 核销前价格
+ /// 核销后价格/操作金额
+ ///
+ ///
+ public async Task AddPayment(long userId, string orderNo, int payType, decimal beforeMoney, decimal money)
+ {
+ // 添加订单流水
+ Payment payment = new Payment
+ {
+ CustomerGuid = userId,
+ PaymentNumber = orderNo,
+ PaymentBuytype = payType,
+ PaymentBeforeMoney = beforeMoney,
+ PaymentMoney = money,
+ PaymentStatus = 1
+ };
+ var response = await _PaymentRepository.InsertReturnSnowflakeIdAsync(payment);
+ if (response == 0)
+ throw new CustomException("订单流水数据加入失败");
+
+ return response;
+ }
+
+
+ // 添加业务订单
+ public async Task AddOrder(long userId, string orderNo, int payType, decimal beforeMoney, decimal money)
+ {
+ Payment payment = new Payment
+ {
+ CustomerGuid = userId,
+ PaymentNumber = orderNo,
+ PaymentBuytype = payType,
+ PaymentBeforeMoney = beforeMoney,
+ PaymentMoney = money,
+ PaymentStatus = 1
+ };
+ var response = await _PaymentRepository.InsertReturnSnowflakeIdAsync(payment);
+ if (response == 0)
+ throw new CustomException("订单流水数据加入失败");
+
+ return response;
+ }
+
+
+
+ #endregion
+
+
+ #endregion
+
+ }
+}
diff --git a/ARW.Service/Api/IBusinessService/PayManage/IPayServiceApi.cs b/ARW.Service/Api/IBusinessService/PayManage/IPayServiceApi.cs
new file mode 100644
index 0000000..993c75d
--- /dev/null
+++ b/ARW.Service/Api/IBusinessService/PayManage/IPayServiceApi.cs
@@ -0,0 +1,24 @@
+using System.Threading.Tasks;
+using ARW.Model.Models.Business.Payments;
+using static Infrastructure.WeChat.TenPay.Pay;
+
+namespace ARW.Service.Api.IBusinessService.PayManage
+{
+ ///
+ /// 微信支付类Api
+ ///
+ /// @author lwh
+ /// @date 2023-09-27
+ ///
+ public interface IPayServiceApi : IBaseService
+ {
+ ///
+ /// 统一下单的业务处理
+ ///
+ ///
+ ///
+ Task HandelPrePay(PayDto parm);
+
+
+ }
+}
diff --git a/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs b/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs
index fe14bed..7f917e7 100644
--- a/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs
+++ b/ARW.WebApi/Controllers/Api/Wechat/WeChatLoginController.cs
@@ -16,6 +16,8 @@ using ARW.Model.Models.Business.Custom.Customers;
using ARW.Service.System;
using Infrastructure.Attribute;
using ARW.Service.Business.IBusinessService.Custom.Customers;
+using Newtonsoft.Json.Linq;
+using Aliyun.OSS;
namespace ARW.WebApi.Controllers.Api.Wechat
{
@@ -58,11 +60,17 @@ namespace ARW.WebApi.Controllers.Api.Wechat
if (user == null)
{
+ string appId = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_AppId");
+ string appSecret = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_AppSecret");
+ string openid = await GetOpenIDAsync(parm.CustomerXcxOpenidCode, appId, appSecret);
+
+ // 客户默认头像
addModal.CustomerAvatar = "https://cdn-we-retail.ym.tencent.com/miniapp/usercenter/icon-user-center-avatar@2x.png";
addModal.CustomerNickname = "用户" + addModal.CustomerMobilePhoneNumber.Substring(addModal.CustomerMobilePhoneNumber.Length - 4); ;
addModal.CustomerGender = 1;
addModal.CustomerType = 1;
addModal.CustomerLastLoginTime = DateTime.Now;
+ addModal.CustomerXcxOpenid = openid;
var response = await _customerService.InsertReturnSnowflakeIdAsync(addModal);
if (response == 0)
{
@@ -101,7 +109,7 @@ namespace ARW.WebApi.Controllers.Api.Wechat
///
[Log(Title = "退出登录")]
[HttpPost("logout")]
- public IActionResult LogOut()
+ public async Task LogOut()
{
var userid = HttpContext.GetUId();
var name = HttpContext.GetName();
@@ -112,6 +120,21 @@ namespace ARW.WebApi.Controllers.Api.Wechat
+ ///
+ /// 获取OpenId
+ ///
+ ///
+ [Log(Title = "获取OpenId")]
+ [HttpPost("getOpenId")]
+ public async Task GetOpenId([FromBody] CustomerLoginDto parm)
+ {
+ string appId = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_AppId");
+ string appSecret = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_AppSecret");
+ string openid = await GetOpenIDAsync(parm.Code, appId, appSecret);
+ return SUCCESS(openid);
+ }
+
+
///
/// 获取用户手机号
@@ -189,5 +212,38 @@ namespace ARW.WebApi.Controllers.Api.Wechat
+ ///
+ /// 获取OpenId
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task GetOpenIDAsync(string code, string appId, string appSecret)
+ {
+ string url = $"https://api.weixin.qq.com/sns/jscode2session?appid={appId}&secret={appSecret}&js_code={code}&grant_type=authorization_code";
+
+ using (HttpClient client = new HttpClient())
+ {
+ HttpResponseMessage response = await client.GetAsync(url);
+ response.EnsureSuccessStatusCode();
+
+ string responseBody = await response.Content.ReadAsStringAsync();
+ JObject json = JObject.Parse(responseBody);
+
+ if (json.ContainsKey("openid"))
+ {
+ string openid = json["openid"].ToString();
+ return openid;
+ }
+ else
+ {
+ throw new Exception("无法获取OpenID:" + json);
+ }
+ }
+ }
+
+
}
}
diff --git a/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs b/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs
index c403902..f4543bc 100644
--- a/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs
+++ b/ARW.WebApi/Controllers/Api/Wechat/WxPay/WxPayController.cs
@@ -11,6 +11,8 @@ using ARW.Admin.WebApi.Framework;
using Senparc.Weixin.Open.WxOpenAPIs;
using Senparc.Weixin.WxOpen.AdvancedAPIs.WxApp;
using ARW.Service.Business.IBusinessService.Custom.Customers;
+using ARW.Service.Api.IBusinessService.PayManage;
+using ARW.Service.Api.BusinessService.PaymentManage;
namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
{
@@ -23,21 +25,21 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
{
private readonly ICustomerService _CustomerService;
- private readonly IPaymentService _PaymentService;
+ private readonly IPayServiceApi _PayServiceApi;
private readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private readonly SenparcHttpClient _httpClient;
- public WxPayController(ICustomerService customerService, SenparcHttpClient httpClient, IPaymentService paymentService)
+ public WxPayController(ICustomerService customerService, SenparcHttpClient httpClient, IPayServiceApi payServiceApi)
{
_CustomerService = customerService;
_httpClient = httpClient;
- _PaymentService = paymentService;
+ _PayServiceApi = payServiceApi;
}
#region 微信支付
///
- /// 微信支付
+ /// 微信支付(统一下单)
///
///
///
@@ -46,59 +48,16 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
{
if (parm == null) { throw new CustomException("请求参数错误"); }
- Pay pay = new Pay(_httpClient);
-
- // 获取金额
- 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;
- //}
+ parm.UserId = user.UserId;
- var orderNo = Common.Common.CreateNoQuery();
- var payEntity = await pay.PrePay(0, parm.openId, orderNo, parm.payType, price);
-
- if (payEntity == null)
- {
- throw new CustomException("下单失败!");
- }
- else
- {
-
- var userId = 1600478763014033408;
-
- Payment payment = new Payment
- {
- //PaymentBusinessGuid = parm.ProductGuid,
- PaymentNumber = orderNo,
- PaymentBuytype = parm.payType,
- CustomerGuid = userId,
- PaymentStatus = 1
- };
-
- var response = await _PaymentService.InsertReturnSnowflakeIdAsync(payment);
- if (response == 0)
- throw new CustomException("数据加入失败");
-
- var res = await _PaymentService.GetFirstAsync(s => s.PaymentGuid == response);
-
- PayParams pay1 = new PayParams
- {
- jsApiUiPackage = payEntity,
- outTradeNo = orderNo,
- CreateTime = res.Create_time,
- OverTime = res.Create_time.AddMinutes(1)
- };
-
- return SUCCESS(pay1);
-
- }
+ /* 统一下单的业务处理 */
+ var payRes = await _PayServiceApi.HandelPrePay(parm);
+ return SUCCESS(payRes);
}
+
///
/// 微信支付回调
///
@@ -116,7 +75,7 @@ namespace ARW.WebApi.Controllers.Api.Wechat.WxPay
{
logger.Info("微信支付回调之业务:", res.trade_state);
// 业务
- var respones = _PaymentService.UpdateAsync(f => new Payment
+ var respones = _PayServiceApi.UpdateAsync(f => new Payment
{
PaymentWeixinNumber = res.transaction_id,
PaymentBeforeMoney = res.amount.total,
diff --git a/ARW.WebApi/Program.cs b/ARW.WebApi/Program.cs
index 3427d7c..795f096 100644
--- a/ARW.WebApi/Program.cs
+++ b/ARW.WebApi/Program.cs
@@ -48,12 +48,12 @@ var senparcWeixinSetting = builder.Services.BuildServiceProvider().GetRequiredSe
register.UseSenparcWeixin(senparcWeixinSetting.Value, senparcSetting.Value);//微信全局注册,必须!
// 小程序
-await AccessTokenContainer.RegisterAsync("wx8b03fffabbbfe804", "ef5845d854c1111cd842bb54481be0c1");
+await AccessTokenContainer.RegisterAsync("wx8b03fffabbbfe804", "233a99954667ccfd6697dd3d31743fde");
// 公众号
-await AccessTokenContainer.RegisterAsync("wxa515d1bd73d06294", "c97d2e3ded5f6a7c86a4bbee3f1ab3ab");
+await AccessTokenContainer.RegisterAsync("wxa515d1bd73d06294", "9d0ba50302d9ae27916314605b9aa04e");
// 添加WeChat单例服务
-builder.Services.AddSingleton(new WeChatLogin("wxf3f7f286bfbb7dfa", "c2a02e478d9f0683d8dafec646c3d2ca"));
+builder.Services.AddSingleton(new WeChatLogin("wx8b03fffabbbfe804", "233a99954667ccfd6697dd3d31743fde"));
//配置跨域
builder.Services.AddCors(c =>
diff --git a/ARW.WebApi/appsettings.json b/ARW.WebApi/appsettings.json
index ad38b06..1e12804 100644
--- a/ARW.WebApi/appsettings.json
+++ b/ARW.WebApi/appsettings.json
@@ -7,8 +7,8 @@
}
},
"ConnectionStrings": {
- //"conn_db": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=tKFJjWwL2kxMYtJK;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
- "conn_db": "server=127.0.0.1;Database=shop_template;Uid=root;Pwd=root;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
+ "conn_db": "server=47.242.159.172;Database=shop_template;Uid=shop_template;Pwd=tKFJjWwL2kxMYtJK;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
+ //"conn_db": "server=127.0.0.1;Database=shop_template;Uid=root;Pwd=root;SslMode=none;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=true;",
"conn_db_type": "8" //数据库类型 MySql = 0, SqlServer = 1
},
"urls": "http://localhost:8888", //项目启动url,如果改动端口前端对应devServer也需要进行修改
@@ -132,26 +132,27 @@
//以下不使用的参数可以删除,key 修改后将会失效
//公众号
- "Token": "63_I_BSEoa_qwlHgGSVxLmyNylHJ11ejzc9_WiWPRt64sDetCJe9CLU9YwVbL-VoAjqCH0Pg5QElGL4p_B2z63SKG9jj-dRPp-BD1gpiaAe6uxrwocfFeX4JXepvgcRAGhACAHQW",
+ "Token": "",
"EncodingAESKey": "", //公众号解密秘钥
"WeixinAppId": "wxa515d1bd73d06294", //公众号AppId
- "WeixinAppSecret": "c97d2e3ded5f6a7c86a4bbee3f1ab3ab", //公众号秘钥
+ "WeixinAppSecret": "9d0ba50302d9ae27916314605b9aa04e", //公众号秘钥
//微信支付V3
"TenPayV3_AppId": "wx8b03fffabbbfe804", // 小程序AppId
- "TenPayV3_AppSecret": "ef5845d854c1111cd842bb54481be0c1", // 小程序AppSecret
+ "TenPayV3_AppSecret": "233a99954667ccfd6697dd3d31743fde", // 小程序AppSecret
"TenPayV3_SubAppId": "", //子小程序AppId,没有可留空
"TenPayV3_SubAppSecret": "", //子小程序AppSecret,没有可留空
- "TenPayV3_MchId": "1626418383", //商户号
+ "TenPayV3_MchName": "阿尔文电商", //商户名称
+ "TenPayV3_MchId": "1645875842", //商户号
"TenPayV3_SubMchId": "", //子商户,没有可留空
"TenPayV3_Key": "", // (旧) Key
- "TenPayV3_CertPath": "C:\\Users\\PC\\Desktop\\ARW2.0\\ARW-net\\ARW.WebApi\\WeChat\\certificate", //支付证书物理路径,如:D:\\cert\\apiclient_cert.p12
- "TenPayV3_CertSecret": "1626418383", //支付证书密码(原始密码和 MchId 相同)
- "TenPayV3_TenpayNotify": "http://aerwen.net/prod-api/api/WxPay/Notify", // 回调方法
- "TenPayV3_WxOpenNotify": "http://aerwen.net/prod-api/api/WxPay/Notify", // 小程序回调方法
- "TenPayV3_PrivateKey": "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDfVjagN3LpB6EdUx1YQvKlIsVhJyLkpezWRd8Sq7G65i0Z9YnhzJ4LA5YCgfdzwywrFjy/Dps60YYbS8vfVvuyrobP5Y143ID9i2nB8oZOBZERJKHwc3sdYKL3upOQUx+2k+Sd15iWlUCGSdsU8KE/k6aprvAkKjhdGRdQwgEd8KycOTjGIPYM1MoHcAI7JTjelEoggcCCxKHRHX3ASGw2WZbj0xAEAWmxBGQ9+KPrFtg4rqFB69sk/V9cb5lF/hy5sJf44FYS/UowH9xIrf0niC5j5ROSAbPI4nCa/N6LpNFQzLHQ0aOJWdStjZwdU3iqo5WMtXruPwv+dr6Fe8DBAgMBAAECggEARUwr8PSjjBjY7g9vCIblYUXztpx9IDM31JijidiKcjKfhfGBEfX6h/JZ5ndLP7ksiEYDHUk78zk2Alw3axpDSQMMQ4+3oOvSfll2vD4zXBwwEgCq2sAKUGg+yN00klCog29KPYu7BeZTuhdKiinL7r0ytm3Yh3AuQvzZFi7MR+xkK6wwcGlMdnK3WkwOsAb4g77xg0Iek4TC150RK5jLbAOW/9/jaz/QSjJZzgbqpUNMJaeXjT0rUx8cGOSXpRxziSJNFGcX5BwozcdIhp3PHx/VugfliPcfr7HP6FVMLX3jhNAKE32UQyaq/2bCSy9mnbaRubho6jDur5vp+vBVAQKBgQD5wfjFUavsEBsbt0DjXw6D2Qjj67U9ccgqQjzUPFbeYb+awmXOPCqb5as1dkaZ71f+whv7nWKL+P6f3TIsM1Pz8nL/lm0LxjLO50n/JxjIR6GGQ/vCGtJb84c+gavJ49y3SjsMAVWTvTHZYUj/mYYZ7Urnuz0nb1hJqlahWb1VEQKBgQDk6zE0QzL/fbYYc7fQQ8O2ddvnSuwwNZDjasXpuWXAYNTqGNrhIdLBiEpj9uIO3Z7UhCjoh+mFWhDcbUQ+G0l6rQHE3Z7IMFBOHZDCGoQgWuwsMuz8tGXIa5nrdZ4ep2DB4VxsGGFJqRiopj7f5IDRbNlifmr2CfzxVGHcDJTwsQKBgCdvhURCvQ6tDFq3+LruC3CuGEVEtn1ZNe3WP5yTWnQKoyJgh4qk3WV4QixS3Jr5u78yDxEPrLvFOQ8s8fsgr6TZJ2dL7TPqu6MHyhtLpRIanVqB6YKgkY6LSVOJTgK2w+b9BY3DuCt3uCNGxSv2pcH6QdWNLv7HCf23s64OaWLBAoGAF/OHtWkmh9bWW56X5+F/M7MHLB8JsU2ZeEHurTKps8Qt4sRw+kc4rukcp3LoWhfUC3Y8dX/q7fnrc7S3BCyEtqItYjSx7U4oyNONFtIBawU4WrOFWjdhwuOHOjyXK6vlksOKkQDIBRX9L4Adaf2VgNP7trN1a4LGBVYH2ycx2jECgYBM/Ge2QKkRXaVkfmbnJ6ZPg0KIAZJ7tL7GxAICVeqZ4OeqyQP9cFvaJjdvGnE2B0xo2ApZhLgzno+pZRd4tnV3IHXBeHyMhAGZ5I4r4shwzF4U84FZk7bg/CeyNyyv7Ljflw7erlDMDCr/xvloerwzwggxHc35JUCiT5FI02jWhQ==", //(新)证书私钥
- "TenPayV3_SerialNumber": "1BD546C97BFA3BF71672C6915AC4E9E1EAE9C90E", //(新)证书序列号
- "TenPayV3_ApiV3Key": "CHOFVQJOXBJEWZJEJKUWTHUBOSVQBRIW" //(新)APIv3 密钥
+ "TenPayV3_CertPath": "D:\\.Net\\Aerwen\\shop_template\\wecaht_information\\cert\\apiclient_cert.p12", //支付证书物理路径,如:D:\\cert\\apiclient_cert.p12
+ "TenPayV3_CertSecret": "1645875842", //支付证书密码(原始密码和 MchId 相同)
+ "TenPayV3_TenpayNotify": "http://shop.api.aerwen.net/api/WxPay/Notify", // 回调方法
+ "TenPayV3_WxOpenNotify": "http://shop.api.aerwen.net/api/WxPay/Notify", // 小程序回调方法
+ "TenPayV3_PrivateKey": "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC7wzMe6ZBFh+Zsa4cZf0s2dfMfDlmbGD7KEly6l1aK42YsR+5VpFcB+TJH3pVAsRO0X//mMrQXDqlAzha8PgMKa5PuSc6LevfUaX6nHf454AwaTXc3CHdhClNbrHdaAqh+LqxvrAJwZydrBGwI9IgW73Ze0oFWiNGt7aLhnH30CxC1vmHkq/BrTsV7qUVenjJmmxdSR3SwtRI1IdeWOdTXasR4LU5hROvnVs/HIjzQTp+J3XMwf4zaOZgWTqz+23KZhuCVE9ZXe+quJCgWvuT+O8Do9SyG5iAZMlLg6nZYGy3L6cke/Am3KZDD9cUwQI+uS3z3gF0TYiG8fQVoJl25AgMBAAECggEBAJ+9diR6eO9uqy7aXFno3kg7GNf3EWzNt72a2aE1V79Zr3dEyxO5ePyI0aorR7d971GpysBBqs1i/8POkbEc4OFgnL5BtKMdvvLLvaDX942tex51gVMktMuuSTTZCcFeOZMAiluHb5vJZtO5M2B7CbzZhU8usDK6vAjI/6YJyW5w9cp9JLQwRGHe4P9aSbqlCE0swMDzdpGCvXB6GTSlATQtNkjnaPeZpv1HtOgJk72HNV56BY55zsYSrhTA+7Pd5jKCGPdQry84RkBnbTzM/BlFBfR5LXzwCH/cRBz3cgdhoklxT730oBnbaHDERzan4GbDY7pKqF6bIM8mJou2AbECgYEA6RikdNXFmbmuJ8GDgt/wtuEAsEQLovoCw2KFGGMk1Uu5rZJ908OKJ0aTzMdTXQEz4+QBqstJNzg2VA1blnTw/06l0RjprcJ0Ibq9BB0vCfFjR2R3OhiZlq/KjFHIeJ14+qhKKQlZ+inCL4G5VGRcR2MuHCmq3Msa6wAkCBMp7vsCgYEAzjY4p9TldFg+qJIv2x53Gz0SbqIA3g0L08tSvlxI2sWkluWMk1KVU6pMsInL/eogEGqYV/n1kjjTVJp75G7fxThdeO9BUxlpwmjTYXGlMUkLGB3/LXw//IKi6dWDJoZUW60z/yYfsPnM9/eYLXRF4dsHlb6nJvISXCLjZ4OdN9sCgYAPhJd2O8ES8dyZQvXJYbU5x5LvKSiJKhHDBi0MKZWLKaZr2sPLtEnfQYCXcnGnUGwu8L/3qd7u8SwUvmrpglGE/axmVj1AVyC6Gh95RaQbClnsp9CUKo0XDg7y9oLdHMawEUIWp0u5LsyBsyYuaxwFmKG6OD/qwQ7CtFixvOzevwKBgHZC0FEoHoOPzDd+xyVCHoqnhred/yNZlgvb0lNLt5iHurGzaeBffzYhN6QTEsNHDyZ7C22A853tKv2dLyo9j+WaQrkFdZBDxcxxs7BxrYxLWKp3IY4jcMrO3MF/6pwgc6az+Vr9sTUcvbkD7Ok8gotZwsrVMSV7tJ3UgFgwOez7AoGAB2TKMM7QrVfotvDtcDR689NvJ55RGWiKZv/BzsT5zE7LJH+0jwWl1jy24I1DSGgsPmLAt29+VLfgwfAyCz5ytMgvx6iu+cnsyriK3/SNdFZtymUegkIdzSONXslVZYqFsBKQz/M+BmgPvnQao/e8r8eWpIBZLBr93ud+LpDmEio=", //(新)证书私钥
+ "TenPayV3_SerialNumber": "6C34D380F6B239BEE351D9EB4AD2655FF38D4AAA", //(新)证书序列号
+ "TenPayV3_ApiV3Key": "3aF7gH1jKmN5pR8tU2xW4z7C9vY0BqXr" //(新)APIv3 密钥
}
}
diff --git a/Infrastructure/WeChat/TenPay/Pay.cs b/Infrastructure/WeChat/TenPay/Pay.cs
index 03b98fc..bc9ad0e 100644
--- a/Infrastructure/WeChat/TenPay/Pay.cs
+++ b/Infrastructure/WeChat/TenPay/Pay.cs
@@ -57,6 +57,7 @@ namespace Infrastructure.WeChat.TenPay
var TenPayV3_AppId = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_AppId");
var TenPayV3_AppSecret = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_AppSecret");
var TenPayV3_MchId = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_MchId");
+ var TenPayV3_MchName = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_MchName");
var TenPayV3_Key = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_Key");
var TenPayV3_CertPath = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_CertPath");
var TenPayV3_CertSecret = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_CertPath");
@@ -68,7 +69,7 @@ namespace Infrastructure.WeChat.TenPay
var tenPayV3Info = new TenPayV3Info(TenPayV3_AppId, TenPayV3_AppSecret, TenPayV3_MchId, TenPayV3_Key, TenPayV3_CertPath, TenPayV3_CertSecret,TenPayV3_TenpayNotify, TenPayV3_WxOpenNotify,TenPayV3_PrivateKey, TenPayV3_SerialNumber, TenPayV3_ApiV3Key);
- TenPayV3InfoCollection.Register(tenPayV3Info, "测试");
+ TenPayV3InfoCollection.Register(tenPayV3Info, TenPayV3_MchName);
this.TenPayV3Info = tenPayV3Info;
_tenpayV3Setting = Senparc.Weixin.Config.SenparcWeixinSetting.TenpayV3Setting;
@@ -77,12 +78,13 @@ namespace Infrastructure.WeChat.TenPay
}
- public async Task PrePay(long productGuid, string openId,string orderNo,int type,int price)
+ public async Task PrePay(string openId,string orderNo,int type,int price)
{
string sp_billno = orderNo;//out_trade_no
//调用下单接口下单
- var name = "测试";
+ var TenPayV3_MchName = AppSettings.GetConfig("SenparcWeixinSetting:TenPayV3_MchName");
+ var name = TenPayV3_MchName;
try
{
@@ -94,7 +96,7 @@ namespace Infrastructure.WeChat.TenPay
TransactionsRequestData jsApiRequestData = new(
appId,
TenPayV3Info.MchId,
- name + " - 微信支付 V3",
+ name,
sp_billno,
new TenpayDateTime(DateTime.Now.AddMinutes(1), false),
null,
@@ -374,19 +376,31 @@ namespace Infrastructure.WeChat.TenPay
public class PayDto
{
///
- /// 产品Guid
+ /// 客户Guid
///
- public long ProductGuid { get; set; }
+ public long UserId { get; set; }
///
/// 支付类型
///
- public int type { get; set; }
+ public int PayType { get; set; }
///
/// 小程序用户OpenId
///
- public string openId { get; set; }
+ public string OpenId { get; set; }
+
+
+ ///
+ /// 核销前价格
+ ///
+ public decimal BeforeMoney { get; set; }
+
+
+ ///
+ /// 核销后价格/操作金额
+ ///
+ public decimal Money { get; set; }
}
///
diff --git a/Infrastructure/WeChat/TenPay/PayParameters.cs b/Infrastructure/WeChat/TenPay/PayParameters.cs
index 22a24cb..7f8df0e 100644
--- a/Infrastructure/WeChat/TenPay/PayParameters.cs
+++ b/Infrastructure/WeChat/TenPay/PayParameters.cs
@@ -59,7 +59,7 @@ namespace Infrastructure.WeChat.TenPay
///
/// AppSecret是APPID对应的接口密码,用于获取接口调用凭证时使用
///
- public string secret { get { return "0666e1b9071ce6baacca2adf5945319d"; } }
+ public string secret { get { return "233a99954667ccfd6697dd3d31743fde"; } }
///
/// 是否需要分账 Y-是,需要分账 N-否,不分账 字母要求大写,不传默认不分账
///