فهرست منبع

增加二期功能

15954078560 2 سال پیش
والد
کامیت
618aaaa30a

+ 39 - 0
application/admin/controller/Active.php

@@ -28,6 +28,9 @@ class Active extends Backend
         $this->view->assign("isFreeList", $this->model->getIsFreeList());
         $this->view->assign("isOverlyingList", $this->model->getIsOverlyingList());
         $this->view->assign("statusList", $this->model->getStatusList());
+        $this->view->assign("showstatusList", $this->model->getShowstatusList());
+        $this->view->assign("isAutoshowList", $this->model->getIsAutoshowList());
+        $this->view->assign("isBannerList", $this->model->getIsBannerList());
     }
 
 
@@ -107,6 +110,9 @@ class Active extends Backend
                         $this->model->validateFailException(true)->validate($validate);
                     }
                     $result = $this->model->allowField(true)->save($params);
+
+                    $id = $this->model->id;
+
                     Db::commit();
                 } catch (ValidateException $e) {
                     Db::rollback();
@@ -119,6 +125,15 @@ class Active extends Backend
                     $this->error($e->getMessage());
                 }
                 if ($result !== false) {
+                    if ($params['is_banner'] == 1) {
+                        //在轮播图显示
+                        $banner_data['title'] = $params['title'];
+                        $banner_data['image'] = $params['image'];
+                        $banner_data['url'] = '/pages/home/detail?id='.$id;
+                        $banner_data['createtime'] = time();
+
+                        Db::name('banner')->insertGetId($banner_data);
+                    }
                     $this->success();
                 } else {
                     $this->error(__('No rows were inserted'));
@@ -151,9 +166,33 @@ class Active extends Backend
                 if ($row['status'] == 2 || $row['status'] == 3) {
                     $this->error('活动已经结束或取消');
                 }
+                if ($params['showstatus'] == 0) { //下架
+                    $count = Db::name('active_order')->where(['active_id' => $ids, 'status' => ['neq', 3]])->count('id');
+                    if ($count) {
+                        $this->error('已经有人报名,不能下架');
+                    }
+                }
 
                 $result = false;
                 Db::startTrans();
+
+                //是否在轮播图显示
+                if ($params['is_banner'] == 0) {
+                    //不显示
+                    Db::name('banner')->where(['title' => $row['title']])->delete();
+                } elseif ($params['is_banner'] == 1) {
+                    //显示
+                    $banner_count = Db::name('banner')->where(['title' => $row['title']])->count('id');
+                    if (!$banner_count) {
+                        $banner_data['title'] = $row['title'];
+                        $banner_data['image'] = $row['image'];
+                        $banner_data['url'] = '/pages/home/detail?id=' . $ids;
+                        $banner_data['createtime'] = time();
+
+                        Db::name('banner')->insertGetId($banner_data);
+                    }
+                }
+
                 try {
                     if (isset($params['status'])) {
                         if ($params['status'] == 2) {

+ 10 - 0
application/admin/lang/zh-cn/active.php

@@ -38,6 +38,16 @@ return [
     'Status 1'         => '已成行',
     'Status 2'         => '已结束',
     'Status 3'         => '已取消',
+    'Showstatus'       => '上架状态',
+    'Showstatus 0'     => '下架',
+    'Showstatus 1'     => '上架',
+    'Is_autoshow'      => '是否自动上架',
+    'Is_autoshow 0'    => '否',
+    'Is_autoshow 1'    => '是',
+    'Showtime'         => '自动上架时间',
+    'Is_banner'        => '是否在轮播图显示',
+    'Is_banner 0'      => '不显示',
+    'Is_banner 1'      => '显示',
     'Weigh'            => '权重排序',
     'Createtime'       => '创建时间',
     'Updatetime'       => '更新时间'

+ 50 - 0
application/admin/model/Active.php

@@ -31,6 +31,10 @@ class Active extends Model
         'collectiontime_text',
         'signupendtime_text',
         'refundendtime_text',
+        'showtime_text',
+        'is_autoshow_text',
+        'showtime_text',
+        'is_banner_text',
         'is_free_text',
         'is_overlying_text',
         'status_text'
@@ -66,6 +70,21 @@ class Active extends Model
         return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => __('Status 3')];
     }
 
+    public function getShowstatusList()
+    {
+        return ['0' => __('Showstatus 0'), '1' => __('Showstatus 1')];
+    }
+
+    public function getIsAutoshowList()
+    {
+        return ['0' => __('Is_autoshow 0'), '1' => __('Is_autoshow 1')];
+    }
+
+    public function getIsBannerList()
+    {
+        return ['0' => __('Is_banner 0'), '1' => __('Is_banner 1')];
+    }
+
 
     public function getTypeTextAttr($value, $data)
     {
@@ -133,6 +152,33 @@ class Active extends Model
         return isset($list[$value]) ? $list[$value] : '';
     }
 
+    public function getShowstatusTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['showstatus']) ? $data['showstatus'] : '');
+        $list = $this->getShowstatuslist();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+    public function getIsAutoshowTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['is_autoshow']) ? $data['is_autoshow'] : '');
+        $list = $this->getIsAutoshowList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
+    public function getShowtimeTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['showtime']) ? $data['showtime'] : '');
+        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
+    }
+
+    public function getIsBannerTextAttr($value, $data)
+    {
+        $value = $value ? $value : (isset($data['is_banner']) ? $data['is_banner'] : '');
+        $list = $this->getIsBannerList();
+        return isset($list[$value]) ? $list[$value] : '';
+    }
+
     protected function setStarttimeAttr($value)
     {
         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
@@ -158,5 +204,9 @@ class Active extends Model
         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
     }
 
+    protected function setShowtimeAttr($value)
+    {
+        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
+    }
 
 }

+ 42 - 0
application/admin/view/active/add.html

@@ -195,6 +195,48 @@
         </div>
     </div>-->
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Showstatus')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <div class="radio">
+                {foreach name="showstatusList" item="vo"}
+                <label for="row[showstatus]-{$key}"><input id="row[showstatus]-{$key}" name="row[showstatus]" name="key" type="radio" value="{$key}" value="0" {in}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_autoshow')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <div class="radio">
+                {foreach name="isAutoshowList" item="vo"}
+                <label for="row[is_autoshow]-{$key}"><input id="row[is_autoshow]-{$key}" name="row[is_autoshow]" name="key" type="radio" value="{$key}" value="0" {in}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Showtime')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-rule="required" data-use-current="true" id="c-showtime" name="row[showtime]" type="text" value="{:date('Y-m-d H:i:s')}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_banner')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <div class="radio">
+                {foreach name="isBannerList" item="vo"}
+                <label for="row[is_banner]-{$key}"><input id="row[is_banner]-{$key}" name="row[is_banner]" name="key" type="radio" value="{$key}" value="0" {in}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="0">

+ 43 - 0
application/admin/view/active/edit.html

@@ -197,6 +197,49 @@
         </div>
     </div>
     <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Showstatus')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <div class="radio">
+                {foreach name="showstatusList" item="vo"}
+                <label for="row[showstatus]-{$key}"><input id="row[showstatus]-{$key}" name="row[showstatus]" name="key" type="radio" value="{$key}" value="$row.showstatus" {in}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_autoshow')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <div class="radio">
+                {foreach name="isAutoshowList" item="vo"}
+                <label for="row[is_autoshow]-{$key}"><input id="row[is_autoshow]-{$key}" name="row[is_autoshow]" name="key" type="radio" value="{$key}" value="$row.is_autoshow" {in}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Showtime')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-rule="required" data-use-current="true" id="c-showtime" name="row[showtime]" type="text" value="{:$row.showtime?datetime($row.showtime):''}">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('Is_banner')}:</label>
+        <div class="col-xs-12 col-sm-8">
+
+            <div class="radio">
+                {foreach name="isBannerList" item="vo"}
+                <label for="row[is_banner]-{$key}"><input id="row[is_banner]-{$key}" name="row[is_banner]" name="key" type="radio" value="{$key}" value="$row.is_banner" {in}checked{/in} /> {$vo}</label>
+                {/foreach}
+            </div>
+
+        </div>
+    </div>
+
+    <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
         <div class="col-xs-12 col-sm-8">
             <input id="c-weigh" data-rule="required" class="form-control" name="row[weigh]" type="number" value="{$row.weigh|htmlentities}">

+ 29 - 0
application/api/controller/Index.php

@@ -42,6 +42,7 @@ class Index extends Api
 
 //        $where['signupendtime'] = ['gt', time()];
         $where['status'] = ['neq', 3];
+        $where['showstatus'] = 1;
         if ($type) {
             $where['type'] = $type;
         }
@@ -115,6 +116,9 @@ class Index extends Api
         if ($info['status'] == 3) {
             $this->error('活动已经取消');
         }
+        if ($info['showstatus'] != 1) {
+            $this->error('活动暂时不能报名');
+        }
         if ($info['signupendtime'] < time()) {
             $this->error('活动报名已经截止');
         }
@@ -199,6 +203,9 @@ class Index extends Api
         if ($info['status'] == 3) {
             $this->error('活动已经取消');
         }
+        if ($info['showstatus'] != 1) {
+            $this->error('活动暂时不能报名');
+        }
         if ($info['signupendtime'] < time()) {
             $this->error('活动报名已经截止');
         }
@@ -949,6 +956,9 @@ class Index extends Api
         if ($info['status'] == 3) {
             $this->error('活动已取消');
         }
+        if ($info['showstatus'] != 1) {
+            $this->error('活动暂时不能报名');
+        }
 
         $access_token = Cache::get('access_token');
         if (!$access_token) {
@@ -1080,6 +1090,9 @@ class Index extends Api
         if ($info['status'] == 3) {
             $this->error('活动已取消');
         }
+        if ($info['showstatus'] != 1) {
+            $this->error('活动暂时不能报名');
+        }
 
         $data = [
             [
@@ -1167,4 +1180,20 @@ class Index extends Api
         $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
         $this->success('', $imgurl);
     }
+    
+    //查询帮报名过的人员信息
+    public function getpeopleinfo() {
+        $name = input('name', '', 'trim'); //名称
+        if (!$name) {
+            $this->success('信息', (object)[]);
+        }
+
+        $info = Db::name('active_people')->field('name, idcard, mobile, emergencycontact, contactmobile')->where(['user_id' => $this->auth->id, 'name' => $name])->find();
+
+        if (!$info) {
+            $info = (object)[];
+        }
+
+        $this->success('信息', $info);
+    }
 }

+ 27 - 0
application/api/controller/Notify.php

@@ -640,4 +640,31 @@ class Notify extends Api
         echo 'wan bi';
         die;
     }
+
+    //自动上架活动
+    public function showactive() {
+        set_time_limit(0);
+
+        $time = time();
+        $where = array(
+            'showstatus' => 0,
+            'is_autoshow' => 1,
+            'showtime' => ['elt', $time]
+        );
+
+        $active = Db::name('active');
+        $list = $active->where($where)->limit(200)->select();
+
+        if (!$list) {
+            echo 'mei shu ju';
+            die;
+        }
+
+        foreach ($list as &$v) {
+            $active->where(['id' => $v['id'], 'showstatus' => 0])->setField(['showstatus' => 1]);
+        }
+
+        echo 'wan bi';
+        die;
+    }
 }

+ 4 - 0
public/assets/js/backend/active.js

@@ -51,6 +51,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'minage', title: __('Minage')},
                         {field: 'maxage', title: __('Maxage')},
                         {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3')}, formatter: Table.api.formatter.status},
+                        {field: 'showstatus', title: __('Showstatus'), searchList: {"0":__('Showstatus 0'),"1":__('Showstatus 1')}, formatter: Table.api.formatter.status},
+                        {field: 'is_autoshow', title: __('Is_autoshow'), searchList: {"0":__('Is_autoshow 0'),"1":__('Is_autoshow 1')}, formatter: Table.api.formatter.status},
+                        {field: 'showtime', title: __('Showtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
+                        {field: 'is_banner', title: __('Is_banner'), searchList: {"0":__('Is_banner 0'),"1":__('Is_banner 1')}, formatter: Table.api.formatter.status},
                         {field: 'weigh', title: __('Weigh'), operate: false},
                         {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},