Browse Source

盒子下单

lizhen_gitee 9 months ago
parent
commit
8c14a425f6
1 changed files with 25 additions and 4 deletions
  1. 25 4
      application/api/controller/tvuser/Wenzhen.php

+ 25 - 4
application/api/controller/tvuser/Wenzhen.php

@@ -33,10 +33,19 @@ class Wenzhen extends Api
         return $data;
     }
 
-    //检查是否月vip
+    //判断是否 健康E家自己的vip
     private function checkvip(){
+        $is_my_vip = 0;
+
         $tv_userid = $this->auth->tv_userid;
-        return true;
+
+        //跨数据库查询
+        $tv_user = Db::connect('database_tv')->name('hu_user')->where('id',$tv_userid)->find();
+        if(!empty($tv_user)){
+            $is_my_vip = $tv_user['is_my_vip'];
+        }
+
+        return $is_my_vip;
     }
 
     //创建订单
@@ -47,12 +56,24 @@ class Wenzhen extends Api
             $this->error('用户错误');
         }
 
-        //判断是否是电视盒子月vip
+        //判断是否 健康E家自己的vip
         $checkvip = $this->checkvip();
         if(!$checkvip){
-            $this->error('您还不是月VIP');
+            $this->error('您不是健康E家的VIP用户');
+        }
+
+        //检查本月是否已经下过一个有效单了
+        $checkmap = [
+            'user_id' => $this->auth->id,
+            'comefrom'=> 2,
+            'status'  => ['IN',[10,20,25,30]],//有效状态
+        ];
+        $check_order = Db::name('wenzhen_order')->where($checkmap)->find();
+        if(!empty($check_order)){
+            $this->error('您本月的免费问诊次数已用完');
         }
 
+        //问诊患者
         $member_data = $this->add_member();
 
         //问诊信息