SysPayment.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. namespace Biz\Pay;
  3. class SysPayment {
  4. protected $paymentBank = '';
  5. protected $paymentQuick = '';
  6. protected $paymentTypeList = array();
  7. static function init() {
  8. return new self();
  9. }
  10. public function __construct() {
  11. $this->pay_type();
  12. $this->paymentBank = 'HuiPay'; //网银支付名称
  13. $this->paymentQuick = 'XinHuiScan'; //快捷支付名称
  14. $this->paymentTypeList = array(
  15. 'alipay', //支付宝
  16. 'weixin', // 微信
  17. 'baidupay', //百付宝
  18. 'tenpay', //财付通
  19. 'qqpay', //QQ钱包
  20. 'jdpay', //京东钱包
  21. 'union', //银联
  22. );
  23. }
  24. /**
  25. * 得到当前系统设置的快捷支付名称
  26. * @return [type] [description]
  27. */
  28. public function getCurrentQuickPaymentName() {
  29. return $this->paymentQuick;
  30. }
  31. /**
  32. * 读取支付类型
  33. * [pay_type description]
  34. * @return [type] [description]
  35. */
  36. public function pay_type() {
  37. $data = M('payment')->where('status', '1')->get();
  38. if ($data['pay_type'] == 1) {
  39. $this->paymentBank = $data['payment_name'];
  40. }
  41. if ($data['pay_type'] == 2) {
  42. $this->paymentQuick = $data['payment_name'];
  43. }
  44. return $data;
  45. }
  46. /**
  47. * 得到当前系统设置的银行直链名称
  48. * @return [type] [description]
  49. */
  50. public function getCurrentBankPaymentName() {
  51. return $this->paymentBank;
  52. }
  53. /**
  54. * 得到所有快捷支付的可支付类型列表
  55. **/
  56. public function getQuickTypeList() {
  57. $cls = "\\Biz\\Pay\\Payment\\" . $this->paymentQuick . "Payment";
  58. $payment = new $cls(new \Biz\Pay\PaymentDataAccess());
  59. $paymentList = $payment->getPaymentType();
  60. $paymentList = $this->filterPayType($paymentList);
  61. return $paymentList;
  62. }
  63. /**
  64. * 得到所有网银在线支付类型列表
  65. * @return [type] [description]
  66. */
  67. public function getBankTypeList($changeMobile = 1) {
  68. $cls = "\\Biz\\Pay\\Payment\\" . $this->paymentBank . "Payment";
  69. $payment = new $cls(new \Biz\Pay\PaymentDataAccess());
  70. $payment->isMobile = $changeMobile;
  71. return $paymentList = $payment->getPaymentType();
  72. }
  73. /**
  74. * 过滤不存在的支付类型
  75. * @param [type] $payment_list [description]
  76. * @return [type] [description]
  77. */
  78. public function filterPayType($payment_list) {
  79. $list = $this->paymentTypeList;
  80. $enabled = array();
  81. if (is_array($payment_list) && count($payment_list) > 0) {
  82. foreach ($payment_list as $k => $v) {
  83. if (in_array($k, $list)) {
  84. $enabled[] = $k;
  85. }
  86. }
  87. if (is_array($enabled) && count($enabled) > 0) {
  88. return $enabled;
  89. }
  90. return;
  91. }
  92. return;
  93. }
  94. public function getLang() {
  95. return include ROOT_PATH . '/Config/payment.conf.php';
  96. }
  97. }