EnterExitCostRepository.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. 
  2. using AutoMapper;
  3. using NPOI.SS.Formula.Functions;
  4. using OASystem.Domain;
  5. using OASystem.Domain.Dtos.Groups;
  6. using OASystem.Domain.Dtos.System;
  7. using OASystem.Domain.Entities.Groups;
  8. using OASystem.Domain.ViewModels.Groups;
  9. using OASystem.Infrastructure.Repositories.System;
  10. using OASystem.Infrastructure.Tools;
  11. using System;
  12. using System.Collections.Generic;
  13. using System.Linq;
  14. using System.Security.Policy;
  15. using System.Text;
  16. using System.Threading.Tasks;
  17. namespace OASystem.Infrastructure.Repositories.Groups
  18. {
  19. /// <summary>
  20. /// 出入境费用 仓库
  21. /// </summary>
  22. public class EnterExitCostRepository : BaseRepository<Grp_EnterExitCost, EnterExitCostView>
  23. {
  24. private readonly IMapper _mapper;
  25. private readonly SetDataRepository _setDataRep;
  26. public EnterExitCostRepository(SqlSugarClient sqlSugar, IMapper mapper, SetDataRepository setDataRep)
  27. : base(sqlSugar)
  28. {
  29. _setDataRep = setDataRep;
  30. _mapper = mapper;
  31. }
  32. /// <summary>
  33. /// 出入境费用正式 --> 权限验证
  34. /// </summary>
  35. /// <param name="groupId">团组Id</param>
  36. /// <param name="permission">操作权限 1:查看;2:新增;3:编辑;4:删除;5:下载; </param>
  37. /// <returns></returns>
  38. public async Task<bool> PermissionValidationAsync(int groupId, int permission)
  39. {
  40. //参数验证
  41. if (groupId < 1) return false;
  42. var permissionIds = new List<int>() { 1, 2, 3, 4, 5 };
  43. if (!permissionIds.Contains(permission)) return false;
  44. var info = await _sqlSugar.Queryable<Grp_EnterExitCostPermission>()
  45. .Where(it => it.GroupId == groupId && it.Permission == permission)
  46. .FirstAsync();
  47. if (info != null) return true;
  48. return false;
  49. }
  50. /// <summary>
  51. /// 更新出入境费用汇率信息
  52. /// </summary>
  53. /// <returns></returns>
  54. public async Task<Result> SetEnterExitCostCurrencyChange()
  55. {
  56. Result result = new Result { Code = -1, Msg = "未知错误" };
  57. var enterExitList = await _sqlSugar.Queryable<Grp_EnterExitCost>().ToListAsync();
  58. foreach (var item in enterExitList)
  59. {
  60. string rateStr = string.Format(@"美元(USD):{0}|日元(JPY):{1}|欧元(EUR):{2}|英镑(GBP):{3}|港币(HKD):{4}", item.RateUSD, item.RateJPY, item.RateEUR, item.RateGBP, item.RateHKD);
  61. item.CurrencyRemark = rateStr;
  62. }
  63. var res = await _sqlSugar.Updateable(enterExitList)
  64. .WhereColumns(it => new { it.Id })
  65. .UpdateColumns(it => new { it.CurrencyRemark })
  66. .ExecuteCommandAsync();
  67. if (res > 0)
  68. {
  69. result.Code = 0;
  70. result.Msg = res.ToString();
  71. return result;
  72. }
  73. return result;
  74. }
  75. /// <summary>
  76. /// 查询 根据 Diid 查询
  77. /// </summary>
  78. /// <returns></returns>
  79. public async Task<JsonView> GetEnterExitCostInfoByDiId(EnterExitCostInfobyDiIdDto dto)
  80. {
  81. var result = new JsonView() { Code = 400 , Msg = "暂无数据" };
  82. var enterExitCostData = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  83. //Sys_PageFunctionPermission Function = _mapper.Map<Sys_PageFunctionPermission>(dto);
  84. var enterExitCostInfoView = new EnterExitCostInfoView();
  85. if (dto.PortType == 1) // Web
  86. {
  87. if (enterExitCostData != null)
  88. {
  89. var isView = await PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  90. if (enterExitCostData.CreateUserId == dto.CurrUserId) {
  91. enterExitCostInfoView.IsSave = true; //操作权限
  92. enterExitCostInfoView.IsView = true; //查看权限
  93. }
  94. if (!isView)
  95. {
  96. var setUserName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == enterExitCostData.CreateUserId).Select(x => x.CnName).FirstAsync();
  97. result.Msg = $"{setUserName}设置了你不能查看当前团组的出入境费用明细数据,如要查看,请联系{setUserName}!";
  98. return result;
  99. }
  100. enterExitCostInfoView.ViewUsers = await _sqlSugar
  101. .Queryable<Grp_EnterExitCostPermission>()
  102. .Where(x => x.GroupId == dto.DiId)
  103. .Select(x => x.UserId)
  104. .ToArrayAsync();
  105. enterExitCostInfoView = _mapper.Map<EnterExitCostInfoView>(enterExitCostData);
  106. //enterExitCostInfoView.FirstItemRemark = enterExitCostData.Remark;
  107. var dayAndCostSql = string.Format(@"Select ntf.Country,ntf.City,ssd.Name CurremcyCode,ssd.Remark CurrencyName,gdac.* From Grp_DayAndCost gdac
  108. Left Join Grp_NationalTravelFee ntf On ntf.Id = gdac.NationalTravelFeeId
  109. Left Join Sys_SetData ssd On ssd.STid = 66 And gdac.Currency = ssd.Id
  110. Where gdac.Isdel = 0 And ntf.IsDel = 0 And gdac.DiId = {0} Order By [Type] ASC,[Days] ASC", dto.DiId);
  111. var dayAndCostData = await _sqlSugar.SqlQueryable<DayAndCostInfoView>(dayAndCostSql).ToListAsync();
  112. enterExitCostInfoView.QuarterageData = dayAndCostData.Where(it => it.Type == 1).ToList(); //住宿费 1
  113. enterExitCostInfoView.BoardWagesData = dayAndCostData.Where(it => it.Type == 2).ToList(); //伙食费 2
  114. enterExitCostInfoView.MiscellaneousFeeData = dayAndCostData.Where(it => it.Type == 3).ToList(); //公杂费 3
  115. enterExitCostInfoView.TrainingExpenseData = dayAndCostData.Where(it => it.Type == 4).ToList(); //培训费 4
  116. enterExitCostInfoView.DayOtherPriceData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  117. .Where(x => x.IsDel == 0 && x.Diid == dto.DiId)
  118. .OrderBy(x => x.Index)
  119. .Select(x => new DayOtherPriceView
  120. {
  121. DiId = x.Diid,
  122. Id = x.Id,
  123. Cost = x.Cost,
  124. Currency = x.Currency,
  125. Index = x.Index,
  126. SetDataId = x.SetDataId,
  127. SubTotal = x.SubTotal,
  128. Remark = x.Remark,
  129. })
  130. .ToList();
  131. enterExitCostInfoView.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostData.CurrencyRemark);
  132. result.Msg = "操作成功";
  133. result.Code = 200;
  134. }
  135. else
  136. {
  137. // List<DayAndCostInfoView> views = new List<DayAndCostInfoView>()
  138. // {
  139. // new DayAndCostInfoView {Days=1},
  140. // new DayAndCostInfoView {Days=2},
  141. // new DayAndCostInfoView {Days=3},
  142. // new DayAndCostInfoView {Days=4},
  143. // new DayAndCostInfoView {Days=5},
  144. // new DayAndCostInfoView {Days=6},
  145. // new DayAndCostInfoView {Days=7},
  146. // new DayAndCostInfoView {Days=8},
  147. // };
  148. // enterExitCostInfoView.QuarterageData = views;
  149. // enterExitCostInfoView.BoardWagesData = views;
  150. // enterExitCostInfoView.MiscellaneousFeeData = views;
  151. // enterExitCostInfoView.TrainingExpenseData = views;
  152. // result.Code = 0;
  153. enterExitCostInfoView.IsView = true;
  154. enterExitCostInfoView.IsSave = true;
  155. result.Msg = "未查询出数据!可操作该条数据!";
  156. }
  157. result.Data = enterExitCostInfoView;
  158. }
  159. else if (dto.PortType == 2 || dto.PortType == 3)
  160. {
  161. var mobileInfo = new EnterExitCostMobileInfoView();
  162. if (enterExitCostData != null)
  163. {
  164. mobileInfo = _mapper.Map<EnterExitCostMobileInfoView>(enterExitCostData);
  165. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  166. .LeftJoin<Grp_NationalTravelFee>((dac,ntf) => dac.NationalTravelFeeId == ntf.Id)
  167. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  168. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  169. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  170. {
  171. SubId = dac.Id,
  172. DiId = dac.DiId,
  173. Type = dac.Type,
  174. Days = dac.Days,
  175. NationalTravelFeeId = dac.NationalTravelFeeId,
  176. Arae = $"{ntf.Country}-{ntf.City}",
  177. Cost = dac.Cost,
  178. Currency = dac.Currency,
  179. CurrencyName = sd.Name,
  180. SubTotal = dac.SubTotal,
  181. })
  182. .ToList();
  183. mobileInfo.ChoiceOneTotalCost = enterExitCostData.InsidePay;
  184. mobileInfo.ChoiceOneDetails = new ChoiceOneMobileInfoView() {
  185. Visa = enterExitCostData.Visa,
  186. VisaRemark = enterExitCostData.VisaRemark,
  187. YiMiao = enterExitCostData.YiMiao,
  188. HeSuan = enterExitCostData.HeSuan,
  189. Service = enterExitCostData.Service,
  190. Ticket = enterExitCostData.Ticket,
  191. Safe = enterExitCostData.Safe,
  192. };
  193. mobileInfo.ChoiceTwoDetails = new ChoiceTwoMobileInfoView()
  194. {
  195. AirJJ = enterExitCostData.AirJJ,
  196. AirGW = enterExitCostData.AirGW,
  197. AirTD = enterExitCostData.AirTD,
  198. CityTranffic = enterExitCostData.CityTranffic
  199. };
  200. mobileInfo.ChoiceThreeDetails = dayAndCostData.Where(it => it.Type == 1).OrderBy(it => it.Days).ToArray(); //住宿费 1
  201. mobileInfo.ChoiceFourDetails = dayAndCostData.Where(it => it.Type == 2).OrderBy(it => it.Days).ToArray(); //伙食费 2
  202. mobileInfo.ChoiceFiveDetails = dayAndCostData.Where(it => it.Type == 3).OrderBy(it => it.Days).ToArray(); //公杂费 3
  203. mobileInfo.ChoiceSixDetails = dayAndCostData.Where(it => it.Type == 4).OrderBy(it => it.Days).ToArray(); //培训费 4
  204. //其他款项
  205. mobileInfo.OtherExpensesDetails = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  206. .LeftJoin<Sys_SetData>((dop,sd1) => dop.SetDataId == sd1.Id)
  207. .LeftJoin<Sys_SetData>((dop, sd1,sd2) => dop.Currency == sd2.Id)
  208. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  209. .OrderBy((dop, sd1, sd2) => dop.Index)
  210. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  211. {
  212. SubId = dop.Id,
  213. DiId = dop.Diid,
  214. Index = dop.Index,
  215. SetDataId = dop.SetDataId,
  216. SetDataName = sd1.Name,
  217. Cost = dop.Cost,
  218. Currency = dop.Currency,
  219. CurrencyName = sd2.Remark,
  220. SubTotal = dop.SubTotal,
  221. Remark = dop.Remark,
  222. })
  223. .ToArray();
  224. mobileInfo.Currencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostData.CurrencyRemark);
  225. result.Msg = "查询成功";
  226. result.Code = 200;
  227. }
  228. result.Data = mobileInfo;
  229. }
  230. else result.Msg = MsgTips.Port;
  231. return result;
  232. }
  233. /// <summary>
  234. /// Add Or Update
  235. /// </summary>
  236. /// <param name="dto"></param>
  237. /// <returns></returns>
  238. public async Task<Result> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  239. {
  240. Result result = new Result() { Code = -1, Msg = "操作失败!" };
  241. if (dto.SumJJC == 0) dto.OutsideJJPay = 0;
  242. if (dto.SumGWC == 0) dto.OutsideGWPay = 0;
  243. if (dto.SumTDC == 0) dto.OutsideTDPay = 0;
  244. var enterExitCost = _mapper.Map<Grp_EnterExitCost>(dto);
  245. //enterExitCost.Remark = dto.FirstItemRemark;
  246. //enterExitCost.InsidePay = enterExitCost.Visa + enterExitCost.YiMiao + enterExitCost.HeSuan + enterExitCost.Service + enterExitCost.Safe + enterExitCost.Ticket;
  247. List<Grp_DayAndCost> subData = new List<Grp_DayAndCost>();
  248. var quarterageData = _mapper.Map<List<Grp_DayAndCost>>(dto.QuarterageData); //住宿费 1
  249. quarterageData = quarterageData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
  250. if (quarterageData.Count > 0) subData.AddRange(quarterageData);
  251. var boardWagesData = _mapper.Map<List<Grp_DayAndCost>>(dto.BoardWagesData); //伙食费 2
  252. boardWagesData = boardWagesData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
  253. if (boardWagesData.Count > 0) subData.AddRange(boardWagesData);
  254. var miscellaneousFeeData = _mapper.Map<List<Grp_DayAndCost>>(dto.MiscellaneousFeeData); //公杂费 3
  255. miscellaneousFeeData = miscellaneousFeeData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
  256. if (miscellaneousFeeData.Count > 0) subData.AddRange(miscellaneousFeeData);
  257. var trainingExpenseData = _mapper.Map<List<Grp_DayAndCost>>(dto.TrainingExpenseData); //培训费 4
  258. trainingExpenseData = trainingExpenseData.Select(it => { it.CreateUserId = dto.UserId; return it; }).ToList();
  259. if (trainingExpenseData.Count > 0) subData.AddRange(trainingExpenseData);
  260. //处理币种string
  261. enterExitCost.CurrencyRemark = CommonFun.GetCurrencyChinaToString(dto.Currencys);
  262. enterExitCost.CreateUserId = dto.UserId;
  263. _sqlSugar.BeginTran();
  264. if (dto.PortType == 1)
  265. {
  266. try
  267. {
  268. int enterExitId = 0;
  269. if (enterExitCost.Id > 0) //修改
  270. {
  271. //操作权限验证 只有创建人可修改
  272. var info = await _sqlSugar.Queryable<Grp_EnterExitCost,Sys_Users>((eec,u) => new JoinQueryInfos(JoinType.Left,eec.CreateUserId == u.Id))
  273. .Where(it => it.IsDel == 0 && it.Id == enterExitCost.Id)
  274. .Select((eec, u) => new { eec.CreateUserId,u.CnName })
  275. .FirstAsync();
  276. if (info.CreateUserId != dto.UserId)
  277. {
  278. _sqlSugar.RollbackTran();
  279. result.Msg = $"该条信息只有操作人“{info.CnName}”可修改!";
  280. return result;
  281. }
  282. //修改验证
  283. //IsConfirm == 2 不可修改
  284. //var info = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.Id == enterExitCost.Id).First();
  285. //if (info.IsConfirm == 2)
  286. //{
  287. // result.Msg = "该团出入境费用已确认!不可更改!!";
  288. // return result;
  289. //}
  290. var updateId = _sqlSugar.Updateable<Grp_EnterExitCost>(enterExitCost)
  291. .IgnoreColumns(it => new { it.DeleteUserId, it.DeleteTime, it.CreateUserId, it.CreateTime, it.IsDel })
  292. .ExecuteCommand();
  293. if (updateId > 0)
  294. {
  295. enterExitId = enterExitCost.Id;
  296. }
  297. else
  298. {
  299. _sqlSugar.RollbackTran();
  300. result.Msg = "修改操作失败!";
  301. return result;
  302. }
  303. }
  304. else
  305. {
  306. //效重 根据团组Id
  307. var info = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  308. if (info != null )
  309. {
  310. _sqlSugar.RollbackTran();
  311. result.Msg = "该团组相关数据已存在,请勿重新添加!";
  312. return result;
  313. }
  314. //添加
  315. enterExitId = _sqlSugar.Insertable<Grp_EnterExitCost>(enterExitCost).ExecuteReturnIdentity();
  316. if (enterExitId < 1)
  317. {
  318. _sqlSugar.RollbackTran();
  319. result.Msg = "添加操作失败!";
  320. return result;
  321. }
  322. }
  323. if (enterExitId > 0)
  324. {
  325. string sqlDelete = string.Format(@" Delete From Grp_DayAndCost Where Diid = {0} ", dto.DiId);
  326. await ExecuteCommandAsync(sqlDelete);
  327. foreach (var item in subData)
  328. {
  329. var updateId = _sqlSugar.Insertable<Grp_DayAndCost>(item).ExecuteCommand();
  330. if (updateId < 1)
  331. {
  332. _sqlSugar.RollbackTran();
  333. result.Msg = "添加操作失败!";
  334. return result;
  335. }
  336. }
  337. }
  338. _sqlSugar.CommitTran();
  339. result.Code = 0;
  340. result.Msg = "操作成功!";
  341. result.Data = new { sign = enterExitId };
  342. }
  343. catch (Exception ex)
  344. {
  345. _sqlSugar.RollbackTran();
  346. result.Msg = ex.Message;
  347. }
  348. }
  349. else result.Msg = MsgTips.Port;
  350. return result;
  351. }
  352. /// <summary>
  353. /// 确认费用
  354. /// </summary>
  355. /// <param name="id"></param>
  356. /// <returns></returns>
  357. public async Task<JsonView> ConfirmCost(ConfirmCostDto dto)
  358. {
  359. var _view = new JsonView() { Code = 20001, Msg = "操作失败!" };
  360. if (dto.Id < 1)
  361. {
  362. _view.Msg = MsgTips.Id;
  363. return _view;
  364. }
  365. int confirm = 1;
  366. if (dto.Type == 1) confirm = 2; // 确认
  367. else if (dto.Type == 2) { confirm = 1; } // 撤回
  368. else
  369. {
  370. _view.Msg = "请传入正确的type;1:确认 2:撤回";
  371. return _view;
  372. }
  373. var update = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  374. .SetColumns(x => new Grp_EnterExitCost() { IsConfirm = confirm })
  375. .Where(x => x.Id == dto.Id)
  376. .ExecuteCommandAsync();
  377. if (update>0)
  378. {
  379. _view.Code = 200;
  380. _view.Msg = "操作成功!";
  381. return _view;
  382. }
  383. return _view;
  384. }
  385. /// <summary>
  386. /// Del
  387. /// </summary>
  388. /// <param name="dto"></param>
  389. /// <returns></returns>
  390. public async Task<Result> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  391. {
  392. Result result = new Result();
  393. var data = new Grp_DayAndCost()
  394. {
  395. Id = dto.Id,
  396. IsDel = 1,
  397. DeleteUserId = dto.DeleteUserId,
  398. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  399. };
  400. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  401. if (del > 0) result.Code = 0;
  402. else result.Msg = string.Format("删除失败!");
  403. return result;
  404. }
  405. /// <summary>
  406. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  407. /// </summary>
  408. /// <param name="dto"></param>
  409. /// <returns></returns>
  410. public async Task<Result> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  411. {
  412. Result result = new Result();
  413. Grp_NationalTravelFee nationalTravelFee = _mapper.Map<Grp_NationalTravelFee>(dto);
  414. nationalTravelFee.LastUpdateUserId = dto.UserId;
  415. nationalTravelFee.CreateUserId = dto.UserId;
  416. if (dto.PortType == 1) //web
  417. {
  418. var _nationalTravelFee = _sqlSugar.Storageable<Grp_NationalTravelFee>(nationalTravelFee).ToStorage();
  419. if (dto.Id == 0) //新增
  420. {
  421. string selectSql = string.Format(@"Select * From Grp_NationalTravelFee
  422. Where IsDel = 0
  423. And Continent = '{0}'
  424. And Country = '{1}'
  425. And City = '{2}'", dto.Continent, dto.Country, dto.City);
  426. Grp_NationalTravelFee nationalTravelFee1 = new Grp_NationalTravelFee();
  427. nationalTravelFee1 = await _sqlSugar.SqlQueryable<Grp_NationalTravelFee>(selectSql).FirstAsync();
  428. if (nationalTravelFee1 != null)
  429. {
  430. result.Msg = "该国家 城市已存在,请勿重复添加!";
  431. return result;
  432. }
  433. _nationalTravelFee.AsInsertable.ExecuteCommand(); //不存在插入
  434. }
  435. else
  436. {
  437. _nationalTravelFee.AsUpdateable
  438. .IgnoreColumns(it => new { it.CreateUserId, it.CreateTime, it.IsDel })
  439. .WhereColumns(it => it.Id)
  440. .ExecuteCommand(); //存在更新
  441. }
  442. result.Code = 0;
  443. }
  444. else if (dto.PortType == 2) //Android
  445. {
  446. }
  447. else if (dto.PortType == 3) //Ios
  448. {
  449. }
  450. else result.Msg = MsgTips.Port;
  451. return result;
  452. }
  453. /// <summary>
  454. /// 一键清空
  455. /// 删除主表数据 Update
  456. /// 删除子表数据 delete
  457. /// </summary>
  458. /// <param name="id"></param>
  459. /// <param name="diid"></param>
  460. /// <returns></returns>
  461. public async Task<Result> _OneClickClear(int id, int diId, int userId)
  462. {
  463. Result result = new Result() { Code = -1, Msg = "操作成功!" };
  464. if (id < 1) return result = new Result() { Code = -1, Msg = "请传入有效的Id参数!" };
  465. if (diId < 1) return result = new Result() { Code = -1, Msg = "请传入有效的Id参数!" };
  466. if (userId < 1) return result = new Result() { Code = -1, Msg = "请传入有效的UserId参数!" };
  467. BeginTran();
  468. Grp_EnterExitCost _EnterExitCost = new Grp_EnterExitCost() {
  469. Id = id,
  470. IsDel = 1,
  471. DeleteUserId = userId,
  472. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  473. };
  474. //int update = await _sqlSugar.Updateable<Grp_EnterExitCost>(_EnterExitCost).Where(it => it.Id == id).ExecuteCommandAsync();
  475. int update = await _sqlSugar.Updateable<Grp_EnterExitCost>(_EnterExitCost)
  476. .UpdateColumns(it => new {
  477. it.IsDel,
  478. it.DeleteUserId ,
  479. it.DeleteTime
  480. })
  481. .Where(it => it.Id == id).ExecuteCommandAsync();
  482. if (update > 0) {
  483. string sqlDelete = string.Format(@"Delete From Grp_DayAndCost Where Diid = {0} ", diId);
  484. await ExecuteCommandAsync(sqlDelete);
  485. result.Code = 0;
  486. result.Msg = "操作成功!";
  487. CommitTran();
  488. }
  489. else
  490. {
  491. result.Msg = "操作失败";
  492. RollbackTran();
  493. }
  494. return result;
  495. }
  496. }
  497. }