|
@@ -503,7 +503,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
|
|
|
item.ServiceQuotedPrice = item.PayMoney;
|
|
|
item.PayThenMoney = Math.Round(item.PayPercentage/100 * item.ServiceQuotedPrice, 2);
|
|
|
- item.RemainingBalance = Math.Round(item.ServiceQuotedPrice- item.PayPercentage / 100 * item.ServiceQuotedPrice);
|
|
|
+ item.RemainingBalance = Math.Round(item.ServiceQuotedPrice- item.PayPercentage / 100 * item.ServiceQuotedPrice,2);
|
|
|
if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
|
|
|
else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
|
|
|
else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
|
|
@@ -539,7 +539,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
|
|
|
item.ServiceQuotedPrice = item.PayMoney;
|
|
|
item.PayThenMoney = Math.Round(item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
|
|
|
- item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice);
|
|
|
+ item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice,2);
|
|
|
Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == item.PayDid);
|
|
|
if (s != null)
|
|
|
{
|
|
@@ -606,119 +606,154 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
if (carTouristList.Count > 0)
|
|
|
{
|
|
|
- //#region load
|
|
|
-
|
|
|
-
|
|
|
- ////车超时费
|
|
|
- ////餐费和三公经费那个表做完匹配后也放进超支表里
|
|
|
- //DataTable tb = new DataTable();
|
|
|
- //tb.Columns.Add("日期", typeof(DateTime));
|
|
|
- //tb.Columns.Add("费用", typeof(decimal));
|
|
|
- //tb.Columns.Add("币种", typeof(string));
|
|
|
- //var addsTourClientList = new List<Grp_TourClientList>();
|
|
|
- //var carExtraList = carTouristList.Where(x => x.SId == 982).ToList();
|
|
|
- //var mealPriceList = carTouristList.Where(x => x.SId == 93 || x.SId == 988 || x.SId == 989).GroupBy(x => x.DatePrice).ToList();
|
|
|
- //mealPriceList.ForEach(x =>
|
|
|
- //{
|
|
|
- // var row = tb.NewRow();
|
|
|
- // row["日期"] = x.Key;
|
|
|
- // row["费用"] = x.Sum(x => x.Price * x.Count);
|
|
|
- // row["币种"] = x.FirstOrDefault()?.Currency;
|
|
|
- // tb.Rows.Add(row);
|
|
|
- //});
|
|
|
-
|
|
|
- ////限制只能选择地区
|
|
|
+ #region load
|
|
|
+
|
|
|
+ //车超时费
|
|
|
+ //餐费和三公经费那个表做完匹配后也放进超支表里
|
|
|
+ DataTable tb = new DataTable();
|
|
|
+ tb.Columns.Add("日期", typeof(DateTime));
|
|
|
+ tb.Columns.Add("费用", typeof(decimal));
|
|
|
+ tb.Columns.Add("币种", typeof(string));
|
|
|
+ var addsTourClientList = new List<Grp_TourClientList>();
|
|
|
+ var carExtraList = carTouristList.Where(x => x.SId == 982 && x.Price != 0).ToList();
|
|
|
+ var mealPriceList = carTouristList.Where(x => (x.SId == 93 || x.SId == 988 || x.SId == 989) && x.Price != 0).GroupBy(x => x.DatePrice).ToList();
|
|
|
+ mealPriceList.ForEach(x =>
|
|
|
+ {
|
|
|
+ var row = tb.NewRow();
|
|
|
+ row["日期"] = x.Key;
|
|
|
+ row["费用"] = x.Sum(x => x.Price * x.Count);
|
|
|
+ row["币种"] = x.FirstOrDefault()?.Currency;
|
|
|
+ tb.Rows.Add(row);
|
|
|
+ });
|
|
|
|
|
|
+ //限制只能选择地区
|
|
|
+ var opSingle = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(x=>x.Id == dto.CTGGRId);
|
|
|
+ var opSingleCityId = 0;
|
|
|
+ Grp_NationalTravelFee cityPrice = null;
|
|
|
|
|
|
- ////三公费用
|
|
|
- //var cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
|
|
|
- // !string.IsNullOrEmpty(x.City) && x.City.Contains("")
|
|
|
- //).First();
|
|
|
+ //三公费用
|
|
|
+ if (int.TryParse(opSingle.Area,out opSingleCityId))
|
|
|
+ {
|
|
|
+ cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
|
|
|
+ x.Id == opSingleCityId
|
|
|
+ ).First();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cityPrice = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x =>
|
|
|
+ !string.IsNullOrEmpty(x.City) && x.City.Contains(opSingle.Area)
|
|
|
+ ).First();
|
|
|
+ }
|
|
|
|
|
|
- ////超支费用表(数据添加) Fin_GroupExtraCost
|
|
|
- //List<Fin_GroupExtraCost> groupExtraCostsArr = new List<Fin_GroupExtraCost>();
|
|
|
+ //超支费用表(数据添加) Fin_GroupExtraCost
|
|
|
+ List<Fin_GroupExtraCost> groupExtraCostsArr = new List<Fin_GroupExtraCost>();
|
|
|
|
|
|
- ////币种
|
|
|
- //var currOpResult = await _setDataRep.PostCurrencyByDiid(carTouristList[0].DiId, 79, carTouristList[0].Currency);
|
|
|
- //var currOp = currOpResult.Code == 0 ? (currOpResult.Data as CurrencyInfo) == null ? 1 : (currOpResult.Data as CurrencyInfo).Rate : 1;
|
|
|
- //var cityCurrResult = await _setDataRep.PostCurrencyByDiid(carTouristList[0].DiId, 79, cityPrice.Currency);
|
|
|
- //var cityCurr = cityCurrResult.Code == 0 ? (cityCurrResult.Data as CurrencyInfo) == null ? 1 : (cityCurrResult.Data as CurrencyInfo).Rate : 1;
|
|
|
- //var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId);
|
|
|
+ var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId);
|
|
|
+ if (di == null)
|
|
|
+ {
|
|
|
+ result.Code = -1;
|
|
|
+ result.Msg = "无该团组信息!";
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
- //if (di == null)
|
|
|
- //{
|
|
|
- // result.Code = -1;
|
|
|
- // result.Msg = "无该团组信息!";
|
|
|
- // return result;
|
|
|
- //}
|
|
|
+ if (carExtraList.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in carExtraList)
|
|
|
+ {
|
|
|
+ groupExtraCostsArr.Add(new Fin_GroupExtraCost
|
|
|
+ {
|
|
|
+ Price = item.Price,
|
|
|
+ CreateTime = DateTime.Now,
|
|
|
+ CreateUserId = dto.CreateUserId,
|
|
|
+ Coefficient = 1,
|
|
|
+ DiId = dto.DiId,
|
|
|
+ PriceCurrency = item.Currency,
|
|
|
+ PriceName = di.TeamName + "车超时费(地接导入)",
|
|
|
+ PriceType = 1050,
|
|
|
+ PriceDt = item.DatePrice.ObjToDate(),
|
|
|
+ PriceSum = item.Price * item.Count,
|
|
|
+ PriceCount = item.Count,
|
|
|
+ FilePath = string.Empty,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ if (cityPrice != null)
|
|
|
+ {
|
|
|
+ //币种
|
|
|
+ var currOpResult = await _setDataRep.PostCurrencyByDiid(dto.DiId, 79, carTouristList[0].Currency);
|
|
|
+ var currOp = currOpResult.Code == 0 ? (currOpResult.Data as CurrencyInfo) == null ? 1 : (currOpResult.Data as CurrencyInfo)!.Rate : 1;
|
|
|
+ var cityCurrResult = await _setDataRep.PostCurrencyByDiid(dto.DiId, 79, cityPrice.Currency);
|
|
|
+ var cityCurr = cityCurrResult.Code == 0 ? (cityCurrResult.Data as CurrencyInfo) == null ? 1 : (cityCurrResult.Data as CurrencyInfo)!.Rate : 1;
|
|
|
|
|
|
- //if (carExtraList.Count > 0)
|
|
|
- //{
|
|
|
- // foreach (var item in carExtraList)
|
|
|
- // {
|
|
|
- // groupExtraCostsArr.Add(new Fin_GroupExtraCost
|
|
|
- // {
|
|
|
- // Price = item.Price * item.Count,
|
|
|
- // CreateTime = DateTime.Now,
|
|
|
- // CreateUserId = dto.CreateUserId,
|
|
|
- // Coefficient = 1,
|
|
|
- // DiId = dto.DiId,
|
|
|
- // PriceCurrency = item.Currency,
|
|
|
- // PriceName = di.TeamName + "车超时费(地接导入)",
|
|
|
- // PriceType = 1050,
|
|
|
- // PriceDt = item.DatePrice.ObjToDate(),
|
|
|
- // });
|
|
|
- // }
|
|
|
- //}
|
|
|
+ if (tb.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (DataRow item in tb.Rows)
|
|
|
+ {
|
|
|
+ decimal foodCost = 1;
|
|
|
+ if (!decimal.TryParse(cityPrice.FoodCost, out foodCost))
|
|
|
+ {
|
|
|
+ //三公费用 ( 城市餐费用有问题! )
|
|
|
+ }
|
|
|
|
|
|
+ var price = Convert.ToDecimal(item["费用"]);
|
|
|
+ if (item["币种"].ToString() != cityPrice.Currency.ToString()) //币种不相同
|
|
|
+ {
|
|
|
+ //全部转换为rmb;
|
|
|
+ item["费用"] = price * currOp;
|
|
|
+ cityPrice.FoodCost = (foodCost * cityCurr).ToString("F2");
|
|
|
|
|
|
- //if (tb.Rows.Count > 0)
|
|
|
- //{
|
|
|
- // foreach (DataRow item in tb.Rows)
|
|
|
- // {
|
|
|
- // decimal foodCost = 1;
|
|
|
- // if (!decimal.TryParse(cityPrice.FoodCost, out foodCost))
|
|
|
- // {
|
|
|
- // //三公费用 ( 城市餐费用有问题! )
|
|
|
- // }
|
|
|
+ item["币种"] = "836";
|
|
|
+ cityPrice.Currency = 836;
|
|
|
+ }
|
|
|
|
|
|
- // var price = Convert.ToDecimal(item["费用"]);
|
|
|
- // if (item["币种"].ToString() != cityPrice.Currency.ToString()) //币种不相同
|
|
|
- // {
|
|
|
- // //全部转换为rmb;
|
|
|
- // item["费用"] = price * currOp;
|
|
|
- // cityPrice.FoodCost = (foodCost * cityCurr).ToString("F2");
|
|
|
+ if (price > foodCost)
|
|
|
+ {
|
|
|
+ //每天费用大于三公费用
|
|
|
+ groupExtraCostsArr.Add(new Fin_GroupExtraCost
|
|
|
+ {
|
|
|
+ Price = price - foodCost,
|
|
|
+ CreateTime = DateTime.Now,
|
|
|
+ CreateUserId = dto.CreateUserId,
|
|
|
+ Coefficient = 1,
|
|
|
+ DiId = dto.DiId,
|
|
|
+ PriceCurrency = cityPrice.Currency,
|
|
|
+ PriceName = di.TeamName + "餐费(地接导入)",
|
|
|
+ PriceType = 1049,
|
|
|
+ PriceDt = Convert.ToDateTime(item["日期"]),
|
|
|
+ PriceSum = price - foodCost,
|
|
|
+ PriceCount = 1,
|
|
|
+ FilePath = string.Empty,
|
|
|
+ });
|
|
|
|
|
|
- // item["币种"] = "836";
|
|
|
- // cityPrice.Currency = 836;
|
|
|
- // }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // if (price > foodCost)
|
|
|
- // {
|
|
|
- // //每天费用大于三公费用
|
|
|
- // groupExtraCostsArr.Add(new Fin_GroupExtraCost
|
|
|
- // {
|
|
|
- // Price = price - foodCost,
|
|
|
- // CreateTime = DateTime.Now,
|
|
|
- // CreateUserId = dto.CreateUserId,
|
|
|
- // Coefficient = 1,
|
|
|
- // DiId = dto.DiId,
|
|
|
- // PriceCurrency = cityPrice.Currency,
|
|
|
- // PriceName = di.TeamName + "餐费(地接导入)",
|
|
|
- // PriceType = 1049,
|
|
|
- // PriceDt = Convert.ToDateTime(item["日期"]),
|
|
|
- // });
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
+ var isTrue = false;
|
|
|
+ if (groupExtraCostsArr.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (var item in groupExtraCostsArr)
|
|
|
+ {
|
|
|
+ var QuerySgin = _sqlSugar.Queryable<Fin_GroupExtraCost>().Where(x => x.PriceName == item.PriceName && x.DiId == item.DiId && x.IsDel == 0).First();
|
|
|
+ if (QuerySgin == null)
|
|
|
+ {
|
|
|
+ isTrue = _sqlSugar.Insertable<Fin_GroupExtraCost>(item).ExecuteCommand() > 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.Id = QuerySgin.Id;
|
|
|
+ isTrue = _sqlSugar.Updateable<Fin_GroupExtraCost>(QuerySgin).IgnoreColumns(x => new
|
|
|
+ {
|
|
|
+ x.CreateTime,
|
|
|
+ x.CreateUserId,
|
|
|
+ }).ExecuteCommand() > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //if (groupExtraCostsArr.Count > 0)
|
|
|
- //{
|
|
|
- // _sqlSugar.Insertable<Fin_GroupExtraCost>(groupExtraCostsArr);
|
|
|
- //}
|
|
|
- //#endregion
|
|
|
+ #endregion
|
|
|
}
|
|
|
|
|
|
|
|
@@ -747,6 +782,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
Count = item.Count,
|
|
|
Units = item.Units,
|
|
|
}).ExecuteCommandAsync();
|
|
|
+
|
|
|
if (CTable==0)
|
|
|
{
|
|
|
RollbackTran();
|
|
@@ -759,7 +795,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
//List<Grp_CarTouristGuideGroundReservationsContent> carTouristListEnd = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.DiId==dto.DiId && a.CTGGRId==dto.CTGGRId && a.IsDel==0).ToList();
|
|
|
Grp_CreditCardPayment c = new Grp_CreditCardPayment();
|
|
|
c.PaymentCurrency = dto.Currency;
|
|
|
- c.PayMoney = carTouristList.Sum(x => x.Price);
|
|
|
+ c.PayMoney = carTouristList.Sum(x => x.Price * x.Count);
|
|
|
c.PayPercentage = dto.PayPercentage;
|
|
|
c.ConsumptionDate= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
c.CTable = 79;
|
|
@@ -776,22 +812,37 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
c.RMBPrice = c.PayMoney;
|
|
|
c.DayRate = 1;
|
|
|
- Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 79);
|
|
|
- List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
|
|
|
- if (_TeamRate != null)
|
|
|
+
|
|
|
+ #region 老汇率获取
|
|
|
+ //Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 79);
|
|
|
+ //List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
|
|
|
+ //if (_TeamRate != null)
|
|
|
+ //{
|
|
|
+ // Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
|
|
|
+ // if (_SetData != null)
|
|
|
+ // {
|
|
|
+ // currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
|
|
|
+ // CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
|
|
|
+ // if (CurrencyRate != null)
|
|
|
+ // {
|
|
|
+ // c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
|
|
|
+ // c.DayRate = CurrencyRate.Rate;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ var rate = await _setDataRep.PostCurrencyByDiid(dto.DiId, dto.CTGGRId, dto.Currency);
|
|
|
+ if (rate.Code == 0)
|
|
|
{
|
|
|
- Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
|
|
|
- if (_SetData != null)
|
|
|
+ var rateData = rate.Data as CurrencyInfo;
|
|
|
+ if (rateData != null)
|
|
|
{
|
|
|
- currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
|
|
|
- CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
|
|
|
- if (CurrencyRate != null)
|
|
|
- {
|
|
|
- c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
|
|
|
- c.DayRate = CurrencyRate.Rate;
|
|
|
- }
|
|
|
+ c.RMBPrice = c.PayMoney * rateData.Rate;
|
|
|
+ c.DayRate = rateData.Rate;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a=>a.CId==dto.CTGGRId && a.IsDel==0 && a.CTable==79 && a.DIId==dto.DiId);
|
|
|
if (grp_CreditCard!=null)//修改
|
|
|
{
|
|
@@ -825,13 +876,12 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
return result = new Result() { Code = -2, Msg = "添加失败" };
|
|
|
}
|
|
|
}
|
|
|
- int CarTouristGuideCTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservations>().Where(a => a.Id == dto.CTGGRId && a.DiId == dto.DiId).SetColumns(a => new Grp_CarTouristGuideGroundReservations
|
|
|
+ int CarTouristGuideCTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservations>().Where(a => a.Id == dto.CTGGRId && a.DiId == dto.DiId && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservations
|
|
|
{
|
|
|
CId = dto.Currency,
|
|
|
ServiceQuotedPrice = c.PayMoney,
|
|
|
OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
|
|
|
SelectCheck = string.Join(',', dto.SelectCheck)
|
|
|
-
|
|
|
}).ExecuteCommandAsync();
|
|
|
|
|
|
if (CarTouristGuideCTable == 0)
|