CreditCardPaymentService.cs 41 KB

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