Browse Source

补款调整,待更新

FLH 4 weeks ago
parent
commit
c7065121eb

+ 38 - 3
2.Data/XYY.Data.Strandard/Finance/IFinance_Customer_SupplementRepository.cs

@@ -24,11 +24,13 @@ namespace XYY.Data.Standard.Finance
 
     public class Finance_Customer_SupplementRepository : BaseRepository<Finance_Customer_Supplement>, IFinance_Customer_SupplementRepository
     {
-        public Finance_Customer_SupplementRepository(IUnitOfWork unitOfWork, IOrderRepository orderRepository) : base(unitOfWork)
+        public Finance_Customer_SupplementRepository(IUnitOfWork unitOfWork, IOrderRepository orderRepository, IUserCustomerRepository userCustomerRepository) : base(unitOfWork)
         {
             _orderRepository = orderRepository;
+            _userCustomerRepository = userCustomerRepository;
         }
         IOrderRepository _orderRepository;
+        IUserCustomerRepository _userCustomerRepository;
         /// <summary>
         /// 快递资费信息表
         /// </summary>
@@ -79,7 +81,8 @@ namespace XYY.Data.Standard.Finance
             Dictionary<string, string> errorList = new Dictionary<string, string>();
             foreach (var item in list)
             {
-                if (item.FinanceCustomerSupplementType != FinanceCustomerSupplementOrDeductionType.补_Sku处理费)
+                if (item.FinanceCustomerSupplementType != FinanceCustomerSupplementOrDeductionType.补_Sku处理费
+                    && item.FinanceCustomerSupplementType != FinanceCustomerSupplementOrDeductionType.补_通用杂费)
                 {
                     try
                     {
@@ -203,7 +206,10 @@ namespace XYY.Data.Standard.Finance
             Dictionary<string, string> errorList = new Dictionary<string, string>();
             foreach (var item in list)
             {
-                if (item.FinanceCustomerSupplementType != FinanceCustomerSupplementOrDeductionType.补_Sku处理费)
+                if (
+                    item.FinanceCustomerSupplementType != FinanceCustomerSupplementOrDeductionType.补_Sku处理费 &&
+                    item.FinanceCustomerSupplementType != FinanceCustomerSupplementOrDeductionType.补_通用杂费
+                    )
                 {
                     try
                     {
@@ -283,6 +289,35 @@ namespace XYY.Data.Standard.Finance
                     {
                         errorList.Add(item.SystemNo, $"已存在SKU处理费{item.SystemNo}");
                     }
+
+                    if (await IsExistsAsync(x => x.SystemNo == item.SystemNo && x.FinanceCustomerSupplementType
+                    == FinanceCustomerSupplementOrDeductionType.补_通用杂费))
+                    {
+                        errorList.Add(item.SystemNo, $"已存在通用杂费{item.SystemNo}");
+                    } 
+                    else if (list.First().FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.补_通用杂费)
+                    {
+                        item.CreateOrderChannelId = 950;
+                        var customers = await _userCustomerRepository.QueryAsync();
+                        if (item.Fee != item.AvgFee * item.Qty)
+                        {
+                            errorList.Add(item.SystemNo, $" 单价*数量不等于金额 {item.SystemNo}"); 
+                        }
+                        else
+                        {
+                            var c = customers.FirstOrDefault(y =>
+                                y.CompanyName.Trim() == item.CustomerName.Trim()
+                                || y.Abbreviation.Trim() == item.CustomerName.Trim());
+                            if (c == null)
+                            {
+                                errorList.Add(item.SystemNo, $"{item.CustomerName} 客户名在系统中不存在{item.SystemNo}");
+                            }
+                            else
+                            {
+                                item.CustomerId = c.Id;
+                            }
+                        }
+                    }
                 }
 
                 item.transactionNumber = baseSuppl + _orderRepository.GetPackagePrintQty(baseSuppl).ToString("000000");

+ 36 - 1
2.Data/XYY.Model.Strandard/Finance/Finance_Customer_Supplement.cs

@@ -40,9 +40,16 @@ namespace XYY.Model.Standard.Finance
         扣_运费退回 = 8,
         扣_退件退回 = 9,
         补_FBA杂费 = 10,
-        补_Sku处理费 = 11
+        补_Sku处理费 = 11,
+        补_通用杂费 = 12
     }
 
+    public enum SupplementTargetType
+    {
+        客户 = 0,
+        分公司 = 1,
+        全部 = 3
+    }
 
     /// <summary>
     /// SMP费用明细
@@ -180,10 +187,38 @@ namespace XYY.Model.Standard.Finance
             get; set;
         }
 
+        /// <summary>
+        /// 补款对象
+        /// </summary>
+        public int SupplementTargetType
+        {
+            get; set;
+        }
+
         [NoDb]
         public string Guid
         {
             get; set;
         }
+
+        [NoDb]
+        public string CustomerName
+        {
+            get; set;
+        }
+
+        [NoDb]
+        public decimal AvgFee
+        {
+            get; set;
+        }
+
+        [NoDb]
+        public int Qty
+        {
+            get; set;
+        }
+
+
     }
 }

+ 3 - 3
3.Service/XYY.Service.Standard.Finance/IFinance_Customer_SupplementService.cs

@@ -62,8 +62,8 @@ namespace XYY.Service.Standard.Finance
 
         public void AddMQ(List<Finance_Customer_SupplementNew> supplementNews)
         {
-            //string baseUrl = $"http://localhost:22707/api/Finance/AddSupplementMQ";
-            string baseUrl = $"http://120.24.149.148/api/Finance/AddSupplementMQ";
+            string baseUrl = $"http://localhost:22707/api/Finance/AddSupplementMQ";
+            //string baseUrl = $"http://120.24.149.148/api/Finance/AddSupplementMQ";
 
             var client = new RestSharp.RestClient(baseUrl);
             var request = new RestSharp.RestRequest();
@@ -162,7 +162,7 @@ namespace XYY.Service.Standard.Finance
                            fee = supplementNew.Fee,
                            feeItemId = supplement.SMPDetailTypeId,
                            feeItemName =supplement.SMPDetailType,
-                           price = supplementNew.Fee,
+                           price = supplementNew.AvgFee>0?supplementNew.AvgFee: supplementNew.Fee,
                            exchangeRate=1,
                            oriCurrencyCode=supplement.CurrenyRate,
                            oriCurrencyFee=supplement.Fee

+ 90 - 29
5.Api/XYY.Api.Finance/Controllers/FinanceCustomerSupplementsController.cs

@@ -15,6 +15,7 @@ using XYY.Common.Standard;
 using XYY.Core.Standard.ExcelHelper.MSExcelHelper;
 using XYY.Core.Standard.Mvc;
 using XYY.Model.Standard.Finance;
+using XYY.Model.Standard.MpsOrder.dto;
 using XYY.Service.Standard.Customer;
 using XYY.Service.Standard.Finance;
 
@@ -112,45 +113,84 @@ namespace XYY.Api.Finance.Controllers
 
         }
 
-        public async Task<IActionResult> InputFinanceCustomerSupplements(FinanceCustomerSupplementOrDeductionType type,
-            string url, string month, bool isNewFee,
-            string currencyCode = "CNY")
+
+
+        public async Task<IActionResult> InputFinanceCustomerSupplements(
+            FinanceCustomerSupplementOrDeductionType type,
+            string url,
+            string month,
+            bool isNewFee,
+            string currencyCode = "CNY",
+            SupplementTargetType targetValue = SupplementTargetType.全部)
         {
-            System.Net.WebClient client = new System.Net.WebClient();
-            byte[] data = client.DownloadData(url);
-            MSExcelHelper excelHelper = new MSExcelHelper();
-            var list = excelHelper.LoadDataByByte<CustomerSupplementMapping, Finance_Customer_Supplement>(data);
-            foreach (var item in list)
-            {
-                item.CurrenyRate = currencyCode;
-            }
+            List<Finance_Customer_Supplement> list = new List<Finance_Customer_Supplement>();
             var nsmpCustomers = await customerService.GetNSMPCustomer();
-            FinanceCustomerSupplementOrDeductionType financeCustomerSupplementType = type;
-            list.ForEach(x =>
+            if (type == FinanceCustomerSupplementOrDeductionType.补_通用杂费)
             {
-                x.FinanceCustomerSupplementType = type;
-                if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.补_退件费)
-                {
-                    x.Describe = "退件费";
-                }
-                else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.补_重派费)
+                System.Net.WebClient client = new System.Net.WebClient();
+                byte[] data = client.DownloadData(url);
+                MSExcelHelper excelHelper = new MSExcelHelper();
+                var fees = excelHelper.LoadDataByByte<OtherFeeSupplementMapping, Finance_Customer_Supplement>(data);
+                foreach (var item in fees)
                 {
-                    x.Describe = "重派费";
+                    item.CurrenyRate = currencyCode;
+                    item.Describe = item.AvgFee + item.CurrenyRate + "*" + item.Qty;
+                    item.CurrenyRate = currencyCode;
+                    item.SupplementTargetType = (int)targetValue;
+                    item.FinanceCustomerSupplementType = type;
+                    item.FeeString = item.Fee + item.CurrenyRate;
+                    list.Add(item);
                 }
-                else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.扣_重量差异费)
+
+                await this.supplementService.InputFinanceCustomerSupplements(type, list);
+                var nsmpList2 = list.Where(x => nsmpCustomers.Contains(x.CustomerId)).ToList();
+                if (nsmpList2.Count() != 0)
                 {
-                    x.Describe = "重量差异费";
+                    await this.supplementService.InputFinanceCustomerSupplementsNew(type, nsmpList2);
                 }
-                else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.扣_时间差异费)
+                return Ok();
+
+            }
+            else
+            {
+
+                System.Net.WebClient client = new System.Net.WebClient();
+                byte[] data = client.DownloadData(url);
+                MSExcelHelper excelHelper = new MSExcelHelper();
+                excelHelper.LoadDataByByte<CustomerSupplementMapping, Finance_Customer_Supplement>(data);
+                foreach (var item in list)
                 {
-                    x.Describe = "时间差异费";
+                    item.CurrenyRate = currencyCode;
+                    item.SupplementTargetType = (int)type;
+                    item.FinanceCustomerSupplementType = type;
                 }
-                else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.扣_索赔)
+                FinanceCustomerSupplementOrDeductionType financeCustomerSupplementType = type;
+                list.ForEach(x =>
                 {
-                    x.Describe = "索赔费用";
-                }
-                x.Month = month; 
-            });
+                    x.FinanceCustomerSupplementType = type;
+                    if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.补_退件费)
+                    {
+                        x.Describe = "退件费";
+                    }
+                    else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.补_重派费)
+                    {
+                        x.Describe = "重派费";
+                    }
+                    else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.扣_重量差异费)
+                    {
+                        x.Describe = "重量差异费";
+                    }
+                    else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.扣_时间差异费)
+                    {
+                        x.Describe = "时间差异费";
+                    }
+                    else if (x.FinanceCustomerSupplementType == FinanceCustomerSupplementOrDeductionType.扣_索赔)
+                    {
+                        x.Describe = "索赔费用";
+                    }
+                    x.Month = month;
+                });
+            }
             await this.supplementService.InputFinanceCustomerSupplements(type, list);
             var nsmpList = list.Where(x => nsmpCustomers.Contains(x.CustomerId)).ToList();
             if (nsmpList.Count() != 0)
@@ -166,6 +206,27 @@ namespace XYY.Api.Finance.Controllers
             return Ok(items);
         }
 
+
+        public class OtherFeeSupplementMapping : MSExcelClassMapping<Finance_Customer_Supplement>
+        {
+            public OtherFeeSupplementMapping()
+            {
+                Map(x => x.SystemNo).Name("订单编号");
+                Map(x => x.TrackingNumber).Name("订单编号");
+                Map(x => x.CustomerOrderNo).Name("订单编号");
+                Map(x => x.CreateTime).Name("业务时间");
+                Map(x => x.CustomerName).Name("客户");
+                Map(x => x.SMPDetailType).Name("费用名称");
+                Map(x => x.AvgFee).Name("单价");
+                Map(x => x.Qty).Name("数量");
+                Map(x => x.Fee).Name("金额");
+                Map(x => x.OrderRemark).Name("备注");
+            }
+        }
+
+
+
+
         public class CustomerSupplementMapping : MSExcelClassMapping<Finance_Customer_Supplement>
         {
             public CustomerSupplementMapping()