HotelPriceRepository.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. using AutoMapper;
  2. using MathNet.Numerics.Statistics.Mcmc;
  3. using MySqlX.XDevAPI.Common;
  4. using NPOI.SS.Formula.Functions;
  5. using OASystem.Domain;
  6. using OASystem.Domain.Dtos.Financial;
  7. using OASystem.Domain.Dtos.Groups;
  8. using OASystem.Domain.Dtos.Resource;
  9. using OASystem.Domain.Entities.Financial;
  10. using OASystem.Domain.Entities.Groups;
  11. using OASystem.Domain.ViewModels.Financial;
  12. using OASystem.Domain.ViewModels.Groups;
  13. using OASystem.Infrastructure.Repositories.Resource;
  14. using OASystem.Infrastructure.Tools;
  15. using Org.BouncyCastle.Asn1.Ocsp;
  16. using SqlSugar;
  17. using StackExchange.Redis;
  18. using System;
  19. using System.Collections.Generic;
  20. using System.Linq;
  21. using System.Text;
  22. using System.Threading.Tasks;
  23. using static NPOI.HSSF.Util.HSSFColor;
  24. using Result = OASystem.Domain.Result;
  25. namespace OASystem.Infrastructure.Repositories.Groups
  26. {
  27. public class HotelPriceRepository : BaseRepository<Grp_HotelReservations, Grp_HotelReservations>
  28. {
  29. private readonly IMapper _mapper;
  30. private readonly Result _result;
  31. private readonly JsonView _view;
  32. private readonly TeamRateRepository _teamRateRep;
  33. private readonly TourClientListRepository _tourClientListRep;
  34. private readonly HotelDataRepository _hotelDataRep;
  35. public HotelPriceRepository(SqlSugarClient sqlSugar, IMapper mapper, TeamRateRepository teamRateRep, TourClientListRepository tourClientListRep, HotelDataRepository hotelDataRep)
  36. :base(sqlSugar)
  37. {
  38. this._mapper = mapper;
  39. _result = new Result() { Code = -1, Msg = MsgTips.Fail };
  40. _view = new JsonView() { Code = 400, Msg = MsgTips.Fail };
  41. _teamRateRep = teamRateRep;
  42. _tourClientListRep = tourClientListRep;
  43. _hotelDataRep = hotelDataRep;
  44. }
  45. /// <summary>
  46. /// 酒店预定
  47. /// Items By DiId
  48. /// </summary>
  49. /// <param name="dto"></param>
  50. /// <returns></returns>
  51. public async Task<JsonView> _ItemsByDiId(int portType,int diId)
  52. {
  53. string sql = string.Format(@"Select row_number() over(order by hr.CheckInDate asc) as Row_Number,
  54. hr.Id,hr.DiId,sd1.Name As GuestType,hr.ReservationsNo,hr.HotelName,hr.CheckInDate,hr.CheckOutDate,
  55. ccp.PayMoney, ccp.PaymentCurrency,sd2.Name PayCurrency,hr.CreateUserId,u.CnName As CreateUserName,
  56. hr.CreateTime,ccp.IsAuditGM,ccp.IsPay
  57. From Grp_HotelReservations hr
  58. Inner Join Grp_CreditCardPayment ccp On hr.DiId = ccp.DIId And hr.Id = ccp.CId
  59. And ccp.CTable = 76
  60. Left Join Sys_SetData sd1 On hr.GTId = sd1.Id
  61. Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
  62. Left Join Sys_Users u On hr.CreateUserId = u.Id
  63. Where hr.IsDel = 0 And ccp.IsDel = 0 And hr.DiId = {0} ", diId);
  64. if (portType == 1 || portType == 2 || portType == 3)
  65. {
  66. var hotelFeeData = await _sqlSugar.SqlQueryable<HotelReservationsItemsView>(sql).ToListAsync();
  67. _view.Code = 200;
  68. _view.Data = hotelFeeData;
  69. _view.Msg = MsgTips.Succeed;
  70. }
  71. else
  72. {
  73. _view.Msg = MsgTips.Port;
  74. }
  75. return _view;
  76. }
  77. /// <summary>
  78. /// 酒店预定
  79. /// basicsData Init
  80. /// </summary>
  81. /// <param name="dto"></param>
  82. /// <returns></returns>
  83. public async Task<JsonView> _BasicsDataInit(int portType, int diId)
  84. {
  85. List<Sys_SetData> _dataSouruce = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0).ToListAsync();
  86. if (portType == 1 || portType == 2 || portType == 3)
  87. {
  88. //客人类型
  89. List<Sys_SetData> GuestType = _dataSouruce.Where(a => a.STid == 11).ToList();
  90. List<SetDataInfoView> _GuestType = _mapper.Map<List<SetDataInfoView>>(GuestType);
  91. //预订网站
  92. List<Sys_SetData> BookingWebsite = _dataSouruce.Where(a => a.STid == 12).ToList();
  93. List<SetDataInfoView> _BookingWebsite = _mapper.Map<List<SetDataInfoView>>(BookingWebsite);
  94. //支付方式
  95. List<Sys_SetData> Payment = _dataSouruce.Where(a => a.STid == 14).ToList();
  96. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  97. //卡类型
  98. List<Sys_SetData> BankCard = _dataSouruce.Where(a => a.STid == 15).ToList();
  99. List<SetDataCurrencyInfoView> _BankCard = _mapper.Map<List<SetDataCurrencyInfoView>>(BankCard);
  100. //房间入住人类型
  101. List<Sys_SetData> CheckPerson = _dataSouruce.Where(a => a.STid == 71).ToList();
  102. List<SetDataInfoView> _CheckPerson = _mapper.Map<List<SetDataInfoView>>(CheckPerson);
  103. var _teamRateView = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(portType, diId, 76);
  104. string _CheckVolumeNo = string.Empty;
  105. var checkVoumeNoData = _CreateCheckVolumeNo(diId);
  106. if (checkVoumeNoData.Result.Code == 0)
  107. {
  108. _CheckVolumeNo = checkVoumeNoData.Result.Data;
  109. }
  110. //客户名单
  111. var guestNames = await _tourClientListRep._GuestNameItemByDiId(portType, diId);
  112. //三公国家费用标准
  113. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  114. .Where(x => x.IsDel == 0 )
  115. .Select(x => new {
  116. x.Id,
  117. x.Country,
  118. x.City
  119. })
  120. .ToListAsync();
  121. var data = new
  122. {
  123. GuestType = _GuestType, //客人分类
  124. Payment = _Payment,
  125. CurrencyList = _teamRateView,
  126. BankCard = _BankCard,
  127. BookingWebsite = _BookingWebsite,
  128. CheckPerson = _CheckPerson,
  129. CheckVolumeNo = _CheckVolumeNo,
  130. GuestName = guestNames,
  131. Countrys = countrys
  132. };
  133. _view.Code = 200;
  134. _view.Data = data;
  135. _view.Msg = MsgTips.Succeed;
  136. }
  137. else _view.Msg = MsgTips.Port;
  138. return _view;
  139. }
  140. /// <summary>
  141. /// 酒店预定
  142. /// 创建 入住卷号码
  143. /// </summary>
  144. /// <param name="DiId"></param>
  145. /// <returns></returns>
  146. public async Task<Result> _CreateCheckVolumeNo(int DiId)
  147. {
  148. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == DiId && it.IsDel == 0).FirstAsync();
  149. if (groupInfo != null)
  150. {
  151. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  152. {
  153. string no = string.Empty;
  154. string[] countrys = new string[] { };
  155. countrys = groupInfo.VisitCountry.Split('|');
  156. foreach (string country in countrys)
  157. {
  158. //国家城市三字码 未挪数据 暂时用随机数代替
  159. }
  160. no = CommonFun.GetRandomLetter(countrys.Length).ToUpper();
  161. no += CommonFun.GetRandomNumber(2);
  162. _result.Code = 0;
  163. _result.Data = no;
  164. _result.Msg = "入住卷号码 获取成功!";
  165. }
  166. }
  167. return _result;
  168. }
  169. /// <summary>
  170. /// 酒店预定-
  171. /// details
  172. /// </summary>
  173. /// <param name="dto"></param>
  174. /// <returns></returns>
  175. public async Task<JsonView> _Details(int portType, int id)
  176. {
  177. if (id < 0 )
  178. {
  179. _view.Msg = string.Format(@"请输入正确的Id!");
  180. return _view;
  181. }
  182. string sql = string.Format(@"Select hr.Id,hr.DiId,hr.GTId,hr.CheckNumber,hr.ReservationsWebsite,hr.ReservationsNo,
  183. hr.DetermineNo,hr.AreaId,hr.City,hr.HotelName,hr.HotelTel,hr.HotelAddress,hr.GuestName,hr.CheckInDate,hr.CheckOutDate,
  184. hr.CheckType,hr.RoomExplanation,hr.Remark As HotelRemark,hr.SingleRoomPrice,hr.SingleRoomCount,hr.DoubleRoomPrice,
  185. hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount,hr.OtherRoomPrice,hr.OtherRoomCount,hr.CardPrice,hr.CardPriceCurrency,
  186. hr.Isoppay,hr.BreakfastPrice,hr.BreakfastCurrency,hr.GovernmentRent,hr.GovernmentRentCurrency,hr.CityTax,
  187. hr.CityTaxCurrency,ccp.PayDId,ccp.ConsumptionPatterns,ccp.ConsumptionDate,ccp.PayMoney,ccp.PaymentCurrency,
  188. ccp.BankNo,ccp.CardholderName,ccp.CompanyBankNo,ccp.OtherBankName,ccp.OtherSideNo,ccp.OtherSideName,ccp.Payee,
  189. ccp.OrbitalPrivateTransfer,ccp.Remark As CcpRemark
  190. From Grp_HotelReservations hr
  191. Inner Join Grp_CreditCardPayment ccp On hr.DiId = ccp.DIId And hr.Id = ccp.CId
  192. And ccp.CTable = 76
  193. Where hr.IsDel = 0 And ccp.IsDel = 0 And hr.Id = {0}", id);
  194. if (portType == 1 || portType == 2 || portType == 3)
  195. {
  196. var info = await _sqlSugar.SqlQueryable<HotelReservationsDetailsView>(sql).FirstAsync();
  197. string contentSql = string.Format($@"Select
  198. Id,
  199. DiId,
  200. HrId,
  201. PriceType,
  202. Price,
  203. Currency,
  204. Rate,
  205. IsOppay,
  206. PayDId,
  207. ConsumptionPatterns,
  208. ConsumptionDate,
  209. CTDId,
  210. BankNo,
  211. CardholderName,
  212. CompanyBankNo,
  213. OtherBankName,
  214. OtherSideNo,
  215. OtherSideName,
  216. IsPay,
  217. Payee,
  218. OrbitalPrivateTransfer
  219. From Grp_HotelReservationsContent With(NoLock)
  220. Where IsDel = 0 And HrId = {info.Id}");
  221. info.Contents = await _sqlSugar.SqlQueryable<HotelReservationsContnetDetailsView>(contentSql).ToListAsync();
  222. _view.Code = 200;
  223. _view.Data = info;
  224. _view.Msg = MsgTips.Succeed;
  225. }
  226. else _view.Msg = MsgTips.Port;
  227. return _view;
  228. }
  229. /// <summary>
  230. /// 酒店预定
  231. /// Add Or Edit
  232. /// </summary>
  233. /// <returns></returns>
  234. public async Task<JsonView> _AddOrEdit(HotelReservationsAddOrEditDto _dto)
  235. {
  236. var _view = new JsonView() { Code = 400, Msg = MsgTips.Fail };
  237. int portType = _dto.PortType;
  238. if (portType == 1 || portType == 2 || portType == 3)
  239. {
  240. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations();
  241. List<Grp_HotelReservationsContent> _HotelReservationsContents = new List<Grp_HotelReservationsContent>();
  242. Grp_CreditCardPayment _CreditCardPayment = new Grp_CreditCardPayment();
  243. #region 参数处理
  244. _HotelReservations = _mapper.Map<Grp_HotelReservations>(_dto);
  245. _HotelReservationsContents = _mapper.Map<List<Grp_HotelReservationsContent>>(_dto.Contents);
  246. _CreditCardPayment = _mapper.Map<Grp_CreditCardPayment>(_dto);
  247. _HotelReservations.DiId = _dto.DiId;
  248. _HotelReservations.CreateUserId = _dto.UserId;
  249. _HotelReservations.Remark = _dto.HotelRemark;
  250. #region 子表币种汇率处理
  251. //List<Sys_SetData> currData = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 66).ToListAsync();
  252. //List<TeamRateModelView> teamRateModelViews = new List<TeamRateModelView>();
  253. //teamRateModelViews = await _teamRateRep.PostGroupRateInfoByDiId(_dto.DiId);
  254. //if (teamRateModelViews.Count < 0)
  255. //{
  256. // _view.Msg = "该团未设置酒店预订模块相关币种汇率!";
  257. // return _view;
  258. //}
  259. //TeamRateModelView teamRateModels_hotel = new TeamRateModelView();
  260. //teamRateModels_hotel = teamRateModelViews.Where(it => it.CTableId == 76).FirstOrDefault();
  261. //if (teamRateModels_hotel == null)
  262. //{
  263. // _view.Msg = "该团未设置酒店预订模块相关币种汇率!";
  264. // return _view;
  265. //}
  266. //List<TeamRateDescView> teamRateDescViews = new List<TeamRateDescView>();
  267. //teamRateDescViews = teamRateModels_hotel.TeamRates;
  268. //if (teamRateDescViews.Count < 0)
  269. //{
  270. // _view.Msg = "该团未设置酒店预订模块相关币种汇率!";
  271. // return _view;
  272. //}
  273. #endregion
  274. _HotelReservationsContents.ForEach(it => {
  275. it.CreateUserId = _dto.UserId;
  276. it.DiId = _dto.DiId;
  277. it.HrId = _HotelReservations.Id;
  278. //2024-12-05 10:18 更改代付逻辑:是否由地接或其他人代付: 是 : ispay = 0 否 : ispay = 1
  279. if (it.PayDId == 72 || it.IsOppay == 0) it.IsPay = 1;
  280. else it.IsPay = 0;
  281. if (!string.IsNullOrEmpty(it.ConsumptionDate))
  282. {
  283. if (DateTime.TryParse(it.ConsumptionDate, out DateTime dt))
  284. {
  285. it.ConsumptionDate = dt.ToString("yyyy-MM-dd");
  286. }
  287. }
  288. //var currCode = currData.Find(x => x.Id == it.Currency)?.Name;
  289. //decimal? currRate = teamRateDescViews.Find(x => x.CurrencyCode == currCode)?.Rate;
  290. //it.Rate = currRate ?? 0.00M;
  291. });
  292. _HotelReservationsContents = _HotelReservationsContents.OrderBy(x => x.PriceType).ToList();
  293. if (portType == 2 || portType == 3)
  294. {
  295. string checkNo = string.Empty;
  296. Result checkNoRes = await _CreateCheckVolumeNo(_dto.DiId);
  297. if (checkNoRes.Code == 0)
  298. {
  299. checkNo = checkNoRes.Data;
  300. _HotelReservations.CheckNumber = checkNo;
  301. }
  302. }
  303. #region CCP 表参数
  304. _CreditCardPayment.CreateUserId = _dto.UserId;
  305. _CreditCardPayment.DIId = _dto.DiId;
  306. _CreditCardPayment.CTable = 76;
  307. _CreditCardPayment.PayMoney = _dto.CardPrice;
  308. _CreditCardPayment.PaymentCurrency = _dto.CardPriceCurrency;
  309. decimal ccpRate = 1.0000M;
  310. if (_dto.CardPriceCurrency != 836) ccpRate = _dto.Contents.Find(x => x.Currency == _dto.CardPriceCurrency)?.Rate ?? 1.0000M;
  311. _CreditCardPayment.DayRate = ccpRate;
  312. _CreditCardPayment.PayPercentage = 100.00M;
  313. _CreditCardPayment.PayThenMoney = _CreditCardPayment.PayMoney;
  314. _CreditCardPayment.RMBPrice = (_CreditCardPayment.DayRate * _CreditCardPayment.PayMoney).DecimalsKeepTwo();
  315. //if (_CreditCardPayment.PayDId == 72) //刷卡
  316. //{
  317. // _CreditCardPayment.BankNo = "6222 **** **** 7990";
  318. // _CreditCardPayment.CardholderName = "Zhang Hailin";
  319. //}
  320. _CreditCardPayment.Remark = _dto.CcpRemark;
  321. #endregion
  322. #endregion
  323. if (_dto.Id == 0) // Add
  324. {
  325. _sqlSugar.BeginTran();
  326. int hotelId = await _sqlSugar.Insertable<Grp_HotelReservations>(_HotelReservations).ExecuteReturnIdentityAsync();
  327. if (hotelId < 0)
  328. {
  329. _sqlSugar.RollbackTran(); //回滚
  330. _view.Msg = $"酒店预定信息添加失败!";
  331. return _view;
  332. }
  333. _HotelReservationsContents.ForEach(it => {
  334. it.HrId = hotelId;
  335. });
  336. int hotelSubId = await _sqlSugar.Insertable<Grp_HotelReservationsContent>(_HotelReservationsContents).ExecuteReturnIdentityAsync();
  337. if (hotelSubId < 0)
  338. {
  339. _sqlSugar.RollbackTran(); //回滚
  340. _view.Msg = "酒店预定详细信息添加失败";
  341. return _view;
  342. }
  343. _CreditCardPayment.CId = hotelId;
  344. _CreditCardPayment.CTable = 76; //酒店预定模块
  345. int ccpId = await _sqlSugar.Insertable<Grp_CreditCardPayment>(_CreditCardPayment).ExecuteReturnIdentityAsync();
  346. if (ccpId < 0)
  347. {
  348. _view.Msg = "付款信息添加失败!";
  349. _sqlSugar.RollbackTran(); //回滚
  350. return _view;
  351. }
  352. #region 酒店基础数据 添加
  353. var hotelDataReq = new OperationHotelDto()
  354. {
  355. Status = 1,
  356. City = _dto.City,
  357. Name = _dto.HotelName,
  358. Tel = _dto.HotelTel,
  359. Address = _dto.HotelAddress
  360. };
  361. await _hotelDataRep.OperationHotelData(hotelDataReq);
  362. #endregion
  363. _view.Msg = "操作成功!";
  364. _view.Code = 200;
  365. _view.Data = new { ccpId = ccpId, sign = 1, hotelId = hotelId };
  366. _sqlSugar.CommitTran(); // 提交
  367. return _view;
  368. }
  369. else if (_dto.Id > 0) //Edit
  370. {
  371. _sqlSugar.BeginTran();
  372. int hotelStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  373. .UpdateColumns(it => new
  374. {
  375. it.GTId,
  376. it.CheckNumber,
  377. it.ReservationsWebsite,
  378. it.ReservationsNo,
  379. it.DetermineNo,
  380. it.AreaId,
  381. it.City,
  382. it.HotelName,
  383. it.HotelTel,
  384. it.HotelAddress,
  385. it.GuestName,
  386. it.CheckInDate,
  387. it.CheckOutDate,
  388. it.CheckType,
  389. it.RoomExplanation,
  390. it.SingleRoomPrice,
  391. it.SingleRoomCount,
  392. it.DoubleRoomPrice,
  393. it.DoubleRoomCount,
  394. it.SuiteRoomPrice,
  395. it.SuiteRoomCount,
  396. it.OtherRoomPrice,
  397. it.OtherRoomCount,
  398. it.CardPrice,
  399. it.CardPriceCurrency,
  400. it.Remark,
  401. })
  402. .WhereColumns(it => it.Id)
  403. .ExecuteCommandAsync();
  404. if (hotelStatus < 0)
  405. {
  406. _view.Msg = "酒店预定信息修改失败!";
  407. _sqlSugar.RollbackTran(); //回滚
  408. return _view;
  409. }
  410. var hotelSubStatus = false;
  411. var addHotelSubData = _HotelReservationsContents.Where(it => it.Id == 0).ToList();
  412. var updateHotelSubData = _HotelReservationsContents.Where(it => it.Id != 0).ToList();
  413. if (addHotelSubData.Count > 0)
  414. {
  415. int hotelSubAdd = await _sqlSugar.Insertable<Grp_HotelReservationsContent>(addHotelSubData).ExecuteCommandAsync();
  416. if (hotelSubAdd > 0) hotelSubStatus = true;
  417. }
  418. if (updateHotelSubData.Count > 0)
  419. {
  420. int hotelSubUpdate = await _sqlSugar.Updateable<Grp_HotelReservationsContent>(updateHotelSubData)
  421. .IgnoreColumns(it => new {
  422. it.DiId,
  423. it.HrId,
  424. it.CreateUserId,
  425. it.CreateTime,
  426. it.DeleteUserId,
  427. it.DeleteTime
  428. })
  429. .WhereColumns(it => it.Id)
  430. .ExecuteCommandAsync();
  431. if (hotelSubUpdate > 0) hotelSubStatus = true;
  432. }
  433. if (!hotelSubStatus)
  434. {
  435. _view.Msg = "酒店预定子表信息修改失败!";
  436. _sqlSugar.RollbackTran(); //回滚
  437. return _view;
  438. }
  439. var hotelInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  440. .Where(it => it.DIId == _dto.DiId &&
  441. it.CId == _dto.Id &&
  442. it.CTable == 76 &&
  443. it.IsDel == 0
  444. )
  445. .FirstAsync();
  446. if (hotelInfo == null) //ccp表 Add
  447. {
  448. }
  449. else //ccp表 Edit
  450. {
  451. _CreditCardPayment.Id = hotelInfo.Id;
  452. int creditCardStatus = await _sqlSugar.Updateable(_CreditCardPayment)
  453. .UpdateColumns(it => new
  454. {
  455. it.CTDId,
  456. it.PayDId,
  457. it.IsPay,
  458. it.ConsumptionPatterns,
  459. it.ConsumptionDate,
  460. it.PayMoney,
  461. it.PaymentCurrency,
  462. it.PayThenMoney,
  463. it.DayRate,
  464. it.RMBPrice,
  465. it.BankNo,
  466. it.CardholderName,
  467. it.CompanyBankNo,
  468. it.OtherBankName,
  469. it.OtherSideNo,
  470. it.OtherSideName,
  471. it.Payee,
  472. it.OrbitalPrivateTransfer,
  473. it.Remark,
  474. })
  475. .WhereColumns(it => it.Id)
  476. .ExecuteCommandAsync();
  477. if (creditCardStatus < 0)
  478. {
  479. _view.Msg = "付款信息表修改失败!";
  480. _sqlSugar.RollbackTran(); //回滚
  481. return _view;
  482. }
  483. }
  484. _view.Msg = "操作成功!";
  485. _view.Code = 200;
  486. _view.Data = new { ccpId = _CreditCardPayment.Id, sign = 2 ,hotelId = _HotelReservations.Id };
  487. _sqlSugar.CommitTran(); // 提交
  488. return _view;
  489. }
  490. else if (_dto.Id < 0) _view.Msg = MsgTips.Id;
  491. }
  492. else _view.Msg = MsgTips.Port;
  493. return _view;
  494. }
  495. /// <summary>
  496. /// 酒店预定
  497. /// Del
  498. /// </summary>
  499. /// <returns></returns>
  500. public async Task<JsonView> _Del(int id,int userId)
  501. {
  502. _sqlSugar.BeginTran();
  503. Grp_HotelReservations _HotelReservations = new Grp_HotelReservations()
  504. {
  505. Id = id,
  506. IsDel = 1,
  507. DeleteUserId = userId,
  508. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  509. };
  510. int hrStatus = await _sqlSugar.Updateable<Grp_HotelReservations>(_HotelReservations)
  511. .UpdateColumns(it => new
  512. {
  513. it.IsDel,
  514. it.DeleteUserId,
  515. it.DeleteTime,
  516. })
  517. .WhereColumns(it => it.Id)
  518. .ExecuteCommandAsync();
  519. if (hrStatus < 0)
  520. {
  521. _sqlSugar.RollbackTran();
  522. return new JsonView() { Code = 400,Msg = MsgTips.Fail };
  523. }
  524. int hrSubStatus = await _sqlSugar.Updateable<Grp_HotelReservationsContent>()
  525. .SetColumns(it => it.IsDel == 1)
  526. .SetColumns(it => it.DeleteUserId == userId)
  527. .SetColumns(it => it.DeleteTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  528. .Where(it => it.HrId == id).ExecuteCommandAsync();
  529. var ccpInfp = new Grp_CreditCardPayment() {
  530. CId = id,
  531. CTable = 76,
  532. IsDel = 1,
  533. DeleteUserId = userId,
  534. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  535. };
  536. int hrCCPStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>(ccpInfp)
  537. .UpdateColumns(it => new
  538. {
  539. it.IsDel,
  540. it.DeleteUserId,
  541. it.DeleteTime,
  542. })
  543. .WhereColumns(it => new { it.CTable, it.CId })
  544. .ExecuteCommandAsync();
  545. _sqlSugar.CommitTran();
  546. return new JsonView() { Code = 200, Msg = MsgTips.Succeed };
  547. }
  548. }
  549. }