修改统计和同步功能
This commit is contained in:
parent
6401ce8884
commit
2a367c5c3c
|
|
@ -1711,21 +1711,18 @@ class Goods extends Base
|
|||
return $this->renderError('请求方式错误');
|
||||
}
|
||||
|
||||
$id = $request->post('id/d');
|
||||
$url = $request->post('url/s');
|
||||
|
||||
// 验证URL格式
|
||||
if (!filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
return $this->renderError('URL格式不正确');
|
||||
$id = $request->post('id/d', 0);
|
||||
if ($id == 0) {
|
||||
$id = $request->post('goods_id/d', 0);
|
||||
}
|
||||
|
||||
// 确保URL以/结尾
|
||||
if (substr($url, -1) !== '/') {
|
||||
$url .= '/';
|
||||
|
||||
// 获取targets数组参数
|
||||
$targets = $request->post('targets/a', []);
|
||||
|
||||
if (empty($targets)) {
|
||||
return $this->renderError('同步目标URL不能为空');
|
||||
}
|
||||
|
||||
$url .= 'api/goods/receive_sync';
|
||||
|
||||
// 获取盒子数据
|
||||
$goods = GoodsModel::where(['id' => $id])->find();
|
||||
if (!$goods) {
|
||||
|
|
@ -1771,42 +1768,88 @@ class Goods extends Base
|
|||
$postData['goodsExtend'] = $goodsExtend->toArray();
|
||||
}
|
||||
|
||||
// 发送同步请求
|
||||
try {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen(json_encode($postData))
|
||||
]);
|
||||
// 同步结果统计
|
||||
$results = [
|
||||
'success' => [],
|
||||
'failed' => []
|
||||
];
|
||||
$anySuccess = false;
|
||||
$syncUrls = [];
|
||||
|
||||
$response = curl_exec($ch);
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($status !== 200) {
|
||||
return $this->renderError('同步失败,服务器返回状态码: ' . $status);
|
||||
// 循环发送到每个目标URL
|
||||
foreach ($targets as $target) {
|
||||
// 验证URL格式
|
||||
if (!filter_var($target, FILTER_VALIDATE_URL)) {
|
||||
$results['failed'][] = [
|
||||
'url' => $target,
|
||||
'message' => 'URL格式不正确'
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
if (!$responseData || $responseData['code'] !== 1) {
|
||||
$errorMsg = isset($responseData['msg']) ? $responseData['msg'] : '服务器未返回预期响应';
|
||||
return $this->renderError('同步失败: ' . $errorMsg);
|
||||
}
|
||||
// 确保URL格式正确
|
||||
$url = rtrim($target, '/') . '/api/goods_receive_sync?is_test=true';
|
||||
|
||||
// 发送同步请求
|
||||
try {
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // 设置30秒超时
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'Content-Type: application/json',
|
||||
'Content-Length: ' . strlen(json_encode($postData))
|
||||
]);
|
||||
|
||||
// 更新同步状态
|
||||
$response = curl_exec($ch);
|
||||
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($status !== 200) {
|
||||
$results['failed'][] = [
|
||||
'url' => $url,
|
||||
'message' => '服务器返回状态码: ' . $status
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
$responseData = json_decode($response, true);
|
||||
if (!$responseData || $responseData['code'] !== 1) {
|
||||
$errorMsg = isset($responseData['msg']) ? $responseData['msg'] : '服务器未返回预期响应';
|
||||
$results['failed'][] = [
|
||||
'url' => $url,
|
||||
'message' => $errorMsg
|
||||
];
|
||||
continue;
|
||||
}
|
||||
|
||||
// 记录成功URL
|
||||
$results['success'][] = $url;
|
||||
$syncUrls[] = $url;
|
||||
$anySuccess = true;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
$results['failed'][] = [
|
||||
'url' => $url,
|
||||
'message' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// 如果有任何成功的同步,更新商品同步状态
|
||||
if ($anySuccess) {
|
||||
$goods->save([
|
||||
'sync_status' => 1,
|
||||
'sync_url' => $url,
|
||||
'sync_url' => implode(',', $syncUrls),
|
||||
'sync_time' => date('Y-m-d H:i:s')
|
||||
]);
|
||||
|
||||
return $this->renderSuccess('同步成功');
|
||||
} catch (\Exception $e) {
|
||||
return $this->renderError('同步失败: ' . $e->getMessage());
|
||||
|
||||
return $this->renderSuccess('同步完成:' . count($results['success']) . '个站点同步成功,' .
|
||||
count($results['failed']) . '个站点同步失败', $results);
|
||||
} else {
|
||||
return $this->renderError('同步失败:所有目标站点同步均失败', $results);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ class Statistics extends Base
|
|||
|
||||
View::assign('ranges', $ranges);
|
||||
|
||||
|
||||
|
||||
return View::fetch("Statistics/dataStand");
|
||||
}
|
||||
|
||||
|
|
@ -1598,4 +1598,239 @@ class Statistics extends Base
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户数据统计
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getUserStatisticsData()
|
||||
{
|
||||
// 用户注册人数
|
||||
$user_register_count = User::where('status', 1)
|
||||
->where('istest', 0)
|
||||
->where('mobile', '<>', '')
|
||||
->count();
|
||||
|
||||
// 消费人数
|
||||
$consuming_user_count = Db::query("SELECT COUNT(DISTINCT(user_id)) as count
|
||||
FROM `order` ol
|
||||
LEFT JOIN `user` us ON ol.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0");
|
||||
$consuming_user_count = isset($consuming_user_count[0]['count']) ? $consuming_user_count[0]['count'] : 0;
|
||||
|
||||
// 用户货币统计
|
||||
$user_currency = Db::query("SELECT sum(money) as money, sum(money2) as money2, sum(integral) as integral
|
||||
FROM `user`
|
||||
WHERE status=1 AND istest=0");
|
||||
$user_money = isset($user_currency[0]['money']) ? round($user_currency[0]['money'], 2) : 0;
|
||||
$user_money2 = isset($user_currency[0]['money2']) ? round($user_currency[0]['money2'], 2) : 0;
|
||||
$user_integral = isset($user_currency[0]['integral']) ? round($user_currency[0]['integral'], 2) : 0;
|
||||
|
||||
// 订单统计
|
||||
$order_stats = Db::query("SELECT sum(ol.price) as price, count(1) as c
|
||||
FROM `order` ol
|
||||
LEFT JOIN `user` us ON ol.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND ol.status=1");
|
||||
$order_price_total = isset($order_stats[0]['price']) ? round($order_stats[0]['price'], 2) : 0;
|
||||
$order_total_count = isset($order_stats[0]['c']) ? $order_stats[0]['c'] : 0;
|
||||
|
||||
// 盒柜剩余价值
|
||||
$box_remaining = Db::query("SELECT sum(goodslist_money) as total
|
||||
FROM order_list oll
|
||||
LEFT JOIN `user` us ON oll.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND oll.status=0 AND oll.goodslist_type<3");
|
||||
$box_remaining_value = isset($box_remaining[0]['total']) ? round($box_remaining[0]['total'], 2) : 0;
|
||||
|
||||
// 已兑换的达达券
|
||||
$exchanged = Db::query("SELECT sum(goodslist_money) as total
|
||||
FROM order_list oll
|
||||
LEFT JOIN `user` us ON oll.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND oll.status=1 AND oll.goodslist_type<3");
|
||||
$exchanged_coupon = isset($exchanged[0]['total']) ? round($exchanged[0]['total']*100, 2) : 0;
|
||||
|
||||
// 已发货金额
|
||||
$shipped = Db::query("SELECT sum(goodslist_money) as total
|
||||
FROM order_list oll
|
||||
LEFT JOIN `user` us ON oll.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND oll.status=2 AND oll.goodslist_type<3");
|
||||
$shipped_amount = isset($shipped[0]['total']) ? round($shipped[0]['total'], 2) : 0;
|
||||
|
||||
// 出货总金额
|
||||
$total_goods = Db::query("SELECT sum(goodslist_money) as total
|
||||
FROM order_list oll
|
||||
LEFT JOIN `user` us ON oll.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND oll.goodslist_type<3");
|
||||
$total_goods_amount = isset($total_goods[0]['total']) ? round($total_goods[0]['total'], 2) : 0;
|
||||
|
||||
// 返回JSON数据
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取数据成功',
|
||||
'data' => [
|
||||
'user_register_count' => $user_register_count,
|
||||
'consuming_user_count' => $consuming_user_count,
|
||||
'user_money' => $user_money,
|
||||
'user_money2' => $user_money2,
|
||||
'user_integral' => $user_integral,
|
||||
'order_price_total' => $order_price_total,
|
||||
'order_total_count' => $order_total_count,
|
||||
'box_remaining_value' => $box_remaining_value,
|
||||
'exchanged_coupon' => $exchanged_coupon,
|
||||
'shipped_amount' => $shipped_amount,
|
||||
'total_goods_amount' => $total_goods_amount
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取新的利润计算数据
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getProfitData()
|
||||
{
|
||||
// 当天收入:当日微信支付+当日钻石消费
|
||||
$today_income = Db::query("SELECT IFNULL(sum(ol.price),0)+IFNULL(sum(ol.use_money),0) as total
|
||||
FROM `order` ol
|
||||
LEFT JOIN `user` us ON ol.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND ol.status=1
|
||||
AND ol.pay_time>UNIX_TIMESTAMP(CURDATE())");
|
||||
$today_income = isset($today_income[0]['total']) ? round($today_income[0]['total'], 2) : 0;
|
||||
|
||||
// 当日发货金额
|
||||
$today_shipped = Db::query("SELECT sum(goodslist_money) as total
|
||||
FROM order_list oll
|
||||
LEFT JOIN `user` us ON oll.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND oll.status=2
|
||||
AND oll.goodslist_type<3 AND oll.choice_time>UNIX_TIMESTAMP(CURDATE())");
|
||||
$today_shipped = isset($today_shipped[0]['total']) ? round($today_shipped[0]['total'], 2) : 0;
|
||||
|
||||
// 用户盒柜剩余
|
||||
$box_remaining = Db::query("SELECT sum(goodslist_money) as total
|
||||
FROM order_list oll
|
||||
LEFT JOIN `user` us ON oll.user_id=us.id
|
||||
WHERE us.status=1 AND us.istest=0 AND oll.status=0
|
||||
AND oll.goodslist_type<3");
|
||||
$box_remaining = isset($box_remaining[0]['total']) ? round($box_remaining[0]['total'], 2) : 0;
|
||||
|
||||
// 用户还剩多少达达券(查询出来后,需要除以100,达达券和emb的比例为100:1,1块钱兑换100rmb)
|
||||
$remaining_coupon = Db::query("SELECT sum(money2) as money2
|
||||
FROM `user`
|
||||
WHERE status=1 AND istest=0");
|
||||
$remaining_coupon = isset($remaining_coupon[0]['money2']) ? round($remaining_coupon[0]['money2'] / 100, 2) : 0;
|
||||
|
||||
// 计算利润
|
||||
$profit = round($today_income - $today_shipped - $remaining_coupon - $box_remaining, 2);
|
||||
|
||||
// 返回JSON数据
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取数据成功',
|
||||
'data' => [
|
||||
'profit' => $profit,
|
||||
'today_income' => $today_income,
|
||||
'today_shipped' => $today_shipped,
|
||||
'remaining_coupon' => $remaining_coupon,
|
||||
'box_remaining' => $box_remaining,
|
||||
'formula' => "利润({$profit}) = 当天收入({$today_income}) - 当天发货金额({$today_shipped}) - 当天用户剩余达达券({$remaining_coupon}) - 盒柜剩余({$box_remaining})"
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户注册相关数据
|
||||
* @return \think\response\Json
|
||||
*/
|
||||
public function getUserRegisterData()
|
||||
{
|
||||
// 获取测试用户ID列表
|
||||
$userList = User::where('istest', '>', 0)->field('id')->select();
|
||||
$userArray = array_column($userList->toArray(), 'id');
|
||||
|
||||
// 总注册人数
|
||||
$userCount = User::count("id");
|
||||
|
||||
// 设置时间范围
|
||||
$ranges = [
|
||||
// 今日时间
|
||||
'today_start' => strtotime('today'),
|
||||
'today_end' => strtotime('tomorrow') - 1,
|
||||
|
||||
// 昨日时间
|
||||
'yesterday_start' => strtotime('yesterday'),
|
||||
'yesterday_end' => strtotime('today') - 1,
|
||||
|
||||
// 本周时间(周一到周日)
|
||||
'this_week_start' => strtotime('monday this week'),
|
||||
'this_week_end' => strtotime('sunday this week') + 86399,
|
||||
|
||||
// 上周时间(上周一到上周日)
|
||||
'last_week_start' => strtotime('monday last week'),
|
||||
'last_week_end' => strtotime('sunday last week') + 86399,
|
||||
|
||||
// 本月时间(1号到月末)
|
||||
'this_month_start' => strtotime(date('Y-m-01')),
|
||||
'this_month_end' => strtotime(date('Y-m-t')) + 86399,
|
||||
|
||||
// 上月时间(上个月1号到月末)
|
||||
'last_month_start' => strtotime(date('Y-m-01', strtotime('-1 month'))),
|
||||
'last_month_end' => strtotime(date('Y-m-t', strtotime('-1 month'))) + 86399
|
||||
];
|
||||
|
||||
// 今日注册人数
|
||||
$user_today = User::whereBetweenTime('addtime', $ranges['today_start'], $ranges['today_end'])->count('id');
|
||||
|
||||
// 昨日注册人数
|
||||
$user_yesterday = User::whereBetweenTime('addtime', $ranges['yesterday_start'], $ranges['yesterday_end'])->count('id');
|
||||
|
||||
// 本周注册人数
|
||||
$user_this_week = User::whereBetweenTime('addtime', $ranges['this_week_start'], $ranges['this_week_end'])->count('id');
|
||||
|
||||
// 上周注册人数
|
||||
$user_last_week = User::whereBetweenTime('addtime', $ranges['last_week_start'], $ranges['last_week_end'])->count('id');
|
||||
|
||||
// 本月注册人数
|
||||
$user_this_month = User::whereBetweenTime('addtime', $ranges['this_month_start'], $ranges['this_month_end'])->count('id');
|
||||
|
||||
// 上月注册人数
|
||||
$user_last_month = User::whereBetweenTime('addtime', $ranges['last_month_start'], $ranges['last_month_end'])->count('id');
|
||||
|
||||
// 本日充值金额
|
||||
$order_today = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userArray)->whereBetweenTime('addtime', $ranges['today_start'], $ranges['today_end'])->sum('price');
|
||||
|
||||
// 昨日充值金额
|
||||
$order_yesterday = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userArray)->whereBetweenTime('addtime', $ranges['yesterday_start'], $ranges['yesterday_end'])->sum('price');
|
||||
|
||||
// 本周充值金额
|
||||
$order_this_week = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userArray)->whereBetweenTime('addtime', $ranges['this_week_start'], $ranges['this_week_end'])->sum('price');
|
||||
|
||||
// 上周充值金额
|
||||
$order_last_week = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userArray)->whereBetweenTime('addtime', $ranges['last_week_start'], $ranges['last_week_end'])->sum('price');
|
||||
|
||||
// 本月充值金额
|
||||
$order_this_month = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userArray)->whereBetweenTime('addtime', $ranges['this_month_start'], $ranges['this_month_end'])->sum('price');
|
||||
|
||||
// 上月充值金额
|
||||
$order_last_month = OrderModel::where('status', '=', 1)->whereNotIn('user_id', $userArray)->whereBetweenTime('addtime', $ranges['last_month_start'], $ranges['last_month_end'])->sum('price');
|
||||
|
||||
// 返回JSON数据
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '获取数据成功',
|
||||
'data' => [
|
||||
'userCount' => $userCount,
|
||||
'user_today' => $user_today,
|
||||
'user_yesterday' => $user_yesterday,
|
||||
'user_this_week' => $user_this_week,
|
||||
'user_last_week' => $user_last_week,
|
||||
'user_this_month' => $user_this_month,
|
||||
'user_last_month' => $user_last_month,
|
||||
'order_today' => $order_today,
|
||||
'order_yesterday' => $order_yesterday,
|
||||
'order_this_week' => $order_this_week,
|
||||
'order_last_week' => $order_last_week,
|
||||
'order_this_month' => $order_this_month,
|
||||
'order_last_month' => $order_last_month
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -436,7 +436,9 @@ Route::rule('statistics_lotteryUsers', 'Statistics/lotteryUsers', 'GET');
|
|||
Route::rule('statistics_userLotteryDetail', 'Statistics/userLotteryDetail', 'GET');
|
||||
Route::rule('statistics_userLotteryDetailData', 'Statistics/userLotteryDetailData', 'GET');
|
||||
Route::rule('statistics_lotteryUsersData', 'Statistics/lotteryUsersData', 'GET');
|
||||
|
||||
Route::rule('Statistics/getUserStatisticsData', 'Statistics/getUserStatisticsData', 'GET');
|
||||
Route::rule('Statistics/getProfitData', 'Statistics/getProfitData', 'GET');
|
||||
Route::rule('Statistics/getUserRegisterData', 'Statistics/getUserRegisterData', 'GET');
|
||||
// 盒子下架日志相关路由
|
||||
Route::post('goods_offshelf_read', 'GoodsOffshelfController/read');
|
||||
Route::get('goods_offshelf_unread_count', 'GoodsOffshelfController/getUnreadCount');
|
||||
|
|
|
|||
|
|
@ -14,43 +14,45 @@
|
|||
<div class="layui-card">
|
||||
<div class="layui-card-header" style="background-color: yellow;">
|
||||
总注册人数:
|
||||
<span style="color: red;">
|
||||
{$userCount}
|
||||
<span style="color: red;" id="totalUserCount">
|
||||
<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中...
|
||||
</span>
|
||||
<button type="button" class="layui-btn layui-btn-xs layui-btn-warm" id="refreshUserRegister" style="float: right;margin-top: 5px;">
|
||||
<i class="layui-icon layui-icon-refresh"></i> 刷新
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 0px;">
|
||||
<div class="layui-row">
|
||||
<div id="userRegisterLoading" style="text-align: center; padding: 20px;">
|
||||
<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop" style="font-size: 30px;"></i>
|
||||
<p>正在加载数据...</p>
|
||||
</div>
|
||||
<div class="layui-row" id="userRegisterData" style="display: none;">
|
||||
<div class="layui-col-xs6" style="padding: 0px 5px;background-color: #393D49;">
|
||||
<div class="layui-card" style="background-color: #393D49;color: #fff;">
|
||||
<div class="layui-card-header" style="color: #fff;">用户注册数据</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row s-row ">
|
||||
<div class="layui-col-xs6">
|
||||
今日新增用户: <span class="layui-badge layui-bg-gray">{$user_today}</span>
|
||||
今日新增用户: <span class="layui-badge layui-bg-gray" id="user_today">-</span>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
昨日新增用户: <span
|
||||
class="layui-badge layui-bg-gray">{$user_yesterday}</span>
|
||||
昨日新增用户: <span class="layui-badge layui-bg-gray" id="user_yesterday">-</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row s-row ">
|
||||
<div class="layui-col-xs6">
|
||||
本周新增用户: <span
|
||||
class="layui-badge layui-bg-gray">{$user_this_week}</span>
|
||||
本周新增用户: <span class="layui-badge layui-bg-gray" id="user_this_week">-</span>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
上周新增用户: <span
|
||||
class="layui-badge layui-bg-gray">{$user_last_week}</span>
|
||||
上周新增用户: <span class="layui-badge layui-bg-gray" id="user_last_week">-</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row s-row ">
|
||||
<div class="layui-col-xs6">
|
||||
本月新增用户: <span
|
||||
class="layui-badge layui-bg-gray">{$user_this_month}</span>
|
||||
本月新增用户: <span class="layui-badge layui-bg-gray" id="user_this_month">-</span>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
上月新增用户: <span
|
||||
class="layui-badge layui-bg-gray">{$user_last_month}</span>
|
||||
上月新增用户: <span class="layui-badge layui-bg-gray" id="user_last_month">-</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -62,39 +64,32 @@
|
|||
<div class="layui-card-body">
|
||||
<div class="layui-row s-row ">
|
||||
<div class="layui-col-xs6">
|
||||
今日充值金额: <span
|
||||
class="layui-badge layui-bg-gray">{$order_today}</span>
|
||||
今日充值金额: <span class="layui-badge layui-bg-gray" id="order_today_value">-</span>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
昨日充值金额: <span
|
||||
class="layui-badge layui-bg-gray">{$order_yesterday}</span>
|
||||
昨日充值金额: <span class="layui-badge layui-bg-gray" id="order_yesterday_value">-</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row s-row ">
|
||||
<div class="layui-col-xs6">
|
||||
本周充值金额: <span
|
||||
class="layui-badge layui-bg-gray">{$order_this_week}</span>
|
||||
本周充值金额: <span class="layui-badge layui-bg-gray" id="order_this_week_value">-</span>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
上周充值金额: <span
|
||||
class="layui-badge layui-bg-gray">{$order_last_week}</span>
|
||||
上周充值金额: <span class="layui-badge layui-bg-gray" id="order_last_week_value">-</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row s-row ">
|
||||
<div class="layui-col-xs6">
|
||||
本月充值金额: <span
|
||||
class="layui-badge layui-bg-gray">{$order_this_month}</span>
|
||||
本月充值金额: <span class="layui-badge layui-bg-gray" id="order_this_month_value">-</span>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
上月充值金额: <span
|
||||
class="layui-badge layui-bg-gray">{$order_last_month}</span>
|
||||
上月充值金额: <span class="layui-badge layui-bg-gray" id="order_last_month_value">-</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -199,6 +194,9 @@
|
|||
<div class="layui-card">
|
||||
<div class="layui-card-header" style="text-align:center;background-color: #7C98CB;">
|
||||
今日收入汇总
|
||||
<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" id="refreshProfit" style="float: right;margin-top: 5px;">
|
||||
<i class="layui-icon layui-icon-refresh"></i> 刷新
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 0px;">
|
||||
<table class="layui-table">
|
||||
|
|
@ -238,20 +236,24 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td>利润:</td>
|
||||
<td>{$order_lirun}</td>
|
||||
<td id="profit_value">
|
||||
<div class="layui-progress" lay-filter="profit-loading" style="margin-top: 10px;">
|
||||
<div class="layui-progress-bar layui-bg-blue" lay-percent="0%"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>利润计算方式:</td>
|
||||
<td>收入+其它收入-出货-支出=当日利润</td>
|
||||
<td id="profit_formula">加载中...</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-col-xs6" style="display: none;">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header" style="text-align:center;background-color:darkorange;">
|
||||
今日毛利统计
|
||||
|
|
@ -283,12 +285,81 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增用户数据统计卡片 -->
|
||||
<div class="layui-row" style="margin-top: 15px;">
|
||||
<div class="layui-col-xs6">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header" style="text-align:center;background-color: #1E9FFF;color:#fff;">
|
||||
用户数据统计
|
||||
<button type="button" class="layui-btn layui-btn-xs layui-btn-normal" id="refreshUserStats" style="float: right;margin-top: 5px;">
|
||||
<i class="layui-icon layui-icon-refresh"></i> 刷新
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-card-body" style="padding: 0px;">
|
||||
<div id="userStatsLoading" style="text-align: center; padding: 20px;">
|
||||
<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop" style="font-size: 30px;"></i>
|
||||
<p>正在加载数据...</p>
|
||||
</div>
|
||||
<table class="layui-table" id="userStatsTable" style="display: none;">
|
||||
<colgroup>
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
<col width="25%">
|
||||
</colgroup>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>绑定手机号人数:</td>
|
||||
<td id="user_register_count">-</td>
|
||||
<td>抽奖人数:</td>
|
||||
<td id="consuming_user_count">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>用户剩余钻石:</td>
|
||||
<td id="user_money">-</td>
|
||||
<td>用户剩余UU币:</td>
|
||||
<td id="user_integral">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>用户剩余达达券:</td>
|
||||
<td id="user_money2">-</td>
|
||||
<td>微信支付金额:</td>
|
||||
<td id="order_price_total">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>订单支付数量:</td>
|
||||
<td id="order_total_count">-</td>
|
||||
<td>用户出货总金额:</td>
|
||||
<td id="total_goods_amount">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>用户盒柜剩余价值:</td>
|
||||
<td id="box_remaining_value">-</td>
|
||||
<td>用户已兑换的达达券:</td>
|
||||
<td id="exchanged_coupon">-</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>用户已发货金额:</td>
|
||||
<td id="shipped_amount">-</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{include file="Public:footer"/}
|
||||
<script type="text/javascript">
|
||||
layui.use(['layer', 'laydate', 'table'], function () {
|
||||
layui.use(['layer', 'laydate', 'table', 'element'], function () {
|
||||
var $ = layui.$;
|
||||
var layer = layui.layer;
|
||||
var element = layui.element;
|
||||
//执行一个laydate实例
|
||||
var laydate = layui.laydate;
|
||||
laydate.render({
|
||||
|
|
@ -302,11 +373,147 @@
|
|||
// // , range: true
|
||||
// });
|
||||
|
||||
// 加载用户数据统计
|
||||
function loadUserStatistics() {
|
||||
$('#userStatsTable').hide();
|
||||
$('#userStatsLoading').show();
|
||||
|
||||
$.ajax({
|
||||
url: '{:url("admin/Statistics/getUserStatisticsData")}',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
if (res.code === 0) {
|
||||
// 填充数据
|
||||
$('#user_register_count').text(res.data.user_register_count);
|
||||
$('#consuming_user_count').text(res.data.consuming_user_count);
|
||||
$('#user_money').text(res.data.user_money);
|
||||
$('#user_money2').text(res.data.user_money2);
|
||||
$('#user_integral').text(res.data.user_integral);
|
||||
$('#order_price_total').text(res.data.order_price_total);
|
||||
$('#order_total_count').text(res.data.order_total_count);
|
||||
$('#box_remaining_value').text(res.data.box_remaining_value);
|
||||
$('#exchanged_coupon').text(res.data.exchanged_coupon);
|
||||
$('#shipped_amount').text(res.data.shipped_amount);
|
||||
$('#total_goods_amount').text(res.data.total_goods_amount);
|
||||
|
||||
// 显示表格
|
||||
$('#userStatsLoading').hide();
|
||||
$('#userStatsTable').show();
|
||||
} else {
|
||||
layer.msg('加载数据失败:' + res.msg, {icon: 2});
|
||||
$('#userStatsLoading').html('<p>加载失败,请点击刷新按钮重试</p>');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
layer.msg('服务器连接失败,请稍后再试', {icon: 2});
|
||||
$('#userStatsLoading').html('<p>加载失败,请点击刷新按钮重试</p>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 加载利润数据
|
||||
function loadProfitData() {
|
||||
// 更新进度条
|
||||
element.progress('profit-loading', '30%');
|
||||
|
||||
$.ajax({
|
||||
url: '{:url("admin/Statistics/getProfitData")}',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
if (res.code === 0) {
|
||||
// 填充利润数据
|
||||
element.progress('profit-loading', '100%');
|
||||
setTimeout(function() {
|
||||
$('#profit_value').html('<span style="color:' + (res.data.profit >= 0 ? 'green' : 'red') + ';font-weight:bold;">' + res.data.profit + '</span>');
|
||||
$('#profit_formula').html(res.data.formula);
|
||||
}, 300);
|
||||
} else {
|
||||
layer.msg('加载利润数据失败:' + res.msg, {icon: 2});
|
||||
$('#profit_value').html('<span style="color:red;">加载失败</span>');
|
||||
$('#profit_formula').html('加载失败,请刷新页面重试');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
layer.msg('服务器连接失败,请稍后再试', {icon: 2});
|
||||
$('#profit_value').html('<span style="color:red;">加载失败</span>');
|
||||
$('#profit_formula').html('加载失败,请刷新页面重试');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 加载用户注册数据
|
||||
function loadUserRegisterData() {
|
||||
$('#userRegisterData').hide();
|
||||
$('#userRegisterLoading').show();
|
||||
|
||||
$.ajax({
|
||||
url: '{:url("admin/Statistics/getUserRegisterData")}',
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
if (res.code === 0) {
|
||||
// 填充总注册人数
|
||||
$('#totalUserCount').html('<span style="font-weight:bold;">' + res.data.userCount + '</span>');
|
||||
|
||||
// 填充用户注册数据
|
||||
$('#user_today').text(res.data.user_today);
|
||||
$('#user_yesterday').text(res.data.user_yesterday);
|
||||
$('#user_this_week').text(res.data.user_this_week);
|
||||
$('#user_last_week').text(res.data.user_last_week);
|
||||
$('#user_this_month').text(res.data.user_this_month);
|
||||
$('#user_last_month').text(res.data.user_last_month);
|
||||
|
||||
// 填充充值数据
|
||||
$('#order_today_value').text(res.data.order_today);
|
||||
$('#order_yesterday_value').text(res.data.order_yesterday);
|
||||
$('#order_this_week_value').text(res.data.order_this_week);
|
||||
$('#order_last_week_value').text(res.data.order_last_week);
|
||||
$('#order_this_month_value').text(res.data.order_this_month);
|
||||
$('#order_last_month_value').text(res.data.order_last_month);
|
||||
|
||||
// 显示数据区域
|
||||
$('#userRegisterLoading').hide();
|
||||
$('#userRegisterData').show();
|
||||
} else {
|
||||
layer.msg('加载用户数据失败:' + res.msg, {icon: 2});
|
||||
$('#userRegisterLoading').html('<p>加载失败,请点击刷新按钮重试</p>');
|
||||
$('#totalUserCount').html('<span style="color:red;">加载失败</span>');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
layer.msg('服务器连接失败,请稍后再试', {icon: 2});
|
||||
$('#userRegisterLoading').html('<p>加载失败,请点击刷新按钮重试</p>');
|
||||
$('#totalUserCount').html('<span style="color:red;">加载失败</span>');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 页面加载完成后加载数据
|
||||
loadUserStatistics();
|
||||
loadProfitData();
|
||||
loadUserRegisterData();
|
||||
|
||||
// 刷新按钮点击事件
|
||||
$('#refreshUserStats').on('click', function() {
|
||||
loadUserStatistics();
|
||||
});
|
||||
|
||||
// 刷新利润按钮点击事件
|
||||
$('#refreshProfit').on('click', function() {
|
||||
$('#profit_value').html('<div class="layui-progress" lay-filter="profit-loading" style="margin-top: 10px;"><div class="layui-progress-bar layui-bg-blue" lay-percent="0%"></div></div>');
|
||||
$('#profit_formula').html('加载中...');
|
||||
element.render('progress');
|
||||
loadProfitData();
|
||||
});
|
||||
|
||||
// 刷新用户注册数据按钮点击事件
|
||||
$('#refreshUserRegister').on('click', function() {
|
||||
$('#totalUserCount').html('<i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中...');
|
||||
loadUserRegisterData();
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
|
|||
|
|
@ -1357,7 +1357,6 @@ class Notify extends Base
|
|||
|
||||
$maxRand = (int) ($totalProbability * $multiple);
|
||||
$random = mt_rand(0, $maxRand) / $multiple;
|
||||
|
||||
// 查找中奖奖品
|
||||
$prize_id = null;
|
||||
foreach ($probabilityRanges as $range) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user