|
@@ -768,23 +768,16 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
Count = item.Count,
|
|
|
}).ToList();
|
|
|
|
|
|
+ #region 旧数据处理
|
|
|
string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm ss");
|
|
|
-
|
|
|
var ids = carTouristList.Select(x1 => x1.Id);
|
|
|
-
|
|
|
- _ = _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(x => x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId).SetColumns(x => new Grp_CarTouristGuideGroundReservationsContent
|
|
|
+ _ = _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(x => x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId && !ids.Contains(x.Id)).SetColumns(x => new Grp_CarTouristGuideGroundReservationsContent
|
|
|
{
|
|
|
IsDel = 1,
|
|
|
- DeleteTime = time ,
|
|
|
+ DeleteTime = time,
|
|
|
DeleteUserId = dto.CreateUserId,
|
|
|
- }) .ExecuteCommand();
|
|
|
-
|
|
|
- _ = _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(x => x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId && ids.Contains(x.Id)).SetColumns(x => new Grp_CarTouristGuideGroundReservationsContent
|
|
|
- {
|
|
|
- IsDel = 0,
|
|
|
- DeleteTime = "",
|
|
|
- DeleteUserId = null,
|
|
|
}).ExecuteCommand();
|
|
|
+ #endregion
|
|
|
|
|
|
if (carTouristList.Count > 0)
|
|
|
{
|
|
@@ -838,69 +831,30 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
List<Fin_GroupExtraCost> groupExtraCostsArr = new List<Fin_GroupExtraCost>();
|
|
|
List<List<Fin_GroupExtraCost>> enterOverspendArr = new List<List<Fin_GroupExtraCost>>();
|
|
|
|
|
|
- var setDataArr = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 17).ToList();
|
|
|
- var setDataCurrArr = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
|
|
|
- var number = 0; //人数
|
|
|
var aMeal = cityPrice.FoodCost.ObjToDecimal() / 2; //一顿三公费用
|
|
|
- var findSsetDataCurr = setDataCurrArr.Find(q => q.Id == dto.Currency);
|
|
|
- var printRate = 1M;
|
|
|
-
|
|
|
- if (cityPrice.Currency != dto.Currency)
|
|
|
- {
|
|
|
- printRate = dto.Rate;
|
|
|
- findSsetDataCurr = setDataCurrArr.Find(q => q.Id == dto.toCurr);
|
|
|
- }
|
|
|
+ var findSetDataCurr = _sqlSugar.Queryable<Sys_SetData>().First(q => q.Id == dto.toCurr && q.IsDel == 0);
|
|
|
|
|
|
foreach (var item in arr)
|
|
|
{
|
|
|
- var a = carTouristList.Where(x => x.SId == item.Item1 && x.Price != 0).Select(x => {
|
|
|
-
|
|
|
- string remake = x.Remark;
|
|
|
-
|
|
|
- //餐费超支备注额外处理
|
|
|
- if (mealsDic.Values.Contains(item.Item1))
|
|
|
- {
|
|
|
- var keyId = mealsDic.FirstOrDefault(q => q.Value == item.Item1).Key;
|
|
|
-
|
|
|
- //今日一顿餐食费用 (今日一顿餐费 + 今日一顿超支费用)
|
|
|
- var dayMealPrice = carTouristList.Where(q => q.SId == keyId && q.Price != 0 &&
|
|
|
- DateTime.Compare(x.DatePrice.ObjToDate(),q.DatePrice.ObjToDate()) == 0).Sum( q => q.Price) + x.Price;
|
|
|
-
|
|
|
- var findSetData = setDataArr.Find(q => q.Id == keyId);
|
|
|
-
|
|
|
- if (di.VisitPNumber > 1 && x.Count == 1)
|
|
|
- {
|
|
|
- number = di.VisitPNumber;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- number = x.Count;
|
|
|
- }
|
|
|
-
|
|
|
- dayMealPrice = dayMealPrice / number * printRate; //转三公币种
|
|
|
- var price = (int)Math.Round((dayMealPrice * number) - (aMeal * number));
|
|
|
- remake = $"{x.DatePrice?.ToString("M/d")} {findSetData?.Name}{findSsetDataCurr?.Name} {(int)Math.Round(dayMealPrice * number)} - 财政{aMeal} * {number} = {findSsetDataCurr?.Name}{price}";
|
|
|
- }
|
|
|
-
|
|
|
- return new Fin_GroupExtraCost
|
|
|
- {
|
|
|
- Coefficient = item.Item4,
|
|
|
- CreateTime = DateTime.Now,
|
|
|
- CreateUserId = dto.CreateUserId,
|
|
|
- DiId = dto.DiId,
|
|
|
- FilePath = string.Empty,
|
|
|
- IsDel = 0,
|
|
|
- PriceCount = x.Count,
|
|
|
- Price = x.Price,
|
|
|
- PriceDt = x.DatePrice.ObjToDate(),
|
|
|
- PriceCurrency = x.Currency,
|
|
|
- PriceSum = x.Count * x.Price,
|
|
|
- PriceName = di.TeamName + "-" + priceCity + "-" + $"{item.Item2}(地接导入)",
|
|
|
- PriceType = 1028,
|
|
|
- PriceDetailType = item.Item3,
|
|
|
- Remark = remake,
|
|
|
- Area = opSingleCityId
|
|
|
- };
|
|
|
+ var a = carTouristList.Where(x => x.SId == item.Item1 && x.Price != 0).Select(x => new Fin_GroupExtraCost
|
|
|
+ {
|
|
|
+ Coefficient = item.Item4,
|
|
|
+ CreateTime = DateTime.Now,
|
|
|
+ CreateUserId = dto.CreateUserId,
|
|
|
+ DiId = dto.DiId,
|
|
|
+ FilePath = string.Empty,
|
|
|
+ IsDel = 0,
|
|
|
+ PriceCount = x.Count,
|
|
|
+ Price = x.Price,
|
|
|
+ PriceDt = x.DatePrice.ObjToDate(),
|
|
|
+ PriceCurrency = x.Currency,
|
|
|
+ PriceSum = x.Count * x.Price,
|
|
|
+ PriceName = di.TeamName + "-" + priceCity + "-" + $"{item.Item2}(地接导入)",
|
|
|
+ PriceType = 1028,
|
|
|
+ PriceDetailType = item.Item3,
|
|
|
+ Remark = x.Remark,
|
|
|
+ Area = opSingleCityId
|
|
|
+
|
|
|
}).ToList();
|
|
|
|
|
|
if (a.Count > 0)
|
|
@@ -920,7 +874,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
string remake = string.Empty;
|
|
|
var exitMealCount = 0;
|
|
|
var price = 0M;
|
|
|
- var day = 0;
|
|
|
+ //var day = 0;
|
|
|
while (start <= end)
|
|
|
{
|
|
|
//查看每日每顿是否存在超支
|
|
@@ -935,23 +889,23 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
{
|
|
|
remake += $"{start.ToString("M/d")}午餐和晚餐,";
|
|
|
exitMealCount += 2;
|
|
|
- price += (aMeal * 2 * di.VisitPNumber) - (mealPriceWu * printRate) - (mealPriceWan * printRate);
|
|
|
+ price += (aMeal * 2 * di.VisitPNumber) - (mealPriceWu * dto.Rate) - (mealPriceWan * dto.Rate);
|
|
|
}
|
|
|
else if (isExistsWu)
|
|
|
{
|
|
|
remake += $"{start.ToString("M/d")}午餐,";
|
|
|
exitMealCount += 1;
|
|
|
- price += (aMeal * di.VisitPNumber) - (mealPriceWu * printRate);
|
|
|
+ price += (aMeal * di.VisitPNumber) - (mealPriceWu * dto.Rate);
|
|
|
}
|
|
|
else if (isExistsWan)
|
|
|
{
|
|
|
remake += $"{start.ToString("M/d")}晚餐,";
|
|
|
exitMealCount += 1;
|
|
|
- price += (aMeal * di.VisitPNumber) - (mealPriceWan * printRate);
|
|
|
+ price += (aMeal * di.VisitPNumber) - (mealPriceWan * dto.Rate);
|
|
|
}
|
|
|
|
|
|
start = start.AddDays(1);
|
|
|
- day++;
|
|
|
+ //day++;
|
|
|
}
|
|
|
|
|
|
var priceTypeArr = new int[] { 1061 , 1069 };
|
|
@@ -959,7 +913,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
if (exitMealCount > 0 && priceTypeArr.Contains(opSingle.PriceType))
|
|
|
{
|
|
|
remake = remake.TrimEnd(',');
|
|
|
- remake += $"财政 {findSsetDataCurr?.Name} {aMeal} * {di.VisitPNumber} * {exitMealCount}餐";
|
|
|
+ remake += $"财政 {findSetDataCurr?.Name} {aMeal} * {di.VisitPNumber} * {exitMealCount}餐";
|
|
|
int priceInt = (int)Math.Round(price / di.VisitPNumber / exitMealCount);
|
|
|
groupExtraCostsArr.Add(new Fin_GroupExtraCost
|
|
|
{
|
|
@@ -972,7 +926,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
PriceCount = di.VisitPNumber * exitMealCount * -1 ,
|
|
|
Price = priceInt,
|
|
|
PriceDt = opSingle.ServiceStartTime.ObjToDate(),
|
|
|
- PriceCurrency = findSsetDataCurr == null ? dto.toCurr: findSsetDataCurr.Id ,
|
|
|
+ PriceCurrency = findSetDataCurr == null ? dto.toCurr: findSetDataCurr.Id ,
|
|
|
PriceSum = (di.VisitPNumber * exitMealCount * -1) * priceInt,
|
|
|
PriceName = di.TeamName + "-" + priceCity + "-" + $"退餐费(地接导入)",
|
|
|
PriceType = 1028,
|
|
@@ -1049,51 +1003,64 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
- }
|
|
|
|
|
|
+ var existingRecords = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
|
|
|
+ .Where(a => carTouristList.Select(item => item.Id).Contains(a.Id) &&
|
|
|
+ a.CTGGRId == dto.CTGGRId &&
|
|
|
+ a.IsDel == 0)
|
|
|
+ .ToListAsync();
|
|
|
|
|
|
- foreach (var item in carTouristList)
|
|
|
- {
|
|
|
+ var existingRecordsDict = existingRecords.ToDictionary(a => (a.Id));
|
|
|
+
|
|
|
+ var insertList = new List<Grp_CarTouristGuideGroundReservationsContent>();
|
|
|
+ var updateList = new List<Grp_CarTouristGuideGroundReservationsContent>();
|
|
|
|
|
|
- Grp_CarTouristGuideGroundReservationsContent QueryData = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().First(a => a.SId == item.SId && a.Id == item.Id && a.DiId == item.DiId
|
|
|
- && a.CTGGRId == dto.CTGGRId && a.IsDel == 0);
|
|
|
- if (QueryData == null)
|
|
|
+ foreach (var item in carTouristList)
|
|
|
{
|
|
|
- int id = await _sqlSugar.Insertable(item).ExecuteReturnIdentityAsync();
|
|
|
- if (id == 0)
|
|
|
+ if (!existingRecordsDict.TryGetValue((item.Id), out var existingRecord))
|
|
|
{
|
|
|
- RollbackTran();
|
|
|
- return result = new Result() { Code = -2, Msg = "添加失败" };
|
|
|
+ insertList.Add(item);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ existingRecord.Price = item.Price;
|
|
|
+ existingRecord.PriceContent = item.PriceContent;
|
|
|
+ existingRecord.Currency = dto.Currency;
|
|
|
+ existingRecord.Remark = item.Remark;
|
|
|
+ existingRecord.DatePrice = item.DatePrice;
|
|
|
+ existingRecord.Count = item.Count;
|
|
|
+ existingRecord.Units = item.Units;
|
|
|
+ updateList.Add(existingRecord);
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ // 执行批量插入
|
|
|
+ if (insertList.Any())
|
|
|
{
|
|
|
- int CTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.Id == item.Id).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent
|
|
|
+ var insertIds = await _sqlSugar.Insertable(insertList).ExecuteReturnIdentityAsync();
|
|
|
+ if (insertIds == 0)
|
|
|
{
|
|
|
- Price = item.Price,
|
|
|
- PriceContent = item.PriceContent,
|
|
|
- Currency = dto.Currency,
|
|
|
- Remark = item.Remark,
|
|
|
- DatePrice = item.DatePrice,
|
|
|
- Count = item.Count,
|
|
|
- Units = item.Units,
|
|
|
- }).ExecuteCommandAsync();
|
|
|
-
|
|
|
- if (CTable == 0)
|
|
|
+ throw new Exception("添加失败,请稍后重试!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 执行批量更新
|
|
|
+ if (updateList.Any())
|
|
|
+ {
|
|
|
+ var updateCount = await _sqlSugar.Updateable(updateList).ExecuteCommandAsync();
|
|
|
+ if (updateCount == 0)
|
|
|
{
|
|
|
- RollbackTran();
|
|
|
- return result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
|
|
|
+ throw new Exception("修改失败,请稍后重试!");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Regex regex = new Regex("^[\u4e00-\u9fa5]{0,}$");
|
|
|
|
|
|
- //修改C表数据
|
|
|
- //List<Grp_CarTouristGuideGroundReservationsContent> carTouristListEnd = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.DiId==dto.DiId && a.CTGGRId==dto.CTGGRId && a.IsDel==0).ToList();
|
|
|
+ #region 修改C表数据
|
|
|
+
|
|
|
Grp_CreditCardPayment c = new Grp_CreditCardPayment();
|
|
|
c.PaymentCurrency = dto.Currency;
|
|
|
-
|
|
|
for (int i = 0; i < dto.SelectCheck.Count; i++)
|
|
|
{
|
|
|
if (!regex.IsMatch(dto.SelectCheck[i]))
|
|
@@ -1112,7 +1079,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
c.PayPercentage = dto.PayPercentage;
|
|
|
c.ConsumptionDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
c.CTable = 79;
|
|
@@ -1197,6 +1163,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #endregion
|
|
|
+
|
|
|
_ = 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,
|