HotelPriceRepository.cs 54 KB

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