Ver código fonte

我的订单

lizhen_gitee 1 ano atrás
pai
commit
61fc931d5d

+ 5 - 5
application/api/controller/Active.php

@@ -37,7 +37,7 @@ class Active extends Api
                 }
 
                 $item['status_text'] = $status_text;
-                $item['status'] = $status;
+                $item['active_status'] = $status;
             }
         }
 
@@ -58,6 +58,7 @@ class Active extends Api
 
     //报名
     public function join(){
+        $remark = input('remark',0);
         $active_id = input('id',0);
         $info = Db::name('active')->where('is_show',1)->where('id',$active_id)->find();
         if(!$info){
@@ -80,13 +81,11 @@ class Active extends Api
             'active_id' => $active_id,
             'user_id'    => $this->auth->id,
             'student_id'    => $student_id,
+            'status' => 1,
         ];
         $check = Db::name('order')->where($map)->find();
         if($check){
-            if($check['status'] == 0){
-                $this->error('您已经报名,请及时支付');
-            }
-            $this->error('您已经报名该活动');
+            $this->error('该学生已经报名本次活动');
         }
 
         Db::startTrans();
@@ -100,6 +99,7 @@ class Active extends Api
             'createtime' => time(),
             'pay_fee' => $info['pay_fee'],
             'status' => 0,
+            'remark' => $remark,
         ];
 
         $order_id = Db::name('order')->insertGetId($data);

+ 96 - 0
application/api/controller/Order.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+use addons\epay\library\Service;
+/**
+ * 订单
+ */
+class order extends Api
+{
+    protected $noNeedLogin = [''];
+    protected $noNeedRight = ['*'];
+
+
+    public function lists()
+    {
+        $active_status = input('active_status','all');
+
+        $where = [
+            'order.user_id'=>$this->auth->id,
+            'order.status' =>1,
+        ];
+
+        if($active_status == 1){
+            $where['active.activestarttime'] = ['gt',time()];
+        }
+        if($active_status == 2){
+            $where['active.activestarttime'] = ['lt',time()];
+            $where['active.activeendtime'] = ['gt',time()];
+        }
+        if($active_status == 3){
+            $where['active.activeendtime'] = ['lt',time()];
+        }
+
+        $list = Db::name('order')->field('order.*,active.activestarttime,active.activeendtime,active.name,active.image')
+            ->join('active','order.active_id = active.id','LEFT')
+            ->where($where)->order('order.id desc')->autopage()->select();
+        $list = list_domain_image($list,['image']);
+
+        if(!empty($list)){
+            foreach($list as $key => &$item){
+                $status_text = '进行中';
+                $status = 2;
+
+                if(time() < $item['activestarttime']){
+                    $status_text = '报名中';
+                    $status = 1;
+                }
+                if(time() > $item['activeendtime']){
+                    $status_text = '已结束';
+                    $status = 3;
+                }
+
+                $item['status_text'] = $status_text;
+                $item['active_status'] = $status;
+            }
+        }
+
+        $this->success(1,$list);
+    }
+
+    public function info(){
+        $id = input('id',0);
+
+        $info = Db::name('order')->field('order.*,active.activestarttime,active.activeendtime,active.name,us.realname,school.schoolname,classes.classname')
+            ->join('active','order.active_id = active.id','LEFT')
+            ->join('user_student us','order.student_id = us.id','LEFT')
+            ->join('school','us.school_id = school.id','LEFT')
+            ->join('classes','us.classes_id = classes.id','LEFT')
+            ->where('order.id',$id)->find();
+
+
+        $status_text = '进行中';
+        $status = 2;
+
+        if(time() < $info['activestarttime']){
+            $status_text = '报名中';
+            $status = 1;
+        }
+        if(time() > $info['activeendtime']){
+            $status_text = '已结束';
+            $status = 3;
+        }
+
+        $info['status_text'] = $status_text;
+        $info['active_status'] = $status;
+
+        $this->success(1,$info);
+    }
+
+
+
+
+}