|
@@ -1420,10 +1420,17 @@ HTML;
|
|
|
return bcmul(bcdiv((bcsub($nowValue, $lastValue, 2)), $lastValue, 4), 100, 2);
|
|
return bcmul(bcdiv((bcsub($nowValue, $lastValue, 2)), $lastValue, 4), 100, 2);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 后台首页顶部统计
|
|
|
|
|
+ * @return array
|
|
|
|
|
+ * @author 吴汐
|
|
|
|
|
+ * @email 442384644@qq.com
|
|
|
|
|
+ * @date 2023/04/03
|
|
|
|
|
+ */
|
|
|
public function homeStatics()
|
|
public function homeStatics()
|
|
|
{
|
|
{
|
|
|
- /** @var UserServices $uSercice */
|
|
|
|
|
- $uSercice = app()->make(UserServices::class);
|
|
|
|
|
|
|
+ /** @var UserServices $userService */
|
|
|
|
|
+ $userService = app()->make(UserServices::class);
|
|
|
/** @var StoreProductLogServices $productLogServices */
|
|
/** @var StoreProductLogServices $productLogServices */
|
|
|
$productLogServices = app()->make(StoreProductLogServices::class);
|
|
$productLogServices = app()->make(StoreProductLogServices::class);
|
|
|
//TODO 销售额
|
|
//TODO 销售额
|
|
@@ -1433,22 +1440,12 @@ HTML;
|
|
|
$yesterday_sales = $this->dao->todaySales('yesterday');
|
|
$yesterday_sales = $this->dao->todaySales('yesterday');
|
|
|
//日同比
|
|
//日同比
|
|
|
$sales_today_ratio = $this->growth($today_sales, $yesterday_sales);
|
|
$sales_today_ratio = $this->growth($today_sales, $yesterday_sales);
|
|
|
-// //周销售额
|
|
|
|
|
-// //本周
|
|
|
|
|
-// $this_week_sales = $this->dao->thisWeekSales('week');
|
|
|
|
|
-// //上周
|
|
|
|
|
-// $last_week_sales = $this->dao->thisWeekSales('last week');
|
|
|
|
|
-// //周同比
|
|
|
|
|
-// $sales_week_ratio = $this->growth($this_week_sales, $last_week_sales);
|
|
|
|
|
//总销售额
|
|
//总销售额
|
|
|
$total_sales = $this->dao->totalSales('month');
|
|
$total_sales = $this->dao->totalSales('month');
|
|
|
$sales = [
|
|
$sales = [
|
|
|
'today' => $today_sales,
|
|
'today' => $today_sales,
|
|
|
'yesterday' => $yesterday_sales,
|
|
'yesterday' => $yesterday_sales,
|
|
|
'today_ratio' => $sales_today_ratio,
|
|
'today_ratio' => $sales_today_ratio,
|
|
|
-// 'week' => $this_week_sales,
|
|
|
|
|
-// 'last_week' => $last_week_sales,
|
|
|
|
|
-// 'week_ratio' => $sales_week_ratio,
|
|
|
|
|
'total' => $total_sales . '元',
|
|
'total' => $total_sales . '元',
|
|
|
'date' => '今日'
|
|
'date' => '今日'
|
|
|
];
|
|
];
|
|
@@ -1459,21 +1456,12 @@ HTML;
|
|
|
$yesterday_visits = $productLogServices->count(['time' => 'yesterday', 'type' => 'visit']);
|
|
$yesterday_visits = $productLogServices->count(['time' => 'yesterday', 'type' => 'visit']);
|
|
|
//日同比
|
|
//日同比
|
|
|
$visits_today_ratio = $this->growth($today_visits, $yesterday_visits);
|
|
$visits_today_ratio = $this->growth($today_visits, $yesterday_visits);
|
|
|
-// //本周访问量
|
|
|
|
|
-// $this_week_visits = $productLogServices->count(['time' => 'week', 'type' => 'visit']);
|
|
|
|
|
-// //上周访问量
|
|
|
|
|
-// $last_week_visits = $productLogServices->count(['time' => 'last week', 'type' => 'visit']);
|
|
|
|
|
-// //周同比
|
|
|
|
|
-// $visits_week_ratio = $this->growth($this_week_visits, $last_week_visits);
|
|
|
|
|
//总访问量
|
|
//总访问量
|
|
|
$total_visits = $productLogServices->count(['time' => 'month', 'type' => 'visit']);
|
|
$total_visits = $productLogServices->count(['time' => 'month', 'type' => 'visit']);
|
|
|
$visits = [
|
|
$visits = [
|
|
|
'today' => $today_visits,
|
|
'today' => $today_visits,
|
|
|
'yesterday' => $yesterday_visits,
|
|
'yesterday' => $yesterday_visits,
|
|
|
'today_ratio' => $visits_today_ratio,
|
|
'today_ratio' => $visits_today_ratio,
|
|
|
-// 'week' => $this_week_visits,
|
|
|
|
|
-// 'last_week' => $last_week_visits,
|
|
|
|
|
-// 'week_ratio' => $visits_week_ratio,
|
|
|
|
|
'total' => $total_visits . 'Pv',
|
|
'total' => $total_visits . 'Pv',
|
|
|
'date' => '今日'
|
|
'date' => '今日'
|
|
|
];
|
|
];
|
|
@@ -1484,46 +1472,28 @@ HTML;
|
|
|
$yesterday_order = $this->dao->todayOrderVisit('yesterday', 1);
|
|
$yesterday_order = $this->dao->todayOrderVisit('yesterday', 1);
|
|
|
//订单日同比
|
|
//订单日同比
|
|
|
$order_today_ratio = $this->growth($today_order, $yesterday_order);
|
|
$order_today_ratio = $this->growth($today_order, $yesterday_order);
|
|
|
-// //本周订单量
|
|
|
|
|
-// $this_week_order = $this->dao->todayOrderVisit('week', 2);
|
|
|
|
|
-// //上周订单量
|
|
|
|
|
-// $last_week_order = $this->dao->todayOrderVisit('last week', 2);
|
|
|
|
|
-// //订单周同比
|
|
|
|
|
-// $order_week_ratio = $this->growth($this_week_order, $last_week_order);
|
|
|
|
|
//总订单量
|
|
//总订单量
|
|
|
$total_order = $this->dao->count(['time' => 'month', 'paid' => 1, 'refund_status' => 0, 'pid' => 0]);
|
|
$total_order = $this->dao->count(['time' => 'month', 'paid' => 1, 'refund_status' => 0, 'pid' => 0]);
|
|
|
$order = [
|
|
$order = [
|
|
|
'today' => $today_order,
|
|
'today' => $today_order,
|
|
|
'yesterday' => $yesterday_order,
|
|
'yesterday' => $yesterday_order,
|
|
|
'today_ratio' => $order_today_ratio,
|
|
'today_ratio' => $order_today_ratio,
|
|
|
-// 'week' => $this_week_order,
|
|
|
|
|
-// 'last_week' => $last_week_order,
|
|
|
|
|
-// 'week_ratio' => $order_week_ratio,
|
|
|
|
|
'total' => $total_order . '单',
|
|
'total' => $total_order . '单',
|
|
|
'date' => '今日'
|
|
'date' => '今日'
|
|
|
];
|
|
];
|
|
|
//TODO 用户
|
|
//TODO 用户
|
|
|
//今日新增用户
|
|
//今日新增用户
|
|
|
- $today_user = $uSercice->todayAddVisits('today', 1);
|
|
|
|
|
|
|
+ $today_user = $userService->todayAddVisits('today', 1);
|
|
|
//昨日新增用户
|
|
//昨日新增用户
|
|
|
- $yesterday_user = $uSercice->todayAddVisits('yesterday', 1);
|
|
|
|
|
|
|
+ $yesterday_user = $userService->todayAddVisits('yesterday', 1);
|
|
|
//新增用户日同比
|
|
//新增用户日同比
|
|
|
$user_today_ratio = $this->growth($today_user, $yesterday_user);
|
|
$user_today_ratio = $this->growth($today_user, $yesterday_user);
|
|
|
-// //本周新增用户
|
|
|
|
|
-// $this_week_user = $uSercice->todayAddVisits('week', 2);
|
|
|
|
|
-// //上周新增用户
|
|
|
|
|
-// $last_week_user = $uSercice->todayAddVisits('last week', 2);
|
|
|
|
|
-// //新增用户周同比
|
|
|
|
|
-// $user_week_ratio = $this->growth($this_week_user, $last_week_user);
|
|
|
|
|
//所有用户
|
|
//所有用户
|
|
|
- $total_user = $uSercice->count(['time' => 'month']);
|
|
|
|
|
|
|
+ $total_user = $userService->count(['time' => 'month']);
|
|
|
$user = [
|
|
$user = [
|
|
|
'today' => $today_user,
|
|
'today' => $today_user,
|
|
|
'yesterday' => $yesterday_user,
|
|
'yesterday' => $yesterday_user,
|
|
|
'today_ratio' => $user_today_ratio,
|
|
'today_ratio' => $user_today_ratio,
|
|
|
-// 'week' => $this_week_user,
|
|
|
|
|
-// 'last_week' => $last_week_user,
|
|
|
|
|
-// 'week_ratio' => $user_week_ratio,
|
|
|
|
|
'total' => $total_user . '人',
|
|
'total' => $total_user . '人',
|
|
|
'date' => '今日'
|
|
'date' => '今日'
|
|
|
];
|
|
];
|
|
@@ -2566,12 +2536,12 @@ HTML;
|
|
|
public function autoComment()
|
|
public function autoComment()
|
|
|
{
|
|
{
|
|
|
//自动评价天数
|
|
//自动评价天数
|
|
|
- $systemCommentTime = (int)sys_config('system_comment_time', 0);
|
|
|
|
|
|
|
+ $systemCommentTime = sys_config('system_comment_time', 0);
|
|
|
//0为取消自动默认好评功能
|
|
//0为取消自动默认好评功能
|
|
|
if ($systemCommentTime == 0) {
|
|
if ($systemCommentTime == 0) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
- $sevenDay = strtotime(date('Y-m-d H:i:s', strtotime('-' . $systemCommentTime . ' day')));
|
|
|
|
|
|
|
+ $sevenDay = bcsub((string)time(), bcmul((string)$systemCommentTime, '86400'));
|
|
|
/** @var StoreOrderStoreOrderStatusServices $service */
|
|
/** @var StoreOrderStoreOrderStatusServices $service */
|
|
|
$service = app()->make(StoreOrderStoreOrderStatusServices::class);
|
|
$service = app()->make(StoreOrderStoreOrderStatusServices::class);
|
|
|
$orderList = $service->getTakeOrderIds([
|
|
$orderList = $service->getTakeOrderIds([
|
|
@@ -2579,7 +2549,7 @@ HTML;
|
|
|
'is_del' => 0,
|
|
'is_del' => 0,
|
|
|
'paid' => 1,
|
|
'paid' => 1,
|
|
|
'status' => 2,
|
|
'status' => 2,
|
|
|
- 'change_type' => ['take_delivery']
|
|
|
|
|
|
|
+ 'change_type' => ['take_delivery','user_take_delivery']
|
|
|
], 30);
|
|
], 30);
|
|
|
foreach ($orderList as $item) {
|
|
foreach ($orderList as $item) {
|
|
|
AutoCommentJob::dispatch([$item['id'], $item['cart_id']]);
|
|
AutoCommentJob::dispatch([$item['id'], $item['cart_id']]);
|