|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|