Bläddra i källkod

订单余额支付

lizhen_gitee 10 månader sedan
förälder
incheckning
646e44405d

+ 3 - 3
application/admin/controller/Index.php

@@ -41,9 +41,9 @@ class Index extends Backend
         }
         //左侧菜单
         list($menulist, $navlist, $fixedmenu, $referermenu) = $this->auth->getSidebar([
-            'dashboard' => 'hot',
-            'addon'     => ['new', 'red', 'badge'],
-            'auth/rule' => __('Menu'),
+//            'dashboard' => 'hot',
+//            'addon'     => ['new', 'red', 'badge'],
+//            'auth/rule' => __('Menu'),
         ], $this->view->site['fixedpage']);
         $action = $this->request->request('action');
         if ($this->request->isPost()) {

+ 42 - 4
application/api/controller/Wenzhen.php

@@ -72,7 +72,7 @@ class Wenzhen extends Api
             'total_fee'  => $price,
             'book_time'  => strtotime($book_time),
             'createtime' => time(),
-            'status'     => 0,
+            'status'     => 0,//订单状态enum
         ];
 
         Db::startTrans();
@@ -109,7 +109,7 @@ class Wenzhen extends Api
         $pay_type = input('pay_type','wechat');
 
         //pay_type
-        if(!in_array($pay_type,['wechat','alipay'])){
+        if(!in_array($pay_type,['wechat','alipay','wallet'])){
             $this->error();
         }
 
@@ -122,6 +122,37 @@ class Wenzhen extends Api
             $this->error('该订单不能支付');
         }
 
+
+        if($pay_type == 'wallet'){
+            Db::startTrans();
+
+            //扣钱
+            $logtype = $wenzhen_order['ordertype'] == 1 ? 11 : 12;
+            $rs_wallet = model('wallet')->lockChangeAccountRemain($this->auth->id,'money',$wenzhen_order['total_fee'],$logtype,'图文问诊'.$wenzhen_order['order_no'],'wenzhen_order',$order_id);
+            if($rs_wallet['status'] == false){
+                Db::rollback();
+                $this->error($rs_wallet['msg']);
+            }
+
+            //订单改为已支付
+            $wenzhen_update['status'] = 10;//订单状态enum
+            $wenzhen_update['pay_type'] = $pay_type;
+            $wenzhen_update['pay_time'] = time();
+            $update_rs = Db::name('wenzhen_order')->where('id',$order_id)->where('status',0)->update($wenzhen_update);
+            if(!$update_rs){
+                Db::rollback();
+                $this->error('支付失败,重试一下吧');
+            }
+
+            Db::commit();
+
+            $result = [
+                'pay_type' => $pay_type,
+                'pay_params' => '',
+            ];
+            $this->success(1,$result);
+        }
+
         //创建订单
         $platform = 'app';
         $data = [];
@@ -154,11 +185,18 @@ class Wenzhen extends Api
 
         $res = Service::submitOrder($params);
 
+        $result = [
+            'pay_type'=> $pay_type,
+            'pay_params'=> $pay_type
+
+        ];
         if($pay_type == 'wechat'){
-            $this->success('success',json_decode($res,true));
+            $result['pay_params'] = json_decode($res,true);
         }else{
-            $this->success('success',$res);
+            $result['pay_params'] = $res;
         }
+
+        $this->success(1,$result);
     }
 
     //订单列表

+ 4 - 4
application/extra/wallet.php

@@ -10,8 +10,8 @@ return [
 
         10 => '钱包充值到账',//money +
 
-        11 => '图文订单',//money -
-        12 => '视频订单',//money -
+        11 => '图文问诊',//money -
+        12 => '视频问诊',//money -
 
 
         21 => '钱包余额提现',//money -
@@ -20,8 +20,8 @@ return [
 
 /////////////////医生//////////////////
 
-        111 => '图文订单', //money +
-        112 => '视频订单', //money +
+        111 => '图文问诊', //money +
+        112 => '视频问诊', //money +
 
         121 => '钱包余额提现', //money -
         122 => '提现拒绝返回', //money +