From d6ffbd97603decf4d3922a697414f4f7cec30434 Mon Sep 17 00:00:00 2001
From: zhengyuxuan <zhengyuxuan1995>
Date: 星期五, 28 三月 2025 11:13:26 +0800
Subject: [PATCH] fix:获取用户是否为管理员返回值优化
---
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs | 9 ++
LifePayment/LifePayment.Application/User/UserRoleService.cs | 16 ++++
LifePayment/LifePayment.Domain/WeChat/WxClient.cs | 2
LifePayment/LifePayment.Application/User/AccountService.cs | 49 ++++++++++------
LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs | 12 ++++
LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs | 3
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 5 +
LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs | 60 ++++++++++++++++++++
8 files changed, 131 insertions(+), 25 deletions(-)
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
index 226d890..cf63147 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
@@ -631,4 +631,16 @@
/// 鍏呭�煎嚟璇�
/// </summary>
public string Voucher { get; set; }
+}
+
+
+public class SetPayTypeReturn
+{
+ public string Desc { get; set; }
+
+ public string OrderNo { get; set; }
+
+ public decimal PayAmount { get; set; }
+
+ public LifePayTypeEnum LifePayType { get; set; }
}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
index ef60775..3eb2d27 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayOutput.cs
@@ -1169,5 +1169,12 @@
/// <summary>
/// 娓犻亾鍙�
/// </summary>
- public string[] ChannlesNum { get; set; }
+ public List<ChannelOutput> ChannlesNum { get; set; }
+}
+
+public class ChannelOutput
+{
+ public string Name { get; set; }
+
+ public string ChannlesNum { get; set; }
}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index 43213f8..2a8e236 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -843,6 +843,11 @@
return result;
}
+ /// <summary>
+ /// 鏌ヨ寰俊閫�娆捐鍗曚俊鎭�
+ /// </summary>
+ /// <param name="outTradeNo"></param>
+ /// <returns></returns>
public async Task WxPayDomesticRefundsQuery(string outTradeNo)
{
await _wxPayApi.WxPayDomesticRefundsQuery(outTradeNo);
diff --git a/LifePayment/LifePayment.Application/User/AccountService.cs b/LifePayment/LifePayment.Application/User/AccountService.cs
index ac9b944..951403b 100644
--- a/LifePayment/LifePayment.Application/User/AccountService.cs
+++ b/LifePayment/LifePayment.Application/User/AccountService.cs
@@ -5,6 +5,7 @@
using LifePayment.Domain.Shared;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
+using Nest;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -28,6 +29,7 @@
{
private readonly IWxManager _wxManager;
private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository;
+ private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRepository;
private readonly IConfiguration _configuration;
private readonly IIdentityModelAuthenticationService _authenticator;
private readonly IRepository<User, Guid> _userRepository;
@@ -43,6 +45,7 @@
IRepository<User, Guid> userRepository,
IIdentityUserAppService identityUserService,
IRepository<LifePayUser, Guid> lifePayUserRepository,
+ IRepository<LifePayChannles, Guid> lifePayChannlesRepository,
IRepository<UserChannle, Guid> userChannleRep,
IDistributedCache<string> distributedCache)
{
@@ -50,6 +53,7 @@
_wxManager = wxManager;
_identityUserService = identityUserService;
_lifePayUserRepository = lifePayUserRepository;
+ _lifePayChannlesRepository = lifePayChannlesRepository;
_authenticator = authenticator;
_userRepository = userRepository;
_userChannleRep = userChannleRep;
@@ -106,7 +110,6 @@
/// <exception cref="UserFriendlyException"></exception>
public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayPhoneMesssageCodeLogin(LifePayPhoneMesssageCodeLoginInput input)
{
- string[] channlesNum = new string[0];
var lifeUser = await _lifePayUserRepository.Where(x => x.PhoneNumber == input.PhoneNumber).FirstOrDefaultAsync();
if (lifeUser == null)
{
@@ -126,48 +129,58 @@
lifeUser.LastLoginTime = DateTime.Now;
await _lifePayUserRepository.UpdateAsync(lifeUser);
}
+
+ List<ChannelOutput> channlesNum = new List<ChannelOutput>();
var backClientUser = await _userRepository.Where(x => x.ClientId == Constant.ClientType.Back
&& x.PhoneNumber == input.PhoneNumber).FirstOrDefaultAsync();
if (backClientUser != null)
{
- channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id).Select(s => s.ChannleId).ToArrayAsync();
+ channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id)
+ .Select(s => new ChannelOutput()
+ {
+ Name = _lifePayChannlesRepository.Where(x => x.ChannlesNum == s.ChannleId).Select(r => r.ChannlesName).FirstOrDefault(),
+ ChannlesNum = s.ChannleId
+ }).ToListAsync();
}
- LifePayPhoneMesssageCodeLoginOutput result = new LifePayPhoneMesssageCodeLoginOutput()
- {
- UserId = lifeUser.Id,
- IsBackClientUser = backClientUser == null ? false : true,
- ChannlesNum = channlesNum
- };
-
-
+ var result = await LifePayUserMesssageByPhone(lifeUser.PhoneNumber);
+ result.UserId = lifeUser.Id;
return result;
}
public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayUserMesssageByIduser(Guid id)
{
- string[] channlesNum = new string[0];
var lifeUser = await _lifePayUserRepository.Where(x => x.Id == id).FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(lifeUser == null,
"鐢ㄦ埛涓嶅瓨鍦�");
+
+ var result = await LifePayUserMesssageByPhone(lifeUser.PhoneNumber);
+ result.UserId = id;
+ return result;
+ }
+
+ public async Task<LifePayPhoneMesssageCodeLoginOutput> LifePayUserMesssageByPhone(string phoneNumber)
+ {
+ List<ChannelOutput> channlesNum = new List<ChannelOutput>();
var backClientUser = await _userRepository.Where(x => x.ClientId == Constant.ClientType.Back
- && x.PhoneNumber == lifeUser.PhoneNumber).FirstOrDefaultAsync();
+ && x.PhoneNumber == phoneNumber).FirstOrDefaultAsync();
if (backClientUser != null)
{
- channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id).Select(s => s.ChannleId).ToArrayAsync();
+ channlesNum = await _userChannleRep.Where(x => x.UserId == backClientUser.Id)
+ .Select(s => new ChannelOutput()
+ {
+ Name = _lifePayChannlesRepository.Where(x => x.ChannlesNum == s.ChannleId).Select(r => r.ChannlesName).FirstOrDefault(),
+ ChannlesNum = s.ChannleId
+ }).ToListAsync();
}
LifePayPhoneMesssageCodeLoginOutput result = new LifePayPhoneMesssageCodeLoginOutput()
{
- UserId = id,
IsBackClientUser = backClientUser == null ? false : true,
ChannlesNum = channlesNum
};
-
-
- return result;
+ return result;
}
-
public async Task<IdentityModelTokenCacheItem> GetTokenForWeb(AccessRequestDto accessRequestDto, string webClientIp)
{
diff --git a/LifePayment/LifePayment.Application/User/UserRoleService.cs b/LifePayment/LifePayment.Application/User/UserRoleService.cs
index be79492..e8239f5 100644
--- a/LifePayment/LifePayment.Application/User/UserRoleService.cs
+++ b/LifePayment/LifePayment.Application/User/UserRoleService.cs
@@ -103,10 +103,16 @@
List<UserChannle> userChannles = new List<UserChannle>();
foreach (var item in input.ChannlesId)
{
+ var channleNum = item;
+ if (IsGuid(channleNum))
+ {
+ channleNum = await _channleRepository.Where(x => x.Id == Guid.Parse(item)).Select(s => s.ChannlesNum).FirstOrDefaultAsync();
+ }
+
userChannles.Add(new UserChannle()
{
Id = Guid.NewGuid(),
- ChannleId = item,
+ ChannleId = channleNum,
UserId = entity.Id
});
}
@@ -221,5 +227,11 @@
await _roleRepository.DeleteAsync(id);
return Constant.SUCCESS;
}
+
+ private bool IsGuid(string input)
+ {
+ Guid guidOutput;
+ return Guid.TryParse(input, out guidOutput);
+ }
}
-}
\ No newline at end of file
+}
diff --git a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
index c94907b..d088224 100644
--- a/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
+++ b/LifePayment/LifePayment.Domain.Shared/WeChat/WxPayPostBaseModel.cs
@@ -802,4 +802,64 @@
[JsonProperty("download_url")]
public string DownloadUrl { get; set; }
}
+
+ public class WxPayDomesticRefundsQueryReponse
+ {
+ /// <summary>
+ /// 寰俊鏀粯閫�娆惧崟鍙�
+ /// </summary>
+ [JsonProperty("refund_id ")]
+ public string RefundId { get; set; }
+ /// <summary>
+ /// 鍟嗘埛閫�娆惧崟鍙�
+ /// </summary>
+ [JsonProperty("out_refund_no")]
+ public string DownloadUrl { get; set; }
+ /// <summary>
+ /// 寰俊鏀粯璁㈠崟鍙�
+ /// </summary>
+ [JsonProperty("transaction_id ")]
+ public string TransactionId { get; set; }
+
+ /// <summary>
+ /// 鍟嗘埛璁㈠崟鍙�
+ /// </summary>
+ [JsonProperty("out_trade_no")]
+ public string OutTradeNo { get; set; }
+
+ /// <summary>
+ /// 閫�娆炬笭閬� ORIGINAL: 鍘熻矾閫�娆� BALANCE: 閫�鍥炲埌浣欓 OTHER_BALANCE: 鍘熻处鎴峰紓甯搁��鍒板叾浠栦綑棰濊处鎴� OTHER_BANKCARD: 鍘熼摱琛屽崱寮傚父閫�鍒板叾浠栭摱琛屽崱(鍙戣捣寮傚父閫�娆炬垚鍔熷悗杩斿洖)
+ /// </summary>
+ [JsonProperty("channel")]
+ public string Channel { get; set; }
+ /// <summary>
+ /// 閫�娆惧叆璐﹁处鎴�
+ /// </summary>
+ [JsonProperty("user_received_account")]
+ public string UserReceivedAccount { get; set; }
+
+ /// <summary>
+ /// 閫�娆炬垚鍔熸椂闂�
+ /// </summary>
+ [JsonProperty("success_time")]
+ public string SuccessTime { get; set; }
+ /// <summary>
+ /// 閫�娆惧垱寤烘椂闂�
+ /// </summary>
+ [JsonProperty("create_time")]
+ public string CreateTime { get; set; }
+
+ /// <summary>
+ /// 閫�娆剧姸鎬� SUCCESS: 閫�娆炬垚鍔� CLOSED: 閫�娆惧叧闂� PROCESSING: 閫�娆惧鐞嗕腑 ABNORMAL: 閫�娆惧紓甯�
+ /// </summary>
+ [JsonProperty("status")]
+ public string Status { get; set; }
+
+ /// <summary>
+ /// 閲戦淇℃伅
+ /// </summary>
+ [JsonProperty("amount")]
+ public string Amount { get; set; }
+ }
+
}
\ No newline at end of file
diff --git a/LifePayment/LifePayment.Domain/WeChat/WxClient.cs b/LifePayment/LifePayment.Domain/WeChat/WxClient.cs
index ea578a8..61f6131 100644
--- a/LifePayment/LifePayment.Domain/WeChat/WxClient.cs
+++ b/LifePayment/LifePayment.Domain/WeChat/WxClient.cs
@@ -121,8 +121,6 @@
return result;
}
-
-
public async Task<CertificatesReponse> GetCertificates()
{
return await Certificates<CertificatesReponse>(LifePaymentConstant.WxPayCertificates);
diff --git a/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs b/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
index 39a8ee8..c84208a 100644
--- a/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
+++ b/LifePayment/LifePayment.Domain/WeChat/WxPayApi.cs
@@ -39,8 +39,7 @@
public async Task WxPayDomesticRefundsQuery(string outTradeNo)
{
var url = $"{string.Format(LifePaymentConstant.WxPayDomesticRefundsQuery, outTradeNo)}";
- var result = await Certificates<PayTransactionsReponse>(url);
- //return result;
+ var result = await Certificates<WxPayDomesticRefundsQueryReponse>(url);
}
public async Task<WxPayTradeBillApplyReponse> WxPayTradeBillApply(WxPayTradeBillApplyRequest input)
--
Gitblit v1.9.1