Browse Source

修改资料

15954078560 2 năm trước cách đây
mục cha
commit
251a4d0f96
2 tập tin đã thay đổi với 37 bổ sung1 xóa
  1. 8 0
      application/api/controller/Index.php
  2. 29 1
      application/api/controller/User.php

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

@@ -232,6 +232,14 @@ class Index extends Api
                     }
                     if ($this->auth->freenumber <= 0) {
                         $this->error('您的免费次数不足');
+                        break;
+                    }
+                    //检查当月是否用过免费次数
+                    $month_time = strtotime(date('Y-m-1', time()));
+                    $count = Db::name('active_people')->where(['user_id' => $this->auth->id, 'is_free' => 1, 'createtime' => ['egt', $month_time]])->count('id');
+                    if ($count) {
+                        $this->error('您当月已使用过免费次数');
+                        break;
                     }
                     if ($v['vipprice'] != 0 || $v['price'] != 0) {
                         $this->error($this->auth->realname . '价格错误');

+ 29 - 1
application/api/controller/User.php

@@ -424,7 +424,7 @@ class User extends Api
         }
         //修改用户表
         $rt = Db::name('user')->where(['id' => $this->auth->id])->setField($data);
-        if (!$rt) {
+        if ($rt === false) {
             $this->error('修改失败');
         }
 
@@ -1348,4 +1348,32 @@ class User extends Api
 
         $this->success('消息列表', $list);
     }
+
+    //查询当前会员等级信息
+    public function uservip() {
+        //更新会员等级
+        $this->checkviplevel($this->auth->id);
+        //用户信息
+        $user = Db::name('user')->find($this->auth->id);
+        //会员信息
+        $vip_info = Db::name('vip')->find($user['maxlevel']);
+        //下一级所需成长值
+        $next_vip = Db::name('vip')->where(['id' => ['gt', $user['maxlevel']]])->find();
+        if (!$next_vip) {
+            //顶部信息
+            $vip_info['vip_desc'] = '已是最高会员';
+            //成长值百分比0-100
+            $vip_info['growthvalue_percentage'] = 100;
+        } else {
+            //顶部信息
+            $need_growthvalue = $next_vip['growthvalue'] - $user['growthvalue'];
+            $vip_info['vip_desc'] = $vip_info['title'] . '还需' . $need_growthvalue . '成长值成为' . $next_vip['title'];
+            //成长值百分比0-100
+            $vip_info['growthvalue_percentage'] = ceil($user['growthvalue'] / $next_vip['growthvalue'] * 100);
+        }
+        //体验会员到期时间
+        $vip_info['experiencetime'] = $user['experiencetime'] > time() ? date('Y-m-d', $user['experiencetime']) : '';
+
+        $this->success('查询当前会员等级信息', $vip_info);
+    }
 }