joe il y a 4 ans
Parent
commit
a7a1497c48

+ 1 - 21
.env

@@ -1,21 +1 @@
-APP_DEBUG = true
-
-[APP]
-DEFAULT_TIMEZONE = Asia/Shanghai
-
-[DATABASE]
-TYPE = mysql
-HOSTNAME = 127.0.0.1
-DATABASE = twmp
-PREFIX = tw_
-USERNAME = twmp
-PASSWORD = twmp
-HOSTPORT = 3306
-CHARSET = utf8
-DEBUG = true
-
-[LANG]
-default_lang = zh-cn
-
-[FILESYSTEM]
-FILESIZE = 2097152
+APP_DEBUG = true

[APP]
DEFAULT_TIMEZONE = Asia/Shanghai

[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
HOSTPORT = 3306
USERNAME = twong
PASSWORD = 'twong'
DATABASE = twong
PREFIX = eb_
CHARSET = utf8
DEBUG = true

[LANG]
default_lang = zh-cn

+ 3 - 0
app/api/controller/coin/UserCoinController.php

@@ -11,6 +11,9 @@ use crmeb\services\{UtilService, JsonService};
 use think\facade\Config;
 
 class UserCoinController {
+    public function status(Request $request) {
+        
+    }
 
     /**
      * 启动

+ 12 - 6
app/models/board/UserBoard.php

@@ -23,11 +23,17 @@ class UserBoard extends BaseModel {
      */
     public function getDailyWinMoney() {
         $start = ts_of_day();
-        return Db::query(
-            "select u.uid, u.avatar, u.nickname, u.level, sum(reparation) as value 
-    from tw_store_order_cart_info tsoci inner join tw_store_order tso on tsoci.oid=tso.id inner join tw_user u on tso.uid = u.uid 
-    where activity is not null and tso.pay_time > ? 
-    group by oid 
-    order by value desc, u.uid asc limit ?", [$start, 30,]);
+        $prefix = Env::get('database.prefix', 'eb_');
+        $tuser = $prefix . 'user';
+        $tcart_info = $prefix . 'store_order_cart_info';
+        $torder = $prefix . 'store_order';
+        $sql = sprintf("
+            select u.uid, u.avatar, u.nickname, u.level, sum(reparation) as value 
+            from %s tsoci inner join %s tso on tsoci.oid=tso.id inner join %s u on tso.uid = u.uid 
+            where activity is not null and tso.pay_time > %d 
+            group by oid 
+            order by value desc, u.uid asc limit %d
+        ", $tcart_info, $torder, $tuser, $start, 30)
+        return Db::query($sql);
     }
 }

+ 19 - 12
app/models/user/UserNotice.php

@@ -12,6 +12,7 @@ use crmeb\basic\BaseModel;
 use think\facade\Db;
 use think\facade\Log;
 use think\facade\Config;
+use think\facade\Env;
 /**
  * Class UserNotice
  * @package app\models\user
@@ -59,13 +60,15 @@ class UserNotice extends BaseModel
     }
     // 获取未读数
     public static function getNotice($uid){
-        $row = Db::query("
-            select count(*) as unread from tw_user_notice where id not in (
-	            select nid from tw_user_notice_see where uid=?
-            ) and uid in (?, 0) and del_time=0
-            ", [$uid, $uid]
-        );
-
+        $prefix = Env::get('database.prefix', 'eb_');
+        $tnotice = $prefix . 'user_notice';
+        $tnotice_see = $prefix . 'user_notice_see';
+        $sql = sprintf("
+            select count(*) as unread from %s where id not in (
+                select nid from %s where uid=%d
+            ) and uid in (%d, 0) and del_time=0
+        ", $tnotice, $tnotice_see, $uid, $uid);
+        $row = Db::query($sql);
         return intval($row[0]['unread']);
     }
 
@@ -74,13 +77,17 @@ class UserNotice extends BaseModel
      * @return array
      */
     public static function getNoticeList($uid, $page, $limit = 20){
-        $data = Db::query("
+        $prefix = Env::get('database.prefix', 'eb_');
+        $tnotice = $prefix . 'user_notice';
+        $tnotice_see = $prefix . 'user_notice_see';
+        $sql = sprintf("
             select n.id, n.icon, n.`user` as `from`, n.title as subject, n.content as `body`, n.add_time as ts, n.`type`, count(s.id) as `read`
-            from tw_user_notice n right join tw_user_notice_see s on n.uid = s.uid 
-            where n.uid in (?, 0) and n.del_time=0
+            from %s n right join %s s on n.uid = s.uid 
+            where n.uid in (%d, 0) and n.del_time=0
             group by s.id 
-            order by n.add_time desc limit ?,?
-        ", [$uid, ($page-1)*$limit, $limit]);
+            order by n.add_time desc limit %d,%d
+        ", $tnotice, $tnotice_see, $uid, ($page-1)*$limit, $limit);
+        $data = Db::query($sql);
 
         return $data;
     }

+ 8 - 21
docs/通信协议/activities_mine.md

@@ -1,32 +1,19 @@
 # 黑洞星活动
 
-## 全局新增接口
-GET api/user/notifications
+## status
+GET api/coin/status
 
 returns
 ```json
 {
-    "unread": 3,                // 未读消息条数
-    "mining": {
-        "symbol": "doge",           // 当前 coin
-        "icon":  "http://a.png",    // coin icon
-        "price": 2.07,              // 单价(RMB)
-        "step": 0.001,              // 每秒建议步长,可围绕此值随机递增
-        "progress": 12.00123,       // 进度, 0 表示 stopped
-        "total": 208                // 已获得总数
-    },
-    "carousel": {
-      "interval": 3,
-      "items": [{
-                   "text": "<span style=\"color:2343;\"></span>",
-                   "uri": "page/boards",
-                }]      // 跑马灯
-    } 
+  "symbol": "doge",           // 当前 coin
+  "icon":  "http://a.png",    // coin icon
+  "price": 2.07,              // 单价(RMB)
+  "step": 0.001,              // 每秒建议步长,可围绕此值随机递增
+  "progress": 12.00123,       // 进度, 0 表示 stopped
+  "total": 208                // 已获得总数
 }
 ```
-
-客户端自行调用,可定时或切页面调用,相当于服务器推送
-
 ## 
 
 1. 启动

+ 23 - 0
docs/通信协议/global.md

@@ -0,0 +1,23 @@
+## 全局新增接口
+GET api/user/notifications
+
+returns
+```json
+{
+  "unread": 0
+}
+```
+
+
+## carousel 
+GET api/carousel
+noauth
+
+returns
+```json
+"interval": 3,
+"items": [{
+  "text": "<span style=\"color:2343;\"></span>",
+  "uri": "page/boards",
+}]      // 跑马灯
+```

+ 20 - 21
route/api/route.php

@@ -31,27 +31,6 @@ Route::any('wechat/serve', 'wechat.WechatController/serve');//公众号服务
 Route::any('wechat/notify', 'wechat.WechatController/notify');//公众号支付回调
 Route::any('routine/notify', 'wechat.AuthController/notify');//小程序支付回调
 
-/**
- * 消息类 api, 需要权限, 暂时为测试
- */
-Route::get('user/notifications', 'user.UserNotificationController/snapshot')->name('userNotifications');
-
-Route::get('user/messages', 'user.UserNoticeController/messages')->name('userMessages');
-Route::post('user/messages', 'user.UserNoticeController/read')->name('userRead');
-Route::post('user/messages/del', 'user.UserNoticeController/del')->name('userDel');
-/**
- * 挖矿类 api
- */
-Route::post('coin/boot', 'coin.UserCoinController/boot')->name('coinBoot');
-Route::get('coin/history', 'coin.UserCoinController/history')->name('coinHistory');
-Route::post('coin/addr', 'coin.UserCoinController/updateAddr')->name('coinUpdateAddr');
-Route::post('coin/transfer', 'coin.UserCoinController/transfer')->name('coinTransfer');
-// TODO 当前 coin 余额显示到钱包
-
-/**
- * 排行榜 api
- */
-Route::get('boards', 'board.UserBoardController/boards')->name('board');
 
 //管理员订单操作类
 Route::group(function () {
@@ -181,6 +160,26 @@ Route::group(function () {
     Route::get('user/level/task/:id', 'user.UserLevelController/task')->name('userLevelTask');//获取等级任务
     //首页获取未支付订单
     Route::get('order/nopay', 'order.StoreOrderController/get_noPay')->name('getNoPay');//获取未支付订单
+    /**
+     * 消息类 api, 需要权限, 暂时为测试
+     */
+    Route::get('user/notifications', 'user.UserNotificationController/snapshot')->name('userNotifications');
+
+    Route::get('user/messages', 'user.UserNoticeController/messages')->name('userMessages');
+    Route::post('user/messages', 'user.UserNoticeController/read')->name('userRead');
+    Route::post('user/messages/del', 'user.UserNoticeController/del')->name('userDel');
+    /**
+     * 排行榜 api
+     */
+    Route::get('boards', 'board.UserBoardController/boards')->name('board');
+    /**
+     * 挖矿类 api
+     */
+    Route::get('coin/status', 'coin.UserCoinController/status')->name('coinStatus');
+    Route::post('coin/boot', 'coin.UserCoinController/boot')->name('coinBoot');
+    Route::get('coin/history', 'coin.UserCoinController/history')->name('coinHistory');
+    Route::post('coin/addr', 'coin.UserCoinController/updateAddr')->name('coinUpdateAddr');
+    Route::post('coin/transfer', 'coin.UserCoinController/transfer')->name('coinTransfer');
 })->middleware(\app\http\middleware\AllowOriginMiddleware::class)->middleware(\app\http\middleware\AuthTokenMiddleware::class, true);
 //未授权接口
 Route::group(function () {