Przeglądaj źródła

完善报名接口, 完善后台审核退款 , 添加编辑活动

15954078560 2 lat temu
rodzic
commit
fef1fdcc0a

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

@@ -69,6 +69,12 @@ class Active extends Backend
                 if ($params['maxperson'] < 1) {
                     $this->error('请输入正确限报人数');
                 }
+                if ($params['minperson'] < 1) {
+                    $this->error('请输入正确最低成行人数');
+                }
+                if ($params['minperson'] > $params['maxperson']) {
+                    $this->error('最低成行人数不能大于限报人数');
+                }
                 if (strtotime($params['signupendtime']) < time()) {
                     $this->error('报名截止时间不能小于当前时间');
                 }

+ 5 - 1
application/admin/controller/Activerefund.php

@@ -126,7 +126,11 @@ class Activerefund extends Backend
                         if ($params['status'] == 1) {
                             //同意退款
                             //修改活动订单人数
-                            $active_rs = Db::name('active')->where(['id' => $row['active_id'], 'status' => $active_info['status'], 'currentperson' => $active_info['currentperson']])->setField('currentperson', $active_info['currentperson'] - $row['number']);
+                            $active_data['currentperson'] = $active_info['currentperson'] - $row['number'];
+                            if ($active_info['currentperson'] - $row['number'] < $active_info['minperson'] && $active_info['status'] == 1) {
+                                $active_data['status'] = 0;
+                            }
+                            $active_rs = Db::name('active')->where(['id' => $row['active_id'], 'status' => $active_info['status'], 'currentperson' => $active_info['currentperson']])->setField($active_data);
                             if (!$active_rs) {
                                 Db::rollback();
                                 return ['code' => 0, 'msg' => '操作失败'];

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

@@ -92,6 +92,12 @@
             <input id="c-maxperson" data-rule="required" class="form-control" name="row[maxperson]" type="number" value="0">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('最低成行人数')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-minperson" data-rule="required" class="form-control" name="row[minperson]" type="number" value="0">
+        </div>
+    </div>
     <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Currentperson')}:</label>
         <div class="col-xs-12 col-sm-8">

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

@@ -92,6 +92,12 @@
             <input id="c-maxperson" data-rule="required" readonly class="form-control" name="row[maxperson]" type="number" value="{$row.maxperson|htmlentities}">
         </div>
     </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">{:__('最低成行人数')}:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-minperson" data-rule="required" readonly class="form-control" name="row[minperson]" type="number" value="{$row.minperson|htmlentities}">
+        </div>
+    </div>
     <!--<div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('Currentperson')}:</label>
         <div class="col-xs-12 col-sm-8">

+ 20 - 3
application/api/controller/Index.php

@@ -103,7 +103,13 @@ class Index extends Api
         if (!$info) {
             $this->error('活动不存在');
         }
-        if ($info['signupendtime'] < time() || $info['status'] != 0) {
+        if ($info['status'] == 2) {
+            $this->error('活动已经结束');
+        }
+        if ($info['status'] == 3) {
+            $this->error('活动已经取消');
+        }
+        if ($info['signupendtime'] < time()) {
             $this->error('活动报名已经截止');
         }
         if ($info['currentperson'] >= $info['maxperson']) {
@@ -177,7 +183,13 @@ class Index extends Api
         if (!$info) {
             $this->error('活动不存在');
         }
-        if ($info['signupendtime'] < time() || $info['status'] != 0) {
+        if ($info['status'] == 2) {
+            $this->error('活动已经结束');
+        }
+        if ($info['status'] == 3) {
+            $this->error('活动已经取消');
+        }
+        if ($info['signupendtime'] < time()) {
             $this->error('活动报名已经截止');
         }
         if ($info['currentperson'] >= $info['maxperson']) {
@@ -468,11 +480,16 @@ class Index extends Api
         $order_data['number'] = count($active_people_arr);
         $order_data['status'] = $paytype == 1 ? 0 : 1;
         $order_data['createtime'] = time();
+        //构建活动信息
+        $active_data['currentperson'] = $info['currentperson'] + count($active_people_arr);
+        if ($info['currentperson'] + count($active_people_arr) >= $info['minperson'] && $info['status'] == 0) {
+            $active_data['status'] = 1;
+        }
 
         //开始事务
         Db::startTrans();
         //修改活动表数据
-        $active_rs = Db::name('active')->where(['id' => $id, 'status' => 0,'currentperson' => $info['currentperson']])->setField('currentperson', $info['currentperson'] + count($active_people_arr));
+        $active_rs = Db::name('active')->where(['id' => $id, 'status' => $info['status'],'currentperson' => $info['currentperson']])->setField($active_data);
         if (!$active_rs) {
             Db::rollback();
             $this->error('网络延迟,请稍后再试');

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

@@ -41,6 +41,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'insurance', title: __('Insurance'), operate: 'LIKE'},
                         {field: 'leader', title: __('Leader'), operate: 'LIKE'},
                         {field: 'maxperson', title: __('Maxperson')},
+                        {field: 'minperson', title: __('最低成行人数')},
                         {field: 'currentperson', title: __('Currentperson')},
                         {field: 'signupendtime', title: __('Signupendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'refundendtime', title: __('Refundendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},