CarTouristGuideGroundRepository.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. using AutoMapper;
  2. using OASystem.Domain;
  3. using OASystem.Domain.Dtos.Groups;
  4. using OASystem.Domain.Entities.Financial;
  5. using OASystem.Domain.Entities.Groups;
  6. using OASystem.Domain.Entities.Resource;
  7. using OASystem.Domain.ViewModels.Groups;
  8. using OASystem.Infrastructure.Tools;
  9. using System.Collections.Generic;
  10. namespace OASystem.Infrastructure.Repositories.Groups
  11. {
  12. public class CarTouristGuideGroundRepository:BaseRepository<Grp_CarTouristGuideGroundReservations, Grp_CarTouristGuideGroundReservationsContent>
  13. {
  14. private readonly IMapper _mapper;
  15. public CarTouristGuideGroundRepository(SqlSugarClient sqlSugar, IMapper mapper)
  16. : base(sqlSugar)
  17. {
  18. _mapper = mapper;
  19. }
  20. public async Task<Result> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  21. {
  22. Result result = new Result() { Code = -2, Msg = "未知错误" };
  23. BeginTran();
  24. try
  25. {
  26. int id = 0;
  27. Grp_CarTouristGuideGroundReservations grp_CarTouristGuide = _mapper.Map<Grp_CarTouristGuideGroundReservations>(dto);
  28. if (dto.Status == 1)//添加
  29. {
  30. Grp_CarTouristGuideGroundReservations grp_CarTouristGuideGround = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().First(a => a.IsDel == 0 && a.Area == dto.Area && a.BusName == dto.BusName && a.ServiceGuide == dto.ServiceGuide && a.DiId==dto.DiId && a.BusTel==dto.BusTel && a.ServiceTel==dto.ServiceTel);
  31. if (grp_CarTouristGuideGround != null)
  32. {
  33. return result = new Result() { Code = -1, Msg = "该笔费用已存在,请勿重复添加!" };
  34. }
  35. else
  36. {
  37. id = await AddAsyncReturnId(grp_CarTouristGuide);
  38. if (id == 0)
  39. {
  40. RollbackTran();
  41. result = new Result() { Code = -1, Msg = "添加失败,请稍后重试!" };
  42. }
  43. else
  44. {
  45. result = new Result() { Code = 0, Msg = "添加成功!" };
  46. }
  47. }
  48. }
  49. else if (dto.Status == 2)//修改
  50. {
  51. bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_CarTouristGuideGroundReservations
  52. {
  53. Area = grp_CarTouristGuide.Area,
  54. ServiceCompany = grp_CarTouristGuide.ServiceCompany,
  55. ServiceGuide = grp_CarTouristGuide.ServiceGuide,
  56. ServiceTel = grp_CarTouristGuide.ServiceTel,
  57. BusName = grp_CarTouristGuide.BusName,
  58. BusDescription = grp_CarTouristGuide.BusDescription,
  59. BusTel = grp_CarTouristGuide.BusTel,
  60. ServiceStartTime = grp_CarTouristGuide.ServiceStartTime,
  61. ServiceEndTime = grp_CarTouristGuide.ServiceEndTime,
  62. ServiceDescription = grp_CarTouristGuide.ServiceDescription,
  63. QuotedPriceExplanation = grp_CarTouristGuide.QuotedPriceExplanation,
  64. OrbitalPrivateTransfer = grp_CarTouristGuide.OrbitalPrivateTransfer,
  65. Remark = grp_CarTouristGuide.Remark,
  66. });
  67. if (res)
  68. {
  69. id = dto.Id;
  70. result = new Result() { Code = 0, Msg = "修改成功!" };
  71. }
  72. else
  73. {
  74. RollbackTran();
  75. result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
  76. }
  77. }
  78. if (id!=0)
  79. {
  80. Res_LocalGuideData _LocalGuideDataCar = _sqlSugar.Queryable<Res_LocalGuideData>().First(a => a.UnitName == dto.BusName && a.ContactTel == dto.BusTel && a.IsDel == 0);
  81. if (_LocalGuideDataCar == null)
  82. {
  83. Res_LocalGuideData res_LocalGuideCar = new Res_LocalGuideData();
  84. res_LocalGuideCar.UnitName = dto.BusName;
  85. res_LocalGuideCar.ContactTel = dto.BusTel;
  86. res_LocalGuideCar.CreateUserId = dto.CreateUserId;
  87. int cId = await _sqlSugar.Insertable(res_LocalGuideCar).ExecuteReturnIdentityAsync();
  88. }
  89. Res_LocalGuideData _LocalGuideDataService = _sqlSugar.Queryable<Res_LocalGuideData>().First(a => a.UnitName == dto.ServiceCompany && a.ContactTel == dto.ServiceTel && a.IsDel == 0);
  90. if (_LocalGuideDataService == null)
  91. {
  92. Res_LocalGuideData res_LocalGuideService = new Res_LocalGuideData();
  93. res_LocalGuideService.UnitName = dto.ServiceCompany;
  94. res_LocalGuideService.ContactTel = dto.ServiceTel;
  95. res_LocalGuideService.Contact = dto.ServiceTel;
  96. res_LocalGuideService.CreateUserId = dto.CreateUserId;
  97. int cId = await _sqlSugar.Insertable(res_LocalGuideService).ExecuteReturnIdentityAsync();
  98. }
  99. }
  100. CommitTran();
  101. }
  102. catch (Exception ex)
  103. {
  104. result = new Result() { Code = -2, Msg = "未知错误" };
  105. }
  106. return result;
  107. }
  108. public async Task<Result> CarTouristGuideGroundContent(CarTouristGuideGroundContentDto dto)
  109. {
  110. Result result = new Result() { Code = -2, Msg = "未知错误" };
  111. try
  112. {
  113. List<Grp_GroupsTaskAssignment> grp_GroupsTaskAssignment = Query<Grp_GroupsTaskAssignment>(a => a.IsDel == 0 && a.UId == dto.UserId && a.CTId == 79).ToList();
  114. string DiId = "0";
  115. foreach (var item in grp_GroupsTaskAssignment)
  116. {
  117. DiId += item.DIId + ",";
  118. }
  119. if (DiId != "0")
  120. {
  121. DiId = DiId.Substring(0, DiId.Length - 1);
  122. }
  123. string sql = string.Format(@"select * from Grp_DelegationInfo where Id in({0}) and IsDel={1}", DiId, 0);
  124. //团组下拉框
  125. List<Grp_DelegationInfo> _Delegations = _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToList();
  126. List<ShareGroupInfoIIView> grp_Delegations = _mapper.Map<List<ShareGroupInfoIIView>>(_Delegations);
  127. //支付方式
  128. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  129. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  130. //币种
  131. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  132. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  133. //列表初始化
  134. List<Sys_SetData> TableInitialization = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 17 && a.IsDel == 0).ToList();
  135. List<SetDataInfoView> _TableInitialization = _mapper.Map<List<SetDataInfoView>>(TableInitialization);
  136. _TableInitialization= _TableInitialization.OrderBy(a=>a.Name).ToList();
  137. var data = new
  138. {
  139. Payment = _Payment,
  140. CurrencyList = _CurrencyList,
  141. Delegations = grp_Delegations,
  142. TableInitialization = _TableInitialization
  143. };
  144. return result = new Result() { Code = 0, Msg = "查询成功",Data=data };
  145. }
  146. catch (Exception)
  147. {
  148. return result = new Result() { Code = -2, Msg = "未知错误" };
  149. throw;
  150. }
  151. }
  152. public async Task<Result> OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  153. {
  154. Result result = new Result() { Code = -2, Msg = "未知错误" };
  155. try
  156. {
  157. List<Grp_CarTouristGuideGroundReservationsContent> grp_CarTouristsContent = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.IsDel==0 && a.CTGGRId==dto.Id).ToList();
  158. List<CarTouristGuideGroundReservationsContentView> carTouristGuides = _mapper.Map<List<CarTouristGuideGroundReservationsContentView>>(grp_CarTouristsContent);
  159. foreach (var item in carTouristGuides)
  160. {
  161. item.SidName= _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == item.SId).Name;
  162. }
  163. Grp_CreditCardPayment CreditCardPayment = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79);
  164. CarTouristCreditCardPaymentView _CreditCardPayment = _mapper.Map<CarTouristCreditCardPaymentView>(CreditCardPayment);
  165. if (_CreditCardPayment!=null)
  166. {
  167. _CreditCardPayment.PayName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PayDId).Name;
  168. _CreditCardPayment.PaymentCurrencyName = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == _CreditCardPayment.PaymentCurrency).Name;
  169. if (_CreditCardPayment.OrbitalPrivateTransfer==0) _CreditCardPayment.OrbitalPrivateTransferStr = "公转";
  170. else _CreditCardPayment.OrbitalPrivateTransferStr = "私转";
  171. }
  172. var data = new
  173. {
  174. CarTouristsContent = carTouristGuides,
  175. CreditCardPayment = _CreditCardPayment,
  176. };
  177. return result = new Result() { Code = 0, Msg = "查询成功", Data = data };
  178. }
  179. catch (Exception)
  180. {
  181. return result = new Result() { Code = -2, Msg = "未知错误" };
  182. throw;
  183. }
  184. }
  185. /// <summary>
  186. /// 根据diid查询op费用列表
  187. /// </summary>
  188. /// <param name="dto"></param>
  189. /// <returns></returns>
  190. public async Task<Result> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  191. {
  192. Result result = new Result() { Code = -2, Msg = "未知错误" };
  193. if (dto.PortType == 0 || string.IsNullOrWhiteSpace(dto.PortType.ToString()))
  194. {
  195. return result = new Result() { Code = -1, Msg = "请传入PortType参数,请求端口分类 1 Web 2 Android 3 IOS" };
  196. }
  197. try
  198. {
  199. #region SQL条件拼接
  200. string sqlWhere = string.Empty;
  201. sqlWhere += string.Format(@"And t.DIId={0} and t.isdel={1}", dto.DiId, 0);
  202. string UserId = "";
  203. List<Grp_GroupsTaskAssignment> gtaUIdList = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>().Where(a => a.DIId == dto.DiId && a.IsDel == 0 && a.CTId == 79).ToList();
  204. foreach (Grp_GroupsTaskAssignment gta in gtaUIdList)
  205. UserId += gta.UId + ",";
  206. if (!string.IsNullOrWhiteSpace(UserId))
  207. {
  208. UserId = UserId.Substring(0, UserId.Length - 1);
  209. }
  210. else
  211. {
  212. UserId = "0";
  213. }
  214. sqlWhere += string.Format(@" And t.CreateUserId in ({0})", UserId);
  215. if (!string.IsNullOrEmpty(sqlWhere.Trim()))
  216. {
  217. Regex r = new Regex("And");
  218. sqlWhere = r.Replace(sqlWhere, "Where", 1);
  219. }
  220. #endregion
  221. int startIndex = (dto.PageIndex - 1) * dto.PageSize + 1;
  222. int endIndex = startIndex + dto.PageSize - 1;
  223. if (dto.PortType == 1)
  224. {
  225. string sql = string.Format(@"select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage,c.PayMoney,c.PayDid from
  226. Grp_CarTouristGuideGroundReservations t
  227. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  228. left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
  229. order by c.IsAuditGM,c.PayPercentage desc", sqlWhere);
  230. List<Grp_CarTouristGuideGroundView> infoViews = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
  231. foreach (var item in infoViews)
  232. {
  233. item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
  234. item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
  235. item.ServiceQuotedPrice = item.PayMoney;
  236. item.PayThenMoney = Math.Round(item.PayPercentage/100 * item.ServiceQuotedPrice, 2);
  237. item.RemainingBalance = Math.Round(item.ServiceQuotedPrice- item.PayPercentage / 100 * item.ServiceQuotedPrice);
  238. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  239. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  240. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  241. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  242. Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a=>a.IsDel==0 && a.Id==item.PayDid);
  243. if (s!=null)
  244. {
  245. item.PayStrd = s.Name;
  246. }else item.PayStrd ="未选择";
  247. }
  248. return result = new Result() { Code = 0, Msg = "查询成功!", Data = infoViews };
  249. }
  250. else if (dto.PortType == 2 || dto.PortType == 3)
  251. {
  252. string sql = string.Format(@"Select * From (
  253. Select row_number() over (order by c.IsAuditGM,c.PayPercentage desc) as RowNumber,t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage,c.PayDid
  254. from
  255. Grp_CarTouristGuideGroundReservations t
  256. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  257. left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
  258. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  259. List<Grp_CarTouristGuideGroundView> grp_CarTourists = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
  260. foreach (var item in grp_CarTourists)
  261. {
  262. item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
  263. item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
  264. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  265. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  266. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  267. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  268. item.ServiceQuotedPrice = item.PayMoney;
  269. item.PayThenMoney = Math.Round(item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
  270. item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice);
  271. Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == item.PayDid);
  272. if (s != null)
  273. {
  274. item.PayStrd = s.Name;
  275. }
  276. else item.PayStrd = "未选择";
  277. }
  278. string CountSql = string.Format(@"Select COUNT(1) as Count From (
  279. select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage from
  280. Grp_CarTouristGuideGroundReservations t
  281. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  282. left Join Sys_SetData s on s.Id=t.CId {0}
  283. ) temp ", sqlWhere);
  284. DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
  285. if (dataCount != null)
  286. {
  287. int count = dataCount.Count;
  288. float totalPage = (float)count / dto.PageSize;//总页数
  289. if (totalPage == 0) totalPage = 1;
  290. else totalPage = (int)Math.Ceiling((double)totalPage);
  291. ListViewBase<Grp_CarTouristGuideGroundView> rst = new ListViewBase<Grp_CarTouristGuideGroundView>();
  292. rst.DataList = grp_CarTourists;
  293. rst.DataCount = count;
  294. rst.CurrPageIndex = dto.PageIndex;
  295. rst.CurrPageSize = dto.PageSize;
  296. return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
  297. }
  298. }
  299. }
  300. catch (Exception)
  301. {
  302. return result = new Result() { Code = -2, Msg = "未知错误" };
  303. throw;
  304. }
  305. return result;
  306. }
  307. /// <summary>
  308. /// OP费用录入填写详情
  309. /// </summary>
  310. /// <param name="dto"></param>
  311. /// <returns></returns>
  312. public async Task<Result> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  313. {
  314. Result result = new Result() { Code = -2, Msg = "未知错误" };
  315. try
  316. {
  317. BeginTran();
  318. List<Grp_CarTouristGuideGroundReservationsContent> carTouristList = new List<Grp_CarTouristGuideGroundReservationsContent>();
  319. foreach (var item in dto.OPContentList)
  320. {
  321. Grp_CarTouristGuideGroundReservationsContent s = new Grp_CarTouristGuideGroundReservationsContent();
  322. s.Id= item.Id;
  323. s.DiId = dto.DiId;
  324. s.CTGGRId = dto.CTGGRId;
  325. s.SId = item.SId;
  326. s.Price=item.Price;
  327. s.PriceContent = item.priceContent;
  328. s.Currency = dto.Currency;
  329. //s.Remark=item.Remark;
  330. s.CreateUserId = dto.CreateUserId;
  331. carTouristList.Add(s);
  332. }
  333. foreach (var item in carTouristList)
  334. {
  335. Grp_CarTouristGuideGroundReservationsContent QueryData = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().First(a => a.SId == item.SId && a.Id == item.Id && a.DiId == item.DiId && a.IsDel==0);
  336. if (QueryData==null)
  337. {
  338. if (item.Price!=0)
  339. {
  340. int id = await _sqlSugar.Insertable(item).ExecuteReturnIdentityAsync();
  341. if (id == 0)
  342. {
  343. RollbackTran();
  344. return result = new Result() { Code = -2, Msg = "添加失败" };
  345. }
  346. }
  347. }
  348. else
  349. {
  350. int CTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.Id == item.Id).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent
  351. {
  352. Price = item.Price,
  353. PriceContent = item.PriceContent,
  354. Currency = dto.Currency,
  355. Remark = item.Remark,
  356. }).ExecuteCommandAsync();
  357. if (CTable==0)
  358. {
  359. RollbackTran();
  360. return result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
  361. }
  362. }
  363. }
  364. //修改C表数据
  365. List<Grp_CarTouristGuideGroundReservationsContent> carTouristListEnd = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.DiId==dto.DiId && a.CTGGRId==dto.CTGGRId && a.IsDel==0).ToList();
  366. Grp_CreditCardPayment c=new Grp_CreditCardPayment();
  367. c.PaymentCurrency = dto.Currency;
  368. foreach (var item in carTouristListEnd)
  369. {
  370. c.PayMoney += item.Price;
  371. }
  372. c.PayPercentage = dto.PayPercentage;
  373. c.ConsumptionDate= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  374. c.CTable = 79;
  375. c.CId = dto.CTGGRId;
  376. c.IsAuditGM = 0;
  377. c.PayDId=dto.PayDId;
  378. c.DIId = dto.DiId;
  379. c.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  380. c.Payee=dto.Payee;
  381. c.CreateUserId=dto.CreateUserId;
  382. if (c.PayDId == 72)
  383. {
  384. c.IsPay = 1;
  385. }
  386. c.RMBPrice = c.PayMoney;
  387. c.DayRate = 1;
  388. Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 79);
  389. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  390. if (_TeamRate != null)
  391. {
  392. Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
  393. if (_SetData != null)
  394. {
  395. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  396. CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  397. if (CurrencyRate != null)
  398. {
  399. c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
  400. c.DayRate = CurrencyRate.Rate;
  401. }
  402. }
  403. }
  404. Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a=>a.CId==dto.CTGGRId && a.IsDel==0 && a.CTable==79 && a.DIId==dto.DiId);
  405. if (grp_CreditCard!=null)//修改
  406. {
  407. int CTable = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId==dto.DiId).SetColumns(a => new Grp_CreditCardPayment
  408. {
  409. PaymentCurrency = c.PaymentCurrency,
  410. PayMoney = c.PayMoney,
  411. PayPercentage = c.PayPercentage,
  412. CTable = c.CTable,
  413. PayDId = c.PayDId,
  414. OrbitalPrivateTransfer = c.OrbitalPrivateTransfer,
  415. Payee = c.Payee,
  416. IsPay = c.IsPay,
  417. RMBPrice = c.RMBPrice,
  418. DayRate = c.DayRate,
  419. }).ExecuteCommandAsync();
  420. if (CTable == 0)
  421. {
  422. RollbackTran();
  423. return result = new Result() { Code = -2, Msg = "修改失败" };
  424. }
  425. }
  426. else//添加
  427. {
  428. int id = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
  429. if (id == 0)
  430. {
  431. RollbackTran();
  432. return result = new Result() { Code = -2, Msg = "添加失败" };
  433. }
  434. }
  435. int CarTouristGuideCTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservations>().Where(a => a.Id == dto.CTGGRId && a.DiId == dto.DiId).SetColumns(a => new Grp_CarTouristGuideGroundReservations
  436. {
  437. CId=dto.Currency,
  438. ServiceQuotedPrice=c.PayMoney,
  439. OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
  440. }).ExecuteCommandAsync();
  441. if (CarTouristGuideCTable == 0)
  442. {
  443. RollbackTran();
  444. return result = new Result() { Code = -2, Msg = "修改失败" };
  445. }
  446. result = new Result() { Code =0, Msg = "保存成功" };
  447. CommitTran();
  448. }
  449. catch (Exception)
  450. {
  451. return result = new Result() { Code = -2, Msg = "未知错误" };
  452. throw;
  453. }
  454. return result;
  455. }
  456. }
  457. }