...
|
...
|
@@ -33,8 +33,19 @@ class Ggoods extends Backend |
|
|
}
|
|
|
$this->assign('gtype',$arr);
|
|
|
|
|
|
//品牌分类名称
|
|
|
$res = Db::name('btype')->field('id,name,address')->select();
|
|
|
$arr = [];
|
|
|
foreach($res as $value){
|
|
|
$arr[$value['id']] = $value['name'].'------'.$value['address'];
|
|
|
}
|
|
|
$this->assign('btype',$arr);
|
|
|
|
|
|
//商品标识
|
|
|
$this->assign('flag',[1=>'推荐',2=>'设计师作品',3=>'新人特惠']);
|
|
|
|
|
|
//商品分类
|
|
|
$this->assign('g_type',[1=>'品类',2=>'品牌',3=>'全部']);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -132,10 +143,47 @@ class Ggoods extends Backend |
|
|
$params['is_new'] = 0;
|
|
|
}
|
|
|
|
|
|
$params['type'] = 0;
|
|
|
$res = Db::name('gtype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$params['type_name'] = $res['name'];
|
|
|
$result = $this->model->allowField(true)->save($params);
|
|
|
//处理商品分类逻辑
|
|
|
$g_type = $params['g_type'];
|
|
|
if($g_type == 1){
|
|
|
//品类,销毁商品分类变量,品牌分类字段
|
|
|
unset($params['g_type'],$params['b_id']);
|
|
|
|
|
|
$params['type'] = 0;
|
|
|
$res = Db::name('gtype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$params['type_name'] = $res['name'];
|
|
|
$result = $this->model->allowField(true)->save($params);
|
|
|
|
|
|
}else if($g_type == 2){
|
|
|
//品牌,销毁商品分类变量,品类分类,品牌分类字段
|
|
|
$params['t_id'] = $params['b_id'];
|
|
|
unset($params['g_type'],$params['b_id']);
|
|
|
|
|
|
$params['type'] = 1;
|
|
|
$res = Db::name('btype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$params['type_name'] = $res['name'];
|
|
|
$result = $this->model->allowField(true)->save($params);
|
|
|
}else{
|
|
|
//全部
|
|
|
unset($params['g_type']);
|
|
|
//品类
|
|
|
$same_time = time();
|
|
|
$arr = [];
|
|
|
$arr[0] = $params;
|
|
|
$arr[0]['type'] = 0;
|
|
|
$res = Db::name('gtype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$arr[0]['type_name'] = $res['name'];
|
|
|
$arr[0]['same'] = $same_time;
|
|
|
//品牌
|
|
|
$arr[1] = $params;
|
|
|
$arr[1]['type'] = 1;
|
|
|
$arr[1]['t_id'] = $params['b_id'];
|
|
|
$res1 = Db::name('btype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$arr[1]['type_name'] = $res1['name'];
|
|
|
$arr[1]['same'] = $same_time;
|
|
|
$result = $this->model->allowField(true)->saveAll($arr);
|
|
|
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (ValidateException $e) {
|
|
|
Db::rollback();
|
...
|
...
|
@@ -208,9 +256,31 @@ class Ggoods extends Backend |
|
|
$params['is_new'] = 0;
|
|
|
}
|
|
|
|
|
|
$res = Db::name('gtype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$params['type_name'] = $res['name'];
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
//查询是否为相同的商品
|
|
|
$res1 = Db::name('goods')->where(['id'=>$ids])->field('id,same')->find();
|
|
|
if($res1['same'] == 0){
|
|
|
$res = Db::name('gtype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$params['type_name'] = $res['name'];
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
}else{
|
|
|
//更新品类商品,也更相同的品牌商品
|
|
|
$arr = [];
|
|
|
$arr[0] = $params;
|
|
|
$arr[0]['id'] = $ids;
|
|
|
$res = Db::name('gtype')->where('id',$params['t_id'])->field('id,name')->find();
|
|
|
$arr[0]['type_name'] = $res['name'];
|
|
|
//品牌
|
|
|
$count = Db::name('goods')->where(['same'=>$res1['same']])->useSoftDelete('deletetime')->count();
|
|
|
if($count == 2){
|
|
|
$res2 = Db::name('goods')->where(['same'=>$res1['same']])->field('id,type,type_name,t_id')->order('id desc')->find();
|
|
|
$arr[1] = $params;
|
|
|
$arr[1]['id'] = $res2['id'];
|
|
|
$arr[1]['type'] = $res2['type'];
|
|
|
$arr[1]['type_name'] = $res2['type_name'];
|
|
|
$arr[1]['t_id'] = $res2['t_id'];
|
|
|
}
|
|
|
$result = $this->model->allowField(true)->saveAll($arr);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (ValidateException $e) {
|
|
|
Db::rollback();
|
...
|
...
|
|