作者 耿培杰

编辑购物车接口,后台分组管理

... ... @@ -53,20 +53,24 @@ class Goods extends Backend
if ($this->request->request('keyField')) {
return $this->selectpage();
}
$category_group_id = $this->request->param('category_group_id');
$where1 = [];
if (!empty($category_group_id)) $where1['category_group_ids'] = ['like','%,'.$category_group_id.',%'];
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->with(['brand', 'category', 'category2', 'level', 'country', 'part', 'categorygroup', 'depot'])
->where($where)
->where($where1)
->order($sort, $order)
->count();
$list = $this->model
->with(['brand', 'category', 'category2', 'level', 'country', 'part', 'categorygroup', 'depot'])
->where($where)
->where($where1)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $key => $row) {
// $row->getRelation('brand')->visible(['id']);
... ...
... ... @@ -5,7 +5,8 @@ return [
'En_title' => '英文标题',
'Ch_content' => '中文内容',
'En_content' => '英文内容',
'Image' => '图片',
'Image' => '中文图片',
'en_image' => '英文图片',
'Status' => '状态',
'Status 1' => '显示',
'Status 2' => '隐藏',
... ...
... ... @@ -39,6 +39,20 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('En_image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-en_image" class="form-control" size="50" name="row[en_image]" type="text">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-en_image" class="btn btn-danger plupload" data-input-id="c-en_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-en_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-en_image" class="btn btn-primary fachoose" data-input-id="c-en_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-en_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-en_image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -40,6 +40,20 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('En_image')}:</label>
<div class="col-xs-12 col-sm-8">
<div class="input-group">
<input id="c-en_image" class="form-control" size="50" name="row[en_image]" type="text" value="{$row.en_image|htmlentities}">
<div class="input-group-addon no-border no-padding">
<span><button type="button" id="plupload-en_image" class="btn btn-danger plupload" data-input-id="c-en_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp" data-multiple="false" data-preview-id="p-en_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
<span><button type="button" id="fachoose-en_image" class="btn btn-primary fachoose" data-input-id="c-en_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
</div>
<span class="msg-box n-right" for="c-en_image"></span>
</div>
<ul class="row list-inline plupload-preview" id="p-en_image"></ul>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -194,6 +194,63 @@ class Car extends Api
}
/**
* @ApiTitle (编辑购物车)
* @ApiSummary (编辑购物车)
* @ApiMethod (POST)
* @ApiRoute (/api/car/editCar)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name=car_id, type=string, required=true, description="购物车id")
* @ApiParams (name=number, type=string, required=true, description="数量")
* @ApiReturn({
"code": 1,
"msg": "SUCCESS",
"time": "1587472510",
"data": {
"total": 1,
"list": [
{
"content": "content", 评论内容
"images": [
"http://q7s0a1rb4.bkt.clouddn.com/uploads/20200420/26f5e51b8ac7fbd6f1c649cc45a18265.png" 评论图片
],
"createtime": "2020-04-20", 评论日期
"avatar": "avatar", 用户头像
"nickname": "admin" 用户昵称
}
]
}
})
*/
public function editCar(){
$userId = $this->getUserId();
$data = $this->request->param();
$data['user_id'] = $userId;
$validate = new Validate([
'car_id' => 'require',
'number' => 'require',
]);
$validate->message([
'car_id' => '缺少参数 car_id!',
'number' => '缺少参数 number!',
]);
if (!$validate->check($data)) {
$this->error($validate->getError());
}
if ($data['number'] == 0) $this->error('数量不能为0');
$carInfo = $this->carModel->where('id',$data['car_id'])->find();
$stock_num = Db::name('goods')->where(['id'=>$carInfo['goods_id']])->value('stock_num');
if (empty($stock_num) || $stock_num < $data['number']) $this->error('库存不足');
$res = $this->carModel->where('id',$data['car_id'])->update(['number'=>$data['number']]);
if ($res) $this->success('SUCCESS');
else $this->error('ERROR');
}
/**
* @ApiTitle (购物车数量递增)
* @ApiSummary (购物车数量递增)
* @ApiMethod (POST)
... ...
... ... @@ -219,6 +219,7 @@ class UserAddress extends Api
{
$model = new UserAddressModel();
$areaModel = new Area();
$areaExtendModel = new AreaExtend();
$userId = $this->getUserId();
$where['user_id'] = $userId;
... ... @@ -227,6 +228,11 @@ class UserAddress extends Api
$ids = $data[$k]['province_id'].','.$data[$k]['city_id'].','.$data[$k]['county_id'];
$area = $areaModel->where(['id'=>['in',$ids]])->column('name');
$data[$k]['address'] = implode('',$area).$v['address'];
$where = ['province_id'=>$v['province_id'],'city_id'=>$v['city_id'],'county_id'=>$v['county_id']];
$is_special = $areaExtendModel->where($where)->value('is_special');
if (!$is_special) $is_special = $areaExtendModel->where(['province_id'=>$v['province_id']])->value('is_special');
$data[$k]['postage_type'] = $is_special;
}
$this->success('SUCCESS',$data);
... ...
... ... @@ -21,8 +21,8 @@ class ChoosePage extends Model
{
$where['status'] = 1;
if ($lang == 'ch') $field = 'id,ch_title title,image';
else $field = 'id,en_title title,image';
if ($lang == 'ch') $field = 'id,image';
else $field = 'id,en_image image';
$data = $this
->where($where)
... ...
此 diff 太大无法显示。
... ... @@ -36,7 +36,16 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{field: 'weigh', title: __('Weigh'), operate:false},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.toggle,yes:1,no:2},
{field: 'sitelist', title: __('Sitelist'), searchList: {"1":__('Sitelist 1'),"2":__('Sitelist 2'),"3":__('Sitelist 3')}, operate:'FIND_IN_SET', formatter: Table.api.formatter.label},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
buttons: [
{
name: 'goods', title: '商品信息', icon: 'fa fa-bars',
classname: 'btn btn-xs btn-warning btn-dialog',
url: 'goods/index?category_group_id={id}',
extend: "data-area='[\"65%\",\"80%\"]'"
}
]
}
]
]
});
... ...
... ... @@ -26,8 +26,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'ch_title', title: __('Ch_title')},
{field: 'en_title', title: __('En_title')},
// {field: 'en_title', title: __('En_title')},
{field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image,operate:false},
{field: 'en_image', title: __('En_image'), events: Table.api.events.image, formatter: Table.api.formatter.image,operate:false},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.toggle,yes:1,no:2},
{field: 'phone', title: __('Phone'),operate:false,visible:false},
{field: 'wechat', title: __('Wechat'),operate:false,visible:false},
... ...