浏览代码

增加私人订制

15954078560 3 年之前
父节点
当前提交
2b83d06b0b
共有 1 个文件被更改,包括 73 次插入2 次删除
  1. 73 2
      application/api/controller/Index.php

+ 73 - 2
application/api/controller/Index.php

@@ -13,7 +13,7 @@ use wxpay;
  */
 class Index extends Api
 {
-    protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype'];
+    protected $noNeedLogin = ['banner', 'activelist', 'personaltype', 'personalactivetype', 'car', 'leader', 'personaldirection'];
     protected $noNeedRight = ['*'];
 
     /**
@@ -373,7 +373,7 @@ class Index extends Api
             $where['title|desc|remark|collectionplace|leader'] = ['like', '%'.$keyword.'%'];
         }
 
-        $list = Db::name('active')->field('id, type, title, desc, remark, image, price, maxperson, currentperson')
+        $list = Db::name('active')->field('id, type, title, desc, remark, image, price, maxperson, currentperson, status')
             ->where($where)->page($this->page, $this->pagenum)->order('createtime', 'desc')->select();
 
         foreach ($list as &$v) {
@@ -756,6 +756,12 @@ class Index extends Api
 
         //开始事务
         Db::startTrans();
+        //修改活动表数据
+        $active_rs = Db::name('active')->where(['id' => $id, 'currentperson' => $info['currentperson']])->setField('currentperson', $info['currentperson'] + count($active_people));
+        if (!$active_rs) {
+            Db::rollback();
+            $this->error('网络延迟,请稍后再试');
+        }
         //添加订单
         $rs = Db::name('active_order')->insertGetId($order_data);
         if (!$rs) {
@@ -864,8 +870,73 @@ class Index extends Api
         return $list;
     }
 
+    //车辆类型
+    public function car() {
+        $list = Db::name('car')->field('id, name, desc')->order('weigh', 'desc')->select();
+
+        $this->success('车辆类型', $list);
+    }
+
+    //领队
+    public function leader() {
+        $list = Db::name('leader')->field('id, name')->order('weigh', 'desc')->select();
+
+        $this->success('领队', $list);
+    }
+    
+    //私人订制出行方向
+    public function personaldirection() {
+        $list = Db::name('personal_direction')->field('id, name')->order('weigh', 'desc')->select();
+
+        $this->success('私人订制出行方向', $list);
+    }
+
     //私人订制
     public function personalactive() {
+        $type = input('type', '', 'trim'); //类型
+        $number = input('number', 0, 'intval'); //出行人数
+        $traveltime = input('traveltime', '', 'strtotime'); //出行时间
+        $traveday = input('traveday', 0, 'intval'); //出行天数
+        $activetype = input('activetype', '', 'trim'); //活动类型
+        $car = input('car', '', 'trim'); //车辆
+        $leader = input('leader', '', 'trim'); //领队
+        $travedirection = input('travedirection', '', 'trim'); //出行方向
+        $freerange = input('freerange', '', 'trim'); //空闲时段
+        $remark = input('remark', '', 'trim'); //留言
+
+        if (!$type || iconv_strlen($type, 'utf-8') > 50) {
+            $this->error('请选择类型');
+        }
+        if ($number <= 0) {
+            $this->error('请填写出行人数');
+        }
+        if ($traveltime < time()) {
+            $this->error('请选择正确出行时间');
+        }
+        if ($traveday <= 0) {
+            $this->error('请填写正确出行天数');
+        }
+        if (!$activetype || iconv_strlen($activetype, 'utf-8') > 50) {
+            $this->error('请选择活动类型');
+        }
+        if ($car && iconv_strlen($car, 'utf-8') > 50) {
+            $this->error('请选择车辆');
+        }
+        if ($leader && iconv_strlen($leader, 'utf-8') > 50) {
+            $this->error('请选择领队');
+        }
+        if (!$travedirection || iconv_strlen($travedirection, 'utf-8') > 50) {
+            $this->error('请选择出行方向');
+        }
+        if (!$freerange || iconv_strlen($freerange, 'utf-8') > 50) {
+            $this->error('请选择空闲时段');
+        }
+        if (iconv_strlen($remark, 'utf-8') > 500) {
+            $this->error('留言最多500字');
+        }
+
+
+
         
     }