[ 'only' => ['getNoticeInfo'] ] ]; /** * 轮播图 */ public function rotationChart() { $data = Request::param(); $limit = $data['limit'] ?? 11; $RotationChart = new RotationChart(); $list = $RotationChart ->field('image,url') ->where('status',1) ->order('sort asc,create_time desc') ->paginate($limit); $data = $list->toArray()['data']; foreach ($data as &$item) { $item['image'] = get_image_url($item['image']); if ($item['url']) $item['url'] = get_jump_url($item['url']); } return $this->renderSuccess('数据返回成功',[ 'list' => $data, 'total' => $list->total() ]); } /** * 获取首页中间记录 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function awardRecords() { $data = Request::param(); $limit = $data['limit'] ?? 10; $records = new AwardsRecords(); $list = $records->field('user_id,awards_amount')->order('create_time desc')->paginate($limit); $data = $list->toArray()['data']; foreach ($data as &$item) { $user = UserModel::field('phone')->find($item['user_id']); $item['user_id'] = substr($item['user_id'],0,2)."XX"; $item['phone'] = format_phone_number($user['phone']); $item['awards_amount'] = number_format($item['awards_amount']); } return $this->renderSuccess('数据返回成功',[ 'list' => $data, 'total' => $list->total() ]); } /** * 首页专区列表 * @return array */ public function zoneList() { return $this->renderSuccess('数据返回成功',ZoneModel::getList()); } /** * 返回公告 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getNotice() { $Notice = Notice::where('status',1)->order('create_time','desc')->find(); return $this->renderSuccess('数据返回成功',!empty($Notice) ? ['id' => $Notice->id, 'title' => $Notice->title] : []); } /** * 公告详情 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getNoticeInfo() { $param = Request::param(); try { validate()->rule(['id|公告id' => 'require|number'])->check($param); $Notice = Notice::where('id',$param['id'])->order('sort asc,id desc')->find(); $create_time = $Notice->create_time; if (!empty($Notice->update_time)) $create_time = $Notice->update_time; return $this->renderSuccess('数据返回成功',[ 'title' => $Notice->title, 'create_time' => date("Y.m.d H:i:s",strtotime($create_time)), 'content' => $Notice->content ]); } catch (ValidateException $validateException) { return $this->renderError($validateException->getMessage()); } } /** * temp controller 临时 */ public function autoTest() { $param = Request::param(); try { validate()->rule([ 'limit|limit' => 'number|max:1000000', 'user_id|用户ID' => 'number|length:1,10', 'zone_goods_id|zone_goods_id' => 'number|length:1,10' ])->check($param); $limit = $param['limit'] ?? 500; $user_id = $param['user_id'] ?? 1; $zone_goods_id = $param['zone_goods_id'] ?? 1; $result = \app\logic\Zone::auto($user_id,$zone_goods_id,$limit); if ($result != '完成') throw new ValidateException($result); return $this->renderSuccess($result); } catch (ValidateException $validateException) { return $this->renderError($validateException->getMessage()); } } }