123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?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('user_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() {
-
- }
-
- }
|