member_payment.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. /**
  3. * 支付
  4. *
  5. *
  6. *
  7. *
  8. * by 33hao.com 好商城V3 运营版
  9. */
  10. //use Shopnc\Tpl;
  11. defined('InShopNC') or exit('Access Invalid!');
  12. class member_paymentControl extends mbMemberControl
  13. {
  14. private $payment_code = 'alipay';
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. $this->payment_code = isset($_GET['payment_code']) && trim($_GET['payment_code']) != '' ? trim($_GET['payment_code']) : 'alipay';
  19. }
  20. /**
  21. * 实物订单支付
  22. */
  23. public function payOp()
  24. {
  25. $token = trim($_GET['key']);
  26. if (false == $this->checkToken($token)) {
  27. return joutput_error($this->err_code);
  28. }
  29. $pay_sn = $_GET['pay_sn'];
  30. $model_mb_payment = Model('mb_payment');
  31. $logic_payment = Logic('payment');
  32. $condition = array();
  33. $condition['payment_code'] = $this->payment_code;
  34. $mb_payment_info = $model_mb_payment->getMbPaymentOpenInfo($condition);
  35. if (!$mb_payment_info) {
  36. output_error('系统不支持选定的支付方式');
  37. }
  38. //重新计算所需支付金额
  39. $result = $logic_payment->getRealOrderInfo($pay_sn, $this->member_info['member_id']);
  40. if (!$result['state']) {
  41. output_error($result['msg']);
  42. }
  43. //第三方API支付
  44. $this->_api_pay($result['data'], $mb_payment_info);
  45. }
  46. /**
  47. * 虚拟订单支付
  48. */
  49. public function vr_payOp()
  50. {
  51. $token = trim($_GET['key']);
  52. if (false == $this->checkToken($token)) {
  53. return joutput_error($this->err_code);
  54. }
  55. $order_sn = $_GET['pay_sn'];
  56. $model_mb_payment = Model('mb_payment');
  57. $logic_payment = Logic('payment');
  58. $condition = array();
  59. $condition['payment_code'] = $this->payment_code;
  60. $mb_payment_info = $model_mb_payment->getMbPaymentOpenInfo($condition);
  61. if (!$mb_payment_info) {
  62. output_error('系统不支持选定的支付方式');
  63. }
  64. //重新计算所需支付金额
  65. $result = $logic_payment->getVrOrderInfo($order_sn, $this->member_info['member_id']);
  66. if (!$result['state']) {
  67. output_error($result['msg']);
  68. }
  69. //第三方API支付
  70. $this->_api_pay($result['data'], $mb_payment_info);
  71. }
  72. /**
  73. * 第三方在线支付接口
  74. *
  75. */
  76. private function _api_pay($order_pay_info, $mb_payment_info)
  77. {
  78. $inc_file = BASE_PATH . DS . 'api' . DS . 'payment' . DS . $this->payment_code . DS . $this->payment_code . '.php';
  79. if (!is_file($inc_file)) {
  80. output_error('支付接口不存在');
  81. }
  82. if ($payment_info['payment_code'] == 'wxpay') {
  83. $wxpayurl = BASE_SITE_URL . '/mobile/api/payment/wxpay/wxpay.php?pay_sn=' . $order_pay_info['pay_sn'] . '&pay_amount=' . $order_pay_info['api_pay_amount'];
  84. redirect($wxpayurl);
  85. //@header("Location: ".ApiUrl.'/api/paymentpaypay.php?pay_sn='.$order_pay_info['pay_sn'].'&pay_amount='.$order_pay_info['api_pay_amount']);
  86. } else {
  87. require($inc_file);
  88. $param = array();
  89. $param = $mb_payment_info['payment_config'];
  90. $param['order_sn'] = $order_pay_info['pay_sn'];
  91. $param['order_amount'] = $order_pay_info['api_pay_amount'];
  92. $param['order_type'] = ($order_pay_info['order_type'] == 'real_order' ? 'r' : 'v');
  93. $payment_api = new $this->payment_code();
  94. $return = $payment_api->submit($param);
  95. echo $return;
  96. }
  97. exit();
  98. }
  99. /**
  100. * 获取可用参数列表
  101. */
  102. public function payment_listOp()
  103. {
  104. $token = trim($_GET['key']);
  105. if (false == $this->checkToken($token)) {
  106. return joutput_error($this->err_code);
  107. }
  108. $model_mb_payment = Model('mb_payment');
  109. $payment_list = $model_mb_payment->getMbPaymentOpenList();
  110. $payment_array = array();
  111. if (!empty($payment_list)) {
  112. foreach ($payment_list as $value) {
  113. $payment_array[] = $value['payment_code'];
  114. }
  115. }
  116. output_data(array('payment_list' => $payment_array));
  117. }
  118. }