15954078560 2 år sedan
förälder
incheckning
9146a0a330
1 ändrade filer med 101 tillägg och 0 borttagningar
  1. 101 0
      application/api/controller/Pay.php

+ 101 - 0
application/api/controller/Pay.php

@@ -0,0 +1,101 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use app\common\library\Ems;
+use app\common\library\Sms;
+use fast\Random;
+use think\Config;
+use think\Validate;
+use think\Db;
+use wxpay;
+
+/**
+ * 会员接口
+ */
+class Pay extends Api
+{
+    protected $noNeedLogin = ['notify'];
+    protected $noNeedRight = '*';
+
+    public function _initialize()
+    {
+        parent::_initialize();
+
+        if (!Config::get('fastadmin.usercenter')) {
+            $this->error(__('User center already closed'));
+        }
+
+    }
+
+    //二合一支付
+    public function pay() {
+        $user_token = input('token', '', 'trim');
+        if (!$user_token) {
+            $this->error('参数缺失');
+        }
+
+        //生成支付订单记录
+        $rechar_order['user_id'] = $this->auth->id;
+        $rechar_order['order_no'] = date('YmdHis', time()) . $this->auth->id . rand(10000000, 99999999); //微信订单编号
+        $rechar_order['money'] = 49;
+        $rechar_order['purpose'] = 3; //充值用途:1=支付订单,2=充值,3=开通会员
+        $rechar_order['pay_type'] = 'zhuowang';
+        $rechar_order['relation_id'] = 1;
+        $rechar_order['createtime'] = time();
+
+        //开始事务
+        $result = Db::name('rechar_order')->insertGetId($rechar_order);
+        if (!$result) {
+            $this->error('网络延迟,请稍后再试');
+        }
+
+        $url = 'http://183.207.215.112:8090/HDC/3.0/hop/svc/pay/toPay.ajax';
+        $data = [
+            'transId' => $rechar_order['order_no'],
+            'orderNo' => $rechar_order['order_no'],
+            'userToken' => $user_token,
+            'notifyUrl' => config('img_url') . '/api/pay/notify',
+            'backUrl' => config('back_url'),
+            'deskCode' => config('desk_code'),
+            'products' => [
+                [
+                    'productCode' => config('product_code'),
+                    'productPrice' => '29',
+                    'productUnit' => '连续包月',
+                    'productCount' => 1
+                ],
+                [
+                    'productCode' => config('product_code'),
+                    'productPrice' => '199',
+                    'productUnit' => '特惠包一年',
+                    'productCount' => 1
+                ],
+                [
+                    'productCode' => config('product_code'),
+                    'productPrice' => '269',
+                    'productUnit' => '特惠包两年',
+                    'productCount' => 1
+                ],
+            ]
+        ];
+        $data = json_encode($data, 320);
+        $header = [
+            'Host:112.4.10.122:8090',
+            'HDC-Service:2',
+            'HDC-APPID:00001',
+            'HDC-Token:8e2b129d2cd3ebf40ca5a1c6048b083ce92e5fd3f305fd6c11a3ef3e35b5fa08',
+            'Content-Type:application/json'
+        ];
+        $rs = httpRequest($url, 'POST', $data, $header);
+        p($rs);
+
+    }
+    
+    //支付回调
+    public function notify() {
+        
+    }
+    
+}