作者 耿培杰

完善后台仓库管理

@@ -112,6 +112,7 @@ class Depot extends Backend @@ -112,6 +112,7 @@ class Depot extends Backend
112 if ($params['type'] == 2) $params['goods_id'] = $params['integral_goods_id']; 112 if ($params['type'] == 2) $params['goods_id'] = $params['integral_goods_id'];
113 $result = $this->model->allowField(true)->save($params); 113 $result = $this->model->allowField(true)->save($params);
114 $stock_num = $this->model->where(['goods_id'=>$params['goods_id'],'type'=>$params['type']])->sum('stock_num'); 114 $stock_num = $this->model->where(['goods_id'=>$params['goods_id'],'type'=>$params['type']])->sum('stock_num');
  115 +
115 if ($params['type'] == 1) $this->goodsModel->where('id',$params['goods_id'])->update(['stock_num'=>$stock_num]); 116 if ($params['type'] == 1) $this->goodsModel->where('id',$params['goods_id'])->update(['stock_num'=>$stock_num]);
116 else $this->integralGoodsModel->where('id',$params['goods_id'])->update(['stock_num'=>$stock_num]); 117 else $this->integralGoodsModel->where('id',$params['goods_id'])->update(['stock_num'=>$stock_num]);
117 Db::commit(); 118 Db::commit();
@@ -109,6 +109,15 @@ class Goods extends Backend @@ -109,6 +109,15 @@ class Goods extends Backend
109 $this->model->validateFailException(true)->validate($validate); 109 $this->model->validateFailException(true)->validate($validate);
110 } 110 }
111 if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ','; 111 if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ',';
  112 + if ($params['is_group'] == 1){
  113 + if (empty($params['group_num'])) $this->error('团购人数不能为空');
  114 + if (!empty($params['group_num']) && $params['group_num'] == 1) $this->error('团购人数必须大于1人');
  115 + if (empty($params['grouptime'])) $this->error('团购有效时间不能为空');
  116 + if (empty($params['group_vip_rebate'])) $this->error('团购会员返利不能为空');
  117 + if (empty($params['group_staff_rebate'])) $this->error('团购员工返利不能为空');
  118 + if (empty($params['group_agency_rebate'])) $this->error('团购代理返利不能为空');
  119 + if (empty($params['group_price'])) $this->error('团购价格不能为空');
  120 + }
112 $result = $this->model->allowField(true)->save($params); 121 $result = $this->model->allowField(true)->save($params);
113 Db::commit(); 122 Db::commit();
114 } catch (ValidateException $e) { 123 } catch (ValidateException $e) {
@@ -161,6 +170,15 @@ class Goods extends Backend @@ -161,6 +170,15 @@ class Goods extends Backend
161 $row->validateFailException(true)->validate($validate); 170 $row->validateFailException(true)->validate($validate);
162 } 171 }
163 if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ','; 172 if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ',';
  173 + if ($params['is_group'] == 1){
  174 + if (empty($params['group_num'])) $this->error('团购人数不能为空');
  175 + if (!empty($params['group_num']) && $params['group_num'] == 1) $this->error('团购人数必须大于1人');
  176 + if (empty($params['grouptime'])) $this->error('团购有效时间不能为空');
  177 + if (empty($params['group_vip_rebate'])) $this->error('团购会员返利不能为空');
  178 + if (empty($params['group_staff_rebate'])) $this->error('团购员工返利不能为空');
  179 + if (empty($params['group_agency_rebate'])) $this->error('团购代理返利不能为空');
  180 + if (empty($params['group_price'])) $this->error('团购价格不能为空');
  181 + }
164 $result = $row->allowField(true)->save($params); 182 $result = $row->allowField(true)->save($params);
165 Db::commit(); 183 Db::commit();
166 } catch (ValidateException $e) { 184 } catch (ValidateException $e) {
1 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> 1 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
2 -  
3 <div class="form-group"> 2 <div class="form-group">
4 <label class="control-label col-xs-12 col-sm-2">{:__('Area_id')}:</label> 3 <label class="control-label col-xs-12 col-sm-2">{:__('Area_id')}:</label>
5 <div class="col-xs-12 col-sm-8"> 4 <div class="col-xs-12 col-sm-8">
6 <input id="c-area_id" data-rule="required" data-source="area/index" data-params='{"custom[pid]":"0"}' class="form-control selectpage" name="row[area_id]" type="text" value=""> 5 <input id="c-area_id" data-rule="required" data-source="area/index" data-params='{"custom[pid]":"0"}' class="form-control selectpage" name="row[area_id]" type="text" value="">
7 </div> 6 </div>
8 </div> 7 </div>
  8 + {if $_GET['type'] eq 'null'}
9 <div class="form-group"> 9 <div class="form-group">
10 <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label> 10 <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
11 <div class="col-xs-12 col-sm-8"> 11 <div class="col-xs-12 col-sm-8">
@@ -30,6 +30,18 @@ @@ -30,6 +30,18 @@
30 <input id="c-integral_goods_id" data-rule="" data-source="integral_goods/index" data-field="ch_name" class="form-control selectpage" name="row[integral_goods_id]" type="text" value=""> 30 <input id="c-integral_goods_id" data-rule="" data-source="integral_goods/index" data-field="ch_name" class="form-control selectpage" name="row[integral_goods_id]" type="text" value="">
31 </div> 31 </div>
32 </div> 32 </div>
  33 + {/if}
  34 +
  35 + {if $_GET['type'] eq 1}
  36 + <input name="row[type]" type="hidden" value="1">
  37 + <input name="row[goods_id]" type="hidden" value="{$_GET['goods_id']}">
  38 +
  39 + {/if}
  40 +
  41 + {if $_GET['type'] eq 2}
  42 + <input name="row[type]" type="hidden" value="2">
  43 + <input name="row[integral_goods_id]" type="hidden" value="{$_GET['goods_id']}">
  44 + {/if}
33 <div class="form-group"> 45 <div class="form-group">
34 <label class="control-label col-xs-12 col-sm-2">{:__('Stock_num')}:</label> 46 <label class="control-label col-xs-12 col-sm-2">{:__('Stock_num')}:</label>
35 <div class="col-xs-12 col-sm-8"> 47 <div class="col-xs-12 col-sm-8">
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 <input id="c-area_id" data-rule="required" data-source="area/index" data-params='{"custom[pid]":"0"}' class="form-control selectpage" name="row[area_id]" type="text" value="{$row.area_id|htmlentities}"> 6 <input id="c-area_id" data-rule="required" data-source="area/index" data-params='{"custom[pid]":"0"}' class="form-control selectpage" name="row[area_id]" type="text" value="{$row.area_id|htmlentities}">
7 </div> 7 </div>
8 </div> 8 </div>
  9 + {if $_GET['type'] eq 'null'}
9 <div class="form-group"> 10 <div class="form-group">
10 <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label> 11 <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
11 <div class="col-xs-12 col-sm-8"> 12 <div class="col-xs-12 col-sm-8">
@@ -30,6 +31,17 @@ @@ -30,6 +31,17 @@
30 <input id="c-integral_goods_id" data-rule="required" data-source="integral_goods/index" data-field="ch_name" class="form-control selectpage" name="row[integral_goods_id]" type="text" value="{$row.goods_id|htmlentities}"> 31 <input id="c-integral_goods_id" data-rule="required" data-source="integral_goods/index" data-field="ch_name" class="form-control selectpage" name="row[integral_goods_id]" type="text" value="{$row.goods_id|htmlentities}">
31 </div> 32 </div>
32 </div> 33 </div>
  34 + {/if}
  35 + {if $_GET['type'] eq 1}
  36 + <input name="row[type]" type="hidden" value="1">
  37 + <input name="row[goods_id]" type="hidden" value="{$_GET['goods_id']}">
  38 +
  39 + {/if}
  40 +
  41 + {if $_GET['type'] eq 2}
  42 + <input name="row[type]" type="hidden" value="2">
  43 + <input name="row[integral_goods_id]" type="hidden" value="{$_GET['goods_id']}">
  44 + {/if}
33 <div class="form-group"> 45 <div class="form-group">
34 <label class="control-label col-xs-12 col-sm-2">{:__('Stock_num')}:</label> 46 <label class="control-label col-xs-12 col-sm-2">{:__('Stock_num')}:</label>
35 <div class="col-xs-12 col-sm-8"> 47 <div class="col-xs-12 col-sm-8">
@@ -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: 'depot/index' + location.search, 8 index_url: 'depot/index' + location.search,
9 - add_url: 'depot/add',  
10 - edit_url: 'depot/edit', 9 + add_url: 'depot/add?type=' + Fast.api.query('type') + '&goods_id=' + Fast.api.query('goods_id'),
  10 + edit_url: 'depot/edit?type=' + Fast.api.query('type') + '&goods_id=' + Fast.api.query('goods_id'),
11 del_url: 'depot/del', 11 del_url: 'depot/del',
12 multi_url: 'depot/multi', 12 multi_url: 'depot/multi',
13 table: 'depot', 13 table: 'depot',
@@ -66,13 +66,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -66,13 +66,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
66 { 66 {
67 name: 'depot', title: '仓库信息', icon: 'fa fa-bars', 67 name: 'depot', title: '仓库信息', icon: 'fa fa-bars',
68 classname: 'btn btn-xs btn-warning btn-dialog', 68 classname: 'btn btn-xs btn-warning btn-dialog',
69 - url: 'depot/index/goods_id/{id}/type/1' 69 + url: 'depot/index/goods_id/{id}/type/1',
  70 + extend: "data-area='[\"65%\",\"80%\"]'"
70 }, 71 },
71 { 72 {
72 name: 'evaluate', title: '评价信息', icon: 'fa fa-bars', 73 name: 'evaluate', title: '评价信息', icon: 'fa fa-bars',
73 classname: 'btn btn-xs btn-info btn-dialog', 74 classname: 'btn btn-xs btn-info btn-dialog',
74 url: 'evaluate/index/goods_id/{id}/type/1', 75 url: 'evaluate/index/goods_id/{id}/type/1',
75 - // extend: 'data-area=\'["1400px", "650px"]\'' 76 + extend: "data-area='[\"65%\",\"80%\"]'",
76 } 77 }
77 ] 78 ]
78 } 79 }