|
@@ -4,6 +4,7 @@ namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
use think\Db;
|
|
|
+use think\Exception;
|
|
|
|
|
|
/**
|
|
|
* 装扮商城接口
|
|
@@ -141,45 +142,49 @@ class Attire extends Api
|
|
|
* 获取我的背包装饰列表
|
|
|
*/
|
|
|
public function getBackAttireList() {
|
|
|
- $page = $this->request->request('page',1); // 分页
|
|
|
- $pageNum = $this->request->request('pageNum',10); // 分页
|
|
|
- $type = $this->request->request("type"); // 装扮类型:1=座驾,2=头饰,3=聊天气泡,4=消息尾灯
|
|
|
- // 分页搜索构建
|
|
|
- $pageStart = ($page-1)*$pageNum;
|
|
|
- global $where;
|
|
|
- $where = [];$whereOr=[];
|
|
|
- $where["user_id"] = $this->auth->id;
|
|
|
- $type && $where["type"] = $type;
|
|
|
+ try {
|
|
|
+ $page = $this->request->request('page',1); // 分页
|
|
|
+ $pageNum = $this->request->request('pageNum',10); // 分页
|
|
|
+ $type = $this->request->request("type"); // 装扮类型:1=座驾,2=头饰,3=聊天气泡,4=消息尾灯
|
|
|
+ // 分页搜索构建
|
|
|
+ $pageStart = ($page-1)*$pageNum;
|
|
|
+ global $where;
|
|
|
+ $where = [];$whereOr=[];
|
|
|
+ $where["user_id"] = $this->auth->id;
|
|
|
+ $type && $where["type"] = $type;
|
|
|
|
|
|
- $whereOr["is_use"] = "0";
|
|
|
- $whereOr["duetime"] = ["gt",time()];
|
|
|
- $list = $this->attirebackModel
|
|
|
- ->field("id,type,file_image,gif_image,attire_name as title,limit_day,duetime,is_use,is_using")
|
|
|
- ->where(function ($query) {
|
|
|
- global $where;
|
|
|
- $query->where($where);
|
|
|
- })
|
|
|
- ->where(function ($query) {
|
|
|
- $query->whereOr(["is_use"=>0,"duetime"=>["gt",time()]]);
|
|
|
- })
|
|
|
- ->limit($pageStart,$pageNum)
|
|
|
- ->select();
|
|
|
+ $whereOr["is_use"] = "0";
|
|
|
+ $whereOr["duetime"] = ["gt",time()];
|
|
|
+ $list = $this->attirebackModel
|
|
|
+ ->field("id,type,file_image,gif_image,attire_name as title,limit_day,duetime,is_use,is_using")
|
|
|
+ ->where(function ($query) {
|
|
|
+ global $where;
|
|
|
+ $query->where($where);
|
|
|
+ })
|
|
|
+ ->where(function ($query) {
|
|
|
+ $query->whereOr(["is_use"=>0,"duetime"=>["gt",time()]]);
|
|
|
+ })
|
|
|
+ ->limit($pageStart,$pageNum)
|
|
|
+ ->select();
|
|
|
|
|
|
- if(!$list) {
|
|
|
- $this->success("背包空空如也!");
|
|
|
- }
|
|
|
-
|
|
|
- foreach($list as $k => $v) {
|
|
|
- // 有效期/剩余天数
|
|
|
- if($v["is_use"] == 1 && $v["duetime"]>time()) { // 正在使用,未过期
|
|
|
- $dtime = "剩余".ceil(($v["duetime"]-time())/86400)."天";
|
|
|
+ if(!$list) {
|
|
|
+ $this->success("背包空空如也!");
|
|
|
}
|
|
|
- if($v["is_use"] == 0) {
|
|
|
- $dtime = "有效期".$v["limit_day"]."天";
|
|
|
+
|
|
|
+ foreach($list as $k => $v) {
|
|
|
+ // 有效期/剩余天数
|
|
|
+ if($v["is_use"] == 1 && $v["duetime"]>time()) { // 正在使用,未过期
|
|
|
+ $dtime = "剩余".ceil(($v["duetime"]-time())/86400)."天";
|
|
|
+ }
|
|
|
+ if($v["is_use"] == 0) {
|
|
|
+ $dtime = "有效期".$v["limit_day"]."天";
|
|
|
+ }
|
|
|
+ $list[$k]["dtime"] = $dtime;
|
|
|
}
|
|
|
- $list[$k]["dtime"] = $dtime;
|
|
|
+ $this->success("获取成功!",$list);
|
|
|
+ } catch (Exception $e) {echo '<pre>';var_dump($e->getMessage());exit;
|
|
|
+ $this->error($e->getMessage());
|
|
|
}
|
|
|
- $this->success("获取成功!",$list);
|
|
|
}
|
|
|
/**
|
|
|
* 使用并装上装饰
|