1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
| <?php
|
| namespace app\shop\service\statistics;
|
| use app\shop\model\branch\Branch as BranchModel;
|
| /**
| * 分会数据概况
| */
| class BranchService
| {
| /**
| * 获取数据概况
| */
| public function getData()
| {
| $today = date('Y-m-d');
| $yesterday = date('Y-m-d', strtotime('-1 day'));
| $data = [
| // 累积分会数
| 'branch_total' => [
| 'today' => number_format($this->getBranchData(null, $today, 'branch_total')),
| 'yesterday' => number_format($this->getBranchData(null, $yesterday, 'branch_total'))
| ],
| // 新增分会数
| 'branch_add' => [
| 'today' => number_format($this->getBranchData($today, null, 'branch_add')),
| 'yesterday' => number_format($this->getBranchData($yesterday, null, 'user_add'))
| ],
| // 新申请分会数
| 'branch_apply' => [
| 'today' => number_format($this->getBranchApplyData($today, null, 'apply_total')),
| 'yesterday' => number_format($this->getBranchApplyData($yesterday, null, 'apply_total'))
| ],
| ];
| return $data;
| }
|
| /**
| * 通过时间段查询用户数据
| */
| public function getDataByDate($days)
| {
| $data = [];
| foreach ($days as $day) {
| $data[] = [
| 'day' => $day,
| 'new_num' => $this->getBranchData($day, null, 'branch_add'),
| ];
| }
| return $data;
| }
| /**
| * 获取用户数据
| */
| private function getBranchData($startDate = null, $endDate = null, $type)
| {
| return (new BranchModel)->getBranchData($startDate, $endDate, $type);
| }
|
| private function getBranchApplyData($startDate = null, $endDate = null, $type){
| return (new BranchApplyModel)->getApplyData($startDate, $endDate, $type);
| }
| /**
| * 获取订单数据
| */
| private function getDepositRefundData($startDate = null, $endDate = null, $type)
| {
| return (new DepositRefundModel())->getRefundData($startDate, $endDate, $type);
| }
| }
|
|