diff --git a/admin/controllers/app/material/Template.php b/admin/controllers/app/material/Template.php
index f5702d8c..d564372f 100644
--- a/admin/controllers/app/material/Template.php
+++ b/admin/controllers/app/material/Template.php
@@ -224,6 +224,7 @@ class Template extends HD_Controller
: array('value' => '', 'src' => '');
if ($info['brand_ids']) {
$brand_ids = str_replace(",0", "", $info['brand_ids']);
+ $brand_ids = str_replace("0,", "", $brand_ids);
$brands = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1), "id desc", 0, 0, 'id,name');
}
$_title = '编辑素材模板';
@@ -275,7 +276,10 @@ class Template extends HD_Controller
}
$brand_ids = '';
if ($info['brand_ids']) {
- $brand_ids = implode(',', $info['brand_ids']);
+ if (!strstr($info['brand_ids'], '0,')) {
+ $brand_ids = '0,';
+ }
+ $brand_ids .= implode(',', $info['brand_ids']);
if (!strstr($brand_ids, ',0')) {
$brand_ids .= ',0';
}
@@ -337,7 +341,10 @@ class Template extends HD_Controller
}
$brand_ids = '';
if ($info['brand_ids']) {
- $brand_ids = implode(',', $info['brand_ids']);
+ if (!strstr($info['brand_ids'], '0,')) {
+ $brand_ids = '0,';
+ }
+ $brand_ids .= implode(',', $info['brand_ids']);
if (!strstr($brand_ids, ',0')) {
$brand_ids .= ',0';
}
diff --git a/api/controllers/plan/Temp.php b/api/controllers/plan/Temp.php
index 7971d31a..0819293c 100644
--- a/api/controllers/plan/Temp.php
+++ b/api/controllers/plan/Temp.php
@@ -16,6 +16,53 @@ class Temp extends HD_Controller
$this->log_file = 'temp.log';
}
+ /**
+ * Notes:更新战败客户到店
+ * Created on: 2022/3/09 11:58
+ * Created by: dengbw
+ * https://liche-api-dev.xiaoyu.com/plan/temp/material_template
+ * https://api.liche.cn/plan/temp/material_template
+ */
+ public function material_template()
+ {
+ $this->load->model('app/material/Material_template_model', 'mdTemplate');
+ $param = $this->input->get();
+ $param['page'] = intval($param['page']);
+ $param['size'] = intval($param['size']);
+ !$param['size'] && $param['size'] = 100;
+ !$param['page'] && $param['page'] = 1;
+ $counts = intval($param['counts']);
+ ob_start(); //打开缓冲区
+ $where = ["id>" => 0];
+ $res = $this->mdTemplate->select($where, 'id ASC', $param['page'], $param['size'], 'id,brand_ids');
+ if (!$res) {
+ echo '
本次更新完成了:';
+ echo '
成功更新 ' . $counts . ' 条';
+ echo '
点击将再次更新>>>';
+ exit;
+ }
+ $log = array();
+ foreach ($res as $key => $value) {
+ $brand_ids = $value['brand_ids'];
+ if ($brand_ids) {
+ if (!strstr($brand_ids, '0,')) {
+ $brand_ids = '0,'.$brand_ids;
+ $ret = $this->mdTemplate->update(['brand_ids' => $brand_ids], ['id' => $value['id']]);
+ if ($ret == 1) {
+ $log[] = ['id' => $value['id'], 'brand_ids' => $brand_ids];
+ $counts++;
+ }
+ }
+ }
+ }
+ echo '
成功更新:';
+ $log && print_r($log);
+ echo '
数据库获取:';
+ echo json_encode($res, JSON_UNESCAPED_UNICODE);
+ header('refresh:3;url=/plan/temp/material_template?counts=' . $counts . '&size=' . $param['size'] . '&page=' . ($param['page'] + 1));
+ ob_end_flush();//输出全部内容到浏览器
+ }
+
/**
* Notes:更新战败客户到店
* Created on: 2022/3/09 11:58
diff --git a/api/controllers/wxapp/material/Home.php b/api/controllers/wxapp/material/Home.php
index 91e13916..1ec7d3b7 100644
--- a/api/controllers/wxapp/material/Home.php
+++ b/api/controllers/wxapp/material/Home.php
@@ -38,29 +38,29 @@ class Home extends Wxapp
*/
protected function get_tabs()
{
- //$distribute = intval($this->input_param('distribute'));
- $distribute = 1;//显示所有品牌
$list = array();
- $res = [];
- if ($distribute == 1) {//分销
- $res = $this->mdAutoBrand->select(array('status' => 1, 'id<>' => 3), "id desc", 0, 0, 'id,name');
- } else {
- 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);
- if ($jsondata['auto_brands']) {
- $brand_ids = implode($jsondata['auto_brands'], ',');
- !$brand_ids && $brand_ids = $jsondata['auto_brands'];
- $res = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1, 'id<>' => 3), "id desc", 0, 0, 'id,name');
- }
- }
- }
- }
+ $res = $this->mdAutoBrand->select(array('status' => 1, 'id<>' => 3), "id desc", 0, 0, 'id,name');//显示所有品牌
+// $distribute = intval($this->input_param('distribute'));
+// $res = [];
+// if ($distribute == 1) {//分销
+// $res = $this->mdAutoBrand->select(array('status' => 1, 'id<>' => 3), "id desc", 0, 0, 'id,name');
+// } else {
+// 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);
+// if ($jsondata['auto_brands']) {
+// $brand_ids = implode($jsondata['auto_brands'], ',');
+// !$brand_ids && $brand_ids = $jsondata['auto_brands'];
+// $res = $this->mdAutoBrand->select(array("id in ({$brand_ids})" => null, 'status' => 1, 'id<>' => 3), "id desc", 0, 0, 'id,name');
+// }
+// }
+// }
+// }
//根据品牌做分类
if ($res) {
foreach ($res as $key => $value) {
- $brand_id = $value['id'] . ',';
+ $brand_id = ',' . $value['id'] . ',';
$where = array('app_id' => $this->app_id, 'type in(4,1)' => null, "brand_ids like '%{$brand_id}%'" => null, 'status' => 1);
$total = $this->mdTemplate->count($where);
if ($total > 0) {
@@ -73,7 +73,7 @@ class Home extends Wxapp
array_multisort($timeKey, SORT_DESC, $list);//排序,根据$total 排序
}
}
- $list[] = ['id' => '3', 'name' => '狸车'];//全品牌蓄客
+ $list[] = ['id' => 3, 'name' => '狸车'];//全品牌蓄客
$this->data['title'] = '推广素材';
$this->data['list'] = $list;
$this->data['list_type'] = [['id' => 4, 'name' => '图片'], ['id' => 1, 'name' => '视频']];
@@ -100,7 +100,7 @@ class Home extends Wxapp
if ($brand_id) {
!$page && $page = 1;
!$size && $size = 8;
- $brand_id = $brand_id . ',';
+ $brand_id = ',' . $brand_id . ',';
$where = array('app_id' => $this->app_id, 'type' => $type, "brand_ids like '%{$brand_id}%'" => null, 'status' => 1);
$total = $this->mdTemplate->count($where);
$fileds = 'id,title,cover,json_data';