正在显示
4 个修改的文件
包含
89 行增加
和
49 行删除
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace app\admin\controller; | 3 | namespace app\admin\controller; |
4 | 4 | ||
5 | use app\common\controller\Backend; | 5 | use app\common\controller\Backend; |
6 | +use fast\Random; | ||
6 | 7 | ||
7 | /** | 8 | /** |
8 | * | 9 | * |
@@ -44,6 +45,9 @@ class Order extends Backend | @@ -44,6 +45,9 @@ class Order extends Backend | ||
44 | */ | 45 | */ |
45 | public function index($ids = NULL) | 46 | public function index($ids = NULL) |
46 | { | 47 | { |
48 | + if($ids){ | ||
49 | + $this->assign("user_id", $ids); | ||
50 | + } | ||
47 | 51 | ||
48 | if($ids){ | 52 | if($ids){ |
49 | $this->assign("user_id", $ids); | 53 | $this->assign("user_id", $ids); |
@@ -95,4 +99,71 @@ class Order extends Backend | @@ -95,4 +99,71 @@ class Order extends Backend | ||
95 | return $this->view->fetch(); | 99 | return $this->view->fetch(); |
96 | } | 100 | } |
97 | 101 | ||
102 | + | ||
103 | + /** | ||
104 | + * 添加 | ||
105 | + */ | ||
106 | + public function add($ids = NULL) | ||
107 | + { | ||
108 | + | ||
109 | + if($ids){ | ||
110 | + $this->assign("user_id", $ids); | ||
111 | + } | ||
112 | + | ||
113 | + if ($this->request->isPost()) { | ||
114 | + $params = $this->request->post("row/a"); | ||
115 | + if ($params) { | ||
116 | + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { | ||
117 | + $params[$this->dataLimitField] = $this->auth->id; | ||
118 | + } | ||
119 | + | ||
120 | + $product = new \app\admin\model\Product(); | ||
121 | + $product = $product->where(['id'=>$params['product_id']])->find(); | ||
122 | + if(empty($product)){ | ||
123 | + $this->error($this->model->getError()); | ||
124 | + } | ||
125 | + $product = $product->toArray(); | ||
126 | + | ||
127 | + $now = date('Y-m-d H:i:s'); | ||
128 | + | ||
129 | + $order_id = Random::uuid(); | ||
130 | + $order_id = str_replace("-","",$order_id); | ||
131 | + | ||
132 | + $params['user_id'] = $ids; | ||
133 | + $params['order_id'] = $order_id; | ||
134 | + $params['status'] = 'success'; | ||
135 | + $params['product_doc'] = json_encode($product);; | ||
136 | + $params['total'] = $product['price']; | ||
137 | + $params['create_time'] = $now; | ||
138 | + $params['third_order_id'] = ''; | ||
139 | + $params['count'] = $product['count']; | ||
140 | + $params['remain'] = ($product['count'] == -1)?999999:$product['count']; | ||
141 | + $params['start'] = $now; | ||
142 | + $params['end'] = date('Y-m-d H:i:s',strtotime('+'.$product['dateCount'].' day',strtotime($now))); | ||
143 | + $params['success_time'] = $now; | ||
144 | + $params['notify'] = false; | ||
145 | + | ||
146 | + try { | ||
147 | + //是否采用模型验证 | ||
148 | + if ($this->modelValidate) { | ||
149 | + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); | ||
150 | + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; | ||
151 | + $this->model->validate($validate); | ||
152 | + } | ||
153 | + $result = $this->model->allowField(true)->insert($params,false,true); | ||
154 | + if ($result !== false) { | ||
155 | + $this->success(); | ||
156 | + } else { | ||
157 | + $this->error($this->model->getError()); | ||
158 | + } | ||
159 | + } catch (\think\exception\PDOException $e) { | ||
160 | + $this->error($e->getMessage()); | ||
161 | + } catch (\think\Exception $e) { | ||
162 | + $this->error($e->getMessage()); | ||
163 | + } | ||
164 | + } | ||
165 | + $this->error(__('Parameter %s can not be empty', '')); | ||
166 | + } | ||
167 | + return $this->view->fetch(); | ||
168 | + } | ||
98 | } | 169 | } |
@@ -6,48 +6,15 @@ | @@ -6,48 +6,15 @@ | ||
6 | <input id="c-product_id" data-rule="required" data-source="product/index" class="form-control selectpage" name="row[product_id]" type="text" value=""> | 6 | <input id="c-product_id" data-rule="required" data-source="product/index" class="form-control selectpage" name="row[product_id]" type="text" value=""> |
7 | </div> | 7 | </div> |
8 | </div> | 8 | </div> |
9 | + {if !isset($user_id)} | ||
9 | <div class="form-group"> | 10 | <div class="form-group"> |
10 | <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label> | 11 | <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label> |
11 | <div class="col-xs-12 col-sm-8"> | 12 | <div class="col-xs-12 col-sm-8"> |
12 | <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value=""> | 13 | <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value=""> |
13 | </div> | 14 | </div> |
14 | </div> | 15 | </div> |
15 | - <div class="form-group"> | ||
16 | - <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label> | ||
17 | - <div class="col-xs-12 col-sm-8"> | ||
18 | - <input id="c-status" data-rule="required" class="form-control" name="row[status]" type="text"> | ||
19 | - </div> | ||
20 | - </div> | ||
21 | - <div class="form-group"> | ||
22 | - <label class="control-label col-xs-12 col-sm-2">{:__('Product_doc')}:</label> | ||
23 | - <div class="col-xs-12 col-sm-8"> | ||
24 | - <input id="c-product_doc" data-rule="required" class="form-control" name="row[product_doc]" type="text"> | ||
25 | - </div> | ||
26 | - </div> | ||
27 | - <div class="form-group"> | ||
28 | - <label class="control-label col-xs-12 col-sm-2">{:__('Total')}:</label> | ||
29 | - <div class="col-xs-12 col-sm-8"> | ||
30 | - <input id="c-total" data-rule="required" class="form-control" step="0.01" name="row[total]" type="number"> | ||
31 | - </div> | ||
32 | - </div> | ||
33 | - <div class="form-group"> | ||
34 | - <label class="control-label col-xs-12 col-sm-2">{:__('Order_id')}:</label> | ||
35 | - <div class="col-xs-12 col-sm-8"> | ||
36 | - <input id="c-order_id" data-rule="required" data-source="order/index" class="form-control selectpage" name="row[order_id]" type="text" value=""> | ||
37 | - </div> | ||
38 | - </div> | ||
39 | - <div class="form-group"> | ||
40 | - <label class="control-label col-xs-12 col-sm-2">{:__('Create_time')}:</label> | ||
41 | - <div class="col-xs-12 col-sm-8"> | ||
42 | - <input id="c-create_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[create_time]" type="text" value="{:date('Y-m-d H:i:s')}"> | ||
43 | - </div> | ||
44 | - </div> | ||
45 | - <div class="form-group"> | ||
46 | - <label class="control-label col-xs-12 col-sm-2">{:__('Third_order_id')}:</label> | ||
47 | - <div class="col-xs-12 col-sm-8"> | ||
48 | - <input id="c-third_order_id" data-rule="required" data-source="third/order/index" class="form-control selectpage" name="row[third_order_id]" type="text" value=""> | ||
49 | - </div> | ||
50 | - </div> | 16 | + {/if} |
17 | + | ||
51 | <div class="form-group layer-footer"> | 18 | <div class="form-group layer-footer"> |
52 | <label class="control-label col-xs-12 col-sm-2"></label> | 19 | <label class="control-label col-xs-12 col-sm-2"></label> |
53 | <div class="col-xs-12 col-sm-8"> | 20 | <div class="col-xs-12 col-sm-8"> |
1 | <div class="panel panel-default panel-intro"> | 1 | <div class="panel panel-default panel-intro"> |
2 | {:build_heading()} | 2 | {:build_heading()} |
3 | 3 | ||
4 | + <input id="user_id" type="text" value="{$user_id}" style="display: none"> | ||
5 | + | ||
4 | <div class="panel-body"> | 6 | <div class="panel-body"> |
5 | <div id="myTabContent" class="tab-content"> | 7 | <div id="myTabContent" class="tab-content"> |
6 | <div class="tab-pane fade active in" id="one"> | 8 | <div class="tab-pane fade active in" id="one"> |
7 | <div class="widget-body no-padding"> | 9 | <div class="widget-body no-padding"> |
8 | <div id="toolbar" class="toolbar"> | 10 | <div id="toolbar" class="toolbar"> |
9 | <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> | 11 | <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a> |
10 | - <!-- <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> | ||
11 | - <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> | ||
12 | - <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> | ||
13 | - <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a> | 12 | + <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('order/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a> |
13 | + <!-- <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('order/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a> | ||
14 | + <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('order/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> | ||
15 | + <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('order/import')?'':'hide'}" title="{:__('Import')}" id="btn-import-file" data-url="ajax/upload" data-mimetype="csv,xls,xlsx" data-multiple="false"><i class="fa fa-upload"></i> {:__('Import')}</a> | ||
14 | 16 | ||
15 | - <div class="dropdown btn-group {:$auth->check('order/multi')?'':'hide'}"> | ||
16 | - <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a> | ||
17 | - <ul class="dropdown-menu text-left" role="menu"> | ||
18 | - <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li> | ||
19 | - <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> | ||
20 | - </ul> | ||
21 | - </div>--> | 17 | + <div class="dropdown btn-group {:$auth->check('order/multi')?'':'hide'}"> |
18 | + <a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a> | ||
19 | + <ul class="dropdown-menu text-left" role="menu"> | ||
20 | + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=normal"><i class="fa fa-eye"></i> {:__('Set to normal')}</a></li> | ||
21 | + <li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li> | ||
22 | + </ul> | ||
23 | + </div>--> | ||
22 | 24 | ||
23 | 25 | ||
24 | </div> | 26 | </div> |
@@ -6,8 +6,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | @@ -6,8 +6,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin | ||
6 | Table.api.init({ | 6 | Table.api.init({ |
7 | extend: { | 7 | extend: { |
8 | index_url: 'order/index' + location.search, | 8 | index_url: 'order/index' + location.search, |
9 | - /*add_url: 'order/add', | ||
10 | - edit_url: 'order/edit', | 9 | + add_url: 'order/add'+($("#user_id").val() === ''?'':'/ids/'+$("#user_id").val()), |
10 | + /*edit_url: 'order/edit', | ||
11 | del_url: 'order/del', | 11 | del_url: 'order/del', |
12 | multi_url: 'order/multi',*/ | 12 | multi_url: 'order/multi',*/ |
13 | table: 'order', | 13 | table: 'order', |
-
请 注册 或 登录 后发表评论