浏览代码

优惠券 意见反馈

15954078560 2 年之前
父节点
当前提交
8fda84b55b
共有 2 个文件被更改,包括 68 次插入1 次删除
  1. 1 1
      application/api/controller/Index.php
  2. 67 0
      application/api/controller/User.php

+ 1 - 1
application/api/controller/Index.php

@@ -134,7 +134,7 @@ class Index extends Api
         }
         }
 
 
         $where['user_id'] = $this->auth->id;
         $where['user_id'] = $this->auth->id;
-        $where['endtime'] = ['gt', time()];
+        $where['endtime'] = ['egt', time()];
         $where['status'] = 0;
         $where['status'] = 0;
         $map = 'type = 1 or (type = 2 and minmoney <= '.$price.')';
         $map = 'type = 1 or (type = 2 and minmoney <= '.$price.')';
 
 

+ 67 - 0
application/api/controller/User.php

@@ -328,6 +328,7 @@ class User extends Api
         $data['maxlevel'] = $user['maxlevel']; //实际有效会员ID
         $data['maxlevel'] = $user['maxlevel']; //实际有效会员ID
         $data['viplevel'] = Db::name('vip')->where(['id' => $user['maxlevel']])->value('level'); //会员等级
         $data['viplevel'] = Db::name('vip')->where(['id' => $user['maxlevel']])->value('level'); //会员等级
         $data['active_count'] = Db::name('active_order')->where(['user_id' => $this->auth->id, 'status' => 2])->count('id'); //完成活动数量
         $data['active_count'] = Db::name('active_order')->where(['user_id' => $this->auth->id, 'status' => 2])->count('id'); //完成活动数量
+        $data['freenumber'] = $user['freenumber']; //会员免费参加活动次数
 
 
         $this->success('会员信息', $data);
         $this->success('会员信息', $data);
     }
     }
@@ -1402,4 +1403,70 @@ class User extends Api
 
 
         $this->success('查询会员权益', $list);
         $this->success('查询会员权益', $list);
     }
     }
+
+    //意见反馈
+    public function feedback() {
+        $content = input('content', '', 'trim'); //问题描述
+        $images = input('images', '', 'trim'); //反馈图片,最多9张用,拼接
+        $mobile = input('mobile', '', 'trim'); //联系电话
+
+        $data = [];
+
+        if (!$content) {
+            $this->error('请输入情况说明');
+        }
+        if (iconv_strlen($content, 'utf-8') > 3000) {
+            $this->error('情况说明最多3000字');
+        }
+        if ($images) {
+            $image_arr = explode(',', $images);
+            if (count($image_arr) > 9) {
+                $this->error('附件照片最多9张');
+            }
+
+            $data['images'] = $images;
+        }
+        if (!is_mobile($mobile)) {
+            $this->error('请输入正确联系电话');
+        }
+
+        $data['user_id'] = $this->auth->id;
+        $data['content'] = $content;
+        $data['images'] = $images;
+        $data['mobile'] = $mobile;
+        $data['createtime'] = time();
+
+        $rs = Db::name('feedback')->insertGetId($data);
+        if (!$rs) {
+            $this->error('反馈失败');
+        }
+
+        $this->success('反馈成功');
+    }
+
+    //我的优惠券
+    public function mycoupon() {
+        $type = input('type', 0, 'intval'); //类型:1未使用 2已使用 3已过期
+        if (!in_array($type, [1, 2, 3])) {
+            $this->error('参数错误');
+        }
+
+        $where['user_id'] = $this->auth->id;
+        if ($type == 1) {
+            $where['endtime'] = ['egt', time()];
+            $where['status'] = 0;
+        } elseif ($type == 2) {
+            $where['status'] = 1;
+        } elseif ($type == 3) {
+            $where['endtime'] = ['lt', time()];
+            $where['status'] = 0;
+        }
+
+        $list = Db::name('user_coupon')->field('id, title, desc, type, money, minmoney, endtime')->where($where)->select();
+        foreach ($list as &$v) {
+            $v['endtime'] = date('Y-m-d', $v['endtime']);
+        }
+
+        $this->success('我的优惠券', $list);
+    }
 }
 }