GroupCostParameterRepository.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. using AutoMapper;
  2. using OASystem.Domain.Entities.Groups;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace OASystem.Infrastructure.Repositories.Groups
  9. {
  10. public class GroupCostParameterRepository : BaseRepository<Grp_GroupCostParameter, Grp_GroupCostParameterView>
  11. {
  12. public GroupCostParameterRepository(SqlSugarClient sqlSugar) :
  13. base(sqlSugar)
  14. {
  15. }
  16. public List<Grp_GroupCostParameter> GetGroupCostParameterListByDiid(int diid)
  17. {
  18. return Query(x=>x.DiId == diid).ToList();
  19. }
  20. public Grp_GroupCostParameter GetGroupCostParameterMainByDiid(int diid)
  21. {
  22. return Query(x => x.DiId == diid).First(x => x.CostType == "A");
  23. }
  24. public async Task<bool> UpdateIsShareById(int id,int IsShare)
  25. {
  26. return await UpdateAsync(x => x.Id == id, x=>new Grp_GroupCostParameter { IsShare = IsShare });
  27. }
  28. public async Task<bool> DeleteGroupCostParameterListByDiid(int diid)
  29. {
  30. return await SoftDeleteAsync(x=>x.DiId == diid);
  31. }
  32. public async Task<bool> SaveAsync(List<Grp_GroupCostParameter> List,int Userid, int diid)
  33. {
  34. bool isTrue = false;
  35. try
  36. {
  37. BeginTran();
  38. isTrue = await DeleteGroupCostParameterListByDiid(diid);
  39. if (List.Count > 0)
  40. {
  41. List.ForEach(x => { x.CreateUserId = Userid; x.CreateTime = DateTime.Now; });
  42. isTrue = Adds(List) > 0;
  43. }
  44. CommitTran();
  45. }
  46. catch (Exception ex)
  47. {
  48. RollbackTran();
  49. isTrue = false;
  50. }
  51. return isTrue;
  52. }
  53. public object GetBaoPi(int diid)
  54. {
  55. List<dynamic> dynamics = new List<dynamic>();
  56. try
  57. {
  58. Grp_EnterExitCost eec = _sqlSugar.Queryable<Grp_EnterExitCost>().First(x => x.DiId == diid);
  59. if (eec != null)
  60. {
  61. var AirJJ = new
  62. {
  63. Type = "JJC",
  64. Price = eec.AirJJ
  65. };
  66. dynamics.Add(AirJJ);
  67. var AirGW = new
  68. {
  69. Type = "GWC",
  70. Price = eec.AirGW
  71. };
  72. dynamics.Add(AirGW);
  73. List<Grp_DayAndCost> dac1 = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.DiId == diid && x.Type == 1 && x.NationalTravelFeeId > 0).ToList(); //酒店费用
  74. List<Grp_DayAndCost> dac2 = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.DiId == diid && x.Type == 2 && x.NationalTravelFeeId > 0).ToList(); //餐费用
  75. List<Grp_DayAndCost> dac3 = (from item in _sqlSugar.Queryable<Grp_DayAndCost>() //公杂费用
  76. where item.DiId == diid && item.Type == 3 && item.NationalTravelFeeId > 0
  77. select item).ToList();
  78. decimal SumHotel = 0;
  79. decimal SumMeals = 0;
  80. decimal SumGongZa = 0;
  81. List<dynamic> hotelList = new List<dynamic>();
  82. List<string> checkString = new List<string>();
  83. if (dac1.Count != 0)//酒店费用
  84. {
  85. for (int i = 0; i < dac1.Count; i++)
  86. {
  87. if (!string.IsNullOrWhiteSpace(dac1[i].Place))
  88. {
  89. if (!checkString.Contains(dac1[i].Place))
  90. {
  91. var hotelData = new
  92. {
  93. CountryOrCity = dac1[i].Place,
  94. Price = dac1[i].SubTotal
  95. };
  96. hotelList.Add(hotelData);
  97. checkString.Add(dac1[i].Place);
  98. }
  99. }
  100. SumHotel += dac1[i].SubTotal;
  101. }
  102. }
  103. hotelList = hotelList.Distinct().ToList();
  104. List<dynamic> MealsList = new List<dynamic>();
  105. if (dac2.Count != 0) //餐费用
  106. {
  107. for (int i = 0; i < dac2.Count; i++)
  108. {
  109. if (checkString.Contains(dac2[i].Place))
  110. {
  111. var mealsData = new
  112. {
  113. CountryOrCity = dac2[i].Place,
  114. Price = dac2[i].SubTotal
  115. };
  116. MealsList.Add(mealsData);
  117. }
  118. SumMeals += dac2[i].SubTotal;
  119. }
  120. }
  121. MealsList = MealsList.Distinct().ToList();
  122. List<dynamic> GongZaList = new List<dynamic>();
  123. if (dac3.Count != 0) //公杂费用
  124. {
  125. for (int i = 0; i < dac3.Count; i++)
  126. {
  127. if (checkString.Contains(dac3[i].Place))
  128. {
  129. var gongZaData = new
  130. {
  131. CountryOrCity = dac3[i].Place,
  132. Price = dac3[i].SubTotal
  133. };
  134. GongZaList.Add(gongZaData);
  135. }
  136. SumGongZa += dac3[i].SubTotal;
  137. }
  138. }
  139. GongZaList = GongZaList.Distinct().ToList();
  140. //签证
  141. var Visa = new
  142. {
  143. Type = "Visa",
  144. Price = eec.Visa,
  145. Desc = eec.VisaRemark
  146. };
  147. dynamics.Add(Visa);
  148. //核酸检测费
  149. var HeSuan = new
  150. {
  151. Type = "HeSuan",
  152. Price = eec.HeSuan //元/人
  153. };
  154. dynamics.Add(HeSuan);
  155. //保险费
  156. var Insurance = new
  157. {
  158. Type = "Insurance",
  159. Price = eec.Safe //元/人
  160. };
  161. dynamics.Add(Insurance);
  162. // 伙食费
  163. var Meals = new
  164. {
  165. Type = "Meals",
  166. Content = MealsList
  167. };
  168. dynamics.Add(Meals);
  169. // 酒店费用
  170. var Hotel = new
  171. {
  172. Type = "Hotel",
  173. Content = hotelList
  174. };
  175. dynamics.Add(Hotel);
  176. // 公杂费用
  177. var GongZa = new
  178. {
  179. Type = "GongZa",
  180. Content = GongZaList
  181. };
  182. dynamics.Add(GongZa);
  183. decimal AirJJCTotal = 0;
  184. decimal AirGWCTotal = 0;
  185. //境内费用(其他费用)选择框
  186. if (eec.ChoiceOne == 1)
  187. {
  188. AirJJCTotal += Math.Round((eec.InsidePay), 2);
  189. AirGWCTotal += Math.Round((eec.InsidePay), 2);
  190. }
  191. //国际旅费合计选择框
  192. if (eec.ChoiceTwo == 1)
  193. {
  194. if (eec.AirJJC_Checked == 1) AirJJCTotal += Math.Round((eec.OutsideJJPay), 2);
  195. if (eec.AirGWC_Checked == 1) AirGWCTotal += Math.Round((eec.OutsaideGWPay), 2);
  196. }
  197. //住宿费合计选择框
  198. if (eec.ChoiceThree == 1)
  199. {
  200. AirJJCTotal += Math.Round(SumHotel, 2);
  201. AirGWCTotal += Math.Round(SumHotel, 2);
  202. }
  203. //伙食费合计选择框
  204. if (eec.ChoiceFour == 1)
  205. {
  206. AirJJCTotal += Math.Round(SumMeals, 2);
  207. AirGWCTotal += Math.Round(SumMeals, 2);
  208. }
  209. //公杂费合计选择框
  210. if (eec.ChoiceFour == 1)
  211. {
  212. AirJJCTotal += Math.Round(SumGongZa, 2);
  213. AirGWCTotal += Math.Round(SumGongZa, 2);
  214. }
  215. // 报批总报价 - 经济舱
  216. var SumAirJJC = new
  217. {
  218. Type = "SumAirJJC",
  219. Price = AirJJCTotal
  220. };
  221. dynamics.Add(SumAirJJC);
  222. //报批总报价 - 公务舱
  223. var SumAirGWC = new
  224. {
  225. Type = "SumAirGWC",
  226. Price = AirGWCTotal
  227. };
  228. dynamics.Add(SumAirGWC);
  229. }
  230. }
  231. catch (Exception)
  232. {
  233. dynamics = new List<dynamic>();
  234. }
  235. return dynamics;
  236. }
  237. }
  238. }