diff --git a/CoreCms.Net.Configuration/GlobalEnumVars.cs b/CoreCms.Net.Configuration/GlobalEnumVars.cs index f0fe2fc..a5fd934 100644 --- a/CoreCms.Net.Configuration/GlobalEnumVars.cs +++ b/CoreCms.Net.Configuration/GlobalEnumVars.cs @@ -971,6 +971,9 @@ namespace CoreCms.Net.Configuration /// [Description("服务订单")] ServiceOrder = 5, + + [Description("鸽子费")] + GeZiFei = 6, } /// /// 付款单状态【对应CoreCmsBillPayments.status字段】 diff --git a/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs b/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs index 10b4f72..d892ddd 100644 --- a/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs +++ b/CoreCms.Net.Services/Bill/CoreCmsBillPaymentsServices.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading.Tasks; + using CoreCms.Net.Configuration; using CoreCms.Net.IRepository; using CoreCms.Net.IRepository.UnitOfWork; @@ -26,13 +27,17 @@ using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Extensions; using CoreCms.Net.Utility.Helper; using CoreCms.Net.WeChat.Service.Options; + using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; + using Newtonsoft.Json; using Newtonsoft.Json.Linq; + using NLog; + using SqlSugar; @@ -227,6 +232,22 @@ namespace CoreCms.Net.Services jm.status = true; jm.data = dto; } + else if (type == (int)GlobalEnumVars.BillPaymentsType.GeZiFei) + { + dto.money = 10; + if (@params != null && @params.ContainsKey("money")) + { + dto.money = @params["money"].ObjectToDecimal(0); //充值金额 + } + + dto.rel.Add(new rel() + { + sourceId = orderId, + money = dto.money + }); + jm.status = true; + jm.data = dto; + } else if (false) { @@ -382,6 +403,7 @@ namespace CoreCms.Net.Services jm.data = dto; } + else if (false) { //todo 其他业务逻辑 @@ -466,6 +488,7 @@ namespace CoreCms.Net.Services if (paymentCode == GlobalEnumVars.PaymentsTypes.wechatpay.ToString()) { jm = await weChatPayServices.PubPay(billPayments); + } //支付宝支付 else if (paymentCode == GlobalEnumVars.PaymentsTypes.alipay.ToString()) @@ -561,7 +584,7 @@ namespace CoreCms.Net.Services var paymentRelData = new CheckPayDTO(); var sourceStrArr = sourceStr.Split(","); - if (sourceStrArr.Length > 0) + if (!string.IsNullOrEmpty(sourceStr) && sourceStrArr.Length > 0) { var paymentRel = await BatchFormatPaymentRel(sourceStrArr, type, @params); if (paymentRel.status == false) @@ -750,6 +773,9 @@ namespace CoreCms.Net.Services break; case (int)GlobalEnumVars.BillPaymentsType.ServiceOrder: break; + case (int)GlobalEnumVars.BillPaymentsType.GeZiFei: + res = "鸽子费"; + break; default: break; } diff --git a/CoreCms.Net.Services/Pay/WeChatPayServices.cs b/CoreCms.Net.Services/Pay/WeChatPayServices.cs index c586cea..c5d9264 100644 --- a/CoreCms.Net.Services/Pay/WeChatPayServices.cs +++ b/CoreCms.Net.Services/Pay/WeChatPayServices.cs @@ -10,6 +10,7 @@ using System; using System.Threading.Tasks; + using CoreCms.Net.Auth.HttpContextUser; using CoreCms.Net.Configuration; using CoreCms.Net.IRepository; @@ -18,10 +19,13 @@ using CoreCms.Net.IServices; using CoreCms.Net.Model.Entities; using CoreCms.Net.Model.ViewModels.UI; using CoreCms.Net.Utility.Extensions; + using Essensoft.Paylink.WeChatPay; using Essensoft.Paylink.WeChatPay.V2; using Essensoft.Paylink.WeChatPay.V2.Request; + using Microsoft.Extensions.Options; + using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -129,7 +133,7 @@ namespace CoreCms.Net.Services jm.status = true; jm.msg = "支付成功"; jm.data = parameter; - jm.otherData = response; + //jm.otherData = response; } else { diff --git a/CoreCms.Net.Web.Admin/Doc.xml b/CoreCms.Net.Web.Admin/Doc.xml index e5ba0b8..5092051 100644 --- a/CoreCms.Net.Web.Admin/Doc.xml +++ b/CoreCms.Net.Web.Admin/Doc.xml @@ -5528,7 +5528,7 @@ 微信小程序消息模板 - + 构造函数 diff --git a/CoreCms.Net.Web.Admin/WxPayCert/apiclient_cert.p12 b/CoreCms.Net.Web.Admin/WxPayCert/apiclient_cert.p12 new file mode 100644 index 0000000..ff0d0ac Binary files /dev/null and b/CoreCms.Net.Web.Admin/WxPayCert/apiclient_cert.p12 differ diff --git a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs index f5aa1a1..224eea0 100644 --- a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs +++ b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs @@ -51,6 +51,7 @@ using System.Text.RegularExpressions; using CoreCms.Net.Model.ViewModels.User; using CoreCms.Net.Repository.UnitOfWork; using CoreCms.Net.IRepository.UnitOfWork; +using Newtonsoft.Json.Linq; namespace CoreCms.Net.Web.WebApi.Controllers { @@ -1266,6 +1267,43 @@ namespace CoreCms.Net.Web.WebApi.Controllers return jm; } + + /// + /// 支付 + /// + /// + [HttpPost] + [Authorize] + public async Task UsePay([FromBody] JObject @params) + { + var jm = new WebApiCallBack(); + + var userId = _user.ID; + if (@params == null || !@params.ContainsKey("money")) + { + jm.status = false; + jm.msg = "参数不全"; + return jm; + } + if (@params.ContainsKey("nonce")) + { + @params.Remove("nonce"); + } + if (@params.ContainsKey("sign")) + { + @params.Remove("sign"); + } + if (!@params.ContainsKey("trade_type")) + { + @params.Add("trade_type", "JSAPI_OFFICIAL"); + } + + //生成支付单,并发起支付 + jm = await _billPaymentsServices.Pay("", "wechatpay", _user.ID, 6, @params); + + return jm; + } + #endregion #region 订单评价 diff --git a/CoreCms.Net.Web.WebApi/Doc.xml b/CoreCms.Net.Web.WebApi/Doc.xml index 41bb5bd..0192e06 100644 --- a/CoreCms.Net.Web.WebApi/Doc.xml +++ b/CoreCms.Net.Web.WebApi/Doc.xml @@ -1133,6 +1133,12 @@ + + + 支付 + + + 订单评价 diff --git a/CoreCms.Net.Web.WebApi/WxPayCert/apiclient_cert.p12 b/CoreCms.Net.Web.WebApi/WxPayCert/apiclient_cert.p12 new file mode 100644 index 0000000..ff0d0ac Binary files /dev/null and b/CoreCms.Net.Web.WebApi/WxPayCert/apiclient_cert.p12 differ diff --git a/CoreCms.Net.Web.WebApi/appsettings.json b/CoreCms.Net.Web.WebApi/appsettings.json index a3c3631..23e424e 100644 --- a/CoreCms.Net.Web.WebApi/appsettings.json +++ b/CoreCms.Net.Web.WebApi/appsettings.json @@ -92,16 +92,16 @@ "WeChatPay": { // 应用号 // 如:微信公众平台AppId、微信开放平台AppId、微信小程序AppId、企业微信CorpId等 - "AppId": "", + "AppId": "wxa17265f5fe8374b1", // 商户号 // 为微信支付商户平台的商户号 - "MchId": "", + "MchId": "1727621532", // API密钥 // 为微信支付商户平台的API密钥,请注意不是APIv3密钥 - "APIKey": "", + "APIKey": "zZ1uE0kU3iU5pB0tF4vA9xJ3oK7kR4cZ", // APIv3密钥 // 为微信支付商户平台的APIv3密钥,请注意不是API密钥,v3接口必填 - "APIv3Key": "", + "APIv3Key": "mU8rK7iV0zK1wV9iE1iW5nH5bT8dC9nU", // API证书(.p12) // 为微信支付商户平台的API证书(.p12),v3接口必填 // 可为证书文件(.p12)路径 / 证书文件(.p12)的base64字符串 @@ -109,7 +109,7 @@ "Certificate": "WxPayCert\\apiclient_cert.p12", // RSA公钥 // 目前仅调用"企业付款到银行卡API"时使用,执行本示例中的"获取RSA加密公钥API"即可获取。 - "RsaPublicKey": "" + "RsaPublicKey": "PUB_KEY_ID_0117276215322025091500291681003001" }, // 支付宝(暂未开通) // 更多配置,请查看AlipayOptions类