chengkun
2025-04-30 6ab292fb7415be124651e312ec4f21c594568f17
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
 
 
 
class crm_index_controller extends adminCommon
{
 
    function index_action()
    {
 
        $auid       =   intval($_SESSION['auid']);
 
        //会员套餐
        $ratingM    =   $this->MODEL('rating');
        $ratinglist =   $ratingM->getList(array('category' => '1', 'service_price' => array('>', '0')), array('field' => '`id`,`name`'));
        $this->yunset('ratinglist', $ratinglist);
 
        $cacheM     =   $this->MODEL('cache');
        $cache      =   $cacheM->GetCache(array('crm'));
        $this->yunset('cache', $cache);
 
        $AdminM     =   $this->MODEL('admin');
        $where      =   array();
        $adminUser  =   $AdminM->getList($where, array('field' => '`uid`,`username`,`name`'));
        $this->yunset('adminUserList', $adminUser);
        $this->yunset('auid', $auid);
 
        // 网站所有支付类型
        include(CONFIG_PATH . 'db.data.php');
        $this->yunset('canpay', $arr_data['pay']);
 
        $this->yunset(array('time' => date('Y-m'), 'month' => '('.(int)date('m').'月)'));
        $this->yuntpl(array('admin/crm_index'));
    }
 
    function addDeal_action()
    {
 
        if (!empty($_POST)) {
 
            $crmM   =   $this->MODEL('crm');
 
            $data           =   $_POST;
            $data['auid']   =   $_SESSION['auid'];
            $return         =   $crmM->addDeal($data);
        } else {
 
            $return =   array('errcode' => 8, 'msg' => '操作错误,请重试!');
        }
        echo json_encode($return);
        die;
    }
 
    function searchcom_action()
    {
 
        if (isset($_POST['keyword'])) {
 
            $companyM   =   $this->MODEL('company');
            $keyword    =   $this->post_trim($_POST['keyword']);
 
            $list       =   $companyM->getList(array('crm_uid' => $_SESSION['auid'], 'name' => array('like', $keyword)), array('field' => '`uid`,`name`'));
 
            $com        =   $list['list'];
 
            if (is_array($com) && !empty($com)) {
                foreach ($com as $val) {
 
                    $data[] =   array('uid' => $val['uid'], 'name' => $val['name'],);
                }
            }
        }
        echo json_encode($data);
        die;
    }
 
    public function orderprice_action()
    {
 
        $id         =   intval($_POST['id']);
        $ratingM    =   $this->MODEL('rating');
        $rating     =   $ratingM->getInfo(array('id' => $id));
        echo json_encode($rating);
    }
 
    /**
     * @desc 工作台 - 消息提醒
     */
    function getNotice_action()
    {
 
        $crmM   =   $this->MODEL('crm');
 
        $return =   $crmM->getNotice($_SESSION['auid']);
 
        echo $return;
    }
 
    /**
     * @desc 我的简报
     */
    function getWorkReport_action()
    {
 
        $crmM   =   $this->MODEL('crm');
 
        if ($_POST['time'] == 1) {//今天
 
            $sDate  =   mktime(0, 0, 0, date('m'), date('d'), date('Y'));
            $eDate  =   mktime(23, 59, 59, date('m'), date('d'), date('Y'));
        } else if ($_POST['time'] == 2) {//昨天
 
            $sDate  =   mktime(0, 0, 0, date('m'), date('d'), date('Y')) - 86400;
            $eDate  =   mktime(23, 59, 59, date('m'), date('d'), date('Y')) - 86400;
        } else if ($_POST['time'] == 3) {//本周
 
            $sDate  =   strtotime(date('Y-m-d', strtotime("this week Monday", time())));
            $eDate  =   strtotime(date('Y-m-d', strtotime("this week Sunday", time()))) + 24 * 3600 - 1;
        } else if ($_POST['time'] == 4) {//本月
 
            $sDate  =   mktime(0, 0, 0, date('m'), 1, date('Y'));
            $eDate  =   mktime(23, 59, 59, date('m'), date('t'), date('Y'));
        }
 
        $return =   $crmM->getWorkReport(array('sdate' => $sDate, 'edate' => $eDate, 'auid' => $_SESSION['auid']));
        echo json_encode($return);
    }
 
    /**
     * @desc  认领客户
     */
    function receiveKh_action()
    {
 
        if ($_POST['uids']) {
 
            $uids   =   @explode(',', $_POST['uids']);
            $auid   =   intval($_SESSION['auid']);
            $crmM   =   $this->MODEL('crm');
            $return =   $crmM->claimCom($uids, $auid);
            echo json_encode($return);
        }
    }
 
 
    function log_action()
    {
 
        $where  =   $urlarr =   array();
 
        $crmM   =   $this->MODEL('crm');
 
        if ($_GET['logType']) {
 
            $where['type']      =   $_GET['logType'];
            $urlarr['logType']  =    $_GET['logType'];
        }
 
        if ($_GET['uid']) {
 
            $where['auid']      =   $_GET['uid'];
            $urlarr['uid']      =   $_GET['uid'];
        }
 
        if ($_GET['keyword']) {
 
            $where['content']   =   array('like', $_GET['keyword']);
            $urlarr['keyword']  =   $_GET['keyword'];
        }
        $urlarr         =   $_GET;
        $urlarr['page'] =   '{{page}}';
        $urlarr['c']    =   'log';
 
        $pageurl        =   Url($_GET['m'], $urlarr, 'admin');
        $pageM          =   $this->MODEL('page');
 
        $pages          =   $pageM->pageList('crm_log', $where, $pageurl, $_GET['page']);
 
        if ($pages['total'] > 0) {
            if (isset($_GET['order'])) {
 
                $where['orderby']   =   $_GET['t'] . ',' . $_GET['order'];
                $urlarr['order']    =   $_GET['order'];
                $urlarr['t']        =   $_GET['t'];
            } else {
 
                $where['orderby']   =   'ctime,desc';
            }
 
            $where['limit'] =   $pages['limit'];
 
            $list           =   $crmM->getCrmLogList($where);
 
            $this->yunset(array('list' => $list));
        }
 
        $typeArr    =   array('1' => '用户录入', '2' => '客户信息', '3' => '跟进记录' , '4' => '订单数据', '5' => '工作任务', '6' => '工作日志', '7' => '转交客户', '8' => '放弃客户', '9' => '等级状态', '10' => '外出申请', '11' => '联系方式', '12' => '领取客户');
        $this->yunset('typeArr', $typeArr);
 
        $adminM     =   $this->MODEL('admin');
        $crmUser    =   $adminM->getList(array('is_crm' => '1'));
        $this->yunset('crmUser', $crmUser);
        $this->yuntpl(array('admin/crm_log'));
    }
 
    /**
     * @desc 删除操作记录
     */
    function delCrmLog_action()
    {
 
        if ($_POST['del']) {
 
            $delId  =   $_POST['del'];
        } else if ($_GET['id']) {
 
            $this->check_token();
            $delId  =   intval($_GET['id']);
        }
 
        $crmM   =   $this->MODEL('crm');
        $return =   $crmM->delCrmLog($delId);
 
        if ($return['errcode'] == '9') {
 
            $this->MODEL('log')->addAdminLog("删除CRM操作记录(ID:" . $delId . ")");
        }
 
        $this->layer_msg($return['msg'], $return['errcode'], $return['layertype'], $_SERVER['HTTP_REFERER']);
    }
 
    function getKhb_action(){
 
        $crmM       =   $this->MODEL('crm');
 
        $crmKhb     =   $crmM->getKhbList($_POST['time']);
        echo json_encode($crmKhb);
    }
 
    function getJeb_action(){
 
        $crmM       =   $this->MODEL('crm');
 
        $crmJeb     =   $crmM->getJebList($_POST['time']);
        echo json_encode($crmJeb);
    }
 
}
 
?>