PlatformordersController.php
2.7 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace app\admin\controller;
use app\admin\model\RouteModel;
use cmf\controller\AdminBaseController;
use function GuzzleHttp\Psr7\str;
use think\Db;
class PlatformordersController extends AdminBaseController{
/**
* 平台订单列表
*/
public function plat_list(){
if($this -> request -> isPost()){
$where = [
"indent_type" => 1
];
if(!empty($_POST['start_time']) && !empty($_POST['end_time'])){
$start_time = strtotime($_POST['start_time']);
$end_time = strtotime($_POST['end_time']);
$where['create_time'] = [['>=',$start_time],['<=',$end_time]];
}
if(!empty($_POST['keyword'])){
$where['order_number'] = $_POST['keyword'];
}
if(!empty($_POST['state'])){
$where['state'] = $_POST['state'];
}
$data = Db::name('indent') -> where($where) -> paginate(1000000);
$data1 = $data -> toArray();
if(count($data1['data'])!=0){
foreach ($data1['data'] as $key => $val){
$data1['data'][$key]['dizhi'] = Db::name('address') -> where('id',$val['indent_address']) -> find();
}
}
$this -> assign('data1',$data1['data']);
}else{
$data = Db::name('indent') -> where('indent_type','1') -> paginate(12);
$data1 = $data -> toArray();
foreach ($data1['data'] as $key => $val){
$data1['data'][$key]['dizhi'] = Db::name('address') -> where('id',$val['indent_address']) -> find();
}
$this -> assign('data1',$data1['data']);
}
$this -> assign('data',$data);
return $this -> fetch();
}
/**
*平台订单查看
*/
public function plat_view(){
$id = $this -> request -> param();
$indent_id = $id['id'];
$data_goods = Db::name('indent_goods') -> where('indent_id',$indent_id) -> select();
$data_in = Db::name('indent') -> where('id',$indent_id) -> find();
$this -> assign('data_goods',$data_goods);
$this -> assign('data_in',$data_in);
//地址查询
$address = Db::name('address') -> where("id",$data_in['indent_address']) -> find();
if(!empty($address)){
$this -> assign('address',$address);
}else{
$this -> assign('address',null);
}
return $this -> fetch();
}
/**
* 订单删除
*/
public function plat_del(){
$id = $_POST['id'];
Db::name('indent') -> delete($id);
Db::name('indent_goods') -> where('indent_id',$id) -> delete();
return true;
}
}