diff --git a/app/customer/common.php b/app/customer/common.php
index 433f0d0..3bc4191 100644
--- a/app/customer/common.php
+++ b/app/customer/common.php
@@ -84,7 +84,7 @@ function trace_type()
//跟进阶段
function trace_stage()
{
- $stage = ['未设置','立项评估','初期沟通','需求分析','方案制定','商务谈判','合同签订','失单'];
+ $stage = ['未设置','立项评估','初期沟通','需求分析','商务谈判','方案制定','合同签订','失单'];
return $stage;
}
diff --git a/app/customer/controller/Api.php b/app/customer/controller/Api.php
index 6ea337b..a4aa242 100644
--- a/app/customer/controller/Api.php
+++ b/app/customer/controller/Api.php
@@ -96,6 +96,9 @@ class Api extends BaseController
$param['admin_id'] = $this->uid;
$tid = CustomerTrace::strict(false)->field(true)->insertGetId($param);
if ($tid) {
+ if(!empty($param['chance_id'])){
+ Db::name('CustomerChance')->where('id',$param['chance_id'])->update(['stage'=>$param['stage']]);
+ }
add_log('add', $tid, $param,'客户跟进记录');
$log_data = array(
'field' => 'new',
diff --git a/app/customer/controller/Trace.php b/app/customer/controller/Trace.php
new file mode 100644
index 0000000..f3b96d6
--- /dev/null
+++ b/app/customer/controller/Trace.php
@@ -0,0 +1,83 @@
+isAjax()) {
+ $param = get_params();
+ $where = array();
+ $whereOr = array();
+ if (!empty($param['keywords'])) {
+ $where[] = ['a.id|a.title|c.name', 'like', '%' . $param['keywords'] . '%'];
+ }
+ if (!empty($param['stage'])) {
+ $where[] = ['a.stage', '=', $param['stage']];
+ }
+ //按时间检索
+ if (!empty($param['diff_time'])) {
+ $diff_time =explode('~', $param['diff_time']);
+ $where[] = ['a.expected_time', 'between', [strtotime(urldecode($diff_time[0])),strtotime(urldecode($diff_time[1]))]];
+ }
+ $where[] = ['a.delete_time', '=', 0];
+
+ $uid = $this->uid;
+ $auth = isAuth($uid,'customer_admin');
+
+ if (empty($param['uid'])) {
+ if($auth==0){
+ $dids = get_department_role($this->uid);
+ if(!empty($dids)){
+ $whereOr[] =['c.belong_did', 'in', $dids];
+ }
+ $whereOr[] =['c.belong_uid', '=', $uid];
+ $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',c.share_ids)")];
+ }
+ }
+ else{
+ $where[] = ['a.belong_uid', '=', $param['uid']];
+ }
+
+ $rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
+ $content = CustomerTrace::where($where)
+ ->where(function ($query) use($whereOr) {
+ $query->whereOr($whereOr);
+ })
+ ->field('a.*,c.name as customer')
+ ->alias('a')
+ ->join('customer c', 'a.cid = c.id')
+ ->order('a.create_time desc')
+ ->paginate($rows, false, ['query' => $param])
+ ->each(function ($item, $key) {
+ $item->admin_name = Db::name('Admin')->where(['id' => $item->admin_id])->value('name');
+ $item->create_time = date('Y-m-d H:i:s', (int) $item->create_time);
+ $item->follow_time = date('Y-m-d H:i', (int) $item->follow_time);
+ $item->next_time = date('Y-m-d H:i', (int) $item->next_time);
+ $item->stage_name = CustomerTrace::$Stage[(int) $item->stage];
+ $item->type_name = CustomerTrace::$Type[(int) $item->type];
+ $item->chance='-';
+ if($item->chance_id>0){
+ $item->chance=Db::name('CustomerChance')->where(['id' => $item->chance_id])->value('title');
+ }
+ });
+ return table_assign(0, '', $content);
+ } else {
+ return view();
+ }
+ }
+}
diff --git a/app/customer/model/CustomerTrace.php b/app/customer/model/CustomerTrace.php
index 33edb6f..3aa0eb6 100644
--- a/app/customer/model/CustomerTrace.php
+++ b/app/customer/model/CustomerTrace.php
@@ -22,7 +22,7 @@ class CustomerTrace extends Model
const SEVEN = 7;
public static $Type = [
- self::ZERO => '未设置',
+ self::ZERO => '其他',
self::ONE => '电话',
self::TWO => '微信',
self::THREE => 'QQ',
@@ -44,6 +44,11 @@ class CustomerTrace extends Model
{
$detail = Db::name('CustomerTrace')->where(['id' => $id])->find();
if (!empty($detail)) {
+ $detail['chance_name'] ='-';
+ if($detail['chance_id'] >0){
+ $detail['chance_name'] =Db::name('CustomerChance')->where(['id' => $detail['chance_id']])->value('title');
+ }
+ $detail['contact_name'] =Db::name('CustomerContact')->where(['id' => $detail['contact_id']])->value('name');
$detail['stage_name'] = self::$Stage[(int) $detail['stage']];
$detail['type_name'] = self::$Type[(int) $detail['type']];
$detail['create_time'] = date('Y-m-d H:i:s', $detail['create_time']);
diff --git a/app/customer/view/api/add_trace.html b/app/customer/view/api/add_trace.html
index b5d3a22..ff39922 100644
--- a/app/customer/view/api/add_trace.html
+++ b/app/customer/view/api/add_trace.html
@@ -1,23 +1,23 @@
{extend name="../../base/view/common/base" /}
{block name="body"}
-
{/block}
@@ -44,7 +40,10 @@
{block name="script"}
{/block}
\ No newline at end of file
diff --git a/app/customer/view/trace/index.html b/app/customer/view/trace/index.html
new file mode 100644
index 0000000..bc14a0b
--- /dev/null
+++ b/app/customer/view/trace/index.html
@@ -0,0 +1,115 @@
+{extend name="../../base/view/common/base" /}
+
+{block name="body"}
+
+{/block}
+
+
+
+{block name="script"}
+
+{/block}
+
\ No newline at end of file
diff --git a/app/install/data/gouguoa.sql b/app/install/data/gouguoa.sql
index f9682ab..4759d4f 100644
--- a/app/install/data/gouguoa.sql
+++ b/app/install/data/gouguoa.sql
@@ -383,6 +383,7 @@ INSERT INTO `oa_admin_rule` VALUES (201, 196, 'home/files/add_group', '新建/
INSERT INTO `oa_admin_rule` VALUES (202, 196, 'home/files/del_group', '删除附件分组','附件分组', 'home', '', 2, 1, 1, 0, 0);
INSERT INTO `oa_admin_rule` VALUES (203, 76, 'user/personal/leave_check', '资料交接', '离职资料', 'user', '', 2, 1, 1, 0, 0);
+INSERT INTO `oa_admin_rule` VALUES (204, 136, 'customer/trace/index', '跟进记录', '跟进记录', 'customer', '', 1, 0, 1, 1656143065, 0);
-- ----------------------------
-- Table structure for oa_admin_group
-- ----------------------------
@@ -403,9 +404,9 @@ CREATE TABLE `oa_admin_group` (
-- ----------------------------
-- Records of oa_admin_group
-- ----------------------------
-INSERT INTO `oa_admin_group` VALUES (1, '超级员工权限', 1, '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203', '1,2,3,4,5,6,7,8,9,10,11,12','超级员工权限,拥有系统的最高权限,不可修改。', 0, 0);
-INSERT INTO `oa_admin_group` VALUES (2, '总经理权限', 1, '1,9,13,17,20,23,25,26,30,2,34,37,41,44,47,50,53,56,59,3,62,65,68,69,71,74,76,4,79,82,85,5,88,91,92,93,94,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203','1,2,3,4,5,6,7,8,9,10,11,12', '总经理的管理权限,可根据公司的具体需求调整。', 0, 0);
-INSERT INTO `oa_admin_group` VALUES (3, '普通员工权限', 1, '5,88,91,92,93,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203','1,2,3,4,5,6,7,8,9,10,11,12', '普通员工管理权限,可根据公司的具体需求调整。', 0, 0);
+INSERT INTO `oa_admin_group` VALUES (1, '超级员工权限', 1, '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204', '1,2,3,4,5,6,7,8,9,10,11,12','超级员工权限,拥有系统的最高权限,不可修改。', 0, 0);
+INSERT INTO `oa_admin_group` VALUES (2, '总经理权限', 1, '1,9,13,17,20,23,25,26,30,2,34,37,41,44,47,50,53,56,59,3,62,65,68,69,71,74,76,4,79,82,85,5,88,91,92,93,94,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204','1,2,3,4,5,6,7,8,9,10,11,12', '总经理的管理权限,可根据公司的具体需求调整。', 0, 0);
+INSERT INTO `oa_admin_group` VALUES (3, '普通员工权限', 1, '5,88,91,92,93,6,95,96,97,98,99,7,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,8,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,140,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204','1,2,3,4,5,6,7,8,9,10,11,12', '普通员工管理权限,可根据公司的具体需求调整。', 0, 0);
-- ----------------------------
-- Table structure for oa_data_auth