SalesOrderController.php
2.9 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* Created by PhpStorm.
* User: 29925
* Date: 2018/8/21
* Time: 11:53
*/
namespace app\user\controller;
use cmf\controller\UserBaseController;
use think\Validate;
class SalesOrderController extends UserBaseController
{
protected $table;
function _initialize()
{
parent::_initialize(); // TODO: Change the autogenerated stub
$this->table = 'OrderSort';
}
/**
* 添加电子订单(选择类型)
*/
public function index() {
$where = [
'delete_time'=>0
];
$list = $this->singleData($this->table,$where,1,['create_time'=>'DESC']);
$this->assign('list',$list);
return $this->fetch();
}
/**
* 添加电子订单(完善内容)
*/
public function detail() {
$sort = $this->request->param('sort');
$where = [
'id' => $sort,
'delete_time'=>0
];
$orderSort = $this->singleData($this->table,$where);
if(!$orderSort) {
$this->error('订单类型错误');
}
$orderSort['options'] = json_decode($orderSort['options'],true);
$this->assign('orderSort',$orderSort);
return $this->fetch();
}
/**
* 提交电子订单
* @param $options 填写的订单内容
*/
public function addOrder() {
if($this->request->isAjax()) {
$data = $this->request->param();
$validate = new Validate([
// 'captcha' => 'require',
'username' => 'require',
'password' => 'require',
]);
$validate->message([
'username.require' => '用户名不能为空',
'password.require' => '密码不能为空',
// 'captcha.require' => '验证码不能为空',
]);
$data = $this->request->post();
if (!$validate->check($data)) {
$this->error($validate->getError());
}
}
}
/**
* 查看已提交订单
*/
public function orders() {
$user_id = cmf_get_current_user_id();
$where = [
'user_id' => $user_id,
'delete_time' => 0
];
$list = $this->singleData('OrderView',$where,2,['create_time'=>'DESC']);
$this->assign('list' ,$list);
return $this->fetch();
}
/**
* 编辑电子订单
* @param $id 电子订单ID
*/
public function edit() {
$id = $this->request->param('id');
if(!$id) {
$this->error('参数错误');
}
$user_id = cmf_get_current_user_id();
$where = [
'user_id' => $user_id,
'delete_time' => 0
];
$orderInfo = $this->singleData('OrderView',$where);
$orderInfo['options'] = json_decode($orderInfo['options'],true);
$this->assign('info',$orderInfo);
return $this->fetch();
}
}