Passed
Push — master ( ac4b8f...c56f2f )
by Carlos
02:39
created

Client::memberCardSummaryById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 7
ccs 0
cts 6
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\OfficialAccount\DataCube;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author overtrue <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * 获取用户增减数据.
25
     *
26
     * @param string $from
27
     * @param string $to
28
     *
29
     * @return mixed
30
     */
31
    public function userSummary(string $from, string $to)
32
    {
33
        return $this->query('datacube/getusersummary', $from, $to);
34
    }
35
36
    /**
37
     * 获取累计用户数据.
38
     *
39
     * @param string $from
40
     * @param string $to
41
     *
42
     * @return mixed
43
     */
44
    public function userCumulate(string $from, string $to)
45
    {
46
        return $this->query('datacube/getusercumulate', $from, $to);
47
    }
48
49
    /**
50
     * 获取图文群发每日数据.
51
     *
52
     * @param string $from
53
     * @param string $to
54
     *
55
     * @return mixed
56
     */
57
    public function articleSummary(string $from, string $to)
58
    {
59
        return $this->query('datacube/getarticlesummary', $from, $to);
60
    }
61
62
    /**
63
     * 获取图文群发总数据.
64
     *
65
     * @param string $from
66
     * @param string $to
67
     *
68
     * @return mixed
69
     */
70
    public function articleTotal(string $from, string $to)
71
    {
72
        return $this->query('datacube/getarticletotal', $from, $to);
73
    }
74
75
    /**
76
     * 获取图文统计数据.
77
     *
78
     * @param string $from
79
     * @param string $to
80
     *
81
     * @return mixed
82
     */
83
    public function userReadSummary(string $from, string $to)
84
    {
85
        return $this->query('datacube/getuserread', $from, $to);
86
    }
87
88
    /**
89
     * 获取图文统计分时数据.
90
     *
91
     * @param string $from
92
     * @param string $to
93
     *
94
     * @return mixed
95
     */
96
    public function userReadHourly(string $from, string $to)
97
    {
98
        return $this->query('datacube/getuserreadhour', $from, $to);
99
    }
100
101
    /**
102
     * 获取图文分享转发数据.
103
     *
104
     * @param string $from
105
     * @param string $to
106
     *
107
     * @return mixed
108
     */
109
    public function userShareSummary(string $from, string $to)
110
    {
111
        return $this->query('datacube/getusershare', $from, $to);
112
    }
113
114
    /**
115
     * 获取图文分享转发分时数据.
116
     *
117
     * @param string $from
118
     * @param string $to
119
     *
120
     * @return mixed
121
     */
122
    public function userShareHourly(string $from, string $to)
123
    {
124
        return $this->query('datacube/getusersharehour', $from, $to);
125
    }
126
127
    /**
128
     * 获取消息发送概况数据.
129
     *
130
     * @param string $from
131
     * @param string $to
132
     *
133
     * @return mixed
134
     */
135
    public function upstreamMessageSummary(string $from, string $to)
136
    {
137
        return $this->query('datacube/getupstreammsg', $from, $to);
138
    }
139
140
    /**
141
     * 获取消息分送分时数据.
142
     *
143
     * @param string $from
144
     * @param string $to
145
     *
146
     * @return mixed
147
     */
148
    public function upstreamMessageHourly(string $from, string $to)
149
    {
150
        return $this->query('datacube/getupstreammsghour', $from, $to);
151
    }
152
153
    /**
154
     * 获取消息发送周数据.
155
     *
156
     * @param string $from
157
     * @param string $to
158
     *
159
     * @return mixed
160
     */
161
    public function upstreamMessageWeekly(string $from, string $to)
162
    {
163
        return $this->query('datacube/getupstreammsgweek', $from, $to);
164
    }
165
166
    /**
167
     * 获取消息发送月数据.
168
     *
169
     * @param string $from
170
     * @param string $to
171
     *
172
     * @return mixed
173
     */
174
    public function upstreamMessageMonthly(string $from, string $to)
175
    {
176
        return $this->query('datacube/getupstreammsgmonth', $from, $to);
177
    }
178
179
    /**
180
     * 获取消息发送分布数据.
181
     *
182
     * @param string $from
183
     * @param string $to
184
     *
185
     * @return mixed
186
     */
187
    public function upstreamMessageDistSummary(string $from, string $to)
188
    {
189
        return $this->query('datacube/getupstreammsgdist', $from, $to);
190
    }
191
192
    /**
193
     * 获取消息发送分布周数据.
194
     *
195
     * @param string $from
196
     * @param string $to
197
     *
198
     * @return mixed
199
     */
200
    public function upstreamMessageDistWeekly(string $from, string $to)
201
    {
202
        return $this->query('datacube/getupstreammsgdistweek', $from, $to);
203
    }
204
205
    /**
206
     * 获取消息发送分布月数据.
207
     *
208
     * @param string $from
209
     * @param string $to
210
     *
211
     * @return mixed
212
     */
213
    public function upstreamMessageDistMonthly(string $from, string $to)
214
    {
215
        return $this->query('datacube/getupstreammsgdistmonth', $from, $to);
216
    }
217
218
    /**
219
     * 获取接口分析数据.
220
     *
221
     * @param string $from
222
     * @param string $to
223
     *
224
     * @return mixed
225
     */
226
    public function interfaceSummary(string $from, string $to)
227
    {
228
        return $this->query('datacube/getinterfacesummary', $from, $to);
229
    }
230
231
    /**
232
     * 获取接口分析分时数据.
233
     *
234
     * @param string $from
235
     * @param string $to
236
     *
237
     * @return mixed
238
     */
239
    public function interfaceSummaryHourly(string $from, string $to)
240
    {
241
        return $this->query('datacube/getinterfacesummaryhour', $from, $to);
242
    }
243
244
    /**
245
     * 拉取卡券概况数据接口.
246
     *
247
     * @param string $from
248
     * @param string $to
249
     * @param int    $condSource
250
     *
251
     * @return mixed
252
     */
253
    public function cardSummary(string $from, string $to, $condSource = 0)
254
    {
255
        $ext = [
256
            'cond_source' => intval($condSource),
257
        ];
258
259
        return $this->query('datacube/getcardbizuininfo', $from, $to, $ext);
260
    }
261
262
    /**
263
     * 获取免费券数据接口.
264
     *
265
     * @param string $from
266
     * @param string $to
267
     * @param int    $condSource
268
     * @param string $cardId
269
     *
270
     * @return mixed
271
     */
272
    public function freeCardSummary(string $from, string $to, int $condSource = 0, string $cardId = '')
273
    {
274
        $ext = [
275
            'cond_source' => intval($condSource),
276
            'card_id' => $cardId,
277
        ];
278
279
        return $this->query('datacube/getcardcardinfo', $from, $to, $ext);
280
    }
281
282
    /**
283
     * 拉取会员卡数据接口.
284
     *
285
     * @param string $from
286
     * @param string $to
287
     * @param int    $condSource
288
     *
289
     * @return mixed
290
     */
291
    public function memberCardSummary(string $from, string $to, $condSource = 0)
292
    {
293
        $ext = [
294
            'cond_source' => intval($condSource),
295
        ];
296
297
        return $this->query('datacube/getcardmembercardinfo', $from, $to, $ext);
298
    }
299
300
    /**
301
     * 拉取单张会员卡数据接口.
302
     *
303
     * @param string $from
304
     * @param string $to
305
     * @param string $cardId
306
     *
307
     * @return mixed
308
     */
309
    public function memberCardSummaryById(string $from, string $to, string $cardId)
310
    {
311
        $ext = [
312
            'card_id' => $cardId,
313
        ];
314
315
        return $this->query('datacube/getcardmembercarddetail', $from, $to, $ext);
316
    }
317
318
    /**
319
     * 查询数据.
320
     *
321
     * @param string $api
322
     * @param string $from
323
     * @param string $to
324
     * @param array  $ext
325
     *
326
     * @return mixed
327
     */
328
    protected function query(string $api, string $from, string $to, array $ext = [])
329
    {
330
        $params = array_merge([
331
            'begin_date' => $from,
332
            'end_date' => $to,
333
        ], $ext);
334
335
        return $this->httpPostJson($api, $params);
336
    }
337
}
338