CreditCardPaymentService.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data.SqlClient;
  7. using System.Data;
  8. using System.Runtime.InteropServices;
  9. namespace DAL
  10. {
  11. /// <summary>
  12. /// 付款信息数据访问类
  13. /// </summary>
  14. public class CreditCardPaymentService
  15. {
  16. /// <summary>
  17. /// 查询所有
  18. /// </summary>
  19. /// <param name="sql">sql语句</param>
  20. /// <param name="param">可变参数数组</param>
  21. /// <returns>返回集合</returns>
  22. List<CreditCardPayment> excuteSql(string sql, params SqlParameter[] param)
  23. {
  24. return ServiceBase<CreditCardPayment>.excuteSql(new CreditCardPayment(), "CreditCardPayment", sql, CommandType.Text, param);
  25. }
  26. /// <summary>
  27. /// 获取单个对象
  28. /// </summary>
  29. /// <param name="sql">sql语句</param>
  30. /// <param name="param">可变参数数组</param>
  31. /// <returns>返回空或者单个对象</returns>
  32. CreditCardPayment excuteType(string sql, params SqlParameter[] param)
  33. {
  34. //查询结果放入对象集合
  35. List<CreditCardPayment> ccpList = excuteSql(sql, param);
  36. //判断集合是否为空
  37. if (ccpList == null || ccpList.Count == 0)
  38. //返回null
  39. return null;
  40. //返回单个对象
  41. return ccpList[0];
  42. }
  43. /// <summary>
  44. /// 根据编号查询对象信息
  45. /// </summary>
  46. /// <param name="id">对象编号</param>
  47. /// <returns>返回空或者单个对象信息</returns>
  48. public CreditCardPayment GetCreditCardPaymentByID(int id, int ispay)
  49. {
  50. string sql = "select * from CreditCardPayment where Id = @id and isdel=0";
  51. //ispay=2为不查询ispay
  52. if (ispay != 2)
  53. {
  54. sql = sql + " and isPay=" + ispay;
  55. }
  56. //调用获取单个对象的方法
  57. return excuteType(sql, new SqlParameter("@id", id));
  58. }
  59. /// <summary>
  60. /// 根据ID集合查询数据
  61. /// </summary>
  62. /// <param name="idlist"></param>
  63. /// <returns></returns>
  64. public List<CreditCardPayment> GetByIdList(string idlist)
  65. {
  66. //调用获取单个对象的方法
  67. return excuteSql("select * from CreditCardPayment where Isdel=0 and Id in (" + idlist + ")");
  68. }
  69. /// <summary>
  70. /// 根据查询对象信息
  71. /// </summary>
  72. /// <param name="id">对象编号</param>
  73. /// <returns>返回空或者单个对象信息</returns>
  74. public CreditCardPayment GetCreditCardPaymentByCIDAndDIIDAndCTable(int cid, int diid, int ctable)
  75. {
  76. //调用获取单个对象的方法
  77. return excuteType("select * from CreditCardPayment where CId = @CId and DIId = @DIId and CTable = @CTable", new SqlParameter("@CId", cid), new SqlParameter("@DIId", diid), new SqlParameter("@CTable", ctable));
  78. }
  79. /// <summary>
  80. /// 查询ctable中的cid
  81. /// </summary>
  82. /// <param name="cids">cid集合</param>
  83. /// <param name="ctable">ctable</param>
  84. /// <returns></returns>
  85. public List<CreditCardPayment> GetCreditCardPaymentByCIDSAndCTable(List<int> cids , int ctable)
  86. {
  87. string sql = $@"select * from CreditCardPayment
  88. where isdel = 0 and cid in ({string.Join(",",cids).TrimEnd(',')}) and ctable = {ctable} ";
  89. return excuteSql(sql);
  90. }
  91. /// <summary>
  92. /// 查询对象集合
  93. /// </summary>
  94. /// <param name="CTable">标识</param>
  95. /// <param name="DIID">团组主键编号</param>
  96. /// <returns></returns>
  97. public List<CreditCardPayment> GetByInCTableAndDIID(string CTable, int DIID)
  98. {
  99. return excuteSql("select * from CreditCardPayment where isdel=0 and CTable in (" + CTable + ") and DIID = " + DIID + "");
  100. }
  101. /// <summary>
  102. /// 新增
  103. /// </summary>
  104. /// <param name="sdt">对象</param>
  105. public bool AddCreditCardPayment(CreditCardPayment ccp)
  106. {
  107. string sql = "insert into CreditCardPayment values(@PayDId,@ConsumptionPatterns,@ConsumptionDate,@CTDId,@BankNo,@CardholderName,@PayMoney,@PaymentCurrency,@DayRate,@CompanyBankNo,@OtherBankName,@OtherSideNo,@OtherSideName,@Remark,@Operator,@OperatorDate,@MFOperator,@MFOperatorDate,@IsAuditDM,@AuditDMOperate,@AuditDMDate,@IsAuditMF,@AuditMFOperate,@AuditMFDate,@IsAuditGM,@AuditGMOperate,@AuditGMDate,@IsPay,@DIId,@CId,@CTable,@IsDel,@PayPercentage,@PayThenMoney,@PayPercentageOld,@PayThenMoneyOld,@UpdateDate,@Payee,@RMBPrice,@OrbitalPrivateTransfer,@ExceedBudget,@IsMatchCreditCard)";
  108. SqlParameter[] parameter = new SqlParameter[]{
  109. new SqlParameter("@PayDId",ccp.PayDId),
  110. new SqlParameter("@ConsumptionPatterns",ccp.ConsumptionPatterns),
  111. new SqlParameter("@ConsumptionDate",ccp.ConsumptionDate),
  112. new SqlParameter("@CTDId",ccp.CTDId),
  113. new SqlParameter("@BankNo",ccp.BankNo),
  114. new SqlParameter("@CardholderName",ccp.CardholderName),
  115. new SqlParameter("@PayMoney",ccp.PayMoney),
  116. new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
  117. new SqlParameter("@DayRate",ccp.DayRate),
  118. new SqlParameter("@CompanyBankNo",ccp.CompanyBankNo),
  119. new SqlParameter("@OtherBankName",ccp.OtherBankName),
  120. new SqlParameter("@OtherSideNo",ccp.OtherSideNo),
  121. new SqlParameter("@OtherSideName",ccp.OtherSideName),
  122. new SqlParameter("@Remark",ccp.Remark),
  123. new SqlParameter("@Operator",ccp.Operators),
  124. new SqlParameter("@OperatorDate",ccp.OperatorsDate),
  125. new SqlParameter("@MFOperator",ccp.MFOperators),
  126. new SqlParameter("@MFOperatorDate",ccp.MFOperatorsDate),
  127. new SqlParameter("@IsAuditDM",ccp.IsAuditDM),
  128. new SqlParameter("@AuditDMOperate",ccp.AuditDMOperate),
  129. new SqlParameter("@AuditDMDate",ccp.AuditDMDate),
  130. new SqlParameter("@IsAuditMF",ccp.IsAuditMF),
  131. new SqlParameter("@AuditMFOperate",ccp.AuditMFOperate),
  132. new SqlParameter("@AuditMFDate",ccp.AuditMFDate),
  133. new SqlParameter("@IsAuditGM",ccp.IsAuditGM),
  134. new SqlParameter("@AuditGMOperate",ccp.AuditGMOperate),
  135. new SqlParameter("@AuditGMDate",ccp.AuditGMDate),
  136. new SqlParameter("@IsPay",ccp.IsPay),
  137. new SqlParameter("@DIId",ccp.DIId),
  138. new SqlParameter("@CId",ccp.CId),
  139. new SqlParameter("@CTable",ccp.CTable),
  140. new SqlParameter("@IsDel",ccp.IsDel),
  141. new SqlParameter("@PayPercentage",ccp.PayPercentage),
  142. new SqlParameter("@PayThenMoney",ccp.PayThenMoney),
  143. new SqlParameter("@PayPercentageOld",ccp.PayPercentage),
  144. new SqlParameter("@PayThenMoneyOld",ccp.PayThenMoney),
  145. new SqlParameter("@UpdateDate",ccp.UpdateDate),
  146. new SqlParameter("@Payee",ccp.Payee),
  147. new SqlParameter("@RMBPrice",ccp.RMBPrice),
  148. new SqlParameter("@OrbitalPrivateTransfer",ccp.OrbitalPrivateTransfer),
  149. new SqlParameter("@ExceedBudget",ccp.ExceedBudget),
  150. new SqlParameter("@IsMatchCreditCard","0")
  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. public bool EditCreditCardPayment(CreditCardPayment ccp)
  161. {
  162. string sql = "update CreditCardPayment set PayThenMoneyOld=PayThenMoney,PayPercentageOld=PayPercentage,UpdateDate=OperatorDate,PayDId = @PayDId,ConsumptionPatterns = @ConsumptionPatterns,ConsumptionDate = @ConsumptionDate,CTDId = @CTDId,BankNo = @BankNo,CardholderName=@CardholderName,PayMoney=@PayMoney,PaymentCurrency = @PaymentCurrency,DayRate = @DayRate,CompanyBankNo = @CompanyBankNo,OtherBankName = @OtherBankName,OtherSideNo = @OtherSideNo,OtherSideName = @OtherSideName,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,PayPercentage = @PayPercentage,PayThenMoney = @PayThenMoney,IsAuditGM = 0,AuditGMOperate=0,AuditGMDate='',Payee=@Payee,RMBPrice=@RMBPrice,OrbitalPrivateTransfer=@OrbitalPrivateTransfer,ExceedBudget=@ExceedBudget where DIId = @DIId and CId = @CId and ID = @ID";
  163. SqlParameter[] parameter = new SqlParameter[]{
  164. new SqlParameter("@PayDId",ccp.PayDId),
  165. new SqlParameter("@ConsumptionPatterns",ccp.ConsumptionPatterns),
  166. new SqlParameter("@ConsumptionDate",ccp.ConsumptionDate),
  167. new SqlParameter("@CTDId",ccp.CTDId),
  168. new SqlParameter("@BankNo",ccp.BankNo),
  169. new SqlParameter("@CardholderName",ccp.CardholderName),
  170. new SqlParameter("@PayMoney",ccp.PayMoney),
  171. new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
  172. new SqlParameter("@DayRate",ccp.DayRate),
  173. new SqlParameter("@CompanyBankNo",ccp.CompanyBankNo),
  174. new SqlParameter("@OtherBankName",ccp.OtherBankName),
  175. new SqlParameter("@OtherSideNo",ccp.OtherSideNo),
  176. new SqlParameter("@OtherSideName",ccp.OtherSideName),
  177. new SqlParameter("@Remark",ccp.Remark),
  178. new SqlParameter("@Operator",ccp.Operators),
  179. new SqlParameter("@OperatorDate",ccp.OperatorsDate),
  180. new SqlParameter("@PayPercentage",ccp.PayPercentage),
  181. new SqlParameter("@PayThenMoney",ccp.PayThenMoney),
  182. new SqlParameter("@DIId",ccp.DIId),
  183. new SqlParameter("@CId",ccp.CId),
  184. new SqlParameter("@Payee",ccp.Payee),
  185. new SqlParameter("@RMBPrice",ccp.RMBPrice),
  186. new SqlParameter("@OrbitalPrivateTransfer",ccp.OrbitalPrivateTransfer),
  187. new SqlParameter("@ExceedBudget",ccp.ExceedBudget),
  188. new SqlParameter("@Id",ccp.Id)
  189. };
  190. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  191. return true;
  192. return false;
  193. }
  194. public bool EditCreditCardPaymentByHotelID(CreditCardPayment ccp)
  195. {
  196. string sql = "update CreditCardPayment set PayMoney=@PayMoney,PaymentCurrency=@PaymentCurrency,DayRate=@DayRate,Operator=@Operator,OperatorDate=@OperatorDate,PayThenMoney=@PayThenMoney,PayThenMoneyOld=@PayThenMoneyOld,RMBPrice=@RMBPrice, IsAuditGM = @IsAuditGM,AuditGMDate=@AuditGMDate where Id = @Id ";
  197. SqlParameter[] parameter = new SqlParameter[]{
  198. new SqlParameter("@PayMoney",ccp.PayMoney),
  199. new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
  200. new SqlParameter("@DayRate",ccp.DayRate),
  201. new SqlParameter("@Operator",ccp.Operators),
  202. new SqlParameter("@OperatorDate",ccp.OperatorsDate),
  203. new SqlParameter("@PayThenMoney",ccp.PayThenMoney),
  204. new SqlParameter("@PayThenMoneyOld",ccp.PayThenMoneyOld),
  205. new SqlParameter("@RMBPrice",ccp.RMBPrice),
  206. new SqlParameter("@IsAuditGM",ccp.IsAuditGM),
  207. new SqlParameter("@AuditGMDate",ccp.AuditGMDate),
  208. new SqlParameter("@Id",ccp.Id)
  209. };
  210. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  211. return true;
  212. return false;
  213. }
  214. /// <summary>
  215. /// 编辑
  216. /// </summary>
  217. /// <param name="sdt">对象</param>
  218. public bool EditCreditCardPaymentByID(CreditCardPayment ccp)
  219. {
  220. string sql = "update CreditCardPayment set PayDId = @PayDId,ConsumptionPatterns = @ConsumptionPatterns,ConsumptionDate = @ConsumptionDate,CTDId = @CTDId,BankNo = @BankNo,CardholderName=@CardholderName,PayMoney=@PayMoney,PaymentCurrency = @PaymentCurrency,DayRate = @DayRate,CompanyBankNo = @CompanyBankNo,OtherBankName = @OtherBankName,OtherSideNo = @OtherSideNo,OtherSideName = @OtherSideName,Remark = @Remark,Operator = @Operator,OperatorDate = @OperatorDate,IsPay = 1 where Id = @Id";
  221. SqlParameter[] parameter = new SqlParameter[]{
  222. new SqlParameter("@PayDId",ccp.PayDId),
  223. new SqlParameter("@ConsumptionPatterns",ccp.ConsumptionPatterns),
  224. new SqlParameter("@ConsumptionDate",ccp.ConsumptionDate),
  225. new SqlParameter("@CTDId",ccp.CTDId),
  226. new SqlParameter("@BankNo",ccp.BankNo),
  227. new SqlParameter("@CardholderName",ccp.CardholderName),
  228. new SqlParameter("@PayMoney",ccp.PayMoney),
  229. new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
  230. new SqlParameter("@DayRate",ccp.DayRate),
  231. new SqlParameter("@CompanyBankNo",ccp.CompanyBankNo),
  232. new SqlParameter("@OtherBankName",ccp.OtherBankName),
  233. new SqlParameter("@OtherSideNo",ccp.OtherSideNo),
  234. new SqlParameter("@OtherSideName",ccp.OtherSideName),
  235. new SqlParameter("@Remark",ccp.Remark),
  236. new SqlParameter("@Operator",ccp.Operators),
  237. new SqlParameter("@OperatorDate",ccp.OperatorsDate),
  238. new SqlParameter("@Id",ccp.Id)
  239. };
  240. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  241. return true;
  242. return false;
  243. }
  244. /// <summary>
  245. /// 编辑 - 价格、货币、汇率
  246. /// </summary>
  247. /// <param name="sdt">对象</param>
  248. public bool EditCreditCardPaymentByMoneyAndCurrencyAndDayRate(CreditCardPayment ccp)
  249. {
  250. string sql = "update CreditCardPayment set PayMoney=@PayMoney,RMBPrice=@RMBPrice,PaymentCurrency = @PaymentCurrency,DayRate = @DayRate,Operator = @Operator,OperatorDate = @OperatorDate ,IsAuditGM = 0,AuditGMOperate=0,AuditGMDate='' where DIId = @DIId and CId = @CId";
  251. SqlParameter[] parameter = new SqlParameter[]{
  252. new SqlParameter("@PayMoney",ccp.PayMoney),
  253. new SqlParameter("@RMBPrice",ccp.RMBPrice),
  254. new SqlParameter("@PaymentCurrency",ccp.PaymentCurrency),
  255. new SqlParameter("@DayRate",ccp.DayRate),
  256. new SqlParameter("@Operator",ccp.Operators),
  257. new SqlParameter("@OperatorDate",ccp.OperatorsDate),
  258. new SqlParameter("@DIId",ccp.DIId),
  259. new SqlParameter("@CId",ccp.CId)
  260. };
  261. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, parameter) > 0)
  262. return true;
  263. return false;
  264. }
  265. /// <summary>
  266. /// 更改人民币金额和汇率
  267. /// </summary>
  268. /// <param name="list"></param>
  269. /// <returns></returns>
  270. public bool EditPayMoneyAndDayRate(int id, string payMoney, string dayRate, string RMBPrice)
  271. {
  272. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set PayMoney = @PayMoney,DayRate = @DayRate,RMBPrice=@RMBPrice where Id = @Id", CommandType.Text, new SqlParameter("@PayMoney", payMoney), new SqlParameter("@DayRate", dayRate), new SqlParameter("@RMBPrice", RMBPrice), new SqlParameter("@Id", id)) > 0)
  273. return true;
  274. return false;
  275. }
  276. /// <summary>
  277. /// 删除
  278. /// </summary>
  279. /// <param name="id"></param>
  280. /// <returns></returns>
  281. public bool DelCreditCardPayment(int cid, int diid)
  282. {
  283. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsDel = 1 where CId = @CId and DIId = @DIId", CommandType.Text, new SqlParameter("@CId", cid), new SqlParameter("DIId", diid)) > 0)
  284. return true;
  285. return false;
  286. }
  287. /// <summary>
  288. /// 更改已付款状态
  289. /// </summary>
  290. /// <param name="id"></param>
  291. /// <returns></returns>
  292. public bool UpdateCreditCardPaymentIsPay(int cid, int diid)
  293. {
  294. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsPay = 1 where CId = @CId and DIId = @DIId", CommandType.Text, new SqlParameter("@CId", cid), new SqlParameter("DIId", diid)) > 0)
  295. return true;
  296. return false;
  297. }
  298. /// <summary>
  299. /// 更改审核通过状态 2021-01-11
  300. /// </summary>
  301. /// <param name="id"></param>
  302. /// <returns></returns>
  303. public bool UpdateAudit(int id, int IsAuditGM, int auditGMOperate, string auditGMDate, float exceedbudget)
  304. {
  305. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = @IsAuditGM,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate ,ExceedBudget=@ExceedBudget where Id = @Id",
  306. CommandType.Text,
  307. new SqlParameter("@IsAuditGM", IsAuditGM),
  308. new SqlParameter("@AuditGMOperate", auditGMOperate),
  309. new SqlParameter("@AuditGMDate", auditGMDate),
  310. new SqlParameter("@ExceedBudget", exceedbudget),
  311. new SqlParameter("@Id", id)) > 0)
  312. return true;
  313. return false;
  314. }
  315. /// <summary>
  316. /// 更改审核通过状态
  317. /// </summary>
  318. /// <param name="id"></param>
  319. /// <returns></returns>
  320. public bool UpdateCreditCardPaymentIsAudit(int id, int auditGMOperate, string auditGMDate)
  321. {
  322. //CreditCardPayment ccp = GetCreditCardPaymentByID(id, 0);
  323. //if (ccp != null)
  324. // if(ccp.CTable==76 || ccp.CTable==85)
  325. // UpdateCreditCardPaymentIsPay(id);
  326. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = 1,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditGMOperate", auditGMOperate), new SqlParameter("@AuditGMDate", auditGMDate), new SqlParameter("@Id", id)) > 0)
  327. return true;
  328. return false;
  329. }
  330. public bool UpdateCreditCardPaymentIsAuditMF(int id, int AuditMFOperate, string AuditMFDate)
  331. {
  332. //CreditCardPayment ccp = GetCreditCardPaymentByID(id, 0);
  333. //if (ccp != null)
  334. // if(ccp.CTable==76 || ccp.CTable==85)
  335. // UpdateCreditCardPaymentIsPay(id);
  336. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditMF = 1,AuditMFOperate = @AuditMFOperate , AuditMFDate = @AuditMFDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditMFOperate", AuditMFOperate), new SqlParameter("@AuditMFDate", AuditMFDate)
  337. , new SqlParameter("@Id", id)) > 0)
  338. return true;
  339. return false;
  340. }
  341. /// <summary>
  342. /// 审核不通过
  343. /// </summary>
  344. /// <param name="id"></param>
  345. /// <returns></returns>
  346. public bool UpdateCreditCardPaymentIsReAudit(int id, int auditGMOperate, string auditGMDate)
  347. {
  348. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = 3,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditGMOperate", auditGMOperate), new SqlParameter("@AuditGMDate", auditGMDate), new SqlParameter("@Id", id)) > 0)
  349. return true;
  350. return false;
  351. }
  352. public List<CreditCardPayment> GetCreditCardPaymentByCTableAndIsPay(int CTable, int IsPay)
  353. {
  354. //调用获取单个对象的方法
  355. return excuteSql("select * from creditCardPayment where IsDel = 0 and CTable = @CTable and IsPay = @IsPay", new SqlParameter("@CTable", CTable), new SqlParameter("@IsPay", IsPay));
  356. }
  357. /// <summary>
  358. /// 根据类别和支付状态查询信用卡表数据
  359. /// 分页
  360. /// 20210910 贾文滔
  361. /// </summary>
  362. /// <param name="CTable"></param>
  363. /// <param name="IsPay"></param>
  364. /// <returns></returns>
  365. public List<CreditCardPayment> GetDataByCTableAndIsPay(int pageIndex, out int sumPage, out int totalRecord, int CTable, int IsPay)
  366. {
  367. string sqlwhere = "Isdel=0 and CTable=" + CTable+ " and IsPay=" + IsPay;
  368. return PageBase<CreditCardPayment>.excutePageSql(new CreditCardPayment(), "CreditCardPayment", "CreditCardPayment", "*", "id desc", sqlwhere, 20, pageIndex, out sumPage, out totalRecord);
  369. }
  370. /// <summary>
  371. /// 经理审核
  372. /// </summary>
  373. /// <returns></returns>
  374. public List<CreditCardPayment> GetOPListByDIID(string diid, int isAuditGM)
  375. {
  376. return excuteSql("select * from creditCardPayment where diid = " + diid + " and IsAuditGM = " + isAuditGM + " and isDel = 0 and Operator > 0 and Operator is not null");
  377. }
  378. /// <summary>
  379. /// 更改审核通过状态
  380. /// </summary>
  381. /// <param name="id"></param>
  382. /// <returns></returns>
  383. public bool UpdateCreditCardPaymentIsAuditByNo(int id, int auditGMOperate, string auditGMDate)
  384. {
  385. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsAuditGM = 2,AuditGMOperate = @AuditGMOperate , AuditGMDate = @AuditGMDate where Id = @Id", CommandType.Text, new SqlParameter("@AuditGMOperate", auditGMOperate), new SqlParameter("@AuditGMDate", auditGMDate), new SqlParameter("@Id", id)) > 0)
  386. return true;
  387. return false;
  388. }
  389. /// <summary>
  390. /// 查询付款集合
  391. /// </summary>
  392. /// <returns></returns>
  393. public List<CreditCardPayment> GetOPIsPayListByDIID(string diid, int isPay)
  394. {
  395. return excuteSql("select * from creditCardPayment where diid = " + diid + " and IsPay = " + isPay + " and IsAuditGM = 1");
  396. }
  397. /// <summary>
  398. /// 付款申请书 - 旧版2016-05-10
  399. /// </summary>
  400. /// <returns></returns>
  401. //public List<CreditCardPayment> GetOPIsPaymentApplicationReport(string startTime,string endTime)
  402. //{
  403. // return excuteSql("select * from creditCardPayment where isDel = 0 and IsPay = 0 and IsAuditGM = 1 and (auditGMDate between '" + startTime + "' and '" + endTime + "')");
  404. //}
  405. /// <summary>
  406. /// 付款申请书
  407. /// </summary>
  408. /// <returns></returns>
  409. public List<CreditCardPayment> GetOPIsPaymentApplicationReport(string startTime, string endTime)
  410. {
  411. return excuteSql("select * from creditCardPayment where isDel = 0 and IsPay = 0 and IsAuditGM = 1 and (auditGMDate between '" + startTime + "' and '" + endTime + "')");
  412. }
  413. /// <summary>
  414. /// 更改已付款状态
  415. /// </summary>
  416. /// <param name="id"></param>
  417. /// <returns></returns>
  418. public bool UpdateCreditCardPaymentIsPay(int id)
  419. {
  420. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsPay = 1 where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  421. return true;
  422. return false;
  423. }
  424. /// <summary>
  425. /// 更改已付款状态
  426. /// </summary>
  427. /// <param name="id"></param>
  428. /// <returns></returns>
  429. public bool UpdateCreditCardPaymentIsPay(int id, string DayRate, string RMBPrice)
  430. {
  431. string sql = "update CreditCardPayment set IsPay = 1";
  432. if (DayRate != "")
  433. {
  434. sql = sql + " ,DayRate=" + DayRate;
  435. }
  436. if (RMBPrice != "")
  437. sql = sql + " ,RMBPrice=" + RMBPrice;
  438. sql = sql + " where id=@Id";
  439. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text, new SqlParameter("@Id", id)) > 0)
  440. return true;
  441. return false;
  442. }
  443. /// <summary>
  444. /// 修改信用卡匹配状态
  445. /// </summary>
  446. /// <param name="id"></param>
  447. /// <param name="IsMatchCreditCard"></param>
  448. /// <returns></returns>
  449. public bool UpdateCreditCardPaymentIsMatchCreditCard(string[] ids, int IsMatchCreditCard = 1)
  450. {
  451. if (ids != null && ids.Length > 0)
  452. {
  453. string sql = $"update CreditCardPayment set IsMatchCreditCard = {IsMatchCreditCard} where isdel = 0 and id in ({string.Join(",", ids).TrimEnd(',')})";
  454. if (SqlHelper.ExecuteNonQuery(sql, CommandType.Text) > 0)
  455. return true;
  456. }
  457. return false;
  458. }
  459. /// <summary>
  460. /// 获取团组总费用
  461. /// </summary>
  462. /// <param name="diid"></param>
  463. /// <returns></returns>
  464. public double GetSumByDIID(int diid)
  465. {
  466. Object obj = SqlHelper.ExecuteScalar("select sum(PayMoney) from CreditCardPayment where diid = " + diid + " and isDel = 0 and isPay = 1", CommandType.Text);
  467. if (obj == null || string.IsNullOrEmpty(obj.ToString()))
  468. {
  469. return 0.0;
  470. }
  471. else
  472. {
  473. return (double)(obj);
  474. }
  475. }
  476. public decimal GetRBMSumByDiid(int diid)
  477. {
  478. Object obj = SqlHelper.ExecuteScalar("select SUM(RMBPrice) from CreditCardPayment where diid = " + diid + " and isDel = 0 and isPay = 1", CommandType.Text);
  479. if (obj == null || string.IsNullOrEmpty(obj.ToString()))
  480. {
  481. return 0.00M;
  482. }
  483. else
  484. {
  485. return Convert.ToDecimal(obj);
  486. }
  487. }
  488. /// <summary>
  489. /// 根据团组业务类型获取收款方
  490. /// </summary>
  491. /// <param name="Ctable">团组业务类型</param>
  492. /// <returns></returns>
  493. public List<string> GetPayee(int Ctable, string payee)
  494. {
  495. List<string> List = new List<string>();
  496. using (SqlDataReader dr = SqlHelper.ExcuteReader("select Distinct(payee) from CreditCardPayment where CTable = " + Ctable + " AND Ispay=1 and Isdel=0 and payee like '%" + payee + "%' ", CommandType.Text))
  497. {
  498. if (dr != null)
  499. {
  500. string str = "";
  501. while (dr.Read())
  502. {
  503. str = dr["payee"].ToString();
  504. List.Add(str);
  505. }
  506. }
  507. }
  508. return List;
  509. }
  510. /// <summary>
  511. /// 获取非团组总费用
  512. /// </summary>
  513. /// <param name="p"></param>
  514. /// <returns></returns>
  515. public double GetSumOfNotTeamByDIID(int diid)
  516. {
  517. return (double)(SqlHelper.ExecuteScalar("select sum(PayMoney) from CreditCardPayment where diid <> " + diid + "", CommandType.Text));
  518. }
  519. /// <summary>
  520. /// 更改团组是否操作完成状态
  521. /// </summary>
  522. /// <param name="id"></param>
  523. /// <returns></returns>
  524. public bool EditCreditCardPaymentByDiid(int id)
  525. {
  526. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set IsSure = 1,SureTime=" + DateTime.Now + " where Id = @Id", CommandType.Text, new SqlParameter("@Id", id)) > 0)
  527. return true;
  528. return false;
  529. }
  530. /// <summary>
  531. /// 根据信用卡账单修改酒店付款金额
  532. /// </summary>
  533. /// <param name="diid"></param>
  534. /// <param name="hotelName"></param>
  535. public bool UpdateCreditCardPaymentMoney(int diid, string hotelName, int payMoney)
  536. {
  537. if (SqlHelper.ExecuteNonQuery("update T set T.PayThenMoneyOld=T.PayThenMoney,T.UpdateDate=T.OperatorDate,T.paymoney = " + payMoney + " from CreditCardPayment T inner join HotelReservations H on T.diid=H.diid where T.diid=" + diid + " and h.isdel=0 and t.isdel=0 and t.CTABLE = 76 and t.cid = h.id and h.hotelName ='" + hotelName + "'", CommandType.Text, null) > 0)
  538. return true;
  539. return false;
  540. }
  541. /// <summary>
  542. /// 根据信用卡账单修改机票付款金额
  543. /// </summary>
  544. /// <param name="diid"></param>
  545. /// <param name="p"></param>
  546. public bool UpdateCreditCardPaymentMoneyForAirTick(int diid, int payMoney)
  547. {
  548. if (SqlHelper.ExecuteNonQuery("update CreditCardPayment set PayThenMoneyOld=paymoney,UpdateDate=OperatorDate,paymoney = " + payMoney + " where diid=" + diid + " and ctable=85 and isdel=0", CommandType.Text, null) > 0)
  549. return true;
  550. return false;
  551. }
  552. /// <summary>
  553. /// 根据团组编号查询该团组的付款信息
  554. /// </summary>
  555. /// <param name="diid"></param>
  556. /// <returns></returns>
  557. public List<CreditCardPayment> GetOPIsPayListByDIID(int diid, int ispay)
  558. {
  559. string sql = "select * from creditCardPayment where diid = " + diid + " and isdel=0 and IsAuditGM=1";
  560. if (ispay != 2)
  561. sql += " and ispay=" + ispay;
  562. return excuteSql(sql);
  563. }
  564. /// <summary>
  565. /// 根据团组编号查询该团组的付款信息 notIsPsy
  566. /// </summary>
  567. /// <param name="diid"></param>
  568. /// <returns></returns>
  569. public List<CreditCardPayment> GetByDIIDNotIsPay(int diid)
  570. {
  571. string sql = "select * from creditCardPayment where diid = " + diid + " and isdel = 0 and IsAuditGM <> 2 ";
  572. return excuteSql(sql);
  573. }
  574. /// <summary>
  575. /// 根据团组编号查询该团组的付款信息
  576. /// </summary>
  577. /// <param name="diid"></param>
  578. /// <returns></returns>
  579. public List<CreditCardPayment> GetListByDIID(int diid)
  580. {
  581. string sql = "select * from creditCardPayment where diid = " + diid + " and isdel = 0 and isPay = 1";
  582. return excuteSql(sql);
  583. }
  584. /// <summary>
  585. /// 根据团组编号查询该团组的付款信息
  586. /// </summary>
  587. /// <param name="diid"></param>
  588. /// <returns></returns>
  589. public List<CreditCardPayment> GetListByID(int id)
  590. {
  591. string sql = "select * from creditCardPayment where id = " + id + " and isdel=0";
  592. return excuteSql(sql);
  593. }
  594. /// <summary>
  595. /// 查询团组所有的付款信息
  596. /// </summary>
  597. /// <returns></returns>
  598. public List<CreditCardPayment> GetOPListByDIID(string diid, string startTime, string endTime)
  599. {
  600. return excuteSql("select * from creditCardPayment where diid = " + diid + " and isDel = 0 and VisitDate between '" + startTime + "' and '" + endTime + "'");
  601. }
  602. /// <summary>
  603. /// 经理审核
  604. /// </summary>
  605. /// <returns></returns>
  606. public List<CreditCardPayment> GetOPListByDIID(int isAuditGM)
  607. {
  608. return excuteSql("select * from creditCardPayment where IsPay = 0 and IsAuditGM = " + isAuditGM + " and isDel = 0");
  609. }
  610. /// <summary>
  611. /// 根据条件查询条件获取 - 分页
  612. /// </summary>
  613. /// <param name="pageIndex"></param>
  614. /// <param name="sumPage"></param>
  615. /// <param name="totalRecord"></param>
  616. /// <param name="dataType"></param>
  617. /// <param name="name"></param>
  618. /// <returns></returns>
  619. public DataTable GetAll(int pageIndex, int pageSize, out int sumPage, out int totalRecord, int isAuditGM, string teamName, string tourCode, string clientName, string clientUnit)
  620. {
  621. SqlParameter[] parameter = new SqlParameter[]{
  622. new SqlParameter("@pageIndex",pageIndex),
  623. new SqlParameter("@pageSize",pageSize),
  624. new SqlParameter("@isAuditGM",isAuditGM),
  625. new SqlParameter("@teamName",teamName),
  626. new SqlParameter("@tourCode",tourCode),
  627. new SqlParameter("@clientName",clientName),
  628. new SqlParameter("@clientUnit",clientUnit)
  629. };
  630. SqlParameter[] parameter1 = new SqlParameter[]{
  631. new SqlParameter("@isAuditGM",isAuditGM),
  632. new SqlParameter("@teamName",teamName),
  633. new SqlParameter("@tourCode",tourCode),
  634. new SqlParameter("@clientName",clientName),
  635. new SqlParameter("@clientUnit",clientUnit)
  636. };
  637. string sqlC = "select count(1) from creditCardPayment T join DelegationInfo D on T.diid=D.id join setData S on T.Cid=S.ID join setData S1 on T.CTable=S1.ID where T.isdel=0 and isAuditGM=@isAuditGM and TeamName like '%" + teamName + "%' and TourCode like '%" + tourCode + "%' and ClientName like '%" + clientName + "%' and clientUnit like '%" + clientUnit + "%'";
  638. object result = SqlHelper.ExecuteScalar(sqlC, CommandType.Text, parameter1);
  639. if (result != null)
  640. {
  641. totalRecord = Convert.ToInt32(result.ToString());
  642. //计算出总页数
  643. sumPage = totalRecord % 10 == 0 ? totalRecord / 10 : totalRecord / 10 + 1;
  644. }
  645. else
  646. {
  647. totalRecord = 0;
  648. //计算出总页数
  649. sumPage = 1;
  650. }
  651. return SqlHelper.TransferProcedure("exec_creditCardPayment", CommandType.StoredProcedure, parameter);
  652. }
  653. //签证费用审核过不能删除
  654. public bool isAduitByaVisa(int diid, int cid)
  655. {
  656. string sql = "select * from creditCardPayment WHERE DIId= @diid AND CId=@cid AND (IsAuditDM=1 OR IsAuditGM = 1 OR IsAuditMF = 1)";
  657. SqlParameter[] parameter = new SqlParameter[]{
  658. new SqlParameter("@diid",diid),
  659. new SqlParameter("@cid",cid)
  660. };
  661. object result = SqlHelper.ExecuteScalar(sql, CommandType.Text, parameter);
  662. if (result != null)
  663. {
  664. return true;
  665. }
  666. else
  667. {
  668. return false;
  669. }
  670. }
  671. /// <summary>
  672. /// 获取全部 - 分页 + 条件
  673. /// </summary>
  674. /// <param name="pageIndex">分页当前页数</param>
  675. /// <param name="sumPage">分页总页数</param>
  676. /// <param name="totalRecord">一共多少条数据</param>
  677. /// <param name="TypeId">信用卡类型</param>
  678. /// <param name="dateType">日期类型</param>
  679. /// <param name="startTime">开始时间</param>
  680. /// <param name="endTime">结束时间</param>
  681. /// <param name="HandlersOper">经手人</param>
  682. /// <returns></returns>
  683. public List<CreditCardPayment> GetALL(int pageIndex, out int sumPage, out int totalRecord, int TypeId, int dateType, string startTime, string endTime, string HandlersOper)
  684. {
  685. //消费类型 不匹配 财付通,京东,微信支付,淘宝
  686. string sqlwhere = "charindex('财付通',ConsumptionPatterns) = 0 " +
  687. "and charindex('京东',ConsumptionPatterns) = 0 " +
  688. "and charindex('微信支付',ConsumptionPatterns) = 0 " +
  689. "and charindex('淘宝',ConsumptionPatterns) = 0 ";
  690. //信用卡类型
  691. if (TypeId == 0)
  692. sqlwhere += " and IsDel = 0 and CTDId != 0 ";
  693. else
  694. sqlwhere += " and IsDel = 0 and CTDId != 0 and CTDId =" + TypeId;
  695. //时间类型
  696. if (dateType == 0 && startTime != "")
  697. {
  698. if (endTime != "")
  699. sqlwhere += " and ConsumptionDate between '" + startTime + "' and '" + endTime + "'";
  700. else
  701. {
  702. endTime = DateTime.Now.ToString("yyyy-MM-dd");
  703. sqlwhere += " and ConsumptionDate between '" + startTime + "' and '" + endTime + "'";
  704. }
  705. }
  706. else if (dateType == 1 && startTime != "")
  707. {
  708. if (endTime != "")
  709. sqlwhere += " and MFOperatorsDate between '" + startTime + "' and '" + endTime + "'";
  710. else
  711. {
  712. endTime = DateTime.Now.ToString("yyyy-MM-dd");
  713. sqlwhere += " and MFOperatorsDate between '" + startTime + "' and '" + endTime + "'";
  714. }
  715. }
  716. //经手人
  717. if (HandlersOper != "")
  718. sqlwhere += " and Operator=" + HandlersOper;
  719. return PageBase<CreditCardPayment>.excutePageSql(new CreditCardPayment(), "CreditCardPayment", "CreditCardPayment", "*", "id desc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  720. }
  721. public List<CreditCardPayment> GetALL(string OperType,int size ,int page,out int total,string Queryname,string groupName)
  722. {
  723. string QuerySql = string.Empty;
  724. string sql = $"select top {size} * from creditCardPayment where isdel = 0 and Operator > 0 and Operator is not null ";
  725. total = 0 ;
  726. if (!string.IsNullOrWhiteSpace(Queryname))
  727. {
  728. UsersService usersService = new UsersService();
  729. var queryUserId = usersService.GetAll().FindAll(x => x.CnName.Contains(Queryname)).Select(x => x.Id);
  730. if (queryUserId.Count() > 0)
  731. {
  732. QuerySql += $" and Operator in ({string.Join(",", queryUserId).TrimEnd(',')}) ";
  733. }
  734. else
  735. {
  736. QuerySql += $" and Operator in (0) ";
  737. }
  738. }
  739. if (!string.IsNullOrWhiteSpace(groupName))
  740. {
  741. DelegationInfoService Dele = new DelegationInfoService();
  742. var deleId = Dele.getByName(groupName).Select(x => x.Id);
  743. if (deleId.Count() > 0)
  744. {
  745. QuerySql += $" and DIId in ({string.Join(",", deleId).TrimEnd(',')}) ";
  746. }
  747. else
  748. {
  749. QuerySql += $" and DIId in (0) ";
  750. }
  751. }
  752. sql += QuerySql;
  753. if (OperType == "finance")
  754. {
  755. sql += $@" and IsAuditMF = 0 and IsAuditGM = 0 and Id not in (
  756. select top {(page-1)*size} Id from creditCardPayment where isdel = 0 and Operator > 0 and Operator is not null
  757. and IsAuditMF = 0 and IsAuditGM = 0 {QuerySql}
  758. order by DIId desc
  759. )";
  760. total = (int)SqlHelper.ExecuteScalar($@"select count(*) from creditCardPayment where isdel = 0 and Operator > 0
  761. and Operator is not null and IsAuditMF = 0 and IsAuditGM = 0 " + QuerySql, CommandType.Text);
  762. }
  763. else if (OperType == "GM")
  764. {
  765. sql += $@" and IsAuditMF = 1 and IsAuditGM = 0 and Id not in (
  766. select top {(page - 1) * size} Id from creditCardPayment where isdel = 0 and Operator > 0 and Operator is not null
  767. and IsAuditMF = 1 and IsAuditGM = 0 {QuerySql}
  768. order by DIId desc
  769. )";
  770. total = (int)SqlHelper.ExecuteScalar($@"select count(*) from creditCardPayment where isdel = 0 and Operator > 0
  771. and Operator is not null and IsAuditMF = 1 and IsAuditGM = 0 " + QuerySql, CommandType.Text);
  772. }
  773. sql += " order by DIId desc ";
  774. return excuteSql(sql);
  775. }
  776. /// <summary>
  777. /// excel导出查询
  778. /// </summary>
  779. /// <param name="TypeId">信用卡类型</param>
  780. /// <param name="startTime">开始时间</param>
  781. /// <param name="endTime">结束时间</param>
  782. /// <returns></returns>
  783. public List<CreditCardPayment> GetDownExcelSelelct(int TypeId, string startTime, string endTime)
  784. {
  785. string sqlwhere = "select * from creditCardPayment where ";
  786. //信用卡类型
  787. if (TypeId == 0)
  788. sqlwhere += "IsDel = 0 and CTDId != 0 ";
  789. else
  790. sqlwhere += "IsDel = 0 and CTDId != 0 and CTDId =" + TypeId;
  791. sqlwhere += " and ConsumptionDate between '" + startTime + "' and '" + endTime + "'";
  792. return excuteSql(sqlwhere);
  793. }
  794. }
  795. }