Parcourir la source

增加我的订单

15954078560 il y a 2 ans
Parent
commit
2900c1da84
1 fichiers modifiés avec 123 ajouts et 5 suppressions
  1. 123 5
      application/api/controller/User.php

+ 123 - 5
application/api/controller/User.php

@@ -1399,12 +1399,55 @@ class User extends Api
         $this->success('查询当前会员等级信息', $vip_info);
     }
 
-    //查询会员权益
-    public function vipprivilege() {
-        $list = Db::name('vip_privilege')->field('id, title, desc')
-            ->where(['vip_id' => $this->auth->maxlevel])->order('weigh desc')->select();
+    //查询所有会员
+    public function vip() {
+        //更新会员等级
+        $this->checkviplevel($this->auth->id);
+        //用户信息
+        $user = Db::name('user')->find($this->auth->id);
+        //会员信息
+        $vip_info = Db::name('vip')->find($user['growthlevel']);
+        //下一级所需成长值
+        $next_vip = Db::name('vip')->where(['id' => ['gt', $user['growthlevel']]])->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);
+        }
+        //所有会员列表
+        $list = Db::name('vip')->select();
+
+        $vip_privilege = Db::name('vip_privilege');
+        foreach ($list as $k => &$v) {
+            $v['vip_desc'] = '';  //顶部信息
+            $v['growthvalue_percentage'] = 0; //成长值百分比0-100
+            $v['experiencetime'] = ''; //体验会员到期时间
+
+            if ($v['id'] == $user['maxlevel']) {
+                $v['now_level'] = 1; //是否是当前等级 1是  0否
+                if ($user['maxlevel'] == $user['experiencelevel'] && $user['experiencetime'] > time()) {
+                    //实际有效会员ID是体验会员id时, 展示体验会员到期时间
+                    $v['experiencetime'] = date('Y-m-d', $user['experiencetime']);
+                }
+            } else {
+                $v['now_level'] = 0;
+            }
+            if ($v['id'] == $user['growthlevel']) {
+                $v = array_merge($v, $vip_info);
+            }
+
+            $v['vip_privilege'] = $vip_privilege->field('id, title, desc')
+                ->where(['vip_id' => $v['id']])->order('weigh desc')->select();
+        }
 
-        $this->success('查询会员权益', $list);
+        $this->success('查询所有会员', $list);
     }
 
     //意见反馈
@@ -1548,6 +1591,81 @@ class User extends Api
     }
 
     //邀请好友底部列表
+    public function invitebottom() {
+        $type = input('type', 0, 'intval'); //1邀请的好友 2报名的好友
+        if (!in_array($type, [1, 2])) {
+            $this->error('参数错误');
+        }
+
+        if ($type == 1) {
+            $list = Db::name('user')->field('id, avatar, nickname, invite_time')
+                ->where(['pre_user_id' => $this->auth->id])->page($this->page, $this->pagenum)->order('id desc')->select();
+        } else {
+            $invite_ids = Db::name('user')->where(['pre_user_id' => $this->auth->id])->column('id');
+            if (!$invite_ids) {
+                $this->success('报名好友列表', []);
+            }
+
+            $list = Db::name('user')->field('id, avatar, nickname, invite_time')
+                ->where(['id' => ['in', $invite_ids]])->page($this->page, $this->pagenum)->order('id desc')->select();
+        }
+
+        $list = list_domain_image($list, ['avatar']);
+        foreach ($list as &$v) {
+            $v['invite_time'] = date('Y-m-d', $v['invite_time']);
+        }
 
+        $this->success('邀请好友底部列表', $list);
+    }
+
+    //我的订单
+    public function myorder() {
+        $type = input('type', 0, 'intval'); //状态:0=待付款,1=待出行,2=已完成,3=已取消
+        if (!in_array($type, [0, 1, 2, 3])) {
+            $this->error('参数错误');
+        }
+
+        $list = Db::name('active_order')->where(['user_id' => $this->auth->id])->page($this->page, $this->pagenum)->order('id desc')->select();
+
+        $active = Db::name('active');
+        foreach ($list as &$v) {
+            $v['active'] = $active->find($v['active_id']);
+            $v['active'] = info_domain_image($v['active'], ['image']);
+        }
+
+        $this->success('我的订单', $list);
+    }
+
+    //我的订单详情
+    public function myorderinfo() {
+        $id = input('id', 0, 'intval'); //订单id
+        if (!$id) {
+            $this->error('参数缺失');
+        }
+
+        $info = Db::name('active_order')->find($id);
+        if (!$info) {
+            $this->error('数据不存在');
+        }
+
+        $info = info_domain_image($info, ['image']);
+        $info['starttime'] = date('Y-m-d H:i', $info['starttime']);
+        $info['endtime'] = date('Y-m-d H:i', $info['endtime']);
+        $info['collectiontime'] = date('Y-m-d H:i', $info['collectiontime']);
+        $info['signupendtime'] = date('Y-m-d H:i', $info['signupendtime']);
+        $info['refundendtime'] = date('Y-m-d H:i', $info['refundendtime']);
+        //查询已报名列表
+        $active_people = Db::name('active_people')->where(['active_id' => $id])->field('user_id, name, createtime')->select();
+        $user = Db::name('user');
+        foreach ($active_people as &$v) {
+            $v['avatar'] = $user->where(['id' => $v['user_id']])->value('avatar');
+            $v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
+        }
+
+        $info['active_people'] = $active_people;
+        $info['customer_service'] = config('site.customer_service') ? config('site.customer_service') : ''; //客服电话
+
+        $this->success('招标详情', $info);
+    }
 
 }