Browse Source

添加其他费用供应商联想功能,提交汇率保留修改

yuanrf 9 months ago
parent
commit
9bef9d648c

+ 92 - 34
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -2982,6 +2982,35 @@ namespace OASystem.API.Controllers
 
         }
 
+        /// <summary>
+        /// 查询供应商名称
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
+        {
+            var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
+                .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList() 
+                ?? new List<Grp_DecreasePayments>();
+            dbResult = dbResult.Distinct(new
+                 ProductComparer ()).ToList();
+
+            var jw = JsonView(true, "success", dbResult.OrderByDescending(x=>x. Id ).Select(x => new
+            {
+                x.Id,
+                x.SupplierAddress,
+                x.SupplierArea,
+                x.SupplierContact,
+                x.SupplierContactNumber,
+                x.SupplierEmail,
+                x.SupplierName,
+                x.SupplierSocialAccount,
+                x.SupplierTypeId,
+            }).ToList());
+            return Ok(jw);
+        }
+
         #endregion
 
         #region 文件上传、删除
@@ -3640,6 +3669,22 @@ namespace OASystem.API.Controllers
             }
         }
 
+
+        private decimal DecimalToFixed2(decimal num)
+        {
+            string numStr = num.ToString("#0.0000");
+            string num1 = numStr.Split(".")[0];
+            string num2 = numStr.Split(".")[1];
+            string num21 = num2.Substring(0, 2);
+            string num22 = num2.Substring(2, 1);
+
+            var bool1 = int.TryParse(num22, out int num221);
+            decimal res = decimal.Parse($"{num1}.{num21}");
+            if (num221 > 0) res += 0.01M;
+
+            return res;
+        }
+
         /// <summary>
         /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
         /// </summary>
@@ -3676,20 +3721,24 @@ namespace OASystem.API.Controllers
 
                 };
 
-                //var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
-                //if (_currencyRate.Count > 0)
-                //{
+                var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
+                if (_currencyRate.Count > 0)
+                {
+                    foreach (var item in _currencyInfos)
+                    {
+                        var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
+                        if (rateInfo != null)
+                        {
+                            decimal rate1 = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
+                            rate1 *= 1.03M;
 
-                //    foreach (var item in _currencyInfos)
-                //    {
-                //        var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
-                //        if (rateInfo != null)
-                //        {
-                //            item.Rate = Convert.ToDecimal(rateInfo.FSellPri) / 100.00M;
-                //        }
-                //    }
-                //}
+                            //if (rate1 <= 0.00M) rate1 = 0.00M;
+                            //else rate1 = Math.Round(rate1, 2) + 0.01M;
 
+                            item.Rate = DecimalToFixed2(rate1);
+                        }
+                    }
+                }
 
                 return Ok(JsonView(true, "查询成功!", new
                 {
@@ -3730,26 +3779,32 @@ namespace OASystem.API.Controllers
                     new CurrencyInfo (){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
                 };
 
-            //var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
-            //List<dynamic> reteInfos = new List<dynamic>();
-            //if (_currencyRate.Count > 0)
-            //{
-            //    foreach (var item in _currencyInfos)
-            //    {
-            //        var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
-            //        if (rateInfo != null)
-            //        {
-            //            item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
-            //            reteInfos.Add(new
-            //            {
-            //                currCode = item.CurrencyCode,
-            //                currName = item.CurrencyName,
-            //                rate = item.Rate,
-            //                lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
-            //            });
-            //        }
-            //    }
-            //}
+            var _currencyRate = await _juHeApi.PostItemRateAsync(_currencyInfos.Select(it => it.CurrencyCode).ToArray());
+            List<dynamic> reteInfos = new List<dynamic>();
+            if (_currencyRate.Count > 0)
+            {
+                foreach (var item in _currencyInfos)
+                {
+                    var rateInfo = _currencyRate.Where(it => it.Name.Equals(item.CurrencyName)).FirstOrDefault();
+                    if (rateInfo != null)
+                    {
+                        item.Rate = Convert.ToDecimal((Convert.ToDecimal(rateInfo.FSellPri == null ? 0.00M : rateInfo.FSellPri) / 100.00M).ToString("#0.0000"));
+
+                        decimal rate1 = item.Rate;
+                        rate1 *= 1.03M;
+                        //if (rate1 <= 0.00M) rate1 = 0.00M;
+                        //else rate1 = Math.Round(rate1, 2) + 0.01M;
+
+                        reteInfos.Add(new
+                        {
+                            currCode = item.CurrencyCode,
+                            currName = item.CurrencyName,
+                            rate = DecimalToFixed2(rate1),
+                            lastUpdateDt = rateInfo.Date + " " + rateInfo.Time
+                        });
+                    }
+                }
+            }
 
             var visaData = await _visaFeeInfoRep.EntryAndExitTips(dto.DiId);
             var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
@@ -3758,7 +3813,7 @@ namespace OASystem.API.Controllers
                 //GroupNameData = groupNameData.Data,
                 visaData = visaData.Data,
                 airData = airData.Data,
-                reteInfos = _currencyInfos
+                reteInfos = reteInfos
             }));
         }
 
@@ -7080,6 +7135,8 @@ namespace OASystem.API.Controllers
             //     Grp_GroupCostParameter());
             var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
 
+            bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == dto.Diid && x.IsDel == 0 ).Count() > 0;
+
             return Ok(JsonView(new
             {
                 groupList,
@@ -7095,7 +7152,8 @@ namespace OASystem.API.Controllers
                     x.Id,
                 }).ToList(),
                 baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
-                blackCodeIsTrue = create.Code == 0 ? true : false
+                blackCodeIsTrue = create.Code == 0 ? true : false,
+                hotelIsTrue = hotelIsTrue,
             })) ;
         }
 

+ 51 - 1
OASystem/OASystem.Domain/Dtos/Groups/DecreasePaymentsDto.cs

@@ -1,5 +1,7 @@
-using System;
+using OASystem.Domain.Entities.Groups;
+using System;
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -157,4 +159,52 @@ namespace OASystem.Domain.Dtos.Groups
 
         public int Id { get; set; }
     }
+
+    public class AssociateSupplierDto
+    {
+        public string param { get; set; }
+    }
+
+    public class ProductComparer : IEqualityComparer<Grp_DecreasePayments>
+    {
+        public bool Equals(Grp_DecreasePayments x, Grp_DecreasePayments y)
+        {
+            if (Object.ReferenceEquals(x,y))
+            {
+                return true;
+            }
+
+            var xStr = 
+                x.SupplierAddress +
+                x.SupplierArea +
+                x.SupplierContact +
+                x.SupplierContactNumber +
+                x.SupplierEmail +
+                x.SupplierName +
+                x.SupplierSocialAccount +
+                x.SupplierTypeId;
+
+            var yStr =
+                y.SupplierAddress +
+                y.SupplierArea +
+                y.SupplierContact +
+                y.SupplierContactNumber +
+                y.SupplierEmail +
+                y.SupplierName +
+                y.SupplierSocialAccount +
+                y.SupplierTypeId;
+
+            if (xStr == yStr)
+            {
+                return true;
+            }
+
+            return false;
+        }
+
+        public int GetHashCode([DisallowNull] Grp_DecreasePayments product)
+        {
+            return 0;
+        }
+    }
 }