chengkun
2025-05-20 4c1f0f659384d71ce28be1fc0343e56e75568fe1
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
<?php
 
 
 
class crm_dealsp_controller extends adminCommon
{
 
    function index_action()
    {
 
        $orderM =   $this->MODEL('companyorder');
 
        $where  =   $urlarr =   array();
 
        $where['crm_uid']       =   array('<>', '');
        $where['order_state']   =   3;
 
        if (isset($_GET['order_id']) && !empty($_GET['order_id'])) {
 
            $where['order_id']  =   trim($_GET['order_id']);
            $urlarr['order_id'] =   $_GET['order_id'];
        }
 
        if (isset($_GET['comname']) && !empty($_GET['comname'])){
 
            $comList    =   $this->obj->select_all('company', array('like', $_GET['comname']),'`uid`');
 
            if (!empty($comList)){
                $comIds =   array();
                foreach ($comIds as $v) {
 
                    $comIds[$v['uid']]  =   $v['uid'];
                }
 
                $where['uid']   =   array('in', pylode(',', $comIds));
            }
        }
        $urlarr            =   $_GET;
        $urlarr['page'] =   "{{page}}";
        $pageurl        =   Url($_GET['m'], $urlarr, 'admin');
 
        $pageM          =   $this->MODEL('page');
        $pages          =   $pageM->pageList('company_order', $where, $pageurl, $_GET['page']);
 
        if ($pages['total'] > 0) {
 
            if ($_GET['order']) {
 
                $where['orderby']   =   $_GET['t'] . ',' . $_GET['order'];
                $urlarr['order']    =   $_GET['order'];
                $urlarr['t']        =   $_GET['t'];
            } else {
 
                $where['orderby']   =   array('order_state, ASC', 'id, DESC');
            }
 
            $where['limit']         =   $pages['limit'];
            $orders                 =   $orderM->getList($where, array('utype' => 'crmdealsp'));
        }
 
        $ratingM    =   $this->MODEL('rating');
        $ratingList =   $ratingM->getList(array('category' => '1'), array('field' => '`id`,`name`'));
 
        $cacheM     =   $this->MODEL('cache');
        $cache      =   $cacheM->GetCache(array('crm'));
 
        $this->yunset(array('orders' => $orders, 'ratinglist' => $ratingList, 'cache' => $cache));
        $this->yuntpl(array('admin/crm_dealsp_list'));
    }
 
    /**
     * @desc 审批订单详细
     */
    function getOrderInfo_action()
    {
 
        $orderM     =   $this->MODEL('companyorder');
 
        $id         =   $_GET['id'];
        $orderInfo  =   $orderM->getInfo(array('id' => $id));
 
        $adminM     =   $this->MODEL('admin');
        $auser      =   $adminM->getAdminUser(array('uid' => $orderInfo['crm_uid']));
 
        $ratingM    =   $this->MODEL('rating');
        $ratingArr  =   $ratingM->getInfo(array('id' => $orderInfo['rating']), array('field' => '`id`,`name`'));
 
        $this->yunset(array('orderInfo' => $orderInfo, 'aname' => $auser['name'], 'ratingName' => $ratingArr['name']));
        $this->yuntpl(array('admin/crm_order_info'));
    }
 
    /**
     * @desc 确认订单,收款
     */
    function spDeal_action()
    {
 
        $this->check_token();
        $id     =   intval($_GET['id']);
        $OrderM =   $this->MODEL('companyorder');
        $return =   $OrderM->setPay($id);
        $this->layer_msg($return['msg'], $return['errcode'], 0, $_SERVER['HTTP_REFERER']);
    }
 
    /**
     * @desc 订单删除
     */
    function del_action()
    {
        $this -> check_token();
 
        $OrderM        =    $this -> MODEL('companyorder');
        $delID        =    is_array($_GET['del']) ? $_GET['del'] : $_GET['id'];
 
        $return     =   $OrderM->del($delID, array('utype' => 'admin'));
        $this -> layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
    }
 
    function getOrders_action(){
 
        $orderM =   $this->MODEL('companyorder');
 
        $where  =   $urlarr =   array();
 
 
        $where['PHPYUNBTWSTART_A']  =   '';
        $where['crm_uid'][]         =   array('=', 0, '');
        $where['crm_uid'][]         =   array('isnull', '', 'or');
        $where['PHPYUNBTWEND_A']    =   '';
 
        $where['usertype']      =   2;
        $where['order_state']   =   2;
 
        if (isset($_GET['order_id']) && !empty($_GET['order_id'])) {
 
            $where['order_id']  =   trim($_GET['order_id']);
            $urlarr['order_id'] =   $_GET['order_id'];
        }
 
        if (isset($_GET['comname']) && !empty($_GET['comname'])){
 
            $comList    =   $this->obj->select_all('company', array('name' => array('like', $_GET['comname'])),'`uid`');
 
            if (!empty($comList)){
                $comIds =   array();
                foreach ($comList as $v) {
 
                    $comIds[$v['uid']]  =   $v['uid'];
                }
 
                $where['uid']   =   array('in', pylode(',', $comIds));
            }
        }
        $urlarr            =   $_GET;
        $urlarr['page'] =   "{{page}}";
        $urlarr['c']    =   "getOrders";
 
        $pageurl        =   Url($_GET['m'], $urlarr, 'admin');
 
        $pageM          =   $this->MODEL('page');
        $pages          =   $pageM->pageList('company_order', $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']   =   array('order_state, ASC', 'id, DESC');
            }
 
            $where['limit']         =   $pages['limit'];
            $orders                 =   $orderM->getList($where, array('utype' => 'crmdealfp'));
            $this->yunset(array('orders' => $orders));
        }
 
        $adminM             =   $this->MODEL('admin');
        $GwInfo             =   $adminM -> getList(array('is_crm' => 1));
        $this -> yunset('GwInfo',$GwInfo);
 
        $this->yuntpl(array('admin/crm_dealfp_list'));
    }
 
    function setCrm_action()
    {
 
        $orderM     =   $this->MODEL('companyorder');
        $adminM     =   $this->MODEL('admin');
 
        $gid        =   intval($_POST['gid']);
        $oid        =   trim($_POST['oid']);
 
        $crmUser    =   $adminM->getAdminUser(array( 'uid' => $gid ));
 
        if (! is_array($crmUser)) {
            $this -> ACT_layer_msg('请选择业务员!', 8, $_SERVER['HTTP_REFERER']);
        }
 
        $return     =   $orderM->setCrm(array('crm_uid' => $gid), array('id' => $oid));
 
        $this->ACT_layer_msg($return['msg'], $return['errcode'], $_SERVER['HTTP_REFERER'], 2, 1);
    }
}
 
?>