|
@@ -9,7 +9,7 @@ use app\admin\model\litestore\Litestorespecvalue as SpecValueModel; |
|
@@ -9,7 +9,7 @@ use app\admin\model\litestore\Litestorespecvalue as SpecValueModel; |
9
|
use think\Db;
|
9
|
use think\Db;
|
10
|
|
10
|
|
11
|
/**
|
11
|
/**
|
12
|
- *
|
12
|
+ *
|
13
|
*
|
13
|
*
|
14
|
* @icon fa fa-circle-o
|
14
|
* @icon fa fa-circle-o
|
15
|
*/
|
15
|
*/
|
|
@@ -26,7 +26,7 @@ class Litestoregoods extends Backend |
|
@@ -26,7 +26,7 @@ class Litestoregoods extends Backend |
26
|
public function _initialize()
|
26
|
public function _initialize()
|
27
|
{
|
27
|
{
|
28
|
parent::_initialize();
|
28
|
parent::_initialize();
|
29
|
- $this->SpecModel = new SpecModel;
|
29
|
+ $this->SpecModel = new SpecModel;
|
30
|
$this->SpecValueModel = new SpecValueModel;
|
30
|
$this->SpecValueModel = new SpecValueModel;
|
31
|
|
31
|
|
32
|
$this->model = new \app\admin\model\litestore\Litestoregoods;
|
32
|
$this->model = new \app\admin\model\litestore\Litestoregoods;
|
|
@@ -40,13 +40,13 @@ class Litestoregoods extends Backend |
|
@@ -40,13 +40,13 @@ class Litestoregoods extends Backend |
40
|
$this->view->assign("spec_attr", '');
|
40
|
$this->view->assign("spec_attr", '');
|
41
|
$this->view->assign("spec_list", '');
|
41
|
$this->view->assign("spec_list", '');
|
42
|
}
|
42
|
}
|
43
|
-
|
43
|
+
|
44
|
/**
|
44
|
/**
|
45
|
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
45
|
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
46
|
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
46
|
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
47
|
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
47
|
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
48
|
*/
|
48
|
*/
|
49
|
-
|
49
|
+
|
50
|
|
50
|
|
51
|
/**
|
51
|
/**
|
52
|
* 查看
|
52
|
* 查看
|
|
@@ -57,35 +57,33 @@ class Litestoregoods extends Backend |
|
@@ -57,35 +57,33 @@ class Litestoregoods extends Backend |
57
|
$this->relationSearch = true;
|
57
|
$this->relationSearch = true;
|
58
|
//设置过滤方法
|
58
|
//设置过滤方法
|
59
|
$this->request->filter(['strip_tags']);
|
59
|
$this->request->filter(['strip_tags']);
|
60
|
- if ($this->request->isAjax())
|
|
|
61
|
- {
|
60
|
+ if ($this->request->isAjax()) {
|
62
|
//如果发送的来源是Selectpage,则转发到Selectpage
|
61
|
//如果发送的来源是Selectpage,则转发到Selectpage
|
63
|
- if ($this->request->request('keyField'))
|
|
|
64
|
- {
|
62
|
+ if ($this->request->request('keyField')) {
|
65
|
return $this->selectpage();
|
63
|
return $this->selectpage();
|
66
|
}
|
64
|
}
|
67
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
65
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
68
|
$total = $this->model
|
66
|
$total = $this->model
|
69
|
- ->with(['category','activity'])
|
|
|
70
|
- ->where($where)
|
|
|
71
|
- ->order($sort, $order)
|
|
|
72
|
- ->count();
|
67
|
+ ->with(['category', 'activity'])
|
|
|
68
|
+ ->where($where)
|
|
|
69
|
+ ->order($sort, $order)
|
|
|
70
|
+ ->count();
|
73
|
|
71
|
|
74
|
$list = $this->model
|
72
|
$list = $this->model
|
75
|
- ->with(['category','activity'])
|
|
|
76
|
- ->where($where)
|
|
|
77
|
- ->order($sort, $order)
|
|
|
78
|
- ->limit($offset, $limit)
|
|
|
79
|
- ->select();
|
73
|
+ ->with(['category', 'activity'])
|
|
|
74
|
+ ->where($where)
|
|
|
75
|
+ ->order($sort, $order)
|
|
|
76
|
+ ->limit($offset, $limit)
|
|
|
77
|
+ ->select();
|
80
|
|
78
|
|
81
|
foreach ($list as $row) {
|
79
|
foreach ($list as $row) {
|
82
|
-
|
80
|
+
|
83
|
$row->getRelation('category')->visible(['name']);
|
81
|
$row->getRelation('category')->visible(['name']);
|
84
|
$row->getRelation('activity')->visible(['name']);
|
82
|
$row->getRelation('activity')->visible(['name']);
|
85
|
// $row->getRelation('freight')->visible(['name']);
|
83
|
// $row->getRelation('freight')->visible(['name']);
|
86
|
- $row->stock_num = Litestoregoodsspec::where('goods_id',$row['goods_id'])->sum('stock_num');
|
84
|
+ $row->stock_num = Litestoregoodsspec::where('goods_id', $row['goods_id'])->sum('stock_num');
|
87
|
}
|
85
|
}
|
88
|
- $list = collection($list)->toArray();
|
86
|
+ $list = collection($list)->toArray();
|
89
|
$result = array("total" => $total, "rows" => $list);
|
87
|
$result = array("total" => $total, "rows" => $list);
|
90
|
|
88
|
|
91
|
return json($result);
|
89
|
return json($result);
|
|
@@ -93,14 +91,15 @@ class Litestoregoods extends Backend |
|
@@ -93,14 +91,15 @@ class Litestoregoods extends Backend |
93
|
return $this->view->fetch();
|
91
|
return $this->view->fetch();
|
94
|
}
|
92
|
}
|
95
|
|
93
|
|
96
|
- public function addSpec($spec_name, $spec_value){
|
|
|
97
|
- // 判断规格组是否存在
|
94
|
+ public function addSpec($spec_name, $spec_value)
|
|
|
95
|
+ {
|
|
|
96
|
+ // 判断规格组是否存在
|
98
|
if (!$specId = $this->SpecModel->getSpecIdByName($spec_name)) {
|
97
|
if (!$specId = $this->SpecModel->getSpecIdByName($spec_name)) {
|
99
|
// 新增规格组and规则值
|
98
|
// 新增规格组and规则值
|
100
|
if ($this->SpecModel->add($spec_name)
|
99
|
if ($this->SpecModel->add($spec_name)
|
101
|
&& $this->SpecValueModel->add($this->SpecModel['id'], $spec_value))
|
100
|
&& $this->SpecValueModel->add($this->SpecModel['id'], $spec_value))
|
102
|
return $this->success('', '', [
|
101
|
return $this->success('', '', [
|
103
|
- 'spec_id' => (int)$this->SpecModel['id'],
|
102
|
+ 'spec_id' => (int)$this->SpecModel['id'],
|
104
|
'spec_value_id' => (int)$this->SpecValueModel['id'],
|
103
|
'spec_value_id' => (int)$this->SpecValueModel['id'],
|
105
|
]);
|
104
|
]);
|
106
|
return $this->error();
|
105
|
return $this->error();
|
|
@@ -109,14 +108,14 @@ class Litestoregoods extends Backend |
|
@@ -109,14 +108,14 @@ class Litestoregoods extends Backend |
109
|
// 判断规格值是否存在
|
108
|
// 判断规格值是否存在
|
110
|
if ($specValueId = $this->SpecValueModel->getSpecValueIdByName($specId, $spec_value)) {
|
109
|
if ($specValueId = $this->SpecValueModel->getSpecValueIdByName($specId, $spec_value)) {
|
111
|
return $this->success('', '', [
|
110
|
return $this->success('', '', [
|
112
|
- 'spec_id' => (int)$specId,
|
111
|
+ 'spec_id' => (int)$specId,
|
113
|
'spec_value_id' => (int)$specValueId,
|
112
|
'spec_value_id' => (int)$specValueId,
|
114
|
]);
|
113
|
]);
|
115
|
}
|
114
|
}
|
116
|
// 添加规则值
|
115
|
// 添加规则值
|
117
|
if ($this->SpecValueModel->add($specId, $spec_value))
|
116
|
if ($this->SpecValueModel->add($specId, $spec_value))
|
118
|
return $this->success('', '', [
|
117
|
return $this->success('', '', [
|
119
|
- 'spec_id' => (int)$specId,
|
118
|
+ 'spec_id' => (int)$specId,
|
120
|
'spec_value_id' => (int)$this->SpecValueModel['id'],
|
119
|
'spec_value_id' => (int)$this->SpecValueModel['id'],
|
121
|
]);
|
120
|
]);
|
122
|
return $this->error();
|
121
|
return $this->error();
|
|
@@ -153,13 +152,13 @@ class Litestoregoods extends Backend |
|
@@ -153,13 +152,13 @@ class Litestoregoods extends Backend |
153
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
152
|
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
154
|
$params[$this->dataLimitField] = $this->auth->id;
|
153
|
$params[$this->dataLimitField] = $this->auth->id;
|
155
|
}
|
154
|
}
|
156
|
- if($params['spec_type'] == '20' && !$this->request->post("spec_many/a")){
|
155
|
+ if ($params['spec_type'] == '20' && !$this->request->post("spec_many/a")) {
|
157
|
$this->error('请添加规格');
|
156
|
$this->error('请添加规格');
|
158
|
}
|
157
|
}
|
159
|
try {
|
158
|
try {
|
160
|
//是否采用模型验证
|
159
|
//是否采用模型验证
|
161
|
if ($this->modelValidate) {
|
160
|
if ($this->modelValidate) {
|
162
|
- $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
161
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
163
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate;
|
162
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : true) : $this->modelValidate;
|
164
|
$this->model->validate($validate);
|
163
|
$this->model->validate($validate);
|
165
|
}
|
164
|
}
|
|
@@ -167,7 +166,7 @@ class Litestoregoods extends Backend |
|
@@ -167,7 +166,7 @@ class Litestoregoods extends Backend |
167
|
if ($result !== false) {
|
166
|
if ($result !== false) {
|
168
|
//成功之后 存储商品规格
|
167
|
//成功之后 存储商品规格
|
169
|
$spec_many_params = $this->request->post("spec_many/a");
|
168
|
$spec_many_params = $this->request->post("spec_many/a");
|
170
|
- $this->model->addGoodsSpec($params,$spec_many_params,$this->request->post("spec/a"));
|
169
|
+ $this->model->addGoodsSpec($params, $spec_many_params, $this->request->post("spec/a"));
|
171
|
$this->success();
|
170
|
$this->success();
|
172
|
} else {
|
171
|
} else {
|
173
|
$this->error($this->model->getError());
|
172
|
$this->error($this->model->getError());
|
|
@@ -189,12 +188,12 @@ class Litestoregoods extends Backend |
|
@@ -189,12 +188,12 @@ class Litestoregoods extends Backend |
189
|
public function del($ids = "")
|
188
|
public function del($ids = "")
|
190
|
{
|
189
|
{
|
191
|
if ($ids) {
|
190
|
if ($ids) {
|
192
|
- $pk = $this->model->getPk();
|
191
|
+ $pk = $this->model->getPk();
|
193
|
$adminIds = $this->getDataLimitAdminIds();
|
192
|
$adminIds = $this->getDataLimitAdminIds();
|
194
|
if (is_array($adminIds)) {
|
193
|
if (is_array($adminIds)) {
|
195
|
$count = $this->model->where($this->dataLimitField, 'in', $adminIds);
|
194
|
$count = $this->model->where($this->dataLimitField, 'in', $adminIds);
|
196
|
}
|
195
|
}
|
197
|
- $list = $this->model->where($pk, 'in', $ids)->select();
|
196
|
+ $list = $this->model->where($pk, 'in', $ids)->select();
|
198
|
$count = 0;
|
197
|
$count = 0;
|
199
|
foreach ($list as $k => $v) {
|
198
|
foreach ($list as $k => $v) {
|
200
|
// 删除商品sku
|
199
|
// 删除商品sku
|
|
@@ -228,13 +227,13 @@ class Litestoregoods extends Backend |
|
@@ -228,13 +227,13 @@ class Litestoregoods extends Backend |
228
|
if ($this->request->isPost()) {
|
227
|
if ($this->request->isPost()) {
|
229
|
$params = $this->request->post("row/a");
|
228
|
$params = $this->request->post("row/a");
|
230
|
if ($params) {
|
229
|
if ($params) {
|
231
|
- if($params['spec_type'] == '20' && !$this->request->post("spec_many/a")){
|
230
|
+ if ($params['spec_type'] == '20' && !$this->request->post("spec_many/a")) {
|
232
|
$this->error('请添加规格');
|
231
|
$this->error('请添加规格');
|
233
|
}
|
232
|
}
|
234
|
try {
|
233
|
try {
|
235
|
//是否采用模型验证
|
234
|
//是否采用模型验证
|
236
|
if ($this->modelValidate) {
|
235
|
if ($this->modelValidate) {
|
237
|
- $name = basename(str_replace('\\', '/', get_class($this->model)));
|
236
|
+ $name = basename(str_replace('\\', '/', get_class($this->model)));
|
238
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate;
|
237
|
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : true) : $this->modelValidate;
|
239
|
$row->validate($validate);
|
238
|
$row->validate($validate);
|
240
|
}
|
239
|
}
|
|
@@ -242,11 +241,11 @@ class Litestoregoods extends Backend |
|
@@ -242,11 +241,11 @@ class Litestoregoods extends Backend |
242
|
if ($result !== false) {
|
241
|
if ($result !== false) {
|
243
|
//成功之后 存储商品规格
|
242
|
//成功之后 存储商品规格
|
244
|
$spec_many_params = $this->request->post("spec_many/a");
|
243
|
$spec_many_params = $this->request->post("spec_many/a");
|
245
|
- $row->addGoodsSpec($params,$spec_many_params,$this->request->post("spec/a"), true);
|
244
|
+ $row->addGoodsSpec($params, $spec_many_params, $this->request->post("spec/a"), true);
|
246
|
// 删除购物车
|
245
|
// 删除购物车
|
247
|
- Db::name('cart')->where('goods_id',$row->goods_id)->delete();
|
246
|
+ Db::name('cart')->where('goods_id', $row->goods_id)->delete();
|
248
|
//删除我常买
|
247
|
//删除我常买
|
249
|
- Db::name('user_buylist')->where('goods_id',$row->goods_id)->delete();
|
248
|
+ Db::name('user_buylist')->where('goods_id', $row->goods_id)->delete();
|
250
|
$this->success();
|
249
|
$this->success();
|
251
|
} else {
|
250
|
} else {
|
252
|
$this->error($row->getError());
|
251
|
$this->error($row->getError());
|
|
@@ -261,11 +260,77 @@ class Litestoregoods extends Backend |
|
@@ -261,11 +260,77 @@ class Litestoregoods extends Backend |
261
|
}
|
260
|
}
|
262
|
// 多规格信息
|
261
|
// 多规格信息
|
263
|
$specData = 'null';
|
262
|
$specData = 'null';
|
264
|
- if ($row['spec_type'] === '20'){
|
263
|
+ if ($row['spec_type'] === '20') {
|
265
|
$specData = json_encode($this->model->getManySpecData($row['spec_rel'], $row['spec']));
|
264
|
$specData = json_encode($this->model->getManySpecData($row['spec_rel'], $row['spec']));
|
266
|
}
|
265
|
}
|
267
|
$row['specData'] = $specData;
|
266
|
$row['specData'] = $specData;
|
268
|
$this->view->assign("row", $row);
|
267
|
$this->view->assign("row", $row);
|
269
|
return $this->view->fetch();
|
268
|
return $this->view->fetch();
|
270
|
}
|
269
|
}
|
|
|
270
|
+
|
|
|
271
|
+
|
|
|
272
|
+ /**
|
|
|
273
|
+ * 导出
|
|
|
274
|
+ */
|
|
|
275
|
+ public function clubpeople(){
|
|
|
276
|
+ //1.从数据库中导出需要进行要导出的数据
|
|
|
277
|
+ $list =Db::query('SELECT stu_list.stu_name,stu_list.stu_department,stu_list.stu_phone,stu_list.stu_email,stu_list.stu_profess
|
|
|
278
|
+ ,club_branch.* FROM club_branch INNER JOIN stu_list ON club_branch.stu_number = stu_list.stu_number
|
|
|
279
|
+ where club_branch.club_id=:acc order by club_branch.club_branch_name ',['acc'=>$clubid]);
|
|
|
280
|
+
|
|
|
281
|
+
|
|
|
282
|
+
|
|
|
283
|
+
|
|
|
284
|
+ //重要补助
|
|
|
285
|
+ //2.加载PHPExcle类库
|
|
|
286
|
+ vendor('PHPExcel.PHPExcel');
|
|
|
287
|
+ //3.实例化PHPExcel类
|
|
|
288
|
+ $objPHPExcel = new \PHPExcel();
|
|
|
289
|
+ //4.激活当前的sheet表
|
|
|
290
|
+ $objPHPExcel->setActiveSheetIndex(0);
|
|
|
291
|
+ //5.设置表格头(即excel表格的第一行)
|
|
|
292
|
+ $objPHPExcel->setActiveSheetIndex(0)
|
|
|
293
|
+ ->setCellValue('A1', '部门')
|
|
|
294
|
+ ->setCellValue('B1', '职位')
|
|
|
295
|
+ ->setCellValue('C1', '学号')
|
|
|
296
|
+ ->setCellValue('D1', '学生姓名')
|
|
|
297
|
+ ->setCellValue('E1', '联系方式')
|
|
|
298
|
+ ->setCellValue('F1', '邮箱')
|
|
|
299
|
+ ->setCellValue('G1', '院系')
|
|
|
300
|
+ ->setCellValue('H1', '专业');
|
|
|
301
|
+ //设置A列水平居中
|
|
|
302
|
+ $objPHPExcel->setActiveSheetIndex(0)->getStyle('A1')->getAlignment()
|
|
|
303
|
+ ->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
304
|
+ //设置单元格宽度
|
|
|
305
|
+ //6.循环刚取出来的数组,将数据逐一添加到excel表格。
|
|
|
306
|
+ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setWidth(10);
|
|
|
307
|
+ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setWidth(20);
|
|
|
308
|
+ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setWidth(20);
|
|
|
309
|
+ $objPHPExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setWidth(30);
|
|
|
310
|
+
|
|
|
311
|
+ for($i=0;$i<count($list);$i++){
|
|
|
312
|
+ $objPHPExcel->getActiveSheet()->setCellValue('A'.($i+2),$list[$i]['club_branch_name']);//ID
|
|
|
313
|
+ $objPHPExcel->getActiveSheet()->setCellValue('B'.($i+2),$list[$i]['club_position']);//标签码
|
|
|
314
|
+ $objPHPExcel->getActiveSheet()->setCellValue('C'.($i+2),$list[$i]['stu_number']);//防伪码
|
|
|
315
|
+ $objPHPExcel->getActiveSheet()->setCellValue('D'.($i+2),$list[$i]['stu_name']);//ID
|
|
|
316
|
+ $objPHPExcel->getActiveSheet()->setCellValue('E'.($i+2),$list[$i]['stu_phone']);//标签码
|
|
|
317
|
+ $objPHPExcel->getActiveSheet()->setCellValue('F'.($i+2),$list[$i]['stu_email']);//ID
|
|
|
318
|
+ $objPHPExcel->getActiveSheet()->setCellValue('G'.($i+2),$list[$i]['stu_department']);//标签码
|
|
|
319
|
+ $objPHPExcel->getActiveSheet()->setCellValue('H'.($i+2),$list[$i]['stu_profess']);//防伪码
|
|
|
320
|
+ }
|
|
|
321
|
+ //7.设置保存的Excel表格名称
|
|
|
322
|
+ $filename = $club_name.'人员名单'.date('ymd',time()).'.xls';
|
|
|
323
|
+ //8.设置当前激活的sheet表格名称;
|
|
|
324
|
+ $objPHPExcel->getActiveSheet()->setTitle('人员名单');
|
|
|
325
|
+ //9.设置浏览器窗口下载表格
|
|
|
326
|
+ header("Content-Type: application/force-download");
|
|
|
327
|
+ header("Content-Type: application/octet-stream");
|
|
|
328
|
+ header("Content-Type: application/download");
|
|
|
329
|
+ header('Content-Disposition:inline;filename="'.$filename.'"');
|
|
|
330
|
+ //生成excel文件
|
|
|
331
|
+ $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
|
|
|
332
|
+ //下载文件在浏览器窗口
|
|
|
333
|
+ $objWriter->save('php://output');
|
|
|
334
|
+ exit;
|
|
|
335
|
+}
|
271
|
} |
336
|
} |