feat: 修改了WorkbenchController和WorkbenchLogic类,添加了根据时间段获取商品统计数据的功能。
This commit is contained in:
parent
0a693d5e37
commit
c03acdb57a
@ -232,48 +232,16 @@ class WorkbenchController extends BaseAdminController
|
|||||||
*/
|
*/
|
||||||
public function get_basic()
|
public function get_basic()
|
||||||
{
|
{
|
||||||
$data = [
|
$startTime=$this->request->get('start_time');//开始时间
|
||||||
"browse" => [
|
$endTime=$this->request->get('end_time');//结束时间
|
||||||
"num" => 11353,
|
if(empty($startTime)){//如果没有传开始时间,则默认获取最近7天的数据
|
||||||
"percent" => "330.03"
|
$startTime=strtotime(date('Y-m-d'));
|
||||||
],
|
$endTime=$startTime+86400;
|
||||||
"user" => [
|
}
|
||||||
"num" => 538,
|
$where=[
|
||||||
"percent" => "47.39"
|
['create_time','between',[$startTime,$endTime]]
|
||||||
],
|
|
||||||
"cart" => [
|
|
||||||
"num" => 1181,
|
|
||||||
"percent" => "43.67"
|
|
||||||
],
|
|
||||||
"order" => [
|
|
||||||
"num" => 105753,
|
|
||||||
"percent" => "-68.07"
|
|
||||||
],
|
|
||||||
"pay" => [
|
|
||||||
"num" => 2476,
|
|
||||||
"percent" => "-99.24"
|
|
||||||
],
|
|
||||||
"payPrice" => [
|
|
||||||
"num" => 163490.54,
|
|
||||||
"percent" => "-87.50"
|
|
||||||
],
|
|
||||||
"cost" => [
|
|
||||||
"num" => 72147.8,
|
|
||||||
"percent" => "-93.33"
|
|
||||||
],
|
|
||||||
"refundPrice" => [
|
|
||||||
"num" => 2321.81,
|
|
||||||
"percent" => "1447.87"
|
|
||||||
],
|
|
||||||
"refund" => [
|
|
||||||
"num" => 39,
|
|
||||||
"percent" => "8.33"
|
|
||||||
],
|
|
||||||
"payPercent" => [
|
|
||||||
"num" => "15.61",
|
|
||||||
"percent" => "-6.58"
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
$data=WorkbenchLogic::get_basic($where);
|
||||||
return $this->data($data);
|
return $this->data($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ namespace app\admin\logic;
|
|||||||
|
|
||||||
|
|
||||||
use app\common\logic\BaseLogic;
|
use app\common\logic\BaseLogic;
|
||||||
|
use app\common\model\store_order\StoreOrder;
|
||||||
|
use app\common\model\store_visit\StoreVisit;
|
||||||
use app\common\service\ConfigService;
|
use app\common\service\ConfigService;
|
||||||
use app\common\service\FileService;
|
use app\common\service\FileService;
|
||||||
|
|
||||||
@ -37,162 +39,40 @@ class WorkbenchLogic extends BaseLogic
|
|||||||
public static function index()
|
public static function index()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
// 版本信息
|
|
||||||
'version' => self::versionInfo(),
|
|
||||||
// 今日数据
|
|
||||||
'today' => self::today(),
|
|
||||||
// 常用功能
|
// 常用功能
|
||||||
'menu' => self::menu(),
|
|
||||||
// 近15日访客数
|
|
||||||
'visitor' => self::visitor(),
|
|
||||||
// 服务支持
|
|
||||||
'support' => self::support()
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------商品统计---------------------------------------//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @notes 常用功能
|
* 商品概况
|
||||||
* @return array[]
|
|
||||||
* @author 乔峰
|
|
||||||
* @date 2021/12/29 16:40
|
|
||||||
*/
|
*/
|
||||||
public static function menu(): array
|
public static function get_basic($where)
|
||||||
{
|
{
|
||||||
|
$browse=StoreVisit::where($where)->count();
|
||||||
|
$user=0;
|
||||||
|
$cart=0;
|
||||||
|
$order=StoreOrder::where($where)->count();
|
||||||
|
$pay=StoreOrder::where($where)->where('paid',1)->count();
|
||||||
|
$payPrice=StoreOrder::where($where)->where('paid',1)->count('pay_price');
|
||||||
|
$cost=StoreOrder::where($where)->where('paid',1)->sum('cost');
|
||||||
|
$refundPrice=StoreOrder::where($where)->where('status','in',[-1,-2])->sum('refund_price');
|
||||||
|
$refund=StoreOrder::where($where)->where('status','in',[-1,-2])->count();
|
||||||
|
$payPercent=0;
|
||||||
return [
|
return [
|
||||||
[
|
'browse'=>['num'=>$browse,'title'=>'浏览量'],//浏览量
|
||||||
'name' => '管理员',
|
'user'=>['num'=>$user,'title'=>'访客数'],//访客数
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.menu_admin')),
|
'cart'=>['num'=>$cart,'title'=>'加购人数'],//加购人数
|
||||||
'url' => '/permission/admin'
|
'order'=>['num'=>$order,'title'=>'订单量'],//订单量
|
||||||
],
|
'pay'=>['num'=>$pay,'title'=>'支付订单量'],//支付订单量
|
||||||
[
|
'payPrice'=>['num'=>$payPrice,'title'=>'支付金额'],//支付金额
|
||||||
'name' => '角色管理',
|
'cost'=>['num'=>$cost,'title'=>'成本'],//成本
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.menu_role')),
|
'refundPrice'=>['num'=>$refundPrice,'title'=>'退款金额'],//退款金额
|
||||||
'url' => '/permission/role'
|
'refund'=>['num'=>$refund,'title'=>'退款订单量'],//退款订单量
|
||||||
],
|
'payPercent'=>['num'=>$payPercent,'title'=>'支付转化率'],//支付转化率
|
||||||
[
|
|
||||||
'name' => '部门管理',
|
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.menu_dept')),
|
|
||||||
'url' => '/organization/department'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => '素材中心',
|
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.menu_file')),
|
|
||||||
'url' => '/material/index'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => '菜单权限',
|
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.menu_auth')),
|
|
||||||
'url' => '/permission/menu'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => '网站信息',
|
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.menu_web')),
|
|
||||||
'url' => '/setting/website/information'
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 版本信息
|
|
||||||
* @return array
|
|
||||||
* @author 乔峰
|
|
||||||
* @date 2021/12/29 16:08
|
|
||||||
*/
|
|
||||||
public static function versionInfo(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'version' => config('project.version'),
|
|
||||||
'website' => config('project.website.url'),
|
|
||||||
'name' => ConfigService::get('website', 'name'),
|
|
||||||
'based' => 'vue3.x、ElementUI、MySQL',
|
|
||||||
'channel' => [
|
|
||||||
'website' => 'https://gitee.com/MuZJun/gather-admin.git',
|
|
||||||
'gitee' => 'https://gitee.com/MuZJun/gather-vue.git',
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 今日数据
|
|
||||||
* @return int[]
|
|
||||||
* @author 乔峰
|
|
||||||
* @date 2021/12/29 16:15
|
|
||||||
*/
|
|
||||||
public static function today(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'time' => date('Y-m-d H:i:s'),
|
|
||||||
// 今日销售额
|
|
||||||
'today_sales' => 100,
|
|
||||||
// 总销售额
|
|
||||||
'total_sales' => 1000,
|
|
||||||
|
|
||||||
// 今日访问量
|
|
||||||
'today_visitor' => 10,
|
|
||||||
// 总访问量
|
|
||||||
'total_visitor' => 100,
|
|
||||||
|
|
||||||
// 今日新增用户量
|
|
||||||
'today_new_user' => 30,
|
|
||||||
// 总用户量
|
|
||||||
'total_new_user' => 3000,
|
|
||||||
|
|
||||||
// 订单量 (笔)
|
|
||||||
'order_num' => 12,
|
|
||||||
// 总订单量
|
|
||||||
'order_sum' => 255
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 访问数
|
|
||||||
* @return array
|
|
||||||
* @author 乔峰
|
|
||||||
* @date 2021/12/29 16:57
|
|
||||||
*/
|
|
||||||
public static function visitor(): array
|
|
||||||
{
|
|
||||||
$num = [];
|
|
||||||
$date = [];
|
|
||||||
for ($i = 0; $i < 15; $i++) {
|
|
||||||
$where_start = strtotime("- " . $i . "day");
|
|
||||||
$date[] = date('Y/m/d', $where_start);
|
|
||||||
$num[$i] = rand(0, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
'date' => $date,
|
|
||||||
'list' => [
|
|
||||||
['name' => '访客数', 'data' => $num]
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @notes 服务支持
|
|
||||||
* @return array[]
|
|
||||||
* @author 乔峰
|
|
||||||
* @date 2022/7/18 11:18
|
|
||||||
*/
|
|
||||||
public static function support()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.qq_group')),
|
|
||||||
'title' => '官方公众号',
|
|
||||||
'desc' => '关注官方公众号',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'image' => FileService::getFileUrl(config('project.default_image.customer_service')),
|
|
||||||
'title' => '添加企业客服微信',
|
|
||||||
'desc' => '想了解更多请添加客服',
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user