From 8c2a88496c11ff6c87e0ae60edfedfc58224b9c6 Mon Sep 17 00:00:00 2001
From: liushijie <lslola@126.com>
Date: 星期三, 19 三月 2025 10:06:38 +0800
Subject: [PATCH] 渠道佣金
---
LifePayment/LifePayment.Application/LifePay/LifePayService.cs | 150 ++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 133 insertions(+), 17 deletions(-)
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index fc3e010..440288d 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -25,9 +25,10 @@
using ZeroD.Util;
using ZeroD.Util.Fadd;
using static LifePayment.Domain.Shared.LifePaymentConstant;
-using static IdentityServer4.Models.IdentityResources;
using Volo.Abp.Data;
using Z.EntityFramework.Plus;
+using LifePayment.Domain.LifePay;
+using pingan.openbank.api.sdk.enums;
namespace LifePayment.Application;
@@ -37,8 +38,10 @@
private readonly ILogger<LifePayService> _logger;
private readonly IRepository<LifePayRate, Guid> _lifePayRateRepository;
+ private readonly IRepository<LifePayPremium, Guid> _lifePayPremiumRepository;
private readonly IRepository<LifePayOrder, Guid> _lifePayOrderRepository;
private readonly IRepository<LifePayUser, Guid> _lifePayUserRepository;
+ private readonly IRepository<LifePayIntroInfo, Guid> _lifePayIntroInfoRepository;
private readonly IRepository<LifePayChannles, Guid> _lifePayChannlesRep;
private readonly IRepository<LifePayAccount, Guid> _lifePayAccount;
private readonly IDataFilter dataFilter;
@@ -55,6 +58,8 @@
IRepository<LifePayRate, Guid> lifePayRateRepository,
IRepository<LifePayOrder, Guid> lifePayOrderRepository,
IRepository<LifePayUser, Guid> lifePayUserRepository,
+ IRepository<LifePayPremium, Guid> lifePayPremiumRepository,
+ IRepository<LifePayIntroInfo, Guid> lifePayIntroInfoRepository,
IAliPayApi aliPayApi,
IWxPayApi wxPayApi,
IOptions<WxPayOption> wxPayOptions,
@@ -67,6 +72,8 @@
_lifePayRateRepository = lifePayRateRepository;
_lifePayOrderRepository = lifePayOrderRepository;
_lifePayUserRepository = lifePayUserRepository;
+ _lifePayPremiumRepository = lifePayPremiumRepository;
+ _lifePayIntroInfoRepository = lifePayIntroInfoRepository;
_aliPayApi = aliPayApi;
_wxPayApi = wxPayApi;
_wxPayOptions = wxPayOptions.Value;
@@ -133,6 +140,27 @@
public async Task<List<LifePayRateListOutput>> GetRate()
{
return await _lifePayRateRepository.Where(x => x.IsDeleted == false).Select(x => new LifePayRateListOutput() { Id = x.Id, Rate = x.Rate, RateType = x.RateType })
+ .ToListAsync();
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎵嬬画璐硅垂鐜�
+ /// </summary>
+ /// <returns></returns>
+ public async Task<List<LifePayPremiumListOutput>> GetPremium()
+ {
+ return await _lifePayPremiumRepository.Where(x => x.IsDeleted == false).Select(x => new LifePayPremiumListOutput() { Id = x.Id, Rate = x.Rate, PremiumType = x.PremiumType })
+ .ToListAsync();
+ }
+
+ /// <summary>
+ /// 椤荤煡閰嶇疆
+ /// </summary>
+ /// <returns></returns>
+ public async Task<List<LifePayIntroInfoOutput>> GetIntroInfo(LifePayOrderTypeEnum lifePayType)
+ {
+ return await _lifePayIntroInfoRepository.Where(x => x.IsDeleted == false && x.LifePayType == lifePayType).OrderBy(x => x.Sequence)
+ .Select(x => new LifePayIntroInfoOutput() { Type = x.Type, ContentSummary = x.ContentSummary, Content = x.Content, LifePayType = x.LifePayType,Path = x.Path,Sequence = x.Sequence })
.ToListAsync();
}
@@ -324,19 +352,12 @@
public async Task<PageOutput<CreateEditPayChannelsInput>> GetLifePayChannlesPage(PageInput input)
{
+ return await GetLifePayChannlesListFilter().GetPageResult(input.PageModel);
+ }
- return await _lifePayChannlesRep.Select(x =>
- new CreateEditPayChannelsInput
- {
- Id = x.Id,
- ChannlesRate = x.ChannlesRate,
- ChannlesName = x.ChannlesName,
- ChannlesNum = x.ChannlesNum,
- Status = x.Status,
- SwitchType = x.SwitchType,
- ChannlesType = x.ChannlesType,
- })
- .GetPageResult(input.PageModel);
+ public async Task<List<CreateEditPayChannelsInput>> GetLifePayChannlesAllList()
+ {
+ return await GetLifePayChannlesListFilter().Where(x => x.Status == LifePayChannelsStatsEnum.鍚敤).ToListAsync();
}
public async Task<CreateEditPayChannelsInput> GetLifePayChannlesDto(Guid id)
@@ -361,6 +382,7 @@
{
Id = x.Id,
ChannlesRate = x.ChannlesRate,
+ ChannlesRakeRate = x.ChannlesRakeRate,
ChannlesName = x.ChannlesName,
ChannlesNum = x.ChannlesNum,
Status = x.Status,
@@ -993,6 +1015,9 @@
throw new UserFriendlyException("褰撳墠璁㈠崟鐘舵�佹棤娉曢��娆�");
}
+ /// TODO 閫�娆捐姹傚畬鎴愬悗濡備綍鎿嶄綔
+ /// var refundResult = await WxPayDomesticRefunds(order.OrderNo, order.RefundApplyRemark, Convert.ToInt32(order.PayAmount * 100), Convert.ToInt32(order.PayAmount * 100));
+
order.PayStatus = LifePayStatusEnum.宸查��娆�;
order.LifePayOrderStatus = LifePayOrderStatusEnum.宸查��娆�;
order.RefundCredentialsImgUrl = input.RefundCredentialsImgUrl;
@@ -1043,6 +1068,26 @@
await _lifePayOrderRepository.UpdateAsync(order);
}
+ public async Task<WxPayDomesticRefundsReponse> WxPayDomesticRefunds(string outTradeNo, string reason, int refund, int total, string currency = "CNY")
+ {
+ WxPayDomesticRefundsRequest req = new WxPayDomesticRefundsRequest
+ {
+ OutTradeNo = outTradeNo,
+ OutRefundNo = CreateRefundOrderNo(),
+ Reason = reason,
+ Amount = new Model_WxPayDomesticRefunds_Amount
+ {
+ Refund = refund,
+ Total = total,
+ Currency = "CNY"
+ },
+ NotifyUrl = $"{_wxPayOptions.NotifyUrl}{LifePaymentConstant.WxPayDomesticRefundsNotifySectionUrl}",
+ };
+
+ var res = await _wxPayApi.WxPayDomesticRefunds(req);
+ return res;
+ }
+
public async Task<int> AddUpdateUserAccount(AddUpdateUserAccountInput input)
{
if (input.Id.HasValue)
@@ -1064,7 +1109,6 @@
}
else
{
-
var repeatAccountContent = await _lifePayAccount.Where(x => x.UserId == input.UserId && x.LifePayType == input.LifePayType && x.Content == input.Content)
.FirstOrDefaultAsync();
CheckExtensions.IfTrueThrowUserFriendlyException(repeatAccountContent != null, "鎴峰彿宸插瓨鍦�");
@@ -1150,6 +1194,7 @@
dto.ChannlesName = input.ChannlesName;
dto.ChannlesNum = input.ChannlesNum;
dto.ChannlesRate = input.ChannlesRate;
+ dto.ChannlesRakeRate = input.ChannlesRakeRate;
dto.SwitchType = input.SwitchType;
dto.ChannlesType = input.ChannlesType;
dto.Status = input.Status;
@@ -1197,6 +1242,7 @@
CheckExtensions.IfTrueThrowUserFriendlyException(dto.Status == LifePayChannelsStatsEnum.绂佺敤, "褰撳墠娓犻亾鍟嗗凡绂佺敤");
return true;
}
+
public async Task CreateEditLifePayRate(List<LifePayRateInput> input)
{
CheckExtensions.IfTrueThrowUserFriendlyException(input.Where(r => r.Rate <= 0).Any(), "鎶樻墸涓嶅緱灏忎簬绛変簬0");
@@ -1226,11 +1272,62 @@
{
await _lifePayRateRepository.InsertManyAsync(listData);
}
-
}
+ public async Task CreateEditLifePayPremium(List<LifePayPremiumInput> input)
+ {
+ CheckExtensions.IfTrueThrowUserFriendlyException(input.Where(r => r.Rate < 0).Any(), "鎶樻墸涓嶅緱灏忎簬0");
+ var listData = new List<LifePayPremium>();
+ foreach (var item in input)
+ {
+ var tmpDto = await _lifePayPremiumRepository.FirstOrDefaultAsync(r => r.PremiumType == item.PremiumType);
+ if (tmpDto != null)
+ {
+ tmpDto.Rate = item.Rate;
+ }
+ else
+ {
+ listData.Add(new LifePayPremium
+ {
+ CreationTime = DateTime.Now,
+ Rate = item.Rate,
+ PremiumType = item.PremiumType,
+ Id = Guid.NewGuid(),
+ });
+ }
+ }
+ if (listData.Any())
+ {
+ await _lifePayPremiumRepository.InsertManyAsync(listData);
+ }
+ }
+ public async Task EditIntroInfo(LifePayIntroInfoInput input)
+ {
+ var listData = new List<LifePayIntroInfo>();
+ foreach (var item in input.Data)
+ {
+ var tmpDto = await _lifePayIntroInfoRepository.Where(r => r.LifePayType == input.LifePayType).DeleteAsync();
+
+ listData.Add(new LifePayIntroInfo
+ {
+ LifePayType = input.LifePayType,
+ CreationTime = DateTime.Now,
+ Type = item.Type,
+ ContentSummary = item.ContentSummary,
+ Content = item.Content,
+ Path = item.Path,
+ Sequence = item.Sequence,
+ Id = Guid.NewGuid(),
+ });
+ }
+
+ if (listData.Any())
+ {
+ await _lifePayIntroInfoRepository.InsertManyAsync(listData);
+ }
+ }
#endregion
#region 绉佹湁
@@ -1238,6 +1335,11 @@
private string CreateOrderNo()
{
return "JF" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + GlobalRandom.GetRandomNum(4);
+ }
+
+ private string CreateRefundOrderNo()
+ {
+ return "JFTK" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + GlobalRandom.GetRandomNum(4);
}
private (decimal PayAmont, decimal DiscountAmount, decimal RechargeAmount) CalculateAmount(decimal amount, decimal rate)
@@ -1476,6 +1578,20 @@
return result;
}
+ private IQueryable<CreateEditPayChannelsInput> GetLifePayChannlesListFilter()
+ {
+ return _lifePayChannlesRep.Select(x =>
+ new CreateEditPayChannelsInput
+ {
+ Id = x.Id,
+ ChannlesRate = x.ChannlesRate,
+ ChannlesName = x.ChannlesName,
+ ChannlesNum = x.ChannlesNum,
+ Status = x.Status,
+ SwitchType = x.SwitchType,
+ ChannlesType = x.ChannlesType,
+ });
+ }
- #endregion
-}
+ #endregion
+ }
--
Gitblit v1.9.1