正在显示
15 个修改的文件
包含
327 行增加
和
0 行删除
application/admin/controller/Activity.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\controller; | ||
4 | + | ||
5 | +use app\common\controller\Backend; | ||
6 | + | ||
7 | +/** | ||
8 | + * 首页活动 | ||
9 | + * | ||
10 | + * @icon fa fa-circle-o | ||
11 | + */ | ||
12 | +class Activity extends Backend | ||
13 | +{ | ||
14 | + | ||
15 | + /** | ||
16 | + * Activity模型对象 | ||
17 | + * @var \app\admin\model\Activity | ||
18 | + */ | ||
19 | + protected $model = null; | ||
20 | + | ||
21 | + public function _initialize() | ||
22 | + { | ||
23 | + parent::_initialize(); | ||
24 | + $this->model = new \app\admin\model\Activity; | ||
25 | + $this->view->assign("placeList", $this->model->getPlaceList()); | ||
26 | + } | ||
27 | + | ||
28 | + public function import() | ||
29 | + { | ||
30 | + parent::import(); | ||
31 | + } | ||
32 | + | ||
33 | + /** | ||
34 | + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 | ||
35 | + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 | ||
36 | + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 | ||
37 | + */ | ||
38 | + | ||
39 | + | ||
40 | +} |
@@ -32,6 +32,7 @@ class Litestoregoods extends Backend | @@ -32,6 +32,7 @@ class Litestoregoods extends Backend | ||
32 | $this->view->assign("goodsStatusList", $this->model->getGoodsStatusList()); | 32 | $this->view->assign("goodsStatusList", $this->model->getGoodsStatusList()); |
33 | $this->view->assign("isDeleteList", $this->model->getIsDeleteList()); | 33 | $this->view->assign("isDeleteList", $this->model->getIsDeleteList()); |
34 | $this->view->assign("makeforList", $this->model->getMakeforList()); | 34 | $this->view->assign("makeforList", $this->model->getMakeforList()); |
35 | + $this->view->assign("isIndexList", $this->model->getIsIndexList()); | ||
35 | 36 | ||
36 | $this->view->assign("spec_attr", ''); | 37 | $this->view->assign("spec_attr", ''); |
37 | $this->view->assign("spec_list", ''); | 38 | $this->view->assign("spec_list", ''); |
application/admin/lang/zh-cn/activity.php
0 → 100644
@@ -36,4 +36,8 @@ return [ | @@ -36,4 +36,8 @@ return [ | ||
36 | 'Brand' => '品牌', | 36 | 'Brand' => '品牌', |
37 | 'Four_images' => '四宫格图', | 37 | 'Four_images' => '四宫格图', |
38 | 'Down_image' => '底部图', | 38 | 'Down_image' => '底部图', |
39 | + 'Is_index' => '首页展示', | ||
40 | + 'Is_index 1' => '已展示', | ||
41 | + 'Is_index 0' => '未展示', | ||
42 | + 'Activity_id' => '活动类型', | ||
39 | ]; | 43 | ]; |
application/admin/model/Activity.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\model; | ||
4 | + | ||
5 | +use think\Model; | ||
6 | + | ||
7 | + | ||
8 | +class Activity extends Model | ||
9 | +{ | ||
10 | + | ||
11 | + | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + // 表名 | ||
16 | + protected $name = 'activity'; | ||
17 | + | ||
18 | + // 自动写入时间戳字段 | ||
19 | + protected $autoWriteTimestamp = false; | ||
20 | + | ||
21 | + // 定义时间戳字段名 | ||
22 | + protected $createTime = false; | ||
23 | + protected $updateTime = false; | ||
24 | + protected $deleteTime = false; | ||
25 | + | ||
26 | + // 追加属性 | ||
27 | + protected $append = [ | ||
28 | + 'place_text' | ||
29 | + ]; | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | + public function getPlaceList() | ||
34 | + { | ||
35 | + return ['left' => __('Place left'), 'rightTop' => __('Place righttop'), 'rightDown' => __('Place rightdown')]; | ||
36 | + } | ||
37 | + | ||
38 | + | ||
39 | + public function getPlaceTextAttr($value, $data) | ||
40 | + { | ||
41 | + $value = $value ? $value : (isset($data['place']) ? $data['place'] : ''); | ||
42 | + $list = $this->getPlaceList(); | ||
43 | + return isset($list[$value]) ? $list[$value] : ''; | ||
44 | + } | ||
45 | + | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | +} |
@@ -49,6 +49,11 @@ class Litestoregoods extends Model | @@ -49,6 +49,11 @@ class Litestoregoods extends Model | ||
49 | return ['1' => __('Makefor 1'),'2' => __('Makefor 2')]; | 49 | return ['1' => __('Makefor 1'),'2' => __('Makefor 2')]; |
50 | } | 50 | } |
51 | 51 | ||
52 | + public function getIsIndexList() | ||
53 | + { | ||
54 | + return ['0' => __('Is_index 0'),'1' => __('Is_index 1')]; | ||
55 | + } | ||
56 | + | ||
52 | public function getGoodsStatusList() | 57 | public function getGoodsStatusList() |
53 | { | 58 | { |
54 | return ['10' => __('Goods_status 10'),'20' => __('Goods_status 20')]; | 59 | return ['10' => __('Goods_status 10'),'20' => __('Goods_status 20')]; |
application/admin/validate/Activity.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\admin\validate; | ||
4 | + | ||
5 | +use think\Validate; | ||
6 | + | ||
7 | +class Activity extends Validate | ||
8 | +{ | ||
9 | + /** | ||
10 | + * 验证规则 | ||
11 | + */ | ||
12 | + protected $rule = [ | ||
13 | + ]; | ||
14 | + /** | ||
15 | + * 提示消息 | ||
16 | + */ | ||
17 | + protected $message = [ | ||
18 | + ]; | ||
19 | + /** | ||
20 | + * 验证场景 | ||
21 | + */ | ||
22 | + protected $scene = [ | ||
23 | + 'add' => [], | ||
24 | + 'edit' => [], | ||
25 | + ]; | ||
26 | + | ||
27 | +} |
application/admin/view/activity/add.html
0 → 100644
1 | +<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | ||
2 | + | ||
3 | + <div class="form-group"> | ||
4 | + <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | ||
5 | + <div class="col-xs-12 col-sm-8"> | ||
6 | + <input id="c-name" class="form-control" name="row[name]" type="text"> | ||
7 | + </div> | ||
8 | + </div> | ||
9 | + <div class="form-group"> | ||
10 | + <label class="control-label col-xs-12 col-sm-2">{:__('Place')}:</label> | ||
11 | + <div class="col-xs-12 col-sm-8"> | ||
12 | + | ||
13 | + <select id="c-place" class="form-control selectpicker" name="row[place]"> | ||
14 | + {foreach name="placeList" item="vo"} | ||
15 | + <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option> | ||
16 | + {/foreach} | ||
17 | + </select> | ||
18 | + | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <div class="form-group layer-footer"> | ||
22 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
25 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
26 | + </div> | ||
27 | + </div> | ||
28 | +</form> |
application/admin/view/activity/edit.html
0 → 100644
1 | +<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> | ||
2 | + | ||
3 | + <div class="form-group"> | ||
4 | + <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label> | ||
5 | + <div class="col-xs-12 col-sm-8"> | ||
6 | + <input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}"> | ||
7 | + </div> | ||
8 | + </div> | ||
9 | + <div class="form-group"> | ||
10 | + <label class="control-label col-xs-12 col-sm-2">{:__('Place')}:</label> | ||
11 | + <div class="col-xs-12 col-sm-8"> | ||
12 | + | ||
13 | + <select id="c-place" class="form-control selectpicker" name="row[place]"> | ||
14 | + {foreach name="placeList" item="vo"} | ||
15 | + <option value="{$key}" {in name="key" value="$row.place"}selected{/in}>{$vo}</option> | ||
16 | + {/foreach} | ||
17 | + </select> | ||
18 | + | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <div class="form-group layer-footer"> | ||
22 | + <label class="control-label col-xs-12 col-sm-2"></label> | ||
23 | + <div class="col-xs-12 col-sm-8"> | ||
24 | + <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button> | ||
25 | + <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button> | ||
26 | + </div> | ||
27 | + </div> | ||
28 | +</form> |
application/admin/view/activity/index.html
0 → 100644
1 | +<div class="panel panel-default panel-intro"> | ||
2 | + {:build_heading()} | ||
3 | + | ||
4 | + <div class="panel-body"> | ||
5 | + <div id="myTabContent" class="tab-content"> | ||
6 | + <div class="tab-pane fade active in" id="one"> | ||
7 | + <div class="widget-body no-padding"> | ||
8 | + <div id="toolbar" class="toolbar"> | ||
9 | + <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('activity/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('activity/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('activity/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a> | ||
13 | + <a href="javascript:;" class="btn btn-danger btn-import {:$auth->check('activity/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 | + | ||
15 | + <div class="dropdown btn-group {:$auth->check('activity/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> | ||
22 | + | ||
23 | + | ||
24 | + </div> | ||
25 | + <table id="table" class="table table-striped table-bordered table-hover table-nowrap" | ||
26 | + data-operate-edit="{:$auth->check('activity/edit')}" | ||
27 | + data-operate-del="{:$auth->check('activity/del')}" | ||
28 | + width="100%"> | ||
29 | + </table> | ||
30 | + </div> | ||
31 | + </div> | ||
32 | + | ||
33 | + </div> | ||
34 | + </div> | ||
35 | +</div> |
@@ -13,6 +13,12 @@ | @@ -13,6 +13,12 @@ | ||
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
15 | <div class="form-group"> | 15 | <div class="form-group"> |
16 | + <label class="control-label col-xs-12 col-sm-2">{:__('Activity_id')}:</label> | ||
17 | + <div class="col-xs-12 col-sm-8"> | ||
18 | + <input id="c-activity_id" data-source="activity/index" class="form-control selectpage" name="row[activity_id]" type="text" value=""> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <div class="form-group"> | ||
16 | <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> | 22 | <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> |
17 | <div class="col-xs-12 col-sm-8"> | 23 | <div class="col-xs-12 col-sm-8"> |
18 | <div class="input-group"> | 24 | <div class="input-group"> |
@@ -282,6 +288,18 @@ | @@ -282,6 +288,18 @@ | ||
282 | 288 | ||
283 | </div> | 289 | </div> |
284 | </div> | 290 | </div> |
291 | + <div class="form-group"> | ||
292 | + <label class="control-label col-xs-12 col-sm-2">{:__('Is_index')}:</label> | ||
293 | + <div class="col-xs-12 col-sm-8"> | ||
294 | + | ||
295 | + <select id="c-is_index" data-rule="required" class="form-control selectpicker" name="row[is_index]"> | ||
296 | + {foreach name="isIndexList" item="vo"} | ||
297 | + <option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option> | ||
298 | + {/foreach} | ||
299 | + </select> | ||
300 | + | ||
301 | + </div> | ||
302 | + </div> | ||
285 | <div class="form-group layer-footer"> | 303 | <div class="form-group layer-footer"> |
286 | <label class="control-label col-xs-12 col-sm-2"></label> | 304 | <label class="control-label col-xs-12 col-sm-2"></label> |
287 | <div class="col-xs-12 col-sm-8"> | 305 | <div class="col-xs-12 col-sm-8"> |
@@ -13,6 +13,12 @@ | @@ -13,6 +13,12 @@ | ||
13 | </div> | 13 | </div> |
14 | </div> | 14 | </div> |
15 | <div class="form-group"> | 15 | <div class="form-group"> |
16 | + <label class="control-label col-xs-12 col-sm-2">{:__('Activity_id')}:</label> | ||
17 | + <div class="col-xs-12 col-sm-8"> | ||
18 | + <input id="c-activity_id" data-source="activity/index" class="form-control selectpage" name="row[activity_id]" type="text" value="{$row.activity_id}"> | ||
19 | + </div> | ||
20 | + </div> | ||
21 | + <div class="form-group"> | ||
16 | <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> | 22 | <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label> |
17 | <div class="col-xs-12 col-sm-8"> | 23 | <div class="col-xs-12 col-sm-8"> |
18 | <div class="input-group"> | 24 | <div class="input-group"> |
@@ -282,6 +288,18 @@ | @@ -282,6 +288,18 @@ | ||
282 | 288 | ||
283 | </div> | 289 | </div> |
284 | </div> | 290 | </div> |
291 | + <div class="form-group"> | ||
292 | + <label class="control-label col-xs-12 col-sm-2">{:__('Is_index')}:</label> | ||
293 | + <div class="col-xs-12 col-sm-8"> | ||
294 | + | ||
295 | + <select id="c-is_index" data-rule="required" class="form-control selectpicker" name="row[is_index]"> | ||
296 | + {foreach name="isIndexList" item="vo"} | ||
297 | + <option value="{$key}" {in name="key" value="$row.is_index"}selected{/in}>{$vo}</option> | ||
298 | + {/foreach} | ||
299 | + </select> | ||
300 | + | ||
301 | + </div> | ||
302 | + </div> | ||
285 | <div class="form-group layer-footer"> | 303 | <div class="form-group layer-footer"> |
286 | <label class="control-label col-xs-12 col-sm-2"></label> | 304 | <label class="control-label col-xs-12 col-sm-2"></label> |
287 | <div class="col-xs-12 col-sm-8"> | 305 | <div class="col-xs-12 col-sm-8"> |
@@ -29,6 +29,8 @@ class Notify extends Api | @@ -29,6 +29,8 @@ class Notify extends Api | ||
29 | } | 29 | } |
30 | $data = $pay->verify(); | 30 | $data = $pay->verify(); |
31 | $model = new \app\api\model\Order(); | 31 | $model = new \app\api\model\Order(); |
32 | + $goodsmodel = new \app\api\model\OrderGoods(); | ||
33 | + $skumodel = new \app\api\model\GoodsSpec(); | ||
32 | try { | 34 | try { |
33 | $out_trade_no = $data['out_trade_no']; | 35 | $out_trade_no = $data['out_trade_no']; |
34 | $order = $model | 36 | $order = $model |
@@ -41,6 +43,13 @@ class Notify extends Api | @@ -41,6 +43,13 @@ class Notify extends Api | ||
41 | $order->transaction_id = $data['transaction_id']; | 43 | $order->transaction_id = $data['transaction_id']; |
42 | $order->pay_time = time(); | 44 | $order->pay_time = time(); |
43 | $order->isUpdate()->save(); | 45 | $order->isUpdate()->save(); |
46 | + // 减少库存 | ||
47 | + $list = $goodsmodel->where('order_id',$order['id'])->select(); | ||
48 | + foreach ($list as $key => $value){ | ||
49 | + if ($value['deduct_stock_type'] == 20){ | ||
50 | + $skumodel->where('goods_spec_id',$value['goods_spec_id'])->setDec('stock_num',$value['total_num']); | ||
51 | + } | ||
52 | + } | ||
44 | //你可以在此编写订单逻辑 | 53 | //你可以在此编写订单逻辑 |
45 | } catch (Exception $e) { | 54 | } catch (Exception $e) { |
46 | } | 55 | } |
@@ -408,6 +408,10 @@ class Order extends Api | @@ -408,6 +408,10 @@ class Order extends Api | ||
408 | $ordermodel->save($order); | 408 | $ordermodel->save($order); |
409 | foreach ($goods_array as $key => &$value){ | 409 | foreach ($goods_array as $key => &$value){ |
410 | $value['order_id'] = $ordermodel->id; | 410 | $value['order_id'] = $ordermodel->id; |
411 | + // 减少库存 | ||
412 | + if ($value['deduct_stock_type'] == 10){ | ||
413 | + $skumodel->where('goods_spec_id',$value['goods_spec_id'])->setDec('stock_num',$value['total_num']); | ||
414 | + } | ||
411 | } | 415 | } |
412 | $ordergoodsmodel->saveAll($goods_array); | 416 | $ordergoodsmodel->saveAll($goods_array); |
413 | $order_address['order_id'] = $ordermodel->id; | 417 | $order_address['order_id'] = $ordermodel->id; |
public/assets/js/backend/activity.js
0 → 100644
1 | +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { | ||
2 | + | ||
3 | + var Controller = { | ||
4 | + index: function () { | ||
5 | + // 初始化表格参数配置 | ||
6 | + Table.api.init({ | ||
7 | + extend: { | ||
8 | + index_url: 'activity/index' + location.search, | ||
9 | + add_url: 'activity/add', | ||
10 | + edit_url: 'activity/edit', | ||
11 | + del_url: 'activity/del', | ||
12 | + multi_url: 'activity/multi', | ||
13 | + import_url: 'activity/import', | ||
14 | + table: 'activity', | ||
15 | + } | ||
16 | + }); | ||
17 | + | ||
18 | + var table = $("#table"); | ||
19 | + | ||
20 | + // 初始化表格 | ||
21 | + table.bootstrapTable({ | ||
22 | + url: $.fn.bootstrapTable.defaults.extend.index_url, | ||
23 | + pk: 'id', | ||
24 | + sortName: 'id', | ||
25 | + columns: [ | ||
26 | + [ | ||
27 | + {checkbox: true}, | ||
28 | + {field: 'id', title: __('Id')}, | ||
29 | + {field: 'name', title: __('Name'), operate: 'LIKE'}, | ||
30 | + {field: 'place', title: __('Place'), searchList: {"left":__('Place left'),"rightTop":__('Place righttop'),"rightDown":__('Place rightdown')}, formatter: Table.api.formatter.normal}, | ||
31 | + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} | ||
32 | + ] | ||
33 | + ] | ||
34 | + }); | ||
35 | + | ||
36 | + // 为表格绑定事件 | ||
37 | + Table.api.bindevent(table); | ||
38 | + }, | ||
39 | + add: function () { | ||
40 | + Controller.api.bindevent(); | ||
41 | + }, | ||
42 | + edit: function () { | ||
43 | + Controller.api.bindevent(); | ||
44 | + }, | ||
45 | + api: { | ||
46 | + bindevent: function () { | ||
47 | + Form.api.bindevent($("form[role=form]")); | ||
48 | + } | ||
49 | + } | ||
50 | + }; | ||
51 | + return Controller; | ||
52 | +}); |
-
请 注册 或 登录 后发表评论