Pay.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\store\shopapi\controller;
  13. use app\model\system\Pay as PayModel;
  14. use app\model\web\Config as WebConfig;
  15. /**
  16. * 支付配置
  17. * Class Pay
  18. * @package app\shop\controller
  19. */
  20. class Pay extends BaseStoreApi
  21. {
  22. /**
  23. * 交易设置详情
  24. */
  25. public function configInfo()
  26. {
  27. $config_model = new WebConfig();
  28. $info = $config_model->getOrderConfig($this->site_id);
  29. $pay_config = $config_model->getPayConfig($this->site_id);
  30. $pay_config = $pay_config[ 'data' ][ 'value' ];
  31. $info = array_merge($info[ 'data' ][ 'value' ], $pay_config);
  32. return $this->response($this->success($info));
  33. }
  34. /**
  35. * 交易设置编辑
  36. */
  37. public function config()
  38. {
  39. $config_model = new WebConfig();
  40. $site_id = $this->site_id;
  41. $member_withdrawal_audit_switch = isset($this->params[ 'member_withdrawal_audit_switch' ]) ? $this->params[ 'member_withdrawal_audit_switch' ] : 0;// 会员提现审核开关,1:开启,0:关闭
  42. $member_withdrawal_rate = isset($this->params[ 'member_withdrawal_rate' ]) ? $this->params[ 'member_withdrawal_rate' ] : 0;
  43. $data = [
  44. 'member_withdrawal_audit_switch' => $member_withdrawal_audit_switch,
  45. 'member_withdrawal_rate' => $member_withdrawal_rate
  46. ];
  47. $res = $config_model->setPayConfig($data, $site_id);
  48. $auto_close = isset($this->params[ 'auto_close' ]) ? $this->params[ 'auto_close' ] : 0;//订单未付款自动关闭时间
  49. $auto_take_delivery = isset($this->params[ 'auto_take_delivery' ]) ? $this->params[ 'auto_take_delivery' ] : 14;//订单发货后自动收货时间
  50. $result = $config_model->setOrderConfig([
  51. 'auto_close' => $auto_close,
  52. 'auto_take_delivery' => $auto_take_delivery,
  53. ], $this->site_id);
  54. return $this->response($res);
  55. }
  56. /**
  57. * 在线支付
  58. * @return mixed|void
  59. */
  60. public function pay()
  61. {
  62. $out_trade_no = $this->params[ 'out_trade_no' ] ?? '';
  63. $pay_model = new PayModel();
  64. $pay_type = $this->params[ 'pay_type' ] ?? '';
  65. $return_url = url('shop/pay/payresult?out_trade_no=' . $out_trade_no);
  66. $res = $pay_model->pay($pay_type, $out_trade_no, 'h5', '', '', $return_url, 0);
  67. return $this->response($res);
  68. }
  69. /**
  70. * 支付结果
  71. * @return mixed|void
  72. */
  73. public function payresult()
  74. {
  75. $out_trade_no = $this->params[ 'out_trade_no' ] ?? '';
  76. $pay_model = new PayModel();
  77. $pay_info = $pay_model->getPayInfo($out_trade_no)[ 'data' ];
  78. if (empty($pay_info)) return $this->error('未获取到支付信息');
  79. return $this->response($pay_info);
  80. }
  81. }