HotelPriceRepository.cs 55 KB

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