HotelPriceRepository.cs 54 KB

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