HotelPriceRepository.cs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095
  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) c.IsPay = 1;
  411. else c.IsPay = 0;
  412. c.RMBPrice = c.PayMoney;
  413. c.DayRate = 1;
  414. Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 76);
  415. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  416. if (_TeamRate != null)
  417. {
  418. Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
  419. if (_SetData != null)
  420. {
  421. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  422. CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  423. if (CurrencyRate != null)
  424. {
  425. c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
  426. c.DayRate = CurrencyRate.Rate;
  427. }
  428. }
  429. }
  430. if (dto.Status == 1)//添加
  431. {
  432. Grp_HotelReservations grp_Hotel = _sqlSugar.Queryable<Grp_HotelReservations>().First(a => a.IsDel == 0 && a.HotelName == dto.HotelName && a.GuestName == dto.GuestName &&
  433. a.CheckInDate == dto.CheckInDate && a.CheckOutDate==dto.CheckOutDate && a.City==dto.City);
  434. if (grp_Hotel != null)
  435. {
  436. return result = new Result() { Code = -1, Msg = "该笔费用已存在,请勿重复添加!" };
  437. }
  438. else
  439. {
  440. id = await AddAsyncReturnId(hotelPrice);
  441. if (id != 0)
  442. {
  443. c.CId = id;
  444. int cId = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
  445. if (cId != 0)
  446. {
  447. result = new Result() { Code = 0, Msg = "添加成功!" };
  448. }
  449. else
  450. {
  451. RollbackTran();
  452. result = new Result() { Code = -1, Msg = "添加失败!" };
  453. }
  454. }
  455. else
  456. {
  457. RollbackTran();
  458. result = new Result() { Code = -1, Msg = "添加失败,请稍后重试!" };
  459. }
  460. }
  461. }
  462. else if (dto.Status == 2)//修改
  463. {
  464. bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_HotelReservations
  465. {
  466. GTId=hotelPrice.GTId,
  467. CheckNumber=hotelPrice.CheckNumber,
  468. ReservationsWebsite=hotelPrice.ReservationsWebsite,
  469. ReservationsNo=hotelPrice.ReservationsNo,
  470. DetermineNo=hotelPrice.DetermineNo,
  471. City=hotelPrice.City,
  472. HotelName=hotelPrice.HotelName,
  473. HotelAddress=hotelPrice.HotelAddress,
  474. HotelTel=hotelPrice.HotelTel,
  475. GuestName=hotelPrice.GuestName,
  476. CheckInDate=hotelPrice.CheckInDate,
  477. BudgetCurrency=hotelPrice.BudgetCurrency,
  478. CheckOutDate=hotelPrice.CheckOutDate,
  479. SingleRoomCount=hotelPrice.SingleRoomCount,
  480. SingleRoomPrice=hotelPrice.SingleRoomPrice,
  481. DoubleRoomCount=hotelPrice.DoubleRoomCount,
  482. DoubleRoomPrice=hotelPrice.DoubleRoomPrice,
  483. SuiteRoomCount=hotelPrice.SuiteRoomCount,
  484. SuiteRoomPrice=hotelPrice.SuiteRoomPrice,
  485. OtherRoomCount=hotelPrice.OtherRoomCount,
  486. OtherRoomPrice=hotelPrice.OtherRoomPrice,
  487. RoomExplanation=hotelPrice.RoomExplanation,
  488. Attachment=hotelPrice.Attachment,
  489. CardPrice=hotelPrice.CardPrice,
  490. CardPriceCurrency=hotelPrice.CardPriceCurrency,
  491. IsCardPrice =hotelPrice.IsCardPrice,
  492. PredictSingleRoom=hotelPrice.PredictSingleRoom,
  493. PredictDoubleRoom=hotelPrice.PredictDoubleRoom,
  494. PredictSuiteRoom=hotelPrice.PredictSuiteRoom,
  495. PredictOtherRoom=hotelPrice.PredictOtherRoom,
  496. GovernmentRent=hotelPrice.GovernmentRent,
  497. GovernmentRentCurrency=hotelPrice.GovernmentRentCurrency,
  498. CityTax=hotelPrice.CityTax,
  499. CityTaxCurrency=hotelPrice.CityTaxCurrency,
  500. CheckType=hotelPrice.CheckType,
  501. CboOne=hotelPrice.SingleRoomCount,
  502. CboTwo=hotelPrice.DoubleRoomCount,
  503. CboThree=hotelPrice.SuiteRoomCount,
  504. CboFour=hotelPrice.SuiteRoomCount,
  505. CreateUserId=hotelPrice.CreateUserId,
  506. Remark=hotelPrice.Remark
  507. });
  508. if (res)
  509. {
  510. int ispay = 0;
  511. if (dto.PayDId == 72) ispay = 1;
  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. IsPay=ispay,
  516. PayMoney = c.PayMoney,
  517. PaymentCurrency = c.PaymentCurrency,
  518. Payee = c.Payee,
  519. OrbitalPrivateTransfer = c.OrbitalPrivateTransfer,
  520. DayRate = c.DayRate,
  521. RMBPrice = c.RMBPrice,
  522. ConsumptionPatterns = c.ConsumptionPatterns,
  523. ConsumptionDate = c.ConsumptionDate,
  524. CTDId = c.CTDId,
  525. CompanyBankNo = c.CompanyBankNo,
  526. OtherBankName = c.OtherBankName,
  527. OtherSideNo = c.OtherSideNo,
  528. OtherSideName = c.OtherSideName,
  529. BankNo = c.BankNo,
  530. CardholderName = c.CardholderName,
  531. Remark = c.Remark,
  532. }).ExecuteCommandAsync();
  533. if (CTable==0)
  534. {
  535. result = new Result() { Code = -1, Msg = "修改失败!" };
  536. RollbackTran();
  537. }
  538. else
  539. {
  540. result = new Result() { Code = 0, Msg = "修改成功!" };
  541. }
  542. }
  543. else
  544. {
  545. RollbackTran();
  546. result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
  547. }
  548. }
  549. CommitTran();
  550. }
  551. catch (Exception ex)
  552. {
  553. return result = new Result() { Code = -2, Msg = "未知错误" };
  554. throw;
  555. }
  556. return result;
  557. }
  558. #endregion
  559. /// <summary>
  560. /// 酒店预定
  561. /// Items By DiId
  562. /// </summary>
  563. /// <param name="dto"></param>
  564. /// <returns></returns>
  565. public async Task<Result> _ItemsByDiId(int portType,int diId)
  566. {
  567. string sql = string.Format(@"Select row_number() over(order by hr.CreateTime Desc) as Row_Number,
  568. hr.Id,hr.DiId,sd1.Name As GuestType,hr.ReservationsNo,hr.HotelName,hr.CheckInDate,hr.CheckOutDate,
  569. ccp.PayMoney, ccp.PaymentCurrency,sd2.Name PayCurrency,hr.CreateUserId,u.CnName As CreateUserName,
  570. hr.CreateTime,ccp.IsAuditGM,ccp.IsPay
  571. From Grp_HotelReservations hr
  572. Inner Join Grp_CreditCardPayment ccp On hr.DiId = ccp.DIId And hr.Id = ccp.CId
  573. And ccp.CTable = 76
  574. Left Join Sys_SetData sd1 On hr.GTId = sd1.Id
  575. Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
  576. Left Join Sys_Users u On hr.CreateUserId = u.Id
  577. Where hr.IsDel = 0 And ccp.IsDel = 0 And hr.DiId = {0} ", diId);
  578. if (portType == 1 || portType == 2 || portType == 3)
  579. {
  580. var hotelFeeData = await _sqlSugar.SqlQueryable<HotelReservationsItemsView>(sql).ToListAsync();
  581. _result.Code = 0;
  582. _result.Data = hotelFeeData;
  583. _result.Msg = "操作成功!";
  584. }
  585. else
  586. {
  587. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS";
  588. }
  589. return _result;
  590. }
  591. /// <summary>
  592. /// 酒店预定
  593. /// basicsData Init
  594. /// </summary>
  595. /// <param name="dto"></param>
  596. /// <returns></returns>
  597. public async Task<Result> _BasicsDataInit(int portType, int diId)
  598. {
  599. List<Sys_SetData> _dataSouruce = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0).ToListAsync();
  600. if (portType == 1 || portType == 2 || portType == 3)
  601. {
  602. //客人类型
  603. List<Sys_SetData> GuestType = _dataSouruce.Where(a => a.STid == 11).ToList();
  604. List<SetDataInfoView> _GuestType = _mapper.Map<List<SetDataInfoView>>(GuestType);
  605. //预订网站
  606. List<Sys_SetData> BookingWebsite = _dataSouruce.Where(a => a.STid == 12).ToList();
  607. List<SetDataInfoView> _BookingWebsite = _mapper.Map<List<SetDataInfoView>>(BookingWebsite);
  608. //支付方式
  609. List<Sys_SetData> Payment = _dataSouruce.Where(a => a.STid == 14).ToList();
  610. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  611. //卡类型
  612. List<Sys_SetData> BankCard = _dataSouruce.Where(a => a.STid == 15).ToList();
  613. List<SetDataCurrencyInfoView> _BankCard = _mapper.Map<List<SetDataCurrencyInfoView>>(BankCard);
  614. //房间入住人类型
  615. List<Sys_SetData> CheckPerson = _dataSouruce.Where(a => a.STid == 71).ToList();
  616. List<SetDataInfoView> _CheckPerson = _mapper.Map<List<SetDataInfoView>>(CheckPerson);
  617. var _teamRateView = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(portType, diId, 76);
  618. string _CheckVolumeNo = string.Empty;
  619. var checkVoumeNoData = _CreateCheckVolumeNo(diId);
  620. if (checkVoumeNoData.Result.Code == 0)
  621. {
  622. _CheckVolumeNo = checkVoumeNoData.Result.Data;
  623. }
  624. //客户名单
  625. var guestNames = await _tourClientListRep._GuestNameItemByDiId(portType, diId);
  626. var data = new
  627. {
  628. GuestType = _GuestType, //客人分类
  629. Payment = _Payment,
  630. CurrencyList = _teamRateView,
  631. BankCard = _BankCard,
  632. BookingWebsite = _BookingWebsite,
  633. CheckPerson = _CheckPerson,
  634. CheckVolumeNo = _CheckVolumeNo,
  635. GuestName = guestNames
  636. };
  637. _result.Code = 0;
  638. _result.Data = data;
  639. _result.Msg = "操作成功!";
  640. }
  641. else
  642. {
  643. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS!";
  644. }
  645. return _result;
  646. }
  647. /// <summary>
  648. /// 酒店预定
  649. /// 创建 入住卷号码
  650. /// </summary>
  651. /// <param name="DiId"></param>
  652. /// <returns></returns>
  653. public async Task<Result> _CreateCheckVolumeNo(int DiId)
  654. {
  655. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == DiId && it.IsDel == 0).FirstAsync();
  656. if (groupInfo != null)
  657. {
  658. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  659. {
  660. string no = string.Empty;
  661. string[] countrys = new string[] { };
  662. countrys = groupInfo.VisitCountry.Split('|');
  663. foreach (string country in countrys)
  664. {
  665. //国家城市三字码 未挪数据 暂时用随机数代替
  666. }
  667. no = CommonFun.GetRandomLetter(countrys.Length).ToUpper();
  668. no += CommonFun.GetRandomNumber(2);
  669. _result.Code = 0;
  670. _result.Data = no;
  671. _result.Msg = "入住卷号码 获取成功!";
  672. }
  673. }
  674. return _result;
  675. }
  676. /// <summary>
  677. /// 酒店预定-
  678. /// details
  679. /// </summary>
  680. /// <param name="dto"></param>
  681. /// <returns></returns>
  682. public async Task<Result> _Details(int portType, int id)
  683. {
  684. if (id < 0 )
  685. {
  686. _result.Msg = string.Format(@"请输入正确的Id!");
  687. return _result;
  688. }
  689. string sql = string.Format(@"Select hr.Id,hr.DiId,hr.GTId,ccp.CTDId,hr.CheckNumber,hr.ReservationsWebsite,hr.ReservationsNo,
  690. hr.DetermineNo,hr.City,hr.HotelName,hr.HotelTel,hr.HotelAddress,hr.GuestName,hr.CheckInDate,hr.CheckOutDate,
  691. hr.CheckType,hr.RoomExplanation,hr.Remark As HotelRemark,hr.SingleRoomPrice,hr.SingleRoomCount,hr.DoubleRoomPrice,
  692. hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount,hr.OtherRoomPrice,hr.OtherRoomCount,hr.CardPrice,
  693. hr.Isoppay,hr.BreakfastPrice,hr.BreakfastCurrency,hr.GovernmentRent,hr.GovernmentRentCurrency,hr.CityTax,
  694. hr.CityTaxCurrency,ccp.PayDId,ccp.ConsumptionPatterns,ccp.ConsumptionDate,ccp.PayMoney,ccp.PaymentCurrency,
  695. ccp.BankNo,ccp.CardholderName,ccp.CompanyBankNo,ccp.OtherBankName,ccp.OtherSideNo,ccp.OtherSideName,ccp.Payee,
  696. ccp.OrbitalPrivateTransfer,ccp.Remark As CcpRemark
  697. From Grp_HotelReservations hr
  698. Inner Join Grp_CreditCardPayment ccp On hr.DiId = ccp.DIId And hr.Id = ccp.CId
  699. And ccp.CTable = 76
  700. Where hr.IsDel = 0 And ccp.IsDel = 0 And hr.Id = {0}", id);
  701. if (portType == 1 || portType == 2 || portType == 3)
  702. {
  703. var info = await _sqlSugar.SqlQueryable<HotelReservationsDetailsView>(sql).FirstAsync();
  704. if (info != null) _result.Msg = "操作成功!";
  705. else _result.Msg = "暂无数据";
  706. _result.Code = 0;
  707. _result.Data = info;
  708. return _result;
  709. }
  710. else
  711. {
  712. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS";
  713. return _result;
  714. }
  715. }
  716. /// <summary>
  717. /// 酒店预定
  718. /// Add Or Edit
  719. /// </summary>
  720. /// <returns></returns>
  721. public async Task<Result> _AddOrEdit(HotelReservationsAddOrEditDto _dto)
  722. {
  723. _result.Code = -1;
  724. int portType = _dto.PortType;
  725. if (portType == 1 || portType == 2 || portType == 3)
  726. {
  727. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations();
  728. Grp_CreditCardPayment _CreditCardPayment = new Grp_CreditCardPayment();
  729. #region 参数处理
  730. _HotelReservations = _mapper.Map<Grp_HotelReservations>(_dto);
  731. _CreditCardPayment = _mapper.Map<Grp_CreditCardPayment>(_dto);
  732. _HotelReservations.DiId = _dto.DiId;
  733. _HotelReservations.CardPriceCurrency = _dto.CTDId;
  734. _HotelReservations.CreateUserId = _dto.UserId;
  735. _HotelReservations.Remark = _dto.HotelRemark;
  736. if (portType == 2 || portType == 3)
  737. {
  738. string checkNo = string.Empty;
  739. Result checkNoRes = await _CreateCheckVolumeNo(_dto.DiId);
  740. if (checkNoRes.Code == 0)
  741. {
  742. checkNo = checkNoRes.Data;
  743. _HotelReservations.CheckNumber = checkNo;
  744. }
  745. }
  746. #region CCP 表参数
  747. if (_dto.PayDId == 72) //刷卡 默认已支付
  748. {
  749. _CreditCardPayment.IsPay = 1;
  750. }else _CreditCardPayment.IsPay = 0;
  751. _CreditCardPayment.CreateUserId = _dto.UserId;
  752. _CreditCardPayment.DIId = _dto.DiId;
  753. _CreditCardPayment.CTable = 76;
  754. _CreditCardPayment.CTDId = _dto.CTDId;
  755. _CreditCardPayment.PayPercentage = 100.00M;
  756. _CreditCardPayment.PayThenMoney = _CreditCardPayment.PayMoney;
  757. string paymentCurrencyCode = string.Empty;
  758. List<Sys_SetData> currencySouruce = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 66).ToListAsync();
  759. if (currencySouruce.Count > 0)
  760. {
  761. Sys_SetData currency = new Sys_SetData();
  762. currency = currencySouruce.Where(it => it.Id == _CreditCardPayment.PaymentCurrency).FirstOrDefault();
  763. if (currency != null)
  764. {
  765. paymentCurrencyCode = currency.Name;
  766. }
  767. }
  768. decimal currencyRate = 0.00M;
  769. if (_CreditCardPayment.PayMoney != 0)
  770. {
  771. if(_CreditCardPayment.PaymentCurrency < 1)
  772. {
  773. _result.Msg = "请选择付款币种!";
  774. return _result;
  775. }
  776. List<TeamRateModelView> teamRateModelViews = new List<TeamRateModelView>();
  777. teamRateModelViews = await _teamRateRep.PostGroupRateInfoByDiId(_dto.DiId);
  778. if (teamRateModelViews.Count < 0)
  779. {
  780. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  781. return _result;
  782. }
  783. TeamRateModelView teamRateModels_hotel = new TeamRateModelView();
  784. teamRateModels_hotel = teamRateModelViews.Where(it => it.CTableId == 76).FirstOrDefault();
  785. if (teamRateModels_hotel == null)
  786. {
  787. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  788. return _result;
  789. }
  790. List<TeamRateDescView> teamRateDescViews = new List<TeamRateDescView>();
  791. teamRateDescViews = teamRateModels_hotel.TeamRates;
  792. if (teamRateDescViews.Count < 0)
  793. {
  794. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  795. return _result;
  796. }
  797. TeamRateDescView teamRateDescView = new TeamRateDescView();
  798. teamRateDescView = teamRateDescViews.Where(it => it.CurrencyCode == paymentCurrencyCode).FirstOrDefault();
  799. if (teamRateDescView == null)
  800. {
  801. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  802. return _result;
  803. }
  804. currencyRate = teamRateDescView.Rate;
  805. }
  806. _CreditCardPayment.DayRate = currencyRate;
  807. _CreditCardPayment.RMBPrice = (_CreditCardPayment.DayRate * _CreditCardPayment.PayMoney).DecimalsKeepTwo();
  808. //if (_CreditCardPayment.PayDId == 72) //刷卡
  809. //{
  810. // _CreditCardPayment.BankNo = "6222 **** **** 7990";
  811. // _CreditCardPayment.CardholderName = "Zhang Hailin";
  812. //}
  813. _CreditCardPayment.Remark = _dto.CcpRemark;
  814. #endregion
  815. #endregion
  816. if (_dto.Id == 0) // Add
  817. {
  818. _sqlSugar.BeginTran();
  819. int hotelId = await _sqlSugar.Insertable<Grp_HotelReservations>(_HotelReservations).ExecuteReturnIdentityAsync();
  820. if (hotelId < 0)
  821. {
  822. _result.Msg = "酒店预定信息添加失败!";
  823. _sqlSugar.RollbackTran(); //回滚
  824. return _result;
  825. }
  826. _CreditCardPayment.CId = hotelId;
  827. _CreditCardPayment.CTable = 76; //酒店预定模块
  828. int ccpId = await _sqlSugar.Insertable<Grp_CreditCardPayment>(_CreditCardPayment).ExecuteReturnIdentityAsync();
  829. if (ccpId < 0)
  830. {
  831. _result.Msg = "付款信息添加失败!";
  832. _sqlSugar.RollbackTran(); //回滚
  833. return _result;
  834. }
  835. #region 酒店基础数据 添加
  836. var hotelDataReq = new OperationHotelDto() {
  837. Status = 1,
  838. City = _dto.City,
  839. Name = _dto.HotelName,
  840. Tel = _dto.HotelTel,
  841. Address = _dto.HotelAddress
  842. };
  843. await _hotelDataRep.OperationHotelData(hotelDataReq);
  844. #endregion
  845. _result.Msg = "操作成功!";
  846. _result.Code = 0;
  847. _sqlSugar.CommitTran(); // 提交
  848. }
  849. else if (_dto.Id > 0) //Edit
  850. {
  851. _sqlSugar.BeginTran();
  852. int hotelStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  853. .UpdateColumns(it => new
  854. {
  855. it.GTId,
  856. it.CheckNumber,
  857. it.ReservationsWebsite,
  858. it.ReservationsNo,
  859. it.DetermineNo,
  860. it.City,
  861. it.HotelName,
  862. it.HotelTel,
  863. it.HotelAddress,
  864. it.GuestName,
  865. it.CheckInDate,
  866. it.CheckOutDate,
  867. it.CheckType,
  868. it.RoomExplanation,
  869. it.SingleRoomPrice,
  870. it.SingleRoomCount,
  871. it.DoubleRoomPrice,
  872. it.DoubleRoomCount,
  873. it.SuiteRoomPrice,
  874. it.SuiteRoomCount,
  875. it.OtherRoomPrice,
  876. it.OtherRoomCount,
  877. it.CardPrice,
  878. it.CardPriceCurrency,
  879. it.Isoppay,
  880. it.BreakfastPrice,
  881. it.BreakfastCurrency,
  882. it.GovernmentRent,
  883. it.GovernmentRentCurrency,
  884. it.CityTax,
  885. it.CityTaxCurrency,
  886. it.Remark,
  887. })
  888. .WhereColumns(it => it.Id)
  889. .ExecuteCommandAsync();
  890. if (hotelStatus < 0)
  891. {
  892. _result.Msg = "酒店预定信息修改失败!";
  893. _sqlSugar.RollbackTran(); //回滚
  894. return _result;
  895. }
  896. var hotelInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  897. .Where(it => it.DIId == _dto.DiId && it.CId == _dto.Id && it.CTable == 76 && it.IsDel == 0)
  898. .FirstAsync();
  899. if (hotelInfo == null) //ccp表 Add
  900. {
  901. }
  902. else //ccp表 Edit
  903. {
  904. _CreditCardPayment.Id = hotelInfo.Id;
  905. int creditCardStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>(_CreditCardPayment)
  906. .UpdateColumns(it => new
  907. {
  908. it.CTDId,
  909. it.PayDId,
  910. it.IsPay,
  911. it.ConsumptionPatterns,
  912. it.ConsumptionDate,
  913. it.PayMoney,
  914. it.PaymentCurrency,
  915. it.PayThenMoney,
  916. it.DayRate,
  917. it.RMBPrice,
  918. it.BankNo,
  919. it.CardholderName,
  920. it.CompanyBankNo,
  921. it.OtherBankName,
  922. it.OtherSideNo,
  923. it.OtherSideName,
  924. it.Payee,
  925. it.OrbitalPrivateTransfer,
  926. it.Remark,
  927. })
  928. .WhereColumns(it => it.Id)
  929. .ExecuteCommandAsync();
  930. if (creditCardStatus < 0)
  931. {
  932. _result.Msg = "付款信息表修改失败!";
  933. _sqlSugar.RollbackTran(); //回滚
  934. return _result;
  935. }
  936. }
  937. _result.Msg = "操作成功!";
  938. _result.Code = 0;
  939. _sqlSugar.CommitTran(); // 提交
  940. }
  941. else if (_dto.Id < 0) //不正确的Id
  942. {
  943. _result.Msg = "请输入正确的数据Id!";
  944. }
  945. }
  946. else
  947. {
  948. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS";
  949. }
  950. return _result;
  951. }
  952. /// <summary>
  953. /// 酒店预定
  954. /// Del
  955. /// </summary>
  956. /// <returns></returns>
  957. public async Task<Result> _Del(int id,int userId)
  958. {
  959. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations()
  960. {
  961. Id = id,
  962. IsDel = 1,
  963. DeleteUserId = userId,
  964. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  965. };
  966. int hrStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  967. .UpdateColumns(it => new
  968. {
  969. it.IsDel,
  970. it.DeleteUserId,
  971. it.DeleteTime,
  972. })
  973. .WhereColumns(it => it.Id)
  974. .ExecuteCommandAsync();
  975. if (hrStatus < 0)
  976. {
  977. _result.Msg = "操作失败!";
  978. return _result;
  979. }
  980. _result.Msg = "操作成功!";
  981. _result.Code = 0;
  982. return _result;
  983. }
  984. }
  985. }