|
@@ -0,0 +1,500 @@
|
|
1
|
+<?php
|
|
2
|
+/**
|
|
3
|
+ * Created by Sublime.
|
|
4
|
+ * User: hao
|
|
5
|
+ * Date: 19/08/30
|
|
6
|
+ * Time: 上午11:20
|
|
7
|
+ */
|
|
8
|
+namespace App\Http\Controllers\Admin;
|
|
9
|
+
|
|
10
|
+use App\Http\Controllers\Controller;
|
|
11
|
+use App\Logs;
|
|
12
|
+use App\CustTotal;
|
|
13
|
+use App\CustDetail;
|
|
14
|
+use Illuminate\Http\Request;
|
|
15
|
+use Illuminate\Support\Facades\DB;
|
|
16
|
+
|
|
17
|
+class custReportController extends Controller
|
|
18
|
+{
|
|
19
|
+ public function totalindex(Request $request){
|
|
20
|
+ $page = (int)$request->input('page');
|
|
21
|
+ $pageSize = 20;
|
|
22
|
+ if($page<=0){
|
|
23
|
+ $page = 1;
|
|
24
|
+ }
|
|
25
|
+
|
|
26
|
+ $offset = ($page-1) * $pageSize;
|
|
27
|
+
|
|
28
|
+ $stime = $request->input('stime');
|
|
29
|
+ $etime = $request->input('etime');
|
|
30
|
+
|
|
31
|
+ $count = CustTotal::where(function($query) use($stime, $etime){
|
|
32
|
+ if($stime) $query->where('dtime', '>=', $stime);
|
|
33
|
+ if($etime) $query->where('dtime', '<=', $etime);
|
|
34
|
+ })->where('is_del',0)->count();
|
|
35
|
+ if ($count > 1) {
|
|
36
|
+ // 总页数
|
|
37
|
+ $pages = ceil($count/$pageSize);
|
|
38
|
+ }else{
|
|
39
|
+ // 总页数
|
|
40
|
+ $pages = 1;
|
|
41
|
+ }
|
|
42
|
+
|
|
43
|
+ $result = CustTotal::where(function($query) use($stime, $etime){
|
|
44
|
+ if($stime) $query->where('dtime', '>=', $stime);
|
|
45
|
+ if($etime) $query->where('dtime', '<=', $etime);
|
|
46
|
+ })->where('is_del',0)->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
|
|
47
|
+ $result = json_decode(json_encode($result),true);
|
|
48
|
+
|
|
49
|
+ return view('custreport/totallist', ['result' =>$result,
|
|
50
|
+ 'page' =>$page,
|
|
51
|
+ 'count' =>$count,
|
|
52
|
+ 'pages' =>$pages,
|
|
53
|
+ 'stime' =>$stime,
|
|
54
|
+ 'etime' =>$etime,
|
|
55
|
+ ]);
|
|
56
|
+ }
|
|
57
|
+
|
|
58
|
+ /**
|
|
59
|
+ * 添加订单
|
|
60
|
+ * @return \Illuminate\View\View
|
|
61
|
+ */
|
|
62
|
+ public function totalcreate(Request $request)
|
|
63
|
+ {
|
|
64
|
+ return view('custreport/totalcreate');
|
|
65
|
+ }
|
|
66
|
+ /**
|
|
67
|
+ * 分组管理-进行添加操作
|
|
68
|
+ * @param Request $request
|
|
69
|
+ * @return \Illuminate\Http\RedirectResponse
|
|
70
|
+ */
|
|
71
|
+ public function totalstore(Request $request)
|
|
72
|
+ {
|
|
73
|
+ $this->validate($request, [
|
|
74
|
+ 'total_cost' => 'required',
|
|
75
|
+ 'total_fan_add' => 'required',
|
|
76
|
+ 'dtime' => 'required',
|
|
77
|
+ ], [
|
|
78
|
+ 'total_cost.required' => '总成本不能为空',
|
|
79
|
+ 'total_fan_add.required' => '总加粉数不能为空',
|
|
80
|
+ 'dtime.required' => '日期不能为空',
|
|
81
|
+ ]);
|
|
82
|
+ //数据库-新增数据
|
|
83
|
+ $custreport = array();
|
|
84
|
+
|
|
85
|
+ $custreport['total_cost'] = $request->input('total_cost');
|
|
86
|
+ $custreport['total_fan_add'] = $request->input('total_fan_add');
|
|
87
|
+ $custreport['dtime'] = $request->input('dtime');
|
|
88
|
+
|
|
89
|
+ $res = DB::table('cust_day_total')->insert($custreport);
|
|
90
|
+ return redirect('/admin/custreport/totalindex')->with('info', '添加成功');
|
|
91
|
+
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ /**
|
|
95
|
+ * 分组管理-编辑分组界面
|
|
96
|
+ * @param $id
|
|
97
|
+ * @return \Illuminate\View\View
|
|
98
|
+ */
|
|
99
|
+ public function totaledit($id,Request $request)
|
|
100
|
+ {
|
|
101
|
+
|
|
102
|
+ $data = CustTotal::where('id', $id)->first();
|
|
103
|
+ return view('custreport/totaledit', [
|
|
104
|
+ 'custreport' => $data,
|
|
105
|
+ ]);
|
|
106
|
+
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ /**
|
|
110
|
+ * 分组管理-进行编辑操作
|
|
111
|
+ * @param Request $request
|
|
112
|
+ * @return \Illuminate\Http\RedirectResponse
|
|
113
|
+ */
|
|
114
|
+ public function totalupdate(Request $request)
|
|
115
|
+ {
|
|
116
|
+ $this->validate($request, [
|
|
117
|
+ 'id' => 'required',
|
|
118
|
+ 'total_cost' => 'required',
|
|
119
|
+ 'total_fan_add' => 'required',
|
|
120
|
+ 'dtime' => 'required',
|
|
121
|
+ ], [
|
|
122
|
+ 'id.required' => 'id不能为空',
|
|
123
|
+ 'total_cost.required' => '总成本不能为空',
|
|
124
|
+ 'total_fan_add.required' => '总加粉数不能为空',
|
|
125
|
+ 'dtime.required' => '日期不能为空',
|
|
126
|
+ ]);
|
|
127
|
+
|
|
128
|
+ $custreport = array();
|
|
129
|
+ $custreport['total_cost'] = $request->input('total_cost');
|
|
130
|
+ $custreport['total_fan_add'] = $request->input('total_fan_add');
|
|
131
|
+ $custreport['dtime'] = $request->input('dtime');
|
|
132
|
+
|
|
133
|
+ $id = (int)$request->input('id');
|
|
134
|
+ $res = DB::table('cust_day_total')->where('id', $id)->update($custreport);
|
|
135
|
+ return redirect('/admin/custreport/totalindex')->with('info', '更新成功');
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ /**
|
|
139
|
+ * 分组管理-进行删除操作
|
|
140
|
+ * @param Request $request
|
|
141
|
+ * @return \Illuminate\Http\RedirectResponse
|
|
142
|
+ */
|
|
143
|
+ public function totaldelete($id)
|
|
144
|
+ {
|
|
145
|
+ $custreport = CustTotal::find($id);
|
|
146
|
+ $custreport->is_del = 1;
|
|
147
|
+ if ($custreport ->save()){
|
|
148
|
+ return redirect('/admin/custreport/totalindex')->with('info', '删除成功');
|
|
149
|
+ }
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ public function total_export(Request $request){
|
|
153
|
+
|
|
154
|
+ $self_role = session('role_name');
|
|
155
|
+ if($self_role == '超级管理员' || $self_role == '团队主管'){
|
|
156
|
+ $admin_id = $request->input('admin_id');
|
|
157
|
+ }else{
|
|
158
|
+ $admin_id = session('admin_id');
|
|
159
|
+ }
|
|
160
|
+ $stime = $request->input('stime');
|
|
161
|
+ $etime = $request->input('etime');
|
|
162
|
+
|
|
163
|
+ $result = custreport::where(function($query) use($admin_id, $stime, $etime){
|
|
164
|
+ if($admin_id) $query->where('admin_id', $admin_id);
|
|
165
|
+ if($stime) $query->where('createTime', '>=', $stime);
|
|
166
|
+ if($etime) $query->where('createTime', '<=', $etime);
|
|
167
|
+ })->where('is_del',0)->custreportBy('id', 'desc')->get();
|
|
168
|
+ $result = json_decode(json_encode($result),true);
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+ $filename="订单数据.xls";
|
|
172
|
+ header("Content-type:application/vnd.ms-excel");
|
|
173
|
+ Header("Accept-Ranges:bytes");
|
|
174
|
+ Header("Content-Disposition:attachment;filename=".$filename); //$filename导出的文件名
|
|
175
|
+ header("Pragma: no-cache");
|
|
176
|
+ header("Expires: 0");
|
|
177
|
+
|
|
178
|
+ $data_str = '<html xmlns:o="urn:schemas-microsoft-com:office:office"
|
|
179
|
+ xmlns:x="urn:schemas-microsoft-com:office:excel"
|
|
180
|
+ xmlns="http://www.w3.org/TR/REC-html40">
|
|
181
|
+ <head>
|
|
182
|
+ <meta http-equiv="expires" content="Mon, 06 Jan 1999 00:00:01 GMT">
|
|
183
|
+ <meta http-equiv=Content-Type content="text/html; charset=gb2312">
|
|
184
|
+ <!--[if gte mso 9]><xml>
|
|
185
|
+ <x:ExcelWorkbook>
|
|
186
|
+ <x:ExcelWorksheets>
|
|
187
|
+ <x:ExcelWorksheet>
|
|
188
|
+ <x:Name></x:Name>
|
|
189
|
+ <x:WorksheetOptions>
|
|
190
|
+ <x:DisplayGridlines/>
|
|
191
|
+ </x:WorksheetOptions>
|
|
192
|
+ </x:ExcelWorksheet>
|
|
193
|
+ </x:ExcelWorksheets>
|
|
194
|
+ </x:ExcelWorkbook>
|
|
195
|
+ </xml><![endif]-->
|
|
196
|
+ </head>';
|
|
197
|
+
|
|
198
|
+ $data_str .= "
|
|
199
|
+ <table>
|
|
200
|
+ <tr>
|
|
201
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","销售微信号")."</th>
|
|
202
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","销售团队")."</th>
|
|
203
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","销售")."</th>
|
|
204
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","订单时间")."</th>
|
|
205
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","加粉时间")."</th>
|
|
206
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","是否复购")."</th>
|
|
207
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","订单金额")."</th>
|
|
208
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","订单商品")."</th>
|
|
209
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","是否退补单")."</th>
|
|
210
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","配送地址")."</th>
|
|
211
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","配送姓名")."</th>
|
|
212
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","配送电话")."</th>
|
|
213
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","供应商成本")."</th>
|
|
214
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","顺丰单号")."</th>
|
|
215
|
+
|
|
216
|
+ </tr>";
|
|
217
|
+ foreach ($result as $k => $v)
|
|
218
|
+ {
|
|
219
|
+ #销售
|
|
220
|
+ $admin = DB::table('admin')->where('id', $v['admin_id'])->first();
|
|
221
|
+ $v['wx_id'] = isset($admin->wx_id) ? $admin->wx_id : '';
|
|
222
|
+ #team
|
|
223
|
+ $team = DB::table('teams')->where('id', $v['team_id'])->first();
|
|
224
|
+ $v['team_name'] = isset($team->name) ? $team->name : '';
|
|
225
|
+ #加粉时间
|
|
226
|
+ $customr = DB::table('customers')->where('phone', $v['receiverMobile'])->first();
|
|
227
|
+ $v['fanTime'] = isset($customr->fanTime) ? $customr->fanTime : '';
|
|
228
|
+
|
|
229
|
+ $v['receiverMobile'] = substr($v['receiverMobile'], 0, 3).'****'.substr($v['receiverMobile'], 7);
|
|
230
|
+
|
|
231
|
+ $fugou = $v['is_fugou']==1? '是' : '否';
|
|
232
|
+ $is_refund = $v['is_refund']==1? '是' : '否';
|
|
233
|
+ $address = $v['receiverState'].$v['receiverCity'].$v['receiverDistrict'].$v['receiverAddress'];
|
|
234
|
+ $data_str .= "<tr>";
|
|
235
|
+ $data_str .= "<td>".$v['wx_id']."</td>";
|
|
236
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["team_name"])."</td>";
|
|
237
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["admin_name"])."</td>";
|
|
238
|
+ $data_str .= "<td>".$v['createTime']."</td>";
|
|
239
|
+ $data_str .= "<td>".$v['fanTime']."</td>";
|
|
240
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $fugou)."</td>";
|
|
241
|
+ $data_str .= "<td>".$v['receivedAmount']."</td>";
|
|
242
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["goods_note"])."</td>";
|
|
243
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $is_refund)."</td>";
|
|
244
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $address)."</td>";
|
|
245
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["receiverName"])."</td>";
|
|
246
|
+ $data_str .= "<td>".$v['receiverMobile']."</td>";
|
|
247
|
+ $data_str .= "<td>".$v['cost']."</td>";
|
|
248
|
+ $data_str .= "<td style='vnd.ms-excel.numberformat:@'>".$v["logistics_id"]."</td>";
|
|
249
|
+ $data_str .= "</tr>";
|
|
250
|
+ }
|
|
251
|
+
|
|
252
|
+ $data_str .= "</table>";
|
|
253
|
+ echo $data_str;
|
|
254
|
+ exit;
|
|
255
|
+ }
|
|
256
|
+
|
|
257
|
+ public function detailindex(Request $request){
|
|
258
|
+ $page = (int)$request->input('page');
|
|
259
|
+ $pageSize = 20;
|
|
260
|
+ if($page<=0){
|
|
261
|
+ $page = 1;
|
|
262
|
+ }
|
|
263
|
+
|
|
264
|
+ $offset = ($page-1) * $pageSize;
|
|
265
|
+
|
|
266
|
+ $self_role = session('role_name');
|
|
267
|
+ if($self_role == '超级管理员' || $self_role == '团队主管'){
|
|
268
|
+ $admin_id = $request->input('admin_id');
|
|
269
|
+ $search_admin = 1;
|
|
270
|
+ }else{
|
|
271
|
+ $admin_id = session('admin_id');
|
|
272
|
+ $search_admin = 0;
|
|
273
|
+ }
|
|
274
|
+
|
|
275
|
+ $stime = $request->input('stime');
|
|
276
|
+ $etime = $request->input('etime');
|
|
277
|
+
|
|
278
|
+ $count = CustDetail::where(function($query) use($admin_id, $stime, $etime){
|
|
279
|
+ if($admin_id) $query->where('admin_id', $admin_id);
|
|
280
|
+ if($stime) $query->where('dtime', '>=', $stime);
|
|
281
|
+ if($etime) $query->where('dtime', '<=', $etime);
|
|
282
|
+ })->where('is_del',0)->count();
|
|
283
|
+ if ($count > 1) {
|
|
284
|
+ // 总页数
|
|
285
|
+ $pages = ceil($count/$pageSize);
|
|
286
|
+ }else{
|
|
287
|
+ // 总页数
|
|
288
|
+ $pages = 1;
|
|
289
|
+ }
|
|
290
|
+
|
|
291
|
+ $result = CustDetail::where(function($query) use($admin_id, $stime, $etime){
|
|
292
|
+ if($admin_id) $query->where('admin_id', $admin_id);
|
|
293
|
+ if($stime) $query->where('dtime', '>=', $stime);
|
|
294
|
+ if($etime) $query->where('dtime', '<=', $etime);
|
|
295
|
+ })->where('is_del',0)->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
|
|
296
|
+ $result = json_decode(json_encode($result),true);
|
|
297
|
+
|
|
298
|
+ $adminList = DB::table('admin')->select('id', 'realname', 'username')->where('id','>', 1)->get();
|
|
299
|
+ $adminList = json_decode(json_encode($adminList), true);
|
|
300
|
+
|
|
301
|
+ return view('custreport/detaillist', ['result' =>$result,
|
|
302
|
+ 'page' =>$page,
|
|
303
|
+ 'count' =>$count,
|
|
304
|
+ 'pages' =>$pages,
|
|
305
|
+ 'stime' =>$stime,
|
|
306
|
+ 'etime' =>$etime,
|
|
307
|
+ 'admin_id' =>$admin_id,
|
|
308
|
+ 'search_admin' =>$search_admin,
|
|
309
|
+ 'adminlist' =>$adminList,
|
|
310
|
+ ]);
|
|
311
|
+ }
|
|
312
|
+
|
|
313
|
+ /**
|
|
314
|
+ * 添加订单
|
|
315
|
+ * @return \Illuminate\View\View
|
|
316
|
+ */
|
|
317
|
+ public function detailcreate(Request $request)
|
|
318
|
+ {
|
|
319
|
+ return view('custreport/detailcreate');
|
|
320
|
+ }
|
|
321
|
+ /**
|
|
322
|
+ * 分组管理-进行添加操作
|
|
323
|
+ * @param Request $request
|
|
324
|
+ * @return \Illuminate\Http\RedirectResponse
|
|
325
|
+ */
|
|
326
|
+ public function detailstore(Request $request)
|
|
327
|
+ {
|
|
328
|
+ $this->validate($request, [
|
|
329
|
+ 'old_consult' => 'required',
|
|
330
|
+ 'new_consult' => 'required',
|
|
331
|
+ 'fan_add' => 'required',
|
|
332
|
+ 'dtime' => 'required',
|
|
333
|
+ ], [
|
|
334
|
+ 'old_consult.required' => '老粉咨询不能为空',
|
|
335
|
+ 'new_consult.required' => '新粉咨询数不能为空',
|
|
336
|
+ 'fan_add.required' => '加粉数不能为空',
|
|
337
|
+ 'dtime.required' => '日期不能为空',
|
|
338
|
+ ]);
|
|
339
|
+ //数据库-新增数据
|
|
340
|
+ $custreport = array();
|
|
341
|
+
|
|
342
|
+ $custreport['old_consult'] = $request->input('old_consult');
|
|
343
|
+ $custreport['new_consult'] = $request->input('new_consult');
|
|
344
|
+ $custreport['fan_add'] = $request->input('fan_add');
|
|
345
|
+ $custreport['dtime'] = $request->input('dtime');
|
|
346
|
+ $custreport['admin_id'] = session('admin_id');
|
|
347
|
+ $custreport['admin_name'] = session('real_name');
|
|
348
|
+
|
|
349
|
+ $res = DB::table('cust_day_detail')->insert($custreport);
|
|
350
|
+ return redirect('/admin/custreport/detailindex')->with('info', '添加成功');
|
|
351
|
+
|
|
352
|
+ }
|
|
353
|
+
|
|
354
|
+ /**
|
|
355
|
+ * 分组管理-编辑分组界面
|
|
356
|
+ * @param $id
|
|
357
|
+ * @return \Illuminate\View\View
|
|
358
|
+ */
|
|
359
|
+ public function detailedit($id,Request $request)
|
|
360
|
+ {
|
|
361
|
+
|
|
362
|
+ $data = CustDetail::where('id', $id)->first();
|
|
363
|
+ return view('custreport/detailedit', [
|
|
364
|
+ 'custreport' => $data,
|
|
365
|
+ ]);
|
|
366
|
+
|
|
367
|
+ }
|
|
368
|
+
|
|
369
|
+ /**
|
|
370
|
+ * 分组管理-进行编辑操作
|
|
371
|
+ * @param Request $request
|
|
372
|
+ * @return \Illuminate\Http\RedirectResponse
|
|
373
|
+ */
|
|
374
|
+ public function detailupdate(Request $request)
|
|
375
|
+ {
|
|
376
|
+ $this->validate($request, [
|
|
377
|
+ 'id' => 'required',
|
|
378
|
+ 'old_consult' => 'required',
|
|
379
|
+ 'new_consult' => 'required',
|
|
380
|
+ 'fan_add' => 'required',
|
|
381
|
+ 'dtime' => 'required',
|
|
382
|
+ ], [
|
|
383
|
+ 'id.required' => 'id不能为空',
|
|
384
|
+ 'old_consult.required' => '老粉咨询不能为空',
|
|
385
|
+ 'new_consult.required' => '新粉咨询数不能为空',
|
|
386
|
+ 'fan_add.required' => '加粉数不能为空',
|
|
387
|
+ 'dtime.required' => '日期不能为空',
|
|
388
|
+ ]);
|
|
389
|
+ //数据库-新增数据
|
|
390
|
+ $custreport = array();
|
|
391
|
+ $custreport['old_consult'] = $request->input('old_consult');
|
|
392
|
+ $custreport['new_consult'] = $request->input('new_consult');
|
|
393
|
+ $custreport['fan_add'] = $request->input('fan_add');
|
|
394
|
+ $custreport['dtime'] = $request->input('dtime');
|
|
395
|
+
|
|
396
|
+ $id = (int)$request->input('id');
|
|
397
|
+ $res = DB::table('cust_day_detail')->where('id', $id)->update($custreport);
|
|
398
|
+ return redirect('/admin/custreport/detailindex')->with('info', '更新成功');
|
|
399
|
+ }
|
|
400
|
+
|
|
401
|
+ /**
|
|
402
|
+ * 分组管理-进行删除操作
|
|
403
|
+ * @param Request $request
|
|
404
|
+ * @return \Illuminate\Http\RedirectResponse
|
|
405
|
+ */
|
|
406
|
+ public function detaildelete($id)
|
|
407
|
+ {
|
|
408
|
+ $custreport = CustDetail::find($id);
|
|
409
|
+ $custreport->is_del = 1;
|
|
410
|
+ if ($custreport ->save()){
|
|
411
|
+ return redirect('/admin/custreport/detailindex')->with('info', '删除成功');
|
|
412
|
+ }
|
|
413
|
+ }
|
|
414
|
+
|
|
415
|
+ public function detail_export(Request $request){
|
|
416
|
+
|
|
417
|
+ $self_role = session('role_name');
|
|
418
|
+ if($self_role == '超级管理员' || $self_role == '团队主管'){
|
|
419
|
+ $admin_id = $request->input('admin_id');
|
|
420
|
+ }else{
|
|
421
|
+ $admin_id = session('admin_id');
|
|
422
|
+ }
|
|
423
|
+ $stime = $request->input('stime');
|
|
424
|
+ $etime = $request->input('etime');
|
|
425
|
+
|
|
426
|
+ $result = CustDetail::where(function($query) use($admin_id, $stime, $etime){
|
|
427
|
+ if($admin_id) $query->where('admin_id', $admin_id);
|
|
428
|
+ if($stime) $query->where('createTime', '>=', $stime);
|
|
429
|
+ if($etime) $query->where('createTime', '<=', $etime);
|
|
430
|
+ })->where('is_del',0)->orderBy('id', 'desc')->get();
|
|
431
|
+ $result = json_decode(json_encode($result),true);
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+ $filename="粉丝数据分日统计.xls";
|
|
435
|
+ header("Content-type:application/vnd.ms-excel");
|
|
436
|
+ Header("Accept-Ranges:bytes");
|
|
437
|
+ Header("Content-Disposition:attachment;filename=".$filename); //$filename导出的文件名
|
|
438
|
+ header("Pragma: no-cache");
|
|
439
|
+ header("Expires: 0");
|
|
440
|
+
|
|
441
|
+ $data_str = "
|
|
442
|
+ <table>
|
|
443
|
+ <tr>
|
|
444
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","销售微信号")."</th>
|
|
445
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","销售团队")."</th>
|
|
446
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","销售")."</th>
|
|
447
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","订单时间")."</th>
|
|
448
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","加粉时间")."</th>
|
|
449
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","是否复购")."</th>
|
|
450
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","订单金额")."</th>
|
|
451
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","订单商品")."</th>
|
|
452
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","是否退补单")."</th>
|
|
453
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","配送地址")."</th>
|
|
454
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","配送姓名")."</th>
|
|
455
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","配送电话")."</th>
|
|
456
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","供应商成本")."</th>
|
|
457
|
+ <th>".iconv("UTF-8", "GB2312//IGNORE","顺丰单号")."</th>
|
|
458
|
+
|
|
459
|
+ </tr>";
|
|
460
|
+ foreach ($result as $k => $v)
|
|
461
|
+ {
|
|
462
|
+ #销售
|
|
463
|
+ $admin = DB::table('admin')->where('id', $v['admin_id'])->first();
|
|
464
|
+ $v['wx_id'] = isset($admin->wx_id) ? $admin->wx_id : '';
|
|
465
|
+ #team
|
|
466
|
+ $team = DB::table('teams')->where('id', $v['team_id'])->first();
|
|
467
|
+ $v['team_name'] = isset($team->name) ? $team->name : '';
|
|
468
|
+ #加粉时间
|
|
469
|
+ $customr = DB::table('customers')->where('phone', $v['receiverMobile'])->first();
|
|
470
|
+ $v['fanTime'] = isset($customr->fanTime) ? $customr->fanTime : '';
|
|
471
|
+
|
|
472
|
+ $v['receiverMobile'] = substr($v['receiverMobile'], 0, 3).'****'.substr($v['receiverMobile'], 7);
|
|
473
|
+
|
|
474
|
+ $fugou = $v['is_fugou']==1? '是' : '否';
|
|
475
|
+ $is_refund = $v['is_refund']==1? '是' : '否';
|
|
476
|
+ $address = $v['receiverState'].$v['receiverCity'].$v['receiverDistrict'].$v['receiverAddress'];
|
|
477
|
+ $data_str .= "<tr>";
|
|
478
|
+ $data_str .= "<td>".$v['wx_id']."</td>";
|
|
479
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["team_name"])."</td>";
|
|
480
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["admin_name"])."</td>";
|
|
481
|
+ $data_str .= "<td>".$v['createTime']."</td>";
|
|
482
|
+ $data_str .= "<td>".$v['fanTime']."</td>";
|
|
483
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $fugou)."</td>";
|
|
484
|
+ $data_str .= "<td>".$v['receivedAmount']."</td>";
|
|
485
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["goods_note"])."</td>";
|
|
486
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $is_refund)."</td>";
|
|
487
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $address)."</td>";
|
|
488
|
+ $data_str .= "<td>".iconv("UTF-8", "GB2312//IGNORE", $v["receiverName"])."</td>";
|
|
489
|
+ $data_str .= "<td>".$v['receiverMobile']."</td>";
|
|
490
|
+ $data_str .= "<td>".$v['cost']."</td>";
|
|
491
|
+ $data_str .= "<td style='vnd.ms-excel.numberformat:@'>".$v["logistics_id"]."</td>";
|
|
492
|
+ $data_str .= "</tr>";
|
|
493
|
+ }
|
|
494
|
+
|
|
495
|
+ $data_str .= "</table>";
|
|
496
|
+ echo $data_str;
|
|
497
|
+ exit;
|
|
498
|
+ }
|
|
499
|
+}
|
|
500
|
+
|