|
|
@@ -11,6 +11,7 @@
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
+use App\Models\EnshrineOrdersModel;
|
|
|
use App\Models\GongdengOrderModel;
|
|
|
use App\Models\MemberModel;
|
|
|
use App\Models\OrdersModel;
|
|
|
@@ -114,7 +115,62 @@ class IndexController extends Backend
|
|
|
}
|
|
|
|
|
|
public function statistics(){
|
|
|
+ $cacheKey = "caches:statis:counts";
|
|
|
+ $datas = RedisService::get($cacheKey);
|
|
|
+ $datas = $datas? json_decode($datas, true) : [];
|
|
|
+ if($datas){
|
|
|
+ return message(MESSAGE_OK, true, $datas);
|
|
|
+ }
|
|
|
|
|
|
+ $datas = [
|
|
|
+ 'gdCount'=> GongdengOrderModel::where(['mark'=> 1,'status'=> 2])
|
|
|
+ ->count('id'),
|
|
|
+ 'gdDayCount'=> GongdengOrderModel::where(['mark'=> 1,'status'=> 2])
|
|
|
+ ->where('pay_at','>=', date('Y-m-d'))
|
|
|
+ ->count('id'),
|
|
|
+ 'shopCount'=> OrdersModel::where(['mark'=> 1])
|
|
|
+ ->whereIn('status',[2,3,4])
|
|
|
+ ->count('id'),
|
|
|
+ 'shopDayCount'=> OrdersModel::where(['mark'=> 1])
|
|
|
+ ->whereIn('status',[2,3,4])
|
|
|
+ ->where('pay_at','>=', date('Y-m-d'))
|
|
|
+ ->count('id'),
|
|
|
+ 'memberCount'=> MemberModel::where(['mark'=> 1,'status'=> 1])
|
|
|
+ ->count('id'),
|
|
|
+ 'memberDayCount'=> MemberModel::where(['mark'=> 1,'status'=> 1])
|
|
|
+ ->where('create_time','>=', strtotime(date('Y-m-d')))
|
|
|
+ ->count('id'),
|
|
|
+ 'enshrineCount'=> EnshrineOrdersModel::where(['mark'=> 1,'status'=> 2])
|
|
|
+ ->sum('total'),
|
|
|
+ 'enshrineDayCount'=> EnshrineOrdersModel::where(['mark'=> 1,'status'=> 2])
|
|
|
+ ->where('pay_at','>=', date('Y-m-d'))
|
|
|
+ ->sum('total'),
|
|
|
+ ];
|
|
|
+
|
|
|
+ RedisService::set($cacheKey, json_encode($datas, 256), rand(5, 10));
|
|
|
+ return message(MESSAGE_OK,true, $datas);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function statisTable(){
|
|
|
+ $type = request()->get('type', 'trade');
|
|
|
+ $dateType = request()->get('dateType', 0);
|
|
|
+ $datas = [];
|
|
|
+
|
|
|
+ switch($type){
|
|
|
+ case 'trade': // 消费
|
|
|
+ break;
|
|
|
+ case 'gd': // 供灯交易量
|
|
|
+ break;
|
|
|
+ case 'member': // 用户注册
|
|
|
+ break;
|
|
|
+ case 'shop': // 商城交易量
|
|
|
+ break;
|
|
|
+ case 'enshrine': // 供奉订单交易额
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return message(MESSAGE_OK,true, $datas);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -126,6 +182,7 @@ class IndexController extends Backend
|
|
|
RedisService::keyDel("caches:index:*");
|
|
|
RedisService::keyDel("caches:articles:*");
|
|
|
RedisService::keyDel("caches:qrcodes:*");
|
|
|
+ RedisService::keyDel("caches:statis:*");
|
|
|
return message(MESSAGE_OK, true);
|
|
|
}
|
|
|
}
|