From f67e786f2c54c7ce570bdffa12e075478a1c2c01 Mon Sep 17 00:00:00 2001
From: xxb
Date: Mon, 23 Aug 2021 11:47:53 +0800
Subject: [PATCH] liche update for biz list search by company and clues cfrom
support level2 when clues add
---
admin/controllers/biz/store/Store.php | 16 ++++++-
admin/controllers/receiver/Clues.php | 65 ++++++++++++++++++++++++---
admin/views/biz/store/lists.php | 12 +++++
admin/views/receiver/clues/get.php | 41 +++++++++++++++--
admin/views/receiver/clues/lists.php | 4 +-
sql/receiver/clue.sql | 35 +++++++++++----
6 files changed, 150 insertions(+), 23 deletions(-)
diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php
index 545db0f3..21c064df 100755
--- a/admin/controllers/biz/store/Store.php
+++ b/admin/controllers/biz/store/Store.php
@@ -38,6 +38,8 @@ class Store extends HD_Controller{
$this->data['brand_id'] = $brand_id = intval($this->input->get('brand_id'));
$this->data['content'] = $content = $this->input->get('content');
$this->data['article'] = $article = $this->input->get('article');
+ $this->data['company_id'] = $company_id = intval($this->input->get('company_id'));
+
$status_arr = array('del' => -1, 'off' => 0, 'on' => 1);
$this->data['provinces'] = $this->area_model->select(array(), '', 0, 0, 'distinct(province_id), province_name');
if($province_id){
@@ -62,6 +64,8 @@ class Store extends HD_Controller{
$where['status > -1'] = null;
}
+ $company_id && $where['company_id'] = $company_id;
+
!$page && $page = 1;
$pagesize = 20;
$bizname && $where['biz_name like "%' . $bizname . '%"'] = null;
@@ -71,7 +75,7 @@ class Store extends HD_Controller{
$county_id && $where['county_id'] = $county_id;
$biz_lists = $this->biz_model->select($where, 'id desc', $page, $pagesize);
- $count = $this->biz_model->count();
+ $count = $this->biz_model->count($where);
$bizlists = [];
foreach($biz_lists as $v){
$brand = $this->bizBrand->get(array('id' => $v['brand_id']), 'brand_name');
@@ -80,6 +84,13 @@ class Store extends HD_Controller{
$bizlists[] = $v;
}
+ //获取公司ID列表
+ $this->load->model("sys/sys_company_model", 'company_model');
+ $where = array('status' => 1);
+ $orderby = 'id desc';
+ $select = 'id, short';
+ $map_company = $this->company_model->map('id', 'short', $where, $orderby, 0, 0, $select);
+
//获取品牌
$lists = $this->bizBrand->select(array('status' => 1), '', '', '', 'brand_name,id');
$data = array();
@@ -89,7 +100,7 @@ class Store extends HD_Controller{
}
}
$this->data['brand_list'] = $data;
-
+ $this->data['companyAry'] = $map_company;
$this->data['lists'] = $bizlists;
$this->data['_title'] = '门店列表';
$this->data['pager'] = array('count' => ceil($count / $pagesize), 'curr' => $page, 'totle' => $count);
@@ -184,6 +195,7 @@ class Store extends HD_Controller{
public function add(){
+ $biz['status'] = 1;
$biz['biz_name'] = $this->input->post('biz_name', true);
if(!$biz['biz_name']){
return $this->show_json(SYS_CODE_FAIL, '商家名称不能为空');
diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php
index e8d2457f..e04f876d 100644
--- a/admin/controllers/receiver/Clues.php
+++ b/admin/controllers/receiver/Clues.php
@@ -182,10 +182,23 @@ class Clues extends HD_Controller
return $this->show_json(SYS_CODE_FAIL, '记录不存在');
}
+ $cf_id1 = '';
+ $cf_id2 = '';
+ if($row['cf_id']){
+ $row_cfrom = $this->clues_cfrom_model->get(array('id' => $row['cf_id']));
+ if($row_cfrom['pid']){
+ $cf_id1 = $row_cfrom['pid'];
+ $cf_id2 = $row['cf_id'];
+ } else {
+ $cf_id1 = $row['cf_id'];
+ }
+ }
+
$info = array(
'name' => $row['name'],
'mobile' => $row['mobile'],
- 'cf_id' => $row['cf_id'],
+ 'cf_id1' => $cf_id1,
+ 'cf_id2' => $cf_id2,
);
$title = "编辑线索";
$action = "edit";
@@ -193,18 +206,19 @@ class Clues extends HD_Controller
$info = array(
'name' => '',
'mobile' => '',
- 'cf_id' => '',
+ 'cf_id1' => '',
+ 'cf_id2' => '',
);
$title = "新增线索";
$action = "add";
}
- $where = array('status' => 1);
+ $where = array('status' => 1, 'pid' => 0);
$select = 'id, title';
$map_cfrom = $this->clues_cfrom_model->map('id', 'title', $where, '', 0, 0, $select);
$this->data['info'] = $info;
- $this->data['cfrom_ary'] = $map_cfrom;
+ $this->data['cfromAry'] = $map_cfrom;
$this->data['action'] = $action;
$this->data['_title'] = $title;
@@ -224,10 +238,18 @@ class Clues extends HD_Controller
return $this->show_json(SYS_CODE_FAIL, '手机号码不准确');
}
+ $cf_id = 0;
+ if($info['cf_id2']){
+ $cf_id = $info['cf_id2'];
+ } else if($info['cf_id1']) {
+ $cf_id = $info['cf_id1'];
+ }
+
$add = array(
'name' => $info['name'],
'mobile' => $info['mobile'],
- 'cf_id' => $info['cf_id'] ? $info['cf_id'] : 0,
+ 'cf_id' => $cf_id,
+ 'admin_id' => $this->uid,
'c_time' => time(),
);
$ret = $this->clues_model->add($add);
@@ -593,6 +615,39 @@ class Clues extends HD_Controller
}
}
+ /**
+ * 返回map select数据
+ * @return bool
+ */
+ function json_map_cfrom(){
+ $pid = $this->input->post('pid');
+ $status = $this->input->post('status');
+
+ $where = array();
+ if(strlen($pid) > 0){
+ $where['pid'] = $pid;
+ }
+
+ if(strlen($status) > 0){
+ $where['status'] = $status;
+ } else {
+ $where["status>-1"] = null;
+ }
+
+ $total = $this->clues_cfrom_model->count($where);
+ $map = array();
+ if($total){
+ $orderby = 'id desc';
+ $select= 'id, title';
+ $rows = $this->clues_cfrom_model->select($where, $orderby, 0, 0, $select);
+ foreach($rows as $v){
+ $map[$v['id']] = $v['title'];
+ }
+ }
+
+ $this->data = $map;
+ return $this->show_json(SYS_CODE_SUCCESS);
+ }
private function upload()
{
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . '/temp/';
diff --git a/admin/views/biz/store/lists.php b/admin/views/biz/store/lists.php
index 5061df34..9c00524b 100755
--- a/admin/views/biz/store/lists.php
+++ b/admin/views/biz/store/lists.php
@@ -69,6 +69,15 @@
+
@@ -79,6 +88,7 @@
+
共有= $pager['totle'] ?>条数据
@@ -142,9 +152,11 @@
el: '#vue-app',
data: {
brand_id: =$brand_id ? $brand_id : "''"?>,
+ company_id:=$company_id?$company_id: 0?>,
lists: {
brand: =json_encode($brand_list)?>
},
+ companyAry:=$companyAry?json_encode($companyAry):'[]'?>
},
methods: {
diff --git a/admin/views/receiver/clues/get.php b/admin/views/receiver/clues/get.php
index a1034cb1..41948e26 100644
--- a/admin/views/receiver/clues/get.php
+++ b/admin/views/receiver/clues/get.php
@@ -15,9 +15,13 @@
@@ -35,13 +39,14 @@
el: '#edit-form',
data: {
info:{},
- cfrom_ary:[],
+ cfromAry:[],
+ cfromAry2:[],
action:""
},
mounted:function() {
var vm = this;
vm.info = =json_encode($info, JSON_UNESCAPED_UNICODE)?>;
- vm.cfrom_ary = =json_encode($cfrom_ary, JSON_UNESCAPED_UNICODE)?>;
+ vm.cfromAry = =json_encode($cfromAry, JSON_UNESCAPED_UNICODE)?>;
vm.action = "=$action?>";
},
methods:{
@@ -82,6 +87,34 @@
}
});
}
+ },
+ watch:{
+ 'info.cf_id1':function(nv, ov){
+ var vm = this;
+ if(nv > 0){
+ $.ajax({
+ url: "receiver/clues/json_map_cfrom",
+ type: 'post',
+ dataType: 'json',
+ data: {
+ pid:vm.info.cf_id1,
+ status:1
+ },
+ beforeSend: function () {},
+ success: function (data) {
+ if (1 == data.code) {
+ vm.cfromAry2 = data.data;
+ if(undefined == vm.cfromAry2[vm.info.cf_id2]){
+ vm.info.cf_id2 = '';
+ }
+ }
+ }
+ });
+ } else {
+ vm.cfromAry2 = [];
+ vm.info.cf_id2 = '';
+ }
+ }
}
});
});
diff --git a/admin/views/receiver/clues/lists.php b/admin/views/receiver/clues/lists.php
index daf5a007..a1458d6e 100644
--- a/admin/views/receiver/clues/lists.php
+++ b/admin/views/receiver/clues/lists.php
@@ -80,9 +80,7 @@
-
- 共= intval($pager['totle']) ?>个客户
-
+
共有= $pager['totle'] ?>条数据
diff --git a/sql/receiver/clue.sql b/sql/receiver/clue.sql
index 2f777edc..4b95f7d8 100644
--- a/sql/receiver/clue.sql
+++ b/sql/receiver/clue.sql
@@ -52,13 +52,30 @@ create table lc_receiver_clue_oplogs (
-- Table:lc_receiver_clue_statistics
-- ---------------------------
drop table if exists lc_receiver_clue_statistics;
-CREATE TABLE `lc_receiver_clue_statistics` (
- `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
- `app_id` int(10) unsigned NOT NULL COMMENT '应用id',
- `uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
- `browse_num` int(10) NOT NULL DEFAULT '0' COMMENT '浏览量',
- `day` date NOT NULL DEFAULT '0000-00-00' COMMENT '日期',
- `c_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
- `u_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
- PRIMARY KEY (`id`)
+CREATE TABLE lc_receiver_clue_statistics (
+ id int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
+ app_id int(10) unsigned NOT NULL COMMENT '应用id',
+ uid int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
+ browse_num int(10) NOT NULL DEFAULT '0' COMMENT '浏览量',
+ day date NOT NULL DEFAULT '0000-00-00' COMMENT '日期',
+ c_time int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
+ u_time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ PRIMARY KEY (id)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='线索统计表'
+
+
+-- ----------------------------
+-- Title:线索来源表
+-- Author:lcc
+-- Table:lc_receiver_clues_cfrom
+-- ---------------------------
+drop table if exists lc_receiver_clues_cfrom;
+create table lc_receiver_clues_cfrom (
+ id int(10) unsigned not null auto_increment comment '自增id',
+ title varchar(32) not null comment '渠道名称',
+ status tinyint(1) not null default '1' comment '状态:-1删除 1使用中',
+ c_time int(10) unsigned not null default '0' comment '创建时间',
+ u_time timestamp not null default current_timestamp on update current_timestamp,
+ primary key (id)
+) engine=innodb default charset=utf8mb4 collate=utf8mb4_0900_ai_ci comment='线索来源表';
+alter table lc_receiver_clues_cfrom add column pid int unsigned not null default 0 comment '父来源ID' after title;