HotelPriceRepository.cs 55 KB

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