소스 검색

支付配置

lizhen_gitee 10 달 전
부모
커밋
29ad67d0b9
3개의 변경된 파일17개의 추가작업 그리고 97개의 파일을 삭제
  1. 5 6
      application/api/controller/HuiPay.php
  2. 2 87
      application/api/controller/Pay.php
  3. 10 4
      application/utils/JingXiu/JingXiuPayUtil.php

+ 5 - 6
application/api/controller/HuiPay.php

@@ -50,8 +50,8 @@ class HuiPay extends Api
             $pay_type = input('pay_type', 'wechat');
             $uid = $this->auth->id;
 
-            if ($pay_type != 'wechat') {
-                throw new Exception('支付类型有误');
+            if (!in_array($pay_type, ['wechat', 'alipay'])) {
+                throw new Exception('错误的支付类型');
             }
 
             if (!$rc_id) {
@@ -109,7 +109,7 @@ class HuiPay extends Api
             Db::commit();
 
             $pay = new JingXiuPayUtil();
-            if (!$pay->wxWapPay($pay_no,$money,'充值会员','/api/hui_pay/pay_notify')){
+            if (!$pay->wxWapPay($pay_no,$money,'充值会员','/api/hui_pay/pay_notify',$pay_type)){
                 $this->error($pay->getMessage());
             }
             $data = $pay->getData();
@@ -129,7 +129,7 @@ class HuiPay extends Api
         Db::startTrans();
         try {
             $rc_id = input_post('rc_id', 0);
-            $pay_type = 'wechat';
+            $pay_type  = input_post('pay_type','wechat');
             $freemoney = input_post('freemoney', 0, 'intval');
             $uid = $this->auth->id;
 
@@ -202,11 +202,10 @@ class HuiPay extends Api
 
             Db::commit();
             $pay = new JingXiuPayUtil();
-            if (!$pay->wxWapPay($pay_no,$money,'充值金币','/api/hui_pay/pay_notify')){
+            if (!$pay->wxWapPay($pay_no,$money,'充值金币','/api/hui_pay/pay_notify',$pay_type)){
                 $this->error($pay->getMessage());
             }
             $data = $pay->getData();
-            dump($data);exit;
             $this->success('success', $data);
         } catch (Exception $e) {
             Db::rollback();

+ 2 - 87
application/api/controller/Pay.php

@@ -109,6 +109,7 @@ class Pay extends Api
     }*/
     public function vip_recharge()
     {
+        exit;//功能重复,采用精秀,屏蔽
         Db::startTrans();
         try {
             $rc_id = input('rc_id',0);
@@ -227,98 +228,12 @@ class Pay extends Api
         $this->success('success',$data);
     }
 
-    //充值金币 创建订单
-    /*public function gold_recharge(){
-
-        $rc_id     = input_post('rc_id',0);
-        $pay_type  = input_post('pay_type','wechat');
-        $freemoney = input_post('freemoney', 0, 'intval');
-        $uid = $this->auth->id;
-
-        if(!$rc_id && !$freemoney){
-            $this->error('请选择或填写充值金额');
-        }
-
-        //赋值money
-        if($rc_id){
-            $recharge_config = Db::name('paygold_config')->where('id',$rc_id)->find();
-            $money = $recharge_config ? $recharge_config['money']: 0;
-            $gold  = $recharge_config ? $recharge_config['gold'] : 0;
-            $first_gold     = $recharge_config ? $recharge_config['first_gold'] : 0;
-            $first_vipdays  = $recharge_config ? $recharge_config['first_vipdays'] : 0;
-            $vip_gold  = $recharge_config ? $recharge_config['vip_gold'] : 0;
-        }
-
-        //自由输入覆盖
-        if(!empty($freemoney)){
-            $rc_id = 0;
-            $money = floatval($freemoney);
-            $bili = config('site.money_to_gold') ?: 10;
-            $gold  = bcmul($money,$bili,0);
-            $first_gold = 0;
-            $first_vipdays = 0;
-            $vip_gold  = 0;
-        }
-
-        //
-        if($money<=0)
-        {
-            $this->error('支付金额必须大于0');
-        }
-        if($money > 10000){
-            $this->error('支付金额太大');
-        }
-        //查询是不是会员,若不是则不赠送金币
-        $vip_endtime = Db::name('user_wallet')->where('user_id',$this->auth->id)->value('vip_endtime');
-        if ($vip_endtime < time()) {
-            $vip_gold = 0;
-        }
-
-        //创建订单
-        $data = [];
-        $data['status'] = 0;
-        $pay_no = createUniqueNo('P',$uid);
-        $data['pay_no'] = $pay_no;
-        $data['money'] = $money;
-        $data['payment_class'] = $pay_type;
-        $data['user_id'] = $uid;
-        $data['ext_info'] =  json_encode(['subject'=>'充值金币支付']);
-        $data['memo'] =  '充值金币支付';
-        $data['createtime'] = time();
-        $data['payment'] = 'app';
-        $orderid = Db::name('pay_order')->insertGetId($data);
-
-        //创建回调
-        $even_data = [];
-        $even_data['event'] = 'success';
-        $even_data['class'] = 'app\common\model\Recharge';
-        $even_data['method'] = 'goldpaysucc';
-        $even_data['args'] = json_encode(['user_id'=>$uid,'gold'=>$gold,'money'=>$money,'pg_id'=>$rc_id,'first_gold'=>$first_gold,'first_vipdays'=>$first_vipdays, 'intro_uid' => $this->auth->intro_uid, 'vip_gold' => $vip_gold]);
-        $even_data['pay_no'] = $pay_no;
-        Db::name('pay_event')->insertGetId($even_data);
 
-        //下单
-        $params = [
-            'type'         => $pay_type,
-            'orderid'      => $pay_no,
-            'title'        => $data['memo'],
-            'amount'       => $data['money'],
-//            'amount'       => 0.01,
-            'method'       => 'app',
-            'notifyurl' => $this->request->root(true) . '/notify.php/paytype/'.$pay_type,
-            'returnurl' => '',
-        ];
-        $res = Service::submitOrder($params);
-        if($pay_type == 'wechat'){
-            $this->success('success',json_decode($res,true));
-        }else{
-            $this->success('success',$res);
-        }
-    }*/
 
     //充值金币 创建订单
     public function gold_recharge()
     {
+        exit;//功能重复,采用精秀,屏蔽
         Db::startTrans();
         try {
             $rc_id     = input_post('rc_id',0);

+ 10 - 4
application/utils/JingXiu/JingXiuPayUtil.php

@@ -24,20 +24,26 @@ class JingXiuPayUtil extends Module
      * @param $notify_url
      * @return bool
      */
-    public function wxWapPay($order_no, $money, $remark = '', $notify_url = '')
+    public function wxWapPay($order_no, $money, $remark = '', $notify_url = '',$pay_type)
     {
         $this->order_no   = $order_no;
         $this->money      = $money;
         // $this->money      = 0.01;
         $this->remark     = $remark;
         $this->notify_url = $notify_url;
+
+        $payment = [
+            'wechat' => 'wechatLiteH5',
+            'alipay' => 'аlipаyApр',
+        ];
+
         try {
-            $result   = $this->addOrder('wechatLiteH5');
+            $result   = $this->addOrder($payment[$pay_type]);
             $code_url = $result['payurl'];
         } catch (\Exception $e) {
-            return $this->error('微信支付下单失败!' . $e->getMessage());
+            return $this->error('支付下单失败!' . $e->getMessage());
         }
-        return $this->success('微信支付下单成功!', [
+        return $this->success('支付下单成功!', [
             'out_trade_no' => $result['out_trade_no'],
             'total_amount' => $result['total_amount'],
             'trade_no'     => $result['trade_no'],