From cb55b4c512cfaa11de40bce26b11d824bb46efe2 Mon Sep 17 00:00:00 2001 From: dengbw Date: Mon, 20 Jun 2022 16:58:05 +0800 Subject: [PATCH] customers_620 --- api/controllers/wxapp/licheb/Customerlogs.php | 19 ++++++++++--- api/controllers/wxapp/licheb/Customers.php | 28 +++++++++++++++++++ api/core/HD_Model.php | 9 +++--- .../receiver/Receiver_comments_model.php | 19 +++++++++++++ .../Receiver_customer_oplogs_model.php | 6 ++-- .../receiver/Receiver_owners_oplogs_model.php | 2 +- home/core/HD_Model.php | 9 +++--- 7 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 common/models/receiver/Receiver_comments_model.php diff --git a/api/controllers/wxapp/licheb/Customerlogs.php b/api/controllers/wxapp/licheb/Customerlogs.php index d4139c11..76f2f845 100644 --- a/api/controllers/wxapp/licheb/Customerlogs.php +++ b/api/controllers/wxapp/licheb/Customerlogs.php @@ -23,25 +23,24 @@ class Customerlogs extends Wxapp $this->load->model('receiver/receiver_customers_model', 'customers_model'); $this->load->model('receiver/receiver_customer_oplogs_model', 'customer_oplogs_model'); + $this->load->model('receiver/receiver_comments_model', 'mdComments'); $this->load->model('receiver/receiver_xz_model'); } protected function get() { - $uid = $this->session['uid']; $id = $this->input_param('id'); $page = $this->input_param('page'); $size = $this->input_param('size'); !$page && $page = 1; !$size && $size = 20; - $where = [ 'customer_id' => $id ]; $count = $this->customer_oplogs_model->count($where); $lists = []; if ($count) { - $rows = $this->customer_oplogs_model->select($where, 'id desc', $page, $size, 'log,uname,type,c_time,imgs'); + $rows = $this->customer_oplogs_model->select($where, 'id desc', $page, $size, 'id,log,uname,type,c_time,imgs'); foreach ($rows as $key => $val) { $record = ''; $second = 0; @@ -60,12 +59,24 @@ class Customerlogs extends Wxapp $rec_row['rec_url'] && $record = $rec_row['rec_url']; $rec_row['duration'] && $second = intval($rec_row['duration'] / 1000); } + $comments = []; + $res = $this->mdComments->select(['pid' => $val['id'], 'status' => 1, 'type' => 0], 'id desc', 0, 0 + , 'uname,content'); + foreach ($res as $key2 => $val2) { + $comments[] = [ + 'uname' => $val2['uname'], + 'content' => $val2['content'] + ]; + } $lists[] = [ + 'id' => $val['id'], 'content' => "【{$val['uname']}】" . $content, 'record_url' => $record, 'second' => $second, 'imgs' => $imgs, - 'c_time' => date('Y.m.d', $val['c_time']) + 'comments' => $comments, + 'type_name' => $this->customer_oplogs_model->typeAry($val['type']), + 'c_time' => date('Y.m.d H:i', $val['c_time']) ]; } } diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 502da794..0abee329 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -327,6 +327,34 @@ class Customers extends Wxapp } } + /** + * Notes:用户评论 + * Created on: 2022/6/20 14:05 + * Created by: dengbw + * @throws Exception + */ + protected function post_comments() + { + $pid = $this->input_param('id'); + $content = $this->input_param('content'); + if (!$pid) { + throw new Exception('参数错误', API_CODE_FAIL); + } + if (!$content) { + throw new Exception('请输入评论内容', API_CODE_FAIL); + } + $this->load->model('receiver/receiver_comments_model', 'mdComments'); + $uid = $this->session['uid']; + $uname = $this->session['uname']; + $add_data = ['pid' => $pid, 'content' => $content, 'uid' => $uid, 'uname' => $uname, 'c_time' => time()]; + $id = $this->mdComments->add($add_data); + if ($id) { + throw new Exception('评论成功', API_CODE_SUCCESS); + } else { + throw new Exception('评论失败', ERR_PARAMS_ERROR); + } + } + //客户跟进 protected function put() { diff --git a/api/core/HD_Model.php b/api/core/HD_Model.php index 96543584..93c150ca 100644 --- a/api/core/HD_Model.php +++ b/api/core/HD_Model.php @@ -268,19 +268,18 @@ class HD_Model extends CI_Model { $offset = null; $limit = null; } - - $result = $this->db->get($this->table_name, $limit, $offset)->result_array(); - + $this->db->from($this->table_name); + $this->db->limit($limit, $offset); + $query = $this->db->get(); + $result = $query ? $query->result_array() : []; if($obj && file_exists($class = APPPATH.'libraries/entity/'.ucfirst($obj).'.php')) { require_once $class; - if(class_exists($obj)) { $result = $this->db->get($this->table_name, $limit, $offset)->custom_result_object($obj); } } - return $result; } diff --git a/common/models/receiver/Receiver_comments_model.php b/common/models/receiver/Receiver_comments_model.php new file mode 100644 index 00000000..3b106fd8 --- /dev/null +++ b/common/models/receiver/Receiver_comments_model.php @@ -0,0 +1,19 @@ +table_name, 'default'); + } + +} \ No newline at end of file diff --git a/common/models/receiver/Receiver_customer_oplogs_model.php b/common/models/receiver/Receiver_customer_oplogs_model.php index eed397af..e288bbab 100644 --- a/common/models/receiver/Receiver_customer_oplogs_model.php +++ b/common/models/receiver/Receiver_customer_oplogs_model.php @@ -21,14 +21,14 @@ class Receiver_customer_oplogs_model extends HD_Model * Notes:类型 * Created on: 2022/4/12 16:51 * Created by: dengbw - * @param int $id + * @param string $id * @return array|mixed */ - public function typeAry($id = 0) + public function typeAry($id = '') { $arr = [0 => '小记', 1 => '发短信', 2 => '拨打号码', 3 => '创建', 4 => '到店', 5 => '试驾', 6 => '订单', 7 => '战败' , 8 => '企微跟进', 9 => '系统']; - if ($id) { + if (strlen($id)) { return $arr[$id]; } else { return $arr; diff --git a/common/models/receiver/Receiver_owners_oplogs_model.php b/common/models/receiver/Receiver_owners_oplogs_model.php index f7530dd0..b8079e52 100644 --- a/common/models/receiver/Receiver_owners_oplogs_model.php +++ b/common/models/receiver/Receiver_owners_oplogs_model.php @@ -20,7 +20,7 @@ class Receiver_owners_oplogs_model extends HD_Model * Notes:类型 * Created on: 2022/6/15 16:51 * Created by: dengbw - * @param int $id + * @param string $id * @return array|mixed */ public function typeAry($id = '') diff --git a/home/core/HD_Model.php b/home/core/HD_Model.php index bafc943c..7a8ad9f2 100644 --- a/home/core/HD_Model.php +++ b/home/core/HD_Model.php @@ -235,19 +235,18 @@ class HD_Model extends CI_Model { $offset = null; $limit = null; } - - $result = $this->db->get($this->table_name, $limit, $offset)->result_array(); - + $this->db->from($this->table_name); + $this->db->limit($limit, $offset); + $query = $this->db->get(); + $result = $query ? $query->result_array() : []; if($obj && file_exists($class = APPPATH.'libraries/entity/'.ucfirst($obj).'.php')) { require_once $class; - if(class_exists($obj)) { $result = $this->db->get($this->table_name, $limit, $offset)->custom_result_object($obj); } } - return $result; }