|
@@ -5,6 +5,7 @@ using OASystem.Domain;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.Entities.Resource;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
+using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
@@ -31,6 +32,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -41,22 +43,31 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
if (diId < 1) { _view.Msg = MsgTips.DiId; return _view; }
|
|
|
if (dataId < 1) { _view.Msg = MsgTips.Id; return _view; }
|
|
|
|
|
|
+ var groupDetails = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).First();
|
|
|
+ if (groupDetails == null)
|
|
|
+ {
|
|
|
+ _view.Msg = $"团组信息为空,不可自动审核!";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
var stids = new List<int>() { 17, 66, 91 };
|
|
|
var setData = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && stids.Contains(x.STid)).ToList();
|
|
|
- string _teamCurrency = string.Empty;
|
|
|
|
|
|
- decimal _teamRate = 0.00M;
|
|
|
- var costContents = new List<GroupCostAuditView>();
|
|
|
- if (feeType != 4)
|
|
|
- {
|
|
|
- var groupInfo = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(x => x.IsDel == 0 && x.DiId == diId).First();
|
|
|
- if (groupInfo == null) { _view.Msg = $"团组成本信息未填写!"; return _view; }
|
|
|
- _teamCurrency = groupInfo.Currency;
|
|
|
- _teamRate = groupInfo.Rate;
|
|
|
+ var groupInfo = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(x => x.IsDel == 0 && x.DiId == diId).First();
|
|
|
+ if (groupInfo == null) { _view.Msg = $"团组成本信息未填写!"; return _view; }
|
|
|
+ string _teamCurrency = groupInfo.Currency;
|
|
|
+ decimal _teamRate = groupInfo.Rate;
|
|
|
|
|
|
-
|
|
|
- if (int.TryParse(_teamCurrency, out int currency)) _teamCurrency = setData.Find(x => x.Id == currency)?.Name ?? "";
|
|
|
+
|
|
|
+ if (int.TryParse(_teamCurrency, out int currency)) _teamCurrency = setData.Find(x => x.Id == currency)?.Name ?? "";
|
|
|
|
|
|
+ var costContents = new List<GroupCostAuditView>();
|
|
|
+ var subFeeTypeIds = new int[] {
|
|
|
+ 4,
|
|
|
+ 5,
|
|
|
+ };
|
|
|
+ if (!subFeeTypeIds.Contains(feeType))
|
|
|
+ {
|
|
|
string costContentSql = $"Select * From Grp_GroupCost";
|
|
|
costContents = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == diId).ToList();
|
|
|
|
|
@@ -88,7 +99,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (feeType == 1)
|
|
|
{
|
|
|
|
|
@@ -289,71 +300,71 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
|
|
|
var opCarCost = item.FirstOrDefault(x => x.SId == 91);
|
|
|
- if (opCarCost != null)
|
|
|
+ if (opCarCost != null)
|
|
|
if (opCarCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.CarFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
|
|
|
var opGuideCost = item.FirstOrDefault(x => x.SId == 92);
|
|
|
- if (opGuideCost != null)
|
|
|
+ if (opGuideCost != null)
|
|
|
if (opGuideCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opGuideScenicCost = item.FirstOrDefault(x => x.SId == 94);
|
|
|
- if (opGuideScenicCost != null)
|
|
|
+ if (opGuideScenicCost != null)
|
|
|
if (opGuideScenicCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideScenicFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opGuideTipCost = item.FirstOrDefault(x => x.SId == 95);
|
|
|
- if (opGuideTipCost != null)
|
|
|
+ if (opGuideTipCost != null)
|
|
|
if (opGuideTipCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideTipFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opGuideMealCost = item.FirstOrDefault(x => x.SId == 983);
|
|
|
- if (opGuideMealCost != null)
|
|
|
+ if (opGuideMealCost != null)
|
|
|
if (opGuideMealCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideMealFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opGuideRoomCost = item.FirstOrDefault(x => x.SId == 984);
|
|
|
- if (opGuideRoomCost != null)
|
|
|
+ if (opGuideRoomCost != null)
|
|
|
if (opGuideRoomCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideRoomFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opGuideTrafficCost = item.FirstOrDefault(x => x.SId == 985);
|
|
|
- if (opGuideTrafficCost != null)
|
|
|
+ if (opGuideTrafficCost != null)
|
|
|
if (opGuideTrafficCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.GuideTrafficFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
|
|
|
|
|
|
var opDriverCost = item.FirstOrDefault(x => x.SId == 979);
|
|
|
- if (opDriverCost != null)
|
|
|
+ if (opDriverCost != null)
|
|
|
if (opDriverCost.Price * _opRate > _teamRate * _opPayPercentage * opCostInfo.Sum(x => x.DriverFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opDriverTipCost = item.FirstOrDefault(x => x.SId == 980);
|
|
|
- if (opDriverTipCost != null)
|
|
|
+ if (opDriverTipCost != null)
|
|
|
if (opDriverTipCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.DriverTipFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opDriverMealCost = item.FirstOrDefault(x => x.SId == 981);
|
|
|
- if (opDriverMealCost != null)
|
|
|
+ if (opDriverMealCost != null)
|
|
|
if (opDriverMealCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.DriverMealFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opClientBreakfastCost = item.FirstOrDefault(x => x.SId == 988);
|
|
|
- if (opClientBreakfastCost != null)
|
|
|
+ if (opClientBreakfastCost != null)
|
|
|
if (opClientBreakfastCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ClientBreakfastFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opClientLunchCost = item.FirstOrDefault(x => x.SId == 93);
|
|
|
- if (opClientLunchCost != null)
|
|
|
+ if (opClientLunchCost != null)
|
|
|
if (opClientLunchCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ClientLunchFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opClientDinnerCost = item.FirstOrDefault(x => x.SId == 989);
|
|
|
- if (opClientDinnerCost != null)
|
|
|
+ if (opClientDinnerCost != null)
|
|
|
if (opClientDinnerCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ClientDinnerFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opScenicTicketCost = item.FirstOrDefault(x => x.SId == 990);
|
|
|
- if (opScenicTicketCost != null)
|
|
|
+ if (opScenicTicketCost != null)
|
|
|
if (opScenicTicketCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.ScenicTicketFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
var opDrinkSnackFruitCost = item.FirstOrDefault(x => x.SId == 991);
|
|
|
- if (opDrinkSnackFruitCost != null)
|
|
|
+ if (opDrinkSnackFruitCost != null)
|
|
|
if (opDrinkSnackFruitCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.DrinkSnackFruitFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
|
|
|
var opTranslatorCost = item.FirstOrDefault(x => x.SId == 994);
|
|
|
- if (opTranslatorCost != null)
|
|
|
+ if (opTranslatorCost != null)
|
|
|
if (opTranslatorCost.Price * _opRate * _opPayPercentage > _teamRate * opCostInfo.Sum(x => x.TranslatorFee) * _opPayPercentage) isAutoAudit = false;
|
|
|
|
|
|
|
|
@@ -397,9 +408,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
var isAutoAudit = false;
|
|
|
var currModule = 98;
|
|
|
- int groupSize = 0;
|
|
|
- var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).FirstAsync();
|
|
|
- if (groupDetails != null) groupSize = groupDetails.VisitPNumber;
|
|
|
+ int groupSize = groupDetails.VisitPNumber;
|
|
|
|
|
|
decimal otherSubTotal = costContents.Sum(x => x.TeFee);
|
|
|
decimal groupCostCNYTotal = costContents.Sum(x => x.TeFee) * _teamRate * groupSize;
|
|
@@ -496,13 +505,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
{
|
|
|
#region 保险费用录入自动审核
|
|
|
var currModule = 82;
|
|
|
- var groupDetails = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == diId).First();
|
|
|
- if (groupDetails == null)
|
|
|
- {
|
|
|
- _view.Msg = $"团组信息为空,不可自动审核!";
|
|
|
- return _view;
|
|
|
- }
|
|
|
-
|
|
|
var insuranceCountryCostData = _sqlSugar.Queryable<Res_BasicInsuranceCost>().Where(x => x.IsDel == 0).ToList();
|
|
|
if (!insuranceCountryCostData.Any())
|
|
|
{
|
|
@@ -601,11 +603,11 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
|
|
|
var ccpUpdate = _sqlSugar.Updateable<Grp_CreditCardPayment>()
|
|
|
- .SetColumns(it => it.IsAuditGM == 3)
|
|
|
- .SetColumns(it => it.AuditGMOperate == 4)
|
|
|
- .SetColumns(it => it.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
|
|
|
- .Where(s => s.DIId == diId && s.CTable == currModule && s.CId == dataId)
|
|
|
- .ExecuteCommand();
|
|
|
+ .SetColumns(it => it.IsAuditGM == 3)
|
|
|
+ .SetColumns(it => it.AuditGMOperate == 4)
|
|
|
+ .SetColumns(it => it.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
|
|
|
+ .Where(s => s.DIId == diId && s.CTable == currModule && s.CId == dataId)
|
|
|
+ .ExecuteCommand();
|
|
|
if (ccpUpdate > 0)
|
|
|
{
|
|
|
_view.Code = 200;
|
|
@@ -615,6 +617,148 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
return _view;
|
|
|
#endregion
|
|
|
}
|
|
|
+ else if (feeType == 5)
|
|
|
+ {
|
|
|
+ #region 机票费用自动审核只处理舱位相关的费用
|
|
|
+
|
|
|
+ var currModule = 85;
|
|
|
+ var auditFeeTypeIds = new List<int>() {
|
|
|
+ 457,
|
|
|
+ 458,
|
|
|
+ 459,
|
|
|
+ 460,
|
|
|
+ 1430,
|
|
|
+ 1431,
|
|
|
+ 1432,
|
|
|
+ };
|
|
|
+
|
|
|
+ var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
|
|
|
+ .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
|
|
|
+ .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
|
|
|
+ .Select((x,y) => new {
|
|
|
+ x.Id,
|
|
|
+ CcpId = y.Id,
|
|
|
+ x.Price,
|
|
|
+ x.CType,
|
|
|
+ x.ClientNum,
|
|
|
+ x.DIId
|
|
|
+ })
|
|
|
+ .FirstAsync();
|
|
|
+ if (airInfo == null)
|
|
|
+ {
|
|
|
+ _view.Msg = $"机票信息为空或费用类型不在自动审核范围内,不可自动审核!";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int ecoPaxCount = groupInfo.JJCRS,
|
|
|
+ firstClassCnt = groupInfo.TDCRS,
|
|
|
+ bizClassCnt = groupInfo.GWCRS;
|
|
|
+ decimal ecoCost = groupInfo.JJCCB,
|
|
|
+ firstCost = groupInfo.TDCCB,
|
|
|
+ bizCost = groupInfo.GWCCB;
|
|
|
+ decimal ecoTotalCost = ecoPaxCount * ecoCost,
|
|
|
+ firstTotalCost = firstClassCnt * firstCost,
|
|
|
+ bizTotalCost = bizClassCnt * bizCost;
|
|
|
+
|
|
|
+ int currAirType = airInfo.CType;
|
|
|
+ int currAirTypeCnt = 0;
|
|
|
+
|
|
|
+ decimal currAirCost = 0.00M;
|
|
|
+
|
|
|
+
|
|
|
+ switch (airInfo.CType)
|
|
|
+ {
|
|
|
+
|
|
|
+ case 457:
|
|
|
+ currAirTypeCnt = groupInfo.TDCRS;
|
|
|
+ currAirCost = currAirTypeCnt * groupInfo.TDCCB;
|
|
|
+ break;
|
|
|
+
|
|
|
+ case 458:
|
|
|
+ currAirTypeCnt = groupInfo.GWCRS;
|
|
|
+ currAirCost = currAirTypeCnt * groupInfo.GWCCB;
|
|
|
+ break;
|
|
|
+ case 459:
|
|
|
+ currAirTypeCnt = groupInfo.JJCRS;
|
|
|
+ currAirCost = currAirTypeCnt * groupInfo.JJCCB;
|
|
|
+ break;
|
|
|
+ case 460:
|
|
|
+ currAirTypeCnt = groupInfo.JJCRS;
|
|
|
+ currAirCost = currAirTypeCnt * groupInfo.JJCCB;
|
|
|
+ break;
|
|
|
+ case 1430:
|
|
|
+ currAirTypeCnt = groupInfo.GWCRS;
|
|
|
+ currAirCost = currAirTypeCnt * groupInfo.GWCCB;
|
|
|
+ break;
|
|
|
+ case 1431:
|
|
|
+ currAirTypeCnt = groupInfo.TDCRS;
|
|
|
+ currAirCost = currAirTypeCnt * groupInfo.TDCCB;
|
|
|
+ break;
|
|
|
+ case 1432:
|
|
|
+ currAirTypeCnt = groupInfo.TDCRS;
|
|
|
+ currAirCost = currAirTypeCnt * groupInfo.TDCCB;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ _view.Msg = $"机票费用类型不在自动审核范围内,不可自动审核!";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+ var currAirTypeDatas = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
|
|
|
+ .Where(x => x.IsDel == 0 && x.DIId == diId && x.CType == airInfo.CType && x.ClientNum == currAirTypeCnt)
|
|
|
+ .ToListAsync();
|
|
|
+ var airTypeText = airInfo.CType switch
|
|
|
+ {
|
|
|
+ 457 => "头等舱",
|
|
|
+ 458 => "公务舱",
|
|
|
+ 459 => "超经舱",
|
|
|
+ 460 => "经济舱",
|
|
|
+ 1430 => "公务舱(实际经济舱)",
|
|
|
+ 1431 => "头等舱(实际公务舱)",
|
|
|
+ 1432 => "头等舱(实际经济舱)",
|
|
|
+ _ => "未知舱位"
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!currAirTypeDatas.Any())
|
|
|
+ {
|
|
|
+ _view.Msg = $"{airTypeText}机票费用数据未填写,不可自动审核!";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (!currAirTypeDatas.Any(x => x.Id == airInfo.CcpId))
|
|
|
+ {
|
|
|
+ _view.Msg = $"机票费用({airTypeText})超出团组成本费用";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ decimal currAirTypeFee = currAirTypeDatas.Sum(x => x.Price * x.ClientNum);
|
|
|
+ if (currAirTypeFee > currAirCost)
|
|
|
+ {
|
|
|
+ _view.Msg = $"机票费用({airTypeText})超出团组成本费用";
|
|
|
+ QuashAudit(currModule, diId, currAirTypeDatas.Select(x => x.Id).ToArray());
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ var upd = _sqlSugar.Updateable<Grp_CreditCardPayment>()
|
|
|
+ .SetColumns(x => x.IsAuditGM == 3)
|
|
|
+ .SetColumns(x => x.AuditGMOperate == 4)
|
|
|
+ .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
|
|
|
+ .Where(x => x.Id == airInfo.CcpId)
|
|
|
+ .ExecuteCommand();
|
|
|
+ if (upd > 0)
|
|
|
+ {
|
|
|
+ _view.Code = StatusCodes.Status200OK;
|
|
|
+ _view.Msg = "自动审核执行成功";
|
|
|
+ return _view;
|
|
|
+ }
|
|
|
+ _view.Msg = "自动审核执行失败";
|
|
|
+ return _view;
|
|
|
+
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
else _view.Msg = $"请传入有效的feeType参数";
|
|
|
|
|
|
return _view;
|
|
@@ -625,7 +769,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -653,7 +797,43 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private bool QuashAudit(int type, int diId, int[] dataId)
|
|
|
+ {
|
|
|
+
|
|
|
+ var ccpInfos = _sqlSugar.Queryable<Grp_CreditCardPayment>()
|
|
|
+ .Where(s => s.DIId == diId && s.CTable == type && dataId.Contains(s.CId) && s.IsAuditGM == 3)
|
|
|
+ .ToList();
|
|
|
+ if (ccpInfos.Any())
|
|
|
+ {
|
|
|
+ ccpInfos.ForEach(x =>
|
|
|
+ {
|
|
|
+ x.IsAuditGM = 0;
|
|
|
+ x.AuditGMOperate = 0;
|
|
|
+ x.AuditGMDate = string.Empty;
|
|
|
+ });
|
|
|
+
|
|
|
+ var ccpUpd = _sqlSugar.Updateable(ccpInfos)
|
|
|
+ .UpdateColumns(x => new { x.IsAuditGM, x.AuditGMOperate, x.AuditGMDate })
|
|
|
+ .ExecuteCommand();
|
|
|
+ if (ccpUpd > 0)
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|