edit-api-auto_biz

This commit is contained in:
lccsw
2023-01-30 15:40:49 +08:00
parent f6f17c4e21
commit 984875b0fe
7 changed files with 77 additions and 36 deletions
+1
View File
@@ -329,4 +329,5 @@ class Brand extends HD_Controller{
echo '执行完毕';
}
}
}
+44 -10
View File
@@ -22,6 +22,7 @@ class Store extends HD_Controller
$this->load->model("biz/biz_trucking_model");
$this->load->model('app/licheb/app_licheb_users_model', 'mdLichebUsers');
$this->load->model('auto/auto_brand_model');
$this->load->model('auto/auto_brand_biz_model');
$this->load->model("biz/biz_brand_model", 'bizBrand');
$this->load->model('area_model');
@@ -203,9 +204,9 @@ class Store extends HD_Controller
}
}
if ($biz['jsondata']) {
$jsondata = json_decode($biz['jsondata'], true);
$biz['auto_brands'] = $jsondata ? $jsondata['auto_brands'] : array();
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$biz['id']],'','','','brand_id');
if ($b_biz_rows) {
$biz['auto_brands'] = array_column($b_biz_rows,'brand_id');
} else {
$biz['auto_brands'] = array();
}
@@ -356,14 +357,47 @@ class Store extends HD_Controller
//授权品牌
$auto_brands = $this->input->post('auto_brands');
$old = $this->biz_model->get(array('id' => $id));
$jsondata = json_decode($old['jsondata'], true);
if ($auto_brands) {
$jsondata['auto_brands'] = $auto_brands;
} else {
unset($jsondata['auto_brands']);
// $old = $this->biz_model->get(array('id' => $id));
// $jsondata = json_decode($old['jsondata'], true);
// if ($auto_brands) {
// $jsondata['auto_brands'] = $auto_brands;
// } else {
// 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);
}
}
$biz['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE);
//商家标签
$tag_more = $this->input->post('tag_more');
+7 -8
View File
@@ -22,6 +22,7 @@ class Series extends Wxapp{
$this->load->model('auto/auto_series_model');
$this->load->model('auto/auto_attr_model');
$this->load->model('auto/auto_cars_model');
$this->load->model('auto/auto_brand_biz_model');
$this->load->model("biz/biz_model");
}
//获取车系
@@ -57,11 +58,9 @@ class Series extends Wxapp{
];
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
if($biz_id){
$biz = $this->biz_model->get(['id'=>$biz_id],'jsondata');
$jsondata = json_decode($biz['jsondata'],true);
$auto_brands = $jsondata['auto_brands'] ? $jsondata['auto_brands'] : [0];
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$biz_id],'','','','brand_id');
$str_brands = implode(',',$auto_brands);
$str_brands = implode(',',array_column($b_biz_rows,'brand_id'));
!$str_brands && $str_brands = 0;
$where["id in ($str_brands)"] = null;
}
@@ -85,11 +84,11 @@ class Series extends Wxapp{
$user = $this->app_user_model->get(array('id' => $uid));
if(isset($user['biz_id'])){
$biz_id = $this->session['new_biz_id'] ? $this->session['new_biz_id'] : intval($this->session['biz_id']);
$biz = $this->biz_model->get(['id'=>$biz_id],'jsondata');
$jsondata = json_decode($biz['jsondata'],true);
$auto_brands = $jsondata['auto_brands'] ? $jsondata['auto_brands'] : [0];
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$biz_id],'','','','brand_id');
$str_brands = implode(',',array_column($b_biz_rows,'brand_id'));
!$str_brands && $str_brands = 0;
$str_brands = implode(',',$auto_brands);
$where["brand_id in ($str_brands)"] = null;
}
if($id){ //只显示相同品牌
+4 -2
View File
@@ -22,6 +22,7 @@ class Biz extends Wxapp
$this->check_headimg = array();//授权微信信息
$this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders');
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
$this->load->model('auto/auto_brand_biz_model');
$this->biz_id = $this->get_biz_id();
}
@@ -301,11 +302,12 @@ class Biz extends Wxapp
$y_month = date('Y-m', strtotime("-1 month"));//上个月
$re_sell = $this->mdBizSell->get(['biz_id' => $biz_id, 'y_month' => $y_month]);
$fields = $this->mdBizSell->get_fields();
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$biz_id],'','','','brand_id');
foreach ($fields as $key => $value) {
if ($key == 'y_month') {
$fields[$key]['value'] = $y_month;
} else if ($key == 'cooperation_car' && $jsondata['auto_brands']) {
$auto_brands = implode(',', $jsondata['auto_brands']);
} else if ($key == 'cooperation_car' && $b_biz_rows) {
$auto_brands = implode(',', array_column($b_biz_rows,'brand_id'));
$res_ab = $this->mdAutoBrand->select(["id in({$auto_brands})" => null], 'id desc', 0, 0, 'name');
$res_ab && $fields[$key]['value'] = array_column($res_ab, 'name');
} else if ($key == 'sales') {
+4 -4
View File
@@ -24,6 +24,7 @@ class User extends Wxapp
$this->load->model("biz/biz_model");
$this->load->model('auto/auto_brand_model');
$this->load->model('auto/auto_brand_biz_model');
$this->load->model('items/items_model', 'mdItems');
$this->load->model('items/items_oplogs_model', 'mdItemsOplogs');
$this->load->library('receiver/orders_v2_entity');
@@ -477,10 +478,9 @@ class User extends Wxapp
if ($bizs) {
foreach ($bizs as $key => $val) {
$auto_brands = [];
$jsondata = json_decode($val['jsondata'], true);
$auto_brands_arr = $jsondata['auto_brands'];
$brand_ids = implode(',', $auto_brands_arr);
if ($auto_brands_arr && $brand_ids) {
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$val['id']],'','','','brand_id');
$brand_ids = implode(',', array_column($b_biz_rows,'brand_id'));
if ($b_biz_rows && $brand_ids) {
$where = [
"id in ($brand_ids)" => null,
"id !=" => 3 //过滤狸车品牌
+15 -7
View File
@@ -27,6 +27,7 @@ class Biz extends Wxapp
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
$this->load->model('auto/auto_attr_model', 'mdAutoAttr');
$this->load->model('auto/auto_brand_biz_model');
$this->load->model("biz/biz_model", 'mdBiz');
$this->load->model('items/items_model', 'mdItems');
$this->app_id == 1 && $this->app_id = 2;//获取狸车宝数据
@@ -142,14 +143,21 @@ class Biz extends Wxapp
$this->mdMaterialBizStatistics->add($where_s);
}
$auto_brands = $list = array();
if ($re['jsondata']) {
$jsondata = json_decode($re['jsondata'], true);
if ($jsondata['auto_brands']) {
$brand_ids = implode(',', $jsondata['auto_brands']);
$res_b = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'name');
$res_b && $auto_brands = array_column($res_b, 'name');
}
// if ($re['jsondata']) {
// $jsondata = json_decode($re['jsondata'], true);
// if ($jsondata['auto_brands']) {
// $brand_ids = implode(',', $jsondata['auto_brands']);
// $res_b = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'name');
// $res_b && $auto_brands = array_column($res_b, 'name');
// }
// }
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$biz_id],'','','','brand_id');
if($b_biz_rows){
$brand_ids = implode(',',array_column($b_biz_rows,'brand_id'));
$res_b = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'name');
$res_b && $auto_brands = array_column($res_b, 'name');
}
$where = ['a.status' => 1, 'b.app_id' => $this->app_id, 'b.biz_id' => $biz_id];
$this->mdTemplate->db->from('lc_material_template as a');
$this->mdTemplate->db->join('lc_material_biz as b', "b.t_id=a.id", 'left');
+2 -5
View File
@@ -153,11 +153,8 @@ class Home extends Wxapp
!$type && $type = 1;
$brand_ids = array();
if ($this->biz_id) {//查找门店授权品牌
$re_b = $this->mdBiz->get(array('id' => $this->biz_id, 'status' => 1));
if ($re_b['jsondata']) {
$jsondata = json_decode($re_b['jsondata'], true);
$jsondata['auto_brands'] && $brand_ids = $jsondata['auto_brands'];
}
$b_biz_rows = $this->auto_brand_biz_model->select(['biz_id'=>$this->biz_id],'','','','brand_id');
$brand_ids = array_column($b_biz_rows,'brand_id');
}
$lists = array();
$total = 0;