store add fixbug auo_brands to table
This commit is contained in:
@@ -285,10 +285,10 @@ class Store extends HD_Controller
|
||||
}
|
||||
|
||||
$auto_brands = $this->input->post('auto_brands');
|
||||
if ($auto_brands) {
|
||||
/*if ($auto_brands) {
|
||||
$jsondata = array('auto_brands' => $auto_brands);
|
||||
$biz['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}*/
|
||||
|
||||
//上传头像
|
||||
$biz['headimg'] = $this->input->post('headimg');
|
||||
@@ -303,6 +303,7 @@ class Store extends HD_Controller
|
||||
if (!$id) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
||||
}
|
||||
$this->grant_auto_brands($auto_brands, $id, $biz['type']);
|
||||
|
||||
foreach ($tag_more as $key => $value) {
|
||||
if ($value) {
|
||||
@@ -319,6 +320,42 @@ class Store extends HD_Controller
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
private function grant_auto_brands($auto_brands, $id, $biz_type){
|
||||
if($auto_brands){
|
||||
$brand_ids = implode(',',$auto_brands);
|
||||
$where = [
|
||||
'biz_id' => $id,
|
||||
"brand_id not in ({$brand_ids})" => null,
|
||||
];
|
||||
if($this->auto_brand_biz_model->count($where)){
|
||||
$this->auto_brand_biz_model->delete($where);
|
||||
}
|
||||
$add_datas = [];
|
||||
foreach ($auto_brands as $key => $val) {
|
||||
$where = [
|
||||
'biz_id' => $id,
|
||||
'brand_id' => $val
|
||||
];
|
||||
if(!$this->auto_brand_biz_model->count($where)){
|
||||
$add_datas[] = [
|
||||
'biz_id' => $id,
|
||||
'type' => $biz_type,
|
||||
'brand_id' => $val,
|
||||
'c_time' => time()
|
||||
];
|
||||
}
|
||||
}
|
||||
$add_datas && $this->auto_brand_biz_model->add_batch($add_datas);
|
||||
}else{
|
||||
$where = [
|
||||
'biz_id' => $id,
|
||||
];
|
||||
if($this->auto_brand_biz_model->count($where)){
|
||||
$this->auto_brand_biz_model->delete($where);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
if (!$this->if_ajax) {
|
||||
@@ -371,39 +408,7 @@ class Store extends HD_Controller
|
||||
// unset($jsondata['auto_brands']);
|
||||
// }
|
||||
// $biz['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
|
||||
if($auto_brands){
|
||||
$brand_ids = implode(',',$auto_brands);
|
||||
$where = [
|
||||
'biz_id' => $id,
|
||||
"brand_id not in ({$brand_ids})" => null,
|
||||
];
|
||||
if($this->auto_brand_biz_model->count($where)){
|
||||
$this->auto_brand_biz_model->delete($where);
|
||||
}
|
||||
$add_datas = [];
|
||||
foreach ($auto_brands as $key => $val) {
|
||||
$where = [
|
||||
'biz_id' => $id,
|
||||
'brand_id' => $val
|
||||
];
|
||||
if(!$this->auto_brand_biz_model->count($where)){
|
||||
$add_datas[] = [
|
||||
'biz_id' => $id,
|
||||
'type' => $biz['type'],
|
||||
'brand_id' => $val,
|
||||
'c_time' => time()
|
||||
];
|
||||
}
|
||||
}
|
||||
$add_datas && $this->auto_brand_biz_model->add_batch($add_datas);
|
||||
}else{
|
||||
$where = [
|
||||
'biz_id' => $id,
|
||||
];
|
||||
if($this->auto_brand_biz_model->count($where)){
|
||||
$this->auto_brand_biz_model->delete($where);
|
||||
}
|
||||
}
|
||||
$this->grant_auto_brands($auto_brands, $id, $biz['type']);
|
||||
|
||||
//门店标签
|
||||
$tag_more = $this->input->post('tag_more');
|
||||
|
||||
Reference in New Issue
Block a user