Browse Source

同一个试课,只能买一次

lizhen_gitee 1 year ago
parent
commit
134539ca79
2 changed files with 12 additions and 0 deletions
  1. 11 0
      application/api/controller/Trylesson.php
  2. 1 0
      application/api/lang/en/trylesson.php

+ 11 - 0
application/api/controller/Trylesson.php

@@ -50,6 +50,17 @@ class Trylesson extends Api
             $this->error('该试课已下架');
         }
 
+        //同一个试课只能买一次
+        $check_map = [
+            'user_id' => $this->auth->id,
+            'order_status' => ['neq',0],
+            'trylesson_id' => $id,
+        ];
+        $check_order = Db::name('trylesson_order')->where($check_map)->find();
+        if(!empty($check_order)){
+            $this->error('您已经购买过此课程');
+        }
+
         //试课数据
         $field = ['firstname','lastname','mobile','email','height','age','weight','address','health','emergency','comefrom','is_first'];
         $data = request_post_hub($field);

+ 1 - 0
application/api/lang/en/trylesson.php

@@ -4,4 +4,5 @@ return [
     '该试课已下架' => 'This trial course has been removed from the shelves',
     '预约失败' => 'Reservation failed',
     '下单失败' => 'Order failed',
+    '您已经购买过此课程' => 'You have already purchased this course',
 ];