HotelPriceRepository.cs 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. using AutoMapper;
  2. using MathNet.Numerics.Statistics.Mcmc;
  3. using MySqlX.XDevAPI.Common;
  4. using NPOI.SS.Formula.Functions;
  5. using OASystem.Domain;
  6. using OASystem.Domain.Dtos.Financial;
  7. using OASystem.Domain.Dtos.Groups;
  8. using OASystem.Domain.Dtos.Resource;
  9. using OASystem.Domain.Entities.Financial;
  10. using OASystem.Domain.Entities.Groups;
  11. using OASystem.Domain.ViewModels.Financial;
  12. using OASystem.Domain.ViewModels.Groups;
  13. using OASystem.Infrastructure.Repositories.Resource;
  14. using OASystem.Infrastructure.Tools;
  15. using SqlSugar;
  16. using StackExchange.Redis;
  17. using System;
  18. using System.Collections.Generic;
  19. using System.Linq;
  20. using System.Text;
  21. using System.Threading.Tasks;
  22. using static NPOI.HSSF.Util.HSSFColor;
  23. using Result = OASystem.Domain.Result;
  24. namespace OASystem.Infrastructure.Repositories.Groups
  25. {
  26. public class HotelPriceRepository : BaseRepository<Grp_HotelReservations, Grp_HotelReservations>
  27. {
  28. private readonly IMapper _mapper;
  29. private readonly Result _result;
  30. private readonly TeamRateRepository _teamRateRep;
  31. private readonly TourClientListRepository _tourClientListRep;
  32. private readonly HotelDataRepository _hotelDataRep;
  33. public HotelPriceRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep, TourClientListRepository tourClientListRep, HotelDataRepository hotelDataRep)
  34. :base(sqlSugar)
  35. {
  36. this._mapper = mapper;
  37. _result = new Result() { Code = -1, Msg = "操作失败!" };
  38. _teamRateRep = teamRateRep;
  39. _tourClientListRep = tourClientListRep;
  40. _hotelDataRep = hotelDataRep;
  41. }
  42. #region 保留
  43. /// <summary>
  44. /// 付款金额计算
  45. /// </summary>
  46. /// <param name="dto"></param>
  47. /// <returns></returns>
  48. public async Task<Result> HotelConversionAmounts(HotelReservationsCNYDto dto)
  49. {
  50. Result result = new Result() { Code = -2, Msg = "未知错误" };
  51. try
  52. {
  53. HotelReservationsView reservationsView=new HotelReservationsView();
  54. if ((dto.CardPriceCurrency == dto.GovernmentRentCurrency || dto.GovernmentRent == 0)
  55. && (dto.CardPriceCurrency == dto.CityTaxCurrency || dto.CityTax== 0))
  56. {
  57. reservationsView.CurrencyId = dto.CardPriceCurrency;
  58. reservationsView.Price=Convert.ToDecimal((dto.CardPrice+dto.GovernmentRent+dto.CityTax).ToString("F2"));
  59. reservationsView.CurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == dto.CardPriceCurrency).Name;
  60. return result = new Result() { Code = 0, Msg = "查询成功", Data = reservationsView };
  61. }
  62. else
  63. {
  64. Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 76);
  65. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  66. decimal CardPrice = 0.00M;
  67. decimal GovernmentRent = 0.00M;
  68. decimal CityTax = 0.00M;
  69. if (_TeamRate != null)
  70. {
  71. Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == dto.CardPriceCurrency);
  72. if (_SetData != null)
  73. {
  74. if (_SetData.Name=="CNY")
  75. {
  76. CardPrice = dto.CardPrice;
  77. }
  78. else
  79. {
  80. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  81. CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  82. if (CurrencyRate != null) CardPrice = dto.CardPrice * Convert.ToDecimal(CurrencyRate.Rate);
  83. else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
  84. }
  85. }
  86. else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
  87. Sys_SetData _SetData1 = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == dto.GovernmentRentCurrency);
  88. if (_SetData1 != null)
  89. {
  90. if (_SetData1.Name == "CNY")
  91. {
  92. GovernmentRent = dto.GovernmentRent;
  93. }
  94. else {
  95. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  96. CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData1.Name);
  97. if (CurrencyRate != null) GovernmentRent = dto.GovernmentRent * Convert.ToDecimal(CurrencyRate.Rate);
  98. else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
  99. }
  100. }
  101. else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
  102. Sys_SetData _SetData2 = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == dto.CityTaxCurrency);
  103. if (_SetData2 != null)
  104. {
  105. if (_SetData2.Name == "CNY")
  106. {
  107. CityTax = dto.CityTax;
  108. }
  109. else
  110. {
  111. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  112. CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData2.Name);
  113. if (CurrencyRate != null) CityTax = dto.CityTax * Convert.ToDecimal(CurrencyRate.Rate);
  114. else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
  115. }
  116. }
  117. else return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data = reservationsView };
  118. reservationsView.CurrencyId = 836;
  119. reservationsView.Price = Convert.ToDecimal((CardPrice + GovernmentRent + CityTax).ToString("F2"));
  120. reservationsView.CurrencyName ="CNY";
  121. return result = new Result() { Code = 0, Msg = "查询成功", Data = reservationsView };
  122. }
  123. else
  124. {
  125. return result = new Result() { Code = -1, Msg = "暂未设置团组汇率,请前往设置!", Data= reservationsView };
  126. }
  127. }
  128. }
  129. catch (Exception ex)
  130. {
  131. return result = new Result() { Code = -2, Msg = "未知错误" };
  132. throw;
  133. }
  134. }
  135. /// <summary>
  136. /// 根据团组id查询酒店数据
  137. /// </summary>
  138. /// <param name="dto"></param>
  139. /// <returns></returns>
  140. public async Task<Result> HotelReservationsByDiId(HotelReservationsByDiIdDto dto)
  141. {
  142. Result result = new Result() { Code = -2, Msg = "未知错误" };
  143. try
  144. {
  145. string UserId = "";
  146. List<Grp_GroupsTaskAssignment> gtaUIdList = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a => a.DIId == dto.DiId && a.IsDel == 0 && a.CTId == 76).ToList();
  147. foreach (Grp_GroupsTaskAssignment gta in gtaUIdList)
  148. UserId += gta.UId + ",";
  149. if (!string.IsNullOrWhiteSpace(UserId))
  150. {
  151. UserId = UserId.Substring(0, UserId.Length - 1);
  152. }
  153. else
  154. {
  155. UserId = "0";
  156. }
  157. string sqlWhere = string.Format(@"Where h.DiId={0} and h.IsDel={1} And h.CreateUserId in ({2})", dto.DiId, 0,UserId);
  158. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  159. int endIndex = startIndex + dto.PageSize - 1;
  160. if (dto.PortType == 1)
  161. {
  162. string sql = string.Format(@"select h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
  163. h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
  164. From Grp_HotelReservations h
  165. Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.isdel=0
  166. left Join Sys_SetData s on c.PaymentCurrency=s.Id
  167. left Join Sys_SetData s1 on h.GTId=s1.Id
  168. left Join Sys_Users u on u.Id=h.CreateUserId {0} order by c.IsAuditGM,c.PayPercentage desc", sqlWhere);
  169. List<HotelReservationsByDiIdView> hotelDataList = _sqlSugar.SqlQueryable<HotelReservationsByDiIdView>(sql).ToList();
  170. foreach (var item in hotelDataList)
  171. {
  172. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  173. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  174. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  175. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  176. if (!string.IsNullOrWhiteSpace(item.CheckInDate))
  177. {
  178. item.CheckInDate = DateTime.Parse(item.CheckInDate).ToString("yyyy-MM-dd");
  179. }
  180. if (!string.IsNullOrWhiteSpace(item.CheckOutDate))
  181. {
  182. item.CheckOutDate = DateTime.Parse(item.CheckOutDate).ToString("yyyy-MM-dd");
  183. }
  184. }
  185. return result = new Result() { Code = 0, Msg = "查询成功!", Data = hotelDataList };
  186. }
  187. else if (dto.PortType == 2 || dto.PortType == 3)
  188. {
  189. string sql = string.Format(@"Select * From (
  190. Select row_number() over (order by c.IsAuditGM,c.PayPercentage desc) as RowNumber,h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
  191. h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
  192. From Grp_HotelReservations h
  193. Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.isdel=0
  194. left Join Sys_SetData s on c.PaymentCurrency=s.Id
  195. left Join Sys_SetData s1 on h.GTId=s1.Id
  196. left Join Sys_Users u on u.Id=h.CreateUserId {0}
  197. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  198. List<HotelReservationsByDiIdView> hotelDataList = _sqlSugar.SqlQueryable<HotelReservationsByDiIdView>(sql).ToList();
  199. foreach (var item in hotelDataList)
  200. {
  201. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  202. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  203. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  204. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  205. if (!string.IsNullOrWhiteSpace(item.CheckInDate))
  206. {
  207. item.CheckInDate = DateTime.Parse(item.CheckInDate).ToString("yyyy-MM-dd");
  208. }
  209. if (!string.IsNullOrWhiteSpace(item.CheckOutDate))
  210. {
  211. item.CheckOutDate = DateTime.Parse(item.CheckOutDate).ToString("yyyy-MM-dd");
  212. }
  213. }
  214. string CountSql = string.Format(@"Select COUNT(1) as Count From (
  215. Select h.Id,s1.Name as GuestType,h.ReservationsNo,h.HotelName,h.CheckInDate,
  216. h.CheckOutDate,c.PayMoney,s.Name as PaymentCurrency,u.CnName as CreateUserName,c.IsAuditGM,h.CreateTime,h.Attachment
  217. From Grp_HotelReservations h
  218. Join Grp_CreditCardPayment c on h.Id=c.CId and c.CTable=76 and c.isdel=0
  219. left Join Sys_SetData s on c.PaymentCurrency=s.Id
  220. left Join Sys_SetData s1 on h.GTId=s1.Id
  221. left Join Sys_Users u on u.Id=h.CreateUserId {0}
  222. ) temp", sqlWhere);
  223. DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
  224. int count = dataCount.Count;
  225. float totalPage = (float)count / dto.PageSize;//总页数
  226. if (totalPage == 0) totalPage = 1;
  227. else totalPage = (int)Math.Ceiling((double)totalPage);
  228. ListViewBase<HotelReservationsByDiIdView> rst = new ListViewBase<HotelReservationsByDiIdView>();
  229. rst.DataList = hotelDataList;
  230. rst.DataCount = count;
  231. rst.CurrPageIndex = dto.PageIndex;
  232. rst.CurrPageSize = dto.PageSize;
  233. return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
  234. }
  235. else
  236. {
  237. return result = new Result() { Code = -2, Msg = "请传入PortType参数,1 Web 2 Android 3 IOS" };
  238. }
  239. }
  240. catch (Exception ex)
  241. {
  242. return result = new Result() { Code = -2, Msg = "未知错误" };
  243. throw;
  244. }
  245. }
  246. /// <summary>
  247. /// 根据酒店费用Id查询详细数据
  248. /// </summary>
  249. /// <param name="dto"></param>
  250. /// <returns></returns>
  251. public async Task<Result> HotelReservationsById(HotelReservationsByIdDto dto)
  252. {
  253. Result result = new Result() { Code = -2, Msg = "未知错误" };
  254. try
  255. {
  256. Grp_HotelReservations hotelReservationsById = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.IsDel == 0 && a.Id == dto.Id);
  257. HotelReservationsByIdView _hotelReservations = _mapper.Map<HotelReservationsByIdView>(hotelReservationsById);
  258. if (_hotelReservations!=null)
  259. {
  260. Sys_SetData GTId = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == hotelReservationsById.GTId);
  261. if (GTId != null) _hotelReservations.GtIdStr = GTId.Name;
  262. if (!string.IsNullOrWhiteSpace(_hotelReservations.CheckInDate))
  263. {
  264. _hotelReservations.CheckInDate = Convert.ToDateTime(hotelReservationsById.CheckInDate).ToString("yyyy-MM-dd");
  265. }
  266. if (!string.IsNullOrWhiteSpace(_hotelReservations.CheckOutDate))
  267. {
  268. _hotelReservations.CheckOutDate = Convert.ToDateTime(hotelReservationsById.CheckOutDate).ToString("yyyy-MM-dd");
  269. }
  270. Sys_SetData GovernmentRentCurrencyStr = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == hotelReservationsById.GovernmentRentCurrency);
  271. if (GovernmentRentCurrencyStr != null) _hotelReservations.GovernmentRentCurrencyStr = GovernmentRentCurrencyStr.Name;
  272. Sys_SetData CityTaxCurrencyStr = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == hotelReservationsById.CityTaxCurrency);
  273. if (CityTaxCurrencyStr != null) _hotelReservations.CityTaxCurrencyStr = CityTaxCurrencyStr.Name;
  274. if (_hotelReservations.CheckType == "") _hotelReservations.CheckTypeStr = "客人房";
  275. else if (_hotelReservations.CheckType == "D") _hotelReservations.CheckTypeStr = "司机房";
  276. else if (_hotelReservations.CheckType == "G") _hotelReservations.CheckTypeStr = "导游房";
  277. else if (_hotelReservations.CheckType == "D&G") _hotelReservations.CheckTypeStr = "司机导游房";
  278. }
  279. string Sql = string.Format(@"select c.PayDId, s.Name asPayDIdStr,c.ConsumptionPatterns,c.ConsumptionDate,c.CTDId,
  280. s1.Name as CTDIdStr,c.BankNo,c.CardholderName,c.PayMoney,c.PaymentCurrency,s2.Name
  281. as PaymentCurrencyStr,c.DayRate,c.CompanyBankNo,c.OtherBankName,c.OtherSideNo,c.OtherSideName,
  282. c.IsAuditGM,c.Payee,c.RMBPrice,c.OrbitalPrivateTransfer,c.Remark from Grp_CreditCardPayment c
  283. left join Sys_SetData s on c.PayDId=s.Id
  284. left join Sys_SetData s1 on c.CTDId=s1.Id
  285. left join Sys_SetData s2 on c.PaymentCurrency=s2.Id
  286. where c.CId ={0} and c.IsDel = 0 and c.CTable = 76", dto.Id);
  287. Grp_CreditCardView _CreditCardPayment = _sqlSugar.SqlQueryable<Grp_CreditCardView>(Sql).First();
  288. if (_CreditCardPayment!=null)
  289. {
  290. if(!string.IsNullOrWhiteSpace(_CreditCardPayment.ConsumptionDate)) _CreditCardPayment.ConsumptionDate=Convert.ToDateTime(_CreditCardPayment.ConsumptionDate).ToString("yyyy-MM-dd");
  291. }
  292. var data = new
  293. {
  294. hotelReservations = _hotelReservations,
  295. creditCardPayment = _CreditCardPayment,
  296. };
  297. return result = new Result() { Code = 0, Msg = "查询成功",Data= data };
  298. }
  299. catch (Exception ex)
  300. {
  301. return result = new Result() { Code = -2, Msg = "未知错误" };
  302. throw;
  303. }
  304. }
  305. /// <summary>
  306. /// 酒店页面下拉框等初始化
  307. /// </summary>
  308. /// <param name="dto"></param>
  309. /// <returns></returns>
  310. public async Task<Result> HotelReservationsInitialize(HotelReservationsDto dto)
  311. {
  312. Result result = new Result() { Code = -2, Msg = "未知错误" };
  313. try
  314. {
  315. List<Grp_GroupsTaskAssignment> grp_GroupsTaskAssignment = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 76).ToList();
  316. string DiId = "0";
  317. foreach (var item in grp_GroupsTaskAssignment)
  318. {
  319. DiId += item.DIId + ",";
  320. }
  321. if (DiId != "0")
  322. {
  323. DiId = DiId.Substring(0, DiId.Length - 1);
  324. }
  325. string sql = string.Format(@"select * from Grp_DelegationInfo where Id in({0}) and IsDel={1}", DiId, 0);
  326. //团组下拉框
  327. List<Grp_DelegationInfo> Delegations = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToList();
  328. List<ShareGroupInfoIIView> grp_Delegations = _mapper.Map<List<ShareGroupInfoIIView>>(Delegations);
  329. for (int i = 0;i< grp_Delegations.Count; i++)
  330. {
  331. grp_Delegations[i].VisitDate = Delegations[i].VisitStartDate.ToString("yyyy-MM-dd")+"至"+ Delegations[i].VisitEndDate.ToString("yyyy-MM-dd");
  332. }
  333. //客人类型
  334. List<Sys_SetData> GuestType = _sqlSugar.Queryable<Sys_SetData>().Where(a=>a.IsDel==0 && a.STid==11).ToList();
  335. List<SetDataInfoView> _GuestType = _mapper.Map<List<SetDataInfoView>>(GuestType);
  336. //支付方式
  337. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  338. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  339. //币种
  340. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  341. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  342. //卡类型
  343. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  344. List<SetDataCurrencyInfoView> _BankCard = _mapper.Map<List<SetDataCurrencyInfoView>>(BankCard);
  345. //预订网站
  346. List<Sys_SetData> BookingWebsite = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 12 && a.IsDel == 0).ToList();
  347. List<SetDataInfoView> _BookingWebsite = _mapper.Map<List<SetDataInfoView>>(BookingWebsite);
  348. if (dto.PortType==2 || dto.PortType==3)
  349. {
  350. GeneralTeamRateInfoDto PostGroupTeamRatedto = new GeneralTeamRateInfoDto();
  351. PostGroupTeamRatedto.DiId= dto.DiId;
  352. PostGroupTeamRatedto.CTable = 76;
  353. PostGroupTeamRatedto.PortType= dto.PortType;
  354. var _teamRateView = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(dto.PortType, dto.DiId, 76);
  355. var data = new
  356. {
  357. GuestType = _GuestType,
  358. Payment = _Payment,
  359. CurrencyList = _teamRateView,
  360. BankCard = _BankCard,
  361. BookingWebsite = _BookingWebsite,
  362. };
  363. return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
  364. }
  365. else
  366. {
  367. var data = new
  368. {
  369. Delegations = grp_Delegations,
  370. GuestType = _GuestType,
  371. Payment = _Payment,
  372. CurrencyList = _CurrencyList,
  373. BankCard = _BankCard,
  374. BookingWebsite = _BookingWebsite,
  375. };
  376. return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
  377. }
  378. }
  379. catch (Exception ex)
  380. {
  381. return result = new Result() { Code = -2, Msg = "未知错误" };
  382. throw;
  383. }
  384. }
  385. /// <summary>
  386. /// 酒店操作
  387. /// </summary>
  388. /// <param name="dto"></param>
  389. /// <returns></returns>
  390. /// <exception cref="NotImplementedException"></exception>
  391. public async Task<Result> OpHotelReservations(OpHotelReservationsData dto)
  392. {
  393. Result result = new Result() { Code = -2, Msg = "未知错误" };
  394. try
  395. {
  396. BeginTran();
  397. int id = dto.Id;
  398. Grp_HotelReservations hotelPrice = _mapper.Map<Grp_HotelReservations>(dto);
  399. hotelPrice.IsCardPrice = hotelPrice.CardPrice!=0 ? 1:0;
  400. hotelPrice.CboOne=hotelPrice.SingleRoomCount !=0 ? 1 : 0;
  401. hotelPrice.CboTwo = hotelPrice.DoubleRoomCount != 0 ? 1 : 0;
  402. hotelPrice.CboThree = hotelPrice.SuiteRoomCount != 0 ? 1 : 0;
  403. hotelPrice.CboFour = hotelPrice.SuiteRoomCount != 0 ? 1 : 0;
  404. Grp_CreditCardPayment c = _mapper.Map<Grp_CreditCardPayment>(dto);
  405. c.Remark = dto.CRemark;
  406. c.PayPercentage = 100;
  407. c.CTable = 76;
  408. c.CId = id;
  409. c.IsAuditGM = 0;
  410. if (c.PayDId == 72)
  411. {
  412. c.IsPay = 1;
  413. }
  414. c.RMBPrice = c.PayMoney;
  415. c.DayRate = 1;
  416. Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 76);
  417. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  418. if (_TeamRate != null)
  419. {
  420. Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
  421. if (_SetData != null)
  422. {
  423. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  424. CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  425. if (CurrencyRate != null)
  426. {
  427. c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
  428. c.DayRate = CurrencyRate.Rate;
  429. }
  430. }
  431. }
  432. if (dto.Status == 1)//添加
  433. {
  434. Grp_HotelReservations grp_Hotel = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.IsDel == 0 && a.HotelName == dto.HotelName && a.GuestName == dto.GuestName &&
  435. a.CheckInDate == dto.CheckInDate && a.CheckOutDate==dto.CheckOutDate && a.City==dto.City);
  436. if (grp_Hotel != null)
  437. {
  438. return result = new Result() { Code = -1, Msg = "该笔费用已存在,请勿重复添加!" };
  439. }
  440. else
  441. {
  442. id = await AddAsyncReturnId(hotelPrice);
  443. if (id != 0)
  444. {
  445. c.CId = id;
  446. int cId = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
  447. if (cId != 0)
  448. {
  449. result = new Result() { Code = 0, Msg = "添加成功!" };
  450. }
  451. else
  452. {
  453. RollbackTran();
  454. result = new Result() { Code = -1, Msg = "添加失败!" };
  455. }
  456. }
  457. else
  458. {
  459. RollbackTran();
  460. result = new Result() { Code = -1, Msg = "添加失败,请稍后重试!" };
  461. }
  462. }
  463. }
  464. else if (dto.Status == 2)//修改
  465. {
  466. bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_HotelReservations
  467. {
  468. GTId=hotelPrice.GTId,
  469. CheckNumber=hotelPrice.CheckNumber,
  470. ReservationsWebsite=hotelPrice.ReservationsWebsite,
  471. ReservationsNo=hotelPrice.ReservationsNo,
  472. DetermineNo=hotelPrice.DetermineNo,
  473. City=hotelPrice.City,
  474. HotelName=hotelPrice.HotelName,
  475. HotelAddress=hotelPrice.HotelAddress,
  476. HotelTel=hotelPrice.HotelTel,
  477. GuestName=hotelPrice.GuestName,
  478. CheckInDate=hotelPrice.CheckInDate,
  479. BudgetCurrency=hotelPrice.BudgetCurrency,
  480. CheckOutDate=hotelPrice.CheckOutDate,
  481. SingleRoomCount=hotelPrice.SingleRoomCount,
  482. SingleRoomPrice=hotelPrice.SingleRoomPrice,
  483. DoubleRoomCount=hotelPrice.DoubleRoomCount,
  484. DoubleRoomPrice=hotelPrice.DoubleRoomPrice,
  485. SuiteRoomCount=hotelPrice.SuiteRoomCount,
  486. SuiteRoomPrice=hotelPrice.SuiteRoomPrice,
  487. OtherRoomCount=hotelPrice.OtherRoomCount,
  488. OtherRoomPrice=hotelPrice.OtherRoomPrice,
  489. RoomExplanation=hotelPrice.RoomExplanation,
  490. Attachment=hotelPrice.Attachment,
  491. CardPrice=hotelPrice.CardPrice,
  492. CardPriceCurrency=hotelPrice.CardPriceCurrency,
  493. IsCardPrice =hotelPrice.IsCardPrice,
  494. PredictSingleRoom=hotelPrice.PredictSingleRoom,
  495. PredictDoubleRoom=hotelPrice.PredictDoubleRoom,
  496. PredictSuiteRoom=hotelPrice.PredictSuiteRoom,
  497. PredictOtherRoom=hotelPrice.PredictOtherRoom,
  498. GovernmentRent=hotelPrice.GovernmentRent,
  499. GovernmentRentCurrency=hotelPrice.GovernmentRentCurrency,
  500. CityTax=hotelPrice.CityTax,
  501. CityTaxCurrency=hotelPrice.CityTaxCurrency,
  502. CheckType=hotelPrice.CheckType,
  503. CboOne=hotelPrice.SingleRoomCount,
  504. CboTwo=hotelPrice.DoubleRoomCount,
  505. CboThree=hotelPrice.SuiteRoomCount,
  506. CboFour=hotelPrice.SuiteRoomCount,
  507. CreateUserId=hotelPrice.CreateUserId,
  508. Remark=hotelPrice.Remark
  509. });
  510. if (res)
  511. {
  512. int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == hotelPrice.Id && a.CTable == 76).SetColumns(a => new Grp_CreditCardPayment
  513. {
  514. PayDId = dto.PayDId,
  515. PayMoney = c.PayMoney,
  516. PaymentCurrency = c.PaymentCurrency,
  517. Payee = c.Payee,
  518. OrbitalPrivateTransfer = c.OrbitalPrivateTransfer,
  519. DayRate = c.DayRate,
  520. RMBPrice = c.RMBPrice,
  521. ConsumptionPatterns = c.ConsumptionPatterns,
  522. ConsumptionDate = c.ConsumptionDate,
  523. CTDId = c.CTDId,
  524. CompanyBankNo = c.CompanyBankNo,
  525. OtherBankName = c.OtherBankName,
  526. OtherSideNo = c.OtherSideNo,
  527. OtherSideName = c.OtherSideName,
  528. BankNo = c.BankNo,
  529. CardholderName = c.CardholderName,
  530. Remark = c.Remark,
  531. }).ExecuteCommandAsync();
  532. if (CTable==0)
  533. {
  534. result = new Result() { Code = -1, Msg = "修改失败!" };
  535. RollbackTran();
  536. }
  537. else
  538. {
  539. result = new Result() { Code = 0, Msg = "修改成功!" };
  540. }
  541. }
  542. else
  543. {
  544. RollbackTran();
  545. result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
  546. }
  547. }
  548. CommitTran();
  549. }
  550. catch (Exception ex)
  551. {
  552. return result = new Result() { Code = -2, Msg = "未知错误" };
  553. throw;
  554. }
  555. return result;
  556. }
  557. #endregion
  558. /// <summary>
  559. /// 酒店预定
  560. /// Items By DiId
  561. /// </summary>
  562. /// <param name="dto"></param>
  563. /// <returns></returns>
  564. public async Task<Result> _ItemsByDiId(int portType,int diId)
  565. {
  566. string sql = string.Format(@"Select row_number() over(order by hr.CreateTime Desc) as Row_Number,
  567. hr.Id,hr.DiId,sd1.Name As GuestType,hr.ReservationsNo,hr.HotelName,hr.CheckInDate,hr.CheckOutDate,
  568. ccp.PayMoney, ccp.PaymentCurrency,sd2.Name PayCurrency,hr.CreateUserId,u.CnName As CreateUserName,
  569. hr.CreateTime,ccp.IsAuditGM
  570. From Grp_HotelReservations hr
  571. Inner Join Grp_CreditCardPayment ccp On hr.DiId = ccp.DIId And hr.Id = ccp.CId
  572. And ccp.CTable = 76
  573. Left Join Sys_SetData sd1 On hr.GTId = sd1.Id
  574. Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
  575. Left Join Sys_Users u On hr.CreateUserId = u.Id
  576. Where hr.IsDel = 0 And ccp.IsDel = 0 And hr.DiId = {0} ", diId);
  577. if (portType == 1 || portType == 2 || portType == 3)
  578. {
  579. var hotelFeeData = await _sqlSugar.SqlQueryable<HotelReservationsItemsView>(sql).ToListAsync();
  580. _result.Code = 0;
  581. _result.Data = hotelFeeData;
  582. _result.Msg = "操作成功!";
  583. }
  584. else
  585. {
  586. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS";
  587. }
  588. return _result;
  589. }
  590. /// <summary>
  591. /// 酒店预定
  592. /// basicsData Init
  593. /// </summary>
  594. /// <param name="dto"></param>
  595. /// <returns></returns>
  596. public async Task<Result> _BasicsDataInit(int portType, int diId)
  597. {
  598. List<Sys_SetData> _dataSouruce = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0).ToListAsync();
  599. if (portType == 1 || portType == 2 || portType == 3)
  600. {
  601. //客人类型
  602. List<Sys_SetData> GuestType = _dataSouruce.Where(a => a.STid == 11).ToList();
  603. List<SetDataInfoView> _GuestType = _mapper.Map<List<SetDataInfoView>>(GuestType);
  604. //预订网站
  605. List<Sys_SetData> BookingWebsite = _dataSouruce.Where(a => a.STid == 12).ToList();
  606. List<SetDataInfoView> _BookingWebsite = _mapper.Map<List<SetDataInfoView>>(BookingWebsite);
  607. //支付方式
  608. List<Sys_SetData> Payment = _dataSouruce.Where(a => a.STid == 14).ToList();
  609. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  610. //卡类型
  611. List<Sys_SetData> BankCard = _dataSouruce.Where(a => a.STid == 15).ToList();
  612. List<SetDataCurrencyInfoView> _BankCard = _mapper.Map<List<SetDataCurrencyInfoView>>(BankCard);
  613. //房间入住人类型
  614. List<Sys_SetData> CheckPerson = _dataSouruce.Where(a => a.STid == 71).ToList();
  615. List<SetDataInfoView> _CheckPerson = _mapper.Map<List<SetDataInfoView>>(CheckPerson);
  616. var _teamRateView = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(portType, diId, 76);
  617. string _CheckVolumeNo = string.Empty;
  618. var checkVoumeNoData = _CreateCheckVolumeNo(diId);
  619. if (checkVoumeNoData.Result.Code == 0)
  620. {
  621. _CheckVolumeNo = checkVoumeNoData.Result.Data;
  622. }
  623. //客户名单
  624. var guestNames = await _tourClientListRep._GuestNameItemByDiId(portType, diId);
  625. var data = new
  626. {
  627. GuestType = _GuestType, //客人分类
  628. Payment = _Payment,
  629. CurrencyList = _teamRateView,
  630. BankCard = _BankCard,
  631. BookingWebsite = _BookingWebsite,
  632. CheckPerson = _CheckPerson,
  633. CheckVolumeNo = _CheckVolumeNo,
  634. GuestName = guestNames
  635. };
  636. _result.Code = 0;
  637. _result.Data = data;
  638. _result.Msg = "操作成功!";
  639. }
  640. else
  641. {
  642. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS!";
  643. }
  644. return _result;
  645. }
  646. /// <summary>
  647. /// 酒店预定
  648. /// 创建 入住卷号码
  649. /// </summary>
  650. /// <param name="DiId"></param>
  651. /// <returns></returns>
  652. public async Task<Result> _CreateCheckVolumeNo(int DiId)
  653. {
  654. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == DiId && it.IsDel == 0).FirstAsync();
  655. if (groupInfo != null)
  656. {
  657. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  658. {
  659. string no = string.Empty;
  660. string[] countrys = new string[] { };
  661. countrys = groupInfo.VisitCountry.Split('|');
  662. foreach (string country in countrys)
  663. {
  664. //国家城市三字码 未挪数据 暂时用随机数代替
  665. }
  666. no = CommonFun.GetRandomLetter(countrys.Length).ToUpper();
  667. no += CommonFun.GetRandomNumber(2);
  668. _result.Code = 0;
  669. _result.Data = no;
  670. _result.Msg = "入住卷号码 获取成功!";
  671. }
  672. }
  673. return _result;
  674. }
  675. /// <summary>
  676. /// 酒店预定-
  677. /// details
  678. /// </summary>
  679. /// <param name="dto"></param>
  680. /// <returns></returns>
  681. public async Task<Result> _Details(int portType, int id)
  682. {
  683. if (id < 0 )
  684. {
  685. _result.Msg = string.Format(@"请输入正确的Id!");
  686. return _result;
  687. }
  688. string sql = string.Format(@"Select hr.Id,hr.DiId,hr.GTId,ccp.CTDId,hr.CheckNumber,hr.ReservationsWebsite,hr.ReservationsNo,
  689. hr.DetermineNo,hr.City,hr.HotelName,hr.HotelTel,hr.HotelAddress,hr.GuestName,hr.CheckInDate,hr.CheckOutDate,
  690. hr.CheckType,hr.RoomExplanation,hr.Remark As HotelRemark,hr.SingleRoomPrice,hr.SingleRoomCount,hr.DoubleRoomPrice,
  691. hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount,hr.OtherRoomPrice,hr.OtherRoomCount,hr.CardPrice,
  692. hr.Isoppay,hr.BreakfastPrice,hr.BreakfastCurrency,hr.GovernmentRent,hr.GovernmentRentCurrency,hr.CityTax,
  693. hr.CityTaxCurrency,ccp.PayDId,ccp.ConsumptionPatterns,ccp.ConsumptionDate,ccp.PayMoney,ccp.PaymentCurrency,
  694. ccp.BankNo,ccp.CardholderName,ccp.CompanyBankNo,ccp.OtherBankName,ccp.OtherSideNo,ccp.OtherSideName,ccp.Payee,
  695. ccp.OrbitalPrivateTransfer,ccp.Remark As CcpRemark
  696. From Grp_HotelReservations hr
  697. Inner Join Grp_CreditCardPayment ccp On hr.DiId = ccp.DIId And hr.Id = ccp.CId
  698. And ccp.CTable = 76
  699. Where hr.IsDel = 0 And ccp.IsDel = 0 And hr.Id = {0}", id);
  700. if (portType == 1 || portType == 2 || portType == 3)
  701. {
  702. var info = await _sqlSugar.SqlQueryable<HotelReservationsDetailsView>(sql).FirstAsync();
  703. if (info != null) _result.Msg = "操作成功!";
  704. else _result.Msg = "暂无数据";
  705. _result.Code = 0;
  706. _result.Data = info;
  707. return _result;
  708. }
  709. else
  710. {
  711. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS";
  712. return _result;
  713. }
  714. }
  715. /// <summary>
  716. /// 酒店预定
  717. /// Add Or Edit
  718. /// </summary>
  719. /// <returns></returns>
  720. public async Task<Result> _AddOrEdit(HotelReservationsAddOrEditDto _dto)
  721. {
  722. int portType = _dto.PortType;
  723. if (portType == 1 || portType == 2 || portType == 3)
  724. {
  725. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations();
  726. Grp_CreditCardPayment _CreditCardPayment = new Grp_CreditCardPayment();
  727. #region 参数处理
  728. _HotelReservations = _mapper.Map<Grp_HotelReservations>(_dto);
  729. _CreditCardPayment = _mapper.Map<Grp_CreditCardPayment>(_dto);
  730. _HotelReservations.DiId = _dto.DiId;
  731. _HotelReservations.CardPriceCurrency = _dto.CTDId;
  732. _HotelReservations.CreateUserId = _dto.UserId;
  733. _HotelReservations.Remark = _dto.HotelRemark;
  734. if (portType == 2 || portType == 3)
  735. {
  736. string checkNo = string.Empty;
  737. Result checkNoRes = await _CreateCheckVolumeNo(_dto.DiId);
  738. if (checkNoRes.Code == 0)
  739. {
  740. checkNo = checkNoRes.Data;
  741. _HotelReservations.CheckNumber = checkNo;
  742. }
  743. }
  744. #region CCP 表参数
  745. if (_dto.PayDId == 72) //刷卡 默认已支付
  746. {
  747. _CreditCardPayment.IsPay = 1;
  748. }
  749. _CreditCardPayment.CreateUserId = _dto.UserId;
  750. _CreditCardPayment.DIId = _dto.DiId;
  751. _CreditCardPayment.CTable = 76;
  752. _CreditCardPayment.CTDId = _dto.CTDId;
  753. _CreditCardPayment.PayPercentage = 100.00M;
  754. _CreditCardPayment.PayThenMoney = _CreditCardPayment.PayMoney;
  755. string paymentCurrencyCode = string.Empty;
  756. List<Sys_SetData> currencySouruce = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 66).ToListAsync();
  757. if (currencySouruce.Count > 0)
  758. {
  759. Sys_SetData currency = new Sys_SetData();
  760. currency = currencySouruce.Where(it => it.Id == _CreditCardPayment.PaymentCurrency).FirstOrDefault();
  761. if (currency != null)
  762. {
  763. paymentCurrencyCode = currency.Name;
  764. }
  765. }
  766. decimal currencyRate = 0.00M;
  767. if (_CreditCardPayment.PayMoney != 0)
  768. {
  769. if(_CreditCardPayment.PaymentCurrency <= 0)
  770. {
  771. _result.Msg = "请选择付款币种!";
  772. return _result;
  773. }
  774. List<TeamRateModelView> teamRateModelViews = new List<TeamRateModelView>();
  775. teamRateModelViews = await _teamRateRep.PostGroupRateInfoByDiId(_dto.DiId);
  776. if (teamRateModelViews.Count < 0)
  777. {
  778. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  779. return _result;
  780. }
  781. TeamRateModelView teamRateModels_hotel = new TeamRateModelView();
  782. teamRateModels_hotel = teamRateModelViews.Where(it => it.CTableId == 76).FirstOrDefault();
  783. if (teamRateModels_hotel == null)
  784. {
  785. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  786. return _result;
  787. }
  788. List<TeamRateDescView> teamRateDescViews = new List<TeamRateDescView>();
  789. teamRateDescViews = teamRateModels_hotel.TeamRates;
  790. if (teamRateDescViews.Count < 0)
  791. {
  792. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  793. return _result;
  794. }
  795. TeamRateDescView teamRateDescView = new TeamRateDescView();
  796. teamRateDescView = teamRateDescViews.Where(it => it.CurrencyCode == paymentCurrencyCode).FirstOrDefault();
  797. if (teamRateDescView == null)
  798. {
  799. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  800. return _result;
  801. }
  802. currencyRate = teamRateDescView.Rate;
  803. }
  804. _CreditCardPayment.DayRate = currencyRate;
  805. _CreditCardPayment.RMBPrice = (_CreditCardPayment.DayRate * _CreditCardPayment.PayMoney).DecimalsKeepTwo();
  806. //if (_CreditCardPayment.PayDId == 72) //刷卡
  807. //{
  808. // _CreditCardPayment.BankNo = "6222 **** **** 7990";
  809. // _CreditCardPayment.CardholderName = "Zhang Hailin";
  810. //}
  811. _CreditCardPayment.Remark = _dto.CcpRemark;
  812. #endregion
  813. #endregion
  814. if (_dto.Id == 0) // Add
  815. {
  816. _sqlSugar.BeginTran();
  817. int hotelId = await _sqlSugar.Insertable<Grp_HotelReservations>(_HotelReservations).ExecuteReturnIdentityAsync();
  818. if (hotelId < 0)
  819. {
  820. _result.Msg = "酒店预定信息添加失败!";
  821. _sqlSugar.RollbackTran(); //回滚
  822. return _result;
  823. }
  824. _CreditCardPayment.CId = hotelId;
  825. _CreditCardPayment.CTable = 76; //酒店预定模块
  826. int ccpId = await _sqlSugar.Insertable<Grp_CreditCardPayment>(_CreditCardPayment).ExecuteReturnIdentityAsync();
  827. if (ccpId < 0)
  828. {
  829. _result.Msg = "付款信息添加失败!";
  830. _sqlSugar.RollbackTran(); //回滚
  831. return _result;
  832. }
  833. #region 酒店基础数据 添加
  834. var hotelDataReq = new OperationHotelDto() {
  835. Status = 1,
  836. City = _dto.City,
  837. Name = _dto.HotelName,
  838. Tel = _dto.HotelTel,
  839. Address = _dto.HotelAddress
  840. };
  841. await _hotelDataRep.OperationHotelData(hotelDataReq);
  842. #endregion
  843. _result.Msg = "操作成功!";
  844. _result.Code = 0;
  845. _sqlSugar.CommitTran(); // 提交
  846. }
  847. else if (_dto.Id > 0) //Edit
  848. {
  849. _sqlSugar.BeginTran();
  850. int hotelStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  851. .UpdateColumns(it => new
  852. {
  853. it.GTId,
  854. it.CheckNumber,
  855. it.ReservationsWebsite,
  856. it.ReservationsNo,
  857. it.DetermineNo,
  858. it.City,
  859. it.HotelName,
  860. it.HotelTel,
  861. it.HotelAddress,
  862. it.GuestName,
  863. it.CheckInDate,
  864. it.CheckOutDate,
  865. it.CheckType,
  866. it.RoomExplanation,
  867. it.SingleRoomPrice,
  868. it.SingleRoomCount,
  869. it.DoubleRoomPrice,
  870. it.DoubleRoomCount,
  871. it.SuiteRoomPrice,
  872. it.SuiteRoomCount,
  873. it.OtherRoomPrice,
  874. it.OtherRoomCount,
  875. it.CardPrice,
  876. it.CardPriceCurrency,
  877. it.Isoppay,
  878. it.BreakfastPrice,
  879. it.BreakfastCurrency,
  880. it.GovernmentRent,
  881. it.GovernmentRentCurrency,
  882. it.CityTax,
  883. it.CityTaxCurrency,
  884. it.Remark,
  885. })
  886. .WhereColumns(it => it.Id)
  887. .ExecuteCommandAsync();
  888. if (hotelStatus < 0)
  889. {
  890. _result.Msg = "酒店预定信息修改失败!";
  891. _sqlSugar.RollbackTran(); //回滚
  892. return _result;
  893. }
  894. var hotelInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  895. .Where(it => it.DIId == _dto.DiId && it.CId == _dto.Id && it.CTable == 76 && it.IsDel == 0)
  896. .FirstAsync();
  897. if (hotelInfo == null) //ccp表 Add
  898. {
  899. }
  900. else //ccp表 Edit
  901. {
  902. _CreditCardPayment.Id = hotelInfo.Id;
  903. int creditCardStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>(_CreditCardPayment)
  904. .UpdateColumns(it => new
  905. {
  906. it.CTDId,
  907. it.PayDId,
  908. it.IsPay,
  909. it.ConsumptionPatterns,
  910. it.ConsumptionDate,
  911. it.PayMoney,
  912. it.PaymentCurrency,
  913. it.PayThenMoney,
  914. it.DayRate,
  915. it.RMBPrice,
  916. it.BankNo,
  917. it.CardholderName,
  918. it.CompanyBankNo,
  919. it.OtherBankName,
  920. it.OtherSideNo,
  921. it.OtherSideName,
  922. it.Payee,
  923. it.OrbitalPrivateTransfer,
  924. it.Remark,
  925. })
  926. .WhereColumns(it => it.Id)
  927. .ExecuteCommandAsync();
  928. if (creditCardStatus < 0)
  929. {
  930. _result.Msg = "付款信息表修改失败!";
  931. _sqlSugar.RollbackTran(); //回滚
  932. return _result;
  933. }
  934. }
  935. _result.Msg = "操作成功!";
  936. _result.Code = 0;
  937. _sqlSugar.CommitTran(); // 提交
  938. }
  939. else if (_dto.Id < 0) //不正确的Id
  940. {
  941. _result.Msg = "请输入正确的数据Id!";
  942. }
  943. }
  944. else
  945. {
  946. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS";
  947. }
  948. return _result;
  949. }
  950. /// <summary>
  951. /// 酒店预定
  952. /// Del
  953. /// </summary>
  954. /// <returns></returns>
  955. public async Task<Result> _Del(int id,int userId)
  956. {
  957. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations()
  958. {
  959. Id = id,
  960. IsDel = 1,
  961. DeleteUserId = userId,
  962. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  963. };
  964. int hrStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  965. .UpdateColumns(it => new
  966. {
  967. it.IsDel,
  968. it.DeleteUserId,
  969. it.DeleteTime,
  970. })
  971. .WhereColumns(it => it.Id)
  972. .ExecuteCommandAsync();
  973. if (hrStatus < 0)
  974. {
  975. _result.Msg = "操作失败!";
  976. return _result;
  977. }
  978. _result.Msg = "操作成功!";
  979. _result.Code = 0;
  980. return _result;
  981. }
  982. }
  983. }