HotelPriceRepository.cs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  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. _result.Code = -1;
  723. int portType = _dto.PortType;
  724. if (portType == 1 || portType == 2 || portType == 3)
  725. {
  726. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations();
  727. Grp_CreditCardPayment _CreditCardPayment = new Grp_CreditCardPayment();
  728. #region 参数处理
  729. _HotelReservations = _mapper.Map<Grp_HotelReservations>(_dto);
  730. _CreditCardPayment = _mapper.Map<Grp_CreditCardPayment>(_dto);
  731. _HotelReservations.DiId = _dto.DiId;
  732. _HotelReservations.CardPriceCurrency = _dto.CTDId;
  733. _HotelReservations.CreateUserId = _dto.UserId;
  734. _HotelReservations.Remark = _dto.HotelRemark;
  735. if (portType == 2 || portType == 3)
  736. {
  737. string checkNo = string.Empty;
  738. Result checkNoRes = await _CreateCheckVolumeNo(_dto.DiId);
  739. if (checkNoRes.Code == 0)
  740. {
  741. checkNo = checkNoRes.Data;
  742. _HotelReservations.CheckNumber = checkNo;
  743. }
  744. }
  745. #region CCP 表参数
  746. if (_dto.PayDId == 72) //刷卡 默认已支付
  747. {
  748. _CreditCardPayment.IsPay = 1;
  749. }
  750. _CreditCardPayment.CreateUserId = _dto.UserId;
  751. _CreditCardPayment.DIId = _dto.DiId;
  752. _CreditCardPayment.CTable = 76;
  753. _CreditCardPayment.CTDId = _dto.CTDId;
  754. _CreditCardPayment.PayPercentage = 100.00M;
  755. _CreditCardPayment.PayThenMoney = _CreditCardPayment.PayMoney;
  756. string paymentCurrencyCode = string.Empty;
  757. List<Sys_SetData> currencySouruce = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 66).ToListAsync();
  758. if (currencySouruce.Count > 0)
  759. {
  760. Sys_SetData currency = new Sys_SetData();
  761. currency = currencySouruce.Where(it => it.Id == _CreditCardPayment.PaymentCurrency).FirstOrDefault();
  762. if (currency != null)
  763. {
  764. paymentCurrencyCode = currency.Name;
  765. }
  766. }
  767. decimal currencyRate = 0.00M;
  768. if (_CreditCardPayment.PayMoney != 0)
  769. {
  770. if(_CreditCardPayment.PaymentCurrency < 1)
  771. {
  772. _result.Msg = "请选择付款币种!";
  773. return _result;
  774. }
  775. List<TeamRateModelView> teamRateModelViews = new List<TeamRateModelView>();
  776. teamRateModelViews = await _teamRateRep.PostGroupRateInfoByDiId(_dto.DiId);
  777. if (teamRateModelViews.Count < 0)
  778. {
  779. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  780. return _result;
  781. }
  782. TeamRateModelView teamRateModels_hotel = new TeamRateModelView();
  783. teamRateModels_hotel = teamRateModelViews.Where(it => it.CTableId == 76).FirstOrDefault();
  784. if (teamRateModels_hotel == null)
  785. {
  786. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  787. return _result;
  788. }
  789. List<TeamRateDescView> teamRateDescViews = new List<TeamRateDescView>();
  790. teamRateDescViews = teamRateModels_hotel.TeamRates;
  791. if (teamRateDescViews.Count < 0)
  792. {
  793. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  794. return _result;
  795. }
  796. TeamRateDescView teamRateDescView = new TeamRateDescView();
  797. teamRateDescView = teamRateDescViews.Where(it => it.CurrencyCode == paymentCurrencyCode).FirstOrDefault();
  798. if (teamRateDescView == null)
  799. {
  800. _result.Msg = "该团未设置酒店预订模块相关币种汇率!";
  801. return _result;
  802. }
  803. currencyRate = teamRateDescView.Rate;
  804. }
  805. _CreditCardPayment.DayRate = currencyRate;
  806. _CreditCardPayment.RMBPrice = (_CreditCardPayment.DayRate * _CreditCardPayment.PayMoney).DecimalsKeepTwo();
  807. //if (_CreditCardPayment.PayDId == 72) //刷卡
  808. //{
  809. // _CreditCardPayment.BankNo = "6222 **** **** 7990";
  810. // _CreditCardPayment.CardholderName = "Zhang Hailin";
  811. //}
  812. _CreditCardPayment.Remark = _dto.CcpRemark;
  813. #endregion
  814. #endregion
  815. if (_dto.Id == 0) // Add
  816. {
  817. _sqlSugar.BeginTran();
  818. int hotelId = await _sqlSugar.Insertable<Grp_HotelReservations>(_HotelReservations).ExecuteReturnIdentityAsync();
  819. if (hotelId < 0)
  820. {
  821. _result.Msg = "酒店预定信息添加失败!";
  822. _sqlSugar.RollbackTran(); //回滚
  823. return _result;
  824. }
  825. _CreditCardPayment.CId = hotelId;
  826. _CreditCardPayment.CTable = 76; //酒店预定模块
  827. int ccpId = await _sqlSugar.Insertable<Grp_CreditCardPayment>(_CreditCardPayment).ExecuteReturnIdentityAsync();
  828. if (ccpId < 0)
  829. {
  830. _result.Msg = "付款信息添加失败!";
  831. _sqlSugar.RollbackTran(); //回滚
  832. return _result;
  833. }
  834. #region 酒店基础数据 添加
  835. var hotelDataReq = new OperationHotelDto() {
  836. Status = 1,
  837. City = _dto.City,
  838. Name = _dto.HotelName,
  839. Tel = _dto.HotelTel,
  840. Address = _dto.HotelAddress
  841. };
  842. await _hotelDataRep.OperationHotelData(hotelDataReq);
  843. #endregion
  844. _result.Msg = "操作成功!";
  845. _result.Code = 0;
  846. _sqlSugar.CommitTran(); // 提交
  847. }
  848. else if (_dto.Id > 0) //Edit
  849. {
  850. _sqlSugar.BeginTran();
  851. int hotelStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  852. .UpdateColumns(it => new
  853. {
  854. it.GTId,
  855. it.CheckNumber,
  856. it.ReservationsWebsite,
  857. it.ReservationsNo,
  858. it.DetermineNo,
  859. it.City,
  860. it.HotelName,
  861. it.HotelTel,
  862. it.HotelAddress,
  863. it.GuestName,
  864. it.CheckInDate,
  865. it.CheckOutDate,
  866. it.CheckType,
  867. it.RoomExplanation,
  868. it.SingleRoomPrice,
  869. it.SingleRoomCount,
  870. it.DoubleRoomPrice,
  871. it.DoubleRoomCount,
  872. it.SuiteRoomPrice,
  873. it.SuiteRoomCount,
  874. it.OtherRoomPrice,
  875. it.OtherRoomCount,
  876. it.CardPrice,
  877. it.CardPriceCurrency,
  878. it.Isoppay,
  879. it.BreakfastPrice,
  880. it.BreakfastCurrency,
  881. it.GovernmentRent,
  882. it.GovernmentRentCurrency,
  883. it.CityTax,
  884. it.CityTaxCurrency,
  885. it.Remark,
  886. })
  887. .WhereColumns(it => it.Id)
  888. .ExecuteCommandAsync();
  889. if (hotelStatus < 0)
  890. {
  891. _result.Msg = "酒店预定信息修改失败!";
  892. _sqlSugar.RollbackTran(); //回滚
  893. return _result;
  894. }
  895. var hotelInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  896. .Where(it => it.DIId == _dto.DiId && it.CId == _dto.Id && it.CTable == 76 && it.IsDel == 0)
  897. .FirstAsync();
  898. if (hotelInfo == null) //ccp表 Add
  899. {
  900. }
  901. else //ccp表 Edit
  902. {
  903. _CreditCardPayment.Id = hotelInfo.Id;
  904. int creditCardStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>(_CreditCardPayment)
  905. .UpdateColumns(it => new
  906. {
  907. it.CTDId,
  908. it.PayDId,
  909. it.IsPay,
  910. it.ConsumptionPatterns,
  911. it.ConsumptionDate,
  912. it.PayMoney,
  913. it.PaymentCurrency,
  914. it.PayThenMoney,
  915. it.DayRate,
  916. it.RMBPrice,
  917. it.BankNo,
  918. it.CardholderName,
  919. it.CompanyBankNo,
  920. it.OtherBankName,
  921. it.OtherSideNo,
  922. it.OtherSideName,
  923. it.Payee,
  924. it.OrbitalPrivateTransfer,
  925. it.Remark,
  926. })
  927. .WhereColumns(it => it.Id)
  928. .ExecuteCommandAsync();
  929. if (creditCardStatus < 0)
  930. {
  931. _result.Msg = "付款信息表修改失败!";
  932. _sqlSugar.RollbackTran(); //回滚
  933. return _result;
  934. }
  935. }
  936. _result.Msg = "操作成功!";
  937. _result.Code = 0;
  938. _sqlSugar.CommitTran(); // 提交
  939. }
  940. else if (_dto.Id < 0) //不正确的Id
  941. {
  942. _result.Msg = "请输入正确的数据Id!";
  943. }
  944. }
  945. else
  946. {
  947. _result.Msg = "请传入正确的PortType参数,1 Web 2 Android 3 IOS";
  948. }
  949. return _result;
  950. }
  951. /// <summary>
  952. /// 酒店预定
  953. /// Del
  954. /// </summary>
  955. /// <returns></returns>
  956. public async Task<Result> _Del(int id,int userId)
  957. {
  958. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations()
  959. {
  960. Id = id,
  961. IsDel = 1,
  962. DeleteUserId = userId,
  963. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  964. };
  965. int hrStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  966. .UpdateColumns(it => new
  967. {
  968. it.IsDel,
  969. it.DeleteUserId,
  970. it.DeleteTime,
  971. })
  972. .WhereColumns(it => it.Id)
  973. .ExecuteCommandAsync();
  974. if (hrStatus < 0)
  975. {
  976. _result.Msg = "操作失败!";
  977. return _result;
  978. }
  979. _result.Msg = "操作成功!";
  980. _result.Code = 0;
  981. return _result;
  982. }
  983. }
  984. }