作者 耿培杰

完善后台仓库管理

... ... @@ -112,6 +112,7 @@ class Depot extends Backend
if ($params['type'] == 2) $params['goods_id'] = $params['integral_goods_id'];
$result = $this->model->allowField(true)->save($params);
$stock_num = $this->model->where(['goods_id'=>$params['goods_id'],'type'=>$params['type']])->sum('stock_num');
if ($params['type'] == 1) $this->goodsModel->where('id',$params['goods_id'])->update(['stock_num'=>$stock_num]);
else $this->integralGoodsModel->where('id',$params['goods_id'])->update(['stock_num'=>$stock_num]);
Db::commit();
... ...
... ... @@ -109,6 +109,15 @@ class Goods extends Backend
$this->model->validateFailException(true)->validate($validate);
}
if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ',';
if ($params['is_group'] == 1){
if (empty($params['group_num'])) $this->error('团购人数不能为空');
if (!empty($params['group_num']) && $params['group_num'] == 1) $this->error('团购人数必须大于1人');
if (empty($params['grouptime'])) $this->error('团购有效时间不能为空');
if (empty($params['group_vip_rebate'])) $this->error('团购会员返利不能为空');
if (empty($params['group_staff_rebate'])) $this->error('团购员工返利不能为空');
if (empty($params['group_agency_rebate'])) $this->error('团购代理返利不能为空');
if (empty($params['group_price'])) $this->error('团购价格不能为空');
}
$result = $this->model->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
... ... @@ -161,6 +170,15 @@ class Goods extends Backend
$row->validateFailException(true)->validate($validate);
}
if (!empty($params['category_group_ids'])) $params['category_group_ids'] = ',' . $params['category_group_ids'] . ',';
if ($params['is_group'] == 1){
if (empty($params['group_num'])) $this->error('团购人数不能为空');
if (!empty($params['group_num']) && $params['group_num'] == 1) $this->error('团购人数必须大于1人');
if (empty($params['grouptime'])) $this->error('团购有效时间不能为空');
if (empty($params['group_vip_rebate'])) $this->error('团购会员返利不能为空');
if (empty($params['group_staff_rebate'])) $this->error('团购员工返利不能为空');
if (empty($params['group_agency_rebate'])) $this->error('团购代理返利不能为空');
if (empty($params['group_price'])) $this->error('团购价格不能为空');
}
$result = $row->allowField(true)->save($params);
Db::commit();
} catch (ValidateException $e) {
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Area_id')}:</label>
<div class="col-xs-12 col-sm-8">
<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="">
</div>
</div>
{if $_GET['type'] eq 'null'}
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
... ... @@ -30,6 +30,18 @@
<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="">
</div>
</div>
{/if}
{if $_GET['type'] eq 1}
<input name="row[type]" type="hidden" value="1">
<input name="row[goods_id]" type="hidden" value="{$_GET['goods_id']}">
{/if}
{if $_GET['type'] eq 2}
<input name="row[type]" type="hidden" value="2">
<input name="row[integral_goods_id]" type="hidden" value="{$_GET['goods_id']}">
{/if}
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Stock_num')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -6,6 +6,7 @@
<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}">
</div>
</div>
{if $_GET['type'] eq 'null'}
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
... ... @@ -30,6 +31,17 @@
<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}">
</div>
</div>
{/if}
{if $_GET['type'] eq 1}
<input name="row[type]" type="hidden" value="1">
<input name="row[goods_id]" type="hidden" value="{$_GET['goods_id']}">
{/if}
{if $_GET['type'] eq 2}
<input name="row[type]" type="hidden" value="2">
<input name="row[integral_goods_id]" type="hidden" value="{$_GET['goods_id']}">
{/if}
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Stock_num')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -6,8 +6,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
Table.api.init({
extend: {
index_url: 'depot/index' + location.search,
add_url: 'depot/add',
edit_url: 'depot/edit',
add_url: 'depot/add?type=' + Fast.api.query('type') + '&goods_id=' + Fast.api.query('goods_id'),
edit_url: 'depot/edit?type=' + Fast.api.query('type') + '&goods_id=' + Fast.api.query('goods_id'),
del_url: 'depot/del',
multi_url: 'depot/multi',
table: 'depot',
... ...
... ... @@ -66,13 +66,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{
name: 'depot', title: '仓库信息', icon: 'fa fa-bars',
classname: 'btn btn-xs btn-warning btn-dialog',
url: 'depot/index/goods_id/{id}/type/1'
url: 'depot/index/goods_id/{id}/type/1',
extend: "data-area='[\"65%\",\"80%\"]'"
},
{
name: 'evaluate', title: '评价信息', icon: 'fa fa-bars',
classname: 'btn btn-xs btn-info btn-dialog',
url: 'evaluate/index/goods_id/{id}/type/1',
// extend: 'data-area=\'["1400px", "650px"]\''
extend: "data-area='[\"65%\",\"80%\"]'",
}
]
}
... ...