chengkun
2025-05-26 4462855c0033970c39ac8d0da704b7dc41eabbfe
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
<?php
 
 
class crm_index_controller extends siteadmin_controller{
    
    function index_action() {
        
        $crmM       =   $this -> MODEL('crm');
        $orderM     =   $this -> MODEL('companyorder');
        
        $auid        =   intval($_SESSION['auid']);
        
        // 代办任务
        $tasks        =   $crmM -> getTaskList(array('uid' => $auid, 'stime' => array('<', time()), 'status' => '1', 'orderby'=>'stime'), array('utype' => 'crm'));
        $this -> yunset('tasks', $tasks);
        $this -> yunset('tasknum',count($tasks));
        
        // 待审核订单
        $orders      =   $orderM -> getList(array('crm_uid' => $auid, 'order_state' => '1'),array('utype'=>'crmdealsp'));
        $this -> yunset('orders', $orders);
        
        //会员套餐
        $ratingM    =    $this -> MODEL('rating');
        $ratinglist    =    $ratingM -> getList(array( 'category' => '1'), array('field'=>'`id`,`name`'));
        $this -> yunset('ratinglist', $ratinglist);
        $cacheM        =   $this -> MODEL('cache');  
        $cache        =   $cacheM -> GetCache(array('crm'));
        $this -> yunset('cache', $cache);
        include(CONFIG_PATH."db.data.php");
        $paystate    =  $arr_data['paystate'];
        $this -> yunset('paystate', $paystate);
        $this -> siteadmin_tpl(array('crm_index'));  
    }
    
    
    function crmDeal_action(){
        $crmM          =   $this -> MODEL('crm');
        $dealData    =   array(
            'uid'                  =>  intval($_POST['com_uid']),
            'rating'               =>  intval($_POST['rid']),
            'crm_uid'              =>  intval($_SESSION['auid']),
            'order_remark'         =>     $_POST['order_remark'],
            'order_type'          =>    $_POST['order_type'],
            'order_price'          =>     $_POST['order_price'],
        );
        $updealData    =   array(
            'uid'                  =>  intval($_POST['com_uid']),
            'rating'               =>  intval($_POST['rid']),
            'crm_uid'              =>  intval($_SESSION['auid']),
            'order_remark'         =>     $_POST['order_remark'],
            'order_type'          =>    $_POST['order_type'],
            'order_price'          =>     $_POST['order_price'],
            'order_id'          =>     $_POST['order_id'],
        );
        if($_POST['id']){
            $return        =    $crmM  -> upDeal(array('id'=>$_POST['id']),$updealData);
        }else{
            $return        =    $crmM  -> addDeal($dealData);
        }
        $this -> ACT_layer_msg( $return['msg'], $return['errcode'], $_SERVER['HTTP_REFERER'], 2, 1);
    }
    function searchcom_action(){
        
        if($_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 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') - 1, date('Y'));
            $eDate  =   mktime(23, 59, 59, date('m'), date('d') - 1, date('Y'));
            
        }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'));
            
        }
       // $sDate     =   strtotime(date('Y-m-d'));
       // $eDate     =   time();  
        
        $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']);
            
            $comM  =   $this -> MODEL('company');
            
            $nid   =   $comM -> upInfo($uids, '', array('crm_uid'=>$auid,'crm_time'=>time()));
            
            echo $nid ? 1 : 2;
            
        }
        
    }
    
}
 
?>