商户微信支付配置
This commit is contained in:
parent
6ace257b7d
commit
bf896352a3
@ -52,4 +52,9 @@ public class AddMerchantInput
|
||||
/// 审核状态
|
||||
/// </summary>
|
||||
public AuditStatus? AuditStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付配置
|
||||
/// </summary>
|
||||
public WeChatPayConfigInputDto? WeChatPayConfig { get; set; }
|
||||
}
|
||||
|
||||
@ -71,4 +71,9 @@ public class MerchantOutput
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付配置
|
||||
/// </summary>
|
||||
public WeChatPayConfigDto? WeChatPayConfig { get; set; }
|
||||
}
|
||||
44
YD_Event.Application/Merchant/Dtos/WeChatPayConfigDto.cs
Normal file
44
YD_Event.Application/Merchant/Dtos/WeChatPayConfigDto.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using YD_Event.Core.Enum;
|
||||
|
||||
namespace YD_Event.Application.Merchant.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付配置DTO
|
||||
/// </summary>
|
||||
public class WeChatPayConfigDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商户ID(外键)
|
||||
/// </summary>
|
||||
public long MerchantId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付商户号
|
||||
/// </summary>
|
||||
public string MerchantIdValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付 APIv3 密钥
|
||||
/// </summary>
|
||||
public string MerchantV3Secret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付商户证书序列号
|
||||
/// </summary>
|
||||
public string MerchantCertificateSerialNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付商户私钥(PEM格式)
|
||||
/// </summary>
|
||||
public string MerchantCertificatePrivateKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
public AvailabilityStatus Status { get; set; }
|
||||
}
|
||||
@ -0,0 +1,39 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using YD_Event.Core.Enum;
|
||||
|
||||
namespace YD_Event.Application.Merchant.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付配置输入DTO
|
||||
/// </summary>
|
||||
public class WeChatPayConfigInputDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 微信支付商户号
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "微信支付商户号不能为空")]
|
||||
public string MerchantIdValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付 APIv3 密钥
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "微信支付 APIv3 密钥不能为空")]
|
||||
public string MerchantV3Secret { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付商户证书序列号
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "微信支付商户证书序列号不能为空")]
|
||||
public string MerchantCertificateSerialNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 微信支付商户私钥(PEM格式)
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "微信支付商户私钥不能为空")]
|
||||
public string MerchantCertificatePrivateKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 可用状态
|
||||
/// </summary>
|
||||
public AvailabilityStatus Status { get; set; } = AvailabilityStatus.Enable;
|
||||
}
|
||||
@ -14,6 +14,7 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
{
|
||||
private readonly ISqlSugarRepository<YD_Event.Core.Entities.Merchant> _repository;
|
||||
private readonly ISqlSugarRepository<UserCoupon> _userCouponRepository;
|
||||
private readonly ISqlSugarRepository<WeChatPayConfig> _weChatPayConfigRepository;
|
||||
private readonly AuthManager _authManager;
|
||||
private readonly IIdGenerator _idGenerator;
|
||||
private readonly IMemoryCache _memoryCache;
|
||||
@ -21,6 +22,7 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
|
||||
public MerchantService(ISqlSugarRepository<YD_Event.Core.Entities.Merchant> repository,
|
||||
ISqlSugarRepository<UserCoupon> userCouponRepository,
|
||||
ISqlSugarRepository<WeChatPayConfig> weChatPayConfigRepository,
|
||||
AuthManager authManager,
|
||||
IIdGenerator idGenerator,
|
||||
IMemoryCache memoryCache,
|
||||
@ -28,6 +30,7 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
{
|
||||
_repository = repository;
|
||||
_userCouponRepository = userCouponRepository;
|
||||
_weChatPayConfigRepository = weChatPayConfigRepository;
|
||||
_authManager = authManager;
|
||||
_idGenerator = idGenerator;
|
||||
_memoryCache = memoryCache;
|
||||
@ -163,11 +166,20 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
/// </summary>
|
||||
[DisplayName("添加商户")]
|
||||
[HttpPost("add")]
|
||||
[UnitOfWork]
|
||||
public async Task Add(AddMerchantInput input)
|
||||
{
|
||||
var entity = input.Adapt<YD_Event.Core.Entities.Merchant>();
|
||||
entity.Id = _idGenerator.NextId();
|
||||
await _repository.InsertAsync(entity);
|
||||
|
||||
if (input.WeChatPayConfig != null)
|
||||
{
|
||||
var weChatPayConfig = input.WeChatPayConfig.Adapt<WeChatPayConfig>();
|
||||
weChatPayConfig.Id = _idGenerator.NextId();
|
||||
weChatPayConfig.MerchantId = entity.Id;
|
||||
await _weChatPayConfigRepository.InsertAsync(weChatPayConfig);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -175,6 +187,7 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
/// </summary>
|
||||
[DisplayName("更新商户")]
|
||||
[HttpPut("edit")]
|
||||
[UnitOfWork]
|
||||
public async Task Update(UpdateMerchantInput input)
|
||||
{
|
||||
var entity = await _repository.GetByIdAsync(input.Id);
|
||||
@ -182,6 +195,31 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
|
||||
input.Adapt(entity);
|
||||
await _repository.UpdateAsync(entity);
|
||||
|
||||
var existingWeChatPayConfig = await _weChatPayConfigRepository.GetFirstAsync(c => c.MerchantId == input.Id);
|
||||
|
||||
if (input.WeChatPayConfig != null)
|
||||
{
|
||||
if (existingWeChatPayConfig != null)
|
||||
{
|
||||
input.WeChatPayConfig.Adapt(existingWeChatPayConfig);
|
||||
await _weChatPayConfigRepository.UpdateAsync(existingWeChatPayConfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
var weChatPayConfig = input.WeChatPayConfig.Adapt<WeChatPayConfig>();
|
||||
weChatPayConfig.Id = _idGenerator.NextId();
|
||||
weChatPayConfig.MerchantId = input.Id;
|
||||
await _weChatPayConfigRepository.InsertAsync(weChatPayConfig);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existingWeChatPayConfig != null)
|
||||
{
|
||||
await _weChatPayConfigRepository.DeleteAsync(existingWeChatPayConfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -204,6 +242,8 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
var entity = await _repository.GetByIdAsync(id);
|
||||
if (entity == null) throw Oops.Bah("商户不存在");
|
||||
|
||||
var weChatPayConfig = await _weChatPayConfigRepository.GetFirstAsync(c => c.MerchantId == id);
|
||||
|
||||
return new MerchantOutput
|
||||
{
|
||||
Id = entity.Id,
|
||||
@ -218,7 +258,8 @@ public class MerchantService : BaseService<YD_Event.Core.Entities.Merchant>, ITr
|
||||
AuditRemark = entity.AuditRemark,
|
||||
Status = entity.Status,
|
||||
CreatedTime = entity.CreatedTime,
|
||||
UpdatedTime = entity.UpdatedTime
|
||||
UpdatedTime = entity.UpdatedTime,
|
||||
WeChatPayConfig = weChatPayConfig != null ? weChatPayConfig.Adapt<WeChatPayConfigDto>() : null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -6053,6 +6053,11 @@
|
||||
审核状态
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.AddMerchantInput.WeChatPayConfig">
|
||||
<summary>
|
||||
微信支付配置
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Merchant.Dtos.MerchantOutput">
|
||||
<summary>
|
||||
商户输出DTO
|
||||
@ -6123,6 +6128,11 @@
|
||||
更新时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.MerchantOutput.WeChatPayConfig">
|
||||
<summary>
|
||||
微信支付配置
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Merchant.Dtos.MerchantQueryInput">
|
||||
<summary>
|
||||
商户查询输入
|
||||
@ -6268,6 +6278,76 @@
|
||||
主键Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto">
|
||||
<summary>
|
||||
微信支付配置DTO
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto.Id">
|
||||
<summary>
|
||||
主键Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto.MerchantId">
|
||||
<summary>
|
||||
商户ID(外键)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto.MerchantIdValue">
|
||||
<summary>
|
||||
微信支付商户号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto.MerchantV3Secret">
|
||||
<summary>
|
||||
微信支付 APIv3 密钥
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto.MerchantCertificateSerialNumber">
|
||||
<summary>
|
||||
微信支付商户证书序列号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto.MerchantCertificatePrivateKey">
|
||||
<summary>
|
||||
微信支付商户私钥(PEM格式)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigDto.Status">
|
||||
<summary>
|
||||
可用状态
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Merchant.Dtos.WeChatPayConfigInputDto">
|
||||
<summary>
|
||||
微信支付配置输入DTO
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigInputDto.MerchantIdValue">
|
||||
<summary>
|
||||
微信支付商户号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigInputDto.MerchantV3Secret">
|
||||
<summary>
|
||||
微信支付 APIv3 密钥
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigInputDto.MerchantCertificateSerialNumber">
|
||||
<summary>
|
||||
微信支付商户证书序列号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigInputDto.MerchantCertificatePrivateKey">
|
||||
<summary>
|
||||
微信支付商户私钥(PEM格式)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:YD_Event.Application.Merchant.Dtos.WeChatPayConfigInputDto.Status">
|
||||
<summary>
|
||||
可用状态
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:YD_Event.Application.Merchant.MerchantService">
|
||||
<summary>
|
||||
商户管理
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user