CarTouristGuideGroundRepository.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  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. if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
  234. else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
  235. item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
  236. item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
  237. item.ServiceQuotedPrice = item.PayMoney;
  238. item.PayThenMoney = Math.Round(item.PayPercentage/100 * item.ServiceQuotedPrice, 2);
  239. item.RemainingBalance = Math.Round(item.ServiceQuotedPrice- item.PayPercentage / 100 * item.ServiceQuotedPrice);
  240. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  241. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  242. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  243. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  244. Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a=>a.IsDel==0 && a.Id==item.PayDid);
  245. if (s!=null)
  246. {
  247. item.PayStrd = s.Name;
  248. }else item.PayStrd ="未选择";
  249. }
  250. return result = new Result() { Code = 0, Msg = "查询成功!", Data = infoViews };
  251. }
  252. else if (dto.PortType == 2 || dto.PortType == 3)
  253. {
  254. string sql = string.Format(@"Select * From (
  255. Select row_number() over (order by c.IsAuditGM,c.PayPercentage desc) as RowNumber,t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage,c.PayDid
  256. from
  257. Grp_CarTouristGuideGroundReservations t
  258. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  259. left Join Sys_SetData s on s.Id=c.PaymentCurrency {0}
  260. ) temp Where RowNumber Between {1} and {2}", sqlWhere, startIndex, endIndex);
  261. List<Grp_CarTouristGuideGroundView> grp_CarTourists = _sqlSugar.SqlQueryable<Grp_CarTouristGuideGroundView>(sql).ToList();
  262. foreach (var item in grp_CarTourists)
  263. {
  264. if (item.OrbitalPrivateTransfer == 0) item.OrbitalPrivateTransferStr = "公转";
  265. else if (item.OrbitalPrivateTransfer == 1) item.OrbitalPrivateTransferStr = "私转";
  266. item.ServiceStartTime = Convert.ToDateTime(item.ServiceStartTime).ToString("yyyy-MM-dd");
  267. item.ServiceEndTime = Convert.ToDateTime(item.ServiceEndTime).ToString("yyyy-MM-dd");
  268. if (item.IsAuditGM == 0) item.IsAuditGMStr = "未审核";
  269. else if (item.IsAuditGM == 1) item.IsAuditGMStr = "已通过";
  270. else if (item.IsAuditGM == 2) item.IsAuditGMStr = "未通过";
  271. else if (item.IsAuditGM == 3) item.IsAuditGMStr = "自动审核";
  272. item.ServiceQuotedPrice = item.PayMoney;
  273. item.PayThenMoney = Math.Round(item.PayPercentage / 100 * item.ServiceQuotedPrice, 2);
  274. item.RemainingBalance = Math.Round(item.ServiceQuotedPrice - item.PayPercentage / 100 * item.ServiceQuotedPrice);
  275. Sys_SetData s = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == item.PayDid);
  276. if (s != null)
  277. {
  278. item.PayStrd = s.Name;
  279. }
  280. else item.PayStrd = "未选择";
  281. }
  282. string CountSql = string.Format(@"Select COUNT(1) as Count From (
  283. select t.*,s.Name as CurrencyStr,c.IsAuditGM,c.PayPercentage from
  284. Grp_CarTouristGuideGroundReservations t
  285. left Join Grp_CreditCardPayment c on CTable=79 and c.CId=t.Id and c.isdel=0
  286. left Join Sys_SetData s on s.Id=t.CId {0}
  287. ) temp ", sqlWhere);
  288. DataCount dataCount = _sqlSugar.SqlQueryable<DataCount>(CountSql).First();
  289. if (dataCount != null)
  290. {
  291. int count = dataCount.Count;
  292. float totalPage = (float)count / dto.PageSize;//总页数
  293. if (totalPage == 0) totalPage = 1;
  294. else totalPage = (int)Math.Ceiling((double)totalPage);
  295. ListViewBase<Grp_CarTouristGuideGroundView> rst = new ListViewBase<Grp_CarTouristGuideGroundView>();
  296. rst.DataList = grp_CarTourists;
  297. rst.DataCount = count;
  298. rst.CurrPageIndex = dto.PageIndex;
  299. rst.CurrPageSize = dto.PageSize;
  300. return result = new Result() { Code = 0, Msg = "查询成功!", Data = rst };
  301. }
  302. }
  303. }
  304. catch (Exception)
  305. {
  306. return result = new Result() { Code = -2, Msg = "未知错误" };
  307. throw;
  308. }
  309. return result;
  310. }
  311. /// <summary>
  312. /// OP费用录入填写详情
  313. /// </summary>
  314. /// <param name="dto"></param>
  315. /// <returns></returns>
  316. public async Task<Result> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  317. {
  318. Result result = new Result() { Code = -2, Msg = "未知错误" };
  319. try
  320. {
  321. BeginTran();
  322. List<Grp_CarTouristGuideGroundReservationsContent> carTouristList = new List<Grp_CarTouristGuideGroundReservationsContent>();
  323. foreach (var item in dto.OPContentList)
  324. {
  325. Grp_CarTouristGuideGroundReservationsContent s = new Grp_CarTouristGuideGroundReservationsContent();
  326. s.Id= item.Id;
  327. s.DiId = dto.DiId;
  328. s.CTGGRId = dto.CTGGRId;
  329. s.SId = item.SId;
  330. s.Price=item.Price;
  331. s.PriceContent = item.priceContent;
  332. s.Currency = dto.Currency;
  333. //s.Remark=item.Remark;
  334. s.CreateUserId = dto.CreateUserId;
  335. carTouristList.Add(s);
  336. }
  337. foreach (var item in carTouristList)
  338. {
  339. Grp_CarTouristGuideGroundReservationsContent QueryData = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().First(a => a.SId == item.SId && a.Id == item.Id && a.DiId == item.DiId && a.IsDel==0);
  340. if (QueryData==null)
  341. {
  342. if (item.Price!=0)
  343. {
  344. int id = await _sqlSugar.Insertable(item).ExecuteReturnIdentityAsync();
  345. if (id == 0)
  346. {
  347. RollbackTran();
  348. return result = new Result() { Code = -2, Msg = "添加失败" };
  349. }
  350. }
  351. }
  352. else
  353. {
  354. int CTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.Id == item.Id).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent
  355. {
  356. Price = item.Price,
  357. PriceContent = item.PriceContent,
  358. Currency = dto.Currency,
  359. Remark = item.Remark,
  360. }).ExecuteCommandAsync();
  361. if (CTable==0)
  362. {
  363. RollbackTran();
  364. return result = new Result() { Code = -1, Msg = "修改失败,请稍后重试!" };
  365. }
  366. }
  367. }
  368. //修改C表数据
  369. List<Grp_CarTouristGuideGroundReservationsContent> carTouristListEnd = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>().Where(a=>a.DiId==dto.DiId && a.CTGGRId==dto.CTGGRId && a.IsDel==0).ToList();
  370. Grp_CreditCardPayment c=new Grp_CreditCardPayment();
  371. c.PaymentCurrency = dto.Currency;
  372. foreach (var item in carTouristListEnd)
  373. {
  374. c.PayMoney += item.Price;
  375. }
  376. c.PayPercentage = dto.PayPercentage;
  377. c.ConsumptionDate= DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  378. c.CTable = 79;
  379. c.CId = dto.CTGGRId;
  380. c.IsAuditGM = 0;
  381. c.PayDId=dto.PayDId;
  382. c.DIId = dto.DiId;
  383. c.OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer;
  384. c.Payee=dto.Payee;
  385. c.CreateUserId=dto.CreateUserId;
  386. if (c.PayDId == 72)
  387. {
  388. c.IsPay = 1;
  389. }
  390. c.RMBPrice = c.PayMoney;
  391. c.DayRate = 1;
  392. Grp_TeamRate _TeamRate = _sqlSugar.Queryable<Grp_TeamRate>().First(a => a.DiId == dto.DiId && a.IsDel == 0 && a.CTable == 79);
  393. List<CurrencyInfo> currencyInfos = new List<CurrencyInfo>();
  394. if (_TeamRate != null)
  395. {
  396. Sys_SetData _SetData = _sqlSugar.Queryable<Sys_SetData>().First(a => a.IsDel == 0 && a.Id == c.PaymentCurrency);
  397. if (_SetData != null)
  398. {
  399. currencyInfos = CommonFun.GetCurrencyChinaToList(_TeamRate.Remark);
  400. CurrencyInfo CurrencyRate = currencyInfos.FirstOrDefault(a => a.CurrencyCode == _SetData.Name);
  401. if (CurrencyRate != null)
  402. {
  403. c.RMBPrice = c.PayMoney * Convert.ToDecimal(CurrencyRate.Rate);
  404. c.DayRate = CurrencyRate.Rate;
  405. }
  406. }
  407. }
  408. Grp_CreditCardPayment grp_CreditCard = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(a=>a.CId==dto.CTGGRId && a.IsDel==0 && a.CTable==79 && a.DIId==dto.DiId);
  409. if (grp_CreditCard!=null)//修改
  410. {
  411. 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
  412. {
  413. PaymentCurrency = c.PaymentCurrency,
  414. PayMoney = c.PayMoney,
  415. PayPercentage = c.PayPercentage,
  416. CTable = c.CTable,
  417. PayDId = c.PayDId,
  418. OrbitalPrivateTransfer = c.OrbitalPrivateTransfer,
  419. Payee = c.Payee,
  420. IsPay = c.IsPay,
  421. RMBPrice = c.RMBPrice,
  422. DayRate = c.DayRate,
  423. }).ExecuteCommandAsync();
  424. if (CTable == 0)
  425. {
  426. RollbackTran();
  427. return result = new Result() { Code = -2, Msg = "修改失败" };
  428. }
  429. }
  430. else//添加
  431. {
  432. int id = await _sqlSugar.Insertable(c).ExecuteReturnIdentityAsync();
  433. if (id == 0)
  434. {
  435. RollbackTran();
  436. return result = new Result() { Code = -2, Msg = "添加失败" };
  437. }
  438. }
  439. int CarTouristGuideCTable = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservations>().Where(a => a.Id == dto.CTGGRId && a.DiId == dto.DiId).SetColumns(a => new Grp_CarTouristGuideGroundReservations
  440. {
  441. CId=dto.Currency,
  442. ServiceQuotedPrice=c.PayMoney,
  443. OrbitalPrivateTransfer = dto.OrbitalPrivateTransfer,
  444. }).ExecuteCommandAsync();
  445. if (CarTouristGuideCTable == 0)
  446. {
  447. RollbackTran();
  448. return result = new Result() { Code = -2, Msg = "修改失败" };
  449. }
  450. result = new Result() { Code =0, Msg = "保存成功" };
  451. CommitTran();
  452. }
  453. catch (Exception)
  454. {
  455. return result = new Result() { Code = -2, Msg = "未知错误" };
  456. throw;
  457. }
  458. return result;
  459. }
  460. }
  461. }