GroupCostParaService.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. namespace DAL
  9. {
  10. public class GroupCostParaService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<GroupCostParameter> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<GroupCostParameter>.excuteSql(new GroupCostParameter(), "GroupCostParameter", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. GroupCostParameter excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<GroupCostParameter> hdList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (hdList == null || hdList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return hdList[0];
  38. }
  39. /// <summary>
  40. /// 根据编号查询对象信息
  41. /// </summary>
  42. /// <param name="id">对象编号</param>
  43. /// <returns>返回空或者单个对象信息</returns>
  44. public GroupCostParameter GetById(int id)
  45. {
  46. //调用获取单个对象的方法
  47. return excuteType("select * from GroupCostParameter where Id = @id", new SqlParameter("@id", id));
  48. }
  49. /// <summary>
  50. /// 查询信息
  51. /// </summary>
  52. /// <returns>返回空或者对象信息</returns>
  53. public GroupCostParameter GetByDiid(int diid)
  54. {
  55. //调用获取单个对象的方法
  56. return excuteType("select * from GroupCostParameter where Diid = @diid", new SqlParameter("@diid", diid));
  57. }
  58. /// <summary>
  59. ///
  60. /// </summary>
  61. /// <param name="diid"></param>
  62. /// <returns></returns>
  63. public GroupCostParameter GetByDiidAndCostTypeA(int diid)
  64. {
  65. return excuteType("select * from GroupCostParameter where Diid = @diid and (CostType = 'A' OR CostType IS NULL) ", new SqlParameter("@diid", diid));
  66. }
  67. public GroupCostParameter GetByDiidAndCostTypeB(int diid)
  68. {
  69. return excuteType("select * from GroupCostParameter where Diid = @diid and (CostType = 'B')", new SqlParameter("@diid", diid));
  70. }
  71. public List<GroupCostParameter> GetAllByDiid(int diid)
  72. {
  73. return excuteSql("select * from GroupCostParameter where Diid = @diid", new SqlParameter("@diid", diid));
  74. }
  75. /// <summary>
  76. /// 查询所有
  77. /// </summary>
  78. /// <returns></returns>
  79. public List<GroupCostParameter> GetAll()
  80. {
  81. return excuteSql("select * from GroupCostParameter where IsDel=0");
  82. }
  83. /// <summary>
  84. /// 增加
  85. /// </summary>
  86. /// <param name="cd"></param>
  87. /// <returns></returns>
  88. public bool AddItaliaTran(GroupCostParameter hd)
  89. {
  90. string sql = "insert into GroupCostParameter values(@Diid,@Currency,@Rate,@Tax,@FFYS,@HotelXS,@JJCCB,@JJCXS,@JJCRS,@GWCCB,@GWCXS,@GWCRS,@HCPCB,@HCPRS,@HCPXS," +
  91. "@CPCB,@CPRS,@CPXS,@BXCB,@BXRS,@BXXS,@HSCB,@HSRS,@HSXS,@VisaCB,@VisaXS,@VisaRS,@GWCB,@GWXS,@GWRS,@DJCB,@DJXS,@LYJCB,@LYJXS,@LYJRS,@SGRCB,@SGRNumber,@SGRXS" +
  92. ",@TBRCB,@TBRNumber,@TBRXS,@JSESCB,@JSESNumber,@JSESXS,@SUITECB,@SUITENumber,@SUITEXS,@IsShare,@Oper,@OpTime,@CostType,@AstartTime,@AendTime,@Anumber,@BstartTime,@BendTime,@Bnumber)";
  93. SqlParameter[] parameter = new SqlParameter[]{
  94. new SqlParameter("@Diid",hd.Diid),
  95. new SqlParameter("@Currency",hd.Currency),
  96. new SqlParameter("@Rate",hd.Rate),
  97. new SqlParameter("@Tax",hd.Tax),
  98. new SqlParameter("@FFYS",hd.FFYS),
  99. new SqlParameter("@HotelXS",hd.HotelXS),
  100. new SqlParameter("@JJCCB",hd.JJCCB),
  101. new SqlParameter("@JJCXS",hd.JJCXS),
  102. new SqlParameter("@JJCRS",hd.JJCRS),
  103. new SqlParameter("@GWCCB",hd.GWCCB),
  104. new SqlParameter("@GWCXS",hd.GWCXS),
  105. new SqlParameter("@GWCRS",hd.GWCRS),
  106. new SqlParameter("@VisaCB",hd.VisaCB),
  107. new SqlParameter("@VisaXS",hd.VisaXS),
  108. new SqlParameter("@VisaRS",hd.VisaRS),
  109. new SqlParameter("@GWCB",hd.GWCB),
  110. new SqlParameter("@GWXS",hd.GWXS),
  111. new SqlParameter("@GWRS",hd.GWRS),
  112. new SqlParameter("@HCPCB",hd.HCPCB),
  113. new SqlParameter("@HCPRS",hd.HCPRS),
  114. new SqlParameter("@HCPXS",hd.HCPXS),
  115. new SqlParameter("@CPCB",hd.CPCB),
  116. new SqlParameter("@CPRS",hd.CPRS),
  117. new SqlParameter("@CPXS",hd.CPXS),
  118. new SqlParameter("@BXCB",hd.BXCB),
  119. new SqlParameter("@BXRS",hd.BXRS),
  120. new SqlParameter("@BXXS",hd.BXXS),
  121. new SqlParameter("@HSCB",hd.HSCB),
  122. new SqlParameter("@HSRS",hd.HSRS),
  123. new SqlParameter("@HSXS",hd.HSXS),
  124. new SqlParameter("@DJCB",hd.DJCB),
  125. new SqlParameter("@DJXS",hd.DJXS),
  126. new SqlParameter("@LYJCB",hd.LYJCB),
  127. new SqlParameter("@LYJXS",hd.LYJXS),
  128. new SqlParameter("@LYJRS",hd.LYJRS),
  129. new SqlParameter("@SGRCB",hd.SGRCB),
  130. new SqlParameter("@SGRNumber",hd.SGRNumber),
  131. new SqlParameter("@SGRXS",hd.SGRXS),
  132. new SqlParameter("@TBRCB",hd.TBRCB),
  133. new SqlParameter("@TBRNumber",hd.TBRNumber),
  134. new SqlParameter("@TBRXS",hd.TBRXS),
  135. new SqlParameter("@JSESCB",hd.JSESCB),
  136. new SqlParameter("@JSESNumber",hd.JSESNumber),
  137. new SqlParameter("@JSESXS",hd.JSESXS),
  138. new SqlParameter("@SUITECB",hd.SUITECB),
  139. new SqlParameter("@SUITENumber",hd.SUITENumber),
  140. new SqlParameter("@SUITEXS",hd.SUITEXS),
  141. new SqlParameter("@IsShare",hd.IsShare),
  142. new SqlParameter("@Oper",hd.Oper),
  143. new SqlParameter("@OpTime",hd.OpTime),
  144. new SqlParameter("@CostType",hd.CostType) ,
  145. new SqlParameter("@AstartTime",hd.AstartTime) ,
  146. new SqlParameter("@AendTime",hd.AendTime) ,
  147. new SqlParameter("@Anumber",hd.Anumber) ,
  148. new SqlParameter("@BstartTime",hd.BstartTime) ,
  149. new SqlParameter("@BendTime",hd.BendTime) ,
  150. new SqlParameter("@Bnumber",hd.Bnumber)
  151. };
  152. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  153. return true;
  154. return false;
  155. }
  156. /// <summary>
  157. /// 编辑
  158. /// </summary>
  159. /// <param name="sdt"></param>
  160. /// <returns></returns>
  161. public bool EditItaliaTran(GroupCostParameter hd)
  162. {
  163. string sql = "update GroupCostParameter set Diid=@Diid,Currency=@Currency,Rate=@Rate,Tax=@Tax,FFYS=@FFYS,HotelXS=@HotelXS,JJCCB=@JJCCB,JJCXS=@JJCXS," +
  164. "JJCRS=@JJCRS,GWCCB=@GWCCB,GWCXS=@GWCXS,GWCRS=@GWCRS,HCPCB=@HCPCB,VisaCB=@VisaCB,HCPRS=@HCPRS,HCPXS=@HCPXS,CPCB=@CPCB,CPRS=@CPRS,CPXS=@CPXS," +
  165. "BXCB=@BXCB,BXRS=@BXRS,BXXS=@BXXS,HSCB=@HSCB,HSRS=@HSRS,HSXS=@HSXS,VisaXS=@VisaXS,VisaRS=@VisaRS,GWCB=@GWCB,GWXS=@GWXS,GWRS=@GWRS,DJCB=@DJCB,DJXS=@DJXS,SGRCB=@SGRCB,SGRNumber=@SGRNumber,SGRXS=@SGRXS," +
  166. "TBRCB=@TBRCB,TBRNumber=@TBRNumber,TBRXS=@TBRXS,LYJCB=@LYJCB,LYJXS=@LYJXS,LYJRS=@LYJRS,JSESCB=@JSESCB,JSESNumber=@JSESNumber,JSESXS=@JSESXS," +
  167. "SUITECB=@SUITECB,SUITENumber=@SUITENumber,SUITEXS=@SUITEXS,Oper=@Oper,OpTime=@OpTime,CostType=@CostType,AstartTime=@AstartTime,AendTime=@AendTime,Anumber=@Anumber,BstartTime=@BstartTime,BendTime=@BendTime,Bnumber=@Bnumber where Id = @Id";
  168. SqlParameter[] parameter = new SqlParameter[]{
  169. new SqlParameter("@Diid",hd.Diid),
  170. new SqlParameter("@Currency",hd.Currency),
  171. new SqlParameter("@Rate",hd.Rate),
  172. new SqlParameter("@Tax",hd.Tax),
  173. new SqlParameter("@FFYS",hd.FFYS),
  174. new SqlParameter("@HotelXS",hd.HotelXS),
  175. new SqlParameter("@JJCCB",hd.JJCCB),
  176. new SqlParameter("@JJCXS",hd.JJCXS),
  177. new SqlParameter("@JJCRS",hd.JJCRS),
  178. new SqlParameter("@GWCCB",hd.GWCCB),
  179. new SqlParameter("@GWCXS",hd.GWCXS),
  180. new SqlParameter("@GWCRS",hd.GWCRS),
  181. new SqlParameter("@HCPCB",hd.HCPCB),
  182. new SqlParameter("@HCPRS",hd.HCPRS),
  183. new SqlParameter("@HCPXS",hd.HCPXS),
  184. new SqlParameter("@CPCB",hd.CPCB),
  185. new SqlParameter("@CPRS",hd.CPRS),
  186. new SqlParameter("@CPXS",hd.CPXS),
  187. new SqlParameter("@BXCB",hd.BXCB),
  188. new SqlParameter("@BXRS",hd.BXRS),
  189. new SqlParameter("@BXXS",hd.BXXS),
  190. new SqlParameter("@HSCB",hd.HSCB),
  191. new SqlParameter("@HSRS",hd.HSRS),
  192. new SqlParameter("@HSXS",hd.HSXS),
  193. new SqlParameter("@VisaCB",hd.VisaCB),
  194. new SqlParameter("@VisaXS",hd.VisaXS),
  195. new SqlParameter("@VisaRS",hd.VisaRS),
  196. new SqlParameter("@GWCB",hd.GWCB),
  197. new SqlParameter("@GWXS",hd.GWXS),
  198. new SqlParameter("@GWRS",hd.GWRS),
  199. new SqlParameter("@DJCB",hd.DJCB),
  200. new SqlParameter("@DJXS",hd.DJXS),
  201. new SqlParameter("@LYJCB",hd.LYJCB),
  202. new SqlParameter("@LYJXS",hd.LYJXS),
  203. new SqlParameter("@LYJRS",hd.LYJRS),
  204. new SqlParameter("@SGRCB",hd.SGRCB),
  205. new SqlParameter("@SGRNumber",hd.SGRNumber),
  206. new SqlParameter("@SGRXS",hd.SGRXS),
  207. new SqlParameter("@TBRCB",hd.TBRCB),
  208. new SqlParameter("@TBRNumber",hd.TBRNumber),
  209. new SqlParameter("@TBRXS",hd.TBRXS),
  210. new SqlParameter("@JSESCB",hd.JSESCB),
  211. new SqlParameter("@JSESNumber",hd.JSESNumber),
  212. new SqlParameter("@JSESXS",hd.JSESXS),
  213. new SqlParameter("@SUITECB",hd.SUITECB),
  214. new SqlParameter("@SUITENumber",hd.SUITENumber),
  215. new SqlParameter("@SUITEXS",hd.SUITEXS),
  216. new SqlParameter("@Oper",hd.Oper),
  217. new SqlParameter("@OpTime",hd.OpTime),
  218. new SqlParameter("@Id",hd.Id),
  219. new SqlParameter("@CostType",hd.CostType) ,
  220. new SqlParameter("@AstartTime",hd.AstartTime) ,
  221. new SqlParameter("@AendTime",hd.AendTime) ,
  222. new SqlParameter("@Anumber",hd.Anumber) ,
  223. new SqlParameter("@BstartTime",hd.BstartTime) ,
  224. new SqlParameter("@BendTime",hd.BendTime) ,
  225. new SqlParameter("@Bnumber",hd.Bnumber)
  226. };
  227. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  228. return true;
  229. return false;
  230. }
  231. /// <summary>
  232. /// 成本预算各项指标
  233. /// </summary>
  234. /// <param name="diid">团组编号</param>
  235. /// <param name="type">(0:签证 1:机票 2:酒店 3:地接(含火车票 船票) 4:公务 5:零用金 6:团组总金额)</param>
  236. /// <param name="price">金额</param>
  237. /// <returns>
  238. /// "-1" : 团组预算系数表没有查到该数据
  239. /// "0/其他小数" : 传入金额小于预算金额正常 返回 "0" / 传入金额超过预算金额 返回 "超出金额占预算金额的百分比(小数显示)"
  240. /// </returns>
  241. public string GetBudgetIndicators(int diid, string type, float price)
  242. {
  243. string ReturnCode = "";
  244. GroupCostParameter gcp = GetByDiid(diid);
  245. if (gcp != null)
  246. {
  247. //团组汇率
  248. float Rate = gcp.Rate;
  249. //签证
  250. float VisaPrice = gcp.VisaCB * gcp.VisaRS * gcp.VisaXS * Rate;
  251. //机票
  252. float JJCPrice = gcp.JJCCB * gcp.JJCRS * gcp.JJCXS * Rate; //经济舱
  253. float GWCPrice = gcp.GWCCB * gcp.GWCRS * gcp.GWCXS * Rate; //公务舱
  254. float JPPrice = JJCPrice + GWCPrice;
  255. //酒店
  256. float SGRPrice = gcp.SGRCB * gcp.SGRNumber * gcp.SGRXS * Rate; // 单人间
  257. float TBRPrice = gcp.TBRCB * gcp.TBRNumber * gcp.TBRXS * Rate; //双人间
  258. float JSESPrice = gcp.JSESCB * gcp.JSESNumber * gcp.JSESXS * Rate; //小套房
  259. float SuitePrice = gcp.SUITECB * gcp.SUITENumber * gcp.SUITEXS * Rate; //套房
  260. float HotelPrice = SGRPrice + TBRPrice + JSESPrice + SuitePrice;
  261. //地接
  262. float DJPrice = gcp.DJCB * gcp.VisaRS * gcp.DJXS * Rate;
  263. float HCPPrice = gcp.HCPCB * gcp.HCPRS * gcp.HCPXS * Rate; //火车票
  264. float CPPrice = gcp.CPCB * gcp.CPRS * gcp.CPXS * Rate; // 船票
  265. DJPrice = DJPrice + HCPPrice + CPPrice;
  266. //公务
  267. float GWPrice = gcp.GWCB * gcp.GWRS * gcp.GWXS * Rate;
  268. //零用金
  269. float LYJPrice = gcp.LYJCB * gcp.LYJRS * gcp.LYJXS * Rate;
  270. //团组预算
  271. float TzPrice = VisaPrice + JPPrice + HotelPrice + DJPrice + GWPrice + LYJPrice;
  272. try
  273. {
  274. switch (type)
  275. {
  276. case "0":
  277. if (price <= VisaPrice)
  278. ReturnCode = "0";
  279. else
  280. ReturnCode = ((price - VisaPrice) / VisaPrice).ToString("0.000").Substring(0, 5);
  281. break;
  282. case "1":
  283. if (price <= JPPrice)
  284. ReturnCode = "0";
  285. else
  286. ReturnCode = ((price - JPPrice) / JPPrice).ToString("0.000").Substring(0, 5);
  287. break;
  288. case "2":
  289. if (price <= HotelPrice)
  290. ReturnCode = "0";
  291. else
  292. ReturnCode = ((price - HotelPrice) / HotelPrice).ToString("0.000").Substring(0, 5);
  293. break;
  294. case "3":
  295. if (price <= DJPrice)
  296. ReturnCode = "0";
  297. else
  298. ReturnCode = ((price - DJPrice) / DJPrice).ToString("0.000").Substring(0, 5);
  299. break;
  300. case "4":
  301. if (price <= GWPrice)
  302. ReturnCode = "0";
  303. else
  304. ReturnCode = ((price - GWPrice) / GWPrice).ToString("0.000").Substring(0, 5);
  305. break;
  306. case "5":
  307. if (price <= LYJPrice)
  308. ReturnCode = "0";
  309. else
  310. ReturnCode = ((price - LYJPrice) / LYJPrice).ToString("0.000").Substring(0, 5);
  311. break;
  312. case "6":
  313. if (price <= TzPrice)
  314. ReturnCode = "0";
  315. else
  316. ReturnCode = ((price - TzPrice) / TzPrice).ToString("0.000").Substring(0, 5);
  317. break;
  318. }
  319. }
  320. catch (Exception)
  321. {
  322. ReturnCode = "-1";
  323. }
  324. }
  325. else
  326. ReturnCode = "-1";
  327. return ReturnCode;
  328. }
  329. /// <summary>
  330. /// 雷怡 2021-08-06 15:08
  331. /// 修改 团组系数 通知表示 0:不允许通知 1:允许通知
  332. /// </summary>
  333. /// <param name="Diid">团组diid</param>
  334. /// <param name="IsShare">0/1</param>
  335. /// <returns></returns>
  336. public bool EditIsShare(int id, int IsShare)
  337. {
  338. string sql = "update GroupCostParameter set IsShare=@IsShare where Id = @id";
  339. SqlParameter[] parameter = new SqlParameter[]{
  340. new SqlParameter("@IsShare",IsShare),
  341. new SqlParameter("@id",id)
  342. };
  343. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  344. return true;
  345. return false;
  346. }
  347. }
  348. }