FinancialPayApiControl.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. namespace LYFZ.Software.MainBusiness.FinancialManagement
  7. {
  8. class FinancialPayApiControl
  9. {
  10. public string SerialNumber { get; set; }
  11. public int PayApiControl(string StrOrdNumber, string payType, decimal paymentAmount)
  12. {
  13. LYFZ.BLL.BLL_ErpSystemConfigure config = new BLL.BLL_ErpSystemConfigure();
  14. if (payType.Replace(" ", "")==("微信刷卡支付"))
  15. {
  16. DataSet ds = config.GetSystemConfigure("*", "WeiXinPayConfig");
  17. if (ds.Tables[0].Rows.Count > 0)
  18. {
  19. LYFZ.Model.Model_ErpSystemConfigure modConfig = config.DataRowToModel(ds.Tables[0].Rows[0]);
  20. LYFZ.BLL.WXConfigData data = new LYFZ.BLL.WXConfigData();
  21. data = (LYFZ.BLL.WXConfigData)Json.JsonTool.JsonToObject(modConfig.Sconfig_Value, data);
  22. if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  23. {
  24. data.MCHID = data.SubMchId;
  25. //data.SubMchId = "";
  26. }
  27. if (!string.IsNullOrEmpty(data.AppId) && !string.IsNullOrEmpty(data.MCHID) && !string.IsNullOrEmpty(data.Key) && data.Open && !string.IsNullOrEmpty(data.SubMchId))
  28. {
  29. LYFZ.Software.MainBusiness.OAShopManagement.frmActionPay actionPay = new OAShopManagement.frmActionPay();
  30. if (LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ThirdOnlinePay)
  31. {
  32. data.MCHID = data.SubMchId;
  33. data.SubMchId = "";
  34. }
  35. actionPay.BindInfoData(payType.Replace(" ", ""), paymentAmount,
  36. data.AppId, data.MCHID, data.Key, data.SubMchId, StrOrdNumber.Trim() + "_" + DateTime.Now.ToString("HHmmssff"), data.TypeData.ToString());
  37. if (actionPay.ShowDialog() != System.Windows.Forms.DialogResult.OK)
  38. {
  39. MessageBoxCustom.Show("取消微信刷卡支付,保存取消");
  40. return -1;
  41. }
  42. else
  43. {
  44. SerialNumber = actionPay.SerialNumber;
  45. return 1;
  46. }
  47. }
  48. else if(!data.Open)
  49. {
  50. MessageBoxCustom.Show("第三方支付 微信刷卡支付未开启,保存取消,请更换付款方式");
  51. return -1;
  52. }
  53. }
  54. }
  55. else if (payType.ToString().Replace(" ", "")==("支付宝条码支付"))
  56. {
  57. DataSet ds = config.GetSystemConfigure("*", "AliPayConfig");
  58. if (ds.Tables[0].Rows.Count > 0)
  59. {
  60. LYFZ.Model.Model_ErpSystemConfigure modConfig = config.DataRowToModel(ds.Tables[0].Rows[0]);
  61. BLL.AliConfigData data = new BLL.AliConfigData();
  62. data = (BLL.AliConfigData)Json.JsonTool.JsonToObject(modConfig.Sconfig_Value, data);
  63. if (!string.IsNullOrEmpty(data.AppId) && !string.IsNullOrEmpty(data.MCHID) && !string.IsNullOrEmpty(data.Key) && data.Open)
  64. {
  65. LYFZ.Software.MainBusiness.OAShopManagement.frmActionPay actionPay = new OAShopManagement.frmActionPay();
  66. if (!string.IsNullOrEmpty(data.SignType))
  67. {
  68. actionPay.signtype = data.SignType;
  69. }
  70. actionPay.BindInfoData(payType.Replace(" ", ""), paymentAmount,
  71. data.AppId, data.MCHID, data.Key, data.SubMchId, StrOrdNumber.Trim() + "_" + DateTime.Now.ToString("HHmmssff"), data.TypeData.ToString());
  72. if (actionPay.ShowDialog() != System.Windows.Forms.DialogResult.OK)
  73. {
  74. MessageBoxCustom.Show("取消支付宝面对面支付,保存取消");
  75. return -1;
  76. }
  77. else
  78. {
  79. SerialNumber = actionPay.SerialNumber;
  80. return 1;
  81. }
  82. }
  83. else if (!data.Open)
  84. {
  85. MessageBoxCustom.Show("第三方支付 支付宝条码支付未开启,保存取消,请更换付款方式");
  86. return -1;
  87. }
  88. }
  89. }
  90. return 0;
  91. }
  92. }
  93. }