|
|
@@ -138,4 +138,58 @@ class WechatExternalInterface extends Controller {
|
|
138
|
138
|
|
|
139
|
139
|
return $res;
|
|
140
|
140
|
}
|
|
|
141
|
+ /**
|
|
|
142
|
+ * 微信当月每天数量统计
|
|
|
143
|
+ */
|
|
|
144
|
+ public function countCurrentmonth() {
|
|
|
145
|
+ $begin = date('Y-m-01');
|
|
|
146
|
+ $res = KfCustomerMsg::select(DB::raw('count(*) as num,FROM_UNIXTIME(created_at, \'%e\') as day'))
|
|
|
147
|
+ ->where('app', 0)
|
|
|
148
|
+ ->where('source',0)
|
|
|
149
|
+ ->where('created_at', '>=', strtotime($begin))
|
|
|
150
|
+ ->groupBy('day')
|
|
|
151
|
+ ->pluck('num', 'day');
|
|
|
152
|
+
|
|
|
153
|
+ $d = (int) date('t');
|
|
|
154
|
+ $data = [];
|
|
|
155
|
+ for ($i = 1; $i <= $d; $i++) {
|
|
|
156
|
+ $data[$i] = $res[$i] ?? 0;
|
|
|
157
|
+ }
|
|
|
158
|
+
|
|
|
159
|
+ return $data;
|
|
|
160
|
+ }
|
|
|
161
|
+
|
|
|
162
|
+ /**
|
|
|
163
|
+ * 微信季度数量统计
|
|
|
164
|
+ */
|
|
|
165
|
+ public function countQuarter() {
|
|
|
166
|
+ $begin = date('Y-01-01');
|
|
|
167
|
+ $res = KfCustomerMsg::select(DB::raw('count(*) as num,QUARTER(FROM_UNIXTIME(created_at)) as quarter'))
|
|
|
168
|
+ ->where('app', 0)
|
|
|
169
|
+ ->where('source',0)
|
|
|
170
|
+ ->where('created_at', '>=', strtotime($begin))
|
|
|
171
|
+ ->groupBy('quarter')
|
|
|
172
|
+ ->pluck('num', 'quarter');
|
|
|
173
|
+
|
|
|
174
|
+ $q = 4;
|
|
|
175
|
+ $data = [];
|
|
|
176
|
+ for ($i = 1; $i <= $q; $i++) {
|
|
|
177
|
+ $data[$i] = $res[$i] ?? 0;
|
|
|
178
|
+ }
|
|
|
179
|
+
|
|
|
180
|
+ return $data;
|
|
|
181
|
+ }
|
|
|
182
|
+
|
|
|
183
|
+ /**
|
|
|
184
|
+ * 微信年度数量统计
|
|
|
185
|
+ */
|
|
|
186
|
+ public function countYear() {
|
|
|
187
|
+ $res = KfCustomerMsg::select(DB::raw('count(*) as num,year(FROM_UNIXTIME(created_at)) as year'))
|
|
|
188
|
+ ->where('app', 0)
|
|
|
189
|
+ ->where('source',0)
|
|
|
190
|
+ ->groupBy('year')
|
|
|
191
|
+ ->pluck('num', 'year');
|
|
|
192
|
+
|
|
|
193
|
+ return $res;
|
|
|
194
|
+ }
|
|
141
|
195
|
}
|