|
@@ -44,6 +44,8 @@ using System.Data.OleDb;
|
|
|
using Org.BouncyCastle.Crypto;
|
|
|
using OfficeOpenXml;
|
|
|
using Org.BouncyCastle.Asn1.Crmf;
|
|
|
+using EyeSoft.Extensions;
|
|
|
+using System.Collections;
|
|
|
|
|
|
namespace OASystem.API.Controllers
|
|
|
{
|
|
@@ -4510,5 +4512,222 @@ Group by PriceType ", dto.diId);
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
+
|
|
|
+ #region 提成计算
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public IActionResult ComputeRoyalties(ComputeRoyaltiesDto dto)
|
|
|
+ {
|
|
|
+ var jw = JsonView(false);
|
|
|
+ var userId = dto.UserId;
|
|
|
+ var user = _sqlSugar.Queryable<Sys_Users>().First(x=>x.Id == userId);
|
|
|
+ if (user == null)
|
|
|
+ {
|
|
|
+ jw.Msg = "暂无该用户!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+ if (!DateTime.TryParse(dto.StartDate,out DateTime StartDateTime))
|
|
|
+ {
|
|
|
+ jw.Msg = "开始时间格式有误!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+ if (!DateTime.TryParse(dto.EndDate, out DateTime EndDateTime))
|
|
|
+ {
|
|
|
+ jw.Msg = "结束时间格式有误!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+ if (DateTime.Compare(StartDateTime,EndDateTime) > 0)
|
|
|
+ {
|
|
|
+ jw.Msg = "开始时间大于结束时间!";
|
|
|
+ return Ok(jw);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int[] AirTicket = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 24).Select(x => x.Id).ToArray();
|
|
|
+
|
|
|
+
|
|
|
+ int[] Hotel = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 25).Select(x => x.Id).ToArray();
|
|
|
+
|
|
|
+
|
|
|
+ int [] OP = _sqlSugar.Queryable<Sys_Users>().Where(x=>x.IsDel == 0 && x.JobPostId == 28).Select(x=>x.Id).ToArray();
|
|
|
+
|
|
|
+
|
|
|
+ int [] Invitation = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 27).Select(x => x.Id).ToArray();
|
|
|
+
|
|
|
+
|
|
|
+ int[] Visa = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0 && x.JobPostId == 26 ).Select(x => x.Id).ToArray();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ArrayList resultArr = new ArrayList();
|
|
|
+
|
|
|
+ var teamLv = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.STid == 56 && x.IsDel == 0).ToList();
|
|
|
+
|
|
|
+ if (AirTicket.Contains(userId))
|
|
|
+ {
|
|
|
+ var listAir = _sqlSugar.Queryable<Grp_AirTicketReservations, Grp_DelegationInfo, Grp_CreditCardPayment>((x, a, b) => new
|
|
|
+ JoinQueryInfos(
|
|
|
+ JoinType.Left, a.Id == x.DIId ,
|
|
|
+ JoinType.Left, b.CTable == 85 && b.CId == x.Id )
|
|
|
+ ).Where((x, a, b) => x.IsDel == 0 && x.CreateUserId == userId && (b.IsAuditGM == 1 || b.IsAuditGM == 3)
|
|
|
+ && a.IsDel == 0 && a.VisitDate > StartDateTime && a.VisitDate < EndDateTime && b.IsDel == 0)
|
|
|
+ .Select((x, a, b) => new
|
|
|
+ {
|
|
|
+ x.FlightsDescription,
|
|
|
+ a.Id,
|
|
|
+ a.TeamName,
|
|
|
+ a.VisitDate,
|
|
|
+ a.TeamLevSId,
|
|
|
+ a.VisitPNumber,
|
|
|
+ x.Price,
|
|
|
+ x.ClientName,
|
|
|
+ x.ClientNum,
|
|
|
+ x.FlightsCode,
|
|
|
+ }).ToList();
|
|
|
+
|
|
|
+ var groupByid = listAir.GroupBy(x => x.Id);
|
|
|
+ foreach (var airArr in groupByid)
|
|
|
+ {
|
|
|
+ var groupAirCount = 0;
|
|
|
+ var infos = new ArrayList();
|
|
|
+ foreach (var air in airArr)
|
|
|
+ {
|
|
|
+ var airCount = 0;
|
|
|
+
|
|
|
+ if (air.FlightsDescription.IsNullOrWhiteSpace())
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (air.ClientName.Contains("-1") || air.ClientName.Contains("行程单") || air.FlightsCode.Contains("行程单"))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ string errMsg = string.Empty;
|
|
|
+
|
|
|
+ if (air.FlightsDescription.Contains("\r\n"))
|
|
|
+ {
|
|
|
+ var rowCode = Regex.Split(air.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase).Where(x=>!string.IsNullOrWhiteSpace(x)).ToArray();
|
|
|
+ for (int i = 0; i < rowCode.Length; i++)
|
|
|
+ {
|
|
|
+ if (i != 0)
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var columnValue = rowCode[i].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
|
|
|
+ string day = columnValue[2].Substring(2, 2);
|
|
|
+ string monthAbbreviations = columnValue[2].Substring(4, 3).ToUpper();
|
|
|
+ monthAbbreviations = GeneralMethod.GetLonger(monthAbbreviations);
|
|
|
+ string EndHHmm = columnValue[5].Substring(0, 2) + ":" + columnValue[5].Substring(2, 2);
|
|
|
+ DateTime EndData = DateTime.Parse($"{DateTime.Now.Year}-{monthAbbreviations}-{day} {EndHHmm}");
|
|
|
+
|
|
|
+ var spDotandEmpty1 = rowCode[i - 1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
|
|
|
+ string day1 = spDotandEmpty1[2].Substring(2, 2);
|
|
|
+ string monthAbbreviations1 = spDotandEmpty1[2].Substring(4, 3).ToUpper();
|
|
|
+ monthAbbreviations1 = GeneralMethod.GetLonger(monthAbbreviations1);
|
|
|
+ string HHmm = spDotandEmpty1[6].Substring(0, 2) + ":" + spDotandEmpty1[6].Substring(2, 2);
|
|
|
+ DateTime data = DateTime.Parse($"{DateTime.Now.Year}-{monthAbbreviations1}-{day1} {HHmm}");
|
|
|
+
|
|
|
+ TimeSpan t3 = EndData - data;
|
|
|
+ double getHour = t3.TotalHours;
|
|
|
+
|
|
|
+ if (getHour >= 6)
|
|
|
+ {
|
|
|
+ if (air.Price > 0)
|
|
|
+ {
|
|
|
+ airCount += 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ airCount -= 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ errMsg = "机票行程代码格式有误!解析失败!" + $"({ex.Message})";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (air.Price > 0)
|
|
|
+ {
|
|
|
+ airCount += 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ airCount -= 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (air.Price > 0)
|
|
|
+ {
|
|
|
+ airCount++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ airCount--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ string info = $"航班{air.FlightsCode} {(air.Price > 0 ? "" : "此笔为退费!")} 人数为{air.ClientNum} 有效段数为{airCount} 总段数为{airCount * air.ClientNum}";
|
|
|
+ if (!string.IsNullOrWhiteSpace(errMsg))
|
|
|
+ {
|
|
|
+ info = $"航班{air.FlightsCode} " + errMsg ;
|
|
|
+ }
|
|
|
+ infos.Add(info);
|
|
|
+ groupAirCount += airCount * air.ClientNum;
|
|
|
+ }
|
|
|
+ var groupinfo = listAir.First(x => x.Id == airArr.Key);
|
|
|
+ string temp = "本团人数" + Convert.ToInt32(groupinfo.VisitPNumber) + ",该人员" + user.CnName + "共订航段数" + groupAirCount.ToString() + ",每程航班提成为10元," + user.CnName + "提成共" + (groupAirCount * 10).ToString("#0.00");
|
|
|
+ resultArr.Add(new
|
|
|
+ {
|
|
|
+ groupinfo.TeamName,
|
|
|
+ groupinfo.Id,
|
|
|
+ chiArr = infos,
|
|
|
+ teamLvStr = teamLv.Find(x=>x.Id == groupinfo.TeamLevSId)?.Name,
|
|
|
+ groupinfo.VisitDate,
|
|
|
+ temp,
|
|
|
+ price = (groupAirCount * 10),
|
|
|
+ }) ;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (Hotel.Contains(userId))
|
|
|
+ {
|
|
|
+ var listHotel = _sqlSugar.Queryable<Grp_HotelReservations, Grp_DelegationInfo>((x, a) => x.DiId == a.Id)
|
|
|
+ .Where((x, a) => x.IsDel == 0 && x.CreateUserId == userId && a.VisitDate > StartDateTime && a.VisitDate < EndDateTime && a.IsDel == 0).ToList();
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (OP.Contains(userId))
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ jw.Data = resultArr;
|
|
|
+ if (resultArr.Count > 0)
|
|
|
+ {
|
|
|
+ jw.Code = 200;
|
|
|
+ jw.Msg = "success!";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ jw.Msg = "暂无数据!";
|
|
|
+ }
|
|
|
+
|
|
|
+ return Ok(jw);
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|