|
|
@@ -3,10 +3,12 @@ namespace app\api\controller\board;
|
|
|
|
|
|
use crmeb\services\UtilService;
|
|
|
use app\models\board\UserBoard;
|
|
|
+use \think\facade\Config;
|
|
|
+use crmeb\utils\Redis;
|
|
|
/**
|
|
|
* 协议见文档 docs/board.md, 协议可能变更
|
|
|
*
|
|
|
- * 使用 UserBoardModel, 数据表为 eb_user_reward_order
|
|
|
+ * 使用 UserBoard Model, 数据表为 store_order_cart_info
|
|
|
*
|
|
|
*
|
|
|
* Class UserBoardController
|
|
|
@@ -14,16 +16,15 @@ use app\models\board\UserBoard;
|
|
|
*/
|
|
|
class UserBoardController {
|
|
|
protected static $DAILY_WIN_MONEY = 1;
|
|
|
+ public static $RDS_BOARD_KEY = 'tmp:board';
|
|
|
|
|
|
public function boards() {
|
|
|
[$type,] = UtilService::getMore([
|
|
|
['type', 1],
|
|
|
], null, true);
|
|
|
-
|
|
|
- switch ($type) {
|
|
|
- case UserBoardController::$DAILY_WIN_MONEY:
|
|
|
- return app('json')->successful('ok', $this->daily_win_money());
|
|
|
- }
|
|
|
+ $s = $this->get_cached_board();
|
|
|
+ $board = json_decode($s, true);
|
|
|
+ return app('json')->successful('ok', $board);
|
|
|
}
|
|
|
|
|
|
protected function daily_win_money() {
|
|
|
@@ -34,6 +35,18 @@ class UserBoardController {
|
|
|
$row['border'] = 0;
|
|
|
$row['vip'] = 0;
|
|
|
}
|
|
|
- return $res;
|
|
|
+ return array(
|
|
|
+ 'banner' => Config::get('app.leader_board_banner'),
|
|
|
+ 'name' => "日榜",
|
|
|
+ 'board' => $res,
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ public function cache_board() {
|
|
|
+ Redis::set(self::$RDS_BOARD_KEY, json_encode($this->daily_win_money()));
|
|
|
+ }
|
|
|
+
|
|
|
+ protected function get_cached_board() {
|
|
|
+ return Redis::get(self::$RDS_BOARD_KEY);
|
|
|
}
|
|
|
}
|