|
|
@@ -234,46 +234,51 @@ class FinanceRepository extends BaseRepository
|
|
234
|
234
|
*/
|
|
235
|
235
|
public function member_overview($mer_id = 0)
|
|
236
|
236
|
{
|
|
237
|
|
- $where = "1=1 ";
|
|
238
|
|
- if ($mer_id) {
|
|
239
|
|
- $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
|
|
240
|
|
- $userRepository = app()->make(UserRepository::class);
|
|
241
|
|
- $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
|
|
242
|
|
- $chilid_userids_string = "1";
|
|
243
|
|
- if (!empty($chilid_userids)) {
|
|
244
|
|
- $chilid_userids_string = implode(',',$chilid_userids);
|
|
245
|
|
- }
|
|
246
|
|
- $where .= "and uid in ({$chilid_userids_string})";
|
|
247
|
|
- }
|
|
248
|
|
- $type = input('type', 1);
|
|
249
|
|
- $day = input('day', '');
|
|
|
237
|
+ $where = " 1=1";
|
|
|
238
|
+ $sWeekWhere = " 1=1";
|
|
|
239
|
+ $weekWhere = " 1=1";
|
|
|
240
|
+ $dayWhere = " 1=1";
|
|
250
|
241
|
|
|
251
|
|
- if ($type == 1 and $day != '') {
|
|
252
|
|
- $where .= " and DATE(create_time) = '" . $day . "'";
|
|
253
|
|
- }
|
|
254
|
|
- if ($type == 2 and $day != '') {
|
|
255
|
|
- $date = new \DateTime($day);
|
|
256
|
|
- $year = $date->format('Y');
|
|
257
|
|
- $month = $date->format('m');
|
|
258
|
|
- $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
|
|
259
|
|
- }
|
|
260
|
|
- $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
|
|
261
|
|
- $dataQuery = array_column($dataQuery, 'count', 'user_group');
|
|
262
|
|
- $shopPartnerCount = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where mer_id={$mer_id} and is_shop_partner=1 group by user_group");
|
|
|
242
|
+ $currentDate = date('Y-m-d');
|
|
|
243
|
+ // 上周的开始日期(周一)
|
|
|
244
|
+ $startDate = date('Y-m-d', strtotime('last Monday', strtotime($currentDate)));
|
|
|
245
|
+ // 上周的结束日期(周日)
|
|
|
246
|
+ $endDate = date('Y-m-d', strtotime('last Sunday', strtotime($currentDate)));
|
|
|
247
|
+
|
|
|
248
|
+ // 获取今天的日期和时间
|
|
|
249
|
+ $today = new \DateTime();
|
|
|
250
|
+ // 计算一周前的日期
|
|
|
251
|
+ $oneWeekAgo = clone $today; // 克隆一个对象,避免修改原始对象
|
|
|
252
|
+ $oneWeekAgo->sub(new \DateInterval('P1W')); // 减去一周
|
|
|
253
|
+
|
|
|
254
|
+ // 格式化日期
|
|
|
255
|
+ $todayFormatted = $today->format('Y-m-d');
|
|
|
256
|
+ $oneWeekAgoFormatted = $oneWeekAgo->format('Y-m-d');
|
|
|
257
|
+ //上周时间条件
|
|
|
258
|
+ $sWeekWhere .= " and DATE(create_time) >= '" . $startDate . "' and DATE(create_time) <= '" . $endDate . "'";
|
|
|
259
|
+ //周时间条件
|
|
|
260
|
+ $weekWhere .= " and DATE(create_time) >= '" . $oneWeekAgoFormatted . "' and DATE(create_time) <= '" . $todayFormatted . "'";
|
|
|
261
|
+ //今日时间条件
|
|
|
262
|
+ $dayWhere .= " and DATE(create_time) = '" . $todayFormatted . "'";
|
|
263
|
263
|
|
|
264
|
|
- $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
|
|
265
|
|
- $maker = array_column($maker, 'count', 'k');
|
|
266
|
264
|
|
|
267
|
|
- $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
|
|
268
|
|
- $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
|
|
|
265
|
+ $userCount = Db::name('user')->where($where)->count();
|
|
|
266
|
+ $userDayCount = Db::name('user')->where($dayWhere)->count();
|
|
|
267
|
+ $userDjCount = Db::name('user')->where($where)->where('status', 0)->count();
|
|
269
|
268
|
|
|
270
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员总人数'];
|
|
271
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增会员'];
|
|
272
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '被冻结会员数'];
|
|
273
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区总业绩'];
|
|
274
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区上周总业绩'];
|
|
275
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区本周总业绩'];
|
|
276
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员专区今日总业绩'];
|
|
|
269
|
+ // 会员专区业绩
|
|
|
270
|
+ $chengjiaomoney = Db::name('store_order')->where($where)->where('paid', 1)->where('mer_id', 496)->sum('pay_price');
|
|
|
271
|
+ $sWeekCount = Db::name('store_order')->where($sWeekWhere)->where('paid', 1)->where('mer_id', 496)->sum('pay_price');
|
|
|
272
|
+ $weekCount = Db::name('store_order')->where($weekWhere)->where('paid', 1)->where('mer_id', 496)->sum('pay_price');
|
|
|
273
|
+ $todayCount = Db::name('store_order')->where($dayWhere)->where('paid', 1)->where('mer_id', 496)->sum('pay_price');
|
|
|
274
|
+
|
|
|
275
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $userCount, 'name' => '会员总人数'];
|
|
|
276
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $userDayCount, 'name' => '今日新增会员'];
|
|
|
277
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $userDjCount, 'name' => '被冻结会员数'];
|
|
|
278
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $chengjiaomoney, 'name' => '会员专区总业绩'];
|
|
|
279
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $sWeekCount, 'name' => '会员专区上周总业绩'];
|
|
|
280
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $weekCount, 'name' => '会员专区本周总业绩'];
|
|
|
281
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $todayCount, 'name' => '会员专区今日总业绩'];
|
|
277
|
282
|
|
|
278
|
283
|
$res['left'][] = $data;
|
|
279
|
284
|
return $res;
|
|
|
@@ -291,41 +296,42 @@ class FinanceRepository extends BaseRepository
|
|
291
|
296
|
public function pv_overview($mer_id = 0)
|
|
292
|
297
|
{
|
|
293
|
298
|
$where = "1=1 ";
|
|
294
|
|
- if ($mer_id) {
|
|
295
|
|
- $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
|
|
296
|
|
- $userRepository = app()->make(UserRepository::class);
|
|
297
|
|
- $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
|
|
298
|
|
- $chilid_userids_string = "1";
|
|
299
|
|
- if (!empty($chilid_userids)) {
|
|
300
|
|
- $chilid_userids_string = implode(',',$chilid_userids);
|
|
301
|
|
- }
|
|
302
|
|
- $where .= "and uid in ({$chilid_userids_string})";
|
|
303
|
|
- }
|
|
304
|
|
- $type = input('type', 1);
|
|
305
|
|
- $day = input('day', '');
|
|
|
299
|
+ $sWeekWhere = " 1=1";
|
|
|
300
|
+ $weekWhere = " 1=1";
|
|
|
301
|
+ $dayWhere = " 1=1";
|
|
|
302
|
+
|
|
|
303
|
+ $currentDate = date('Y-m-d');
|
|
|
304
|
+ // 上周的开始日期(周一)
|
|
|
305
|
+ $startDate = date('Y-m-d', strtotime('last Monday', strtotime($currentDate)));
|
|
|
306
|
+ // 上周的结束日期(周日)
|
|
|
307
|
+ $endDate = date('Y-m-d', strtotime('last Sunday', strtotime($currentDate)));
|
|
306
|
308
|
|
|
307
|
|
- if ($type == 1 and $day != '') {
|
|
308
|
|
- $where .= " and DATE(create_time) = '" . $day . "'";
|
|
309
|
|
- }
|
|
310
|
|
- if ($type == 2 and $day != '') {
|
|
311
|
|
- $date = new \DateTime($day);
|
|
312
|
|
- $year = $date->format('Y');
|
|
313
|
|
- $month = $date->format('m');
|
|
314
|
|
- $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
|
|
315
|
|
- }
|
|
316
|
|
- $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
|
|
317
|
|
- $dataQuery = array_column($dataQuery, 'count', 'user_group');
|
|
|
309
|
+ // 获取今天的日期和时间
|
|
|
310
|
+ $today = new \DateTime();
|
|
|
311
|
+ // 计算一周前的日期
|
|
|
312
|
+ $oneWeekAgo = clone $today; // 克隆一个对象,避免修改原始对象
|
|
|
313
|
+ $oneWeekAgo->sub(new \DateInterval('P1W')); // 减去一周
|
|
|
314
|
+
|
|
|
315
|
+ // 格式化日期
|
|
|
316
|
+ $todayFormatted = $today->format('Y-m-d');
|
|
|
317
|
+ $oneWeekAgoFormatted = $oneWeekAgo->format('Y-m-d');
|
|
|
318
|
+ //上周时间条件
|
|
|
319
|
+ $sWeekWhere .= " and DATE(addtime) >= '" . $startDate . "' and DATE(addtime) <= '" . $endDate . "'";
|
|
|
320
|
+ //周时间条件
|
|
|
321
|
+ $weekWhere .= " and DATE(addtime) >= '" . $oneWeekAgoFormatted . "' and DATE(addtime) <= '" . $todayFormatted . "'";
|
|
|
322
|
+ //今日时间条件
|
|
|
323
|
+ $dayWhere .= " and DATE(addtime) = '" . $todayFormatted . "'";
|
|
318
|
324
|
|
|
319
|
|
- $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
|
|
320
|
|
- $maker = array_column($maker, 'count', 'k');
|
|
321
|
325
|
|
|
322
|
|
- $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
|
|
323
|
|
- $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
|
|
|
326
|
+ $pvCount = Db::name('user_pv_log')->where($where)->sum('pv');
|
|
|
327
|
+ // $pvCunCount = Db::name('user_pv_log')->where($where)->where('mer_id', 496)->sum('pv');
|
|
|
328
|
+ $weekCount = Db::name('user_pv_log')->where($weekWhere)->sum('pv');
|
|
|
329
|
+ $todayCount = Db::name('user_pv_log')->where($dayWhere)->sum('pv');
|
|
324
|
330
|
|
|
325
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '平台总PV'];
|
|
326
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员存量总PV'];
|
|
327
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周新增PV总量'];
|
|
328
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增PV总量'];
|
|
|
331
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $pvCount, 'name' => '平台总PV'];
|
|
|
332
|
+ // $data[] = ['className' => 'el-icon-s-goods', 'count' => $pvCunCount, 'name' => '会员存量总PV'];
|
|
|
333
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $weekCount, 'name' => '本周新增PV总量'];
|
|
|
334
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $todayCount, 'name' => '今日新增PV总量'];
|
|
329
|
335
|
|
|
330
|
336
|
$res['left'][] = $data;
|
|
331
|
337
|
return $res;
|
|
|
@@ -343,44 +349,47 @@ class FinanceRepository extends BaseRepository
|
|
343
|
349
|
public function vr_overview($mer_id = 0)
|
|
344
|
350
|
{
|
|
345
|
351
|
$where = "1=1 ";
|
|
346
|
|
- if ($mer_id) {
|
|
347
|
|
- $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
|
|
348
|
|
- $userRepository = app()->make(UserRepository::class);
|
|
349
|
|
- $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
|
|
350
|
|
- $chilid_userids_string = "1";
|
|
351
|
|
- if (!empty($chilid_userids)) {
|
|
352
|
|
- $chilid_userids_string = implode(',',$chilid_userids);
|
|
353
|
|
- }
|
|
354
|
|
- $where .= "and uid in ({$chilid_userids_string})";
|
|
355
|
|
- }
|
|
356
|
|
- $type = input('type', 1);
|
|
357
|
|
- $day = input('day', '');
|
|
|
352
|
+ $sWeekWhere = " 1=1";
|
|
|
353
|
+ $weekWhere = " 1=1";
|
|
|
354
|
+ $dayWhere = " 1=1";
|
|
|
355
|
+
|
|
|
356
|
+ $currentDate = date('Y-m-d');
|
|
|
357
|
+ // 上周的开始日期(周一)
|
|
|
358
|
+ $startDate = date('Y-m-d', strtotime('last Monday', strtotime($currentDate)));
|
|
|
359
|
+ // 上周的结束日期(周日)
|
|
|
360
|
+ $endDate = date('Y-m-d', strtotime('last Sunday', strtotime($currentDate)));
|
|
358
|
361
|
|
|
359
|
|
- if ($type == 1 and $day != '') {
|
|
360
|
|
- $where .= " and DATE(create_time) = '" . $day . "'";
|
|
361
|
|
- }
|
|
362
|
|
- if ($type == 2 and $day != '') {
|
|
363
|
|
- $date = new \DateTime($day);
|
|
364
|
|
- $year = $date->format('Y');
|
|
365
|
|
- $month = $date->format('m');
|
|
366
|
|
- $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
|
|
367
|
|
- }
|
|
368
|
|
- $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
|
|
369
|
|
- $dataQuery = array_column($dataQuery, 'count', 'user_group');
|
|
370
|
|
-
|
|
371
|
|
- $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
|
|
372
|
|
- $maker = array_column($maker, 'count', 'k');
|
|
373
|
|
-
|
|
374
|
|
- $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
|
|
375
|
|
- $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
|
|
376
|
|
-
|
|
377
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '平台总VR'];
|
|
378
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员存量总VR'];
|
|
379
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周新增VR总量'];
|
|
380
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增VR总量'];
|
|
381
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员消耗总VR'];
|
|
382
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周消耗VR总量'];
|
|
383
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日消耗VR总量'];
|
|
|
362
|
+ // 获取今天的日期和时间
|
|
|
363
|
+ $today = new \DateTime();
|
|
|
364
|
+ // 计算一周前的日期
|
|
|
365
|
+ $oneWeekAgo = clone $today; // 克隆一个对象,避免修改原始对象
|
|
|
366
|
+ $oneWeekAgo->sub(new \DateInterval('P1W')); // 减去一周
|
|
|
367
|
+
|
|
|
368
|
+ // 格式化日期
|
|
|
369
|
+ $todayFormatted = $today->format('Y-m-d');
|
|
|
370
|
+ $oneWeekAgoFormatted = $oneWeekAgo->format('Y-m-d');
|
|
|
371
|
+ //上周时间条件
|
|
|
372
|
+ $sWeekWhere .= " and DATE(addtime) >= '" . $startDate . "' and DATE(addtime) <= '" . $endDate . "'";
|
|
|
373
|
+ //周时间条件
|
|
|
374
|
+ $weekWhere .= " and DATE(addtime) >= '" . $oneWeekAgoFormatted . "' and DATE(addtime) <= '" . $todayFormatted . "'";
|
|
|
375
|
+ //今日时间条件
|
|
|
376
|
+ $dayWhere .= " and DATE(addtime) = '" . $todayFormatted . "'";
|
|
|
377
|
+
|
|
|
378
|
+ $vrCount = Db::name('user_sign_vr')->where($where)->sum('number');
|
|
|
379
|
+ $vrUserCount = Db::name('user')->where($where)->sum('vr');
|
|
|
380
|
+ $vrWeekCount = Db::name('user_sign_vr')->where($weekWhere)->where('type', 1)->sum('number');
|
|
|
381
|
+ $vrDayCount = Db::name('user_sign_vr')->where($dayWhere)->where('type', 1)->sum('number');
|
|
|
382
|
+ $vrXhCount = Db::name('user_sign_vr')->where($where)->where('type', 2)->sum('number');
|
|
|
383
|
+ $vrWeekXhCount = Db::name('user_sign_vr')->where($weekWhere)->where('type', 2)->sum('number');
|
|
|
384
|
+ $vrDayXhCount = Db::name('user_sign_vr')->where($dayWhere)->where('type', 2)->sum('number');
|
|
|
385
|
+
|
|
|
386
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $vrCount, 'name' => '平台总VR'];
|
|
|
387
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $vrUserCount, 'name' => '会员存量总VR'];
|
|
|
388
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $vrWeekCount, 'name' => '本周新增VR总量'];
|
|
|
389
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $vrDayCount, 'name' => '今日新增VR总量'];
|
|
|
390
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $vrXhCount, 'name' => '会员消耗总VR'];
|
|
|
391
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $vrWeekXhCount, 'name' => '本周消耗VR总量'];
|
|
|
392
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $vrDayXhCount, 'name' => '今日消耗VR总量'];
|
|
384
|
393
|
|
|
385
|
394
|
$res['left'][] = $data;
|
|
386
|
395
|
return $res;
|
|
|
@@ -397,48 +406,49 @@ class FinanceRepository extends BaseRepository
|
|
397
|
406
|
public function jifen_overview($mer_id = 0)
|
|
398
|
407
|
{
|
|
399
|
408
|
$where = "1=1 ";
|
|
400
|
|
- if ($mer_id) {
|
|
401
|
|
- $mer_uid = Db::name('merchant')->where('mer_id', $mer_id)->value('uid');
|
|
402
|
|
- $userRepository = app()->make(UserRepository::class);
|
|
403
|
|
- $chilid_userids = $userRepository->getSpreadUidBreak($mer_uid);
|
|
404
|
|
- $chilid_userids_string = "1";
|
|
405
|
|
- if (!empty($chilid_userids)) {
|
|
406
|
|
- $chilid_userids_string = implode(',',$chilid_userids);
|
|
407
|
|
- }
|
|
408
|
|
- $where .= "and uid in ({$chilid_userids_string})";
|
|
409
|
|
- }
|
|
410
|
|
- $type = input('type', 1);
|
|
411
|
|
- $day = input('day', '');
|
|
412
|
|
-
|
|
413
|
|
- if ($type == 1 and $day != '') {
|
|
414
|
|
- $where .= " and DATE(create_time) = '" . $day . "'";
|
|
415
|
|
- }
|
|
416
|
|
- if ($type == 2 and $day != '') {
|
|
417
|
|
- $date = new \DateTime($day);
|
|
418
|
|
- $year = $date->format('Y');
|
|
419
|
|
- $month = $date->format('m');
|
|
420
|
|
- $where .= " and YEAR(create_time) = " . $year . " AND MONTH(create_time) = " . $month;
|
|
421
|
|
- }
|
|
422
|
|
- $dataQuery = Db::query("SELECT user_group,count(uid) count FROM `rrx_user` where {$where} group by user_group");
|
|
423
|
|
- $dataQuery = array_column($dataQuery, 'count', 'user_group');
|
|
424
|
|
-
|
|
425
|
|
- $maker = Db::query("SELECT CONCAT(`user_group`, '-',`is_show`) as k, count(uid) count FROM `rrx_user` where {$where} group by user_group,is_show");
|
|
426
|
|
- $maker = array_column($maker, 'count', 'k');
|
|
427
|
|
-
|
|
428
|
|
- $userByCodeCount = Db::query("SELECT 'temp' as `temp1`, count(*) count FROM `rrx_user` where {$where} and user_group =4 and is_show = 3");
|
|
429
|
|
- $userByCodeCount = array_column($userByCodeCount, 'count', 'temp1');
|
|
430
|
|
-
|
|
431
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '平台总积分'];
|
|
432
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员存量总积分'];
|
|
433
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周新增积分总量'];
|
|
434
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日新增积分总量'];
|
|
435
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '会员消耗总积分'];
|
|
436
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '本周消耗积分总量'];
|
|
437
|
|
- $data[] = ['className' => 'el-icon-s-goods', 'count' => 0, 'name' => '今日消耗积分总量'];
|
|
|
409
|
+ $sWeekWhere = " 1=1";
|
|
|
410
|
+ $weekWhere = " 1=1";
|
|
|
411
|
+ $dayWhere = " 1=1";
|
|
|
412
|
+
|
|
|
413
|
+ $currentDate = date('Y-m-d');
|
|
|
414
|
+ // 上周的开始日期(周一)
|
|
|
415
|
+ $startDate = date('Y-m-d', strtotime('last Monday', strtotime($currentDate)));
|
|
|
416
|
+ // 上周的结束日期(周日)
|
|
|
417
|
+ $endDate = date('Y-m-d', strtotime('last Sunday', strtotime($currentDate)));
|
|
438
|
418
|
|
|
|
419
|
+ // 获取今天的日期和时间
|
|
|
420
|
+ $today = new \DateTime();
|
|
|
421
|
+ // 计算一周前的日期
|
|
|
422
|
+ $oneWeekAgo = clone $today; // 克隆一个对象,避免修改原始对象
|
|
|
423
|
+ $oneWeekAgo->sub(new \DateInterval('P1W')); // 减去一周
|
|
|
424
|
+
|
|
|
425
|
+ // 格式化日期
|
|
|
426
|
+ $todayFormatted = $today->format('Y-m-d');
|
|
|
427
|
+ $oneWeekAgoFormatted = $oneWeekAgo->format('Y-m-d');
|
|
|
428
|
+ //上周时间条件
|
|
|
429
|
+ $sWeekWhere .= " and DATE(addtime) >= '" . $startDate . "' and DATE(addtime) <= '" . $endDate . "'";
|
|
|
430
|
+ //周时间条件
|
|
|
431
|
+ $weekWhere .= " and DATE(addtime) >= '" . $oneWeekAgoFormatted . "' and DATE(addtime) <= '" . $todayFormatted . "'";
|
|
|
432
|
+ //今日时间条件
|
|
|
433
|
+ $dayWhere .= " and DATE(addtime) = '" . $todayFormatted . "'";
|
|
|
434
|
+
|
|
|
435
|
+ $jfCount = Db::name('user_sign_score')->where($where)->sum('reward_socre');
|
|
|
436
|
+ $jfUserCount = Db::name('user')->where($where)->sum('score');
|
|
|
437
|
+ $jfWeekCount = Db::name('user_sign_score')->where($weekWhere)->where('pm', 1)->sum('reward_socre');
|
|
|
438
|
+ $jfDayCount = Db::name('user_sign_score')->where($dayWhere)->where('pm', 1)->sum('reward_socre');
|
|
|
439
|
+ $jfXhCount = Db::name('user_sign_score')->where($where)->where('pm', 2)->sum('reward_socre');
|
|
|
440
|
+ $jfWeekXhCount = Db::name('user_sign_score')->where($weekWhere)->where('pm', 2)->sum('reward_socre');
|
|
|
441
|
+ $jfDayXhCount = Db::name('user_sign_score')->where($dayWhere)->where('pm', 2)->sum('reward_socre');
|
|
|
442
|
+
|
|
|
443
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $jfCount, 'name' => '平台总积分'];
|
|
|
444
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $jfUserCount, 'name' => '会员存量总积分'];
|
|
|
445
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $jfWeekCount, 'name' => '本周新增积分总量'];
|
|
|
446
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $jfDayCount, 'name' => '今日新增积分总量'];
|
|
|
447
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $jfXhCount, 'name' => '会员消耗总积分'];
|
|
|
448
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $jfWeekXhCount, 'name' => '本周消耗积分总量'];
|
|
|
449
|
+ $data[] = ['className' => 'el-icon-s-goods', 'count' => $jfDayXhCount, 'name' => '今日消耗积分总量'];
|
|
439
|
450
|
|
|
440
|
451
|
$res['left'][] = $data;
|
|
441
|
|
-
|
|
442
|
452
|
return $res;
|
|
443
|
453
|
}
|
|
444
|
454
|
|