From bce2ec0274b8ae765bfb318b701e41a82a53ba0e Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期五, 06 六月 2025 17:45:29 +0800
Subject: [PATCH] pref:渠道字段添加

---
 LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml |   25 ++++++++++++
 LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs      |   24 ++++++++++++
 LifePayment/LifePayment.Application/LifePay/LifePayService.cs              |   53 ++++++++++++++++++++------
 3 files changed, 89 insertions(+), 13 deletions(-)

diff --git a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
index 72868d6..dcc6ce2 100644
--- a/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
+++ b/LifePayment/LifePayment.Application.Contracts/LifePay/LifePayInput.cs
@@ -460,6 +460,30 @@
 
     public LifePayChannlesTypeEnum ChannlesType { get; set; }
 
+    /// <summary>
+    /// 浠g悊绫诲瀷
+    /// </summary>
+    public LifePayChannelAgentType? AgentType { get; set; }
+
+    /// <summary>
+    /// 鍖哄煙-鐪両d
+    /// </summary>
+    public int? AreaProvinceId { get; set; }
+
+    /// <summary>
+    /// 鍖哄煙-甯侷d
+    /// </summary>
+    public int? AreaCityId { get; set; }
+
+    /// <summary>
+    /// 鎺ㄥ箍鍛業D
+    /// </summary>
+    public string PromoterIdNumber { get; set; }
+
+    /// <summary>
+    /// 鎺ㄥ箍鍛�
+    /// </summary>
+    public string PromoterName { get; set; }
 }
 
 public class QueryUserAccountListInput : ChannelsBaseInput
diff --git a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
index ee425c3..379bf86 100644
--- a/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
+++ b/LifePayment/LifePayment.Application/LifePay/LifePayService.cs
@@ -50,10 +50,12 @@
     private readonly InitSetting _initSettingOptions;
 
     private readonly IACOOLYManager _aCOOLYManager;
+    private readonly IRepository<LifePayPromoter, Guid> lifePayPromoterRepository;
 
     public LifePayService(IDistributedEventBus distributedEventBus,
                           ILogger<LifePayService> logger,
                           IACOOLYManager aCOOLYManager,
+                          IRepository<LifePayPromoter, Guid> lifePayPromoterRepository,
                           IRepository<LifePayRate, Guid> lifePayRateRepository,
                           IRepository<LifePayOrder, Guid> lifePayOrderRepository,
                           IRepository<LifePayUser, Guid> lifePayUserRepository,
@@ -74,6 +76,7 @@
     {
         _logger = logger;
         _aCOOLYManager = aCOOLYManager;
+        this.lifePayPromoterRepository = lifePayPromoterRepository;
         _lifePayRateRepository = lifePayRateRepository;
         _lifePayOrderRepository = lifePayOrderRepository;
         _lifePayUserRepository = lifePayUserRepository;
@@ -1714,13 +1717,22 @@
         {
             var dto = await _lifePayChannlesRep.FirstOrDefaultAsync(r => r.Id == input.Id.Value);
             CheckExtensions.IfTrueThrowUserFriendlyException(dto == null, "鏈幏鍙栧埌娓犻亾鎶樻墸鏁版嵁");
+            if (!string.IsNullOrWhiteSpace(input.PromoterIdNumber) || !string.IsNullOrWhiteSpace(input.PromoterName))
+            {
+                var promoter = await lifePayPromoterRepository.FirstOrDefaultAsync(it => it.IdNumber == input.PromoterIdNumber && it.Name == input.PromoterName);
+                CheckExtensions.IfTrueThrowUserFriendlyException(promoter == null, "璇ユ帹骞夸汉涓嶅瓨鍦�");
+                dto.PromoterId = promoter.Id;
+            }
+
             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;
+            dto.AgentType = input.AgentType;
+            dto.AreaProvinceId = input.AreaProvinceId;
+            dto.AreaCityId = input.AreaCityId;
             #region 璁板綍鏃ュ織
 
             await LifePayOrderHistory("娓犻亾绠$悊", "缂栬緫", input.Id.Value, TableType.LifePayChannles);
@@ -1732,6 +1744,13 @@
             CheckExtensions.IfTrueThrowUserFriendlyException(input.ChannlesRate < 0.01m, "娓犻亾鎶樻墸璁剧疆閿欒");
             input.Id = Guid.NewGuid();
             var entity = ObjectMapper.Map<CreateEditPayChannelsInput, LifePayChannles>(input);
+            if (!string.IsNullOrWhiteSpace(input.PromoterIdNumber) || !string.IsNullOrWhiteSpace(input.PromoterName))
+            {
+                var promoter = await lifePayPromoterRepository.FirstOrDefaultAsync(it => it.IdNumber == input.PromoterIdNumber && it.Name == input.PromoterName);
+                CheckExtensions.IfTrueThrowUserFriendlyException(promoter == null, "璇ユ帹骞夸汉涓嶅瓨鍦�");
+                entity.PromoterId = promoter.Id;
+            }
+
             await _lifePayChannlesRep.InsertAsync(entity);
 
             #region 璁板綍鏃ュ織
@@ -2181,20 +2200,28 @@
                       });
         return result;
     }
+
     private IQueryable<CreateEditPayChannelsInput> GetLifePayChannlesListFilter()
     {
-        return _lifePayChannlesRep.Select(x =>
-                    new CreateEditPayChannelsInput
-                    {
-                        Id = x.Id,
-                        ChannlesRate = x.ChannlesRate,
-                        ChannlesRakeRate = x.ChannlesRakeRate,
-                        ChannlesName = x.ChannlesName,
-                        ChannlesNum = x.ChannlesNum,
-                        Status = x.Status,
-                        SwitchType = x.SwitchType,
-                        ChannlesType = x.ChannlesType,
-                    });
+        return from x in _lifePayChannlesRep
+               join p in lifePayPromoterRepository on x.PromoterId equals p.Id into pg
+               from pgd in pg.DefaultIfEmpty()
+               select new CreateEditPayChannelsInput
+               {
+                   Id = x.Id,
+                   ChannlesRate = x.ChannlesRate,
+                   ChannlesRakeRate = x.ChannlesRakeRate,
+                   ChannlesName = x.ChannlesName,
+                   ChannlesNum = x.ChannlesNum,
+                   Status = x.Status,
+                   SwitchType = x.SwitchType,
+                   ChannlesType = x.ChannlesType,
+                   AgentType = x.AgentType,
+                   AreaProvinceId = x.AreaProvinceId,
+                   AreaCityId = x.AreaCityId,
+                   PromoterIdNumber = pgd.IdNumber,
+                   PromoterName = pgd.Name,
+               };
     }
 
     public async Task<OrderPriceReturn> GetOrderPrice(decimal price, decimal priceAmount, decimal platformRate, decimal channleRate,
diff --git a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
index 23d2409..57b40f2 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
+++ b/LifePayment/LifePayment.Host/LifePaymentServices.Application.Contracts.xml
@@ -632,6 +632,31 @@
             鐢ㄦ埛Id
             </summary>
         </member>
+        <member name="P:LifePayment.Application.Contracts.CreateEditPayChannelsInput.AgentType">
+            <summary>
+            浠g悊绫诲瀷
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.CreateEditPayChannelsInput.AreaProvinceId">
+            <summary>
+            鍖哄煙-鐪両d
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.CreateEditPayChannelsInput.AreaCityId">
+            <summary>
+            鍖哄煙-甯侷d
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.CreateEditPayChannelsInput.PromoterIdNumber">
+            <summary>
+            鎺ㄥ箍鍛業D
+            </summary>
+        </member>
+        <member name="P:LifePayment.Application.Contracts.CreateEditPayChannelsInput.PromoterName">
+            <summary>
+            鎺ㄥ箍鍛�
+            </summary>
+        </member>
         <member name="P:LifePayment.Application.Contracts.QueryUserAccountListInput.UserId">
             <summary>
             鐢ㄦ埛Id

--
Gitblit v1.9.1