Browse Source

调通接口

lizhen_gitee 3 years ago
parent
commit
9e02fd4423

+ 87 - 0
application/api/controller/Gift.php

@@ -0,0 +1,87 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+
+/**
+ * 礼物接口
+ */
+class Gift extends Api
+{
+    protected $noNeedLogin = ['getGiftList','getGiftType'];
+    protected $noNeedRight = '*';
+    public $giftModel;
+    public $gifttypeModel;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->giftModel = new \app\common\model\Gift();
+        $this->gifttypeModel = new \app\common\model\GiftType();
+    }
+
+    /**
+     * 获取礼物列表
+     */
+    public function getGiftList() {
+        $type = $this->request->request("type"); // 礼物类型:0=活动,1=常规,2=人气,3=浪漫,4=豪华
+        $page = $this->request->request('page',1); // 分页
+        $pageNum = $this->request->request('pageNum',100); // 分页
+        // 分页搜索构建
+        $pageStart = ($page-1)*$pageNum;
+
+        // 获取基本信息
+        $where = [];
+        $type != '' && $where["type"] = $type;
+//        $giftList = $this->giftModel->where($where)->limit($pageStart,$pageNum)->select();
+        $giftList = $this->giftModel->where($where)->order("value","asc")->select();
+        $this->success("获取成功!",$giftList);
+    }
+
+    /**
+     * 获取礼物类型
+     */
+    public function getGiftType() {
+        // 获取基本信息
+        $where = [];
+        $where["is_show"] = 1;
+        $giftList = $this->gifttypeModel->field("id,name")->where($where)->order("weight","desc")->select();
+        $this->success("获取成功!",$giftList);
+    }
+
+    /**
+     * 获取我的背包礼物
+     */
+    public function getMyBackGift() {
+        $userid = $this->auth->id;
+        $page = $this->request->request('page',1); // 分页
+        $pageNum = $this->request->request('pageNum',10); // 分页
+        // 分页搜索构建
+        $pageStart = ($page-1)*$pageNum;
+        $list = \app\common\model\GiftBack::field("id,name,image,gif_image,value,sum(number) as number")
+            ->where(["user_id"=>$userid,"is_use"=>0])
+            ->limit($pageStart,$pageNum)
+            ->order('value', 'asc')
+            ->group("name")
+            ->select();
+        $this->success("获取成功!",$list);
+    }
+
+
+    /**
+     * 获取我的礼物墙
+     */
+    public function getMyGiftWall() {
+        $user_id = $this->request->request("user_id", 0);
+
+        $userid = $user_id ? $user_id : $this->auth->id;
+        $list = \app\common\model\GiftUserParty::alias('a')->join("hx_gift g", "g.id = a.gift_id", "inner")->field("gift_id,g.name,g.image,sum(number) as number")
+            ->where(["user_to_id" => $userid, 'g.type' => ['<>', 6]])
+            ->group("gift_id")
+            ->order('g.value desc')
+            ->select();
+        $this->success("获取成功!", $list);
+    }
+}

+ 2 - 2
application/common/controller/Api.php

@@ -13,7 +13,7 @@ use think\Request;
 use think\Response;
 use think\Route;
 use think\Validate;
-
+use Redis;
 /**
  * API控制器基类
  */
@@ -388,7 +388,7 @@ class Api
 
         $redis = new Redis();
         $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
+        $redis->connect($redisconfig["host"], $redisconfig["port"]);$redis->auth(123456);
         $check = $redis->exists($key);
         if ($check) {
             $redis->incr($key);

+ 1 - 0
application/common/library/Auth.php

@@ -60,6 +60,7 @@ class Auth
 
         'hometown_cityid',
         'hide_is_finishinfo',
+        'level',
     ];
 
     public function __construct($options = [])

+ 17 - 0
application/common/model/GiftType.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 模型
+ */
+class GiftType extends Model
+{
+
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+}

+ 1 - 1
application/common/model/Party.php

@@ -25,7 +25,7 @@ class Party extends Model
         // 判断派对是否存在
         $redis = new Redis();
         $redisconfig = config("redis");
-        $redis->connect($redisconfig["host"], $redisconfig["port"]);
+        $redis->connect($redisconfig["host"], $redisconfig["port"]);$redis->auth(123456);
         if(!is_array($party_id)) {
             return [];
         }

+ 17 - 0
application/common/model/UserAnchorType.php

@@ -0,0 +1,17 @@
+<?php
+
+namespace app\common\model;
+
+use think\Model;
+
+/**
+ * 模型
+ */
+class UserAnchorType extends Model
+{
+
+    // 开启自动写入时间戳字段
+    protected $autoWriteTimestamp = 'int';
+    // 定义时间戳字段名
+    protected $createTime = 'createtime';
+}