| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 | 
							- <?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.images')
 
-             ->join('active','order.active_id = active.id','LEFT')
 
-             ->where($where)->order('order.id desc')->autopage()->select();
 
-         $list = list_domain_image($list,['images']);
 
-         if(!empty($list)){
 
-             foreach($list as $key => &$item){
 
-                 //第一个图
 
-                 $item['image'] = isset($item['images'][0]) ? $item['images'][0] : '';
 
-                 //状态
 
-                 $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,grade.gradename,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('grade','us.grade_id = grade.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);
 
-     }
 
- }
 
 
  |