mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:13:26 +08:00
【测试】增加商家转账到零钱处理
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
<PackageReference Include="Qiniu" Version="8.2.0" />
|
||||
<PackageReference Include="QRCoder" Version="1.4.3" />
|
||||
<PackageReference Include="SixLabors.ImageSharp.Web" Version="2.0.2" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="2.15.2" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
|
||||
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.32" />
|
||||
<PackageReference Include="ToolGood.Words" Version="3.0.3.1" />
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
@@ -33,6 +34,9 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using SKIT.FlurlHttpClient.Wechat.TenpayV3.Settings;
|
||||
using SKIT.FlurlHttpClient.Wechat.TenpayV3;
|
||||
using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models;
|
||||
using SqlSugar;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
@@ -302,7 +306,13 @@ namespace CoreCms.Net.Services
|
||||
{
|
||||
status = (int)GlobalEnumVars.UserTocashStatus.提现成功;
|
||||
var message = JsonConvert.SerializeObject(response);
|
||||
var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash() { status = status, updateTime = DateTime.Now, message = message, type = type }, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常));
|
||||
var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash()
|
||||
{
|
||||
status = status,
|
||||
updateTime = DateTime.Now,
|
||||
message = message,
|
||||
type = type
|
||||
}, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常));
|
||||
jm.status = bl;
|
||||
jm.data = status;
|
||||
}
|
||||
@@ -310,7 +320,13 @@ namespace CoreCms.Net.Services
|
||||
{
|
||||
status = (int)GlobalEnumVars.UserTocashStatus.提现异常;
|
||||
var message = JsonConvert.SerializeObject(response);
|
||||
var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash() { status = status, updateTime = DateTime.Now, message = message, type = type }, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常));
|
||||
var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash()
|
||||
{
|
||||
status = status,
|
||||
updateTime = DateTime.Now,
|
||||
message = message,
|
||||
type = type
|
||||
}, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常));
|
||||
jm.status = bl;
|
||||
jm.data = status;
|
||||
}
|
||||
@@ -363,12 +379,81 @@ namespace CoreCms.Net.Services
|
||||
|
||||
break;
|
||||
}
|
||||
case (int)GlobalEnumVars.UserTocashType.商家转账到零钱:
|
||||
{
|
||||
var user = await _userServices.QueryByIdAsync(info.userId);
|
||||
if (user == null)
|
||||
{
|
||||
jm.msg = "用户信息获取失败";
|
||||
return jm;
|
||||
}
|
||||
var weChatUserInfo = await _weChatInfoServices.QueryByClauseAsync(p => p.userId == info.userId);
|
||||
if (weChatUserInfo == null)
|
||||
{
|
||||
jm.msg = "微信用户数据获取失败";
|
||||
return jm;
|
||||
}
|
||||
//按分计算
|
||||
var amount = Convert.ToInt16((info.money - info.withdrawals) * 100);
|
||||
|
||||
var palpay = _optionsAccessor.Value;
|
||||
|
||||
var manager = new InMemoryCertificateManager();
|
||||
var options = new WechatTenpayClientOptions()
|
||||
{
|
||||
MerchantId = palpay.MchId,
|
||||
MerchantV3Secret = palpay.APIv3Key,
|
||||
MerchantCertificateSerialNumber = "微信商户证书序列号",
|
||||
MerchantCertificatePrivateKey = "-----BEGIN PRIVATE KEY-----微信商户证书私钥,即 `apiclient_key.pem` 文件内容-----END PRIVATE KEY-----",
|
||||
PlatformCertificateManager = manager // 证书管理器的具体用法请参阅下文的高级技巧与加密、验签有关的章节
|
||||
};
|
||||
var client = new WechatTenpayClient(options);
|
||||
|
||||
var request = new CreateTransferBatchRequest();
|
||||
request.AppId = palpay.AppId;
|
||||
request.OutBatchNumber = "ut" + info.createTime.ToString("yyyyMMddHHmmss");
|
||||
request.BatchName = info.id + "用户提现处理";
|
||||
request.BatchRemark = info.id + "用户提现处理";
|
||||
request.TotalAmount = amount;
|
||||
request.TotalNumber = 1;
|
||||
request.TransferDetailList = new List<CreateTransferBatchRequest.Types.TransferDetail>();
|
||||
//转账明细列表
|
||||
var t = new CreateTransferBatchRequest.Types.TransferDetail
|
||||
{
|
||||
OutDetailNumber = "ut" + info.id,
|
||||
TransferAmount = amount,
|
||||
TransferRemark = "用户提现处理",
|
||||
OpenId = weChatUserInfo.openid,
|
||||
UserName = info.accountName
|
||||
};
|
||||
request.TransferDetailList.Add(t);
|
||||
|
||||
var response = await client.ExecuteCreateTransferBatchAsync(request);
|
||||
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
status = (int)GlobalEnumVars.UserTocashStatus.提现成功;
|
||||
var message = JsonConvert.SerializeObject(response);
|
||||
var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash() { status = status, updateTime = DateTime.Now, message = message, type = type }, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常));
|
||||
jm.status = bl;
|
||||
jm.data = status;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = (int)GlobalEnumVars.UserTocashStatus.提现异常;
|
||||
var message = JsonConvert.SerializeObject(response);
|
||||
var bl = await _dal.UpdateAsync(p => new CoreCmsUserTocash() { status = status, updateTime = DateTime.Now, message = message, type = type }, p => p.id == id && (p.status == (int)GlobalEnumVars.UserTocashStatus.待审核 || p.status == (int)GlobalEnumVars.UserTocashStatus.提现异常));
|
||||
jm.status = bl;
|
||||
jm.data = status;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
jm.msg = "提现方式获取失败";
|
||||
jm.status = false;
|
||||
break;
|
||||
}
|
||||
|
||||
return jm;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user