旭晓耿 před 5 roky
rodič
revize
97662ba32e
77 změnil soubory, kde provedl 3142 přidání a 1981 odebrání
  1. 22
    0
      application/admin/common.php
  2. 27
    10
      application/admin/controller/Field.php
  3. 1
    0
      application/admin/controller/Index.php
  4. 58
    12
      application/admin/controller/Install.php
  5. 20
    8
      application/admin/controller/Users.php
  6. 11
    6
      application/admin/logic/FieldGrantLogic.php
  7. 38
    48
      application/admin/logic/MessageLogic.php
  8. 7
    0
      application/admin/logic/WorkLogic.php
  9. 2
    1
      application/admin/model/Common.php
  10. 2
    1
      application/admin/model/ExamineStep.php
  11. 432
    361
      application/admin/model/Excel.php
  12. 33
    14
      application/admin/model/Field.php
  13. 1
    1
      application/admin/model/Record.php
  14. 13
    5
      application/admin/model/Scene.php
  15. 7
    4
      application/admin/model/User.php
  16. 13
    1
      application/admin/model/UserField.php
  17. 1
    1
      application/admin/view/install/index.html
  18. 10
    4
      application/admin/view/install/step1.html
  19. 70
    43
      application/admin/view/install/step2.html
  20. 9
    3
      application/admin/view/install/step3.html
  21. 64
    0
      application/admin/view/install/step5.html
  22. 1
    1
      application/admin/view/public/footer.html
  23. 2
    1
      application/bi/controller/Examine.php
  24. 30
    7
      application/common.php
  25. 19
    6
      application/crm/controller/Business.php
  26. 30
    21
      application/crm/controller/Contract.php
  27. 16
    3
      application/crm/controller/Customer.php
  28. 5
    2
      application/crm/controller/Invoice.php
  29. 5
    1
      application/crm/controller/Leads.php
  30. 3
    0
      application/crm/controller/Product.php
  31. 201
    154
      application/crm/controller/Receivables.php
  32. 2
    4
      application/crm/controller/Visit.php
  33. 4
    3
      application/crm/logic/ActivityLogic.php
  34. 161
    54
      application/crm/logic/CommonLogic.php
  35. 10
    7
      application/crm/logic/IndexLogic.php
  36. 23
    18
      application/crm/logic/VisitLogic.php
  37. 440
    417
      application/crm/model/Business.php
  38. 18
    18
      application/crm/model/Contacts.php
  39. 34
    8
      application/crm/model/Contract.php
  40. 67
    67
      application/crm/model/Customer.php
  41. 1
    0
      application/crm/model/Invoice.php
  42. 14
    12
      application/crm/model/Leads.php
  43. 83
    72
      application/crm/model/Product.php
  44. 16
    5
      application/crm/model/Receivables.php
  45. 3
    1
      application/oa/controller/Event.php
  46. 5
    4
      application/oa/controller/Examine.php
  47. 58
    58
      application/oa/controller/Task.php
  48. 314
    38
      application/oa/logic/ExamineLogic.php
  49. 31
    46
      application/oa/logic/LogLogic.php
  50. 39
    41
      application/oa/logic/TaskLogic.php
  51. 33
    27
      application/oa/logic/UserLogic.php
  52. 120
    118
      application/oa/model/Event.php
  53. 75
    63
      application/oa/model/Examine.php
  54. 24
    24
      application/oa/model/Log.php
  55. 2
    2
      application/work/controller/Task.php
  56. 3
    0
      application/work/controller/Tasklable.php
  57. 21
    1
      application/work/controller/Work.php
  58. 129
    39
      application/work/logic/WorkLogic.php
  59. 48
    36
      application/work/model/Task.php
  60. 6
    1
      application/work/model/Work.php
  61. 4
    1
      config/config.php
  62. 1
    0
      config/route_admin.php
  63. 2
    0
      config/route_crm.php
  64. 2
    2
      config/version.php
  65. 10
    10
      public/sql/5kcrm.sql
  66. 2
    2
      public/sql/install.sql
  67. 0
    7
      public/sql/update_sql_20210207.sql
  68. 2
    0
      public/sql/update_sql_20210227.sql
  69. binární
      public/static/icon/success_gray.png
  70. binární
      public/static/img/bg.png
  71. 37
    32
      public/static/js/step2.js
  72. 52
    12
      public/static/style/base.css
  73. 1
    0
      public/static/style/index.css
  74. 52
    0
      public/static/style/loading.css
  75. 9
    4
      public/static/style/step1.css
  76. 29
    8
      public/static/style/step2.css
  77. 2
    0
      update_sql_20210227.sql

+ 22
- 0
application/admin/common.php Zobrazit soubor

170
     curl_close($ch);
170
     curl_close($ch);
171
     return $return;
171
     return $return;
172
 }
172
 }
173
+
174
+/**
175
+ * 验证序列号
176
+ * @param 
177
+ * @return
178
+ */        
179
+function checkWkCode($wkcode) {
180
+    $pub = config('public_key');
181
+    $openssl_pub = openssl_pkey_get_public($pub);
182
+    // 验签
183
+    $resArr = openssl_public_decrypt(Hex2String($wkcode), $decrypted, $pub);
184
+    if(!$resArr) return false;
185
+    return $decrypted;
186
+}
187
+
188
+function Hex2String($hex){
189
+    $string = '';
190
+    for ($i=0; $i < strlen($hex); $i+=2){
191
+        $string .= chr(hexdec($hex[$i].$hex[$i+1]));
192
+    }
193
+    return $string;
194
+}

+ 27
- 10
application/admin/controller/Field.php Zobrazit soubor

84
      * 自定义字段数据
84
      * 自定义字段数据
85
      */
85
      */
86
     public function read()
86
     public function read()
87
-    {        
87
+    {
88
         $fieldModel = model('Field');
88
         $fieldModel = model('Field');
89
         $param = $this->param;
89
         $param = $this->param;
90
         $data = $fieldModel->getDataList($param);    
90
         $data = $fieldModel->getDataList($param);    
116
         $types_id   = $param['types_id'] ? : 0;
116
         $types_id   = $param['types_id'] ? : 0;
117
 //        $data['types'] = $param['types'];
117
 //        $data['types'] = $param['types'];
118
 
118
 
119
-        $data        = $param['data'];
120
-        $saveParam   = []; # 新增数据
121
-        $updateParam = []; # 编辑数据
122
-        $delParam    = []; # 删除数据
123
-        $fieldIds    = []; # 删除数据(兼容前端11.*.*版本)
119
+        $data         = $param['data'];
120
+        $saveParam    = []; # 新增数据
121
+        $updateParam  = []; # 编辑数据
122
+        $delParam     = []; # 删除数据
123
+        $fieldIds     = []; # 删除数据(兼容前端11.*.*版本)
124
+        $errorMessage = []; # 错误数据
124
         $i = 0;
125
         $i = 0;
125
         foreach ($data AS $k => $v) {
126
         foreach ($data AS $k => $v) {
126
             $i++;
127
             $i++;
128
+
129
+            # 必填的字段不可以隐藏
130
+            if (!empty($v['is_null']) && !empty($v['is_hidden'])) {
131
+                $errorMessage = '必填的字段不可以隐藏!';
132
+                break;
133
+            }
134
+
127
             if ($v['field_id']) {
135
             if ($v['field_id']) {
128
                 if (isset($v['is_deleted']) && $v['is_deleted'] == '1') {
136
                 if (isset($v['is_deleted']) && $v['is_deleted'] == '1') {
129
                     # 删除
137
                     # 删除
143
             }
151
             }
144
         }
152
         }
145
 
153
 
146
-        # 错误数据
147
-        $errorMessage = [];
154
+        # 必填的字段不可以隐藏
155
+        if ($errorMessage) return resultArray(['error' => $errorMessage]);
148
 
156
 
149
         # 兼容前端11.*.*版本的删除条件处理,通过比较差异,来确定谁被前端给删除了 todo 这段代码需要写在新增上面,不然会把新增的给删除掉
157
         # 兼容前端11.*.*版本的删除条件处理,通过比较差异,来确定谁被前端给删除了 todo 这段代码需要写在新增上面,不然会把新增的给删除掉
150
         $oldFieldIds = Db::name('admin_field')->where('types', $types)->column('field_id');
158
         $oldFieldIds = Db::name('admin_field')->where('types', $types)->column('field_id');
170
         # 删除
178
         # 删除
171
         if (!empty($delParam)) {
179
         if (!empty($delParam)) {
172
             if (!$data = $fieldModel->delDataById($delParam)) {
180
             if (!$data = $fieldModel->delDataById($delParam)) {
173
-                $errorMessage[] = $fieldModel->getError();
181
+                if (!empty($fieldModel->getError())) $errorMessage[] = $fieldModel->getError();
174
             }
182
             }
175
         }
183
         }
176
 
184
 
312
                     case 'crm_visit' :
320
                     case 'crm_visit' :
313
                         $visit = new \app\crm\model\Visit();
321
                         $visit = new \app\crm\model\Visit();
314
                         $dataInfo = $visit->getDataById(intval($param['action_id']));
322
                         $dataInfo = $visit->getDataById(intval($param['action_id']));
323
+                        $fieldModel = new \app\admin\model\Field();
324
+                        $datetimeField = $fieldModel->getFieldByFormType('crm_visit', 'datetime'); //日期时间类型
325
+                        foreach ($datetimeField as $key => $val) {
326
+                            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
327
+                        }
315
                         //判断权限
328
                         //判断权限
316
                         $auth_user_ids = $userModel->getUserByPer('crm', 'visit', $param['action']);
329
                         $auth_user_ids = $userModel->getUserByPer('crm', 'visit', $param['action']);
317
                         //读写权限
330
                         //读写权限
318
                         $roPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'read');
331
                         $roPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'read');
319
                         $rwPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
332
                         $rwPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
320
-                        if (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$roPre && !$rwPre) {
333
+                        if (!in_array($user_id, stringToArray($dataInfo['owner_user_id'])) && !in_array($user_id,$auth_user_ids) && !$roPre && !$rwPre) {
321
                             header('Content-Type:application/json; charset=utf-8');
334
                             header('Content-Type:application/json; charset=utf-8');
322
                             exit(json_encode(['code'=>102,'error'=>'无权操作']));
335
                             exit(json_encode(['code'=>102,'error'=>'无权操作']));
323
                         }
336
                         }
614
         $userFieldModel = model('UserField');
627
         $userFieldModel = model('UserField');
615
         $width = $param['width'] > 10 ? $param['width'] : '';
628
         $width = $param['width'] > 10 ? $param['width'] : '';
616
         $unField = array('pool_day','owner_user_name','is_lock','create_user_name');
629
         $unField = array('pool_day','owner_user_name','is_lock','create_user_name');
630
+        switch ($param['field']) {
631
+        	case 'status_id_info' : $param['field'] = 'status_id';
632
+        		break;
633
+        }
617
         if (!in_array($param['field'],$unField)) {
634
         if (!in_array($param['field'],$unField)) {
618
             $res = $userFieldModel->setColumnWidth($param['types'], $param['field'], $width, $userInfo['id']);
635
             $res = $userFieldModel->setColumnWidth($param['types'], $param['field'], $width, $userInfo['id']);
619
             if (!$res) {
636
             if (!$res) {

+ 1
- 0
application/admin/controller/Index.php Zobrazit soubor

52
             if ($value['field'] == 'address')      $field_arr[$key]['form_type'] = 'map_address';
52
             if ($value['field'] == 'address')      $field_arr[$key]['form_type'] = 'map_address';
53
             if ($value['field'] == 'deal_status')  $field_arr[$key]['form_type'] = 'deal_status';
53
             if ($value['field'] == 'deal_status')  $field_arr[$key]['form_type'] = 'deal_status';
54
             if ($value['field'] == 'check_status') $field_arr[$key]['form_type'] = 'check_status';
54
             if ($value['field'] == 'check_status') $field_arr[$key]['form_type'] = 'check_status';
55
+            if ($param['types'] == 'crm_visit' && $value['field'] == 'owner_user_id') $field_arr[$key]['name'] = '回访人';
55
         }
56
         }
56
 
57
 
57
         return resultArray(['data' => $field_arr]);
58
         return resultArray(['data' => $field_arr]);

+ 58
- 12
application/admin/controller/Install.php Zobrazit soubor

27
         $param = Request::instance()->param();          
27
         $param = Request::instance()->param();          
28
         $this->param = $param;
28
         $this->param = $param;
29
 
29
 
30
-        $request = request();
31
-        $m = strtolower($request->module());
32
-        $c = strtolower($request->controller());
33
-        $a = strtolower($request->action());     
34
-	
35
-        if (!in_array($a, array('upgrade','upgradeprocess','checkversion')) && file_exists(CONF_PATH . "install.lock")) {
36
-            echo "<meta http-equiv='content-type' content='text/html; charset=UTF-8'> <script>alert('请勿重复安装!');location.href='".$_SERVER["HTTP_HOST"]."';</script>";
37
-            die();       
38
-        }    
30
+//        $request = request();
31
+//        $m = strtolower($request->module());
32
+//        $c = strtolower($request->controller());
33
+//        $a = strtolower($request->action());
34
+//
35
+//        if (!in_array($a, array('upgrade','upgradeprocess','checkversion')) && file_exists(CONF_PATH . "install.lock")) {
36
+//            echo "<meta http-equiv='content-type' content='text/html; charset=UTF-8'> <script>alert('请勿重复安装!');location.href='".$_SERVER["HTTP_HOST"]."';</script>";
37
+//            die();
38
+//        }
39
     }
39
     }
40
 
40
 
41
     private $upgrade_site = "http://message.72crm.com/";
41
     private $upgrade_site = "http://message.72crm.com/";
73
     public function version()
73
     public function version()
74
     {
74
     {
75
         $res = include(CONF_PATH.'version.php'); 
75
         $res = include(CONF_PATH.'version.php'); 
76
-        return $res ? : array('VERSION' => '9.0.0','RELEASE' => '20190330'); 
76
+        return $res ? : array('VERSION' => '11.0.0','RELEASE' => '20210219'); 
77
     }    
77
     }    
78
 
78
 
79
     public function step2(){
79
     public function step2(){
114
         
114
         
115
         $username = $param['root'];
115
         $username = $param['root'];
116
         $password = $param['pwd'];
116
         $password = $param['pwd'];
117
+        $wkcode = $param['wkcode'];
117
         if (empty($db_config['hostname'])) {
118
         if (empty($db_config['hostname'])) {
118
             return resultArray(['error' => '请填写数据库主机!']);
119
             return resultArray(['error' => '请填写数据库主机!']);
119
         }           
120
         }           
141
         if (empty($username)) {
142
         if (empty($username)) {
142
             return resultArray(['error' => '请填写管理员用户名!']);
143
             return resultArray(['error' => '请填写管理员用户名!']);
143
         }
144
         }
145
+        if (empty($wkcode)) {
146
+            return resultArray(['error' => '请填写序列号!']);
147
+        }
148
+        $resCheckData = checkWkCode($wkcode);
149
+        if (!$resCheckData) {
150
+            return resultArray(['error' => '序列号错误!']);
151
+        }
152
+        $resData = object_to_array(json_decode($resCheckData));
153
+        if ($resData['date'] != date('Y-m-d')) {
154
+            return resultArray(['error' => '序列号已失效,请前往悟空官网个人中心获取最新数据!']);
155
+        }
144
         if (empty($password)) {
156
         if (empty($password)) {
145
             return resultArray(['error' => '请填写管理员密码!']);
157
             return resultArray(['error' => '请填写管理员密码!']);
146
         }
158
         }
161
         }
173
         }
162
 		$db_config['database'] = $database;
174
 		$db_config['database'] = $database;
163
         self::mkDatabase($db_config);
175
         self::mkDatabase($db_config);
176
+        self::mkLicense($wkcode);
164
         $C_Patch = substr($_SERVER['SCRIPT_FILENAME'],0,-10);
177
         $C_Patch = substr($_SERVER['SCRIPT_FILENAME'],0,-10);
165
         $sql = file_get_contents( $C_Patch.'/public/sql/5kcrm.sql');
178
         $sql = file_get_contents( $C_Patch.'/public/sql/5kcrm.sql');
166
         $sqlList = parse_sql($sql, 0, ['5kcrm_' => $db_config['prefix']]);
179
         $sqlList = parse_sql($sql, 0, ['5kcrm_' => $db_config['prefix']]);
185
 		//插入信息
198
 		//插入信息
186
         Db::connect($db_config)->query("insert into ".$db_config['prefix']."admin_user (username, password, salt, img, thumb_img, realname, create_time, num, email, mobile, sex, status, structure_id, post, parent_id, type, authkey, authkey_time ) values ( '".$username."', '".$password."', '".$salt."', '', '', '管理员', ".time().", '', '', '".$username."', '', 1, 1, 'CEO', 0, 1, '', 0 )");
199
         Db::connect($db_config)->query("insert into ".$db_config['prefix']."admin_user (username, password, salt, img, thumb_img, realname, create_time, num, email, mobile, sex, status, structure_id, post, parent_id, type, authkey, authkey_time ) values ( '".$username."', '".$password."', '".$salt."', '', '', '管理员', ".time().", '', '', '".$username."', '', 1, 1, 'CEO', 0, 1, '', 0 )");
187
         Db::connect($db_config)->query("insert into ".$db_config['prefix']."hrm_user_det (user_id, join_time, type, status, userstatus, create_time, update_time, mobile, sex, age, job_num, idtype, idnum, birth_time, nation, internship, done_time, parroll_id, email, political, location, leave_time ) values ( 1, ".time().", 1, 1, 2, ".time().", ".time().", '".$username."', '', 0, '', 0, '', '', 0, 0, 0, 0, '', '', '', 0 )");
200
         Db::connect($db_config)->query("insert into ".$db_config['prefix']."hrm_user_det (user_id, join_time, type, status, userstatus, create_time, update_time, mobile, sex, age, job_num, idtype, idnum, birth_time, nation, internship, done_time, parroll_id, email, political, location, leave_time ) values ( 1, ".time().", 1, 1, 2, ".time().", ".time().", '".$username."', '', 0, '', 0, '', '', 0, 0, 0, 0, '', '', '', 0 )");
188
-        touch(CONF_PATH . "install.lock"); 
201
+        touch(CONF_PATH . "install.lock");
189
         return resultArray(['data'=>'安装成功']);
202
         return resultArray(['data'=>'安装成功']);
190
     }
203
     }
204
+
205
+    public function step5()
206
+    {
207
+        return $this->fetch();
208
+    }
191
 	
209
 	
192
 	//ajax 进度条
210
 	//ajax 进度条
193
     public function progress()
211
     public function progress()
314
     {
332
     {
315
         $items = [
333
         $items = [
316
             'os'      => ['操作系统', PHP_OS, '类Unix', 'ok'],
334
             'os'      => ['操作系统', PHP_OS, '类Unix', 'ok'],
317
-            'php'     => ['PHP版本', PHP_VERSION, '7.2 ( <em style="color: #888; font-size: 12px;">>= 5.6</em> )', 'ok','性能更佳'],
335
+            'php'     => ['PHP版本', PHP_VERSION, '7.3 ( <em style="color: #888; font-size: 12px;">>= 5.6</em> )', 'ok','性能更佳'],
318
             'gd'      => ['gd', '开启', '开启', 'ok'],
336
             'gd'      => ['gd', '开启', '开启', 'ok'],
319
             'openssl' => ['openssl', '开启', '开启', 'ok'],
337
             'openssl' => ['openssl', '开启', '开启', 'ok'],
320
             'pdo' => ['pdo', '开启', '开启', 'ok'],
338
             'pdo' => ['pdo', '开启', '开启', 'ok'],
379
         }
397
         }
380
         return $items;
398
         return $items;
381
     }
399
     }
400
+
401
+    /**
402
+     * 验证序列号
403
+     * @param 
404
+     * @return
405
+     */        
406
+    public function checkCodeOld($username) {
407
+        $encryption = md5($username);
408
+        $substr = substr($username, strlen($username)-6);
409
+        $subArr = str_split($substr, 1);
410
+        $code = '';
411
+        for ($i = 0; $i <= 5; $i++) {
412
+            $code .= $encryption[$subArr[$i]];
413
+        }
414
+        return $code;
415
+    }
416
+
417
+    //写入license文件
418
+    private function mkLicense($wkcode)
419
+    {
420
+        file_put_contents( CONF_PATH.'license.dat', $wkcode);
421
+        // 判断写入是否成功
422
+        // $config = include CONF_PATH.'license.dat';
423
+        // if (empty($config)) {
424
+        //     return resultArray(['error' => 'license配置写入失败!']);
425
+        // }
426
+        return true;
427
+    }    
382
 }
428
 }

+ 20
- 8
application/admin/controller/Users.php Zobrazit soubor

91
         $data = $userModel->getDataById($param['id']);
91
         $data = $userModel->getDataById($param['id']);
92
         if (!$data) {
92
         if (!$data) {
93
             return resultArray(['error' => $userModel->getError()]);
93
             return resultArray(['error' => $userModel->getError()]);
94
-        } 
94
+        }
95
+        $data['serverUserInfo'] = $this->queryLoginUser();
95
         return resultArray(['data' => $data]);
96
         return resultArray(['data' => $data]);
96
     }
97
     }
97
 
98
 
500
         $data['username'] = $param['username'];
501
         $data['username'] = $param['username'];
501
         $data['password'] = user_md5($param['password'], $userData['salt'], $param['username']);
502
         $data['password'] = user_md5($param['password'], $userData['salt'], $param['username']);
502
         $data['userInfo'] = $userData;
503
         $data['userInfo'] = $userData;
504
+        $data['mobile'] = $param['username'];
503
         $resSync = model('Sync')->syncData($data);
505
         $resSync = model('Sync')->syncData($data);
504
         if ($resSync) {
506
         if ($resSync) {
505
             unset($data['userInfo']);
507
             unset($data['userInfo']);
658
     /**
660
     /**
659
      * 设置关注
661
      * 设置关注
660
      *
662
      *
661
-     * @return \think\response\Json
662
-     * @throws \think\Exception
663
-     * @throws \think\exception\PDOException
664
      */
663
      */
665
     public function userStar()
664
     public function userStar()
666
     {
665
     {
700
     /**
699
     /**
701
      * 获取下属(全部层级)
700
      * 获取下属(全部层级)
702
      *
701
      *
703
-     * @return \think\response\Json
704
-     * @throws \think\db\exception\DataNotFoundException
705
-     * @throws \think\db\exception\ModelNotFoundException
706
-     * @throws \think\exception\DbException
707
      */
702
      */
708
     public function subordinate()
703
     public function subordinate()
709
     {
704
     {
720
 
715
 
721
         return resultArray(['data' => $data]);
716
         return resultArray(['data' => $data]);
722
     }
717
     }
718
+
719
+    /**
720
+     * 获取当前登录人信息
721
+     *
722
+     */    
723
+    public function queryLoginUser()
724
+    {
725
+        $resData = [];
726
+        $wkcode = file_get_contents(CONF_PATH.'license.dat'); 
727
+        if ($wkcode) {
728
+            $resCheckData = checkWkCode($wkcode);
729
+            if ($resCheckData) {
730
+                $resData = object_to_array(json_decode($resCheckData));
731
+            }            
732
+        }
733
+        return $resData;      
734
+    }
723
 }
735
 }

+ 11
- 6
application/admin/logic/FieldGrantLogic.php Zobrazit soubor

535
     {
535
     {
536
         $content = [];
536
         $content = [];
537
 
537
 
538
-        $visitList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_visit')->select();
538
+        $visitList = Db::name('admin_field')->field(['name', 'field'])->where(['type' => 'crm_visit', 'operating' => 0])->select();
539
 
539
 
540
         # 处理自定义字段
540
         # 处理自定义字段
541
         foreach ($visitList AS $key => $value) {
541
         foreach ($visitList AS $key => $value) {
551
         }
551
         }
552
 
552
 
553
         # 处理固定字段
553
         # 处理固定字段
554
-//        $content[] = ['name' => '回访时间', 'field' => 'visit_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
555
-        $content[] = ['name' => '负责人', 'field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
556
-        $content[] = ['name' => '客户', 'field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
557
-        $content[] = ['name' => '联系人', 'field' => 'contract_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
554
+        $content[] = ['name' => '回访编号', 'field' => 'number', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
555
+        $content[] = ['name' => '回访形式', 'field' => 'shape', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
556
+        $content[] = ['name' => '客户满意度', 'field' => 'satisfaction', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
557
+        $content[] = ['name' => '回访时间', 'field' => 'visit_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
558
+        $content[] = ['name' => '客户名称', 'field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
559
+        $content[] = ['name' => '联系人', 'field' => 'contacts_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
560
+        $content[] = ['name' => '合同编号', 'field' => 'contract_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
561
+        $content[] = ['name' => '客户反馈', 'field' => 'feedback', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
562
+        $content[] = ['name' => '回访人', 'field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
558
         $content[] = ['name' => '创建时间', 'field' => 'create_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
563
         $content[] = ['name' => '创建时间', 'field' => 'create_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
559
         $content[] = ['name' => '编辑时间', 'field' => 'update_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
564
         $content[] = ['name' => '编辑时间', 'field' => 'update_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
560
         $content[] = ['name' => '创建人', 'field' => 'create_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
565
         $content[] = ['name' => '创建人', 'field' => 'create_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
561
-        $content[] = ['name' => '合同', 'field' => 'contacts_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
566
+
562
 
567
 
563
         Db::name('admin_field_grant')->insert([
568
         Db::name('admin_field_grant')->insert([
564
             'role_id'     => $roleId,
569
             'role_id'     => $roleId,

+ 38
- 48
application/admin/logic/MessageLogic.php Zobrazit soubor

10
     {
10
     {
11
         $where = '';
11
         $where = '';
12
         switch ($label) {
12
         switch ($label) {
13
-
13
+            
14
             case '1':  //任务
14
             case '1':  //任务
15
                 $where = array('in', [1, 2, 3]);//
15
                 $where = array('in', [1, 2, 3]);//
16
                 break;
16
                 break;
21
                 $where = array('in', [6, 7, 8]);
21
                 $where = array('in', [6, 7, 8]);
22
                 break;
22
                 break;
23
             case '4':  //公告
23
             case '4':  //公告
24
-                $where = array('eq', 9);
24
+                $where = 9;
25
                 break;
25
                 break;
26
             case '5' :  //日程
26
             case '5' :  //日程
27
                 $where = 10;
27
                 $where = 10;
36
         }
36
         }
37
         return $where;
37
         return $where;
38
     }
38
     }
39
-
39
+   
40
     public function getDataList($param)
40
     public function getDataList($param)
41
     {
41
     {
42
         $userId = $param['user_id'];
42
         $userId = $param['user_id'];
43
         unset($param['user_id']);
43
         unset($param['user_id']);
44
         //types 1表示已读 0表示未读
44
         //types 1表示已读 0表示未读
45
         if (isset($param['is_read'])) {
45
         if (isset($param['is_read'])) {
46
-            $where['m.read_time'] = ['=', 0];
46
+            $where['m.read_time'] = 0;
47
         }
47
         }
48
         $where['m.to_user_id'] = $userId;
48
         $where['m.to_user_id'] = $userId;
49
         $where['m.is_delete'] = ['eq', 1];
49
         $where['m.is_delete'] = ['eq', 1];
74
                 ->page($param['page'], $param['limit'])
74
                 ->page($param['page'], $param['limit'])
75
                 ->order($order)
75
                 ->order($order)
76
                 ->select();
76
                 ->select();
77
+            $dataCount = db('admin_message')
78
+                ->alias('m')
79
+                ->join('__ADMIN_USER__ user', 'user.id=m.from_user_id', 'LEFT')
80
+                ->where($where)->count();
77
         }
81
         }
78
-        $dataCount = db('admin_message')
79
-            ->alias('m')
80
-            ->join('__ADMIN_USER__ user', 'user.id=m.from_user_id', 'LEFT')
81
-            ->where($where)->count();
82
         //1表示已读 0表示未读
82
         //1表示已读 0表示未读
83
         foreach ($list as $k => $v) {
83
         foreach ($list as $k => $v) {
84
             if ($v['read_time'] == 0) {
84
             if ($v['read_time'] == 0) {
90
             if ($v['type'] == 4) {
90
             if ($v['type'] == 4) {
91
                 $content = db('admin_comment')
91
                 $content = db('admin_comment')
92
                     ->where(
92
                     ->where(
93
-                        [   'status' => 1,
94
-                            'comment_id' => $v['action_id'],
93
+                        ['status' => 1,
94
+                            'type_id' => $v['action_id'],
95
                             'type' => ['like', '%' . $v['controller_name' . '%']],
95
                             'type' => ['like', '%' . $v['controller_name' . '%']],
96
                             'user_id' => $v['from_user_id']
96
                             'user_id' => $v['from_user_id']
97
                         ])
97
                         ])
98
-                    ->find();
99
-                if (!empty($content)) {
100
-                    $list[$k]['content'] = $content['content'];
101
-                }
102
-            } elseif (in_array($v['type'], ['12', '15'])) {
98
+                    ->select();
99
+                $list[$k]['content'] = $content[$k]['content'];
100
+            } elseif (in_array($v['type'], ['7','12', '15',25])) {
103
                 $content = db('admin_examine_record')->where(['types_id' => $v['action_id'], 'types' => ['like', '%' . $v['controller_name' . '%']], 'check_user_id' => $v['from_user_id']])->field('content')->find();
101
                 $content = db('admin_examine_record')->where(['types_id' => $v['action_id'], 'types' => ['like', '%' . $v['controller_name' . '%']], 'check_user_id' => $v['from_user_id']])->field('content')->find();
104
                 if ($content['content']) {
102
                 if ($content['content']) {
105
                     $list[$k]['content'] = $content['content'];
103
                     $list[$k]['content'] = $content['content'];
106
                 }
104
                 }
107
             }
105
             }
108
-            if ($v['type'] == 10) {
109
-                    $item = db('oa_event_notice')->where('id', $v['action_id'])->find();
110
-
111
-                    if ($item) {
112
-                        $noticetype = $item['noticetype'];
113
-                        if($item['noticetype'] == 1){
114
-                            $advance_time =$v['advance_time'] - ($item['number'] * 60);
115
-                        }elseif ($item['noticetype'] == 2){
116
-                            $advance_time =$v['advance_time'] - ($item['number'] * 60 * 60);
117
-                        }else{
118
-                            $advance_time = $v['advance_time'] - ($item['number'] * 60 * 60 * 24);
119
-                        }
120
-
121
-                        $time = time();
122
-                        if ($time == $advance_time ||$time>$advance_time) {
123
-                            $type['value']=$item['number'];
124
-                            $type['type']=$item['noticetype'];
125
-                            $list[$k]['content']= $type;
126
-                            $list[$k]['action_id'] = $item['event_id'];
127
-                        }
128
-                    }
129
-//                p(222);
106
+            if ($v['type'] == 10 && $v['advance_time'] < time()) {
107
+                $item = db('oa_event_notice')->where('id', $v['action_id'])->find();
108
+                if ($item) {
109
+                    $type['value'] = $item['number'];
110
+                    $type['type'] = $item['noticetype'];
111
+                    $list[$k]['content'] = $type;
112
+                    $list[$k]['action_id'] = $item['event_id'];
113
+                }
114
+            } elseif($v['type'] == 10 && $v['advance_time'] > time()) {
115
+                unset($list[$k]);
130
             }
116
             }
117
+            $time=time();
131
             if (in_array($v['type'], ['17', '18', '19', '20', '27'])) {
118
             if (in_array($v['type'], ['17', '18', '19', '20', '27'])) {
132
                 $error_file_path = db('admin_import_record')->where('id', $v['action_id'])->find();
119
                 $error_file_path = db('admin_import_record')->where('id', $v['action_id'])->find();
133
-                if($error_file_path['error_data_file_path']==''){
134
-                    $list[$k]['title'] = '';
120
+                $week = strtotime("+7 day", $error_file_path['create_time']);
121
+                if ($time > (int)$week && $error_file_path['error_data_file_path'] != '') {
122
+                    $list[$k]['valid'] = 0;
123
+                } else {
124
+                    $list[$k]['valid'] = 1;
135
                 }
125
                 }
136
                 $list[$k]['error_file_path'] = $error_file_path['error_data_file_path'];
126
                 $list[$k]['error_file_path'] = $error_file_path['error_data_file_path'];
137
             }
127
             }
151
         }
141
         }
152
         return $data;
142
         return $data;
153
     }
143
     }
154
-
144
+    
155
     /**
145
     /**
156
      * 修改状态变为已读
146
      * 修改状态变为已读
157
      * @param $param
147
      * @param $param
173
         $data['list'] = $list;
163
         $data['list'] = $list;
174
         return $data;
164
         return $data;
175
     }
165
     }
176
-
166
+    
177
     /**
167
     /**
178
      * 删除
168
      * 删除
179
      *
169
      *
190
         }
180
         }
191
         return db('admin_message')->where(['message_id' => $param['message_id']])->update(['is_delete' => 2]);
181
         return db('admin_message')->where(['message_id' => $param['message_id']])->update(['is_delete' => 2]);
192
     }
182
     }
193
-
183
+    
194
     /**
184
     /**
195
      * 批量更新
185
      * 批量更新
196
      * @param $param
186
      * @param $param
200
      */
190
      */
201
     public function readAllMessage($param)
191
     public function readAllMessage($param)
202
     {
192
     {
203
-
193
+        
204
         $where = [
194
         $where = [
205
             'to_user_id' => $param['user_id'],
195
             'to_user_id' => $param['user_id'],
206
             'read_time' => 0
196
             'read_time' => 0
220
         $data['list'] = $list;
210
         $data['list'] = $list;
221
         return $data;
211
         return $data;
222
     }
212
     }
223
-
213
+    
224
     /**
214
     /**
225
      * 批量删除已读
215
      * 批量删除已读
226
      * @param $param
216
      * @param $param
244
         $data['list'] = $list;
234
         $data['list'] = $list;
245
         return $data;
235
         return $data;
246
     }
236
     }
247
-
237
+    
248
     public function unreadCount($param)
238
     public function unreadCount($param)
249
     {
239
     {
250
         $userId = $param['user_id'];
240
         $userId = $param['user_id'];
253
         $label = '';
243
         $label = '';
254
         $where['to_user_id'] = ['eq', $userId];
244
         $where['to_user_id'] = ['eq', $userId];
255
         $where['is_delete'] = ['eq', 1];
245
         $where['is_delete'] = ['eq', 1];
256
-
246
+        
257
         $where['type'] = $this->label('');
247
         $where['type'] = $this->label('');
258
         $allCount = db('admin_message')->where($where)->count();
248
         $allCount = db('admin_message')->where($where)->count();
259
         $where['type'] = $this->label(1);
249
         $where['type'] = $this->label(1);
265
         $where['type'] = 9;
255
         $where['type'] = 9;
266
         $announceCount = db('admin_message')->where($where)->count();
256
         $announceCount = db('admin_message')->where($where)->count();
267
         $where['type'] = $this->label(5);
257
         $where['type'] = $this->label(5);
268
-        $eventCount = db('admin_message')->where($where)->where('advance_time', '>=', time())->count();
258
+        $eventCount = db('admin_message')->where($where)->where(['advance_time'=>['<', time()],'advance_time'=>['<>',0]])->count();
269
         $where['type'] = $this->label(6);
259
         $where['type'] = $this->label(6);
270
         $crmCount = db('admin_message')->where($where)->count();
260
         $crmCount = db('admin_message')->where($where)->count();
271
-
261
+        
272
         $data = [];
262
         $data = [];
273
         $data['allCount'] = $allCount ?: 0;
263
         $data['allCount'] = $allCount ?: 0;
274
         $data['taskCount'] = $taskCount ?: 0;
264
         $data['taskCount'] = $taskCount ?: 0;

+ 7
- 0
application/admin/logic/WorkLogic.php Zobrazit soubor

109
 
109
 
110
         if (!Db::name('admin_group')->where('id', $id)->delete()) return ['status' => false, 'error' => '操作失败!'];
110
         if (!Db::name('admin_group')->where('id', $id)->delete()) return ['status' => false, 'error' => '操作失败!'];
111
 
111
 
112
+        # 将项目权限变更为只读权限
113
+        $readOnlyId = db('admin_group')->where(['title' => '只读', 'types' => 7, 'system' => 1])->value('id');
114
+        if (!empty($readOnlyId)) {
115
+            db('work')->where('group_id', $id)->update(['group_id' => $readOnlyId]);      # 处理公开项目的权限
116
+            db('work_user')->where('group_id', $id)->update(['group_id' => $readOnlyId]); # 处理私有项目的权限
117
+        }
118
+
112
         return ['status' => true];
119
         return ['status' => true];
113
     }
120
     }
114
 }
121
 }

+ 2
- 1
application/admin/model/Common.php Zobrazit soubor

295
 	 */
295
 	 */
296
 	public function exportHandle($list, $field_list, $type = '')
296
 	public function exportHandle($list, $field_list, $type = '')
297
 	{
297
 	{
298
+	 
298
 		foreach ($list as &$val) {
299
 		foreach ($list as &$val) {
299
 			foreach ($field_list as $field) {
300
 			foreach ($field_list as $field) {
300
 				switch ($field['form_type']) {
301
 				switch ($field['form_type']) {
310
 						$val[$field['field']] = implode(',', array_column($temp, 'name'));
311
 						$val[$field['field']] = implode(',', array_column($temp, 'name'));
311
 						break;
312
 						break;
312
 					case 'datetime':
313
 					case 'datetime':
313
-						$val[$field['field']] = strtotime($val[$field['field']]) ? $val[$field['field']] : date('Y-m-d H:i:s', $val[$field['field']]);
314
+						$val[$field['field']] = strtotime($val[$field['field']]) ? $val[$field['field']] : '';
314
 						break;
315
 						break;
315
 					case 'customer':
316
 					case 'customer':
316
 					case 'business':
317
 					case 'business':

+ 2
- 1
application/admin/model/ExamineStep.php Zobrazit soubor

324
                 $is_recheck = 1;
324
                 $is_recheck = 1;
325
             }
325
             }
326
         }
326
         }
327
-        if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'],['2','3'])) {
327
+        if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'],['2','3','4'])) {
328
             $is_check = 1;
328
             $is_check = 1;
329
         }
329
         }
330
 
330
 
339
 
339
 
340
                 $createUserInfo['check_type'] = 3;
340
                 $createUserInfo['check_type'] = 3;
341
                 $newlist[0]['type'] = '3'; //创建
341
                 $newlist[0]['type'] = '3'; //创建
342
+                $newlist[0]['status'] = '5'; //创建,前端要求给创建人加一个status字段,定义为5
342
             }
343
             }
343
             $newlist[0]['user_id_info'] = array($createUserInfo);
344
             $newlist[0]['user_id_info'] = array($createUserInfo);
344
             $newlist[0]['time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
345
             $newlist[0]['time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;

+ 432
- 361
application/admin/model/Excel.php
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 33
- 14
application/admin/model/Field.php Zobrazit soubor

182
         if ($param['types'] == 'crm_customer') {
182
         if ($param['types'] == 'crm_customer') {
183
             $map['field'] = array('not in', ['deal_status']);
183
             $map['field'] = array('not in', ['deal_status']);
184
         }
184
         }
185
-        if ($param['types'] == 'crm_visit') {
186
-            $map['types'] = array('in', ['', $types]);
187
-            $map['field'] = ['not in', ['create_user_id', 'update_time', 'create_time']];
188
-        }
189
         $list = Db::name('AdminField')->where($map)->order('order_id')->select();
185
         $list = Db::name('AdminField')->where($map)->order('order_id')->select();
190
         foreach ($list as $k => $v) {
186
         foreach ($list as $k => $v) {
191
             $list[$k]['setting'] = $v['setting'] ? explode(chr(10), $v['setting']) : [];
187
             $list[$k]['setting'] = $v['setting'] ? explode(chr(10), $v['setting']) : [];
655
             }
651
             }
656
 
652
 
657
         } else {
653
         } else {
658
-            $field_list = $this->where($map)->field('field,types,name,form_type,default_value,is_unique,is_null,input_tips,setting')->order($order)->select();
654
+            $field_list = $this->where($map)->where( 'is_hidden',0)->field('field,types,name,form_type,default_value,is_unique,is_null,input_tips,setting,is_hidden')->order($order)->select();
659
 
655
 
660
             //客户
656
             //客户
661
             if (in_array($param['types'], ['crm_customer'])) {
657
             if (in_array($param['types'], ['crm_customer'])) {
754
                     ];
750
                     ];
755
                 } elseif ($v['form_type'] == 'user') {
751
                 } elseif ($v['form_type'] == 'user') {
756
                     $value = $userModel->getListByStr($dataInfo[$v['field']]) ?: [];
752
                     $value = $userModel->getListByStr($dataInfo[$v['field']]) ?: [];
757
-                } elseif ($v['form_type'] == 'structure') {
753
+                    if (empty($value)) $default_value = $userModel->getListByStr($param['user_id']) ? : [];
754
+                } elseif ($v['form_type'] == 'single_user') {
755
+                    # 单用户
756
+                    $userInfo = $userModel->getListByStr($dataInfo[$v['field']]);
757
+                    $value = !empty($userInfo[0]) ? $userInfo[0] : [];
758
+                    if (empty($value)) {
759
+                        $userInfo = $userModel->getListByStr($param['user_id']);
760
+                        $default_value = !empty($userInfo[0]) ? $userInfo[0] : [];
761
+                    }
762
+                }elseif ($v['form_type'] == 'structure') {
758
                     $value = $structureModel->getListByStr($dataInfo[$v['field']]) ?: [];
763
                     $value = $structureModel->getListByStr($dataInfo[$v['field']]) ?: [];
759
                 } elseif ($v['form_type'] == 'file') {
764
                 } elseif ($v['form_type'] == 'file') {
760
                     $fileIds = [];
765
                     $fileIds = [];
882
         $userModel = new \app\admin\model\User();
887
         $userModel = new \app\admin\model\User();
883
         $user_id = $param['user_id'];
888
         $user_id = $param['user_id'];
884
         $map['types'] = ['in', ['', $types]];
889
         $map['types'] = ['in', ['', $types]];
885
-        $map['form_type'] = ['not in', ['file', 'form', 'checkbox', 'structure', 'business_status']];
890
+        $map['form_type'] = ['not in', ['file', 'form', 'business_status']];
891
+        $map['is_hidden'] = 0;
886
         $field_list = db('admin_field')
892
         $field_list = db('admin_field')
887
             ->where($map)
893
             ->where($map)
888
             ->whereOr(['types' => ''])
894
             ->whereOr(['types' => ''])
1026
         $userLevel = isSuperAdministrators($user_id);
1032
         $userLevel = isSuperAdministrators($user_id);
1027
 
1033
 
1028
         $fieldList = $this->getFieldList($types, $types_id);
1034
         $fieldList = $this->getFieldList($types, $types_id);
1029
-
1030
         $where = [];
1035
         $where = [];
1031
         if ($userFieldData) {
1036
         if ($userFieldData) {
1032
             $fieldArr = [];
1037
             $fieldArr = [];
1033
             $i = 0;
1038
             $i = 0;
1034
             foreach ($userFieldData as $k => $v) {
1039
             foreach ($userFieldData as $k => $v) {
1040
+                if (empty($fieldList[$k])) {
1041
+                    unset($userFieldData[$k]);
1042
+                    continue;
1043
+                }
1044
+
1035
                 if (empty($v['is_hide'])) {
1045
                 if (empty($v['is_hide'])) {
1036
                     $fieldArr[$i]['field'] = $k;
1046
                     $fieldArr[$i]['field'] = $k;
1037
                     $fieldArr[$i]['name'] = $fieldList[$k]['name'];
1047
                     $fieldArr[$i]['name'] = $fieldList[$k]['name'];
1081
                 'form_type' => ['not in', ['file', 'form']],
1091
                 'form_type' => ['not in', ['file', 'form']],
1082
                 'field' => ['not in', $unField],
1092
                 'field' => ['not in', $unField],
1083
                 'types_id' => ['eq', $types_id],
1093
                 'types_id' => ['eq', $types_id],
1094
+                'is_hidden'=>0
1084
             ])
1095
             ])
1085
-            ->field(['field', 'name', 'form_type'])
1096
+            ->field(['field', 'name', 'form_type,is_hidden'])
1086
             ->order('order_id asc')
1097
             ->order('order_id asc')
1087
             ->select();
1098
             ->select();
1088
 
1099
 
1192
         } else {
1203
         } else {
1193
             $listArr = $dataList;
1204
             $listArr = $dataList;
1194
         }
1205
         }
1195
-
1196
         $typesArray = explode('_', $types);
1206
         $typesArray = explode('_', $types);
1197
         $type = array_pop($typesArray);
1207
         $type = array_pop($typesArray);
1198
         if (isset($this->orther_field_list[$types])) {
1208
         if (isset($this->orther_field_list[$types])) {
1257
                 if ($unFormType) $data['form_type'] = array('not in', $unFormType);
1267
                 if ($unFormType) $data['form_type'] = array('not in', $unFormType);
1258
                 $field_arr = $this->fieldSearch($data);
1268
                 $field_arr = $this->fieldSearch($data);
1259
         }
1269
         }
1270
+        if ($types == 'crm_visit') {
1271
+            foreach ($field_arr AS $key => $value) {
1272
+                if ($value['name'] == '负责人') unset($field_arr[(int)$key]);
1273
+            }
1274
+        }
1260
         return $field_arr;
1275
         return $field_arr;
1261
     }
1276
     }
1262
 
1277
 
1315
 
1330
 
1316
         $where = [];
1331
         $where = [];
1317
         $where[$field] = ['eq', $val];
1332
         $where[$field] = ['eq', $val];
1318
-        if ($id) {
1319
-            //为编辑时的验重
1320
-            $where[$dataModel->getpk()] = ['neq', $id];
1333
+            if ($id) {
1334
+                //为编辑时的验重
1335
+                $where[$dataModel->getpk()] = ['neq', $id];
1336
+            }
1337
+        if($types=='crm_product'){
1338
+            $where['delete_user_id'] = 0;
1321
         }
1339
         }
1322
         if ($res = $dataModel->where($where)->find()) {
1340
         if ($res = $dataModel->where($where)->find()) {
1323
             $this->error = '该数据已存在,请修改后提交!';
1341
             $this->error = '该数据已存在,请修改后提交!';
1378
             case 'userStr' :
1396
             case 'userStr' :
1379
                 $val = explode(',', $val);
1397
                 $val = explode(',', $val);
1380
                 $val = count($userModel->getUserNameByArr($val)) > 1 ? ArrayToString($userModel->getUserNameByArr($val)) : implode(',', $userModel->getUserNameByArr($val));
1398
                 $val = count($userModel->getUserNameByArr($val)) > 1 ? ArrayToString($userModel->getUserNameByArr($val)) : implode(',', $userModel->getUserNameByArr($val));
1381
-                break;                
1399
+                break;
1382
             case 'structure' :
1400
             case 'structure' :
1383
                 $val = ArrayToString($structureModel->getStructureNameByArr($val));
1401
                 $val = ArrayToString($structureModel->getStructureNameByArr($val));
1384
                 break;
1402
                 break;
1648
                         break;
1666
                         break;
1649
                     case 'owner_user_id' :
1667
                     case 'owner_user_id' :
1650
                         $data[$key]['fieldName'] = 'owner_user_name';
1668
                         $data[$key]['fieldName'] = 'owner_user_name';
1669
+                        $data[$key]['name'] = '回访人';
1651
                         break;
1670
                         break;
1652
                     case 'contacts_id' :
1671
                     case 'contacts_id' :
1653
                         $data[$key]['fieldName'] = 'contacts_name';
1672
                         $data[$key]['fieldName'] = 'contacts_name';

+ 1
- 1
application/admin/model/Record.php Zobrazit soubor

609
 		}
609
 		}
610
 		$fileModel = new \app\admin\model\File();
610
 		$fileModel = new \app\admin\model\File();
611
 		$record_ids = db('crm_activity')->where(['activity_type' => $types,'activity_type_id' => ['in',$types_id]])->column('activity_id');
611
 		$record_ids = db('crm_activity')->where(['activity_type' => $types,'activity_type_id' => ['in',$types_id]])->column('activity_id');
612
-        db('crm_activity')->where(['activity_type' => $types,'activity_type_id' => ['in',$types_id],'type'=>1])->delete();
612
+        db('crm_activity')->where(['activity_type' => $types,'activity_type_id' => ['in',$types_id]])->delete();
613
 		//删除关联附件
613
 		//删除关联附件
614
         $fileModel->delRFileByModule('crm_activity',$record_ids);
614
         $fileModel->delRFileByModule('crm_activity',$record_ids);
615
 		return true;
615
 		return true;

+ 13
- 5
application/admin/model/Scene.php Zobrazit soubor

53
             foreach ($value AS $k => $v) {
53
             foreach ($value AS $k => $v) {
54
                 $sceneData[$k] = [
54
                 $sceneData[$k] = [
55
                     'condition' => trim($v['condition']),
55
                     'condition' => trim($v['condition']),
56
-                    'value' => $v['value'],
56
+                    'value'     => $v['value'],
57
                     'form_type' => $v['form_type'],
57
                     'form_type' => $v['form_type'],
58
-                    'name' => $v['name'],
59
-                    'type' => $v['type']
58
+                    'name'      => $v['name'],
59
+                    'type'      => $v['type']
60
                 ];
60
                 ];
61
             }
61
             }
62
         }
62
         }
200
         $sceneData = [];
200
         $sceneData = [];
201
         foreach ($param['data'] AS $key => $value) {
201
         foreach ($param['data'] AS $key => $value) {
202
             foreach ($value AS $k => $v) {
202
             foreach ($value AS $k => $v) {
203
-                $sceneData[$k] = $v;
203
+                $sceneData[$k] = [
204
+                    'condition' => trim($v['condition']),
205
+                    'value'     => $v['value'],
206
+                    'form_type' => $v['form_type'],
207
+                    'name'      => $v['name'],
208
+                    'type'      => $v['type']
209
+                ];
204
             }
210
             }
205
         }
211
         }
206
         if (!empty($sceneData)) $param['data'] = $sceneData;
212
         if (!empty($sceneData)) $param['data'] = $sceneData;
210
 		$res = $this->allowField(true)->save($param, ['scene_id' => $id]);
216
 		$res = $this->allowField(true)->save($param, ['scene_id' => $id]);
211
 		if ($param['is_default'] == 1) {
217
 		if ($param['is_default'] == 1) {
212
 			$this->defaultDataById($param,$param['id']);
218
 			$this->defaultDataById($param,$param['id']);
213
-		}
219
+		} else {
220
+		    db('admin_scene_default')->where(['user_id' => $user_id, 'types' => $param['types'], 'scene_id' => $id])->delete();
221
+        }
214
 		if ($res) {
222
 		if ($res) {
215
 			return true;
223
 			return true;
216
 		} else {
224
 		} else {

+ 7
- 4
application/admin/model/User.php Zobrazit soubor

47
 			'name' => '手机号(登录名)',
47
 			'name' => '手机号(登录名)',
48
 			'form_type' => 'mobile',
48
 			'form_type' => 'mobile',
49
 			'is_null' => 1,
49
 			'is_null' => 1,
50
-			'is_unique' => 1
50
+//			'is_unique' => 1 //guogaobo 导入此字段会进行验重查询调用修改用户方法
51
 		],
51
 		],
52
 		[
52
 		[
53
 			'field' => 'password',
53
 			'field' => 'password',
256
 			}
256
 			}
257
 			$param = $temp;
257
 			$param = $temp;
258
 			$param['structure_id'] = 0;
258
 			$param['structure_id'] = 0;
259
+            if(db('admin_user')->where('username',$param['username'])->find()){
260
+                $this->error = '手机号已存在';
261
+                return false;
262
+            }
259
 		} else {
263
 		} else {
260
 			if (empty($param['group_id']) || !is_array($param['group_id'])) {
264
 			if (empty($param['group_id']) || !is_array($param['group_id'])) {
261
 				$this->error = '请至少勾选一个用户组';
265
 				$this->error = '请至少勾选一个用户组';
269
 			return false;
273
 			return false;
270
 		}
274
 		}
271
 		$syncModel = new \app\admin\model\Sync();
275
 		$syncModel = new \app\admin\model\Sync();
272
-
273
 		$this->startTrans();
276
 		$this->startTrans();
274
 		try {
277
 		try {
275
 			$salt = substr(md5(time()),0,4);
278
 			$salt = substr(md5(time()),0,4);
350
 	 */
353
 	 */
351
 	public function updateDataById($param, $id)
354
 	public function updateDataById($param, $id)
352
 	{
355
 	{
356
+	 
353
 		if ($param['user_id']) {
357
 		if ($param['user_id']) {
354
 			//修改个人信息
358
 			//修改个人信息
355
 			$data['email'] = $param['email'];
359
 			$data['email'] = $param['email'];
396
 				$this->error = '直属上级不能是自己或下属';
400
 				$this->error = '直属上级不能是自己或下属';
397
 				return false;
401
 				return false;
398
 			}
402
 			}
403
+			p(2333);
399
 			if (db('admin_user')->where(['id' => ['neq',$id],'username' => $param['username']])->find()) {
404
 			if (db('admin_user')->where(['id' => ['neq',$id],'username' => $param['username']])->find()) {
400
 				$this->error = '手机号已存在';
405
 				$this->error = '手机号已存在';
401
 				return false;			
406
 				return false;			
925
         $authList['jxc']       = (Object)[];
930
         $authList['jxc']       = (Object)[];
926
         $authList['knowledge'] = (Object)[];
931
         $authList['knowledge'] = (Object)[];
927
 
932
 
928
-        $authList['crm']['receivables']['excelexport'] = false;
929
-
930
         return $authList;
933
         return $authList;
931
     }
934
     }
932
 
935
 

+ 13
- 1
application/admin/model/UserField.php Zobrazit soubor

147
             $field_list[$v['field']]['name'] = $v['name'];
147
             $field_list[$v['field']]['name'] = $v['name'];
148
             $fieldArr[$k]['width'] = '';
148
             $fieldArr[$k]['width'] = '';
149
         }
149
         }
150
-       
150
+
151
         //已设置字段
151
         //已设置字段
152
         $value = $this->where(['types' => $types,'user_id' => $user_id])->value('datas');
152
         $value = $this->where(['types' => $types,'user_id' => $user_id])->value('datas');
153
         $value = $value ? json_decode($value, true) : [];
153
         $value = $value ? json_decode($value, true) : [];
162
             $a = 0;
162
             $a = 0;
163
             $b = 0;
163
             $b = 0;
164
             foreach ($value as $k=>$v) {
164
             foreach ($value as $k=>$v) {
165
+                if (empty($field_list[$k]['name'])) continue;
166
+
165
                 if (empty($v['is_hide'])) {
167
                 if (empty($v['is_hide'])) {
166
                     $valueList[] = $k;
168
                     $valueList[] = $k;
167
                     $value_list[$a]['field'] = $k; 
169
                     $value_list[$a]['field'] = $k; 
193
         $data = [];
195
         $data = [];
194
         $data['value_list'] = $value_list ? : []; //展示列
196
         $data['value_list'] = $value_list ? : []; //展示列
195
         $data['hide_list'] = $hide_list ? : []; //隐藏列
197
         $data['hide_list'] = $hide_list ? : []; //隐藏列
198
+
199
+        if ($types == 'crm_visit') {
200
+            foreach ($data['value_list'] AS $key => $value) {
201
+                if ($value['name'] == '负责人') $data['value_list'][$key]['name'] = '回访人';
202
+            }
203
+            foreach ($data['hide_list'] AS $key => $value) {
204
+                if ($value['name'] == '负责人') $data['hide_list'][$key]['name'] = '回访人';
205
+            }
206
+        }
207
+
196
         return $data ? : [];
208
         return $data ? : [];
197
     }    
209
     }    
198
 }
210
 }

+ 1
- 1
application/admin/view/install/index.html Zobrazit soubor

28
 			官方地址:<a target="_blank" href="http://www.5kcrm.com">www.5kcrm.com</a> / <a target="_blank" href="https://www.72crm.com">www.72crm.com</a><br>
28
 			官方地址:<a target="_blank" href="http://www.5kcrm.com">www.5kcrm.com</a> / <a target="_blank" href="https://www.72crm.com">www.72crm.com</a><br>
29
 			官方电话:400-0812-558<br>
29
 			官方电话:400-0812-558<br>
30
 			官方邮箱:service@5kcrm.com<br>
30
 			官方邮箱:service@5kcrm.com<br>
31
-			官方社区:<a target="_blank" href="http://www.72crm.net">bbs.72crm.net</a><br>
31
+			官方社区:<a target="_blank" href="https://bbs.72crm.com">bbs.72crm.com</a><br>
32
 			官方社群:<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=f4687b809bf63f08f707aa1c56dee8dbcb9526237c429c4532222021d65bf83c">悟空CRM交流10群(486745026)</a><br>
32
 			官方社群:<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=f4687b809bf63f08f707aa1c56dee8dbcb9526237c429c4532222021d65bf83c">悟空CRM交流10群(486745026)</a><br>
33
 		<br>
33
 		<br>
34
 		<p>一、协议中提到的名词约定</p>
34
 		<p>一、协议中提到的名词约定</p>

+ 10
- 4
application/admin/view/install/step1.html Zobrazit soubor

16
         <div class="top">
16
         <div class="top">
17
             <div class="step-group">
17
             <div class="step-group">
18
                 <div class="step active">
18
                 <div class="step active">
19
-                    <div class="sort">1</div>
19
+                    <div class="sort">
20
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
21
+                    </div>
20
                     <div class="desc">检查安装环境</div>
22
                     <div class="desc">检查安装环境</div>
21
                 </div>
23
                 </div>
22
                 <div class="step line"></div>
24
                 <div class="step line"></div>
23
                 <div class="step">
25
                 <div class="step">
24
-                    <div class="sort">2</div>
26
+                    <div class="sort">
27
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
28
+                    </div>
25
                     <div class="desc">创建数据库</div>
29
                     <div class="desc">创建数据库</div>
26
                 </div>
30
                 </div>
27
                 <div class="step line"></div>
31
                 <div class="step line"></div>
28
                 <div class="step">
32
                 <div class="step">
29
-                    <div class="sort">3</div>
33
+                    <div class="sort">
34
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
35
+                    </div>
30
                     <div class="desc">安装成功</div>
36
                     <div class="desc">安装成功</div>
31
                 </div>
37
                 </div>
32
             </div>
38
             </div>
34
         <div class="container">
40
         <div class="container">
35
             <div class="content">
41
             <div class="content">
36
                 <div class="base-top">
42
                 <div class="base-top">
37
-                    <span class="title">1 检查安装环境</span>
43
+                    <span class="title">检查安装环境</span>
38
                     <span class="version">当前版本:{$data['version']['VERSION']} {$data['version']['RELEASE']}</span>
44
                     <span class="version">当前版本:{$data['version']['VERSION']} {$data['version']['RELEASE']}</span>
39
                 </div>
45
                 </div>
40
                 <div class="table">
46
                 <div class="table">

+ 70
- 43
application/admin/view/install/step2.html Zobrazit soubor

7
         <link rel="shortcut icon" href="__STATIC__/icon/favicon.ico">
7
         <link rel="shortcut icon" href="__STATIC__/icon/favicon.ico">
8
         <link rel="stylesheet" href="__STATIC__/style/base.css">
8
         <link rel="stylesheet" href="__STATIC__/style/base.css">
9
         <link rel="stylesheet" href="__STATIC__/style/step2.css">
9
         <link rel="stylesheet" href="__STATIC__/style/step2.css">
10
+        <link rel="stylesheet" href="__STATIC__/style/loading.css">
10
         <script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
11
         <script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
11
     </head>
12
     </head>
12
-    <body>
13
+    
14
+    <body style="width: 100%; height: 100%;position: relative;">
15
+        <div id="cover">
16
+           <div id="loader-container">
17
+            <p id="loadingText">creating...</p>
18
+        </div> 
19
+        </div>  
20
+        
13
         <div class="header-wrapper">
21
         <div class="header-wrapper">
14
             {include file="public/header"}   
22
             {include file="public/header"}   
15
         </div>
23
         </div>
16
         <div class="top">
24
         <div class="top">
17
             <div class="step-group">
25
             <div class="step-group">
18
                 <div class="step active">
26
                 <div class="step active">
19
-                    <div class="sort">1</div>
27
+                    <div class="sort">
28
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
29
+                    </div>
20
                     <div class="desc">检查安装环境</div>
30
                     <div class="desc">检查安装环境</div>
21
                 </div>
31
                 </div>
22
                 <div class="step active line"></div>
32
                 <div class="step active line"></div>
23
                 <div class="step active">
33
                 <div class="step active">
24
-                    <div class="sort">2</div>
34
+                    <div class="sort">
35
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
36
+                    </div>
25
                     <div class="desc">创建数据库</div>
37
                     <div class="desc">创建数据库</div>
26
                 </div>
38
                 </div>
27
                 <div class="step line"></div>
39
                 <div class="step line"></div>
28
                 <div class="step">
40
                 <div class="step">
29
-                    <div class="sort">3</div>
41
+                    <div class="sort">
42
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
43
+                    </div>
30
                     <div class="desc">安装成功</div>
44
                     <div class="desc">安装成功</div>
31
                 </div>
45
                 </div>
32
             </div>
46
             </div>
33
         </div>
47
         </div>
34
-
35
-        <div class="container">
48
+        <div class="container">         
36
             <div class="content">
49
             <div class="content">
37
                 <div class="base-top">
50
                 <div class="base-top">
38
-                    <span class="title">2 创建数据库</span>
51
+                    <span class="title">创建数据库</span>
39
                     <span class="version">当前版本:{$envir_data['version']['VERSION']} {$envir_data['version']['RELEASE']}</span>
52
                     <span class="version">当前版本:{$envir_data['version']['VERSION']} {$envir_data['version']['RELEASE']}</span>
40
                 </div>
53
                 </div>
41
                 <div class="form">
54
                 <div class="form">
42
                     <div class="form-sec-title">请填写数据库信息</div>
55
                     <div class="form-sec-title">请填写数据库信息</div>
43
-                        <div class="form-item">
44
-                            <div class="form-label">数据库主机:</div>
45
-                            <input type="text" name="databaseUrl">
46
-                            <!--<div class="error" style="display: none">数据库主机不能空</div>-->
47
-                            <div class="remind">数据库地址一般为127.0.0.1</div>
48
-                        </div>
49
-                        <div class="form-item">
50
-                            <div class="form-label">数据库名:</div>
51
-                            <input type="text" name="databaseName">
52
-                        </div>
53
-                        <div class="form-item">
54
-                            <div class="form-label">端口:</div>
55
-                            <input type="text" name="databasePort">
56
-                            <div class="remind">一般为 3306</div>
57
-                        </div>
58
-                        <div class="form-item">
59
-                            <div class="form-label">数据库用户名:</div>
60
-                            <input type="text" name="databaseUser">
61
-                            <div class="remind">生产环境建议创建独立账号</div>
62
-                        </div>
63
-                        <div class="form-item">
64
-                            <div class="form-label">数据库密码:</div>
65
-                            <input type="password" name="databasePwd">
66
-                        </div>
67
-                        <div class="form-item">
56
+                    <div class="form-item">
57
+                        <div class="form-label">数据库主机:</div>
58
+                        <input type="text" class="wkform" name="databaseUrl" placeholder="127.0.0.1">
59
+                        <!--<div class="error" style="display: none">数据库主机不能空</div>-->
60
+                        <!-- <div class="remind">数据库地址一般为127.0.0.1</div> -->
61
+                    </div>
62
+                    <div class="form-item">
63
+                        <div class="form-label">数据库名:</div>
64
+                        <input type="text" class="wkform" name="databaseName">
65
+                    </div>
66
+                    <div class="form-item">
67
+                        <div class="form-label">端口:</div>
68
+                        <input type="text" class="wkform" name="databasePort" placeholder="一般为3306">
69
+                        <!-- <div class="remind">一般为 3306</div> -->
70
+                    </div>
71
+                    <div class="form-item">
72
+                        <div class="form-label">数据库用户名:</div>
73
+                        <input type="text" class="wkform" name="databaseUser" placeholder="生产环境建议创建独立账号">
74
+                        <!-- <div class="remind">生产环境建议创建独立账号</div> -->
75
+                    </div>
76
+                    <div class="form-item">
77
+                        <div class="form-label">数据库密码:</div>
78
+                        <input type="password" class="wkform" name="databasePwd">
79
+                    </div>
80
+                    <div class="form-item">
68
                         <div class="form-label">表前缀:</div>
81
                         <div class="form-label">表前缀:</div>
69
-                            <input type="text" name="databaseTable">
70
-                            <div class="remind">默认为5kcrm_</div>
71
-                        </div>
72
-                        <div class="form-sec-title">请填写管理员信息</div>
73
-                        <div class="form-item">
74
-                            <div class="form-label">管理员账号:</div>
75
-                            <input type="text" name="root" placeholder="请输入手机号码">
82
+                        <input type="text" class="wkform" name="databaseTable" placeholder="默认我5kcrm-">
83
+                        <!-- <div class="remind">默认为5kcrm_</div> -->
84
+                    </div>
85
+                    <div class="form-item">
86
+                        <div class="form-label">安装序列号:</div>
87
+                        <textarea name="wkcode" class="wkform" rows="6" placeholder="请输入您的序列号"></textarea>
88
+                        <div class="remind">
89
+                            <span class="title">您需要通过手机号来<a class="base-a" target="_blank" href="https://www.72crm.com/login">注册悟空ID</a>,该手机号将作为您登录系统的管理员账号。您需要进入【悟空个人中心】,点击【开源版下载】<a class="base-a" target="_blank" href="https://www.72crm.com/login">获取您的序列号</a>,如您已经注册悟空ID,您只需要点击<a class="base-a" target="_blank" href="https://www.72crm.com/login">登录个人中心</a>即可查看您的序列号</span>
76
                         </div>
90
                         </div>
77
-                        <div class="form-item">
91
+                    </div>
92
+
93
+                    <div class="form-sec-title">请填写管理员信息</div>
94
+                    <p style="color:#d5d5d5;font-size: 12px;">
95
+                        请填写以下管理员信息,是指完成且系统安装成功后,您可以使用管理员信息登录系统.
96
+                    </p>
97
+                    <div class="form-item">
98
+                        <div class="form-label">管理员账号:</div>
99
+                        <input type="text" class="wkform" name="root" placeholder="请输入您的手机号码">
100
+                    </div>                     
101
+                    <div class="form-item">
78
                         <div class="form-label">管理员密码:</div>
102
                         <div class="form-label">管理员密码:</div>
79
-                        <input type="password" name="pwd">
103
+                        <input type="password" class="wkform" name="pwd" placeholder="6~20位字母加数字组合">
80
                     </div>
104
                     </div>
105
+                    
81
                 </div>
106
                 </div>
107
+                <div class="base-des">
108
+                </div>                
82
                 <div class="install_progress_a">
109
                 <div class="install_progress_a">
83
                 <!-- <progress class="install_progress" max="97" value="8"></progress> -->
110
                 <!-- <progress class="install_progress" max="97" value="8"></progress> -->
84
                 </div>
111
                 </div>
85
                 <div class="control">
112
                 <div class="control">
86
                     <div class="prev btn">上一步</div>
113
                     <div class="prev btn">上一步</div>
87
-                    <div class="next btn primary">下一步</div>
114
+                    <div class="next btn primary">安装</div>
88
                 </div>
115
                 </div>
89
             </div>
116
             </div>
90
-        </div>
117
+        </div>     
91
         <div class="footer-wrapper">
118
         <div class="footer-wrapper">
92
             {include file="public/footer"}
119
             {include file="public/footer"}
93
         </div>
120
         </div>

+ 9
- 3
application/admin/view/install/step3.html Zobrazit soubor

16
         <div class="top">
16
         <div class="top">
17
             <div class="step-group">
17
             <div class="step-group">
18
                 <div class="step active">
18
                 <div class="step active">
19
-                    <div class="sort">1</div>
19
+                    <div class="sort">
20
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
21
+                    </div>
20
                     <div class="desc">检查安装环境</div>
22
                     <div class="desc">检查安装环境</div>
21
                 </div>
23
                 </div>
22
                 <div class="step active line"></div>
24
                 <div class="step active line"></div>
23
                 <div class="step active">
25
                 <div class="step active">
24
-                    <div class="sort">2</div>
26
+                    <div class="sort">
27
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
28
+                    </div>
25
                     <div class="desc">创建数据库</div>
29
                     <div class="desc">创建数据库</div>
26
                 </div>
30
                 </div>
27
                 <div class="step line active"></div>
31
                 <div class="step line active"></div>
28
                 <div class="step">
32
                 <div class="step">
29
-                    <div class="sort">3</div>
33
+                    <div class="sort">
34
+                        <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
35
+                    </div>
30
                     <div class="desc">安装成功</div>
36
                     <div class="desc">安装成功</div>
31
                 </div>
37
                 </div>
32
             </div>
38
             </div>

+ 64
- 0
application/admin/view/install/step5.html Zobrazit soubor

1
+<!DOCTYPE html>
2
+<html lang="zh-CN">
3
+<head>
4
+    <meta charset="UTF-8">
5
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
6
+    <title>悟空CRM安装向导</title>
7
+    <link rel="shortcut icon" href="__STATIC__/icon/favicon.ico">
8
+    <link rel="stylesheet" href="__STATIC__/style/base.css">
9
+    <link rel="stylesheet" href="__STATIC__/style/step3.css">
10
+    <script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
11
+</head>
12
+<body>
13
+<div class="header-wrapper">
14
+    {include file="public/header"}
15
+</div>
16
+<div class="top">
17
+    <div class="step-group">
18
+        <div class="step active">
19
+            <div class="sort">
20
+                <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
21
+            </div>
22
+            <div class="desc">检查安装环境</div>
23
+        </div>
24
+        <div class="step active line"></div>
25
+        <div class="step active">
26
+            <div class="sort">
27
+                <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
28
+            </div>
29
+            <div class="desc">创建数据库</div>
30
+        </div>
31
+        <div class="step line active"></div>
32
+        <div class="step">
33
+            <div class="sort">
34
+                <img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
35
+            </div>
36
+            <div class="desc">安装成功</div>
37
+        </div>
38
+    </div>
39
+</div>
40
+<div class="container">
41
+    <div class="result">
42
+        <div class="status-box" style="display:flex; align-items:center;justify-content:center">
43
+            <img class="pic" style="width: 50px; height: 50px;" src="__STATIC__/icon/success.png" alt="">       
44
+        </div>
45
+         <h1 style="text-align:center">恭喜您,已成功安装悟空CRM</h1>
46
+        <div class="desc" style="color:#acacac; font-weight: 600; margin-top: 50px; line-height:30px">
47
+            <p>您已经成功安装开源PHP悟空CRM,您可以尽情享用悟空CRM开源版算有功能及服务.</p>
48
+            <p>使用管理员账号即可登录</p>
49
+        </div>
50
+        <div class="control">
51
+            <div class="btn primary login">立即登录</div>
52
+        </div>
53
+    </div>
54
+</div>
55
+<div class="footer-wrapper">
56
+    {include file="public/footer"}
57
+</div>
58
+</body>
59
+<script>
60
+    $('.login').click(function () {
61
+        window.location = '../../../index.html'
62
+    })
63
+</script>
64
+</html>

+ 1
- 1
application/admin/view/public/footer.html Zobrazit soubor

1
 <footer class="footer">
1
 <footer class="footer">
2
   <div class="content">
2
   <div class="content">
3
     悟空CRM受国家计算机软件著作权保护,未经授权不得进行商业行为,违者必究。<br>
3
     悟空CRM受国家计算机软件著作权保护,未经授权不得进行商业行为,违者必究。<br>
4
-    &copy;2021 悟空软件<a target="_blank" href="http://www.5kcrm.com">www.5kcrm.com</a>
4
+    &copy;2021 悟空软件 <a target="_blank" style="color: #fff;" href="http://www.5kcrm.com">www.5kcrm.com</a>
5
   </div>
5
   </div>
6
 </footer>
6
 </footer>

+ 2
- 1
application/bi/controller/Examine.php Zobrazit soubor

122
         unset($where['create_time']);
122
         unset($where['create_time']);
123
         unset($where['create_user_id']);
123
         unset($where['create_user_id']);
124
         unset($where['create_user_id']);
124
         unset($where['create_user_id']);
125
-        $where['check_status'] = 'all';
125
+//        $where['check_status'] = 'all';
126
         $where['page'] = $param['page'];
126
         $where['page'] = $param['page'];
127
         $where['limit'] = $param['limit'];
127
         $where['limit'] = $param['limit'];
128
         $where['user_id'] = $user_id;
128
         $where['user_id'] = $user_id;
129
+        $where['bi_types'] = 'bi';
129
         $where['between_time'] = array($start_time,$end_time);
130
         $where['between_time'] = array($start_time,$end_time);
130
         $list = $examineModel->getDataList($where);
131
         $list = $examineModel->getDataList($where);
131
 
132
 

+ 30
- 7
application/common.php Zobrazit soubor

165
                 if (!empty($v['start'])) $v['start'] = date('Y-m-d', $v['start']);
165
                 if (!empty($v['start'])) $v['start'] = date('Y-m-d', $v['start']);
166
                 if (!empty($v['end']))   $v['end']   = date('Y-m-d', $v['end']);
166
                 if (!empty($v['end']))   $v['end']   = date('Y-m-d', $v['end']);
167
             }
167
             }
168
-            if ($v['form_type'] == 'user') {
168
+            # 创建人、负责人、回访人(非自定义字段)
169
+            if ($v['form_type'] == 'user' && in_array($k, ['create_user_id', 'owner_user_id'])) {
169
                 if ($v['condition'] == 'is') $v['condition'] = 'contains';
170
                 if ($v['condition'] == 'is') $v['condition'] = 'contains';
170
             }
171
             }
171
-            if ($types == 'contract') {
172
+            # 自定义字段的user、structure类型
173
+            if (($v['form_type'] == 'user' && !in_array($k, ['create_user_id', 'owner_user_id'])) || $v['form_type'] == 'structure') {
174
+                if ($v['condition'] == 'is') $v['condition'] = 'contains';
175
+                if ($v['condition'] == 'isNot') {
176
+                    return "(".$c.$k." not like '%".$v['value'][0]."%' OR ".$c.$k." is null)";
177
+                }
178
+            }
179
+            # 处理多选字段的精确搜索
180
+            if ($v['form_type'] == 'checkbox' && !empty($v['value'])) {
181
+                if ($v['condition'] == 'is' && count($v['value']) == 1) $v['value'][0] = ',' . $v['value'][0] . ',';
182
+                if ($v['condition'] == 'is' && count($v['value']) > 1) {
183
+                    $checkboxLike = '';
184
+                    foreach ($v['value'] AS $kk => $vv) {
185
+                        $checkboxLike .= $c.$k." like "."'%".$vv."%' AND ";
186
+                    }
187
+                    return "(".$checkboxLike."LENGTH(".$c.$k.") = LENGTH('".arrayToString($v['value'])."'))";
188
+                }
189
+            }
190
+            if ($types == 'contract' && !empty($v['value'])) {
172
                 switch ($k) {
191
                 switch ($k) {
173
                     case 'business_id' :
192
                     case 'business_id' :
174
                         $k = 'name';
193
                         $k = 'name';
186
                         break;
205
                         break;
187
                 }
206
                 }
188
             }
207
             }
189
-            if ($types == 'receivables' && $v['name'] == '合同编号') {
208
+            if ($types == 'receivables' && $v['name'] == '合同编号' && !empty($v['value'])) {
190
                 $k = 'num';
209
                 $k = 'num';
191
                 $c = 'contract.';
210
                 $c = 'contract.';
192
             }
211
             }
193
-            if ($types == 'receivables' && $k == 'plan_id') {
212
+            if ($types == 'receivables' && $k == 'plan_id' && !empty($v['value'])) {
194
                 $planIds = [];
213
                 $planIds = [];
195
                 foreach ($v['value'] AS $kk => $vv) {
214
                 foreach ($v['value'] AS $kk => $vv) {
196
                     $planIdArray = db('crm_receivables_plan')->whereLike('num', '%' . $vv . '%')->column('plan_id');
215
                     $planIdArray = db('crm_receivables_plan')->whereLike('num', '%' . $vv . '%')->column('plan_id');
200
                 }
219
                 }
201
                 $v['value'] = array_unique($planIds);
220
                 $v['value'] = array_unique($planIds);
202
             }
221
             }
203
-            if ($types == 'invoice' && $v['type'] == 'invoice_status') {
222
+            if ($types == 'invoice' && $v['type'] == 'invoice_status' && !empty($v['value'])) {
204
                 foreach ($v['value'] AS $kk => $vv) {
223
                 foreach ($v['value'] AS $kk => $vv) {
205
                     if ($vv == '已开票') $v['value'][$kk] = 1;
224
                     if ($vv == '已开票') $v['value'][$kk] = 1;
206
                     if ($vv == '未开票') $v['value'][$kk] = 0;
225
                     if ($vv == '未开票') $v['value'][$kk] = 0;
207
                 }
226
                 }
208
             }
227
             }
209
-            if ($types == 'visit' && $v['type'] == 'contract_name') {
228
+            if ($types == 'visit' && $v['type'] == 'contract_name' && !empty($v['value'])) {
210
                 $k = 'num';
229
                 $k = 'num';
211
                 $c = 'contract.';
230
                 $c = 'contract.';
212
             }
231
             }
213
-            if ($k == 'check_status' && is_array($v) && in_array($v['value'][0], $checkStatusList)) {
232
+            if ($types == 'visit' && $v['type'] == 'contacts_name' && !empty($v['value'])) {
233
+                $k = 'name';
234
+                $c = 'contacts.';
235
+            }
236
+            if ($k == 'check_status' && is_array($v) && in_array($v['value'][0], $checkStatusList) && !empty($v['value'])) {
214
                 $v['value'] = $checkStatusArray[$v['value'][0]] ?: '0';
237
                 $v['value'] = $checkStatusArray[$v['value'][0]] ?: '0';
215
             }
238
             }
216
             if (is_array($v)) {
239
             if (is_array($v)) {

+ 19
- 6
application/crm/controller/Business.php Zobrazit soubor

276
                 $errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:无权限;';
276
                 $errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:无权限;';
277
                 continue;
277
                 continue;
278
             }
278
             }
279
-            $resBusiness = db('crm_business')->where(['business_id' => $business_id])->update($data);
280
-            if (!$resBusiness) {
281
-                $errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:数据出错;';
282
-                continue;
283
-            }
284
 
279
 
285
             //团队成员
280
             //团队成员
286
             teamUserId(
281
             teamUserId(
291
                 $is_remove,
286
                 $is_remove,
292
                 0
287
                 0
293
             );
288
             );
294
-                
289
+
290
+            $resBusiness = db('crm_business')->where(['business_id' => $business_id])->update($data);
291
+            if (!$resBusiness) {
292
+                $errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:数据出错;';
293
+                continue;
294
+            } else {
295
+                $businessArray = [];
296
+                $teamBusiness = db('crm_business')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('business_id', $business_id)->find();
297
+                if (!empty($teamBusiness['ro_user_id'])) {
298
+                    $businessRo = arrayToString(array_diff(stringToArray($teamBusiness['ro_user_id']), [$teamBusiness['owner_user_id']]));
299
+                    $businessArray['ro_user_id'] = $businessRo;
300
+                }
301
+                if (!empty($teamBusiness['rw_user_id'])) {
302
+                    $businessRo = arrayToString(array_diff(stringToArray($teamBusiness['rw_user_id']), [$teamBusiness['owner_user_id']]));
303
+                    $businessArray['rw_user_id'] = $businessRo;
304
+                }
305
+                db('crm_business')->where('business_id', $business_id)->update($businessArray);
306
+            }
307
+
295
             //修改记录
308
             //修改记录
296
             updateActionLog($userInfo['id'], 'crm_business', $business_id, '', '', '将商机转移给:'.$ownerUserName);       
309
             updateActionLog($userInfo['id'], 'crm_business', $business_id, '', '', '将商机转移给:'.$ownerUserName);       
297
         }
310
         }

+ 30
- 21
application/crm/controller/Contract.php Zobrazit soubor

214
         if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
214
         if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
215
             return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
215
             return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
216
         }
216
         }
217
-
218
-        if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
219
-            //保存为草稿
220
-            $param['check_status'] = 5; //草稿(未提交)
221
-            $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
222
-        } else {
223
             if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
217
             if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
224
                 //将合同审批状态至为待审核,提交后重新进行审批
218
                 //将合同审批状态至为待审核,提交后重新进行审批
225
                 //审核判断(是否有符合条件的审批流)
219
                 //审核判断(是否有符合条件的审批流)
244
                 } else {
238
                 } else {
245
                     $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
239
                     $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
246
                 }
240
                 }
247
-                if ($param['is_draft']) {
241
+                if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
248
                     //保存为草稿
242
                     //保存为草稿
249
                     $param['check_status'] = 5;
243
                     $param['check_status'] = 5;
250
                     $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
244
                     $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
257
                 }
251
                 }
258
                 $param['flow_user_id'] = '';
252
                 $param['flow_user_id'] = '';
259
             }
253
             }
260
-        }
254
+        
261
 
255
 
262
         if ($contractModel->updateDataById($param, $param['id'])) {
256
         if ($contractModel->updateDataById($param, $param['id'])) {
263
             //将审批记录至为无效
257
             //将审批记录至为无效
314
                 $isDel = false;
308
                 $isDel = false;
315
                 $errorMessage[] = '名称为'.$data['name'].'的合同删除失败,错误原因:当前合同已作废,非超级管理员,不可删除';
309
                 $errorMessage[] = '名称为'.$data['name'].'的合同删除失败,错误原因:当前合同已作废,非超级管理员,不可删除';
316
             }
310
             }
317
-            if (!in_array($data['check_status'],['0','4','5','6']) && !in_array(1,$adminTypes)) {
311
+            if (!in_array($data['check_status'], [4, 5]) && !in_array(1,$adminTypes)) {
318
                 $isDel = false;
312
                 $isDel = false;
319
                 $errorMessage[] = '名称为'.$data['name'].'的合同删除失败,错误原因:当前状态为审批中或已审批通过,不可删除';
313
                 $errorMessage[] = '名称为'.$data['name'].'的合同删除失败,错误原因:当前状态为审批中或已审批通过,不可删除';
320
             }
314
             }
335
                 return resultArray(['error' => $contractModel->getError()]);
329
                 return resultArray(['error' => $contractModel->getError()]);
336
             }
330
             }
337
             //删除跟进记录
331
             //删除跟进记录
338
-            $recordModel->delDataByTypes('crm_contract',$delIds);
332
+            $recordModel->delDataByTypes(6,$delIds);
339
             //删除关联附件
333
             //删除关联附件
340
-            $fileModel->delRFileByModule(6,$delIds);
334
+            $fileModel->delRFileByModule('crm_contract',$delIds);
341
             //删除关联操作记录
335
             //删除关联操作记录
342
             $actionRecordModel->delDataById(['types'=>'crm_contract','action_id'=>$delIds]);
336
             $actionRecordModel->delDataById(['types'=>'crm_contract','action_id'=>$delIds]);
343
             // 删除回款记录
337
             // 删除回款记录
395
                 $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:无权限;';
389
                 $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:无权限;';
396
                 continue;
390
                 continue;
397
             }
391
             }
398
-            if (in_array($contractInfo['check_status'],['0','1'])) {
399
-                $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:待审或审批中,无法转移;';
400
-                continue;
401
-            }            
402
-            $resContract = db('crm_contract')->where(['contract_id' => $contract_id])->update($data);
403
-            if (!$resContract) {
404
-                $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:数据出错;';
405
-                continue;
406
-            }
392
+//            if (in_array($contractInfo['check_status'],['0','1'])) {
393
+//                $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:待审或审批中,无法转移;';
394
+//                continue;
395
+//            }
407
 
396
 
408
             //团队成员
397
             //团队成员
409
             teamUserId(
398
             teamUserId(
411
                 $contract_id,
400
                 $contract_id,
412
                 $type,
401
                 $type,
413
                 [$contractInfo['owner_user_id']],
402
                 [$contractInfo['owner_user_id']],
414
-                $is_remove,
403
+                ($is_remove == 1) ? 1 : '',
415
                 0
404
                 0
416
             );
405
             );
406
+
407
+            $resContract = db('crm_contract')->where(['contract_id' => $contract_id])->update($data);
408
+            if (!$resContract) {
409
+                $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:数据出错;';
410
+                continue;
411
+            } else {
412
+                # 处理负责人重复显示在团队成员中的bug
413
+                $contractArray = [];
414
+                $teamContract = db('crm_contract')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('contract_id', $contract_id)->find();
415
+                if (!empty($teamContract['ro_user_id'])) {
416
+                    $contractRo = arrayToString(array_diff(stringToArray($teamContract['ro_user_id']), [$teamContract['owner_user_id']]));
417
+                    $contractArray['ro_user_id'] = $contractRo;
418
+                }
419
+                if (!empty($teamContract['rw_user_id'])) {
420
+                    $contractRo = arrayToString(array_diff(stringToArray($teamContract['rw_user_id']), [$teamContract['owner_user_id']]));
421
+                    $contractArray['rw_user_id'] = $contractRo;
422
+                }
423
+                db('crm_contract')->where('contract_id', $contract_id)->update($contractArray);
424
+            }
425
+
417
             //修改记录
426
             //修改记录
418
             updateActionLog($userInfo['id'], 'crm_contract', $contract_id, '', '', '将合同转移给:'.$ownerUserName);        
427
             updateActionLog($userInfo['id'], 'crm_contract', $contract_id, '', '', '将合同转移给:'.$ownerUserName);        
419
         }
428
         }

+ 16
- 3
application/crm/controller/Customer.php Zobrazit soubor

316
             if (!$resCustomer) {
316
             if (!$resCustomer) {
317
                 $errorMessage[] = $customerInfo['name'].'转移失败,错误原因:数据出错;';
317
                 $errorMessage[] = $customerInfo['name'].'转移失败,错误原因:数据出错;';
318
                 continue;
318
                 continue;
319
-            } 
319
+            } else {
320
+                # 处理转移时,负责人出现在只读和读写成员列表中
321
+                $customerArray = [];
322
+                $teamCustomer = db('crm_customer')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('customer_id', $customer_id)->find();
323
+                if (!empty($teamCustomer['ro_user_id'])) {
324
+                    $customerRo = arrayToString(array_diff(stringToArray($teamCustomer['ro_user_id']), [$teamCustomer['owner_user_id']]));
325
+                    $customerArray['ro_user_id'] = $customerRo;
326
+                }
327
+                if (!empty($teamCustomer['rw_user_id'])) {
328
+                    $customerRo = arrayToString(array_diff(stringToArray($teamCustomer['rw_user_id']), [$teamCustomer['owner_user_id']]));
329
+                    $customerArray['rw_user_id'] = $customerRo;
330
+                }
331
+                db('crm_customer')->where('customer_id', $customer_id)->update($customerArray);
332
+            }
320
             
333
             
321
             if (in_array('crm_contacts',$types)) {
334
             if (in_array('crm_contacts',$types)) {
322
                 $contactsIds = [];
335
                 $contactsIds = [];
339
                     if ($resBusiness !== true) {
352
                     if ($resBusiness !== true) {
340
                         $errorMessage = $errorMessage ? array_merge($errorMessage,$resBusiness) : $resBusiness;
353
                         $errorMessage = $errorMessage ? array_merge($errorMessage,$resBusiness) : $resBusiness;
341
                         continue;                        
354
                         continue;                        
342
-                    }                    
355
+                    }
343
                 }
356
                 }
344
             }
357
             }
345
 
358
 
677
         $file = request()->file('file');
690
         $file = request()->file('file');
678
         // $res = $excelModel->importExcel($file, $param, $this);
691
         // $res = $excelModel->importExcel($file, $param, $this);
679
         $res = $excelModel->batchImportData($file, $param, $this);
692
         $res = $excelModel->batchImportData($file, $param, $this);
680
-        return resultArray(['data' => '导入成功']);
693
+        return resultArray(['data' => $excelModel->getError()]);
681
     }
694
     }
682
 
695
 
683
     /**
696
     /**

+ 5
- 2
application/crm/controller/Invoice.php Zobrazit soubor

315
      */
315
      */
316
     public function delete(InvoiceLogic $invoiceLogic)
316
     public function delete(InvoiceLogic $invoiceLogic)
317
     {
317
     {
318
+        $actionRecordModel = new \app\admin\model\ActionRecord();
319
+        $fileModel = new \app\admin\model\File();
318
         $idArray  = $this->param['id'];
320
         $idArray  = $this->param['id'];
319
         $userinfo = $this->userInfo['id'];
321
         $userinfo = $this->userInfo['id'];
320
 
322
 
326
         if (!isSuperAdministrators($userinfo['id'])) {
328
         if (!isSuperAdministrators($userinfo['id'])) {
327
             $list = $invoiceLogic->getExamineStatus($idString, true);
329
             $list = $invoiceLogic->getExamineStatus($idString, true);
328
             foreach ($list AS $key => $value) {
330
             foreach ($list AS $key => $value) {
329
-                if (!in_array($value['check_status'], ['3', '4', '5', '6'])) {
331
+                if (!in_array($value['check_status'],  [4, 5])) {
330
                     $status = false;
332
                     $status = false;
331
                     break;
333
                     break;
332
                 }
334
                 }
338
         if (!$invoiceLogic->delete($idArray)) return resultArray(['error' => '删除失败!']);
340
         if (!$invoiceLogic->delete($idArray)) return resultArray(['error' => '删除失败!']);
339
 
341
 
340
         # 删除附件
342
         # 删除附件
341
-        $fileModel = new \app\admin\model\File();
342
         $fileModel->delRFileByModule('crm_invoice', $idArray);
343
         $fileModel->delRFileByModule('crm_invoice', $idArray);
344
+        //删除关联操作记录
345
+        $actionRecordModel->delDataById(['types'=>'crm_invoice','action_id'=>$idArray]);
343
 
346
 
344
         return resultArray(['data' => '删除成功!']);
347
         return resultArray(['data' => '删除成功!']);
345
     }
348
     }

+ 5
- 1
application/crm/controller/Leads.php Zobrazit soubor

226
             $data['deal_time'] = time();
226
             $data['deal_time'] = time();
227
             $data['create_time'] = time();
227
             $data['create_time'] = time();
228
             $data['update_time'] = time();
228
             $data['update_time'] = time();
229
-            $data['next_time'] = $leadsInfo['next_time'] ? date('Y-m-d H:i:s', $leadsInfo['next_time']) : 0;
229
+            $data['next_time'] = $leadsInfo['next_time'];
230
+            if (empty($data['telephone'])) $data['telephone'] = 0;
230
             # 获取客户的时间
231
             # 获取客户的时间
231
             $data['obtain_time'] = time();
232
             $data['obtain_time'] = time();
232
             //权限判断
233
             //权限判断
404
         $file = request()->file('file');
405
         $file = request()->file('file');
405
         // $res = $excelModel->importExcel($file, $param);
406
         // $res = $excelModel->importExcel($file, $param);
406
         $res = $excelModel->batchImportData($file, $param, $this);
407
         $res = $excelModel->batchImportData($file, $param, $this);
408
+        if (!$res) {
409
+            return resultArray(['error' => $excelModel->getError()]);
410
+        }
407
         return resultArray(['data' => $excelModel->getError()]);
411
         return resultArray(['data' => $excelModel->getError()]);
408
     }
412
     }
409
 
413
 

+ 3
- 0
application/crm/controller/Product.php Zobrazit soubor

10
 use app\admin\controller\ApiCommon;
10
 use app\admin\controller\ApiCommon;
11
 use app\crm\model\Product as ProductModel;
11
 use app\crm\model\Product as ProductModel;
12
 use app\admin\model\File as FileModel;
12
 use app\admin\model\File as FileModel;
13
+use app\admin\model\ActionRecord as ActionRecordModel;
13
 use think\Db;
14
 use think\Db;
14
 use think\Hook;
15
 use think\Hook;
15
 use think\Request;
16
 use think\Request;
294
                 ProductModel::commit();
295
                 ProductModel::commit();
295
                 // 删除关联附件
296
                 // 删除关联附件
296
                 (new FileModel)->delRFileByModule('crm_product', $delIds);
297
                 (new FileModel)->delRFileByModule('crm_product', $delIds);
298
+                // 操作记录
299
+                (new ActionRecordModel)->delDataById('crm_product', $delIds);
297
                 // 添加删除记录
300
                 // 添加删除记录
298
                 actionLog($delIds, '', '', '');
301
                 actionLog($delIds, '', '', '');
299
                 return resultArray(['data' => '删除成功']);
302
                 return resultArray(['data' => '删除成功']);

+ 201
- 154
application/crm/controller/Receivables.php Zobrazit soubor

19
 class Receivables extends ApiCommon
19
 class Receivables extends ApiCommon
20
 {
20
 {
21
     use AutoNumberTrait;
21
     use AutoNumberTrait;
22
-
22
+    
23
     /**
23
     /**
24
      * 用于判断权限
24
      * 用于判断权限
25
      * @permission 无限制
25
      * @permission 无限制
26
      * @allow 登录用户可访问
26
      * @allow 登录用户可访问
27
      * @other 其他根据系统设置
27
      * @other 其他根据系统设置
28
-    **/    
28
+     **/
29
     public function _initialize()
29
     public function _initialize()
30
     {
30
     {
31
         $action = [
31
         $action = [
32
-            'permission'=>[''],
33
-            'allow'=>['check','revokecheck','system','count']
32
+            'permission' => [''],
33
+            'allow' => ['check', 'revokecheck', 'system', 'count']
34
         ];
34
         ];
35
-        Hook::listen('check_auth',$action);
35
+        Hook::listen('check_auth', $action);
36
         $request = Request::instance();
36
         $request = Request::instance();
37
-        $a = strtolower($request->action());        
37
+        $a = strtolower($request->action());
38
         if (!in_array($a, $action['permission'])) {
38
         if (!in_array($a, $action['permission'])) {
39
             parent::_initialize();
39
             parent::_initialize();
40
         }
40
         }
41
-    } 
42
-
41
+    }
42
+    
43
     /**
43
     /**
44
      * 回款列表
44
      * 回款列表
45
+     * @return
45
      * @author Michael_xu
46
      * @author Michael_xu
46
-     * @return 
47
      */
47
      */
48
     public function index()
48
     public function index()
49
     {
49
     {
50
         $receivablesModel = model('Receivables');
50
         $receivablesModel = model('Receivables');
51
         $param = $this->param;
51
         $param = $this->param;
52
         $userInfo = $this->userInfo;
52
         $userInfo = $this->userInfo;
53
-        $param['user_id'] = $userInfo['id'];        
54
-        $data = $receivablesModel->getDataList($param);       
53
+        $param['user_id'] = $userInfo['id'];
54
+        $data = $receivablesModel->getDataList($param);
55
         return resultArray(['data' => $data]);
55
         return resultArray(['data' => $data]);
56
     }
56
     }
57
-
57
+    
58
+    /**
59
+     * 导出
60
+     * @param
61
+     * @return
62
+     * @author guogaobo
63
+     */
64
+    public function excelExport()
65
+    {
66
+        $param = $this->param;
67
+        $userInfo = $this->userInfo;
68
+        $param['user_id'] = $userInfo['id'];
69
+        if ($param['receivables_id']) {
70
+            $param['receivables_id'] = ['condition' => 'in', 'value' => $param['receivables_id'], 'form_type' => 'text', 'name' => ''];
71
+            $param['is_excel'] = 1;
72
+        }
73
+        $excelModel = new \app\admin\model\Excel();
74
+        // 导出的字段列表
75
+        $fieldModel = new \app\admin\model\Field();
76
+        $field_list = $fieldModel->getIndexFieldConfig('crm_receivables', $userInfo['id']);
77
+        // 文件名
78
+        $file_name = '5kcrm_receivables_' . date('Ymd');
79
+        
80
+        $model = model('Receivables');
81
+        $temp_file = $param['temp_file'];
82
+        unset($param['temp_file']);
83
+        $page = $param['page'] ?: 1;
84
+        unset($param['page']);
85
+        unset($param['export_queue_index']);
86
+        return $excelModel->batchExportCsv($file_name, $temp_file, $field_list, $page, function ($page, $limit) use ($model, $param, $field_list) {
87
+            $param['page'] = $page;
88
+            $param['limit'] = $limit;
89
+            $data = $model->getDataList($param);
90
+            $data['list'] = $model->exportHandle($data['list'], $field_list, 'Receivables');
91
+            return $data;
92
+        });
93
+    }
94
+    
58
     /**
95
     /**
59
      * 添加回款
96
      * 添加回款
60
      *
97
      *
69
         $param['owner_user_id'] = $userInfo['id'];
106
         $param['owner_user_id'] = $userInfo['id'];
70
         $examineStatus = $param['examineStatus']; // 审批是否停用
107
         $examineStatus = $param['examineStatus']; // 审批是否停用
71
         unset($param['examineStatus']);
108
         unset($param['examineStatus']);
72
-
109
+        
73
         # 自动设置回款编号
110
         # 自动设置回款编号
74
         $numberInfo = [];
111
         $numberInfo = [];
75
         if (empty($param['number'])) {
112
         if (empty($param['number'])) {
80
         if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
117
         if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
81
             //保存为草稿
118
             //保存为草稿
82
             $param['check_status'] = 5; //草稿(未提交)
119
             $param['check_status'] = 5; //草稿(未提交)
83
-            $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
84
-        } else {
85
-            if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
86
-                //审核判断(是否有符合条件的审批流)
87
-                $examineFlowModel = new \app\admin\model\ExamineFlow();
88
-                if (!$examineFlowModel->checkExamine($param['owner_user_id'], 'crm_receivables')) {
89
-                    return resultArray(['error' => '暂无审批人,无法创建']);
90
-                }
91
-                //添加审批相关信息
92
-                $examineFlowData = $examineFlowModel->getFlowByTypes($param['owner_user_id'], 'crm_receivables');
93
-                if (!$examineFlowData) {
94
-                    return resultArray(['error' => '无可用审批流,请联系管理员']);
95
-                }
96
-                $param['flow_id'] = $examineFlowData['flow_id'];
97
-                //获取审批人信息
98
-                if ($examineFlowData['config'] == 1) {
99
-                    //固定审批流
100
-                    $nextStepData = $examineStepModel->nextStepUser($userInfo['id'], $examineFlowData['flow_id'], 'crm_receivables', 0, 0, 0);
101
-                    $next_user_ids = arrayToString($nextStepData['next_user_ids']) ? : '';
102
-                    $check_user_id = $next_user_ids ? : [];
103
-                    $param['order_id'] = 1;
104
-                } else {
105
-                    $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
106
-                }
107
-                if (!$check_user_id) {
108
-                    return resultArray(['error' => '无可用审批人,请联系管理员']);
109
-                }
110
-                $param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
120
+            $param['check_user_id'] = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
121
+        }
122
+        if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
123
+            //审核判断(是否有符合条件的审批流)
124
+            $examineFlowModel = new \app\admin\model\ExamineFlow();
125
+            if (!$examineFlowModel->checkExamine($param['owner_user_id'], 'crm_receivables')) {
126
+                return resultArray(['error' => '暂无审批人,无法创建']);
127
+            }
128
+            //添加审批相关信息
129
+            $examineFlowData = $examineFlowModel->getFlowByTypes($param['owner_user_id'], 'crm_receivables');
130
+            if (!$examineFlowData) {
131
+                return resultArray(['error' => '无可用审批流,请联系管理员']);
132
+            }
133
+            $param['flow_id'] = $examineFlowData['flow_id'];
134
+            //获取审批人信息
135
+            if ($examineFlowData['config'] == 1) {
136
+                //固定审批流
137
+                $nextStepData = $examineStepModel->nextStepUser($userInfo['id'], $examineFlowData['flow_id'], 'crm_receivables', 0, 0, 0);
138
+                $next_user_ids = arrayToString($nextStepData['next_user_ids']) ?: '';
139
+                $check_user_id = $next_user_ids ?: [];
140
+                $param['order_id'] = 1;
111
             } else {
141
             } else {
112
-                # 审批流停用,将状态改为审核通过
113
-                $param['check_status'] = 2;
142
+                $check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
114
             }
143
             }
144
+            if (!$check_user_id) {
145
+                return resultArray(['error' => '无可用审批人,请联系管理员']);
146
+            }
147
+            $param['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
148
+        } else {
149
+            # 审批流停用,将状态改为审核通过
150
+            $param['check_status'] = 2;
115
         }
151
         }
152
+        
116
         $res = $receivablesModel->createData($param);
153
         $res = $receivablesModel->createData($param);
117
         if ($res) {
154
         if ($res) {
118
             //回款计划关联
155
             //回款计划关联
121
             }
158
             }
122
             # 更新crm_number_sequence表中的last_date、create_time字段
159
             # 更新crm_number_sequence表中的last_date、create_time字段
123
             if (!empty($numberInfo['data'])) (new NumberSequence())->batchUpdate($numberInfo['data']);
160
             if (!empty($numberInfo['data'])) (new NumberSequence())->batchUpdate($numberInfo['data']);
124
-
161
+            
125
             return resultArray(['data' => '添加成功']);
162
             return resultArray(['data' => '添加成功']);
126
         } else {
163
         } else {
127
             return resultArray(['error' => $receivablesModel->getError()]);
164
             return resultArray(['error' => $receivablesModel->getError()]);
128
         }
165
         }
129
     }
166
     }
130
-
167
+    
131
     /**
168
     /**
132
      * 回款详情
169
      * 回款详情
170
+     * @param
171
+     * @return
133
      * @author Michael_xu
172
      * @author Michael_xu
134
-     * @param  
135
-     * @return 
136
      */
173
      */
137
     public function read()
174
     public function read()
138
     {
175
     {
140
         $userModel = new \app\admin\model\User();
177
         $userModel = new \app\admin\model\User();
141
         $param = $this->param;
178
         $param = $this->param;
142
         $data = $receivablesModel->getDataById($param['id']);
179
         $data = $receivablesModel->getDataById($param['id']);
143
-
180
+        
144
         //判断权限
181
         //判断权限
145
         $auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'read');
182
         $auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'read');
146
-        if (!in_array($data['owner_user_id'],$auth_user_ids)) {
183
+        if (!in_array($data['owner_user_id'], $auth_user_ids)) {
147
             $authData['dataAuth'] = 0;
184
             $authData['dataAuth'] = 0;
148
             return resultArray(['data' => $authData]);
185
             return resultArray(['data' => $authData]);
149
-        }         
186
+        }
150
         if (!$data) {
187
         if (!$data) {
151
             return resultArray(['error' => $receivablesModel->getError()]);
188
             return resultArray(['error' => $receivablesModel->getError()]);
152
         }
189
         }
153
         return resultArray(['data' => $data]);
190
         return resultArray(['data' => $data]);
154
     }
191
     }
155
-
192
+    
156
     /**
193
     /**
157
      * 编辑回款
194
      * 编辑回款
195
+     * @param
196
+     * @return
158
      * @author Michael_xu
197
      * @author Michael_xu
159
-     * @param 
160
-     * @return 
161
      */
198
      */
162
     public function update()
199
     public function update()
163
-    {    
200
+    {
164
         $receivablesModel = model('Receivables');
201
         $receivablesModel = model('Receivables');
165
         $userModel = new \app\admin\model\User();
202
         $userModel = new \app\admin\model\User();
166
         $param = $this->param;
203
         $param = $this->param;
171
         //判断权限
208
         //判断权限
172
         $dataInfo = $receivablesModel->getDataById($param['id']);
209
         $dataInfo = $receivablesModel->getDataById($param['id']);
173
         $auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'update');
210
         $auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'update');
174
-        if (!in_array($dataInfo['owner_user_id'],$auth_user_ids)) {
211
+        if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
175
             header('Content-Type:application/json; charset=utf-8');
212
             header('Content-Type:application/json; charset=utf-8');
176
-            exit(json_encode(['code'=>102,'error'=>'无权操作']));
213
+            exit(json_encode(['code' => 102, 'error' => '无权操作']));
177
         }
214
         }
178
-
215
+        
179
         # 自动设置回款编号
216
         # 自动设置回款编号
180
         $numberInfo = [];
217
         $numberInfo = [];
181
         if (empty($param['number'])) {
218
         if (empty($param['number'])) {
183
             if (empty($numberInfo['number'])) return resultArray(['error' => '请填写回款编号!']);
220
             if (empty($numberInfo['number'])) return resultArray(['error' => '请填写回款编号!']);
184
             $param['number'] = $numberInfo['number'];
221
             $param['number'] = $numberInfo['number'];
185
         }
222
         }
186
-
223
+        
187
         //已进行审批,不能编辑
224
         //已进行审批,不能编辑
188
         if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
225
         if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
189
             return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
226
             return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
190
         }
227
         }
191
-
228
+        
192
         if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
229
         if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
193
             //保存为草稿
230
             //保存为草稿
194
             $param['check_status'] = 5; //草稿(未提交)
231
             $param['check_status'] = 5; //草稿(未提交)
195
-            $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
232
+            $param['check_user_id'] = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
196
         } else {
233
         } else {
197
             if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
234
             if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
198
                 if ($param['is_draft']) {
235
                 if ($param['is_draft']) {
199
                     //保存为草稿
236
                     //保存为草稿
200
                     $param['check_status'] = 5;
237
                     $param['check_status'] = 5;
201
-                    $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
238
+                    $param['check_user_id'] = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
202
                 } else {
239
                 } else {
203
                     //将回款审批状态至为待审核,提交后重新进行审批
240
                     //将回款审批状态至为待审核,提交后重新进行审批
204
                     //审核判断(是否有符合条件的审批流)
241
                     //审核判断(是否有符合条件的审批流)
217
                     if ($examineFlowData['config'] == 1) {
254
                     if ($examineFlowData['config'] == 1) {
218
                         //固定审批流
255
                         //固定审批流
219
                         $nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $examineFlowData['flow_id'], 'crm_receivables', 0, 0, 0);
256
                         $nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $examineFlowData['flow_id'], 'crm_receivables', 0, 0, 0);
220
-                        $next_user_ids = arrayToString($nextStepData['next_user_ids']) ? : '';
221
-                        $check_user_id = $next_user_ids ? : [];
257
+                        $next_user_ids = arrayToString($nextStepData['next_user_ids']) ?: '';
258
+                        $check_user_id = $next_user_ids ?: [];
222
                         $param['order_id'] = 1;
259
                         $param['order_id'] = 1;
223
                     } else {
260
                     } else {
224
-                        $check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
261
+                        $check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
225
                     }
262
                     }
226
                     if (!$check_user_id) {
263
                     if (!$check_user_id) {
227
                         return resultArray(['error' => '无可用审批人,请联系管理员']);
264
                         return resultArray(['error' => '无可用审批人,请联系管理员']);
228
                     }
265
                     }
229
-                    $param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
266
+                    $param['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
230
                     $param['check_status'] = 0;
267
                     $param['check_status'] = 0;
231
                     $param['flow_user_id'] = '';
268
                     $param['flow_user_id'] = '';
232
                 }
269
                 }
233
             }
270
             }
234
         }
271
         }
235
-
272
+        
236
         $res = $receivablesModel->updateDataById($param, $param['id']);
273
         $res = $receivablesModel->updateDataById($param, $param['id']);
237
         if ($res) {
274
         if ($res) {
238
             //将审批记录至为无效
275
             //将审批记录至为无效
239
             $examineRecordModel = new \app\admin\model\ExamineRecord();
276
             $examineRecordModel = new \app\admin\model\ExamineRecord();
240
-            $examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);
277
+            $examineRecordModel->setEnd(['types' => 'crm_receivables', 'types_id' => $param['id']]);
241
             # 更新crm_number_sequence表中的last_date、create_time字段
278
             # 更新crm_number_sequence表中的last_date、create_time字段
242
             if (!empty($numberInfo['data'])) (new NumberSequence())->batchUpdate($numberInfo['data']);
279
             if (!empty($numberInfo['data'])) (new NumberSequence())->batchUpdate($numberInfo['data']);
243
-
280
+            
244
             return resultArray(['data' => '编辑成功']);
281
             return resultArray(['data' => '编辑成功']);
245
         } else {
282
         } else {
246
             return resultArray(['error' => $receivablesModel->getError()]);
283
             return resultArray(['error' => $receivablesModel->getError()]);
247
-        }       
284
+        }
248
     }
285
     }
249
-
286
+    
250
     /**
287
     /**
251
      * 删除回款
288
      * 删除回款
289
+     * @param
290
+     * @return
252
      * @author Michael_xu
291
      * @author Michael_xu
253
-     * @param 
254
-     * @return 
255
      */
292
      */
256
     public function delete()
293
     public function delete()
257
     {
294
     {
295
+        $actionRecordModel = new \app\admin\model\ActionRecord();
296
+        $fileModel = new \app\admin\model\File();
297
+        $recordModel = new \app\admin\model\Record();
258
         $receivablesModel = model('Receivables');
298
         $receivablesModel = model('Receivables');
259
         $param = $this->param;
299
         $param = $this->param;
260
-        $userInfo = $this->userInfo;      
300
+        $userInfo = $this->userInfo;
261
         if (!is_array($param['id'])) {
301
         if (!is_array($param['id'])) {
262
             $receivables_id = [$param['id']];
302
             $receivables_id = [$param['id']];
263
         } else {
303
         } else {
265
         }
305
         }
266
         $delIds = [];
306
         $delIds = [];
267
         $errorMessage = [];
307
         $errorMessage = [];
268
-
308
+        
269
         //数据权限判断
309
         //数据权限判断
270
         $userModel = new \app\admin\model\User();
310
         $userModel = new \app\admin\model\User();
271
         $auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'delete');
311
         $auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'delete');
272
         $adminTypes = adminGroupTypes($userInfo['id']);
312
         $adminTypes = adminGroupTypes($userInfo['id']);
273
-        foreach ($receivables_id as $k=>$v) {
313
+        foreach ($receivables_id as $k => $v) {
274
             $isDel = true;
314
             $isDel = true;
275
             //数据详情
315
             //数据详情
276
             $data = $receivablesModel->getDataById($v);
316
             $data = $receivablesModel->getDataById($v);
277
             if (!$data) {
317
             if (!$data) {
278
                 $isDel = false;
318
                 $isDel = false;
279
-                $errorMessage[] = 'id为'.$v.'的回款删除失败,错误原因:'.$receivablesModel->getError();
319
+                $errorMessage[] = 'id为' . $v . '的回款删除失败,错误原因:' . $receivablesModel->getError();
280
                 continue;
320
                 continue;
281
             }
321
             }
282
-            if (!in_array($data['owner_user_id'],$auth_user_ids)) {
322
+            if (!in_array($data['owner_user_id'], $auth_user_ids)) {
283
                 $isDel = false;
323
                 $isDel = false;
284
-                $errorMessage[] = '名称为'.$data['number'].'的回款删除失败,错误原因:无权操作';
324
+                $errorMessage[] = '名称为' . $data['number'] . '的回款删除失败,错误原因:无权操作';
285
                 continue;
325
                 continue;
286
             }
326
             }
287
-            if (!in_array($data['check_status'],['0','4','5']) && !in_array(1,$adminTypes)) {
327
+            if (!in_array($data['check_status'], [4, 5]) && !in_array(1, $adminTypes)) {
288
                 $isDel = false;
328
                 $isDel = false;
289
-                $errorMessage[] = '名称为'.$data['number'].'的回款删除失败,错误原因:请先撤销审核';
329
+                $errorMessage[] = '名称为' . $data['number'] . '的回款删除失败,错误原因:请先撤销审核';
290
                 continue;
330
                 continue;
291
             }
331
             }
292
             if ($isDel) {
332
             if ($isDel) {
293
                 if (db('crm_receivables_plan')->where('receivables_id', $v)->value('plan_id')) {
333
                 if (db('crm_receivables_plan')->where('receivables_id', $v)->value('plan_id')) {
294
                     $isDel = false;
334
                     $isDel = false;
295
-                    $errorMessage[] = '名称为'.$data['number'].'的回款删除失败,错误原因:回款已关联回款计划,不能删除!';
335
+                    $errorMessage[] = '名称为' . $data['number'] . '的回款删除失败,错误原因:回款已关联回款计划,不能删除!';
296
                     continue;
336
                     continue;
297
-                }                
337
+                }
298
             }
338
             }
299
             if ($isDel) {
339
             if ($isDel) {
300
                 $delIds[] = $v;
340
                 $delIds[] = $v;
301
-            }             
341
+            }
302
         }
342
         }
303
         if ($delIds) {
343
         if ($delIds) {
304
             $data = $receivablesModel->delDatas($delIds);
344
             $data = $receivablesModel->delDatas($delIds);
305
             if (!$data) {
345
             if (!$data) {
306
                 return resultArray(['error' => $receivablesModel->getError()]);
346
                 return resultArray(['error' => $receivablesModel->getError()]);
307
-            } 
308
-            actionLog($delIds,'','','');         
347
+            }
348
+            //删除跟进记录
349
+            $recordModel->delDataByTypes(7,$delIds);
350
+            # 删除附件
351
+            $fileModel->delRFileByModule('crm_receivables', $delIds);
352
+            //删除关联操作记录
353
+            $actionRecordModel->delDataById(['types' => 'crm_receivables', 'action_id' => $delIds]);
354
+            actionLog($delIds, '', '', '');
309
         }
355
         }
356
+        
310
         if ($errorMessage) {
357
         if ($errorMessage) {
311
             return resultArray(['error' => $errorMessage]);
358
             return resultArray(['error' => $errorMessage]);
312
         } else {
359
         } else {
313
             return resultArray(['data' => '删除成功']);
360
             return resultArray(['data' => '删除成功']);
314
-        }            
315
-    }    
316
-	
361
+        }
362
+    }
363
+    
317
     /**
364
     /**
318
      * 回款审核
365
      * 回款审核
319
-     * @author Michael_xu
320
-     * @param 
366
+     * @param
321
      * @return
367
      * @return
322
-     */  
368
+     * @author Michael_xu
369
+     */
323
     public function check()
370
     public function check()
324
     {
371
     {
325
         $param = $this->param;
372
         $param = $this->param;
329
         $examineStepModel = new \app\admin\model\ExamineStep();
376
         $examineStepModel = new \app\admin\model\ExamineStep();
330
         $examineRecordModel = new \app\admin\model\ExamineRecord();
377
         $examineRecordModel = new \app\admin\model\ExamineRecord();
331
         $examineFlowModel = new \app\admin\model\ExamineFlow();
378
         $examineFlowModel = new \app\admin\model\ExamineFlow();
332
-
379
+        
333
         $receivablesData = [];
380
         $receivablesData = [];
334
         $receivablesData['update_time'] = time();
381
         $receivablesData['update_time'] = time();
335
         $receivablesData['check_status'] = 1; //0待审核,1审核通中,2审核通过,3审核未通过
382
         $receivablesData['check_status'] = 1; //0待审核,1审核通中,2审核通过,3审核未通过
336
         //权限判断
383
         //权限判断
337
         if (!$examineStepModel->checkExamine($user_id, 'crm_receivables', $param['id'])) {
384
         if (!$examineStepModel->checkExamine($user_id, 'crm_receivables', $param['id'])) {
338
-           return resultArray(['error' => $examineStepModel->getError()]); 
385
+            return resultArray(['error' => $examineStepModel->getError()]);
339
         };
386
         };
340
         //审批主体详情
387
         //审批主体详情
341
         $dataInfo = $receivablesModel->getDataById($param['id']);
388
         $dataInfo = $receivablesModel->getDataById($param['id']);
342
         $flowInfo = $examineFlowModel->getDataById($dataInfo['flow_id']);
389
         $flowInfo = $examineFlowModel->getDataById($dataInfo['flow_id']);
343
         $is_end = 0; // 1审批结束
390
         $is_end = 0; // 1审批结束
344
-
391
+        
345
         $status = $param['status'] ? 1 : 0; //1通过,0驳回
392
         $status = $param['status'] ? 1 : 0; //1通过,0驳回
346
         $checkData = [];
393
         $checkData = [];
347
         $checkData['check_user_id'] = $user_id;
394
         $checkData['check_user_id'] = $user_id;
350
         $checkData['check_time'] = time();
397
         $checkData['check_time'] = time();
351
         $checkData['content'] = $param['content'];
398
         $checkData['content'] = $param['content'];
352
         $checkData['flow_id'] = $dataInfo['flow_id'];
399
         $checkData['flow_id'] = $dataInfo['flow_id'];
353
-        $checkData['order_id'] = $dataInfo['order_id'] ? : 1;
400
+        $checkData['order_id'] = $dataInfo['order_id'] ?: 1;
354
         $checkData['status'] = $status;
401
         $checkData['status'] = $status;
355
         
402
         
356
         if ($status == 1) {
403
         if ($status == 1) {
358
                 //固定流程
405
                 //固定流程
359
                 //获取下一审批信息
406
                 //获取下一审批信息
360
                 $nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $dataInfo['flow_id'], 'crm_receivables', $param['id'], $dataInfo['order_id'], $user_id);
407
                 $nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $dataInfo['flow_id'], 'crm_receivables', $param['id'], $dataInfo['order_id'], $user_id);
361
-                $next_user_ids = $nextStepData['next_user_ids'] ? : [];
362
-                $receivablesData['order_id'] = $nextStepData['order_id'] ? : '';
408
+                $next_user_ids = $nextStepData['next_user_ids'] ?: [];
409
+                $receivablesData['order_id'] = $nextStepData['order_id'] ?: '';
363
                 if (!$next_user_ids) {
410
                 if (!$next_user_ids) {
364
                     $is_end = 1;
411
                     $is_end = 1;
365
                     //审批结束
412
                     //审批结束
368
                 } else {
415
                 } else {
369
                     //修改主体相关审批信息
416
                     //修改主体相关审批信息
370
                     $receivablesData['check_user_id'] = arrayToString($next_user_ids);
417
                     $receivablesData['check_user_id'] = arrayToString($next_user_ids);
371
-                }                 
418
+                }
372
             } else {
419
             } else {
373
                 //自选流程
420
                 //自选流程
374
                 $is_end = $param['is_end'] ? 1 : '';
421
                 $is_end = $param['is_end'] ? 1 : '';
375
-                $check_user_id = $param['check_user_id'] ? : '';
422
+                $check_user_id = $param['check_user_id'] ?: '';
376
                 if ($is_end !== 1 && empty($check_user_id)) {
423
                 if ($is_end !== 1 && empty($check_user_id)) {
377
-                    return resultArray(['error' => '请选择下一审批人']); 
424
+                    return resultArray(['error' => '请选择下一审批人']);
378
                 }
425
                 }
379
                 $receivablesData['check_user_id'] = arrayToString($param['check_user_id']);
426
                 $receivablesData['check_user_id'] = arrayToString($param['check_user_id']);
380
-            } 
427
+            }
381
             if ($is_end == 1) {
428
             if ($is_end == 1) {
382
                 $checkData['check_status'] = !empty($status) ? 2 : 3;
429
                 $checkData['check_status'] = !empty($status) ? 2 : 3;
383
                 $receivablesData['check_user_id'] = '';
430
                 $receivablesData['check_user_id'] = '';
384
                 $receivablesData['check_status'] = 2;
431
                 $receivablesData['check_status'] = 2;
385
-            }                     
432
+            }
386
         } else {
433
         } else {
387
             //审批驳回
434
             //审批驳回
388
             $is_end = 1;
435
             $is_end = 1;
391
             // $examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);                       
438
             // $examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);                       
392
         }
439
         }
393
         //已审批人ID
440
         //已审批人ID
394
-        $receivablesData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']),[$user_id])) : arrayToString([$user_id]);        
441
+        $receivablesData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']), [$user_id])) : arrayToString([$user_id]);
395
         $resReceivables = db('crm_receivables')->where(['receivables_id' => $param['id']])->update($receivablesData);
442
         $resReceivables = db('crm_receivables')->where(['receivables_id' => $param['id']])->update($receivablesData);
396
         if ($resReceivables) {
443
         if ($resReceivables) {
397
             if ($status) {
444
             if ($status) {
416
                     $dataInfo['owner_user_id']
463
                     $dataInfo['owner_user_id']
417
                 );
464
                 );
418
             }
465
             }
419
-
466
+            
420
             //审批记录
467
             //审批记录
421
             $resRecord = $examineRecordModel->createData($checkData);
468
             $resRecord = $examineRecordModel->createData($checkData);
422
             
469
             
423
             if ($is_end == 1 && !empty($status)) {
470
             if ($is_end == 1 && !empty($status)) {
424
                 //发送站内信 通过
471
                 //发送站内信 通过
425
                 (new Message())->send(
472
                 (new Message())->send(
426
-					Message::RECEIVABLES_PASS,
427
-					[
428
-						'title' => $dataInfo['number'],
429
-						'action_id' => $param['id']
430
-					],
431
-					$dataInfo['owner_user_id']
432
-				);
473
+                    Message::RECEIVABLES_PASS,
474
+                    [
475
+                        'title' => $dataInfo['number'],
476
+                        'action_id' => $param['id']
477
+                    ],
478
+                    $dataInfo['owner_user_id']
479
+                );
433
             }
480
             }
434
-            return resultArray(['data' => '审批成功']);            
481
+            return resultArray(['data' => '审批成功']);
435
         } else {
482
         } else {
436
-            return resultArray(['error' => '审批失败,请重试!']); 
483
+            return resultArray(['error' => '审批失败,请重试!']);
437
         }
484
         }
438
     }
485
     }
439
-
486
+    
440
     /**
487
     /**
441
      * 回款撤销审核
488
      * 回款撤销审核
442
-     * @author Michael_xu
443
-     * @param 
489
+     * @param
444
      * @return
490
      * @return
445
-     */  
491
+     * @author Michael_xu
492
+     */
446
     public function revokeCheck()
493
     public function revokeCheck()
447
     {
494
     {
448
         $param = $this->param;
495
         $param = $this->param;
453
         $examineRecordModel = new \app\admin\model\ExamineRecord();
500
         $examineRecordModel = new \app\admin\model\ExamineRecord();
454
         $customerModel = model('Customer');
501
         $customerModel = model('Customer');
455
         $userModel = new \app\admin\model\User();
502
         $userModel = new \app\admin\model\User();
456
-
503
+        
457
         $receivablesData = [];
504
         $receivablesData = [];
458
         $receivablesData['update_time'] = time();
505
         $receivablesData['update_time'] = time();
459
         $receivablesData['check_status'] = 0; //0待审核,1审核通中,2审核通过,3审核未通过
506
         $receivablesData['check_status'] = 0; //0待审核,1审核通中,2审核通过,3审核未通过
460
         //审批主体详情
507
         //审批主体详情
461
-        $dataInfo = $receivablesModel->getDataById($param['id']);        
508
+        $dataInfo = $receivablesModel->getDataById($param['id']);
462
         //权限判断(创建人或负责人或管理员)
509
         //权限判断(创建人或负责人或管理员)
463
         if ($dataInfo['check_status'] == 2) {
510
         if ($dataInfo['check_status'] == 2) {
464
-            return resultArray(['error' => '已审批结束,不能撤销']);   
465
-        } 
511
+            return resultArray(['error' => '已审批结束,不能撤销']);
512
+        }
466
         if ($dataInfo['check_status'] == 4) {
513
         if ($dataInfo['check_status'] == 4) {
467
-            return resultArray(['error' => '无需撤销']);   
468
-        } 
469
-        $admin_user_ids = $userModel->getAdminId(); 
514
+            return resultArray(['error' => '无需撤销']);
515
+        }
516
+        $admin_user_ids = $userModel->getAdminId();
470
         if ($dataInfo['owner_user_id'] !== $user_id && !in_array($user_id, $admin_user_ids)) {
517
         if ($dataInfo['owner_user_id'] !== $user_id && !in_array($user_id, $admin_user_ids)) {
471
             return resultArray(['error' => '没有权限']);
518
             return resultArray(['error' => '没有权限']);
472
-        }     
519
+        }
473
         
520
         
474
         $is_end = 0; // 1审批结束
521
         $is_end = 0; // 1审批结束
475
         $status = 2; //1通过,0驳回, 2撤销
522
         $status = 2; //1通过,0驳回, 2撤销
492
             // $examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);
539
             // $examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);
493
             //审批记录
540
             //审批记录
494
             $resRecord = $examineRecordModel->createData($checkData);
541
             $resRecord = $examineRecordModel->createData($checkData);
495
-            return resultArray(['data' => '撤销成功']);            
542
+            return resultArray(['data' => '撤销成功']);
496
         } else {
543
         } else {
497
-            return resultArray(['error' => '撤销失败,请重试!']); 
544
+            return resultArray(['error' => '撤销失败,请重试!']);
498
         }
545
         }
499
     }
546
     }
500
-
547
+    
501
     /**
548
     /**
502
      * 转移
549
      * 转移
503
      *
550
      *
505
      */
552
      */
506
     public function transfer()
553
     public function transfer()
507
     {
554
     {
508
-        $param            = $this->param;
509
-        $userInfo         = $this->userInfo;
555
+        $param = $this->param;
556
+        $userInfo = $this->userInfo;
510
         $receivablesModel = model('Receivables');
557
         $receivablesModel = model('Receivables');
511
-
558
+        
512
         $userModel = new \app\admin\model\User();
559
         $userModel = new \app\admin\model\User();
513
-        $authIds   = $userModel->getUserByPer();
514
-
560
+        $authIds = $userModel->getUserByPer();
561
+        
515
         if (empty($param['owner_user_id'])) return resultArray(['error' => '变更负责人不能为空']);
562
         if (empty($param['owner_user_id'])) return resultArray(['error' => '变更负责人不能为空']);
516
         if (empty($param['receivables_id']) || !is_array($param['receivables_id'])) return resultArray(['error' => '请选择需要转移的回款']);
563
         if (empty($param['receivables_id']) || !is_array($param['receivables_id'])) return resultArray(['error' => '请选择需要转移的回款']);
517
-
564
+        
518
         $owner_user_info = $userModel->getUserById($param['owner_user_id']);
565
         $owner_user_info = $userModel->getUserById($param['owner_user_id']);
519
-
566
+        
520
         $data = [
567
         $data = [
521
             'owner_user_id' => $param['owner_user_id'],
568
             'owner_user_id' => $param['owner_user_id'],
522
-            'update_time'   => time(),
569
+            'update_time' => time(),
523
         ];
570
         ];
524
-
571
+        
525
         $errorMessage = [];
572
         $errorMessage = [];
526
         foreach ($param['receivables_id'] as $receivables_id) {
573
         foreach ($param['receivables_id'] as $receivables_id) {
527
             $receivables_info = $receivablesModel->getDataById($receivables_id);
574
             $receivables_info = $receivablesModel->getDataById($receivables_id);
528
             if (!$receivables_info) {
575
             if (!$receivables_info) {
529
-                $errorMessage[] = 'id:为《'.$receivables_id.'》的回款转移失败,错误原因:数据不存在;';
576
+                $errorMessage[] = 'id:为《' . $receivables_id . '》的回款转移失败,错误原因:数据不存在;';
530
                 continue;
577
                 continue;
531
             }
578
             }
532
-
579
+            
533
             # 转移至当前负责人的直接跳过
580
             # 转移至当前负责人的直接跳过
534
             if ($param['owner_user_id'] == $receivables_info['owner_user_id']) continue;
581
             if ($param['owner_user_id'] == $receivables_info['owner_user_id']) continue;
535
-
582
+            
536
             if (!in_array($receivables_info['owner_user_id'], $authIds)) {
583
             if (!in_array($receivables_info['owner_user_id'], $authIds)) {
537
-                $errorMessage[] = $receivables_info['number'].'"转移失败,错误原因:无权限;';
584
+                $errorMessage[] = $receivables_info['number'] . '"转移失败,错误原因:无权限;';
538
                 continue;
585
                 continue;
539
             }
586
             }
540
-
541
-            if (in_array($receivables_info['check_status'],['0','1'])) {
542
-                $errorMessage[] = $receivables_info['number'].'转移失败,错误原因:待审或审批中,无法转移;';
587
+            
588
+            if (in_array($receivables_info['check_status'], ['0', '1'])) {
589
+                $errorMessage[] = $receivables_info['number'] . '转移失败,错误原因:待审或审批中,无法转移;';
543
                 continue;
590
                 continue;
544
             }
591
             }
545
-
592
+            
546
             $res = $receivablesModel->where(['receivables_id' => $receivables_id])->update($data);
593
             $res = $receivablesModel->where(['receivables_id' => $receivables_id])->update($data);
547
             if (!$res) {
594
             if (!$res) {
548
-                $errorMessage[] = $receivables_info['number'].'"转移失败,错误原因:数据出错;';
595
+                $errorMessage[] = $receivables_info['number'] . '"转移失败,错误原因:数据出错;';
549
                 continue;
596
                 continue;
550
             }
597
             }
551
-			updateActionLog($userInfo['id'], 'crm_receivables', $receivables_id, '', '', '将回款转移给:' . $owner_user_info['realname']);
598
+            updateActionLog($userInfo['id'], 'crm_receivables', $receivables_id, '', '', '将回款转移给:' . $owner_user_info['realname']);
552
         }
599
         }
553
         if (!$errorMessage) {
600
         if (!$errorMessage) {
554
             return resultArray(['data' => '转移成功']);
601
             return resultArray(['data' => '转移成功']);
556
             return resultArray(['error' => $errorMessage]);
603
             return resultArray(['error' => $errorMessage]);
557
         }
604
         }
558
     }
605
     }
559
-
606
+    
560
     /**
607
     /**
561
      * 系统信息
608
      * 系统信息
562
      *
609
      *
568
     public function system()
615
     public function system()
569
     {
616
     {
570
         if (empty($this->param['id'])) return resultArray(['error' => '参数错误!']);
617
         if (empty($this->param['id'])) return resultArray(['error' => '参数错误!']);
571
-
618
+        
572
         $receivablesModel = new \app\crm\model\Receivables();
619
         $receivablesModel = new \app\crm\model\Receivables();
573
-
620
+        
574
         $data = $receivablesModel->getSystemInfo($this->param['id']);
621
         $data = $receivablesModel->getSystemInfo($this->param['id']);
575
-
622
+        
576
         return resultArray(['data' => $data]);
623
         return resultArray(['data' => $data]);
577
     }
624
     }
578
-
625
+    
579
     /**
626
     /**
580
      * table标签栏数量
627
      * table标签栏数量
581
      *
628
      *
587
     public function count()
634
     public function count()
588
     {
635
     {
589
         if (empty($this->param['receivables_id'])) return resultArray(['error' => '参数错误!']);
636
         if (empty($this->param['receivables_id'])) return resultArray(['error' => '参数错误!']);
590
-
637
+        
591
         # 附件
638
         # 附件
592
         $fileCount = Db::name('crm_receivables_file')->alias('receivables')->join('__ADMIN_FILE__ file', 'file.file_id = receivables.file_id', 'LEFT')->where('receivables_id', $this->param['receivables_id'])->count();
639
         $fileCount = Db::name('crm_receivables_file')->alias('receivables')->join('__ADMIN_FILE__ file', 'file.file_id = receivables.file_id', 'LEFT')->where('receivables_id', $this->param['receivables_id'])->count();
593
-
640
+        
594
         return resultArray(['data' => ['fileCount' => $fileCount]]);
641
         return resultArray(['data' => ['fileCount' => $fileCount]]);
595
     }
642
     }
596
 }
643
 }

+ 2
- 4
application/crm/controller/Visit.php Zobrazit soubor

68
             if (empty($numberInfo['number'])) return resultArray(['error' => '请填写回访编号!']);
68
             if (empty($numberInfo['number'])) return resultArray(['error' => '请填写回访编号!']);
69
             $param['number'] = $numberInfo['number'];
69
             $param['number'] = $numberInfo['number'];
70
         }
70
         }
71
-        $param['owner_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
71
+        $param['owner_user_id'] = $param['owner_user_id'] ? : $userInfo['id'];
72
         $param['create_user_id'] = $userInfo['id'];
72
         $param['create_user_id'] = $userInfo['id'];
73
-        $param['visit_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
74
         $param['update_time'] = time();
73
         $param['update_time'] = time();
75
         $res = $Visit->createData($param);
74
         $res = $Visit->createData($param);
76
         if ($res) {
75
         if ($res) {
119
         $param = $this->param;
118
         $param = $this->param;
120
         $userInfo = $this->userInfo;
119
         $userInfo = $this->userInfo;
121
         $param['user_id'] = $userInfo['id'];
120
         $param['user_id'] = $userInfo['id'];
122
-        $param['owner_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
123
-        $param['visit_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];        
121
+        $param['owner_user_id'] = $param['owner_user_id'] ? : $userInfo['id'];
124
         # 设置回访编号
122
         # 设置回访编号
125
         $numberInfo = [];
123
         $numberInfo = [];
126
         if (empty($param['number'])) {
124
         if (empty($param['number'])) {

+ 4
- 3
application/crm/logic/ActivityLogic.php Zobrazit soubor

359
         $fileModel = new \app\admin\model\File();
359
         $fileModel = new \app\admin\model\File();
360
         foreach ($dataArray AS $key => $value) {
360
         foreach ($dataArray AS $key => $value) {
361
             # 用户信息 todo 有模型文件,时间问题,暂时将查询写在循环中
361
             # 用户信息 todo 有模型文件,时间问题,暂时将查询写在循环中
362
-            $realname = Db::name('admin_user')->where('id', $dataArray[$key]['create_user_id'])->value('realname');
363
-            $dataArray[$key]['create_user_name'] = $realname;
362
+            $realname = Db::name('admin_user')->where('id', $dataArray[$key]['create_user_id'])->find();
363
+            $dataArray[$key]['create_user_name'] = $realname['realname'];
364
+            $dataArray[$key]['thumb_img'] =  $realname['thumb_img'] ? getFullPath($realname['thumb_img']) : '';;
364
 
365
 
365
             # 附件信息
366
             # 附件信息
366
             if ($value['type'] = 1) {
367
             if ($value['type'] = 1) {
785
         # 审批
786
         # 审批
786
         if ($activityType == 9) {
787
         if ($activityType == 9) {
787
             $categoryId       = Db::name('oa_examine')->where('examine_id', $activityTypeId)->value('category_id');
788
             $categoryId       = Db::name('oa_examine')->where('examine_id', $activityTypeId)->value('category_id');
788
-            $activityTypeName = Db::name('oa_examine_category')->where('category_id', $categoryId);
789
+            $activityTypeName = Db::name('oa_examine_category')->where('category_id', $categoryId)->value('title');
789
         }
790
         }
790
         # 日程
791
         # 日程
791
         if ($activityType == 10) {
792
         if ($activityType == 10) {

+ 161
- 54
application/crm/logic/CommonLogic.php Zobrazit soubor

12
 use app\admin\model\User;
12
 use app\admin\model\User;
13
 use app\crm\model\Customer;
13
 use app\crm\model\Customer;
14
 use think\Db;
14
 use think\Db;
15
+use think\Validate;
15
 
16
 
16
 class CommonLogic
17
 class CommonLogic
17
 {
18
 {
18
     public $error = '操作失败!';
19
     public $error = '操作失败!';
19
-
20
+    
20
     /**
21
     /**
21
      * 快捷编辑【线索、客户、联系人、商机、合同、回款、回访、产品】
22
      * 快捷编辑【线索、客户、联系人、商机、合同、回款、回访、产品】
22
      *
23
      *
37
          * $param['name']      字段中文名,用作提示
38
          * $param['name']      字段中文名,用作提示
38
          * $param['value]      字段值
39
          * $param['value]      字段值
39
          */
40
          */
40
-
41
+        
41
         $actionId = $param['action_id'];
42
         $actionId = $param['action_id'];
42
-        $types    = $param['types'];
43
+        $types = $param['types'];
43
         unset($param['action_id']);
44
         unset($param['action_id']);
44
         unset($param['types']);
45
         unset($param['types']);
45
-
46
+        
46
         # 模型
47
         # 模型
47
         $model = db($types);
48
         $model = db($types);
48
-
49
+        
49
         # 主键
50
         # 主键
50
         $primaryKey = '';
51
         $primaryKey = '';
51
-        if ($types == 'crm_leads')       $primaryKey = 'leads_id';
52
-        if ($types == 'crm_customer')    $primaryKey = 'customer_id';
53
-        if ($types == 'crm_contacts')    $primaryKey = 'contacts_id';
54
-        if ($types == 'crm_business')    $primaryKey = 'business_id';
55
-        if ($types == 'crm_contract')    $primaryKey = 'contract_id';
56
-        if ($types == 'crm_receivables') $primaryKey = 'receivables_id';
57
-        if ($types == 'crm_visit')       $primaryKey = 'visit_id';
58
-        if ($types == 'crm_product')     $primaryKey = 'product_id';
59
-
52
+       // author      guogaobo $item模块
53
+        $info='';
54
+        switch ($types) {
55
+            case 'crm_leads' :
56
+                $primaryKey = 'leads_id';
57
+                $dataModel=new \app\crm\model\Leads();
58
+                $info=$dataModel->getDataById($actionId);
59
+                break;
60
+            case 'crm_customer' :
61
+                $primaryKey = 'customer_id';
62
+                $info=db('crm_customer')->where('customer_id',$actionId)->find();
63
+                break;
64
+            case 'crm_contacts' :
65
+                $primaryKey = 'contacts_id';
66
+                $dataModel=new \app\crm\model\Contacts();
67
+                $info=$dataModel->getDataById($actionId);
68
+                break;
69
+            case 'crm_business' :
70
+                $primaryKey = 'business_id';
71
+                $dataModel=new \app\crm\model\Business();
72
+                $info=$dataModel->getDataById($actionId);
73
+                break;
74
+            case 'crm_contract' :
75
+                $primaryKey = 'contract_id';
76
+                $info=db('crm_contract')->where('customer_id',$actionId)->find();
77
+                break;
78
+            case 'crm_receivables' :
79
+                $primaryKey = 'receivables_id';
80
+                $info=db('crm_receivables')->where('customer_id',$actionId)->find();
81
+                break;
82
+            case 'crm_visit' :
83
+                $primaryKey = 'visit_id';
84
+                $dataModel=new \app\crm\logic\VisitLogic();
85
+                $info=$dataModel->getDataById($actionId);
86
+                break;
87
+            case 'crm_product' :
88
+                $primaryKey = 'product_id';
89
+                $dataModel=new \app\crm\model\Product();
90
+                $info=$dataModel->getDataById($actionId);
91
+                break;
92
+        }
60
         $apiCommon = new ApiCommon();
93
         $apiCommon = new ApiCommon();
61
         $userModel = new User();
94
         $userModel = new User();
62
 
95
 
96
+
97
+        if (in_array($types, ['crm_contract', 'crm_receivables'])) {
98
+            $checkStatus = $model->where($primaryKey, $actionId)->value('check_status');
99
+            if (!in_array($checkStatus, [4, 5, 6])) {
100
+                $this->error = '只能编辑状态为撤销、草稿或作废的信息!';
101
+                return false;
102
+            }
103
+        }
104
+        # 产品修改验证
105
+        if($types == 'crm_product'){
106
+            foreach ($param['list'] as $val){
107
+                $infoData=db('crm_product')->where(['name'=>$val['name'],'delete_user_id'=>0])->find();
108
+                if(!empty($infoData)){
109
+                    $fieldModel = new \app\admin\model\Field();
110
+                    $validateArr = $fieldModel->validateField('crm_product'); //获取自定义字段验证规则
111
+                    $validate = new Validate($validateArr['rule'], $validateArr['message']);
112
+                    $result = $validate->check($val);
113
+                    if (!$result) {
114
+                        $this->error = $validate->getError();
115
+                        return false;
116
+                    }
117
+                }
118
+            }
119
+        }
120
+
63
         # 客户模块快捷编辑权限验证
121
         # 客户模块快捷编辑权限验证
64
         if ($types == 'crm_customer') {
122
         if ($types == 'crm_customer') {
65
-            $dataInfo  = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
123
+            $dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
66
             $auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'update');
124
             $auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'update');
67
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
125
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
68
             $wherePool = (new Customer())->getWhereByPool();
126
             $wherePool = (new Customer())->getWhereByPool();
69
             $resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $param['action_id']])->where($wherePool)->find();
127
             $resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $param['action_id']])->where($wherePool)->find();
70
-            if ($resPool || (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre)) {
128
+            if ($resPool || (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre)) {
71
                 $this->error = '无权操作!';
129
                 $this->error = '无权操作!';
72
                 return false;
130
                 return false;
73
             }
131
             }
74
         }
132
         }
75
-
133
+        
76
         # 商机模块快捷编辑权限验证
134
         # 商机模块快捷编辑权限验证
77
         if ($types == 'crm_business') {
135
         if ($types == 'crm_business') {
78
-            $dataInfo  = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
136
+            $dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
79
             $auth_user_ids = $userModel->getUserByPer('crm', 'business', 'update');
137
             $auth_user_ids = $userModel->getUserByPer('crm', 'business', 'update');
80
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
138
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
81
-            if (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre) {
139
+            if (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre) {
82
                 $this->error = '无权操作!';
140
                 $this->error = '无权操作!';
83
                 return false;
141
                 return false;
84
             }
142
             }
85
         }
143
         }
86
-
144
+        
87
         # 合同模块快捷编辑权限验证
145
         # 合同模块快捷编辑权限验证
88
         if ($types == 'crm_contract') {
146
         if ($types == 'crm_contract') {
89
-            $dataInfo  = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
147
+            $dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
90
             $auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'update');
148
             $auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'update');
91
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
149
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
92
             if (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre) {
150
             if (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre) {
95
             }
153
             }
96
         }
154
         }
97
 
155
 
98
-        foreach ($param AS $key => $value) {
99
-            # 查询自定义字段信息
100
-            $fieldInfo = Db::name('admin_field')->field(['max_length', 'is_unique', 'is_null', 'name'])
101
-                ->where('types', $types)->where('field', $key)->find();
102
-
103
-            # 字符长度
104
-            if (!empty($fieldInfo['max_length']) && strlen($value) > $fieldInfo['max_length']) {
105
-                $this->error = $fieldInfo['name'] . ' 字符长度不能超过 ' . $fieldInfo['max_length'] . ' 个字符!';
106
-                return false;
107
-            }
156
+        $fieldModel = new \app\admin\model\Field();
157
+        # 日期时间类型
158
+        $datetimeField = $fieldModel->getFieldByFormType($types, 'datetime');
159
+        # 附件类型
160
+        $fileField = $fieldModel->getFieldByFormType($types, 'file');
161
+        # 多选类型
162
+        $checkboxField = $fieldModel->getFieldByFormType($types, 'checkbox');
163
+        # 人员类型
164
+        $userField = $fieldModel->getFieldByFormType($types, 'user');
165
+        # 部门类型
166
+        $structureField = $fieldModel->getFieldByFormType($types, 'structure');
167
+
168
+        foreach ($param['list'] as $key => $value) {
169
+            foreach ($value as $k => $v) {
170
+                # 查询自定义字段信息
171
+                $fieldInfo = Db::name('admin_field')->field(['max_length', 'is_unique', 'is_null', 'name'])
172
+                    ->where('types', $types)->where('field', $k)->find();
173
+
174
+                # 字符长度
175
+                if (!empty($fieldInfo['max_length']) && strlen($v) > $fieldInfo['max_length']) {
176
+                    $this->error = $fieldInfo['name'] . ' 字符长度不能超过 ' . $fieldInfo['max_length'] . ' 个字符!';
177
+                    return false;
178
+                }
108
 
179
 
109
-            # 必填
110
-            if (!empty($fieldInfo['is_null']) && empty($value)) {
111
-                $this->error = $fieldInfo['name'] . ' 是必填信息,不能为空!';
112
-                return false;
113
-            }
180
+                # 必填
181
+                if (!empty($fieldInfo['is_null']) && empty($v)) {
182
+                    $this->error = $fieldInfo['name'] . ' 是必填信息,不能为空!';
183
+                    return false;
184
+                }
114
 
185
 
115
-            # 唯一
116
-            if (!empty($fieldInfo['is_unique']) && $model->where([$primaryKey => ['neq', $actionId]])->where($key, $value)->value($primaryKey)) {
117
-                $this->error = $fieldInfo['name'] . ' 内容重复!';
118
-                return false;
186
+                # 唯一
187
+                if (!empty($fieldInfo['is_unique']) && $model->where([$primaryKey => ['neq', $actionId]])->where($k, $v)->value($primaryKey)) {
188
+                    $this->error = $fieldInfo['name'] . ' 内容重复!';
189
+                    return false;
190
+                }
119
             }
191
             }
120
         }
192
         }
121
-
193
+        
122
         # 编辑参数
194
         # 编辑参数
123
         $data = [];
195
         $data = [];
196
+        $item=[];
124
         if (!empty($param['list'])) {
197
         if (!empty($param['list'])) {
125
-            foreach ($param['list'] AS $key => $value) {
126
-                foreach ($value AS $k => $v) {
127
-                    # 处理下次联系时间格式
128
-                    if ($k == 'next_time') {
198
+            foreach ($param['list'] as $key => $value) {
199
+                foreach ($value as $k => $v) {
200
+                    if ($k == 'next_time' || in_array($k, $datetimeField)) {
201
+                        # 处理下次联系时间格式、datetime类型数据
129
                         $data[$k] = !empty($v) ? strtotime($v) : '';
202
                         $data[$k] = !empty($v) ? strtotime($v) : '';
130
-                    } else {
131
-                        $data[$k] = $v;
132
-                    }
133
-                    # 处理产品类别
134
-                    if ($types == 'crm_product' && $k == 'category_id') {
203
+                    } elseif ($types == 'crm_product' && $k == 'category_id') {
204
+                        # 处理产品类别
135
                         $categorys = explode(',', $v);
205
                         $categorys = explode(',', $v);
136
-                        $data[$k]  = $categorys[count($categorys) - 1];
206
+                        $data[$k] = $categorys[count($categorys) - 1];
207
+                    } elseif (in_array($k, $fileField)) {
208
+                        # 处理附件类型数据
209
+                        $fileArray = [];
210
+                        foreach ($v AS $kk => $vv) {
211
+                            if (!empty($vv['file_id'])) $fileArray[] = $vv['file_id'];
212
+                        }
213
+                        if (!empty($fileArray)) $data[$k] = arrayToString($fileArray);
214
+                    } elseif (in_array($k, $checkboxField)) {
215
+                        # 处理多选类型数据
216
+                        $data[$k] = arrayToString($v);
217
+                    } elseif (in_array($k, $userField)) {
218
+                        # 处理人员类型数据
219
+                        $userArray = [];
220
+                        foreach ($v AS $kk => $vv) {
221
+                           if (!empty($vv['id'])) $userArray[] = $vv['id'];
222
+                        }
223
+                        $data[$k] = !empty($userArray) ? arrayToString($userArray) : '';
224
+                    } elseif (in_array($k, $structureField)) {
225
+                        # 处理部门类型数据
226
+                        $structureArray = [];
227
+                        foreach ($v AS $kk => $vv) {
228
+                            if (!empty($vv['id'])) $structureArray[] = $vv['id'];
229
+                        }
230
+                        $data[$k] = !empty($structureArray) ? arrayToString($structureArray) : '';
231
+                    } elseif ($types == 'crm_visit' && $k == 'contract_id') {
232
+                        # 处理回访提交过来的合同编号
233
+                        if (!empty($v[0]['contract_id'])) $data[$k] = $v[0]['contract_id'];
234
+                    }else {
235
+                        $data[$k] = $v;
137
                     }
236
                     }
138
                 }
237
                 }
238
+                $item=$value;
139
             }
239
             }
140
-            $data[$primaryKey] = $actionId;
240
+            $data[$primaryKey]   = $actionId;
241
+            $data['update_time'] = time();
141
         }
242
         }
142
-
143
-        return $model->update($data);
243
+        $res = $model->update($data);
244
+        //详细信息修改新增操作记录
245
+        if ($res) {
246
+            //修改记录
247
+            $user_id = $apiCommon->userInfo;
248
+            updateActionLog($user_id['id'], $types, $actionId, $info, $item);
249
+        }
250
+        return $res;
144
     }
251
     }
145
 }
252
 }

+ 10
- 7
application/crm/logic/IndexLogic.php Zobrazit soubor

23
         '12' => 'december',
23
         '12' => 'december',
24
     ];
24
     ];
25
 
25
 
26
+    /**
27
+     * @param $param
28
+     * @return array
29
+     */
26
     public function index($param)
30
     public function index($param)
27
     {
31
     {
28
         $adminModel = new \app\admin\model\Admin();
32
         $adminModel = new \app\admin\model\Admin();
69
         $contract_auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'index');
73
         $contract_auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'index');
70
         $receivables_auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'index');
74
         $receivables_auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'index');
71
         $record_auth_user_ids = $userModel->getUserByPer('crm', 'activity', 'index');
75
         $record_auth_user_ids = $userModel->getUserByPer('crm', 'activity', 'index');
72
-
73
         $resCount = queryCache(
76
         $resCount = queryCache(
74
             $this->getCountSql([
77
             $this->getCountSql([
75
                 'start_time' => $between_time[0],
78
                 'start_time' => $between_time[0],
76
                 'end_time' => $between_time[1],
79
                 'end_time' => $between_time[1],
77
-                'customer_auth_user_ids' => array_intersect($userIds, $customer_auth_user_ids),
78
-                'contacts_auth_user_ids' => array_intersect($userIds, $contacts_auth_user_ids),
79
-                'business_auth_user_ids' => array_intersect($userIds, $business_auth_user_ids),
80
-                'contract_auth_user_ids' => array_intersect($userIds, $contract_auth_user_ids),
81
-                'receivables_auth_user_ids' => array_intersect($userIds, $receivables_auth_user_ids),
82
-                'record_auth_user_ids' => array_intersect($userIds, $record_auth_user_ids),
80
+                'customer_auth_user_ids' => array_intersect($userIds, $customer_auth_user_ids) ? :[-1],
81
+                'contacts_auth_user_ids' => array_intersect($userIds, $contacts_auth_user_ids) ? :[-1],
82
+                'business_auth_user_ids' => array_intersect($userIds, $business_auth_user_ids) ? :[-1],
83
+                'contract_auth_user_ids' => array_intersect($userIds, $contract_auth_user_ids) ? :[-1],
84
+                'receivables_auth_user_ids' => array_intersect($userIds, $receivables_auth_user_ids) ? :[-1],
85
+                'record_auth_user_ids' => array_intersect($userIds, $record_auth_user_ids) ? :[-1],
83
             ])
86
             ])
84
         );
87
         );
85
 
88
 

+ 23
- 18
application/crm/logic/VisitLogic.php Zobrazit soubor

54
 
54
 
55
         //高级筛选
55
         //高级筛选
56
         $map = where_arr($map, 'crm', 'visit', 'index');
56
         $map = where_arr($map, 'crm', 'visit', 'index');
57
-        $order = ['visit.update_time desc'];
58
 
57
 
59
-        if (isset($map['visit.visit_time'])) {
60
-            $map['visit.visit_time'][1][0] = date('Y-m-d', $map['visit.visit_time'][1][0]);
61
-            $map['visit.visit_time'][1][1] = date('Y-m-d', $map['visit.visit_time'][1][1]);
62
-        }
63
         $authMap = [];
58
         $authMap = [];
64
         if (!$partMap) {
59
         if (!$partMap) {
65
             $a = 'index';
60
             $a = 'index';
68
                 if (!is_array($map['visit.owner_user_id'][1])) {
63
                 if (!is_array($map['visit.owner_user_id'][1])) {
69
                     $map['visit.owner_user_id'][1] = [$map['visit.owner_user_id'][1]];
64
                     $map['visit.owner_user_id'][1] = [$map['visit.owner_user_id'][1]];
70
                 }
65
                 }
71
-                if ($map['visit.owner_user_id'][0] == 'neq') {
66
+                if (in_array($map['visit.owner_user_id'][0], ['neq', 'notin'])) {
72
                     $auth_user_ids = array_diff($auth_user_ids, $map['visit.owner_user_id'][1]) ?: [];    //取差集
67
                     $auth_user_ids = array_diff($auth_user_ids, $map['visit.owner_user_id'][1]) ?: [];    //取差集
73
                 } else {
68
                 } else {
74
                     $auth_user_ids = array_intersect($map['visit.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
69
                     $auth_user_ids = array_intersect($map['visit.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
75
                 }
70
                 }
76
-                unset($map['visit.owner_user_id']);
77
                 $auth_user_ids = array_merge(array_unique(array_filter($auth_user_ids))) ?: ['-1'];
71
                 $auth_user_ids = array_merge(array_unique(array_filter($auth_user_ids))) ?: ['-1'];
78
                 $authMap['visit.owner_user_id'] = array('in', $auth_user_ids);
72
                 $authMap['visit.owner_user_id'] = array('in', $auth_user_ids);
73
+                unset($map['visit.owner_user_id']);
79
             } else {
74
             } else {
80
                 $authMapData = [];
75
                 $authMapData = [];
81
                 $authMapData['auth_user_ids'] = $auth_user_ids;
76
                 $authMapData['auth_user_ids'] = $auth_user_ids;
82
                 $authMapData['user_id'] = $user_id;
77
                 $authMapData['user_id'] = $user_id;
83
                 $authMap = function ($query) use ($authMapData) {
78
                 $authMap = function ($query) use ($authMapData) {
84
-                    $query->where('visit.owner_user_id', array('in', $authMapData['auth_user_ids']))
79
+                    $query->where('visit.owner_user_id', ['in', $authMapData['auth_user_ids']])
85
                         ->whereOr('visit.ro_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'))
80
                         ->whereOr('visit.ro_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'))
86
                         ->whereOr('visit.rw_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'));
81
                         ->whereOr('visit.rw_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'));
87
                 };
82
                 };
96
         //人员类型
91
         //人员类型
97
         $userField = $fieldModel->getFieldByFormType('crm_visit', 'user'); //人员类型
92
         $userField = $fieldModel->getFieldByFormType('crm_visit', 'user'); //人员类型
98
         $structureField = $fieldModel->getFieldByFormType('crm_visit', 'structure');  //部门类型
93
         $structureField = $fieldModel->getFieldByFormType('crm_visit', 'structure');  //部门类型
94
+        $datetimeField = $fieldModel->getFieldByFormType('crm_visit', 'datetime'); //日期时间类型
99
 
95
 
100
         //排序
96
         //排序
101
         if ($order_type && $order_field) {
97
         if ($order_type && $order_field) {
118
             ->where($partMap)
114
             ->where($partMap)
119
             ->where($authMap)
115
             ->where($authMap)
120
             ->limit($request['offset'], $request['length'])
116
             ->limit($request['offset'], $request['length'])
121
-            ->field(array_merge($indexField, [
122
-                'contract.num' => 'contract_number',
123
-                'customer.name' => 'customer_name',
124
-                'contacts.name' => 'contacts_name',
125
-
126
-            ]))
117
+            ->field('visit.*,
118
+                contract.num as contract_number,
119
+                customer.name as customer_name,
120
+                contacts.name as contacts_name'
121
+            )
127
             ->orderRaw($order)
122
             ->orderRaw($order)
128
             ->group('visit.visit_id')
123
             ->group('visit.visit_id')
129
             ->select();
124
             ->select();
140
             $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
135
             $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
141
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
136
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
142
             foreach ($userField as $key => $val) {
137
             foreach ($userField as $key => $val) {
143
-                $list[$k][$val . '_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
138
+                $usernameField  = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
139
+                $list[$k][$val] = implode($usernameField, ',');
144
             }
140
             }
145
             foreach ($structureField as $key => $val) {
141
             foreach ($structureField as $key => $val) {
146
-                $list[$k][$val . '_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
142
+                $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
143
+                $list[$k][$val]     = implode($structureNameField, ',');
144
+            }
145
+            foreach ($datetimeField as $key => $val) {
146
+                $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
147
             }
147
             }
148
             $list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
148
             $list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
149
             $list[$k]['contract_id_info']['name'] = $v['contract_name'];
149
             $list[$k]['contract_id_info']['name'] = $v['contract_name'];
161
             $is_update = 0;
161
             $is_update = 0;
162
             $is_delete = 0;
162
             $is_delete = 0;
163
             if (in_array($v['owner_user_id'], $readAuthIds) || $roPre || $rwPre) $is_read = 1;
163
             if (in_array($v['owner_user_id'], $readAuthIds) || $roPre || $rwPre) $is_read = 1;
164
-            if (in_array($v['owner_user_id'], $updateAuthIds) || $rwPre) $is_update = 1;
164
+            if (in_array($v['owner_user_id'], $updateAuthIds)  || $rwPre) $is_update = 1;
165
             if (in_array($v['owner_user_id'], $deleteAuthIds)) $is_delete = 1;
165
             if (in_array($v['owner_user_id'], $deleteAuthIds)) $is_delete = 1;
166
             $permission['is_read'] = $is_read;
166
             $permission['is_read'] = $is_read;
167
             $permission['is_update'] = $is_update;
167
             $permission['is_update'] = $is_update;
198
         $dataInfo['contacts_id_info'] = db('crm_contacts')->where(['contacts_id' => $dataInfo['contacts_id']])->field('contacts_id,name')->find();
198
         $dataInfo['contacts_id_info'] = db('crm_contacts')->where(['contacts_id' => $dataInfo['contacts_id']])->field('contacts_id,name')->find();
199
         $dataInfo['contacts_name'] = !empty($dataInfo['contacts_id_info']['name']) ? $dataInfo['contacts_id_info']['name'] : '';
199
         $dataInfo['contacts_name'] = !empty($dataInfo['contacts_id_info']['name']) ? $dataInfo['contacts_id_info']['name'] : '';
200
         # 处理日期格式
200
         # 处理日期格式
201
+        $fieldModel = new \app\admin\model\Field();
202
+        $datetimeField = $fieldModel->getFieldByFormType('crm_visit', 'datetime'); //日期时间类型
203
+        foreach ($datetimeField as $key => $val) {
204
+            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
205
+        }
201
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
206
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
202
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
207
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
203
         return $dataInfo;
208
         return $dataInfo;
330
                 return resultArray(['error' => $this->getError()]);
335
                 return resultArray(['error' => $this->getError()]);
331
             }
336
             }
332
             //删除关联附件
337
             //删除关联附件
333
-            $fileModel->delRFileByModule('crm_business', $delIds);
338
+            $fileModel->delRFileByModule('crm_visit', $delIds);
334
             //删除关联操作记录
339
             //删除关联操作记录
335
             $actionRecordModel->delDataById(['types' => 'crm_visit', 'visit_id' => $delIds]);
340
             $actionRecordModel->delDataById(['types' => 'crm_visit', 'visit_id' => $delIds]);
336
             actionLog($delIds, '', '', '');
341
             actionLog($delIds, '', '', '');

+ 440
- 417
application/crm/model/Business.php
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 18
- 18
application/crm/model/Contacts.php Zobrazit soubor

85
 			if (!is_array($map['contacts.owner_user_id'][1])) {
85
 			if (!is_array($map['contacts.owner_user_id'][1])) {
86
 				$map['contacts.owner_user_id'][1] = [$map['contacts.owner_user_id'][1]];
86
 				$map['contacts.owner_user_id'][1] = [$map['contacts.owner_user_id'][1]];
87
 			}
87
 			}
88
-			if ($map['contacts.owner_user_id'][0] == 'neq') {
88
+			if (in_array($map['contacts.owner_user_id'][0], ['neq', 'notin'])) {
89
 				$auth_user_ids = array_diff($auth_user_ids, $map['contacts.owner_user_id'][1]) ? : [];	//取差集	
89
 				$auth_user_ids = array_diff($auth_user_ids, $map['contacts.owner_user_id'][1]) ? : [];	//取差集	
90
 			} else {
90
 			} else {
91
 				$auth_user_ids = array_intersect($map['contacts.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集	
91
 				$auth_user_ids = array_intersect($map['contacts.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集	
107
 		//列表展示字段
107
 		//列表展示字段
108
 		$indexField = $fieldModel->getIndexField('crm_contacts', $user_id, 1) ? : array('name');
108
 		$indexField = $fieldModel->getIndexField('crm_contacts', $user_id, 1) ? : array('name');
109
 		$userField = $fieldModel->getFieldByFormType('crm_contacts', 'user'); //人员类型
109
 		$userField = $fieldModel->getFieldByFormType('crm_contacts', 'user'); //人员类型
110
-		$structureField = $fieldModel->getFieldByFormType('crm_contacts', 'structure');  //部门类型			
110
+		$structureField = $fieldModel->getFieldByFormType('crm_contacts', 'structure');  //部门类型
111
+        $datetimeField = $fieldModel->getFieldByFormType('crm_contacts', 'datetime'); //日期时间类型
111
 
112
 
112
 		//排序
113
 		//排序
113
 		if ($order_type && $order_field) {
114
 		if ($order_type && $order_field) {
130
         			->where($searchMap)
131
         			->where($searchMap)
131
         			->where($authMap)
132
         			->where($authMap)
132
         			->where($customerWhere)
133
         			->where($customerWhere)
133
-        			->count('contacts_id'); 
134
+        			->count('contacts_id');
134
 		if ($getCount == 1) {
135
 		if ($getCount == 1) {
135
 			$data['dataCount'] = $dataCount ? : 0;
136
 			$data['dataCount'] = $dataCount ? : 0;
136
 	        return $data;
137
 	        return $data;
144
 				->where($customerWhere)
145
 				->where($customerWhere)
145
         		->limit($request['offset'], $request['length'])
146
         		->limit($request['offset'], $request['length'])
146
         		->field('contacts.*,customer.name as customer_name')
147
         		->field('contacts.*,customer.name as customer_name')
147
-        		->field(implode(',',$indexField).',customer.name as customer_name')
148
         		->orderRaw($order)
148
         		->orderRaw($order)
149
         		->select();
149
         		->select();
150
         
150
         
154
         	$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'] ? : '';
154
         	$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'] ? : '';
155
         	$list[$k]['customer_id_info']['name'] = $v['customer_name'] ? : '';
155
         	$list[$k]['customer_id_info']['name'] = $v['customer_name'] ? : '';
156
 			foreach ($userField as $key => $val) {
156
 			foreach ($userField as $key => $val) {
157
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
157
+			    $usernameField  = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
158
+                $list[$k][$val] = implode($usernameField, ',');
158
         	}
159
         	}
159
 			foreach ($structureField as $key => $val) {
160
 			foreach ($structureField as $key => $val) {
160
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
161
-        	} 
161
+			    $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
162
+                $list[$k][$val]     = implode($structureNameField, ',');
163
+        	}
164
+            foreach ($datetimeField as $key => $val) {
165
+                $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
166
+            }
162
 
167
 
163
 			//权限
168
 			//权限
164
 			$permission = [];
169
 			$permission = [];
173
 	        $permission['is_delete'] = $is_delete;
178
 	        $permission['is_delete'] = $is_delete;
174
 	        $list[$k]['permission']	= $permission;
179
 	        $list[$k]['permission']	= $permission;
175
 
180
 
176
-            # 下次联系时间
177
-            $list[$k]['next_time'] = !empty($v['next_time']) ? date('Y-m-d H:i:s', $v['next_time']) : null;
178
-
179
             # 关注
181
             # 关注
180
             $starWhere = ['user_id' => $user_id, 'target_id' => $v['contacts_id'], 'type' => 'crm_contacts'];
182
             $starWhere = ['user_id' => $user_id, 'target_id' => $v['contacts_id'], 'type' => 'crm_contacts'];
181
             $star = Db::name('crm_star')->where($starWhere)->value('star_id');
183
             $star = Db::name('crm_star')->where($starWhere)->value('star_id');
227
             $param['primary'] = 1;
229
             $param['primary'] = 1;
228
         }
230
         }
229
 
231
 
230
-        # 处理下次联系时间
231
-        if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
232
-
233
 		//处理部门、员工、附件、多选类型字段
232
 		//处理部门、员工、附件、多选类型字段
234
 		$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
233
 		$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
235
 		foreach ($arrFieldAtt as $k=>$v) {
234
 		foreach ($arrFieldAtt as $k=>$v) {
249
                 'create_user_id'   => $param['create_user_id'],
248
                 'create_user_id'   => $param['create_user_id'],
250
                 'update_time'      => time(),
249
                 'update_time'      => time(),
251
                 'create_time'      => time(),
250
                 'create_time'      => time(),
252
-                'customer_ids'      => $param['customer_id']
251
+                'customer_ids'     => $param['customer_id']
253
             ]);
252
             ]);
254
 
253
 
255
             # 处理商机首要联系人
254
             # 处理商机首要联系人
319
 			return false;
318
 			return false;
320
 		}
319
 		}
321
 
320
 
322
-        # 处理下次联系时间
323
-        if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
324
-
325
 		//处理部门、员工、附件、多选类型字段
321
 		//处理部门、员工、附件、多选类型字段
326
 		$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
322
 		$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
327
 		foreach ($arrFieldAtt as $k=>$v) {
323
 		foreach ($arrFieldAtt as $k=>$v) {
382
         # 处理决策人显示问题
378
         # 处理决策人显示问题
383
         $dataInfo['decision'] = !empty($dataInfo['decision']) && $dataInfo['decision'] == '是' ? '是' : '';
379
         $dataInfo['decision'] = !empty($dataInfo['decision']) && $dataInfo['decision'] == '是' ? '是' : '';
384
         # 处理时间格式
380
         # 处理时间格式
385
-        $dataInfo['next_time']   = !empty($dataInfo['next_time'])   ? date('Y-m-d H:i:s', $dataInfo['next_time'])   : null;
381
+        $fieldModel = new \app\admin\model\Field();
382
+        $datetimeField = $fieldModel->getFieldByFormType('crm_contacts', 'datetime'); //日期时间类型
383
+        foreach ($datetimeField as $key => $val) {
384
+            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
385
+        }
386
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
386
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
387
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
387
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
388
         $dataInfo['last_time']   = !empty($dataInfo['last_time'])   ? date('Y-m-d H:i:s', $dataInfo['last_time'])   : null;
388
         $dataInfo['last_time']   = !empty($dataInfo['last_time'])   ? date('Y-m-d H:i:s', $dataInfo['last_time'])   : null;

+ 34
- 8
application/crm/model/Contract.php Zobrazit soubor

99
 				if (!is_array($map['contract.owner_user_id'][1])) {
99
 				if (!is_array($map['contract.owner_user_id'][1])) {
100
 					$map['contract.owner_user_id'][1] = [$map['contract.owner_user_id'][1]];
100
 					$map['contract.owner_user_id'][1] = [$map['contract.owner_user_id'][1]];
101
 				}				
101
 				}				
102
-				if ($map['contract.owner_user_id'][0] == 'neq') {
102
+				if (in_array($map['contract.owner_user_id'][0], ['neq', 'notin'])) {
103
 					$auth_user_ids = array_diff($auth_user_ids, $map['contract.owner_user_id'][1]) ? : [];	//取差集	
103
 					$auth_user_ids = array_diff($auth_user_ids, $map['contract.owner_user_id'][1]) ? : [];	//取差集	
104
 				} else {
104
 				} else {
105
 					$auth_user_ids = array_intersect($map['contract.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
105
 					$auth_user_ids = array_intersect($map['contract.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
127
 		//人员类型
127
 		//人员类型
128
 		$userField = $fieldModel->getFieldByFormType('crm_contract', 'user');
128
 		$userField = $fieldModel->getFieldByFormType('crm_contract', 'user');
129
 		$structureField = $fieldModel->getFieldByFormType('crm_contract', 'structure');  //部门类型
129
 		$structureField = $fieldModel->getFieldByFormType('crm_contract', 'structure');  //部门类型
130
+        $datetimeField = $fieldModel->getFieldByFormType('crm_contract', 'datetime'); //日期时间类型
130
 		//排序
131
 		//排序
131
 		if ($order_type && $order_field) {
132
 		if ($order_type && $order_field) {
132
 			$order = $fieldModel->getOrderByFormtype('crm_contract','contract',$order_field,$order_type);
133
 			$order = $fieldModel->getOrderByFormtype('crm_contract','contract',$order_field,$order_type);
186
         	$list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
187
         	$list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
187
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
188
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
188
 			foreach ($userField as $key => $val) {
189
 			foreach ($userField as $key => $val) {
189
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
190
+                $usernameField  = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
191
+                $list[$k][$val] = implode($usernameField, ',');
190
         	}
192
         	}
191
 			foreach ($structureField as $key => $val) {
193
 			foreach ($structureField as $key => $val) {
192
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
194
+                $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
195
+                $list[$k][$val]     = implode($structureNameField, ',');
193
         	}
196
         	}
197
+            foreach ($datetimeField as $key => $val) {
198
+                $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
199
+            }
194
         	$list[$k]['business_id_info']['business_id'] = $v['business_id'];
200
         	$list[$k]['business_id_info']['business_id'] = $v['business_id'];
195
         	$list[$k]['business_id_info']['name'] = $v['business_name'];
201
         	$list[$k]['business_id_info']['name'] = $v['business_name'];
196
         	$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
202
         	$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
226
             $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
232
             $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
227
             $list[$k]['update_time'] = !empty($v['update_time']) ? date('Y-m-d H:i:s', $v['update_time']) : null;
233
             $list[$k]['update_time'] = !empty($v['update_time']) ? date('Y-m-d H:i:s', $v['update_time']) : null;
228
             $list[$k]['last_time']   = !empty($v['last_time'])   ? date('Y-m-d H:i:s', $v['last_time'])   : null;
234
             $list[$k]['last_time']   = !empty($v['last_time'])   ? date('Y-m-d H:i:s', $v['last_time'])   : null;
235
+            $list[$k]['order_date'] = ($v['order_date']!='0000-00-00') ? $v['order_date'] : null;
236
+            $list[$k]['start_time'] = ($v['start_time']!='0000-00-00') ? $v['start_time'] : null;
237
+            $list[$k]['end_time'] = ($v['end_time']!='0000-00-00') ? $v['end_time'] : null;
229
             # 签约人姓名
238
             # 签约人姓名
230
             $orderNames = Db::name('admin_user')->whereIn('id', trim($v['order_user_id'], ','))->column('realname');
239
             $orderNames = Db::name('admin_user')->whereIn('id', trim($v['order_user_id'], ','))->column('realname');
231
             $list[$k]['order_user_name'] = implode(',', $orderNames);
240
             $list[$k]['order_user_name'] = implode(',', $orderNames);
488
         $orderNames = Db::name('admin_user')->whereIn('id', trim($dataInfo['order_user_id'], ','))->column('realname');
497
         $orderNames = Db::name('admin_user')->whereIn('id', trim($dataInfo['order_user_id'], ','))->column('realname');
489
         $dataInfo['order_user_name'] = implode(',', $orderNames);
498
         $dataInfo['order_user_name'] = implode(',', $orderNames);
490
         # 处理时间根式
499
         # 处理时间根式
500
+        $fieldModel = new \app\admin\model\Field();
501
+        $datetimeField = $fieldModel->getFieldByFormType('crm_contract', 'datetime'); //日期时间类型
502
+        foreach ($datetimeField as $key => $val) {
503
+            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
504
+        }
491
         $dataInfo['next_time']   = !empty($dataInfo['next_time'])   ? date('Y-m-d H:i:s', $dataInfo['next_time'])   : null;
505
         $dataInfo['next_time']   = !empty($dataInfo['next_time'])   ? date('Y-m-d H:i:s', $dataInfo['next_time'])   : null;
492
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
506
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
493
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
507
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
510
     	foreach ($ids as $id) {
524
     	foreach ($ids as $id) {
511
     		$contractInfo = [];
525
     		$contractInfo = [];
512
     		$contractInfo = db('crm_contract')->where(['contract_id' => $id])->find();
526
     		$contractInfo = db('crm_contract')->where(['contract_id' => $id])->find();
513
-			if (in_array($contractInfo['check_status'],['0','1'])) {
514
-	            $errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:审批中,无法转移;';
515
-	            continue;
516
-	        }	     		
527
+//			if (in_array($contractInfo['check_status'],['0','1'])) {
528
+//	            $errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:审批中,无法转移;';
529
+//	            continue;
530
+//	        }
517
 			//团队成员
531
 			//团队成员
518
 	        $teamData = [];
532
 	        $teamData = [];
519
             $teamData['type'] = $type; //权限 1只读2读写
533
             $teamData['type'] = $type; //权限 1只读2读写
529
 	        if (!db('crm_contract')->where(['contract_id' => $id])->update($data)) {
543
 	        if (!db('crm_contract')->where(['contract_id' => $id])->update($data)) {
530
 				$errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:数据出错;';
544
 				$errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:数据出错;';
531
 	            continue;				      	
545
 	            continue;				      	
532
-	        }
546
+	        } else {
547
+                $contractArray = [];
548
+                $teamContract = db('crm_contract')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('contract_id', $id)->find();
549
+                if (!empty($teamContract['ro_user_id'])) {
550
+                    $contractRo = arrayToString(array_diff(stringToArray($teamContract['ro_user_id']), [$teamContract['owner_user_id']]));
551
+                    $contractArray['ro_user_id'] = $contractRo;
552
+                }
553
+                if (!empty($teamContract['rw_user_id'])) {
554
+                    $contractRo = arrayToString(array_diff(stringToArray($teamContract['rw_user_id']), [$teamContract['owner_user_id']]));
555
+                    $contractArray['rw_user_id'] = $contractRo;
556
+                }
557
+                db('crm_contract')->where('contract_id', $id)->update($contractArray);
558
+            }
533
     	}
559
     	}
534
     	if ($errorMessage) {
560
     	if ($errorMessage) {
535
 			return $errorMessage;
561
 			return $errorMessage;

+ 67
- 67
application/crm/model/Customer.php Zobrazit soubor

127
 			    	if (!is_array($map['customer.owner_user_id'][1])) {
127
 			    	if (!is_array($map['customer.owner_user_id'][1])) {
128
 						$map['customer.owner_user_id'][1] = [$map['customer.owner_user_id'][1]];
128
 						$map['customer.owner_user_id'][1] = [$map['customer.owner_user_id'][1]];
129
 					}
129
 					}
130
-					if ($map['customer.owner_user_id'][0] == 'neq') {
130
+					if (in_array($map['customer.owner_user_id'][0], ['neq', 'notin'])) {
131
 						$auth_user_ids = array_diff($auth_user_ids, $map['customer.owner_user_id'][1]) ? : [];	//取差集
131
 						$auth_user_ids = array_diff($auth_user_ids, $map['customer.owner_user_id'][1]) ? : [];	//取差集
132
 					} else {
132
 					} else {
133
 						$auth_user_ids = array_intersect($map['customer.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
133
 						$auth_user_ids = array_intersect($map['customer.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
169
 		$indexField = $fieldModel->getIndexField('crm_customer', $user_id, 1) ? : array('name');
169
 		$indexField = $fieldModel->getIndexField('crm_customer', $user_id, 1) ? : array('name');
170
 		$userField = $fieldModel->getFieldByFormType('crm_customer', 'user'); //人员类型
170
 		$userField = $fieldModel->getFieldByFormType('crm_customer', 'user'); //人员类型
171
 		$structureField = $fieldModel->getFieldByFormType('crm_customer', 'structure'); //部门类型
171
 		$structureField = $fieldModel->getFieldByFormType('crm_customer', 'structure'); //部门类型
172
+        $datetimeField = $fieldModel->getFieldByFormType('crm_customer', 'datetime'); //日期时间类型
172
 		//排序
173
 		//排序
173
 		if ($order_type && $order_field) {
174
 		if ($order_type && $order_field) {
174
 			$order = $fieldModel->getOrderByFormtype('crm_customer','customer',$order_field,$order_type);
175
 			$order = $fieldModel->getOrderByFormtype('crm_customer','customer',$order_field,$order_type);
190
 				->where($poolMap)
191
 				->where($poolMap)
191
 				->where($otherMap)
192
 				->where($otherMap)
192
         		->limit($request['offset'], $request['length'])
193
         		->limit($request['offset'], $request['length'])
193
-        		->field(implode(',',$indexField))
194
-        		->order($order_t) /*置顶*/
194
+        		->field('customer.*')
195
         		->orderRaw($order)
195
         		->orderRaw($order)
196
 				->select();
196
 				->select();
197
         //保护规则
197
         //保护规则
228
                 $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
228
                 $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
229
 				foreach ($userField as $key => $val) {
229
 				foreach ($userField as $key => $val) {
230
 					if (in_array($val, $field_list)) {
230
 					if (in_array($val, $field_list)) {
231
-						$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
231
+                        $usernameField  = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
232
+                        $list[$k][$val] = implode($usernameField, ',');
232
 					}
233
 					}
233
 	        	}
234
 	        	}
234
 				foreach ($structureField as $key => $val) {
235
 				foreach ($structureField as $key => $val) {
235
 					if (in_array($val, $field_list)) {
236
 					if (in_array($val, $field_list)) {
236
-						$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
237
+                        $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
238
+                        $list[$k][$val]     = implode($structureNameField, ',');
237
 					}
239
 					}
238
 				}
240
 				}
241
+                foreach ($datetimeField as $key => $val) {
242
+                    $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
243
+                }
239
 				//商机数
244
 				//商机数
240
 				$list[$k]['business_count'] = $business_count[$v['customer_id']]['count'] ?: 0;
245
 				$list[$k]['business_count'] = $business_count[$v['customer_id']]['count'] ?: 0;
241
 	        	//距进入公海天数
246
 	        	//距进入公海天数
268
 		        $permission['is_delete'] = $is_delete;
273
 		        $permission['is_delete'] = $is_delete;
269
 		        $list[$k]['permission']	= $permission;
274
 		        $list[$k]['permission']	= $permission;
270
 
275
 
271
-		        # 下次联系时间
272
-                $list[$k]['next_time'] = !empty($v['next_time']) ? date('Y-m-d H:i:s', $v['next_time']) : null;
273
-
274
                 # 关注
276
                 # 关注
275
                 $starWhere = ['user_id' => $user_id, 'target_id' => $v['customer_id'], 'type' => 'crm_customer'];
277
                 $starWhere = ['user_id' => $user_id, 'target_id' => $v['customer_id'], 'type' => 'crm_customer'];
276
                 $star = Db::name('crm_star')->where($starWhere)->value('star_id');
278
                 $star = Db::name('crm_star')->where($starWhere)->value('star_id');
327
 			return false;
329
 			return false;
328
 		}
330
 		}
329
         unset($param['customer_id']);
331
         unset($param['customer_id']);
330
-        # 处理下次联系时间
331
-        if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
332
-
333
 
332
 
334
 		//处理部门、员工、附件、多选类型字段
333
 		//处理部门、员工、附件、多选类型字段
335
 		$arrFieldAtt = $fieldModel->getArrayField('crm_customer');
334
 		$arrFieldAtt = $fieldModel->getArrayField('crm_customer');
377
 	 * @author Michael_xu
376
 	 * @author Michael_xu
378
 	 * @param  
377
 	 * @param  
379
 	 * @return                            
378
 	 * @return                            
380
-	 */	
381
-	public function updateDataById($param, $customer_id = '')
382
-	{
383
-		$user_id = $param['user_id'];
384
-		$dataInfo = $this->get($customer_id);
385
-		if (!$dataInfo) {
386
-			$this->error = '数据不存在或已删除';
387
-			return false;
388
-		}		
389
-
390
-		//数据权限判断
379
+	 */
380
+    public function updateDataById($param, $customer_id = '')
381
+    {
382
+        $user_id = $param['user_id'];
383
+        $dataInfo = $this->get($customer_id);
384
+        if (!$dataInfo) {
385
+            $this->error = '数据不存在或已删除';
386
+            return false;
387
+        }
388
+        $id = $param['id']?:$customer_id;
389
+        //数据权限判断
391
         $userModel = new \app\admin\model\User();
390
         $userModel = new \app\admin\model\User();
392
         $auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'update');
391
         $auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'update');
393
         //读写权限
392
         //读写权限
394
-        $rwPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');     
393
+        $rwPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
395
         //判断是否客户池数据
394
         //判断是否客户池数据
396
         $wherePool = $this->getWhereByPool();
395
         $wherePool = $this->getWhereByPool();
397
-		$resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $param['id']])->where($wherePool)->find();
396
+        $resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $id])->where($wherePool)->find();
398
         if ($resPool || (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre)) {
397
         if ($resPool || (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre)) {
399
             $this->error = '无权操作';
398
             $this->error = '无权操作';
400
             return false;
399
             return false;
401
-        }		
402
-
403
-		$param['customer_id'] = $customer_id;
404
-		//过滤不能修改的字段
405
-		$unUpdateField = ['create_user_id','is_deleted','delete_time','user_id'];
406
-		foreach ($unUpdateField as $v) {
407
-			unset($param[$v]);
408
-		}
409
-		$param['deal_status'] = $dataInfo['deal_status'];
410
-		$fieldModel = new \app\admin\model\Field();
411
-		// 自动验证
412
-		$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
413
-		$validate = new Validate($validateArr['rule'], $validateArr['message']);
414
-		$result = $validate->check($param);
415
-		if (!$result) {
416
-			$this->error = $validate->getError();
417
-			return false;
418
-		}
419
-		//地址
420
-		$param['address'] = $param['address'] ? implode(chr(10),$param['address']) : '';
421
-		if ($param['deal_status'] == '已成交' && $dataInfo->data['deal_status'] == '未成交') {
400
+        }
401
+        
402
+        $param['customer_id'] = $customer_id;
403
+        //过滤不能修改的字段
404
+        $unUpdateField = ['create_user_id','is_deleted','delete_time','user_id'];
405
+        foreach ($unUpdateField as $v) {
406
+            unset($param[$v]);
407
+        }
408
+        $param['deal_status'] = $dataInfo['deal_status'];
409
+        $fieldModel = new \app\admin\model\Field();
410
+        // 自动验证
411
+        $validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
412
+        $validate = new Validate($validateArr['rule'], $validateArr['message']);
413
+        $result = $validate->check($param);
414
+        if (!$result) {
415
+            $this->error = $validate->getError();
416
+            return false;
417
+        }
418
+        //地址
419
+        $param['address'] = $param['address'] ? implode(chr(10),$param['address']) : '';
420
+        if ($param['deal_status'] == '已成交' && $dataInfo->data['deal_status'] == '未成交') {
422
             $param['deal_time'] = time();
421
             $param['deal_time'] = time();
423
         }
422
         }
424
-
425
-        # 处理下次联系时间
426
-        if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
427
-
428
-		//处理部门、员工、附件、多选类型字段
429
-		$arrFieldAtt = $fieldModel->getArrayField('crm_customer');
430
-		foreach ($arrFieldAtt as $k=>$v) {
431
-			$param[$v] = arrayToString($param[$v]);
432
-		}
433
-		$param['follow'] = '已跟进';
434
-		if ($this->update($param, ['customer_id' => $customer_id], true)) {
435
-			//修改记录
436
-			updateActionLog($user_id, 'crm_customer', $customer_id, $dataInfo->data, $param);
437
-			$data = [];
438
-			$data['customer_id'] = $customer_id;
439
-			return $data;
440
-		} else {
441
-			$this->error = '编辑失败';
442
-			return false;
443
-		}					
444
-	}
423
+        
424
+        //处理部门、员工、附件、多选类型字段
425
+        $arrFieldAtt = $fieldModel->getArrayField('crm_customer');
426
+        foreach ($arrFieldAtt as $k=>$v) {
427
+            $param[$v] = arrayToString($param[$v]);
428
+        }
429
+        $param['follow'] = '已跟进';
430
+        if ($this->update($param, ['customer_id' => $customer_id], true)) {
431
+            //修改记录
432
+            updateActionLog($user_id, 'crm_customer', $customer_id, $dataInfo->data, $param);
433
+            $data = [];
434
+            $data['customer_id'] = $customer_id;
435
+            return $data;
436
+        } else {
437
+            $this->error = '编辑失败';
438
+            return false;
439
+        }
440
+    }
445
 
441
 
446
     /**
442
     /**
447
      * 客户数据
443
      * 客户数据
495
         $primaryId = Db::name('crm_contacts')->where(['customer_id' => $id, 'primary' => 1])->value('contacts_id');
491
         $primaryId = Db::name('crm_contacts')->where(['customer_id' => $id, 'primary' => 1])->value('contacts_id');
496
         $dataInfo['contacts_id'] = !empty($primaryId) && $this->getContactsAuth($primaryId) ? $primaryId : 0;
492
         $dataInfo['contacts_id'] = !empty($primaryId) && $this->getContactsAuth($primaryId) ? $primaryId : 0;
497
         # 处理时间格式
493
         # 处理时间格式
498
-        $dataInfo['next_time']   = !empty($dataInfo['next_time'])   ? date('Y-m-d H:i:s', $dataInfo['next_time'])   : null;
494
+        $fieldModel = new \app\admin\model\Field();
495
+        $datetimeField = $fieldModel->getFieldByFormType('crm_customer', 'datetime'); //日期时间类型
496
+        foreach ($datetimeField as $key => $val) {
497
+            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
498
+        }
499
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
499
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
500
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
500
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
501
         $dataInfo['last_time']   = !empty($dataInfo['last_time'])   ? date('Y-m-d H:i:s', $dataInfo['last_time'])   : null;
501
         $dataInfo['last_time']   = !empty($dataInfo['last_time'])   ? date('Y-m-d H:i:s', $dataInfo['last_time'])   : null;

+ 1
- 0
application/crm/model/Invoice.php Zobrazit soubor

14
 {
14
 {
15
     protected $name = 'crm_invoice';
15
     protected $name = 'crm_invoice';
16
     protected $pk   = 'invoice_id';
16
     protected $pk   = 'invoice_id';
17
+    protected $dateFormat = "Y-m-d H:i:s";
17
 
18
 
18
     /**
19
     /**
19
      * 关联用户模型
20
      * 关联用户模型

+ 14
- 12
application/crm/model/Leads.php Zobrazit soubor

90
             if (!is_array($map['leads.owner_user_id'][1])) {
90
             if (!is_array($map['leads.owner_user_id'][1])) {
91
                 $map['leads.owner_user_id'][1] = [$map['leads.owner_user_id'][1]];
91
                 $map['leads.owner_user_id'][1] = [$map['leads.owner_user_id'][1]];
92
             }
92
             }
93
-            if ($map['leads.owner_user_id'][0] == 'neq') {
93
+            if (in_array($map['leads.owner_user_id'][0], ['neq', 'notin'])) {
94
                 $auth_user_ids = array_diff($auth_user_ids, $map['leads.owner_user_id'][1]) ?: [];    //取差集
94
                 $auth_user_ids = array_diff($auth_user_ids, $map['leads.owner_user_id'][1]) ?: [];    //取差集
95
             } else {
95
             } else {
96
                 $auth_user_ids = array_intersect($map['leads.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
96
                 $auth_user_ids = array_intersect($map['leads.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
104
         $indexField = $fieldModel->getIndexField('crm_leads', $user_id, 1) ?: array('name');
104
         $indexField = $fieldModel->getIndexField('crm_leads', $user_id, 1) ?: array('name');
105
         $userField = $fieldModel->getFieldByFormType('crm_leads', 'user'); //人员类型
105
         $userField = $fieldModel->getFieldByFormType('crm_leads', 'user'); //人员类型
106
         $structureField = $fieldModel->getFieldByFormType('crm_leads', 'structure');  //部门类型
106
         $structureField = $fieldModel->getFieldByFormType('crm_leads', 'structure');  //部门类型
107
+        $datetimeField = $fieldModel->getFieldByFormType('crm_leads', 'datetime'); //日期时间类型
107
 
108
 
108
         //排序
109
         //排序
109
         if ($order_type && $order_field) {
110
         if ($order_type && $order_field) {
139
             $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
140
             $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
140
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
141
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
141
             foreach ($userField as $key => $val) {
142
             foreach ($userField as $key => $val) {
142
-                $list[$k][$val . '_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
143
+                $usernameField  = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
144
+                $list[$k][$val] = implode($usernameField, ',');
143
             }
145
             }
144
             foreach ($structureField as $key => $val) {
146
             foreach ($structureField as $key => $val) {
145
-                $list[$k][$val . '_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
147
+                $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
148
+                $list[$k][$val]     = implode($structureNameField, ',');
149
+            }
150
+            foreach ($datetimeField as $key => $val) {
151
+                $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
146
             }
152
             }
147
             //权限
153
             //权限
148
             $permission = [];
154
             $permission = [];
156
             $permission['is_update'] = $is_update;
162
             $permission['is_update'] = $is_update;
157
             $permission['is_delete'] = $is_delete;
163
             $permission['is_delete'] = $is_delete;
158
             $list[$k]['permission'] = $permission;
164
             $list[$k]['permission'] = $permission;
159
-            # 下次联系时间
160
-            $list[$k]['next_time'] = !empty($v['next_time']) ? date('Y-m-d H:i:s', $v['next_time']) : null;
161
             # 关注
165
             # 关注
162
             $starWhere = ['user_id' => $user_id, 'target_id' => $v['leads_id'], 'type' => 'crm_leads'];
166
             $starWhere = ['user_id' => $user_id, 'target_id' => $v['leads_id'], 'type' => 'crm_leads'];
163
             $star = Db::name('crm_star')->where($starWhere)->value('star_id');
167
             $star = Db::name('crm_star')->where($starWhere)->value('star_id');
210
             $param[$v] = arrayToString($param[$v]);
214
             $param[$v] = arrayToString($param[$v]);
211
         }
215
         }
212
 
216
 
213
-        # 处理下次联系时间
214
-        if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
215
-
216
         if ($this->data($param)->allowField(true)->isUpdate(false)->save()) {
217
         if ($this->data($param)->allowField(true)->isUpdate(false)->save()) {
217
             //修改记录
218
             //修改记录
218
             updateActionLog($param['create_user_id'], 'crm_leads', $this->leads_id, '', '', '创建了线索');
219
             updateActionLog($param['create_user_id'], 'crm_leads', $this->leads_id, '', '', '创建了线索');
276
             return false;
277
             return false;
277
         }
278
         }
278
 
279
 
279
-        # 处理下次联系时间
280
-        if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
281
-
282
         //处理部门、员工、附件、多选类型字段
280
         //处理部门、员工、附件、多选类型字段
283
         $arrFieldAtt = $fieldModel->getArrayField('crm_leads');
281
         $arrFieldAtt = $fieldModel->getArrayField('crm_leads');
284
         foreach ($arrFieldAtt as $k => $v) {
282
         foreach ($arrFieldAtt as $k => $v) {
323
         $starId = empty($userId) ? 0 : Db::name('crm_star')->where(['user_id' => $userId, 'target_id' => $id, 'type' => 'crm_leads'])->value('star_id');
321
         $starId = empty($userId) ? 0 : Db::name('crm_star')->where(['user_id' => $userId, 'target_id' => $id, 'type' => 'crm_leads'])->value('star_id');
324
         $dataInfo['star'] = !empty($starId) ? 1 : 0;
322
         $dataInfo['star'] = !empty($starId) ? 1 : 0;
325
         # 处理时间格式处理
323
         # 处理时间格式处理
326
-        $dataInfo['next_time']   = !empty($dataInfo['next_time'])   ? date('Y-m-d H:i:s', $dataInfo['next_time'])   : null;
324
+        $fieldModel = new \app\admin\model\Field();
325
+        $datetimeField = $fieldModel->getFieldByFormType('crm_leads', 'datetime'); //日期时间类型
326
+        foreach ($datetimeField as $key => $val) {
327
+            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
328
+        }
327
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
329
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
328
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
330
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
329
         $dataInfo['last_time']   = !empty($dataInfo['last_time'])   ? date('Y-m-d H:i:s', $dataInfo['last_time'])   : null;
331
         $dataInfo['last_time']   = !empty($dataInfo['last_time'])   ? date('Y-m-d H:i:s', $dataInfo['last_time'])   : null;

+ 83
- 72
application/crm/model/Product.php Zobrazit soubor

35
      * @return array
35
      * @return array
36
      */
36
      */
37
 	public function getDataList($request)
37
 	public function getDataList($request)
38
-    {  	
38
+    {
39
     	$userModel = new \app\admin\model\User();
39
     	$userModel = new \app\admin\model\User();
40
     	$structureModel = new \app\admin\model\Structure();
40
     	$structureModel = new \app\admin\model\Structure();
41
     	$fieldModel = new \app\admin\model\Field();
41
     	$fieldModel = new \app\admin\model\Field();
48
     	$isStatus = !empty($request['is_status']) ? $request['is_status'] : 0;
48
     	$isStatus = !empty($request['is_status']) ? $request['is_status'] : 0;
49
 		unset($request['scene_id']);
49
 		unset($request['scene_id']);
50
 		unset($request['search']);
50
 		unset($request['search']);
51
-		unset($request['user_id']); 
52
-		unset($request['order_field']);	
51
+		unset($request['user_id']);
52
+		unset($request['order_field']);
53
 		unset($request['order_type']);
53
 		unset($request['order_type']);
54
 		unset($request['is_status']);
54
 		unset($request['is_status']);
55
 
55
 
87
             if (!is_array($map['product.owner_user_id'][1])) {
87
             if (!is_array($map['product.owner_user_id'][1])) {
88
                 $map['product.owner_user_id'][1] = [$map['product.owner_user_id'][1]];
88
                 $map['product.owner_user_id'][1] = [$map['product.owner_user_id'][1]];
89
             }
89
             }
90
-            if ($map['product.owner_user_id'][0] == 'neq') {
90
+            if (in_array($map['product.owner_user_id'][0], ['neq', 'notin'])) {
91
                 $auth_user_ids = array_diff($auth_user_ids, $map['product.owner_user_id'][1]) ?: [];    //取差集
91
                 $auth_user_ids = array_diff($auth_user_ids, $map['product.owner_user_id'][1]) ?: [];    //取差集
92
             } else {
92
             } else {
93
                 $auth_user_ids = array_intersect($map['product.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
93
                 $auth_user_ids = array_intersect($map['product.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
102
 		$indexField = $fieldModel->getIndexField('crm_product', $user_id, 1) ? : ['name'];
102
 		$indexField = $fieldModel->getIndexField('crm_product', $user_id, 1) ? : ['name'];
103
 		$userField = $fieldModel->getFieldByFormType('crm_product', 'user'); //人员类型
103
 		$userField = $fieldModel->getFieldByFormType('crm_product', 'user'); //人员类型
104
 		$structureField = $fieldModel->getFieldByFormType('crm_product', 'structure');  //部门类型
104
 		$structureField = $fieldModel->getFieldByFormType('crm_product', 'structure');  //部门类型
105
-					
105
+        $datetimeField = $fieldModel->getFieldByFormType('crm_product', 'datetime'); //日期时间类型
106
+		
106
 		//排序
107
 		//排序
107
 		if ($order_type && $order_field) {
108
 		if ($order_type && $order_field) {
108
 			$order = $fieldModel->getOrderByFormtype('crm_product','product',$order_field,$order_type);
109
 			$order = $fieldModel->getOrderByFormtype('crm_product','product',$order_field,$order_type);
109
 		} else {
110
 		} else {
110
 			$order = 'product.update_time desc';
111
 			$order = 'product.update_time desc';
111
-		}		
112
+		}
112
 
113
 
113
 		$join = [
114
 		$join = [
114
 			['__CRM_PRODUCT_CATEGORY__ product_category', 'product_category.category_id = product.category_id', 'LEFT'],
115
 			['__CRM_PRODUCT_CATEGORY__ product_category', 'product_category.category_id = product.category_id', 'LEFT'],
115
 		];
116
 		];
116
-
117
+        $map['product.delete_user_id']=0;
117
 		$list = db('crm_product')->alias('product')
118
 		$list = db('crm_product')->alias('product')
118
 				->join($join)
119
 				->join($join)
119
 				->where($map)
120
 				->where($map)
120
 				->where($authMap)
121
 				->where($authMap)
121
         		->limit($request['offset'], $request['length'])
122
         		->limit($request['offset'], $request['length'])
122
 				->field($indexField)
123
 				->field($indexField)
123
-				->field(array_merge($indexField, ['product_category.name' => 'category_name']))
124
+				->field('product.*,product_category.name as category_name')
124
         		->orderRaw($order)
125
         		->orderRaw($order)
125
         		->select();
126
         		->select();
126
         $dataCount = db('crm_product')->alias('product')
127
         $dataCount = db('crm_product')->alias('product')
132
         	$list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
133
         	$list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
133
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
134
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
134
         	foreach ($userField as $key => $val) {
135
         	foreach ($userField as $key => $val) {
135
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
136
+                $usernameField  = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
137
+                $list[$k][$val] = implode($usernameField, ',');
136
         	}
138
         	}
137
 			foreach ($structureField as $key => $val) {
139
 			foreach ($structureField as $key => $val) {
138
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
140
+                $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
141
+                $list[$k][$val]     = implode($structureNameField, ',');
139
         	}
142
         	}
143
+            foreach ($datetimeField as $key => $val) {
144
+                $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
145
+            }
140
         	//产品类型
146
         	//产品类型
141
 			$list[$k]['category_id_info'] = $v['category_name'];
147
 			$list[$k]['category_id_info'] = $v['category_name'];
142
             # 处理日期格式
148
             # 处理日期格式
153
 	/**
159
 	/**
154
 	 * 创建产品主表信息
160
 	 * 创建产品主表信息
155
 	 * @author Michael_xu
161
 	 * @author Michael_xu
156
-	 * @param  
157
-	 * @return                            
158
-	 */	
162
+	 * @param
163
+	 * @return
164
+	 */
159
 	public function createData($param)
165
 	public function createData($param)
160
 	{
166
 	{
161
 		$fieldModel = new \app\admin\model\Field();
167
 		$fieldModel = new \app\admin\model\Field();
162
 		$productCategoryModel = model('ProductCategory');
168
 		$productCategoryModel = model('ProductCategory');
163
-		// 自动验证
164
-		$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
165
-		$validate = new Validate($validateArr['rule'], $validateArr['message']);
166
-
167
-		$result = $validate->check($param);
168
-		if (!$result) {
169
-			$this->error = $validate->getError();
170
-			return false;
171
-		}
172
-
169
+        $dataInfo = db('crm_product')->where(['name'=>$param['name'],'delete_user_id'=>0])->find();
170
+        if(isset($dataInfo)){
171
+            // 自动验证
172
+            $validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
173
+            $validate = new Validate($validateArr['rule'], $validateArr['message']);
174
+    
175
+            $result = $validate->check($param);
176
+            if (!$result) {
177
+                $this->error = $validate->getError();
178
+                return false;
179
+            }
180
+        }
173
 		//处理部门、员工、附件、多选类型字段
181
 		//处理部门、员工、附件、多选类型字段
174
 		$arrFieldAtt = $fieldModel->getArrayField('crm_product');
182
 		$arrFieldAtt = $fieldModel->getArrayField('crm_product');
175
 		foreach ($arrFieldAtt as $k=>$v) {
183
 		foreach ($arrFieldAtt as $k=>$v) {
200
 		} else {
208
 		} else {
201
 			$this->error = '添加失败';
209
 			$this->error = '添加失败';
202
 			return false;
210
 			return false;
203
-		}			
211
+		}
204
 	}
212
 	}
205
 
213
 
206
 	/**
214
 	/**
207
 	 * 编辑产品主表信息
215
 	 * 编辑产品主表信息
208
 	 * @author Michael_xu
216
 	 * @author Michael_xu
209
-	 * @param  
210
-	 * @return                            
211
-	 */	
217
+	 * @param
218
+	 * @return
219
+	 */
212
 	public function updateDataById($param, $product_id = '')
220
 	public function updateDataById($param, $product_id = '')
213
 	{
221
 	{
222
+        $userModel = new \app\admin\model\User();
214
 		$dataInfo = $this->getDataById($product_id);
223
 		$dataInfo = $this->getDataById($product_id);
215
 		$productCategoryModel = model('ProductCategory');
224
 		$productCategoryModel = model('ProductCategory');
216
 		if (!$dataInfo) {
225
 		if (!$dataInfo) {
222
         if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
231
         if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
223
             $this->error = '无权操作';
232
             $this->error = '无权操作';
224
             return false;
233
             return false;
225
-        }		
234
+        }
226
 
235
 
227
 		$param['product_id'] = $product_id;
236
 		$param['product_id'] = $product_id;
228
 		//过滤不能修改的字段
237
 		//过滤不能修改的字段
232
 		}
241
 		}
233
 		
242
 		
234
 		$fieldModel = new \app\admin\model\Field();
243
 		$fieldModel = new \app\admin\model\Field();
235
-		// 自动验证
236
-		$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
237
-		$validate = new Validate($validateArr['rule'], $validateArr['message']);
238
-
239
-		$result = $validate->check($param);
240
-		if (!$result) {
241
-			$this->error = $validate->getError();
242
-			return false;
243
-		}	
244
+            // 自动验证
245
+//            $validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
246
+//            $validate = new Validate($validateArr['rule'], $validateArr['message']);
247
+//
248
+//            $result = $validate->check($param);
249
+//            if (!$result) {
250
+//                $this->error = $validate->getError();
251
+//                return false;
252
+//            }
253
+		
244
 
254
 
245
 		//处理部门、员工、附件、多选类型字段
255
 		//处理部门、员工、附件、多选类型字段
246
 		$arrFieldAtt = $fieldModel->getArrayField('crm_product');
256
 		$arrFieldAtt = $fieldModel->getArrayField('crm_product');
250
 
260
 
251
 		//产品分类
261
 		//产品分类
252
 		$category_id = $param['category_id'];
262
 		$category_id = $param['category_id'];
253
-		if (is_array($category_id)) {
254
-			$param['category_id'] = $productCategoryModel->getIdByStr($category_id);
255
-			$param['category_str'] = arrayToString($category_id);
256
-		}
263
+//		if (is_array($category_id)) {
264
+//			$param['category_id'] = $productCategoryModel->getIdByStr($category_id);
265
+//			$param['category_str'] = arrayToString($category_id);
266
+//		}
257
         if(!is_int($category_id)){
267
         if(!is_int($category_id)){
258
             $list=db('crm_product_category')->column('category_id','name');
268
             $list=db('crm_product_category')->column('category_id','name');
269
+            $param['category_id']=1;
259
             foreach ($list as $k=>$v){
270
             foreach ($list as $k=>$v){
260
-                if($k==$param['category_id']){
271
+                if($k==$category_id){
261
                     $param['category_id']=$v;
272
                     $param['category_id']=$v;
262
-                }else{
263
-                    $param['category_id']=0;
264
                 }
273
                 }
265
             }
274
             }
266
         }
275
         }
274
 			$this->rollback();
283
 			$this->rollback();
275
 			$this->error = '编辑失败';
284
 			$this->error = '编辑失败';
276
 			return false;
285
 			return false;
277
-		}					
286
+		}
278
 	}
287
 	}
279
 
288
 
280
     /**
289
     /**
287
      * @throws \think\exception\DbException
296
      * @throws \think\exception\DbException
288
      */
297
      */
289
    	public function getDataById($id = '')
298
    	public function getDataById($id = '')
290
-   	{   		
299
+   	{
291
    		$map['product_id'] = $id;
300
    		$map['product_id'] = $id;
301
+   		$map['delete_user_id'] = 0;
292
 		$dataInfo = db('crm_product')->where($map)->find();
302
 		$dataInfo = db('crm_product')->where($map)->find();
293
 		if (!$dataInfo) {
303
 		if (!$dataInfo) {
294
 			$this->error = '暂无此数据';
304
 			$this->error = '暂无此数据';
302
 
312
 
303
 		$userModel = new \app\admin\model\User();
313
 		$userModel = new \app\admin\model\User();
304
 		$dataInfo['create_user_id_info'] = $userModel->getUserById($dataInfo['create_user_id']);
314
 		$dataInfo['create_user_id_info'] = $userModel->getUserById($dataInfo['create_user_id']);
305
-        $dataInfo['category_id_info'] = db('crm_product_category')->where(['category_id' => $dataInfo['category_id']])->value('name');	
315
+        $dataInfo['category_id_info'] = db('crm_product_category')->where(['category_id' => $dataInfo['category_id']])->value('name');
306
 		# 处理日期格式
316
 		# 处理日期格式
317
+        $fieldModel = new \app\admin\model\Field();
318
+        $datetimeField = $fieldModel->getFieldByFormType('crm_product', 'datetime'); //日期时间类型
319
+        foreach ($datetimeField as $key => $val) {
320
+            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
321
+        }
307
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
322
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
308
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
323
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
309
         return $dataInfo;
324
         return $dataInfo;
320
      */
335
      */
321
    	private function getProductImages($fileIds)
336
    	private function getProductImages($fileIds)
322
     {
337
     {
323
-        $result = [];
338
+        $files = Db::name('admin_file')->whereIn('file_id', $fileIds)->select();
324
 
339
 
325
-        $files = Db::name('admin_file')->field(['file_id', 'file_path_thumb', 'file_path', 'save_name'])->whereIn('file_id', $fileIds)->select();
326
         foreach ($files AS $key => $value) {
340
         foreach ($files AS $key => $value) {
327
-            $result[] = [
328
-                'file_id'         => $value['file_id'],
329
-                'file_path_thumb' => getFullPath($value['file_path_thumb']),
330
-                'file_path'       => getFullPath($value['file_path']),
331
-                'save_name'       => $value['save_name']
332
-            ];
341
+            $files[$key]['file_path'] = getFullPath($value['file_path']);
342
+            $files[$key]['file_path_thumb'] = getFullPath($value['file_path_thumb']);
343
+            $files[$key]['size'] = format_bytes($value['size']);
333
         }
344
         }
334
 
345
 
335
-        return $result;
346
+        return $files;
336
     }
347
     }
337
 
348
 
338
 	/**
349
 	/**
346
      * @param  subtotal 小计(折扣后价格)
357
      * @param  subtotal 小计(折扣后价格)
347
      * @param  unit 单位
358
      * @param  unit 单位
348
      * @param  total_price 折扣后整单总价
359
      * @param  total_price 折扣后整单总价
349
-     * @param  discount_rate 整单折扣 
360
+     * @param  discount_rate 整单折扣
350
      * @param  objId 关联对象ID
361
      * @param  objId 关联对象ID
351
-     * @return 
352
-     */ 
362
+     * @return
363
+     */
353
     public function createObject($types, $param, $objId)
364
     public function createObject($types, $param, $objId)
354
     {
365
     {
355
     	switch ($types) {
366
     	switch ($types) {
375
 		    		$product[$key]['discount'] = $value['discount']; //折扣
386
 		    		$product[$key]['discount'] = $value['discount']; //折扣
376
 		    		$product[$key]['unit'] = $value['unit'] ? : ''; //单位
387
 		    		$product[$key]['unit'] = $value['unit'] ? : ''; //单位
377
 		    		$product[$key]['subtotal'] = $value['subtotal'];
388
 		    		$product[$key]['subtotal'] = $value['subtotal'];
378
-		    		// $total_price += $product[$key]['subtotal'] = round(($value['price'] * $value['num']) * $discount); //总价	
389
+		    		// $total_price += $product[$key]['subtotal'] = round(($value['price'] * $value['num']) * $discount); //总价
379
 		    		$product[$key][$db_id] = $objId;
390
 		    		$product[$key][$db_id] = $objId;
380
 		    	}
391
 		    	}
381
 
392
 
388
 				//产品合计
399
 				//产品合计
389
 				$rData['discount_rate'] = !empty($param['discount_rate']) ? $param['discount_rate'] : 0.00; //整单折扣
400
 				$rData['discount_rate'] = !empty($param['discount_rate']) ? $param['discount_rate'] : 0.00; //整单折扣
390
 		    	$discount_rate = ((100 - $rData['discount_rate']) > 0) ? (100 - $rData['discount_rate'])/100 : 0;
401
 		    	$discount_rate = ((100 - $rData['discount_rate']) > 0) ? (100 - $rData['discount_rate'])/100 : 0;
391
-		    	// $rData['total_price'] = $total_price ? $total_price*$discount_rate : '0.00'; //整单合计	
392
-		    	$rData['total_price'] = $param['total_price'] ? : '0.00'; //整单合计	
393
-		    	db($rDb)->where([$db_id => $objId])->update($rData);	    	
402
+		    	// $rData['total_price'] = $total_price ? $total_price*$discount_rate : '0.00'; //整单合计
403
+		    	$rData['total_price'] = $param['total_price'] ? : '0.00'; //整单合计
404
+		    	db($rDb)->where([$db_id => $objId])->update($rData);
394
 		    	
405
 		    	
395
 		    	// 提交事务
406
 		    	// 提交事务
396
     			Db::commit();
407
     			Db::commit();
397
-		    	return true;    			
408
+		    	return true;
398
 			} catch (\Exception $e) {
409
 			} catch (\Exception $e) {
399
 				$this->error = '产品数据创建出错';
410
 				$this->error = '产品数据创建出错';
400
 				// 回滚事务
411
 				// 回滚事务
401
-			    Db::rollback();					
402
-	    		return false;   				    
412
+			    Db::rollback();
413
+	    		return false;
403
 			}
414
 			}
404
     	} else {
415
     	} else {
405
     		//删除产品信息
416
     		//删除产品信息
425
         $perUserIds = $userModel->getUserByPer('bi', 'product', 'read'); //权限范围内userIds
436
         $perUserIds = $userModel->getUserByPer('bi', 'product', 'read'); //权限范围内userIds
426
         $whereData = $adminModel->getWhere($param, '', $perUserIds); //统计条件
437
         $whereData = $adminModel->getWhere($param, '', $perUserIds); //统计条件
427
         $userIds = $whereData['userIds'];
438
         $userIds = $whereData['userIds'];
428
-        $between_time = $whereData['between_time'];     
439
+        $between_time = $whereData['between_time'];
429
         $where = [];
440
         $where = [];
430
 		//时间段
441
 		//时间段
431
 		$where['contract.create_time'] = ['between', $between_time];
442
 		$where['contract.create_time'] = ['between', $between_time];
457
 			$list[$k]['contract_id_info'] = $contract_info ? : array();
468
 			$list[$k]['contract_id_info'] = $contract_info ? : array();
458
 			//产品
469
 			//产品
459
 			$product_info = [];
470
 			$product_info = [];
460
-			$product_info['name'] = $v['product_name']; 
471
+			$product_info['name'] = $v['product_name'];
461
 			$product_info['product_id'] = $v['product_id'];
472
 			$product_info['product_id'] = $v['product_id'];
462
 			$list[$k]['product_id_info'] = $product_info ? : array();
473
 			$list[$k]['product_id_info'] = $product_info ? : array();
463
 			//负责人
474
 			//负责人
467
 			$list[$k]['owner_user_name'] = $owner_user_id_info['realname'];
478
 			$list[$k]['owner_user_name'] = $owner_user_id_info['realname'];
468
 		}
479
 		}
469
         return $list;
480
         return $list;
470
-    }  
481
+    }
471
 
482
 
472
 	/**
483
 	/**
473
      * [根据产品类别ID,查询父级ID]
484
      * [根据产品类别ID,查询父级ID]
474
      * @author Michael_xu
485
      * @author Michael_xu
475
-     * @param 
476
-     * @return                   
477
-     */		
486
+     * @param
487
+     * @return
488
+     */
478
 	public function getPidStr($category_id, $idArr, $first = '')
489
 	public function getPidStr($category_id, $idArr, $first = '')
479
 	{
490
 	{
480
 		if ($first == 1) $idArr = [];
491
 		if ($first == 1) $idArr = [];

+ 16
- 5
application/crm/model/Receivables.php Zobrazit soubor

83
 			if (!is_array($map['receivables.owner_user_id'][1])) {
83
 			if (!is_array($map['receivables.owner_user_id'][1])) {
84
 				$map['receivables.owner_user_id'][1] = [$map['receivables.owner_user_id'][1]];
84
 				$map['receivables.owner_user_id'][1] = [$map['receivables.owner_user_id'][1]];
85
 			}
85
 			}
86
-			if ($map['receivables.owner_user_id'][0] == 'neq') {
86
+			if (in_array($map['receivables.owner_user_id'][0], ['neq', 'notin'])) {
87
 				$auth_user_ids = array_diff($auth_user_ids, $map['receivables.owner_user_id'][1]) ? : [];	//取差集	
87
 				$auth_user_ids = array_diff($auth_user_ids, $map['receivables.owner_user_id'][1]) ? : [];	//取差集	
88
 			} else {
88
 			} else {
89
 				$auth_user_ids = array_intersect($map['receivables.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
89
 				$auth_user_ids = array_intersect($map['receivables.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
97
 		$indexField = $fieldModel->getIndexField('crm_receivables', $user_id, 1) ? : array('number');    
97
 		$indexField = $fieldModel->getIndexField('crm_receivables', $user_id, 1) ? : array('number');    
98
 		//人员类型
98
 		//人员类型
99
 		$userField = $fieldModel->getFieldByFormType('crm_receivables', 'user');
99
 		$userField = $fieldModel->getFieldByFormType('crm_receivables', 'user');
100
-		$structureField = $fieldModel->getFieldByFormType('crm_receivables', 'structure');  //部门类型	    			
100
+		$structureField = $fieldModel->getFieldByFormType('crm_receivables', 'structure');  //部门类型
101
+        $datetimeField = $fieldModel->getFieldByFormType('crm_receivables', 'datetime'); //日期时间类型
101
 
102
 
102
 		if ($request['order_type'] && $request['order_field']) {
103
 		if ($request['order_type'] && $request['order_field']) {
103
 			$order = $fieldModel->getOrderByFormtype('crm_receivables','receivables',$order_field,$order_type);
104
 			$order = $fieldModel->getOrderByFormtype('crm_receivables','receivables',$order_field,$order_type);
134
 				->where($map)
135
 				->where($map)
135
 				->where($authMap)
136
 				->where($authMap)
136
         		->limit($request['offset'], $request['length'])
137
         		->limit($request['offset'], $request['length'])
137
-				->field(implode(',',$indexField).',customer.name as customer_name,contract.name as contract_name,contract.num as contract_num,contract.money as contract_money')
138
+				->field('receivables.*,customer.name as customer_name,contract.name as contract_name,contract.num as contract_num,contract.money as contract_money')
138
 				->orderRaw($order)
139
 				->orderRaw($order)
139
 				->select();	
140
 				->select();	
140
 
141
 
150
         	$list[$k]['contract_id_info']['money'] = $v['contract_money'] ? : '0.00';
151
         	$list[$k]['contract_id_info']['money'] = $v['contract_money'] ? : '0.00';
151
         	$list[$k]['contract_money'] = $v['contract_money'] ? : '0.00';  
152
         	$list[$k]['contract_money'] = $v['contract_money'] ? : '0.00';  
152
 			foreach ($userField as $key => $val) {
153
 			foreach ($userField as $key => $val) {
153
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
154
+                $usernameField  = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
155
+                $list[$k][$val] = implode($usernameField, ',');
154
         	}
156
         	}
155
 			foreach ($structureField as $key => $val) {
157
 			foreach ($structureField as $key => $val) {
156
-        		$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
158
+                $structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
159
+                $list[$k][$val]     = implode($structureNameField, ',');
157
         	}
160
         	}
161
+            foreach ($datetimeField as $key => $val) {
162
+                $list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
163
+            }
158
         	$list[$k]['check_status_info'] = $this->statusArr[$v['check_status']];
164
         	$list[$k]['check_status_info'] = $this->statusArr[$v['check_status']];
159
         	//期数
165
         	//期数
160
         	$plan_num = db('crm_receivables_plan')->where(['plan_id' => $v['plan_id']])->value('num');
166
         	$plan_num = db('crm_receivables_plan')->where(['plan_id' => $v['plan_id']])->value('num');
403
         $dataInfo['contract_id_info'] = $dataInfo['contract_id'] ? db('crm_contract')->where(['contract_id' => $dataInfo['contract_id']])->field('contract_id,name,money')->find() : [];  		
409
         $dataInfo['contract_id_info'] = $dataInfo['contract_id'] ? db('crm_contract')->where(['contract_id' => $dataInfo['contract_id']])->field('contract_id,name,money')->find() : [];  		
404
 		$dataInfo['receivables_id'] = $id;
410
 		$dataInfo['receivables_id'] = $id;
405
 		# 处理时间格式
411
 		# 处理时间格式
412
+        $fieldModel = new \app\admin\model\Field();
413
+        $datetimeField = $fieldModel->getFieldByFormType('crm_receivables', 'datetime'); //日期时间类型
414
+        foreach ($datetimeField as $key => $val) {
415
+            $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
416
+        }
406
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
417
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
407
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
418
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
408
 		return $dataInfo;
419
 		return $dataInfo;

+ 3
- 1
application/oa/controller/Event.php Zobrazit soubor

236
         $eventModel = model('Event');
236
         $eventModel = model('Event');
237
 
237
 
238
         $data = $eventModel->getDataById($this->param['event_id']);
238
         $data = $eventModel->getDataById($this->param['event_id']);
239
-
239
+        if(!$data['title']){
240
+            return resultArray(['error' => '日程已删除']);
241
+        }
240
         return resultArray(['data' => $data]);
242
         return resultArray(['data' => $data]);
241
     }
243
     }
242
 
244
 

+ 5
- 4
application/oa/controller/Examine.php Zobrazit soubor

468
                     $is_end = 1;
468
                     $is_end = 1;
469
                     //审批结束
469
                     //审批结束
470
                     $checkData['check_status'] = !empty($status) ? 2 : 3;
470
                     $checkData['check_status'] = !empty($status) ? 2 : 3;
471
-                    $examineData['check_user_id'] = '';
471
+//                    $examineData['check_user_id'] = '';
472
                 } else {
472
                 } else {
473
                     //修改主体相关审批信息
473
                     //修改主体相关审批信息
474
                     $examineData['check_user_id'] = arrayToString($next_user_ids);
474
                     $examineData['check_user_id'] = arrayToString($next_user_ids);
484
             }
484
             }
485
             if ($is_end == 1) {
485
             if ($is_end == 1) {
486
                 $checkData['check_status'] = !empty($status) ? 2 : 3;
486
                 $checkData['check_status'] = !empty($status) ? 2 : 3;
487
-                $examineData['check_user_id'] = '';
487
+//                $examineData['check_user_id'] = '';
488
                 $examineData['check_status'] = 2;
488
                 $examineData['check_status'] = 2;
489
             }
489
             }
490
         } else {
490
         } else {
588
         $checkData['status'] = $status;
588
         $checkData['status'] = $status;
589
 
589
 
590
         $examineData['check_status'] = 4;
590
         $examineData['check_status'] = 4;
591
-        $examineData['check_user_id'] = '';
592
-        $examineData['flow_user_id'] = '';
591
+        # 如果将审批人置空,会导致普通员工在右上角消息中无法查看审批
592
+        $examineData['check_user_id'] = $dataInfo['check_user_id'];
593
+        $examineData['flow_user_id']  = '';
593
         $resExamine = db('oa_examine')->where(['examine_id' => $examine_id])->update($examineData);
594
         $resExamine = db('oa_examine')->where(['examine_id' => $examine_id])->update($examineData);
594
         if ($resExamine) {
595
         if ($resExamine) {
595
             //将审批记录至为无效
596
             //将审批记录至为无效

+ 58
- 58
application/oa/controller/Task.php Zobrazit soubor

33
         Hook::listen('check_auth', $action);
33
         Hook::listen('check_auth', $action);
34
         $request = Request::instance();
34
         $request = Request::instance();
35
         $a = strtolower($request->action());
35
         $a = strtolower($request->action());
36
-
36
+        
37
         if (!in_array($a, $action['permission'])) {
37
         if (!in_array($a, $action['permission'])) {
38
             parent::_initialize();
38
             parent::_initialize();
39
         }
39
         }
48
             }
48
             }
49
         }
49
         }
50
     }
50
     }
51
-
51
+    
52
     //判断任务(需创建人和负责人才能编辑删除)
52
     //判断任务(需创建人和负责人才能编辑删除)
53
     public function checkSub($task_id)
53
     public function checkSub($task_id)
54
     {
54
     {
62
             exit(json_encode(['code' => 102, 'error' => '没有权限']));
62
             exit(json_encode(['code' => 102, 'error' => '没有权限']));
63
         }
63
         }
64
     }
64
     }
65
-
65
+    
66
     /**
66
     /**
67
      * 查看下属创建的任务
67
      * 查看下属创建的任务
68
      * @param   //负责和参与
68
      * @param   //负责和参与
71
      */
71
      */
72
     public function subTaskList()
72
     public function subTaskList()
73
     {
73
     {
74
-
74
+    
75
     }
75
     }
76
-
76
+    
77
     /**
77
     /**
78
      * 查看所有的项目
78
      * 查看所有的项目
79
      * @param
79
      * @param
88
         $data['count'] = $count;
88
         $data['count'] = $count;
89
         return resultArray(['data' => $data]);
89
         return resultArray(['data' => $data]);
90
     }
90
     }
91
-
91
+    
92
     /**
92
     /**
93
      * 查看某个项目下任务列表
93
      * 查看某个项目下任务列表
94
      * @param
94
      * @param
104
         $list = $taskModel->getDataList($param, $userInfo['id']);
104
         $list = $taskModel->getDataList($param, $userInfo['id']);
105
         return resultArray(['data' => $list]);
105
         return resultArray(['data' => $list]);
106
     }
106
     }
107
-
107
+    
108
     /**
108
     /**
109
      * 查看我的任务
109
      * 查看我的任务
110
      * @param
110
      * @param
137
         } else {
137
         } else {
138
             $where['t.status'] = [['=', 1], ['=', 5], 'OR'];
138
             $where['t.status'] = [['=', 1], ['=', 5], 'OR'];
139
         }
139
         }
140
-
141
         if ($param['main_user_id']) {
140
         if ($param['main_user_id']) {
142
             $where['t.main_user_id'] = $param['main_user_id'];
141
             $where['t.main_user_id'] = $param['main_user_id'];
143
         }
142
         }
154
                 $subArr[] = $v;
153
                 $subArr[] = $v;
155
                 $subArr[] = '|';
154
                 $subArr[] = '|';
156
             }
155
             }
157
-            $subValue = $subList ? arrayToString($subArr) : '';       
156
+            $subValue = $subList ? arrayToString($subArr) : '';
158
             $where['t.ishidden'] = 0;
157
             $where['t.ishidden'] = 0;
159
             $where['t.pid'] = 0;
158
             $where['t.pid'] = 0;
160
             if ($type != 0) {
159
             if ($type != 0) {
161
                 switch ($type) {
160
                 switch ($type) {
162
                     case '1' :
161
                     case '1' :
163
-                        $type = 't.main_user_id in ('.$subStr.')';
162
+                        $type = 't.main_user_id in (' . $subStr . ')';
164
                         break; //下属负责的
163
                         break; //下属负责的
165
                     case '3' :
164
                     case '3' :
166
                         //使用正则查询
165
                         //使用正则查询
167
                         // SELECT * FROM 5kcrm_task WHERE owner_user_id REGEXP '(,1,|,2,|,3,)';
166
                         // SELECT * FROM 5kcrm_task WHERE owner_user_id REGEXP '(,1,|,2,|,3,)';
168
-                        $type = $subValue ? 't.owner_user_id REGEXP "('.$subValue.')"' : '';
167
+                        $type = $subValue ? 't.owner_user_id REGEXP "(' . $subValue . ')"' : '';
169
                         break; //下属参与的
168
                         break; //下属参与的
170
                 }
169
                 }
171
             } else {
170
             } else {
172
                 if (!$subValue) {
171
                 if (!$subValue) {
173
                     $type = 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . '))';
172
                     $type = 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . '))';
174
                 } else {
173
                 } else {
175
-                    $type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "('.$subValue.')")';
174
+                    $type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "(' . $subValue . ')")';
176
                 }
175
                 }
177
             }
176
             }
178
             // $where['t.work_id'] = 0;
177
             // $where['t.work_id'] = 0;
195
                     $query->where($type);
194
                     $query->where($type);
196
                 })
195
                 })
197
                 ->count();
196
                 ->count();
198
-
199
-            $completeCount = db('task') ->alias('t')->where($where)
197
+            $completeCount = db('task')->alias('t')
200
                 ->where($map)
198
                 ->where($map)
201
                 ->where(function ($query) use ($type) {
199
                 ->where(function ($query) use ($type) {
202
                     $query->where($type);
200
                     $query->where($type);
203
-                })->where('t.status', 5)->count();
204
-
201
+                })
202
+                ->where($map)->where(['t.status' => 5, 't.ishidden' => 0, 'priority' => $priority])->count();
205
             foreach ($taskList as $k => $v) {
203
             foreach ($taskList as $k => $v) {
206
                 $temp = $v ?: [];
204
                 $temp = $v ?: [];
207
                 if ($v['pid']) {
205
                 if ($v['pid']) {
217
                 $taskList[$k]['lableList'] = $v['lable_id'] ? $lableModel->getDataByStr($v['lable_id']) : [];
215
                 $taskList[$k]['lableList'] = $v['lable_id'] ? $lableModel->getDataByStr($v['lable_id']) : [];
218
                 $taskList[$k]['main_user'] = $v['main_user_id'] ? $userModel->getUserById($v['main_user_id']) : array();
216
                 $taskList[$k]['main_user'] = $v['main_user_id'] ? $userModel->getUserById($v['main_user_id']) : array();
219
                 $taskList[$k]['relationCount'] = $taskModel->getRelationCount($v['task_id']);
217
                 $taskList[$k]['relationCount'] = $taskModel->getRelationCount($v['task_id']);
220
-
218
+                
221
                 $taskList[$k]['create_time'] = date('Y-m-d', $v['create_time']) ?: '';
219
                 $taskList[$k]['create_time'] = date('Y-m-d', $v['create_time']) ?: '';
222
                 $taskList[$k]['update_time'] = date('Y-m-d', $v['update_time']) ?: '';
220
                 $taskList[$k]['update_time'] = date('Y-m-d', $v['update_time']) ?: '';
223
                 $taskList[$k]['start_time'] = $v['start_time'] == 0 ? null : date('Y-m-d', $v['start_time']);;
221
                 $taskList[$k]['start_time'] = $v['start_time'] == 0 ? null : date('Y-m-d', $v['start_time']);;
226
                 if (!empty($v['stop_time']) && (strtotime(date('Ymd')) + 86400 > $v['stop_time'])) $is_end = 1;
224
                 if (!empty($v['stop_time']) && (strtotime(date('Ymd')) + 86400 > $v['stop_time'])) $is_end = 1;
227
                 $taskList[$k]['is_end'] = $is_end;
225
                 $taskList[$k]['is_end'] = $is_end;
228
             }
226
             }
229
-
227
+            
230
         } else {
228
         } else {
231
             $map['t.pid'] = 0;
229
             $map['t.pid'] = 0;
232
             // $map['t.work_id'] = 0;
230
             // $map['t.work_id'] = 0;
236
                         $type = 't.main_user_id =' . $userInfo['id'] . '';
234
                         $type = 't.main_user_id =' . $userInfo['id'] . '';
237
                         break; //我负责的
235
                         break; //我负责的
238
                     case '3' :
236
                     case '3' :
239
-                        $type = 't.owner_user_id like "%,'.$userInfo['id'].',%"';
237
+                        $type = 't.owner_user_id like "%,' . $userInfo['id'] . ',%"';
240
                         break; //我参与的
238
                         break; //我参与的
241
                 }
239
                 }
242
             } else {
240
             } else {
243
                 $adminIds = $userModel->getAdminId();
241
                 $adminIds = $userModel->getAdminId();
244
-                if (in_array($userInfo['id'],$adminIds)) {
245
-                    $type = 't.is_open = 1';  
242
+                if (in_array($userInfo['id'], $adminIds)) {
243
+                    $type = 't.is_open = 1';
246
                 } else {
244
                 } else {
247
-                    $type = 't.is_open = 1 AND (t.main_user_id =' . $userInfo['id'] .' OR t.owner_user_id like "%,'.$userInfo['id'].',%")';
245
+                    $type = 't.is_open = 1 AND (t.main_user_id =' . $userInfo['id'] . ' OR t.owner_user_id like "%,' . $userInfo['id'] . ',%")';
248
                 }
246
                 }
249
             }
247
             }
250
             $where['t.ishidden'] = 0;
248
             $where['t.ishidden'] = 0;
259
                 ->order('t.task_id desc')
257
                 ->order('t.task_id desc')
260
                 ->select();
258
                 ->select();
261
             $dataCount = db('task')->alias('t')->where($where)->where($type)->where($map)->count();
259
             $dataCount = db('task')->alias('t')->where($where)->where($type)->where($map)->count();
262
-            $completeCount = db('task')->alias('t')->where($where)->where($type)->where($map)->where('t.status', 5)->count();
260
+            $completeCount = db('task')->alias('t')
261
+                ->where($type)
262
+                ->where($map)->where(['t.status' => 5, 't.ishidden' => 0, 'priority' => $priority])->count();
263
             foreach ($taskList as $key => $value) {
263
             foreach ($taskList as $key => $value) {
264
                 $pname = '';
264
                 $pname = '';
265
                 if ($value['pid']) {
265
                 if ($value['pid']) {
266
-                    $pname = Db::name('Task')->where('task_id ='.$value['pid'])->value('name');
266
+                    $pname = Db::name('Task')->where('task_id =' . $value['pid'])->value('name');
267
                 }
267
                 }
268
-                $taskList[$key]['pname'] = $pname ? : '';
268
+                $taskList[$key]['pname'] = $pname ?: '';
269
                 $taskList[$key]['thumb_img'] = $value['thumb_img'] ? getFullPath($value['thumb_img']) : '';
269
                 $taskList[$key]['thumb_img'] = $value['thumb_img'] ? getFullPath($value['thumb_img']) : '';
270
-                $taskList[$key]['subcount'] = Db::name('Task')->where(['ishidden' => 0,'status' => 1,'pid' => $value['task_id']])->count(); //子任务
271
-                $taskList[$key]['subdonecount'] = Db::name('Task')->where(['ishidden' => 0,'status' => 5,'pid' => $value['task_id']])->count(); //已完成子任务
272
-                $taskList[$key]['commentcount'] = Db::name('AdminComment')->where(['type' => 'task','type_id' => $value['task_id']])->count();
273
-                $taskList[$key]['filecount'] = Db::name('WorkTaskFile')->where('task_id ='.$value['task_id'])->count();
270
+                $taskList[$key]['subcount'] = Db::name('Task')->where(['ishidden' => 0, 'status' => 1, 'pid' => $value['task_id']])->count(); //子任务
271
+                $taskList[$key]['subdonecount'] = Db::name('Task')->where(['ishidden' => 0, 'status' => 5, 'pid' => $value['task_id']])->count(); //已完成子任务
272
+                $taskList[$key]['commentcount'] = Db::name('AdminComment')->where(['type' => 'task', 'type_id' => $value['task_id']])->count();
273
+                $taskList[$key]['filecount'] = Db::name('WorkTaskFile')->where('task_id =' . $value['task_id'])->count();
274
                 $taskList[$key]['lableList'] = $value['lable_id'] ? $lableModel->getDataByStr($value['lable_id']) : [];
274
                 $taskList[$key]['lableList'] = $value['lable_id'] ? $lableModel->getDataByStr($value['lable_id']) : [];
275
-
276
-                $taskList[$key]['create_time'] =  date('Y-m-d', $value['create_time']) ?: '';
277
-                $taskList[$key]['update_time'] =  date('Y-m-d', $value['update_time']) ?: '';
278
-                $taskList[$key]['start_time'] = $value['start_time']==0?null:date('Y-m-d', $value['start_time']);;
279
-                $taskList[$key]['stop_time'] = $value['stop_time']==0?null:date('Y-m-d', $value['stop_time']);
275
+                
276
+                $taskList[$key]['create_time'] = date('Y-m-d', $value['create_time']) ?: '';
277
+                $taskList[$key]['update_time'] = date('Y-m-d', $value['update_time']) ?: '';
278
+                $taskList[$key]['start_time'] = $value['start_time'] == 0 ? null : date('Y-m-d', $value['start_time']);;
279
+                $taskList[$key]['stop_time'] = $value['stop_time'] == 0 ? null : date('Y-m-d', $value['stop_time']);
280
                 //负责人信息
280
                 //负责人信息
281
                 $taskList[$key]['main_user'] = $value['main_user_id'] ? $userModel->getDataById($value['main_user_id']) : array();
281
                 $taskList[$key]['main_user'] = $value['main_user_id'] ? $userModel->getDataById($value['main_user_id']) : array();
282
                 $taskList[$key]['relationCount'] = $taskModel->getRelationCount($value['task_id']);
282
                 $taskList[$key]['relationCount'] = $taskModel->getRelationCount($value['task_id']);
283
                 $is_end = 0;
283
                 $is_end = 0;
284
-                if (!empty($value['stop_time']) && (strtotime(date('Ymd'))+86399 > $value['stop_time'])) $is_end = 1;
284
+                if (!empty($value['stop_time']) && (strtotime(date('Ymd')) + 86399 > $value['stop_time'])) $is_end = 1;
285
                 $taskList[$key]['is_end'] = $is_end;
285
                 $taskList[$key]['is_end'] = $is_end;
286
             }
286
             }
287
         }
287
         }
288
-
288
+        
289
         $data = [];
289
         $data = [];
290
         $data['page']['list'] = $taskList ?: [];
290
         $data['page']['list'] = $taskList ?: [];
291
         $data['page']['dataCount'] = $dataCount ?: 0;
291
         $data['page']['dataCount'] = $dataCount ?: 0;
302
         }
302
         }
303
         return resultArray(['data' => $data]);
303
         return resultArray(['data' => $data]);
304
     }
304
     }
305
-
305
+    
306
     /**
306
     /**
307
      * 任务列表导出
307
      * 任务列表导出
308
      * @return \think\response\Json|void
308
      * @return \think\response\Json|void
316
         $data = $TaskLogic->excelExport($param);
316
         $data = $TaskLogic->excelExport($param);
317
         return $data;
317
         return $data;
318
     }
318
     }
319
-
319
+    
320
     /**
320
     /**
321
      * 获取任务详情
321
      * 获取任务详情
322
      * @param
322
      * @param
338
             return resultArray(['error' => $taskmodel->getError()]);
338
             return resultArray(['error' => $taskmodel->getError()]);
339
         }
339
         }
340
     }
340
     }
341
-
341
+    
342
     /**
342
     /**
343
      * 任务编辑保存
343
      * 任务编辑保存
344
      * @param
344
      * @param
365
             return resultArray(['error' => $taskModel->getError()]);
365
             return resultArray(['error' => $taskModel->getError()]);
366
         }
366
         }
367
     }
367
     }
368
-
368
+    
369
     /**
369
     /**
370
      * 解除关联关系
370
      * 解除关联关系
371
      * @param
371
      * @param
403
             return resultArray(['error' => '操作失败']);
403
             return resultArray(['error' => '操作失败']);
404
         }
404
         }
405
     }
405
     }
406
-
406
+    
407
     /**
407
     /**
408
      * 获取任务操作记录
408
      * 获取任务操作记录
409
      * @param
409
      * @param
420
         $list = $taskModel->getTaskLogList($param) ?: [];
420
         $list = $taskModel->getTaskLogList($param) ?: [];
421
         return resultArray(['data' => $list]);
421
         return resultArray(['data' => $list]);
422
     }
422
     }
423
-
423
+    
424
     /**
424
     /**
425
      * 优先级设置
425
      * 优先级设置
426
      * @param
426
      * @param
432
         $param = $this->param;
432
         $param = $this->param;
433
         $userInfo = $this->userInfo;
433
         $userInfo = $this->userInfo;
434
         $param['create_user_id'] = $userInfo['id'];
434
         $param['create_user_id'] = $userInfo['id'];
435
-
435
+        
436
         if (!isset($param['priority_id']) || !$param['task_id']) {
436
         if (!isset($param['priority_id']) || !$param['task_id']) {
437
             return resultArray(['error' => '参数错误']);
437
             return resultArray(['error' => '参数错误']);
438
         }
438
         }
446
             return resultArray(['error' => '操作失败']);
446
             return resultArray(['error' => '操作失败']);
447
         }
447
         }
448
     }
448
     }
449
-
449
+    
450
     /**
450
     /**
451
      * 参与人/参与部门编辑
451
      * 参与人/参与部门编辑
452
      * @param
452
      * @param
481
         }
481
         }
482
         return resultArray(['error' => '修改失败']);
482
         return resultArray(['error' => '修改失败']);
483
     }
483
     }
484
-
484
+    
485
     /**
485
     /**
486
      * 单独删除参与人
486
      * 单独删除参与人
487
      * @param
487
      * @param
504
             return resultArray(['error' => $taskModel->getError()]);
504
             return resultArray(['error' => $taskModel->getError()]);
505
         }
505
         }
506
     }
506
     }
507
-
507
+    
508
     /**
508
     /**
509
      * 单独删除参与部门
509
      * 单独删除参与部门
510
      * @param
510
      * @param
527
             return resultArray(['error' => $taskModel->getError()]);
527
             return resultArray(['error' => $taskModel->getError()]);
528
         }
528
         }
529
     }
529
     }
530
-
530
+    
531
     /**
531
     /**
532
      * 设置任务截止时间
532
      * 设置任务截止时间
533
      * @param
533
      * @param
553
             return resultArray(['error' => $taskModel->getError()]);
553
             return resultArray(['error' => $taskModel->getError()]);
554
         }
554
         }
555
     }
555
     }
556
-
556
+    
557
     /**
557
     /**
558
      * 添加删除标签
558
      * 添加删除标签
559
      * @param
559
      * @param
584
             return resultArray(['error' => $taskModel->getError()]);
584
             return resultArray(['error' => $taskModel->getError()]);
585
         }
585
         }
586
     }
586
     }
587
-
587
+    
588
     /**
588
     /**
589
      * 任务标题描述更新
589
      * 任务标题描述更新
590
      * @param
590
      * @param
606
             return resultArray(['error' => $taskModel->getError()]);
606
             return resultArray(['error' => $taskModel->getError()]);
607
         }
607
         }
608
     }
608
     }
609
-
609
+    
610
     /**
610
     /**
611
      * 任务标记结束
611
      * 任务标记结束
612
      * @param
612
      * @param
646
         }
646
         }
647
         return resultArray(['data' => '操作成功']);
647
         return resultArray(['data' => '操作成功']);
648
     }
648
     }
649
-
649
+    
650
     /**
650
     /**
651
      * 日历任务展示/月份
651
      * 日历任务展示/月份
652
      * @param
652
      * @param
666
             return resultArray(['error' => $taskModel->getError()]);
666
             return resultArray(['error' => $taskModel->getError()]);
667
         }
667
         }
668
     }
668
     }
669
-
669
+    
670
     /**
670
     /**
671
      * 添加任务
671
      * 添加任务
672
      * @param
672
      * @param
689
             return resultArray(['error' => $taskModel->getError()]);
689
             return resultArray(['error' => $taskModel->getError()]);
690
         }
690
         }
691
     }
691
     }
692
-
692
+    
693
     /**
693
     /**
694
      * 删除主负责人
694
      * 删除主负责人
695
      * @param
695
      * @param
717
         }
717
         }
718
         return resultArray(['data' => '操作成功']);
718
         return resultArray(['data' => '操作成功']);
719
     }
719
     }
720
-
720
+    
721
     /**
721
     /**
722
      * 重命名任务
722
      * 重命名任务
723
      * @param
723
      * @param
740
             return resultArray(['error' => $workModel->getError()]);
740
             return resultArray(['error' => $workModel->getError()]);
741
         }
741
         }
742
     }
742
     }
743
-
743
+    
744
     /**
744
     /**
745
      * 删除任务
745
      * 删除任务
746
      * @param
746
      * @param
765
             return resultArray(['error' => $workModel->getError()]);
765
             return resultArray(['error' => $workModel->getError()]);
766
         }
766
         }
767
     }
767
     }
768
-
768
+    
769
     /**
769
     /**
770
      * 归档任务 改变状态
770
      * 归档任务 改变状态
771
      * @param
771
      * @param
793
             return resultArray(['error' => $taskModel->getError()]);
793
             return resultArray(['error' => $taskModel->getError()]);
794
         }
794
         }
795
     }
795
     }
796
-
796
+    
797
     /**
797
     /**
798
      * 恢复归档任务
798
      * 恢复归档任务
799
      * @param
799
      * @param
821
             return resultArray(['error' => $taskModel->getError()]);
821
             return resultArray(['error' => $taskModel->getError()]);
822
         }
822
         }
823
     }
823
     }
824
-
824
+    
825
     /**
825
     /**
826
      * 归档任务列表
826
      * 归档任务列表
827
      * @param
827
      * @param

+ 314
- 38
application/oa/logic/ExamineLogic.php Zobrazit soubor

10
 class ExamineLogic extends Common
10
 class ExamineLogic extends Common
11
 {
11
 {
12
     private $statusArr = ['0' => '待审核', '1' => '审核中', '2' => '审核通过', '3' => '已拒绝', '4' => '已撤回'];
12
     private $statusArr = ['0' => '待审核', '1' => '审核中', '2' => '审核通过', '3' => '已拒绝', '4' => '已撤回'];
13
-
13
+    
14
+    public function getDataList($request)
15
+    {
16
+        $userModel = new \app\admin\model\User();
17
+        $fileModel = new \app\admin\model\File();
18
+        $recordModel = new \app\admin\model\Record();
19
+        
20
+        $examine_by = $request['examine_by']; //1待我审批 2我已审批 all 全部
21
+        $user_id = $request['user_id'];
22
+        $bi = $request['bi_types'];
23
+        $check_status = $request['check_status']; //0 待审批 2 审批通过 4 审批拒绝 all 全部
24
+        unset($request['by']);
25
+        unset($request['bi_types']);
26
+        unset($request['user_id']);
27
+        unset($request['check_status']);
28
+        unset($request['examine_by']);
29
+        $request = $this->fmtRequest($request);
30
+        $map = $request['map'] ?: [];
31
+        if (isset($map['search']) && $map['search']) {
32
+            //普通筛选
33
+            $map['examine.content'] = ['like', '%' . $map['search'] . '%'];
34
+        } else {
35
+            $map = where_arr($map, 'oa', 'examine', 'index'); //高级筛选
36
+        }
37
+        unset($map['search']);
38
+        //审批类型
39
+        $map['examine.category_id'] = $map['examine.category_id'] ?: array('gt', 0);
40
+        
41
+        $map_str = '';
42
+        $logmap = '';
43
+        switch ($examine_by) {
44
+            case 'all' :
45
+                //如果超管则能看到全部
46
+                if (!isSuperAdministrators($user_id)) {
47
+                    $map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " ) OR ( flow_user_id LIKE '%," . $user_id . ",%'  OR `flow_user_id` = " . $user_id . " ) )";
48
+                }
49
+                break;
50
+            case '1' :
51
+                $map['check_user_id'] = [['like', '%,' . $user_id . ',%']];
52
+                break; //待审
53
+            case '2' :
54
+                $map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " )
55
+                 OR ( flow_user_id LIKE '%," . $user_id . ",%'  OR `flow_user_id` = " . $user_id . " ) )";
56
+//                $map['flow_user_id'] = [['like', '%,' . $user_id . ',%'], ['eq', $user_id], 'or'];
57
+                break; //已审
58
+            default:
59
+                $map['examine.create_user_id'] = $user_id;
60
+                break;
61
+        }
62
+        $order = 'examine.create_time desc,examine.update_time desc';
63
+        //发起时间
64
+        if ($map['examine.between_time'][0] && $map['examine.between_time'][1]) {
65
+            $start_time = $map['examine.between_time'][0];
66
+            $end_time = $map['examine.between_time'][1];
67
+            $map['examine.create_time'] = array('between', array($start_time, $end_time));
68
+        }
69
+        unset($map['examine.between_time']);
70
+        
71
+        //审核状态 0 待审批 2 审批通过 4 审批拒绝 all 全部
72
+        if (isset($check_status)) {
73
+            if ($check_status == 'all') {
74
+                $map['examine.check_status'] = ['egt', 0];
75
+                if (isSuperAdministrators($user_id)) {
76
+                    unset($map['examine.create_user_id']);
77
+                }
78
+            } elseif ($check_status == 4) {
79
+                $map['examine.check_status'] = ['eq', 3];
80
+            } elseif ($check_status == 0) {
81
+                $map['examine.check_status'] = ['<=', 1];
82
+            } else {
83
+                $map['examine.check_status'] = $check_status;
84
+            }
85
+        } else {
86
+            if ($examine_by == 'all') {
87
+                $map['examine.check_status'] = ['egt', 0];
88
+            } elseif ($examine_by == 1) {
89
+                $map['examine.check_status'] = ['elt', 1];
90
+            } elseif ($examine_by == 2) {
91
+                $map['examine.check_status'] = ['egt', 2];
92
+            }
93
+        }
94
+        $join = [
95
+            ['__ADMIN_USER__ user', 'user.id = examine.create_user_id', 'LEFT'],
96
+            ['__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT'],
97
+        ];
98
+        $list_view = db('oa_examine')
99
+            ->alias('examine')
100
+            ->where($map_str)
101
+            ->where($map)
102
+            ->join($join);
103
+        $res = [];
104
+        $list = $list_view
105
+            ->page($request['page'], $request['limit'])
106
+            ->field('examine.*,user.realname,user.thumb_img,examine_category.title as category_name,examine_category.category_id as examine_config,examine_category.icon as examineIcon')
107
+            ->order($order)
108
+            ->select();
109
+        foreach ($list as $k => $v) {
110
+            $causeCount = 0;
111
+            $causeTitle = '';
112
+            $duration = $v['duration'] ?: '0.0';
113
+            $money = $v['money'] ?: '0.00';
114
+            
115
+            $list[$k]['causeTitle'] = $causeTitle;
116
+            $list[$k]['causeCount'] = $causeCount ?: 0;
117
+            $item = db('oa_examine_travel')->where(['examine_id' => $v['examine_id']])->select();
118
+            if ($item) {
119
+                foreach ($item as $key => $value) {
120
+                    if($v['check_status']==4){
121
+                        $usernames = '';
122
+                    }else{
123
+                        $usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
124
+                    }
125
+                 
126
+                    //关联业务
127
+                    $relationArr = [];
128
+                    $relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
129
+                    $item[$key]['relation'] = arrayToString(array_column($relationArr['businessList'], 'name')) . ' ' .
130
+                        arrayToString(array_column($relationArr['contactsList'], 'name')) . ' ' .
131
+                        arrayToString(array_column($relationArr['contractList'], 'name')) . ' ' .
132
+                        arrayToString(array_column($relationArr['customerList'], 'name'));
133
+                    $res[] = [
134
+                        'category_name' => $v['category_name'],
135
+                        'create_time' => !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null,
136
+                        'realname' => $v['realname'],
137
+                        'check_status_info' => $this->statusArr[(int)$v['check_status']],
138
+                        'examine_name' => implode($usernames, ','),
139
+                        'content' => $v['content'],
140
+                        'remark' => $v['remark'],
141
+                        'duration' => $v['duration'],
142
+                        'vehicle' => $value['vehicle'],
143
+                        'trip' => $value['trip'],
144
+                        'money' => $value['money'],
145
+                        'traffic' => $value['traffic'],
146
+                        'stay' => $value['stay'],
147
+                        'diet' => $value['diet'],
148
+                        'other' => $value['other'],
149
+                        'start_address' => $value['start_address'],
150
+                        'end_address' => $value['end_address'],
151
+                        'start_time' => !empty($value['start_time']) ? date('Y-m-d H:i:s', $value['start_time']) : null,
152
+                        'end_time' => !empty($value['end_time']) ? date('Y-m-d H:i:s', $value['end_time']) : null,
153
+                        'description' => $value['description'],
154
+                        'replyList' => str_replace(',', ' ', $item[$key]['relation']),
155
+                    ];
156
+                }
157
+            } else {
158
+                $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
159
+                $list[$k]['start_time'] = !empty($v['start_time']) ? date('Y-m-d H:i:s', $v['start_time']) : null;
160
+                $list[$k]['end_time'] = !empty($v['end_time']) ? date('Y-m-d H:i:s', $v['end_time']) : null;
161
+                if($v['check_status']==4){
162
+                    $usernames = '';
163
+                }else{
164
+                    $usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
165
+                }
166
+                //关联业务
167
+                $relationArr = [];
168
+                $relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
169
+                $list[$k]['relation'] = arrayToString(array_column($relationArr['businessList'], 'name')) . ' ' .
170
+                    arrayToString(array_column($relationArr['contactsList'], 'name')) . ' ' .
171
+                    arrayToString(array_column($relationArr['contractList'], 'name')) . ' ' .
172
+                    arrayToString(array_column($relationArr['customerList'], 'name'));
173
+                $res[] = [
174
+                    'category_name' => $v['category_name'],
175
+                    'create_time' => !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null,
176
+                    'realname' => $v['realname'],
177
+                    'check_status_info' => $this->statusArr[(int)$v['check_status']],
178
+                    'examine_name' => implode($usernames, ','),
179
+                    'content' => $v['content'],
180
+                    'remark' => $v['remark'],
181
+                    'duration' => $v['duration'],
182
+                    'vehicle' => '',
183
+                    'money' => $v['money'],
184
+                    'traffic' => '',
185
+                    'stay' => '',
186
+                    'diet' => '',
187
+                    'other' => '',
188
+                    'start_address' => '',
189
+                    'end_address' => '',
190
+                    'start_time' => !empty($v['start_time']) ? date('Y-m-d H:i:s', $v['start_time']) : null,
191
+                    'end_time' => !empty($v['end_time']) ? date('Y-m-d H:i:s', $v['end_time']) : null,
192
+                    'description' => '',
193
+                    'replyList' => str_replace(',', ' ', $item[$key]['relation']),
194
+                ];
195
+            }
196
+        }
197
+        return $res;
198
+    }
199
+    
14
     /**
200
     /**
15
      * 审批导出
201
      * 审批导出
16
      * @param $param
202
      * @param $param
19
     public function excelExport($param)
205
     public function excelExport($param)
20
     {
206
     {
21
         $excelModel = new \app\admin\model\Excel();
207
         $excelModel = new \app\admin\model\Excel();
22
-        $field_list1 = [
23
-            array('name' => '审批类型', 'field' => 'category_name', 'form_type' => 'text'),
24
-            array('name' => '创建时间', 'field' => 'create_time', 'form_type' => ''),
25
-            array('name' => '创建人', 'field' => 'create_user_id', 'form_type' => 'user'),
26
-            array('name' => '状态', 'field' => 'check_status_info','form_type' => ''),
27
-            array('name' => '当前审批人', 'field' => 'check_user_id','form_type' => 'userStr'),
28
-            // array('name' => '下一审批人', 'field' => 'last_user_id','form_type' => 'user'),
29
-            // array('name' => '关联业务', 'field' => 'relation','form_type' => ''),
30
-        ];
31
-        // 导出的字段列表
32
-        $fieldModel = new \app\admin\model\Field();
33
-        $field_list = $fieldModel->getIndexFieldConfig('oa_examine', $param['user_id'], $param['category_id']);
208
+        $data = $this->getDataList($param);
209
+        $list = [];
210
+        switch ($param['category_id']) {
211
+            case '1' :
212
+                $field_list = [
213
+                    '0' => ['name' => '审批类型', 'field' => 'category_name'],
214
+                    '1' => ['name' => '创建时间', 'field' => 'create_time'],
215
+                    '2' => ['name' => '创建人', 'field' => 'realname'],
216
+                    '3' => ['name' => '状态', 'field' => 'check_status_info'],
217
+                    '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
218
+                    '5' => ['name' => '备注', 'field' => 'description'],
219
+                    '6' => ['name' => '关联业务', 'field' => 'replyList'],
220
+                ];
221
+                break;
222
+            case '2' :
223
+                $field_list = [
224
+                    '0' => ['name' => '审批类型', 'field' => 'category_name'],
225
+                    '1' => ['name' => '创建时间', 'field' => 'create_time'],
226
+                    '2' => ['name' => '创建人', 'field' => 'realname'],
227
+                    '3' => ['name' => '状态', 'field' => 'check_status_info'],
228
+                    '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
229
+                    '5' => ['name' => '审批内容', 'field' => 'content'],
230
+                    '6' => ['name' => '开始时间', 'field' => 'start_time'],
231
+                    '7' => ['name' => '结束时间', 'field' => 'end_time'],
232
+                    '8' => ['name' => '时长', 'field' => 'duration'],
233
+                    '9' => ['name' => '备注', 'field' => 'description'],
234
+                    '10' => ['name' => '关联业务', 'field' => 'replyList'],
235
+                ];
236
+                break;
237
+            case '3' :
238
+                $field_list = [
239
+                    '0' => ['name' => '审批类型', 'field' => 'category_name'],
240
+                    '1' => ['name' => '创建时间', 'field' => 'create_time'],
241
+                    '2' => ['name' => '创建人', 'field' => 'realname'],
242
+                    '3' => ['name' => '状态', 'field' => 'check_status_info'],
243
+                    '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
244
+                    '5' => ['name' => '出差事由', 'field' => 'content'],
245
+                    '6' => ['name' => '备注', 'field' => 'remark'],
246
+                    '7' => ['name' => '出差总天数', 'field' => 'duration'],
247
+                    '8' => ['name' => '交通工具', 'field' => 'vehicle'],
248
+                    '9' => ['name' => '单程往返', 'field' => 'trip'],
249
+                    '10' => ['name' => '出发城市', 'field' => 'start_address'],
250
+                    '11' => ['name' => '目的城市', 'field' => 'end_address'],
251
+                    '12' => ['name' => '开始时间', 'field' => 'start_time'],
252
+                    '13' => ['name' => '结束时间', 'field' => 'end_time'],
253
+                    '14' => ['name' => '出差备注', 'field' => 'description'],
254
+                    '15' => ['name' => '时长', 'field' => 'duration'],
255
+                    '16' => ['name' => '关联业务', 'field' => 'replyList'],
256
+                ];
257
+                break;
258
+            case '4' :
259
+                $field_list = [
260
+                    '0' => ['name' => '审批类型', 'field' => 'category_name'],
261
+                    '1' => ['name' => '创建时间', 'field' => 'create_time'],
262
+                    '2' => ['name' => '创建人', 'field' => 'realname',],
263
+                    '3' => ['name' => '状态', 'field' => 'check_status_info'],
264
+                    '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
265
+                    '5' => ['name' => '加班原因', 'field' => 'content'],
266
+                    '6' => ['name' => '开始时间', 'field' => 'start_time'],
267
+                    '7' => ['name' => '结束时间', 'field' => 'end_time'],
268
+                    '8' => ['name' => '加班总天数', 'field' => 'duration'],
269
+                    '9' => ['name' => '备注', 'field' => 'description'],
270
+                    '10' => ['name' => '关联业务', 'field' => 'replyList'],
271
+                ];
272
+                break;
273
+            case '5':
274
+                $field_list = [
275
+                    '0' => ['name' => '审批类型', 'field' => 'category_name'],
276
+                    '1' => ['name' => '创建时间', 'field' => 'create_time'],
277
+                    '2' => ['name' => '创建人', 'field' => 'realname'],
278
+                    '3' => ['name' => '状态', 'field' => 'check_status_info'],
279
+                    '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
280
+                    '5' => ['name' => '差旅内容', 'field' => 'content'],
281
+                    '6' => ['name' => '报销总金额', 'field' => 'money'],
282
+                    '7' => ['name' => '备注', 'field' => 'remark'],
283
+                    '8' => ['name' => '出发城市', 'field' => 'start_address'],
284
+                    '9' => ['name' => '目的城市', 'field' => 'end_address'],
285
+                    '10' => ['name' => '开始时间', 'field' => 'start_time'],
286
+                    '11' => ['name' => '结束时间', 'field' => 'end_time'],
287
+                    '12' => ['name' => '交通费', 'field' => 'traffic'],
288
+                    '13' => ['name' => '住宿费', 'field' => 'stay'],
289
+                    '14' => ['name' => '餐饮费', 'field' => 'diet'],
290
+                    '15' => ['name' => '其他费用', 'field' => 'other'],
291
+                    '16' => ['name' => '合计', 'field' => 'money'],
292
+                    '17' => ['name' => '费用明细描述', 'field' => 'description'],
293
+                    '18' => ['name' => '关联业务', 'field' => 'relation'],
294
+                ];
295
+                break;
296
+            case '6' :
297
+                $field_list = [
298
+                    '0' => ['name' => '审批类型', 'field' => 'category_name'],
299
+                    '1' => ['name' => '创建时间', 'field' => 'create_time'],
300
+                    '2' => ['name' => '创建人', 'field' => 'realname'],
301
+                    '3' => ['name' => '状态', 'field' => 'check_status_info'],
302
+                    '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
303
+                    '5' => ['name' => '借款事由', 'field' => 'content'],
304
+                    '6' => ['name' => '开始时间', 'field' => 'start_time'],
305
+                    '7' => ['name' => '结束时间', 'field' => 'end_time'],
306
+                    '8' => ['name' => '借款金额', 'field' => 'money'],
307
+                    '9' => ['name' => '备注', 'field' => 'description'],
308
+                    '10' => ['name' => '关联业务', 'field' => 'replyList'],
309
+                ];
310
+                break;
311
+            default :
312
+                $field_list = [
313
+                    '0' => ['name' => '审批类型', 'field' => 'category_name'],
314
+                    '1' => ['name' => '创建时间', 'field' => 'create_time'],
315
+                    '2' => ['name' => '创建人', 'field' => 'realname'],
316
+                    '3' => ['name' => '状态', 'field' => 'check_status_info'],
317
+                    '4' => ['name' => '当前审批人', 'field' => 'examine_name'],
318
+                    '5' => ['name' => '备注', 'field' => 'description'],
319
+                    '6' => ['name' => '关联业务', 'field' => 'replyList'],
320
+                    
321
+                ];
322
+        }
34
         $file_name = 'oa_examine';
323
         $file_name = 'oa_examine';
35
-        $temp_file = $param['temp_file'];
36
-        unset($param['temp_file']);
37
-        $page = $param['page'] ?: 1;
38
-        $model = model('Examine');
39
-        $field_list = array_merge_recursive($field_list1, $field_list);
40
-
41
-        return $excelModel->batchExportCsv($file_name, $temp_file, $field_list, $page, function ($page, $limit) use ($model, $param, $field_list) {
42
-            $param['page'] = $page;
43
-            $param['limit'] = $limit;
44
-            $data = $model->getDataList($param);
45
-            // $newData['list'] = $model->exportHandle($data['page']['list'], $field_list, 'oa_examine');
46
-            $newData['list'] = $data['page']['list'];
47
-            return $newData;
48
-        });
324
+        return $excelModel->dataExportCsv($file_name, $field_list, $data);
49
     }
325
     }
50
-
326
+    
51
     /**
327
     /**
52
      * 审批数据
328
      * 审批数据
53
      * @param $param
329
      * @param $param
65
                 $query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
341
                 $query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
66
             };
342
             };
67
         } elseif ($param['status'] == 1) {
343
         } elseif ($param['status'] == 1) {
68
-            $where['a.check_status'] = ['in', [2,3]];
69
-            $whereOr = function ($query) use ( $user_id) {
70
-                $query->where('a.check_user_id',['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
344
+            $where['a.check_status'] = ['in', [2, 3]];
345
+            $whereOr = function ($query) use ($user_id) {
346
+                $query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
71
             };
347
             };
72
         } elseif ($param['status'] == 3) {
348
         } elseif ($param['status'] == 3) {
73
             $where['a.check_status'] = ['lt', 5];
349
             $where['a.check_status'] = ['lt', 5];
98
                     $list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
374
                     $list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
99
                     $list[$k]['customer_id_info']['name'] = $v['customer_name'];
375
                     $list[$k]['customer_id_info']['name'] = $v['customer_name'];
100
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
376
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
101
-
377
+                    
102
                 }
378
                 }
103
                 $dataCount = db('crm_contract')
379
                 $dataCount = db('crm_contract')
104
                     ->alias('a')
380
                     ->alias('a')
135
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
411
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
136
                     $list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
412
                     $list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
137
                     $list[$k]['contract_id_info']['name'] = $v['contract_name'];
413
                     $list[$k]['contract_id_info']['name'] = $v['contract_name'];
138
-
414
+                    
139
                 }
415
                 }
140
                 break;
416
                 break;
141
             case '3':
417
             case '3':
153
                     ->select();
429
                     ->select();
154
                 foreach ($list as $k => $v) {
430
                 foreach ($list as $k => $v) {
155
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
431
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
156
-
432
+                    
157
                 }
433
                 }
158
                 $dataCount = db('crm_invoice')
434
                 $dataCount = db('crm_invoice')
159
                     ->alias('a')
435
                     ->alias('a')
162
                     ->where($whereOr)
438
                     ->where($whereOr)
163
                     ->count();
439
                     ->count();
164
                 break;
440
                 break;
165
-
441
+            
166
         }
442
         }
167
-
443
+        
168
         foreach ($list as $key => $v) {
444
         foreach ($list as $key => $v) {
169
             $list[$key]['create_time'] = date('Y-m-d H:i:s', $v['create_time']) ?: '';
445
             $list[$key]['create_time'] = date('Y-m-d H:i:s', $v['create_time']) ?: '';
170
         }
446
         }
171
-
447
+        
172
         $data = [];
448
         $data = [];
173
         $data['page']['list'] = $list;
449
         $data['page']['list'] = $list;
174
         $data['page']['dataCount'] = $dataCount ?: 0;
450
         $data['page']['dataCount'] = $dataCount ?: 0;
184
         }
460
         }
185
         return $data;
461
         return $data;
186
     }
462
     }
187
-
463
+    
188
 }
464
 }

+ 31
- 46
application/oa/logic/LogLogic.php Zobrazit soubor

38
     public function getDataList($request)
38
     public function getDataList($request)
39
     {
39
     {
40
         $userModel = new \app\admin\model\User();
40
         $userModel = new \app\admin\model\User();
41
-        $structureModel = new \app\admin\model\Structure();
42
-        $fileModel = new \app\admin\model\File();
43
         $commonModel = new \app\admin\model\Comment();
41
         $commonModel = new \app\admin\model\Comment();
44
-        $BusinessModel = new \app\crm\model\Business();
45
-        $ContactsModel = new \app\crm\model\Contacts();
46
-        $ContractModel = new \app\crm\model\Contract();
47
-        $CustomerModel = new \app\crm\model\Customer();
48
         $recordModel = new \app\admin\model\Record();
42
         $recordModel = new \app\admin\model\Record();
49
-
50
         $user_id = $request['read_user_id'];
43
         $user_id = $request['read_user_id'];
51
         $by = $request['by'] ?: '';
44
         $by = $request['by'] ?: '';
52
 
45
 
78
         }
71
         }
79
         $requestData = $this->requestData();
72
         $requestData = $this->requestData();
80
         //获取权限范围内的员工
73
         //获取权限范围内的员工
74
+        //获取权限范围内的员工
81
         $auth_user_ids = getSubUserId();
75
         $auth_user_ids = getSubUserId();
82
-        if ($request['send_user_id'] && !in_array(trim(arrayToString($request['send_user_id']), ','), $auth_user_ids)) {
83
-            $map['log.create_user_id'] = $user_id;
84
-        } else {
85
-            if ($request['send_user_id'] && in_array(trim(arrayToString($request['send_user_id']), ','), $auth_user_ids)) {
86
-                $map['log.create_user_id'] = ['in', trim(arrayToString($request['send_user_id']), ',')];
87
-                $map['log.send_user_ids'] = ['like', '%,' . $request['read_user_id'] . ',%'];
88
-            } else {
89
-                $dataWhere['user_id'] = $user_id;
90
-                $dataWhere['structure_id'] = $request['structure_id'];
91
-                $dataWhere['auth_user_ids'] = $auth_user_ids;
92
-                $logMap = '';
93
-                switch ($by) {
94
-                    case 'me' :
95
-                        $map['log.create_user_id'] = $user_id;
96
-                        break;
97
-                    case 'other':
98
-                        $logMap = function ($query) use ($dataWhere) {
99
-                            $query->where('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
100
-                                ->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
101
-                        };
102
-                        break;
103
-                    default :
104
-                        $logMap = function ($query) use ($dataWhere) {
105
-                            $query->where('log.create_user_id', array('in', implode(',', $dataWhere['auth_user_ids'])))
106
-                                ->whereOr('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
107
-                                ->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
108
-                        };
109
-                        break;
110
-                }
111
-            }
76
+        $dataWhere['user_id'] = $user_id;
77
+        $dataWhere['structure_id'] = $request['structure_id'];
78
+        $dataWhere['auth_user_ids'] = $auth_user_ids;
79
+        $logMap = '';
80
+        if ($request['send_user_id'] != '') {
81
+            $map['log.create_user_id'] = ['in', trim(arrayToString($request['send_user_id']), ',')];
82
+        }
83
+        switch ($by) {
84
+            case 'me' :
85
+                $map['log.create_user_id'] = $user_id;
86
+                break;
87
+            case 'other':
88
+                $logMap = function ($query) use ($dataWhere) {
89
+                    $query->where('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
90
+                        ->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
91
+                };
92
+                break;
93
+            default :
94
+                $logMap = function ($query) use ($dataWhere) {
95
+                    $query->where('log.create_user_id', array('in', implode(',', $dataWhere['auth_user_ids'])))
96
+                        ->whereOr('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
97
+                        ->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
98
+                };
99
+                break;
112
         }
100
         }
113
         $list = Db::name('OaLog')
101
         $list = Db::name('OaLog')
114
             ->where($map)
102
             ->where($map)
103
+            ->where($logMap)
115
             ->where($searchMap)
104
             ->where($searchMap)
116
             ->alias('log')
105
             ->alias('log')
117
             ->join('__ADMIN_USER__ user', 'user.id = log.create_user_id', 'LEFT')
106
             ->join('__ADMIN_USER__ user', 'user.id = log.create_user_id', 'LEFT')
118
-            ->page($request['page'], $request['limit'])
119
             ->field('log.*,user.realname')
107
             ->field('log.*,user.realname')
120
             ->order('log.update_time desc')
108
             ->order('log.update_time desc')
121
             ->select();
109
             ->select();
651
 
639
 
652
     /**
640
     /**
653
      * 销售简报跟进数量统计
641
      * 销售简报跟进数量统计
654
-     * @param $param
655
-     * @return array
656
-     * @throws \think\db\exception\DataNotFoundException
657
-     * @throws \think\db\exception\ModelNotFoundException
658
-     * @throws \think\exception\DbException
642
+     *
643
+     * @param $param 参数
659
      */
644
      */
660
     public function activityCount($param)
645
     public function activityCount($param)
661
     {
646
     {
665
         if (empty($param['log_id'])) {
650
         if (empty($param['log_id'])) {
666
             $between_time = [$start_time['start_time'], $start_time['end_time']];
651
             $between_time = [$start_time['start_time'], $start_time['end_time']];
667
             $map['create_time'] = array('between', $between_time);
652
             $map['create_time'] = array('between', $between_time);
653
+            $map['create_user_id'] =$user_id;
668
         } else {
654
         } else {
669
-
670
             $start_time = strtotime(date("Y-m-d", $item['create_time']));
655
             $start_time = strtotime(date("Y-m-d", $item['create_time']));
671
             $end_time = strtotime(date("Y-m-d H:i:s", $item['create_time']));
656
             $end_time = strtotime(date("Y-m-d H:i:s", $item['create_time']));
672
             $between_time = [$start_time, $end_time];
657
             $between_time = [$start_time, $end_time];
673
             $map['create_time'] = array('between', $between_time);
658
             $map['create_time'] = array('between', $between_time);
659
+            $map['create_user_id'] =  $item['create_user_id'];
674
         }
660
         }
675
         $map['status']=1;
661
         $map['status']=1;
676
         $typesList = ['1', '2', '3', '5', '6'];
662
         $typesList = ['1', '2', '3', '5', '6'];
677
             foreach ($typesList as $k => $v) {
663
             foreach ($typesList as $k => $v) {
678
-                $activityData = db('crm_activity')->where($map)->where(['create_user_id' => $item['create_user_id'], 'type' => 1, 'activity_type' => $v])->count();
664
+                $activityData = db('crm_activity')->where($map)->where(['type' => 1, 'activity_type' => $v])->count();
679
                 if($v==1){
665
                 if($v==1){
680
                     $arr[$k]['types'] ='crm_leads';
666
                     $arr[$k]['types'] ='crm_leads';
681
                     $arr[$k]['activity_type'] =1;
667
                     $arr[$k]['activity_type'] =1;
693
                     $arr[$k]['activity_type'] =6;
679
                     $arr[$k]['activity_type'] =6;
694
                 }
680
                 }
695
                 $arr[$k]['dataCount'] = $activityData;
681
                 $arr[$k]['dataCount'] = $activityData;
696
-
697
             }
682
             }
698
             $data = $arr;
683
             $data = $arr;
699
         return $data;
684
         return $data;

+ 39
- 41
application/oa/logic/TaskLogic.php Zobrazit soubor

15
         $userModel = new \app\admin\model\User();
15
         $userModel = new \app\admin\model\User();
16
         $taskModel = new TaskModel();
16
         $taskModel = new TaskModel();
17
         $recordModel = new \app\admin\model\Record();
17
         $recordModel = new \app\admin\model\Record();
18
-        $str = ','.$param['user_id'].',';
19
-
18
+        $str = ',' . $param['user_id'] . ',';
19
+        
20
         //自定义时间
20
         //自定义时间
21
         $map['t.stop_time'] = $param['dueDate'] ? strtotime($param['dueDate'] . ' +1 month -1 day') : ['>=', 0];
21
         $map['t.stop_time'] = $param['dueDate'] ? strtotime($param['dueDate'] . ' +1 month -1 day') : ['>=', 0];
22
         $search = $param['search'];
22
         $search = $param['search'];
34
         } else {
34
         } else {
35
             $where['t.status'] = [['=', 1], ['=', 5], 'OR'];
35
             $where['t.status'] = [['=', 1], ['=', 5], 'OR'];
36
         }
36
         }
37
-
37
+        
38
         if ($param['main_user_id']) {
38
         if ($param['main_user_id']) {
39
             $where['t.main_user_id'] = $param['main_user_id'];
39
             $where['t.main_user_id'] = $param['main_user_id'];
40
         }
40
         }
41
         //项目id
41
         //项目id
42
         $priority = ($param['priority'] || $param['priority'] == '0') ? $param['priority'] : ['in', [0, 1, 2, 3]];
42
         $priority = ($param['priority'] || $param['priority'] == '0') ? $param['priority'] : ['in', [0, 1, 2, 3]];
43
-        $where['t.priority'] = $priority;        
44
-
43
+        $where['t.priority'] = $priority;
44
+        
45
         if ($param['work_id'] != 0) {
45
         if ($param['work_id'] != 0) {
46
             $where['t.work_id'] = $param['work_id'];
46
             $where['t.work_id'] = $param['work_id'];
47
             $taskList = db('task')
47
             $taskList = db('task')
56
                 $where = [];
56
                 $where = [];
57
                 $where['ishidden'] = 0;
57
                 $where['ishidden'] = 0;
58
                 $where['pid'] = 0;
58
                 $where['pid'] = 0;
59
-                $where['whereStr'] = ' ( task.create_user_id =' . $param['user_id'] . ' or (  task.owner_user_id like "%,'.$param['user_id'].',%") or ( task.main_user_id = '.$param['user_id'].' ) )';
59
+                $where['whereStr'] = ' ( task.create_user_id =' . $param['user_id'] . ' or (  task.owner_user_id like "%,' . $param['user_id'] . ',%") or ( task.main_user_id = ' . $param['user_id'] . ' ) )';
60
                 if (!empty($this->param['search'])) {
60
                 if (!empty($this->param['search'])) {
61
-                    $where['taskSearch'] = ' and (task.name like "%'.$this->param['search'].'%" OR task.description like "%'.$this->param['search'].'%")';
61
+                    $where['taskSearch'] = ' and (task.name like "%' . $this->param['search'] . '%" OR task.description like "%' . $this->param['search'] . '%")';
62
                 }
62
                 }
63
                 # 截止日期
63
                 # 截止日期
64
                 $timeWhere = $this->getTimeParam($param['time_type']);
64
                 $timeWhere = $this->getTimeParam($param['time_type']);
76
                     ->join('AdminUser u', 'u.id = t.main_user_id', 'LEFT')
76
                     ->join('AdminUser u', 'u.id = t.main_user_id', 'LEFT')
77
                     ->field('t.task_id,t.name as task_name,t.main_user_id,t.description,t.priority,t.stop_time,t.create_time,t.owner_user_id,t.start_time,t.create_user_id,u.realname as main_user_name,t.is_top')
77
                     ->field('t.task_id,t.name as task_name,t.main_user_id,t.description,t.priority,t.stop_time,t.create_time,t.owner_user_id,t.start_time,t.create_user_id,u.realname as main_user_name,t.is_top')
78
                     ->where($where)
78
                     ->where($where)
79
-                    ->where($whereStr)
80
                     ->where($timeWhere)
79
                     ->where($timeWhere)
81
                     ->where($labelWhere)
80
                     ->where($labelWhere)
82
                     ->order('t.task_id desc')
81
                     ->order('t.task_id desc')
83
                     ->select();
82
                     ->select();
84
-
83
+                
85
             } else {
84
             } else {
86
                 ///下属任务
85
                 ///下属任务
87
                 if ($param['mold'] == 1) {
86
                 if ($param['mold'] == 1) {
96
                     if ($type != 0) {
95
                     if ($type != 0) {
97
                         switch ($type) {
96
                         switch ($type) {
98
                             case '1' :
97
                             case '1' :
99
-                                $type = 't.main_user_id in ('.$subStr.')';
98
+                                $type = 't.main_user_id in (' . $subStr . ')';
100
                                 break; //下属负责的
99
                                 break; //下属负责的
101
                             case '3' :
100
                             case '3' :
102
                                 //使用正则查询
101
                                 //使用正则查询
103
                                 // SELECT * FROM 5kcrm_task WHERE owner_user_id REGEXP '(,1,|,2,|,3,)';
102
                                 // SELECT * FROM 5kcrm_task WHERE owner_user_id REGEXP '(,1,|,2,|,3,)';
104
-                                $type = $subValue ? 't.owner_user_id REGEXP "('.$subValue.')"' : '';
103
+                                $type = $subValue ? 't.owner_user_id REGEXP "(' . $subValue . ')"' : '';
105
                                 break; //下属参与的
104
                                 break; //下属参与的
106
                         }
105
                         }
107
                     } else {
106
                     } else {
108
                         if (!$subValue) {
107
                         if (!$subValue) {
109
                             $type = 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . '))';
108
                             $type = 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . '))';
110
                         } else {
109
                         } else {
111
-                            $type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "('.$subValue.')")';
110
+                            $type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "(' . $subValue . ')")';
112
                         }
111
                         }
113
-                    } 
112
+                    }
114
                     $map['t.pid'] = 0;
113
                     $map['t.pid'] = 0;
115
                     $map['t.ishidden'] = 0;
114
                     $map['t.ishidden'] = 0;
116
                     $taskList = Db::name('Task')
115
                     $taskList = Db::name('Task')
121
                         )
120
                         )
122
                         ->where(function ($query) use ($type) {
121
                         ->where(function ($query) use ($type) {
123
                             $query->where($type);
122
                             $query->where($type);
124
-                        })                    
123
+                        })
125
                         ->where($where)
124
                         ->where($where)
126
                         ->where($map)
125
                         ->where($map)
127
                         ->order('t.task_id desc')
126
                         ->order('t.task_id desc')
128
-                        ->select();      
129
-                }  else {
127
+                        ->select();
128
+                } else {
130
                     $map['t.pid'] = 0;
129
                     $map['t.pid'] = 0;
131
                     // $map['t.work_id'] = 0;
130
                     // $map['t.work_id'] = 0;
132
                     if ($type != 0) {
131
                     if ($type != 0) {
135
                                 $type = 't.main_user_id =' . $param['user_id'] . '';
134
                                 $type = 't.main_user_id =' . $param['user_id'] . '';
136
                                 break; //我负责的
135
                                 break; //我负责的
137
                             case '3' :
136
                             case '3' :
138
-                                $type = 't.owner_user_id like "%,'.$param['user_id'].',%"';
137
+                                $type = 't.owner_user_id like "%,' . $param['user_id'] . ',%"';
139
                                 break; //我参与的
138
                                 break; //我参与的
140
                         }
139
                         }
141
                     } else {
140
                     } else {
142
                         $adminIds = $userModel->getAdminId();
141
                         $adminIds = $userModel->getAdminId();
143
-                        if (in_array($param['user_id'],$adminIds)) {
144
-                            $type = 't.is_open = 1';  
142
+                        if (in_array($param['user_id'], $adminIds)) {
143
+                            $type = 't.is_open = 1';
145
                         } else {
144
                         } else {
146
-                            $type = 't.is_open = 1 AND (t.main_user_id =' . $param['user_id'] .' OR t.owner_user_id like "%,'.$param['user_id'].',%")';
145
+                            $type = 't.is_open = 1 AND (t.main_user_id =' . $param['user_id'] . ' OR t.owner_user_id like "%,' . $param['user_id'] . ',%")';
147
                         }
146
                         }
148
                     }
147
                     }
149
                     $where['t.ishidden'] = 0;
148
                     $where['t.ishidden'] = 0;
154
                         ->where($where)
153
                         ->where($where)
155
                         ->where($type)
154
                         ->where($type)
156
                         ->where($map)
155
                         ->where($map)
157
-                        ->page($param['page'], $param['limit'])
158
                         ->order('t.task_id desc')
156
                         ->order('t.task_id desc')
159
                         ->select();
157
                         ->select();
160
-                }  
158
+                }
161
             }
159
             }
162
         }
160
         }
163
         foreach ($taskList as $key => $value) {
161
         foreach ($taskList as $key => $value) {
185
             //创建时间
183
             //创建时间
186
             $taskList[$key]['create_time'] = $value['create_time'] ? date('Y-m-d H:i:s', $value['create_time']) : '';
184
             $taskList[$key]['create_time'] = $value['create_time'] ? date('Y-m-d H:i:s', $value['create_time']) : '';
187
             //开始时间
185
             //开始时间
188
-            $taskList[$key]['start_time'] =  $value['start_time'] ? date('Y-m-d H:i:s', $value['start_time']) : '';
186
+            $taskList[$key]['start_time'] = $value['start_time'] ? date('Y-m-d H:i:s', $value['start_time']) : '';
189
             //结束时间
187
             //结束时间
190
             $taskList[$key]['stop_time'] = $value['stop_time'] ? date('Y-m-d H:i:s', $value['stop_time']) : '';
188
             $taskList[$key]['stop_time'] = $value['stop_time'] ? date('Y-m-d H:i:s', $value['stop_time']) : '';
191
             //优先级
189
             //优先级
217
         }
215
         }
218
         return $taskList;
216
         return $taskList;
219
     }
217
     }
220
-
218
+    
221
     /**
219
     /**
222
      * 任务导出
220
      * 任务导出
223
      * @param $param
221
      * @param $param
224
      */
222
      */
225
     public function excelExport($param)
223
     public function excelExport($param)
226
     {
224
     {
227
-
225
+        
228
         $data = $this->getDataList($param);
226
         $data = $this->getDataList($param);
229
         $excelModel = new \app\admin\model\Excel();
227
         $excelModel = new \app\admin\model\Excel();
230
         if ($param['work_id'] != 0) {
228
         if ($param['work_id'] != 0) {
280
         }
278
         }
281
         return $excelModel->taskExportCsv($file_name, $field_list, $title, $data);
279
         return $excelModel->taskExportCsv($file_name, $field_list, $title, $data);
282
     }
280
     }
283
-
281
+    
284
     public function where($param)
282
     public function where($param)
285
     {
283
     {
286
         $taskModel = new TaskModel();
284
         $taskModel = new TaskModel();
289
         $workModel = new WorkModel();
287
         $workModel = new WorkModel();
290
         $userModel = new \app\admin\model\User();
288
         $userModel = new \app\admin\model\User();
291
         $work_id = $param['work_id'] ?: '';
289
         $work_id = $param['work_id'] ?: '';
292
-
290
+        
293
         if ($param['main_user_id']) {
291
         if ($param['main_user_id']) {
294
             $map['t.main_user_id'] = ['in', $param['main_user_id']];
292
             $map['t.main_user_id'] = ['in', $param['main_user_id']];
295
         }
293
         }
296
-
294
+        
297
         //截止时间
295
         //截止时间
298
         if ($param['stop_time_type']) {
296
         if ($param['stop_time_type']) {
299
             if ($param['stop_time_type'] == '5') { //没有截至日期
297
             if ($param['stop_time_type'] == '5') { //没有截至日期
326
                 $map['t.stop_time'] = ['between', [$timeAry[0], $timeAry[1]]];
324
                 $map['t.stop_time'] = ['between', [$timeAry[0], $timeAry[1]]];
327
             }
325
             }
328
         }
326
         }
329
-
327
+        
330
         if ($param['lable_id']) {
328
         if ($param['lable_id']) {
331
             $taskIds = [];
329
             $taskIds = [];
332
             $task_ids = [];
330
             $task_ids = [];
339
                 $lableWhere['ishidden'] = 0;
337
                 $lableWhere['ishidden'] = 0;
340
                 $lableWhere['pid'] = 0;
338
                 $lableWhere['pid'] = 0;
341
                 $lableWhere['is_archive'] = 0;
339
                 $lableWhere['is_archive'] = 0;
342
-
340
+                
343
                 $task_id = $taskModel->where($lableWhere)->column('task_id');
341
                 $task_id = $taskModel->where($lableWhere)->column('task_id');
344
                 if ($task_id && $task_ids) {
342
                 if ($task_id && $task_ids) {
345
                     $task_ids = array_unique(array_filter(array_merge($task_ids, $task_id)));
343
                     $task_ids = array_unique(array_filter(array_merge($task_ids, $task_id)));
349
             }
347
             }
350
             $map['t.task_id'] = ['in', $task_ids];
348
             $map['t.task_id'] = ['in', $task_ids];
351
         } else {
349
         } else {
352
-
350
+            
353
             $map['t.task_id'] = $work_id;
351
             $map['t.task_id'] = $work_id;
354
         }
352
         }
355
         return $map;
353
         return $map;
356
     }
354
     }
357
-
355
+    
358
     /**
356
     /**
359
      * 获取截止日期参数
357
      * 获取截止日期参数
360
      * @param $type
358
      * @param $type
363
     private function getTimeParam($type)
361
     private function getTimeParam($type)
364
     {
362
     {
365
         $result = [];
363
         $result = [];
366
-
364
+        
367
         # 今天
365
         # 今天
368
         if ($type == 1) {
366
         if ($type == 1) {
369
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
367
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
370
         }
368
         }
371
-
369
+        
372
         # 明天
370
         # 明天
373
         if ($type == 2) {
371
         if ($type == 2) {
374
             $tomorrow = date("Y-m-d 23:59:59", strtotime("+1 day"));
372
             $tomorrow = date("Y-m-d 23:59:59", strtotime("+1 day"));
375
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime($tomorrow) . ')';
373
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime($tomorrow) . ')';
376
         }
374
         }
377
-
375
+        
378
         # 本周
376
         # 本周
379
         if ($type == 3) {
377
         if ($type == 3) {
380
             $week = mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"));
378
             $week = mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"));
381
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . $week . ')';
379
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . $week . ')';
382
         }
380
         }
383
-
381
+        
384
         # 本月
382
         # 本月
385
         if ($type == 4) {
383
         if ($type == 4) {
386
             $month = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
384
             $month = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
387
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . $month . ')';
385
             $result = '(task.stop_time > 0 AND task.stop_time <= ' . $month . ')';
388
         }
386
         }
389
-
387
+        
390
         # 未设置截止日期
388
         # 未设置截止日期
391
         if ($type == 5) {
389
         if ($type == 5) {
392
             $result = $result = '(task.stop_time = 0)';;
390
             $result = $result = '(task.stop_time = 0)';;
393
         }
391
         }
394
-
392
+        
395
         # 已延期
393
         # 已延期
396
         if ($type == 6) {
394
         if ($type == 6) {
397
             $result = '(task.status = 2 OR task.stop_time >= ' . time() . ')';
395
             $result = '(task.status = 2 OR task.stop_time >= ' . time() . ')';
398
         }
396
         }
399
-
397
+        
400
         # 今日更新
398
         # 今日更新
401
         if ($type == 7) {
399
         if ($type == 7) {
402
             $result = '(task.update_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' AND task.update_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
400
             $result = '(task.update_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' AND task.update_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
403
         }
401
         }
404
-
402
+        
405
         return $result;
403
         return $result;
406
     }
404
     }
407
-
405
+    
408
 }
406
 }

+ 33
- 27
application/oa/logic/UserLogic.php Zobrazit soubor

27
         $initials_type = ($param['initials'] == 1) ? 1 : 2;
27
         $initials_type = ($param['initials'] == 1) ? 1 : 2;
28
         $where['user.status'] = 1;
28
         $where['user.status'] = 1;
29
         if ($search) {
29
         if ($search) {
30
-            $where = function ($query) use ($search) {
30
+            $whereMap = function ($query) use ($search) {
31
                 $query->where('user.realname', array('like', '%' . $search . '%'))
31
                 $query->where('user.realname', array('like', '%' . $search . '%'))
32
                     ->whereOr('user.mobile', array('like', '%' . $search . '%'));
32
                     ->whereOr('user.mobile', array('like', '%' . $search . '%'));
33
             };
33
             };
34
         }
34
         }
35
-        if ($param['star_type'] == 1) {
36
-            $item = Db::name('crm_star')->where('user_id', $user_id)->column('target_id');
37
-            $where['user.id'] = ['in', $item];
38
-        }
39
-        if ($param['structure_id'] == '') {
40
-            $list = Db::name('admin_user')
41
-                ->alias('user')
42
-                ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
43
-                ->where($where)
44
-                ->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name,user.mobile')
45
-                ->page($param['page'], $param['limit'])
46
-                ->select();
47
-
48
-            foreach ($list as $k => $v) {
49
-                $starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];
50
-                $star = Db::name('crm_star')->where($starWhere)->value('star_id');
51
-                $list[$k]['thumb_img'] = $v['thumb_img'] ? getFullPath($v['thumb_img']) : '';
52
-                $list[$k]['star'] = !empty($star) ? 1 : 0;
35
+        if($param['structure_id']){
36
+            $where['user.id']= $param['structure_id'];
37
+        }
38
+        if (isset($param['star_type'])) {
39
+            if ($param['star_type'] == 1) {
40
+                $item = Db::name('crm_star')->where(['user_id'=>$user_id,'type'=>'admin_user'])->column('target_id');
41
+                if(!empty($item)) {
42
+                    $where['user.id'] = ['in', $item];
43
+                    $list = Db::name('admin_user')
44
+                        ->alias('user')
45
+                        ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
46
+                        ->where($where)
47
+                        ->where($whereMap)
48
+                        ->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name,user.mobile')
49
+                        ->page($param['page'], $param['limit'])
50
+                        ->select();
51
+                    foreach ($list as $k => $v) {
52
+                        $starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];
53
+                        $star = Db::name('crm_star')->where($starWhere)->value('star_id');
54
+                        $list[$k]['thumb_img'] = $v['thumb_img'] ? getFullPath($v['thumb_img']) : '';
55
+                        $list[$k]['star'] = !empty($star) ? 1 : 0;
56
+                    }
57
+                    $dataCount = Db::name('admin_user')
58
+                        ->alias('user')
59
+                        ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
60
+                        ->where($where)
61
+                        ->count();
62
+                    $newarray = $this->groupByInitials($list, 'realname', $initials_type);
63
+                }else{
64
+                    return false;
65
+                }
53
             }
66
             }
54
-            $dataCount = Db::name('admin_user')
55
-                ->alias('user')
56
-                ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
57
-                ->where($where)
58
-                ->count();
59
-            $newarray = $this->groupByInitials($list, 'realname', $initials_type);
60
         } else {
67
         } else {
61
             $list = Db::name('admin_user')
68
             $list = Db::name('admin_user')
62
                 ->alias('user')
69
                 ->alias('user')
63
                 ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
70
                 ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
64
                 ->where($where)
71
                 ->where($where)
65
-                ->where('structure.id', $param['structure_id'])
72
+                ->where($whereMap)
66
                 ->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name')
73
                 ->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name')
67
                 ->page($param['page'], $param['limit'])
74
                 ->page($param['page'], $param['limit'])
68
                 ->select();
75
                 ->select();
70
                 ->alias('user')
77
                 ->alias('user')
71
                 ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
78
                 ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
72
                 ->where($where)
79
                 ->where($where)
73
-                ->where('structure.id', $param['structure_id'])
74
                 ->count();
80
                 ->count();
75
             foreach ($list as $k => $v) {
81
             foreach ($list as $k => $v) {
76
                 $starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];
82
                 $starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];

+ 120
- 118
application/oa/model/Event.php Zobrazit soubor

30
         'start_time' => 'timestamp',
30
         'start_time' => 'timestamp',
31
         'end_time' => 'timestamp',
31
         'end_time' => 'timestamp',
32
     ];
32
     ];
33
-
33
+    
34
     /**
34
     /**
35
      * [getDataList 日程list]
35
      * [getDataList 日程list]
36
      * @param     [by]                       $by [查询时间段类型]
36
      * @param     [by]                       $by [查询时间段类型]
42
         $userModel = new \app\admin\model\User();
42
         $userModel = new \app\admin\model\User();
43
         $recordModel = new \app\admin\model\Record();
43
         $recordModel = new \app\admin\model\Record();
44
         $user_id = $param['user_id'];
44
         $user_id = $param['user_id'];
45
-
45
+        
46
         //默认本账户or 自定义用户id
46
         //默认本账户or 自定义用户id
47
         if ($param['start_time'] && $param['end_time']) {
47
         if ($param['start_time'] && $param['end_time']) {
48
             $start_time = $param['start_time'];
48
             $start_time = $param['start_time'];
51
             $start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
51
             $start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
52
             $end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
52
             $end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
53
         }
53
         }
54
-
54
+        
55
         $where = '( ( start_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) ) 
55
         $where = '( ( start_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) ) 
56
         OR ( ( end_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND  ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) ) 
56
         OR ( ( end_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND  ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) ) 
57
         OR ( start_time < ' . $start_time . ' AND end_time > ' . $end_time . ' AND ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) )';
57
         OR ( start_time < ' . $start_time . ' AND end_time > ' . $end_time . ' AND ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) )';
58
         $event_date = Db::name('OaEvent')->where($where)->select();
58
         $event_date = Db::name('OaEvent')->where($where)->select();
59
-
60
-        foreach ($event_date as $k => $v) {
59
+        foreach ($event_date as $k=>$v) {
61
             $event_date[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
60
             $event_date[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
62
-            $event_date[$k]['ownerList'] = $userModel->getDataByStr($v['owner_user_ids']) ?: [];
63
-
64
-            $relationArr = [];
61
+            $event_date[$k]['ownerList'] = $userModel->getDataByStr($v['owner_user_ids']) ? : [];
62
+        
63
+            $relationArr= [];
65
             $relationArr = $recordModel->getListByRelationId('event', $v['event_id']);
64
             $relationArr = $recordModel->getListByRelationId('event', $v['event_id']);
66
             $event_date[$k]['businessList'] = $relationArr['businessList'];
65
             $event_date[$k]['businessList'] = $relationArr['businessList'];
67
             $event_date[$k]['contactsList'] = $relationArr['contactsList'];
66
             $event_date[$k]['contactsList'] = $relationArr['contactsList'];
68
             $event_date[$k]['contractList'] = $relationArr['contractList'];
67
             $event_date[$k]['contractList'] = $relationArr['contractList'];
69
             $event_date[$k]['customerList'] = $relationArr['customerList'];
68
             $event_date[$k]['customerList'] = $relationArr['customerList'];
70
-            $event_date[$k]['type'] = 'event';
69
+        
71
             $event_date[$k]['remindtype'] = (int)$v['remindtype'];
70
             $event_date[$k]['remindtype'] = (int)$v['remindtype'];
72
             $noticeInfo = Db::name('OaEventNotice')->where(['event_id' => $v['event_id']])->find();
71
             $noticeInfo = Db::name('OaEventNotice')->where(['event_id' => $v['event_id']])->find();
73
             $is_repeat = 0;
72
             $is_repeat = 0;
74
             if ($noticeInfo) {
73
             if ($noticeInfo) {
75
                 $is_repeat = 1;
74
                 $is_repeat = 1;
76
             }
75
             }
77
-            $color = db('admin_oa_schedule')->where('schedule_id', $v['schedule_id'])->find();
78
-            $event_date[$k]['color'] = $color['color'];
79
             $event_date[$k]['is_repeat'] = $is_repeat;
76
             $event_date[$k]['is_repeat'] = $is_repeat;
80
             $event_date[$k]['stop_time'] = $noticeInfo ? $noticeInfo['stop_time'] : '';
77
             $event_date[$k]['stop_time'] = $noticeInfo ? $noticeInfo['stop_time'] : '';
81
             $event_date[$k]['noticetype'] = $noticeInfo ? $noticeInfo['noticetype'] : '';
78
             $event_date[$k]['noticetype'] = $noticeInfo ? $noticeInfo['noticetype'] : '';
82
             if ($noticeInfo['noticetype'] == '2') {
79
             if ($noticeInfo['noticetype'] == '2') {
83
-                $event_date[$k]['repeat'] = $noticeInfo['repeated'] ? explode('|||', $noticeInfo['repeated']) : [];
80
+                $event_date[$k]['repeat'] = $noticeInfo['repeated'] ? explode('|||',$noticeInfo['repeated']) : [];
84
             } else {
81
             } else {
85
-                $event_date[$k]['repeat'] = '';
82
+                $event_date[$k]['repeat'] =  '';
86
             }
83
             }
87
             //权限
84
             //权限
88
             $is_update = 0;
85
             $is_update = 0;
93
             }
90
             }
94
             $permission['is_update'] = $is_update;
91
             $permission['is_update'] = $is_update;
95
             $permission['is_delete'] = $is_delete;
92
             $permission['is_delete'] = $is_delete;
96
-            $event_date[$k]['permission'] = $permission;
97
-
93
+            $event_date[$k]['permission']	= $permission;
98
             $event_date[$k]['start_time'] = !empty($v['start_time']) ? $v['start_time'] * 1000 : null;
94
             $event_date[$k]['start_time'] = !empty($v['start_time']) ? $v['start_time'] * 1000 : null;
99
             $event_date[$k]['end_time'] = !empty($v['end_time']) ? $v['end_time'] * 1000 : null;
95
             $event_date[$k]['end_time'] = !empty($v['end_time']) ? $v['end_time'] * 1000 : null;
100
-
96
+    
101
             $event_date[$k]['type_id'] = $v['schedule_id'];
97
             $event_date[$k]['type_id'] = $v['schedule_id'];
102
         }
98
         }
103
-
104
-        return $event_date ?: [];
99
+        return $event_date ? : [];
105
     }
100
     }
106
-
101
+    
107
     /**
102
     /**
108
      * 系统自定义类型数据(任务)
103
      * 系统自定义类型数据(任务)
109
      *
104
      *
116
     public function eventTask($param)
111
     public function eventTask($param)
117
     {
112
     {
118
         $user_id = $param['user_id'];
113
         $user_id = $param['user_id'];
119
-
114
+        
120
         // 默认本账户or 自定义用户id
115
         // 默认本账户or 自定义用户id
121
         if ($param['start_time'] && $param['end_time']) {
116
         if ($param['start_time'] && $param['end_time']) {
122
             $start_time = $param['start_time'];
117
             $start_time = $param['start_time'];
129
             '((stop_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%")) 
124
             '((stop_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%")) 
130
           OR ((stop_time > ' . $start_time . ' AND stop_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%"))
125
           OR ((stop_time > ' . $start_time . ' AND stop_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%"))
131
           OR ((stop_time > ' . $start_time . ' AND stop_time >' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%"))';
126
           OR ((stop_time > ' . $start_time . ' AND stop_time >' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%"))';
132
-
127
+        
133
         //分配的任务 负责人或参与人是当前用户
128
         //分配的任务 负责人或参与人是当前用户
134
         $event_date = db('task')->where(['stop_time' => ['>', 0], 'ishidden' => ['=', 0]])->where($between_time)
129
         $event_date = db('task')->where(['stop_time' => ['>', 0], 'ishidden' => ['=', 0]])->where($between_time)
135
             ->field('task_id,name,start_time,stop_time')->select();
130
             ->field('task_id,name,start_time,stop_time')->select();
142
         }
137
         }
143
         return $event_date;
138
         return $event_date;
144
     }
139
     }
145
-
140
+    
146
     /**
141
     /**
147
      * 系统自定义类型数据(客户)
142
      * 系统自定义类型数据(客户)
148
      *
143
      *
157
         $userModel = new \app\admin\model\User();
152
         $userModel = new \app\admin\model\User();
158
         $recordModel = new \app\admin\model\Record();
153
         $recordModel = new \app\admin\model\Record();
159
         $user_id = $param['user_id'];
154
         $user_id = $param['user_id'];
160
-
161
-
155
+        
156
+        
162
         //默认本账户or 自定义用户id
157
         //默认本账户or 自定义用户id
163
         if ($param['start_time'] && $param['end_time']) {
158
         if ($param['start_time'] && $param['end_time']) {
164
             $start_time = $param['start_time'];
159
             $start_time = $param['start_time'];
174
         $between_time = '((next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '))
169
         $between_time = '((next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '))
175
         OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id =' . $user_id . '))
170
         OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id =' . $user_id . '))
176
         OR ((next_time > ' . $start_time . ' AND next_time > ' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '))';
171
         OR ((next_time > ' . $start_time . ' AND next_time > ' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '))';
177
-        $event_date = db('crm_customer')->where(['next_time'=> ['>', 0],'owner_user_id'=>['<>',0]])->where($between_time)->where('')
172
+        $event_date = db('crm_customer')->where(['next_time' => ['>', 0], 'owner_user_id' => ['<>', 0]])->where($between_time)->where('')
178
             ->field('next_time as start_time,customer_id,name ')->group('start_time')->select();
173
             ->field('next_time as start_time,customer_id,name ')->group('start_time')->select();
179
         $item = [];
174
         $item = [];
180
         foreach ($event_date as $k2 => $v) {
175
         foreach ($event_date as $k2 => $v) {
233
             $event_date[$k4]['stop_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
228
             $event_date[$k4]['stop_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
234
             $item[] = $v['start_time'] ? $v['start_time'] : '';
229
             $item[] = $v['start_time'] ? $v['start_time'] : '';
235
         }
230
         }
236
-
231
+        
237
         $list_data['receivables'] = $item ? array_values(array_unique($item)) : [];
232
         $list_data['receivables'] = $item ? array_values(array_unique($item)) : [];
238
         //需联系的线索 next_time
233
         //需联系的线索 next_time
239
-
234
+        
240
         $between_time = '(( next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ')AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '  ))
235
         $between_time = '(( next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ')AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '  ))
241
     
236
     
242
         OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
237
         OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
256
             $event_date[$k5]['stop_time'] = !empty($v['start_time']) ? $v['start_time'] * 1000 : null;
251
             $event_date[$k5]['stop_time'] = !empty($v['start_time']) ? $v['start_time'] * 1000 : null;
257
             $item[] = $v['start_time'] ? date('Y-m-d', $v['start_time']) : '';
252
             $item[] = $v['start_time'] ? date('Y-m-d', $v['start_time']) : '';
258
         }
253
         }
259
-
254
+        
260
         $list_data['leads'] = $item ? array_values(array_unique($item)) : [];
255
         $list_data['leads'] = $item ? array_values(array_unique($item)) : [];
261
         //需联系的商机 next_time
256
         //需联系的商机 next_time
262
         $between_time =
257
         $between_time =
263
             '((next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '  )) 
258
             '((next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '  )) 
264
           OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
259
           OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
265
           OR ((next_time > ' . $start_time . ' AND next_time >' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))';
260
           OR ((next_time > ' . $start_time . ' AND next_time >' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))';
266
-
261
+        
267
         $event_date = db('crm_business')->where($between_time)->where('next_time', '>', 0)->field('next_time as start_time,business_id,name ')->select();
262
         $event_date = db('crm_business')->where($between_time)->where('next_time', '>', 0)->field('next_time as start_time,business_id,name ')->select();
268
         unset($item);
263
         unset($item);
269
         foreach ($event_date as $k6 => $v) {
264
         foreach ($event_date as $k6 => $v) {
273
             $event_date[$k6]['start_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
268
             $event_date[$k6]['start_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
274
             $event_date[$k6]['stop_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
269
             $event_date[$k6]['stop_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
275
             $item[] = $v['start_time'] ? date('Y-m-d', $v['start_time']) : '';
270
             $item[] = $v['start_time'] ? date('Y-m-d', $v['start_time']) : '';
276
-
271
+            
277
         }
272
         }
278
         $list_data['businessNext'] = $item ? array_values(array_unique($item)) : [];
273
         $list_data['businessNext'] = $item ? array_values(array_unique($item)) : [];
279
-
274
+        
280
         //需要联系的客户 next_time crm_customer
275
         //需要联系的客户 next_time crm_customer
281
         $return_time = date('Y-m-d', $start_time);
276
         $return_time = date('Y-m-d', $start_time);
282
         $return_end = date('Y-m-d', $end_time);
277
         $return_end = date('Y-m-d', $end_time);
292
             ->field('deal_date as start_time,business_id,name')
287
             ->field('deal_date as start_time,business_id,name')
293
             ->group('start_time')
288
             ->group('start_time')
294
             ->select();
289
             ->select();
295
-
290
+        
296
         unset($item);
291
         unset($item);
297
         foreach ($event_date as $k7 => $v) {
292
         foreach ($event_date as $k7 => $v) {
298
             $event_date[$k7]['color'] = 7;
293
             $event_date[$k7]['color'] = 7;
305
         $list_data['business'] = $item ? array_values(array_unique($item)) : [];
300
         $list_data['business'] = $item ? array_values(array_unique($item)) : [];
306
         return $list_data ?: [];
301
         return $list_data ?: [];
307
     }
302
     }
308
-
303
+    
309
     /**
304
     /**
310
      * 日历上显示
305
      * 日历上显示
311
      * @return array
306
      * @return array
316
     public function listStatus($param)
311
     public function listStatus($param)
317
     {
312
     {
318
         $userId = $param['user_id'];
313
         $userId = $param['user_id'];
319
-
314
+        
320
         if ($param['start_time'] && $param['end_time']) {
315
         if ($param['start_time'] && $param['end_time']) {
321
             $start_time = $param['start_time'];
316
             $start_time = $param['start_time'];
322
             $end_time = $param['end_time'];
317
             $end_time = $param['end_time'];
324
             $start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
319
             $start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
325
             $end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
320
             $end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
326
         }
321
         }
327
-
322
+        
328
         $list = Db::name('oa_event')->where(['end_time' => ['>', 0], 'start_time' => ['>', 0]])
323
         $list = Db::name('oa_event')->where(['end_time' => ['>', 0], 'start_time' => ['>', 0]])
329
             ->where(function ($query) use ($userId) {
324
             ->where(function ($query) use ($userId) {
330
                 $query->whereOr('create_user_id', $userId);
325
                 $query->whereOr('create_user_id', $userId);
336
         }
331
         }
337
         return $list;
332
         return $list;
338
     }
333
     }
339
-
334
+    
340
     /**
335
     /**
341
      * 类型列表
336
      * 类型列表
342
      * @return array|void
337
      * @return array|void
367
         $data['list'] = $list;
362
         $data['list'] = $list;
368
         return $data;
363
         return $data;
369
     }
364
     }
370
-
365
+    
371
     /**
366
     /**
372
      * 修改展示类型
367
      * 修改展示类型
373
      * @param $param
368
      * @param $param
395
                             ->whereIn('schedule_id', arrayToString($param['schedule_id']))
390
                             ->whereIn('schedule_id', arrayToString($param['schedule_id']))
396
                             ->update(['type' => 1]);
391
                             ->update(['type' => 1]);
397
                     }
392
                     }
398
-
393
+                    
399
                 } else {
394
                 } else {
400
                     db('admin_oa_schedule_relation')->where('user_id', $param['user_id'])->insert(['schedule_id' => $v, 'user_id' => $param['user_id'], 'type' => 1, 'create_time' => time()]);
395
                     db('admin_oa_schedule_relation')->where('user_id', $param['user_id'])->insert(['schedule_id' => $v, 'user_id' => $param['user_id'], 'type' => 1, 'create_time' => time()]);
401
                 }
396
                 }
402
-
397
+                
403
             } else {
398
             } else {
404
                 db('admin_oa_schedule_relation')->where('user_id', $param['user_id'])->insert(['schedule_id' => $v, 'user_id' => $param['user_id'], 'type' => 1, 'create_time' => time()]);
399
                 db('admin_oa_schedule_relation')->where('user_id', $param['user_id'])->insert(['schedule_id' => $v, 'user_id' => $param['user_id'], 'type' => 1, 'create_time' => time()]);
405
             }
400
             }
407
         $data = [];
402
         $data = [];
408
         return $data;
403
         return $data;
409
     }
404
     }
410
-
405
+    
411
     /**
406
     /**
412
      * 创建日程信息
407
      * 创建日程信息
413
      *
408
      *
428
         $param['create_time'] = time();
423
         $param['create_time'] = time();
429
         $param['update_time'] = time();
424
         $param['update_time'] = time();
430
         unset($param['user_id']);
425
         unset($param['user_id']);
431
-
426
+        
432
         # 关联数据
427
         # 关联数据
433
         $relation = [];
428
         $relation = [];
434
         if (!empty($param['customer_ids'])) $relation['customer_ids'] = arrayToString($param['customer_ids']);
429
         if (!empty($param['customer_ids'])) $relation['customer_ids'] = arrayToString($param['customer_ids']);
435
         if (!empty($param['contacts_ids'])) $relation['contacts_ids'] = arrayToString($param['contacts_ids']);
430
         if (!empty($param['contacts_ids'])) $relation['contacts_ids'] = arrayToString($param['contacts_ids']);
436
         if (!empty($param['business_ids'])) $relation['business_ids'] = arrayToString($param['business_ids']);
431
         if (!empty($param['business_ids'])) $relation['business_ids'] = arrayToString($param['business_ids']);
437
         if (!empty($param['contract_ids'])) $relation['contract_ids'] = arrayToString($param['contract_ids']);
432
         if (!empty($param['contract_ids'])) $relation['contract_ids'] = arrayToString($param['contract_ids']);
438
-
433
+        
439
         # 提醒数据
434
         # 提醒数据
440
         $notice = $param['notice'];
435
         $notice = $param['notice'];
441
-
436
+        
442
         # 删除多余字段
437
         # 删除多余字段
443
         unset($param['customer_ids']);
438
         unset($param['customer_ids']);
444
         unset($param['contacts_ids']);
439
         unset($param['contacts_ids']);
445
         unset($param['business_ids']);
440
         unset($param['business_ids']);
446
         unset($param['contract_ids']);
441
         unset($param['contract_ids']);
447
         unset($param['notice']);
442
         unset($param['notice']);
448
-
443
+        
449
         if ($this->allowField(true)->save($param)) {
444
         if ($this->allowField(true)->save($param)) {
450
             $eventId = $this->event_id;
445
             $eventId = $this->event_id;
451
-
446
+            
452
             # 提醒
447
             # 提醒
453
             if (!empty($notice)) {
448
             if (!empty($notice)) {
454
                 $noticeData = [];
449
                 $noticeData = [];
467
                 }
462
                 }
468
                 if (!empty($noticeData)) Db::name('oa_event_notice')->insertAll($noticeData);
463
                 if (!empty($noticeData)) Db::name('oa_event_notice')->insertAll($noticeData);
469
             }
464
             }
470
-
465
+            
471
             # 关联数据
466
             # 关联数据
472
             if (!empty($relation)) {
467
             if (!empty($relation)) {
473
                 $relation['event_id'] = $eventId;
468
                 $relation['event_id'] = $eventId;
474
                 $relation['status'] = 1;
469
                 $relation['status'] = 1;
475
                 $relation['create_time'] = time();
470
                 $relation['create_time'] = time();
476
-
471
+                
477
                 Db::name('oa_event_relation')->insert($relation);
472
                 Db::name('oa_event_relation')->insert($relation);
478
             }
473
             }
479
-
474
+            
480
             actionLog($eventId, $param['owner_user_ids'], '', '创建了日程');
475
             actionLog($eventId, $param['owner_user_ids'], '', '创建了日程');
481
-
476
+            
482
             $data['event_id'] = $eventId;
477
             $data['event_id'] = $eventId;
483
             // 站内信
478
             // 站内信
484
             $item = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
479
             $item = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
500
                     ],
495
                     ],
501
                     stringToArray($param['owner_user_ids'])
496
                     stringToArray($param['owner_user_ids'])
502
                 );
497
                 );
503
-
498
+                
504
             }
499
             }
505
-
500
+            
506
             return $data;
501
             return $data;
507
         } else {
502
         } else {
508
             $this->error = '添加失败';
503
             $this->error = '添加失败';
509
             return false;
504
             return false;
510
         }
505
         }
511
-
512
-
506
+        
507
+        
513
     }
508
     }
514
-
509
+    
515
     /**
510
     /**
516
      * 即将到期合同列表
511
      * 即将到期合同列表
517
      * @param $param
512
      * @param $param
562
                 $event_date[$k]['return_date'] = $v['return_date'] ? $v['return_date'] : null;
557
                 $event_date[$k]['return_date'] = $v['return_date'] ? $v['return_date'] : null;
563
             }
558
             }
564
         }
559
         }
565
-
560
+        
566
         $data = [];
561
         $data = [];
567
         $data['list'] = $event_date;
562
         $data['list'] = $event_date;
568
         $data['countData'] = $count;
563
         $data['countData'] = $count;
569
         return $data;
564
         return $data;
570
     }
565
     }
571
-
566
+    
572
     /**
567
     /**
573
      * 续联系客户
568
      * 续联系客户
574
      * @param $param
569
      * @param $param
605
         $data['countData'] = $count;
600
         $data['countData'] = $count;
606
         return $data;
601
         return $data;
607
     }
602
     }
608
-
603
+    
609
     /**
604
     /**
610
      * 续联系客户
605
      * 续联系客户
611
      * @param $param
606
      * @param $param
642
         $data['countData'] = $count;
637
         $data['countData'] = $count;
643
         return $data;
638
         return $data;
644
     }
639
     }
645
-
640
+    
646
     /**
641
     /**
647
      * 计划回款
642
      * 计划回款
648
      * @param $param
643
      * @param $param
659
         //需要联系的客户 next_time crm_customer
654
         //需要联系的客户 next_time crm_customer
660
         $between_time['business.next_time'] = ['between', [$return_time, $return_end]];
655
         $between_time['business.next_time'] = ['between', [$return_time, $return_end]];
661
         $between_time['business.create_user_id|business.owner_user_id'] = ['eq', $user_id];
656
         $between_time['business.create_user_id|business.owner_user_id'] = ['eq', $user_id];
662
-
657
+        
663
         $event_date = db('crm_business')
658
         $event_date = db('crm_business')
664
             ->alias('business')
659
             ->alias('business')
665
             ->join('__ADMIN_USER__ user', 'user.id = business.owner_user_id', 'LEFT')
660
             ->join('__ADMIN_USER__ user', 'user.id = business.owner_user_id', 'LEFT')
682
         $data['countData'] = $count;
677
         $data['countData'] = $count;
683
         return $data;
678
         return $data;
684
     }
679
     }
685
-
680
+    
686
     /**
681
     /**
687
      * 预计成交商机
682
      * 预计成交商机
688
      * @param $param
683
      * @param $param
719
         $data['countData'] = $count;
714
         $data['countData'] = $count;
720
         return $data;
715
         return $data;
721
     }
716
     }
722
-
717
+    
723
     /**
718
     /**
724
      * 公共时间处理
719
      * 公共时间处理
725
      * @param $param
720
      * @param $param
728
     {
723
     {
729
         $userModel = new \app\admin\model\User();
724
         $userModel = new \app\admin\model\User();
730
         $recordModel = new \app\admin\model\Record();
725
         $recordModel = new \app\admin\model\Record();
731
-
732
-
726
+        
727
+        
733
         //默认本账户or 自定义用户id
728
         //默认本账户or 自定义用户id
734
         if ($param['start_time'] && $param['end_time']) {
729
         if ($param['start_time'] && $param['end_time']) {
735
             $start_time = $param['start_time'];
730
             $start_time = $param['start_time'];
744
         $data = [$start_time, $end_time];
739
         $data = [$start_time, $end_time];
745
         return $data;
740
         return $data;
746
     }
741
     }
747
-
742
+    
748
     /**
743
     /**
749
      * 编辑日程信息
744
      * 编辑日程信息
750
      *
745
      *
776
         $param['end_time'] = !empty($param['end_time']) ? strtotime($param['end_time']) : $todayTime[1];
771
         $param['end_time'] = !empty($param['end_time']) ? strtotime($param['end_time']) : $todayTime[1];
777
         $param['update_time'] = time();
772
         $param['update_time'] = time();
778
         unset($param['user_id']);
773
         unset($param['user_id']);
779
-
774
+        
780
         # 关联数据
775
         # 关联数据
781
         $relation = [];
776
         $relation = [];
782
         if (!empty($param['customer_ids'])) $relation['customer_ids'] = arrayToString($param['customer_ids']);
777
         if (!empty($param['customer_ids'])) $relation['customer_ids'] = arrayToString($param['customer_ids']);
783
-        if (!empty($param['contacts_ids'])) $relation['contacts_ids'] = arrayToString($param['customer_ids']);
784
-        if (!empty($param['business_ids'])) $relation['business_ids'] = arrayToString($param['customer_ids']);
785
-        if (!empty($param['contract_ids'])) $relation['contract_ids'] = arrayToString($param['customer_ids']);
786
-
787
-
778
+        if (!empty($param['contacts_ids'])) $relation['contacts_ids'] = arrayToString($param['contacts_ids']);
779
+        if (!empty($param['business_ids'])) $relation['business_ids'] = arrayToString($param['business_ids']);
780
+        if (!empty($param['contract_ids'])) $relation['contract_ids'] = arrayToString($param['contract_ids']);
781
+        
782
+        
788
         # 提醒数据
783
         # 提醒数据
789
         $notice = $param['notice'];
784
         $notice = $param['notice'];
790
-
785
+        
791
         # 删除多余字段
786
         # 删除多余字段
792
         unset($param['customer_ids']);
787
         unset($param['customer_ids']);
793
         unset($param['contacts_ids']);
788
         unset($param['contacts_ids']);
794
         unset($param['business_ids']);
789
         unset($param['business_ids']);
795
         unset($param['contract_ids']);
790
         unset($param['contract_ids']);
796
         unset($param['notice']);
791
         unset($param['notice']);
797
-
792
+        
798
         if ($this->allowField(true)->save($param, ['event_id' => $event_id])) {
793
         if ($this->allowField(true)->save($param, ['event_id' => $event_id])) {
799
             $eventId = $this->event_id;
794
             $eventId = $this->event_id;
800
             actionLog($event_id, $param['owner_user_ids'], '', '修改了日程');
795
             actionLog($event_id, $param['owner_user_ids'], '', '修改了日程');
801
             $list = db('oa_event_notice')->where('event_id', $eventId)->select();
796
             $list = db('oa_event_notice')->where('event_id', $eventId)->select();
802
-            $item = Db::name('OaEventNotice')->where(['event_id' => $eventId])->delete();
803
-            if (!$item) {
797
+            if ($list) {
804
                 foreach ($list as $k => $v) {
798
                 foreach ($list as $k => $v) {
805
                     Db::name('admin_message')->where(['type' => 9, 'action_id' => $v['id']])->delete();
799
                     Db::name('admin_message')->where(['type' => 9, 'action_id' => $v['id']])->delete();
806
                 }
800
                 }
807
             }
801
             }
802
+            $item = Db::name('OaEventNotice')->where(['event_id' => $eventId])->delete();
808
             # 提醒
803
             # 提醒
809
             if (!empty($notice)) {
804
             if (!empty($notice)) {
810
                 $noticeData = [];
805
                 $noticeData = [];
813
                     if ($value['type'] == 1) $startTime = $param['start_time'] - ($value['number'] * 60);
808
                     if ($value['type'] == 1) $startTime = $param['start_time'] - ($value['number'] * 60);
814
                     if ($value['type'] == 2) $startTime = $param['start_time'] - ($value['number'] * 60 * 60);
809
                     if ($value['type'] == 2) $startTime = $param['start_time'] - ($value['number'] * 60 * 60);
815
                     if ($value['type'] == 3) $startTime = $param['start_time'] - ($value['number'] * 60 * 60 * 24);
810
                     if ($value['type'] == 3) $startTime = $param['start_time'] - ($value['number'] * 60 * 60 * 24);
816
-
811
+                    
817
                     $noticeData[] = [
812
                     $noticeData[] = [
818
                         'event_id' => $eventId,
813
                         'event_id' => $eventId,
819
                         'noticetype' => $value['type'],
814
                         'noticetype' => $value['type'],
822
                         'stop_time' => $param['end_time']
817
                         'stop_time' => $param['end_time']
823
                     ];
818
                     ];
824
                 }
819
                 }
825
-                if (!empty($noticeData)) Db::name('oa_event_notice')->insertAll($noticeData);
826
-            }
827
-
828
-            if (!$item) {
829
-                $item = Db::name('OaEventNotice')->where('event_id', $eventId)->select();
830
-                foreach ($item as $val) {
831
-                    if ($value['noticetype'] == '1') { //分
832
-                        $dd = strtotime($param['start_time']) - ($val['number'] * 60);
833
-                    } else if ($val['noticetype'] == '2') { //时
834
-                        $dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60);
835
-                    } else if ($val['noticetype'] == '3') {//天
836
-                        $dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60 * 24);
820
+                if (!empty($noticeData)) {
821
+                    $item = Db::name('oa_event_notice')->insertAll($noticeData);
822
+                    if ($item) {
823
+                       
824
+                        $item = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
825
+                        foreach ($item as $val) {
826
+                            if ($value['noticetype'] == '1') { //分
827
+                                $dd = strtotime($param['start_time']) - ($val['number'] * 60);
828
+                            } else if ($val['noticetype'] == '2') { //时
829
+                                $dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60);
830
+                            } else if ($val['noticetype'] == '3') {//天
831
+                                $dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60 * 24);
832
+                            }
833
+                            // 站内信
834
+                            (new Message())->send(
835
+                                Message::EVENT_MESSAGE,
836
+                                [
837
+                                    'title' => $param['title'],
838
+                                    'action_id' => $val['id'],
839
+                                    'advance_time' => $dd ?: 0
840
+                                ],
841
+                                stringToArray($param['owner_user_ids'])
842
+                            );
843
+            
844
+                        }
837
                     }
845
                     }
838
-                    // 站内信
839
-                    (new Message())->send(
840
-                        Message::EVENT_MESSAGE,
841
-                        [
842
-                            'title' => $param['title'],
843
-                            'action_id' => $val['id'],
844
-                            'advance_time' => $dd ?: 0
845
-                        ],
846
-                        array_diff(stringToArray($param['owner_user_ids']), stringToArray($dataInfo['owner_user_ids']))
847
-                    );
848
-
849
                 }
846
                 }
850
             }
847
             }
851
-            $data['event_id'] = $event_id;
852
-            Db::name('OaEventRelation')->where(['event_id' => $event_id])->update([
853
-                'customer_ids' => trim($relation['customer_ids'], ','),
854
-                'contacts_ids' => trim($relation['contacts_ids'], ','),
855
-                'business_ids' => trim($relation['business_ids'], ','),
856
-                'contract_ids' => trim($relation['contract_ids'], ','),
857
-            ]);
858
             
848
             
849
+           
850
+            $data['event_id'] = $event_id;
851
+            if (Db::name('OaEventRelation')->where(['event_id' => $event_id])->find()) {
852
+                Db::name('OaEventRelation')->where(['event_id' => $event_id])->update($relation);
853
+            } else {
854
+                if (!empty($relation)) {
855
+                    $relation['event_id'] = $eventId;
856
+                    $relation['status'] = 1;
857
+                    $relation['create_time'] = time();
858
+                    Db::name('OaEventRelation')->where(['event_id' => $event_id])->insert($relation);
859
+                }
860
+            }
859
             return $data;
861
             return $data;
860
         } else {
862
         } else {
861
             $this->error = '编辑失败';
863
             $this->error = '编辑失败';
862
             return false;
864
             return false;
863
         }
865
         }
864
     }
866
     }
865
-
867
+    
866
     /**
868
     /**
867
      * 日程数据
869
      * 日程数据
868
      *
870
      *
876
     {
878
     {
877
         # 日程数据
879
         # 日程数据
878
         $eventData = Db::name('oa_event')->where('event_id', $eventId)->find();
880
         $eventData = Db::name('oa_event')->where('event_id', $eventId)->find();
879
-
881
+        
880
         # 颜色类型
882
         # 颜色类型
881
         $eventData['color'] = Db::name('admin_oa_schedule')->where('schedule_id', $eventData['schedule_id'])->value('color');
883
         $eventData['color'] = Db::name('admin_oa_schedule')->where('schedule_id', $eventData['schedule_id'])->value('color');
882
-
884
+        
883
         # 创建人信息
885
         # 创建人信息
884
         $eventData['create_user_name'] = Db::name('admin_user')->where('id', $eventData['create_user_id'])->value('realname');
886
         $eventData['create_user_name'] = Db::name('admin_user')->where('id', $eventData['create_user_id'])->value('realname');
885
-
887
+        
886
         # 参与人信息
888
         # 参与人信息
887
         $eventData['owner_user_info'] = Db::name('admin_user')->field(['id', 'realname'])->whereIn('id', trim($eventData['owner_user_ids'], ','))->select();
889
         $eventData['owner_user_info'] = Db::name('admin_user')->field(['id', 'realname'])->whereIn('id', trim($eventData['owner_user_ids'], ','))->select();
888
-
890
+        
889
         # 处理日程的日期数据
891
         # 处理日程的日期数据
890
         $eventData['start_time'] = !empty($eventData['start_time']) ? date('Y-m-d H:i:s', $eventData['start_time']) : '';
892
         $eventData['start_time'] = !empty($eventData['start_time']) ? date('Y-m-d H:i:s', $eventData['start_time']) : '';
891
         $eventData['end_time'] = !empty($eventData['end_time']) ? date('Y-m-d H:i:s', $eventData['end_time']) : '';
893
         $eventData['end_time'] = !empty($eventData['end_time']) ? date('Y-m-d H:i:s', $eventData['end_time']) : '';
892
         $eventData['create_time'] = !empty($eventData['create_time']) ? date('Y-m-d H:i:s', $eventData['create_time']) : '';
894
         $eventData['create_time'] = !empty($eventData['create_time']) ? date('Y-m-d H:i:s', $eventData['create_time']) : '';
893
         $eventData['update_time'] = !empty($eventData['update_time']) ? date('Y-m-d H:i:s', $eventData['update_time']) : '';
895
         $eventData['update_time'] = !empty($eventData['update_time']) ? date('Y-m-d H:i:s', $eventData['update_time']) : '';
894
-
896
+        
895
         # 日程提醒数据
897
         # 日程提醒数据
896
         $noticeData = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
898
         $noticeData = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
897
-
899
+        
898
         # 整理日程提醒数据
900
         # 整理日程提醒数据
899
         $eventData['notice'] = [];
901
         $eventData['notice'] = [];
900
         foreach ($noticeData as $key => $value) {
902
         foreach ($noticeData as $key => $value) {
903
                 'value' => $value['number']
905
                 'value' => $value['number']
904
             ];
906
             ];
905
         }
907
         }
906
-
908
+        
907
         # 关联客户数据
909
         # 关联客户数据
908
         $relationData = Db::name('oa_event_relation')->where('event_id', $eventId)->find();
910
         $relationData = Db::name('oa_event_relation')->where('event_id', $eventId)->find();
909
-
911
+        
910
         # 关联的客户数据
912
         # 关联的客户数据
911
         $eventData['customer'] = [];
913
         $eventData['customer'] = [];
912
         if (!empty($relationData['customer_ids'])) {
914
         if (!empty($relationData['customer_ids'])) {
927
         if (!empty($relationData['contract_ids'])) {
929
         if (!empty($relationData['contract_ids'])) {
928
             $eventData['contract'] = Db::name('crm_contract')->field(['contract_id', 'name'])->whereIn('contract_id', trim($relationData['contract_ids'], ','))->select();
930
             $eventData['contract'] = Db::name('crm_contract')->field(['contract_id', 'name'])->whereIn('contract_id', trim($relationData['contract_ids'], ','))->select();
929
         }
931
         }
930
-
932
+        
931
         return $eventData;
933
         return $eventData;
932
     }
934
     }
933
-
935
+    
934
     //根据ID 删除日程
936
     //根据ID 删除日程
935
     public function delDataById($param)
937
     public function delDataById($param)
936
     {
938
     {
939
             $this->error = '数据不存在或已删除';
941
             $this->error = '数据不存在或已删除';
940
             return false;
942
             return false;
941
         }
943
         }
942
-
944
+        
943
         if ($dataInfo['create_user_id'] != $param['user_id']) {
945
         if ($dataInfo['create_user_id'] != $param['user_id']) {
944
             $this->error = '没有编辑权限';
946
             $this->error = '没有编辑权限';
945
             return false;
947
             return false;
946
         }
948
         }
947
-
949
+        
948
         $map['event_id'] = $param['event_id'];
950
         $map['event_id'] = $param['event_id'];
949
         $map['create_user_id'] = $param['user_id'];
951
         $map['create_user_id'] = $param['user_id'];
950
         $flag = $this->where($map)->delete();
952
         $flag = $this->where($map)->delete();

+ 75
- 63
application/oa/model/Examine.php Zobrazit soubor

23
     protected $createTime = 'create_time';
23
     protected $createTime = 'create_time';
24
     protected $updateTime = 'update_time';
24
     protected $updateTime = 'update_time';
25
     protected $autoWriteTimestamp = true;
25
     protected $autoWriteTimestamp = true;
26
-    private $statusArr = ['待审核','审核中','审核通过','已拒绝','已撤回'];
27
-
26
+    private $statusArr = ['待审核', '审核中', '审核通过', '已拒绝', '已撤回'];
27
+    
28
     /**
28
     /**
29
      * [getDataList 审批list]
29
      * [getDataList 审批list]
30
      * @param     [string]                   $map [查询条件]
30
      * @param     [string]                   $map [查询条件]
38
         $userModel = new \app\admin\model\User();
38
         $userModel = new \app\admin\model\User();
39
         $fileModel = new \app\admin\model\File();
39
         $fileModel = new \app\admin\model\File();
40
         $recordModel = new \app\admin\model\Record();
40
         $recordModel = new \app\admin\model\Record();
41
-
41
+        
42
         $examine_by = $request['examine_by']; //1待我审批 2我已审批 all 全部
42
         $examine_by = $request['examine_by']; //1待我审批 2我已审批 all 全部
43
         $user_id = $request['user_id'];
43
         $user_id = $request['user_id'];
44
+        $bi = $request['bi_types'];
44
         $check_status = $request['check_status']; //0 待审批 2 审批通过 4 审批拒绝 all 全部
45
         $check_status = $request['check_status']; //0 待审批 2 审批通过 4 审批拒绝 all 全部
45
         unset($request['by']);
46
         unset($request['by']);
47
+        unset($request['bi_types']);
46
         unset($request['user_id']);
48
         unset($request['user_id']);
47
         unset($request['check_status']);
49
         unset($request['check_status']);
48
         unset($request['examine_by']);
50
         unset($request['examine_by']);
56
         }
58
         }
57
         unset($map['search']);
59
         unset($map['search']);
58
         //审批类型
60
         //审批类型
59
-        $map['examine.category_id'] = $map['examine.category_id'] ? : array('gt', 0);
60
-
61
+        $map['examine.category_id'] = $map['examine.category_id'] ?: array('gt', 0);
62
+        
61
         $map_str = '';
63
         $map_str = '';
62
         $logmap = '';
64
         $logmap = '';
63
         switch ($examine_by) {
65
         switch ($examine_by) {
71
                 $map['check_user_id'] = [['like', '%,' . $user_id . ',%']];
73
                 $map['check_user_id'] = [['like', '%,' . $user_id . ',%']];
72
                 break; //待审
74
                 break; //待审
73
             case '2' :
75
             case '2' :
74
-                $map['flow_user_id'] = [['like', '%,' . $user_id . ',%'], ['eq', $user_id], 'or'];
76
+                $map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " )
77
+                 OR ( flow_user_id LIKE '%," . $user_id . ",%'  OR `flow_user_id` = " . $user_id . " ) )";
78
+//                $map['flow_user_id'] = [['like', '%,' . $user_id . ',%'], ['eq', $user_id], 'or'];
75
                 break; //已审
79
                 break; //已审
76
             default:
80
             default:
77
                 $map['examine.create_user_id'] = $user_id;
81
                 $map['examine.create_user_id'] = $user_id;
85
             $map['examine.create_time'] = array('between', array($start_time, $end_time));
89
             $map['examine.create_time'] = array('between', array($start_time, $end_time));
86
         }
90
         }
87
         unset($map['examine.between_time']);
91
         unset($map['examine.between_time']);
88
-
92
+        
89
         //审核状态 0 待审批 2 审批通过 4 审批拒绝 all 全部
93
         //审核状态 0 待审批 2 审批通过 4 审批拒绝 all 全部
90
-        if ($check_status) {
94
+        if (isset($check_status)) {
91
             if ($check_status == 'all') {
95
             if ($check_status == 'all') {
92
                 $map['examine.check_status'] = ['egt', 0];
96
                 $map['examine.check_status'] = ['egt', 0];
93
                 if (isSuperAdministrators($user_id)) {
97
                 if (isSuperAdministrators($user_id)) {
95
                 }
99
                 }
96
             } elseif ($check_status == 4) {
100
             } elseif ($check_status == 4) {
97
                 $map['examine.check_status'] = ['eq', 3];
101
                 $map['examine.check_status'] = ['eq', 3];
102
+            } elseif ($check_status == 0) {
103
+                $map['examine.check_status'] = ['<=', 1];
98
             } else {
104
             } else {
99
                 $map['examine.check_status'] = $check_status;
105
                 $map['examine.check_status'] = $check_status;
100
-            }            
101
-        } else {
102
-            $map['examine.check_status'] = ['egt', 0];
106
+            }
107
+        }else{
108
+            if ($examine_by == 'all') {
109
+                $map['examine.check_status'] = ['egt', 0];
110
+            } elseif ($examine_by == 1) {
111
+                $map['examine.check_status'] = ['elt', 1];
112
+            } elseif($examine_by == 2) {
113
+                $map['examine.check_status'] = ['egt', 2];
114
+            }
103
         }
115
         }
104
-        
105
         $join = [
116
         $join = [
106
             ['__ADMIN_USER__ user', 'user.id = examine.create_user_id', 'LEFT'],
117
             ['__ADMIN_USER__ user', 'user.id = examine.create_user_id', 'LEFT'],
107
             ['__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT'],
118
             ['__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT'],
111
             ->where($map_str)
122
             ->where($map_str)
112
             ->where($map)
123
             ->where($map)
113
             ->join($join);
124
             ->join($join);
114
-
125
+        
115
         $list = $list_view
126
         $list = $list_view
116
             ->page($request['page'], $request['limit'])
127
             ->page($request['page'], $request['limit'])
117
             ->field('examine.*,user.realname,user.thumb_img,examine_category.title as category_name,examine_category.category_id as examine_config,examine_category.icon as examineIcon')
128
             ->field('examine.*,user.realname,user.thumb_img,examine_category.title as category_name,examine_category.category_id as examine_config,examine_category.icon as examineIcon')
123
             ->join($join)
134
             ->join($join)
124
             ->count('examine_id');
135
             ->count('examine_id');
125
         $admin_user_ids = $userModel->getAdminId();
136
         $admin_user_ids = $userModel->getAdminId();
126
-
137
+        
127
         foreach ($list as $k => $v) {
138
         foreach ($list as $k => $v) {
128
             $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
139
             $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
129
             $causeCount = 0;
140
             $causeCount = 0;
131
             $duration = $v['duration'] ?: '0.0';
142
             $duration = $v['duration'] ?: '0.0';
132
             $money = $v['money'] ?: '0.00';
143
             $money = $v['money'] ?: '0.00';
133
             if (in_array($v['category_id'], ['3', '5'])) {
144
             if (in_array($v['category_id'], ['3', '5'])) {
134
-                $causeCount = db('oa_examine_travel')->where(['examine_id' => $v['examine_id']])->count() ? : 0;
145
+                $causeCount = db('oa_examine_travel')->where(['examine_id' => $v['examine_id']])->count() ?: 0;
135
                 if ($v['category_id'] == 3) $causeTitle = $causeCount . '个行程,共' . $duration . '天';
146
                 if ($v['category_id'] == 3) $causeTitle = $causeCount . '个行程,共' . $duration . '天';
136
                 if ($v['category_id'] == 5) $causeTitle = $causeCount . '个报销事项,共' . $money . '元';
147
                 if ($v['category_id'] == 5) $causeTitle = $causeCount . '个报销事项,共' . $money . '元';
137
-
148
+                
138
                 //附件
149
                 //附件
139
                 $fileList = [];
150
                 $fileList = [];
140
                 $imgList = [];
151
                 $imgList = [];
152
                 }
163
                 }
153
                 $list[$k]['fileList'] = $fileList ?: [];
164
                 $list[$k]['fileList'] = $fileList ?: [];
154
                 $list[$k]['imgList'] = $imgList ?: [];
165
                 $list[$k]['imgList'] = $imgList ?: [];
155
-
166
+                
156
             }
167
             }
157
             $list[$k]['causeTitle'] = $causeTitle;
168
             $list[$k]['causeTitle'] = $causeTitle;
158
-            $list[$k]['causeCount'] = $causeCount ? : 0;
159
-
169
+            $list[$k]['causeCount'] = $causeCount ?: 0;
170
+            
160
             //关联业务
171
             //关联业务
161
             $relationArr = [];
172
             $relationArr = [];
162
             $relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
173
             $relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
164
             $list[$k]['contactsList'] = $relationArr['contactsList'];
175
             $list[$k]['contactsList'] = $relationArr['contactsList'];
165
             $list[$k]['contractList'] = $relationArr['contractList'];
176
             $list[$k]['contractList'] = $relationArr['contractList'];
166
             $list[$k]['customerList'] = $relationArr['customerList'];
177
             $list[$k]['customerList'] = $relationArr['customerList'];
167
-
178
+            
168
             //附件
179
             //附件
169
             $fileList = [];
180
             $fileList = [];
170
             $imgList = [];
181
             $imgList = [];
182
             }
193
             }
183
             $list[$k]['fileList'] = $fileList ?: [];
194
             $list[$k]['fileList'] = $fileList ?: [];
184
             $list[$k]['imgList'] = $imgList ?: [];
195
             $list[$k]['imgList'] = $imgList ?: [];
185
-
196
+            
186
             //创建人或管理员有撤销权限
197
             //创建人或管理员有撤销权限
187
             $permission = [];
198
             $permission = [];
188
             $is_recheck = 0;
199
             $is_recheck = 0;
195
                     $is_recheck = 1;
206
                     $is_recheck = 1;
196
                 }
207
                 }
197
             }
208
             }
198
-
209
+            
199
             //创建人(失败、撤销状态时可编辑)
210
             //创建人(失败、撤销状态时可编辑)
200
             if ($v['create_user_id'] == $user_id && in_array($v['check_status'], ['3', '4'])) {
211
             if ($v['create_user_id'] == $user_id && in_array($v['check_status'], ['3', '4'])) {
201
                 $is_update = 1;
212
                 $is_update = 1;
210
             if ($examineFlowData['config'] == 1) {
221
             if ($examineFlowData['config'] == 1) {
211
                 //固定审批流
222
                 //固定审批流
212
                 $examineStepModel = new \app\admin\model\ExamineStep();
223
                 $examineStepModel = new \app\admin\model\ExamineStep();
213
-                $nextStepData = $examineStepModel->nextStepUser($user_id, $examineFlowData['flow_id'], 'oa_examine', 0, 0, 0);
214
-                $is_check = $nextStepData['next_user_ids'] ? 1 : 0;
224
+//                $nextStepData = $examineStepModel->nextStepUser($user_id, $examineFlowData['flow_id'], 'oa_examine', 0, 0, 0);
225
+                $is_check = in_array($user_id, stringToArray($v['check_user_id'])) && in_array($v['check_status'], [0, 1]) ? 1 : 0;
215
                 $is_end = 1;
226
                 $is_end = 1;
216
             } else {
227
             } else {
217
                 $is_end = 0;
228
                 $is_end = 0;
218
-                if ($v['check_user_id'] == (',' . $user_id . ',')) {
229
+                if ($v['check_user_id'] == (',' . $user_id . ',') && in_array($v['check_status'], [0, 1])) {
219
                     $is_check = 1;
230
                     $is_check = 1;
220
-                }else{
231
+                } else {
221
                     $is_check = 0;
232
                     $is_check = 0;
222
                 }
233
                 }
223
-            }            
224
-            if ($v['last_user_id'] == 0) {
225
-                $user_name = $userModel->getListByStr(stringToArray($v['check_user_id']));
226
-                $list[$k]['examine_name'] = $user_name[0]['realname'];
227
-            } else {
228
-                $user_name = $userModel->getListByStr(stringToArray($v['last_user_id']));
229
-                $list[$k]['examine_name'] = $user_name[0]['realname'];
230
             }
234
             }
231
-
235
+            if($v['check_status']==4){
236
+                $usernames = db('admin_user')->whereIn('id', stringToArray($user_id))->column('realname');
237
+            }else{
238
+                $usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
239
+            }
240
+            
241
+            $list[$k]['examine_name'] = implode($usernames, ',');
242
+            
232
             $permission['is_check'] = $is_check;
243
             $permission['is_check'] = $is_check;
233
             $permission['is_delete'] = $is_delete;
244
             $permission['is_delete'] = $is_delete;
234
             $permission['is_recheck'] = $is_recheck;
245
             $permission['is_recheck'] = $is_recheck;
236
             $list[$k]['permission'] = $permission;
247
             $list[$k]['permission'] = $permission;
237
             $list[$k]['config'] = $is_end;
248
             $list[$k]['config'] = $is_end;
238
             $list[$k]['check_status_info'] = $this->statusArr[(int)$v['check_status']];
249
             $list[$k]['check_status_info'] = $this->statusArr[(int)$v['check_status']];
239
-            $list[$k]['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
250
+            $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
251
+            $list[$k]['update_time'] = !empty($v['update_time']) ? date('Y-m-d H:i:s', $v['update_time']) : null;
240
         }
252
         }
241
         $data = [];
253
         $data = [];
242
         $data['page']['list'] = $list;
254
         $data['page']['list'] = $list;
243
         $data['page']['dataCount'] = $dataCount ?: 0;
255
         $data['page']['dataCount'] = $dataCount ?: 0;
244
-
256
+        
245
         if ($request['page'] != 1 && (int)($request['page'] * $request['limit']) >= (int)$dataCount) {
257
         if ($request['page'] != 1 && (int)($request['page'] * $request['limit']) >= (int)$dataCount) {
246
             $data['page']['firstPage'] = false;
258
             $data['page']['firstPage'] = false;
247
             $data['page']['lastPage'] = true;
259
             $data['page']['lastPage'] = true;
254
         }
266
         }
255
         return $data;
267
         return $data;
256
     }
268
     }
257
-
269
+    
258
     /**
270
     /**
259
      * 创建审批信息
271
      * 创建审批信息
260
      * @param
272
      * @param
279
             $this->error = $validate->getError();
291
             $this->error = $validate->getError();
280
             return false;
292
             return false;
281
         }
293
         }
282
-
294
+        
283
         $categoryInfo = $examineCategoryModel->getDataById($param['category_id']);
295
         $categoryInfo = $examineCategoryModel->getDataById($param['category_id']);
284
-
296
+        
285
         $fileArr = $param['file_id']; //接收表单附件
297
         $fileArr = $param['file_id']; //接收表单附件
286
         unset($param['file_id']);
298
         unset($param['file_id']);
287
         $param['start_time'] = $param['start_time'] ? strtotime($param['start_time']) : 0;
299
         $param['start_time'] = $param['start_time'] ? strtotime($param['start_time']) : 0;
309
                 $rdata['status'] = 1;
321
                 $rdata['status'] = 1;
310
                 $rdata['create_time'] = time();
322
                 $rdata['create_time'] = time();
311
                 Db::name('OaExamineRelation')->insert($rdata);
323
                 Db::name('OaExamineRelation')->insert($rdata);
312
-
324
+                
313
                 //处理差旅相关
325
                 //处理差旅相关
314
                 $resTravel = true;
326
                 $resTravel = true;
315
                 if (in_array($param['category_id'], ['3', '5']) && $param['cause']) {
327
                 if (in_array($param['category_id'], ['3', '5']) && $param['cause']) {
329
                     ],
341
                     ],
330
                     $send_user_id
342
                     $send_user_id
331
                 );
343
                 );
332
-
333
-
344
+                
345
+                
334
                 $data = [];
346
                 $data = [];
335
                 $data['examine_id'] = $this->examine_id;
347
                 $data['examine_id'] = $this->examine_id;
336
-
348
+                
337
                 # 添加活动记录
349
                 # 添加活动记录
338
                 if (!empty($rdata['customer_ids']) || !empty($rdata['contacts_ids']) || !empty($rdata['business_ids']) || !empty($rdata['contract_ids'])) {
350
                 if (!empty($rdata['customer_ids']) || !empty($rdata['contacts_ids']) || !empty($rdata['business_ids']) || !empty($rdata['contract_ids'])) {
339
                     Db::name('crm_activity')->insert([
351
                     Db::name('crm_activity')->insert([
350
                         'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
362
                         'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
351
                     ]);
363
                     ]);
352
                 }
364
                 }
353
-
365
+                
354
                 return $data;
366
                 return $data;
355
             } else {
367
             } else {
356
                 $this->error = $examineDataModel->getError();
368
                 $this->error = $examineDataModel->getError();
361
             return false;
373
             return false;
362
         }
374
         }
363
     }
375
     }
364
-
376
+    
365
     /**
377
     /**
366
      * 编辑审批信息
378
      * 编辑审批信息
367
      *
379
      *
387
             $this->error = '数据不存在或已删除';
399
             $this->error = '数据不存在或已删除';
388
             return false;
400
             return false;
389
         }
401
         }
390
-
402
+        
391
         //过滤不能修改的字段
403
         //过滤不能修改的字段
392
         $unUpdateField = ['create_user_id', 'is_deleted', 'delete_time'];
404
         $unUpdateField = ['create_user_id', 'is_deleted', 'delete_time'];
393
         foreach ($unUpdateField as $v) {
405
         foreach ($unUpdateField as $v) {
394
             unset($param[$v]);
406
             unset($param[$v]);
395
         }
407
         }
396
         $categoryInfo = $examineCategoryModel->getDataById($dataInfo['category_id']);
408
         $categoryInfo = $examineCategoryModel->getDataById($dataInfo['category_id']);
397
-
409
+        
398
         //验证
410
         //验证
399
         $fieldModel = new \app\admin\model\Field();
411
         $fieldModel = new \app\admin\model\Field();
400
         $validateArr = $fieldModel->validateField($this->name, $dataInfo['category_id']); //获取自定义字段验证规则
412
         $validateArr = $fieldModel->validateField($this->name, $dataInfo['category_id']); //获取自定义字段验证规则
404
             $this->error = $validate->getError();
416
             $this->error = $validate->getError();
405
             return false;
417
             return false;
406
         }
418
         }
407
-
419
+        
408
         $fileArr = $param['file_id']; //接收表单附件
420
         $fileArr = $param['file_id']; //接收表单附件
409
         unset($param['file_id']);
421
         unset($param['file_id']);
410
         $param['start_time'] = $param['start_time'] ? strtotime($param['start_time']) : 0;
422
         $param['start_time'] = $param['start_time'] ? strtotime($param['start_time']) : 0;
422
                         return false;
434
                         return false;
423
                     }
435
                     }
424
                 }
436
                 }
425
-
437
+                
426
                 //站内信
438
                 //站内信
427
                 $send_user_id = stringToArray($param['check_user_id']);
439
                 $send_user_id = stringToArray($param['check_user_id']);
428
                 if ($send_user_id) {
440
                 if ($send_user_id) {
435
                         $send_user_id
447
                         $send_user_id
436
                     );
448
                     );
437
                 }
449
                 }
438
-
450
+                
439
                 //相关业务
451
                 //相关业务
440
                 $rdata = [];
452
                 $rdata = [];
441
                 $rdata['customer_ids'] = $param['oaExamineRelation']['customer_ids'] ? arrayToString($param['oaExamineRelation']['customer_ids']) : [];
453
                 $rdata['customer_ids'] = $param['oaExamineRelation']['customer_ids'] ? arrayToString($param['oaExamineRelation']['customer_ids']) : [];
443
                 $rdata['business_ids'] = $param['oaExamineRelation']['business_ids'] ? arrayToString($param['oaExamineRelation']['business_ids']) : [];
455
                 $rdata['business_ids'] = $param['oaExamineRelation']['business_ids'] ? arrayToString($param['oaExamineRelation']['business_ids']) : [];
444
                 $rdata['contract_ids'] = $param['oaExamineRelation']['contract_ids'] ? arrayToString($param['oaExamineRelation']['contract_ids']) : [];
456
                 $rdata['contract_ids'] = $param['oaExamineRelation']['contract_ids'] ? arrayToString($param['oaExamineRelation']['contract_ids']) : [];
445
                 Db::name('OaExamineRelation')->where('examine_id = ' . $examine_id)->update($rdata);
457
                 Db::name('OaExamineRelation')->where('examine_id = ' . $examine_id)->update($rdata);
446
-
458
+                
447
                 //处理差旅相关
459
                 //处理差旅相关
448
                 $resTravel = true;
460
                 $resTravel = true;
449
                 if (in_array($dataInfo['category_id'], ['3', '5']) && $param['cause']) {
461
                 if (in_array($dataInfo['category_id'], ['3', '5']) && $param['cause']) {
465
                         $send_user_id
477
                         $send_user_id
466
                     );
478
                     );
467
                 }
479
                 }
468
-
480
+                
469
                 $data = [];
481
                 $data = [];
470
                 $data['examine_id'] = $examine_id;
482
                 $data['examine_id'] = $examine_id;
471
-
483
+                
472
                 # 删除活动记录
484
                 # 删除活动记录
473
                 Db::name('crm_activity')->where(['activity_type' => 9, 'activity_type_id' => $examine_id])->delete();
485
                 Db::name('crm_activity')->where(['activity_type' => 9, 'activity_type_id' => $examine_id])->delete();
474
                 # 添加活动记录
486
                 # 添加活动记录
487
                         'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
499
                         'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
488
                     ]);
500
                     ]);
489
                 }
501
                 }
490
-
502
+                
491
                 return $data;
503
                 return $data;
492
             } else {
504
             } else {
493
                 $this->error = $examineDataModel->getError();
505
                 $this->error = $examineDataModel->getError();
498
             return false;
510
             return false;
499
         }
511
         }
500
     }
512
     }
501
-
513
+    
502
     /**
514
     /**
503
      * 审批数据
515
      * 审批数据
504
      * @param  $id 审批ID
516
      * @param  $id 审批ID
516
             ->where($map)
528
             ->where($map)
517
             ->alias('examine')
529
             ->alias('examine')
518
             ->join('__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT');
530
             ->join('__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT');
519
-
531
+        
520
         $dataInfo = $data_view
532
         $dataInfo = $data_view
521
             ->field('examine.*,examine_category.title as category_name,examine_category.icon as examineIcon')
533
             ->field('examine.*,examine_category.title as category_name,examine_category.icon as examineIcon')
522
             ->find();
534
             ->find();
534
         // foreach ($fieldList as $k=>$v) {
546
         // foreach ($fieldList as $k=>$v) {
535
         // 	$dataInfo[$v] = $fieldModel->getFormValueByField($v, $dataInfo[$v]);
547
         // 	$dataInfo[$v] = $fieldModel->getFormValueByField($v, $dataInfo[$v]);
536
         // }
548
         // }
537
-
549
+        
538
         //关联业务
550
         //关联业务
539
         $relationArr = [];
551
         $relationArr = [];
540
         $relationArr = $recordModel->getListByRelationId('examine', $id);
552
         $relationArr = $recordModel->getListByRelationId('examine', $id);
542
         $dataInfo['contactsList'] = $relationArr['contactsList'];
554
         $dataInfo['contactsList'] = $relationArr['contactsList'];
543
         $dataInfo['contractList'] = $relationArr['contractList'];
555
         $dataInfo['contractList'] = $relationArr['contractList'];
544
         $dataInfo['customerList'] = $relationArr['customerList'];
556
         $dataInfo['customerList'] = $relationArr['customerList'];
545
-
557
+        
546
         $travelList = [];
558
         $travelList = [];
547
         if (in_array($dataInfo['category_id'], ['3', '5'])) {
559
         if (in_array($dataInfo['category_id'], ['3', '5'])) {
548
             //行程、费用明细
560
             //行程、费用明细
574
             }
586
             }
575
         }
587
         }
576
         $dataInfo['travelList'] = $travelList;
588
         $dataInfo['travelList'] = $travelList;
577
-
589
+        
578
         //附件
590
         //附件
579
         $fileList = [];
591
         $fileList = [];
580
         $imgList = [];
592
         $imgList = [];
596
         $dataInfo['examine_id'] = $id;
608
         $dataInfo['examine_id'] = $id;
597
         return $dataInfo;
609
         return $dataInfo;
598
     }
610
     }
599
-
611
+    
600
     /**
612
     /**
601
      * 审批差旅数据保存
613
      * 审批差旅数据保存
602
      * @param examine_id 审批ID
614
      * @param examine_id 审批ID
615
             unset($v['files']);
627
             unset($v['files']);
616
             $newData = $v;
628
             $newData = $v;
617
             $newData['examine_id'] = $examine_id;
629
             $newData['examine_id'] = $examine_id;
618
-
630
+            
619
             $fileArr = $v['file_id']; //接收表单附件
631
             $fileArr = $v['file_id']; //接收表单附件
620
             unset($newData['file_id']);
632
             unset($newData['file_id']);
621
             unset($newData['fileList']);
633
             unset($newData['fileList']);
643
         }
655
         }
644
         return true;
656
         return true;
645
     }
657
     }
646
-
658
+    
647
     /**
659
     /**
648
      * 审批差旅数据编辑
660
      * 审批差旅数据编辑
649
      * @param examine_id 审批ID
661
      * @param examine_id 审批ID
657
         }
669
         }
658
         $oldTravelIds = db('oa_examine_travel')->where(['examine_id' => $examine_id])->column('travel_id');
670
         $oldTravelIds = db('oa_examine_travel')->where(['examine_id' => $examine_id])->column('travel_id');
659
         $oldTravelFileIds = db('oa_examine_travel_file')->where(['travel_id' => ['in', $oldTravelIds]])->column('r_id');
671
         $oldTravelFileIds = db('oa_examine_travel_file')->where(['travel_id' => ['in', $oldTravelIds]])->column('r_id');
660
-
672
+        
661
         $successRes = true;
673
         $successRes = true;
662
         foreach ($data as $k => $v) {
674
         foreach ($data as $k => $v) {
663
             $newData = [];
675
             $newData = [];

+ 24
- 24
application/oa/model/Log.php Zobrazit soubor

23
     protected $createTime = 'create_time';
23
     protected $createTime = 'create_time';
24
     protected $updateTime = 'update_time';
24
     protected $updateTime = 'update_time';
25
     protected $autoWriteTimestamp = true;
25
     protected $autoWriteTimestamp = true;
26
-
26
+    
27
     /**
27
     /**
28
      * [getDataList 日志list]
28
      * [getDataList 日志list]
29
      * @param     [string]                   $map [查询条件]
29
      * @param     [string]                   $map [查询条件]
39
         $fileModel = new \app\admin\model\File();
39
         $fileModel = new \app\admin\model\File();
40
         $commonModel = new \app\admin\model\Comment();
40
         $commonModel = new \app\admin\model\Comment();
41
         $recordModel = new \app\admin\model\Record();
41
         $recordModel = new \app\admin\model\Record();
42
-
42
+        
43
         $user_id = $request['read_user_id'];
43
         $user_id = $request['read_user_id'];
44
         $by = $request['by'] ?: '';
44
         $by = $request['by'] ?: '';
45
-
45
+        
46
         $map = [];
46
         $map = [];
47
         $search = $request['search'];
47
         $search = $request['search'];
48
         if (isset($request['search']) && $request['search']) {
48
         if (isset($request['search']) && $request['search']) {
138
             $list[$k]['contactsList'] = $relationArr['contactsList'];
138
             $list[$k]['contactsList'] = $relationArr['contactsList'];
139
             $list[$k]['contractList'] = $relationArr['contractList'];
139
             $list[$k]['contractList'] = $relationArr['contractList'];
140
             $list[$k]['customerList'] = $relationArr['customerList'];
140
             $list[$k]['customerList'] = $relationArr['customerList'];
141
-
141
+            
142
             if ($v['is_relation'] == 1) {
142
             if ($v['is_relation'] == 1) {
143
                 $list[$k]['bulletin']['customerNum'] = $v['save_customer'];
143
                 $list[$k]['bulletin']['customerNum'] = $v['save_customer'];
144
                 $list[$k]['bulletin']['businessNum'] = $v['save_business'];
144
                 $list[$k]['bulletin']['businessNum'] = $v['save_business'];
148
             } else {
148
             } else {
149
                 $list[$k]['bulletin'] = 0;
149
                 $list[$k]['bulletin'] = 0;
150
             }
150
             }
151
-
151
+            
152
             $is_update = 0;
152
             $is_update = 0;
153
             $is_delete = 0;
153
             $is_delete = 0;
154
             //3天内的日志可删,可修改
154
             //3天内的日志可删,可修改
183
             $data['page']['firstPage'] = true;
183
             $data['page']['firstPage'] = true;
184
             $data['page']['lastPage'] = false;
184
             $data['page']['lastPage'] = false;
185
         }
185
         }
186
-
186
+        
187
         return $data;
187
         return $data;
188
     }
188
     }
189
-
190
-
189
+    
190
+    
191
     // 创建日志信息
191
     // 创建日志信息
192
     public function createData($param)
192
     public function createData($param)
193
     {
193
     {
209
         foreach ($arr as $value) {
209
         foreach ($arr as $value) {
210
             unset($param[$value]);
210
             unset($param[$value]);
211
         }
211
         }
212
-
212
+        
213
         if ($param['category_id'] == 1) {
213
         if ($param['category_id'] == 1) {
214
             $param['title'] = date('Y-m-d') . '-日报';
214
             $param['title'] = date('Y-m-d') . '-日报';
215
         } else if ($param['category_id'] == 2) {
215
         } else if ($param['category_id'] == 2) {
217
         } else if ($param['category_id'] == 3) {
217
         } else if ($param['category_id'] == 3) {
218
             $param['title'] = date('Y-m-d') . '-月报';
218
             $param['title'] = date('Y-m-d') . '-月报';
219
         }
219
         }
220
-
220
+        
221
         if ($this->data($param)->allowField(true)->save()) {
221
         if ($this->data($param)->allowField(true)->save()) {
222
             $log_id = $this->log_id;
222
             $log_id = $this->log_id;
223
             //操作记录
223
             //操作记录
231
                     return false;
231
                     return false;
232
                 }
232
                 }
233
             }
233
             }
234
-
234
+            
235
             $temp = User::where(['structure_id' => ['in', $param['send_structure_ids']]])->column('id');
235
             $temp = User::where(['structure_id' => ['in', $param['send_structure_ids']]])->column('id');
236
             (new Message())->send(
236
             (new Message())->send(
237
                 Message::LOG_SEND,
237
                 Message::LOG_SEND,
245
             $data = [];
245
             $data = [];
246
             $data['log_id'] = $log_id;
246
             $data['log_id'] = $log_id;
247
             $data = $param;
247
             $data = $param;
248
-
248
+            
249
             if (count($fileArr)) {
249
             if (count($fileArr)) {
250
                 $fileList = Db::name('AdminFile')->where('file_id in (' . implode(',', $fileArr) . ')')->select();
250
                 $fileList = Db::name('AdminFile')->where('file_id in (' . implode(',', $fileArr) . ')')->select();
251
                 foreach ($fileList as $k => $v) {
251
                 foreach ($fileList as $k => $v) {
258
             //发送部门
258
             //发送部门
259
             $data['sendStructureList'] = $param['send_structure_ids'] ? $userModel->getListByStr($param['send_structure_ids']) : [];
259
             $data['sendStructureList'] = $param['send_structure_ids'] ? $userModel->getListByStr($param['send_structure_ids']) : [];
260
             $data['log_id'] = $log_id;
260
             $data['log_id'] = $log_id;
261
-
261
+            
262
             $rdata['log_id'] = $log_id;
262
             $rdata['log_id'] = $log_id;
263
             $rdata['status'] = 1;
263
             $rdata['status'] = 1;
264
             $rdata['create_time'] = time();
264
             $rdata['create_time'] = time();
265
             //关联业务
265
             //关联业务
266
             Db::name('OaLogRelation')->insert($rdata);
266
             Db::name('OaLogRelation')->insert($rdata);
267
-
267
+            
268
             //相关业务
268
             //相关业务
269
             $relationArr = $recordModel->getListByRelationId('log', $log_id);
269
             $relationArr = $recordModel->getListByRelationId('log', $log_id);
270
             $data['businessList'] = $relationArr['businessList'];
270
             $data['businessList'] = $relationArr['businessList'];
271
             $data['contactsList'] = $relationArr['contactsList'];
271
             $data['contactsList'] = $relationArr['contactsList'];
272
             $data['contractList'] = $relationArr['contractList'];
272
             $data['contractList'] = $relationArr['contractList'];
273
             $data['customerList'] = $relationArr['customerList'];
273
             $data['customerList'] = $relationArr['customerList'];
274
-
274
+            
275
             # 添加活动记录
275
             # 添加活动记录
276
             if (!empty($rdata['customer_ids']) || !empty($rdata['contacts_ids']) || !empty($rdata['business_ids']) || !empty($rdata['contract_ids'])) {
276
             if (!empty($rdata['customer_ids']) || !empty($rdata['contacts_ids']) || !empty($rdata['business_ids']) || !empty($rdata['contract_ids'])) {
277
                 Db::name('crm_activity')->insert([
277
                 Db::name('crm_activity')->insert([
288
                     'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
288
                     'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
289
                 ]);
289
                 ]);
290
             }
290
             }
291
-
291
+            
292
             return $data;
292
             return $data;
293
         } else {
293
         } else {
294
             $this->error = '添加失败';
294
             $this->error = '添加失败';
295
             return false;
295
             return false;
296
         }
296
         }
297
     }
297
     }
298
-
298
+    
299
     /**
299
     /**
300
      * 编辑日志信息
300
      * 编辑日志信息
301
      * @param
301
      * @param
318
         $rdata['contacts_ids'] = $param['contacts_ids'] ? arrayToString($param['contacts_ids']) : '';
318
         $rdata['contacts_ids'] = $param['contacts_ids'] ? arrayToString($param['contacts_ids']) : '';
319
         $rdata['business_ids'] = $param['business_ids'] ? arrayToString($param['business_ids']) : '';
319
         $rdata['business_ids'] = $param['business_ids'] ? arrayToString($param['business_ids']) : '';
320
         $rdata['contract_ids'] = $param['contract_ids'] ? arrayToString($param['contract_ids']) : '';
320
         $rdata['contract_ids'] = $param['contract_ids'] ? arrayToString($param['contract_ids']) : '';
321
-
321
+        
322
         $arr = ['customer_ids', 'contacts_ids', 'business_ids', 'contract_ids'];
322
         $arr = ['customer_ids', 'contacts_ids', 'business_ids', 'contract_ids'];
323
         foreach ($arr as $value) {
323
         foreach ($arr as $value) {
324
             unset($param[$value]);
324
             unset($param[$value]);
332
         unset($param['file']);
332
         unset($param['file']);
333
         $param['send_user_ids'] = $param['send_user_ids'] ? arrayToString($param['send_user_ids']) : '';
333
         $param['send_user_ids'] = $param['send_user_ids'] ? arrayToString($param['send_user_ids']) : '';
334
         $param['send_structure_ids'] = $param['send_structure_ids'] ? arrayToString($param['send_structure_ids']) : '';
334
         $param['send_structure_ids'] = $param['send_structure_ids'] ? arrayToString($param['send_structure_ids']) : '';
335
-
335
+        
336
         if ($this->allowField(true)->save($param, ['log_id' => $log_id])) {
336
         if ($this->allowField(true)->save($param, ['log_id' => $log_id])) {
337
             //操作日志
337
             //操作日志
338
             Db::name('AdminActionLog')->where(['action_id' => $log_id])->update(['join_user_ids' => $this->send_user_ids, 'structure_ids' => $this->send_structure_ids]);
338
             Db::name('AdminActionLog')->where(['action_id' => $log_id])->update(['join_user_ids' => $this->send_user_ids, 'structure_ids' => $this->send_structure_ids]);
373
             return false;
373
             return false;
374
         }
374
         }
375
     }
375
     }
376
-
376
+    
377
     /**
377
     /**
378
      * 日志数据
378
      * 日志数据
379
      * @param  $id 日志ID
379
      * @param  $id 日志ID
385
         $userModel = new \app\admin\model\User();
385
         $userModel = new \app\admin\model\User();
386
         $structureModel = new \app\admin\model\Structure();
386
         $structureModel = new \app\admin\model\Structure();
387
         $commonModel = new \app\admin\model\Comment();
387
         $commonModel = new \app\admin\model\Comment();
388
-
388
+        
389
         $map['log.log_id'] = $id;
389
         $map['log.log_id'] = $id;
390
         $data_view = db('oa_log')
390
         $data_view = db('oa_log')
391
             ->where($map)
391
             ->where($map)
396
             $this->error = '暂无此数据';
396
             $this->error = '暂无此数据';
397
             return false;
397
             return false;
398
         }
398
         }
399
-
399
+        
400
         $relation = Db::name('OaLogRelation')->where('log_id =' . $id)->find();
400
         $relation = Db::name('OaLogRelation')->where('log_id =' . $id)->find();
401
         $BusinessModel = new \app\crm\model\Business(); //商机
401
         $BusinessModel = new \app\crm\model\Business(); //商机
402
         $dataInfo['businessList'] = $relation['business_ids'] ? $BusinessModel->getDataByStr($relation['business_ids']) : [];
402
         $dataInfo['businessList'] = $relation['business_ids'] ? $BusinessModel->getDataByStr($relation['business_ids']) : [];
406
         $dataInfo['contractList'] = $relation['contract_ids'] ? $ContractModel->getDataByStr($relation['contract_ids']) : [];
406
         $dataInfo['contractList'] = $relation['contract_ids'] ? $ContractModel->getDataByStr($relation['contract_ids']) : [];
407
         $CustomerModel = new \app\crm\model\Customer();//客户
407
         $CustomerModel = new \app\crm\model\Customer();//客户
408
         $dataInfo['customerList'] = $relation['customer_ids'] ? $CustomerModel->getDataByStr($relation['customer_ids']) : [];
408
         $dataInfo['customerList'] = $relation['customer_ids'] ? $CustomerModel->getDataByStr($relation['customer_ids']) : [];
409
-
409
+        
410
         $dataInfo['create_user_info']['realname'] = $dataInfo['realname'] ?: '';
410
         $dataInfo['create_user_info']['realname'] = $dataInfo['realname'] ?: '';
411
         $dataInfo['create_user_info']['id'] = $dataInfo['create_user_id'] ?: '';
411
         $dataInfo['create_user_info']['id'] = $dataInfo['create_user_id'] ?: '';
412
         $dataInfo['create_user_info']['thumb_img'] = $dataInfo['thumb_img'] ? getFullPath($dataInfo['thumb_img']) : '';
412
         $dataInfo['create_user_info']['thumb_img'] = $dataInfo['thumb_img'] ? getFullPath($dataInfo['thumb_img']) : '';
430
         $dataInfo['replyList'] = $commonModel->read($param);
430
         $dataInfo['replyList'] = $commonModel->read($param);
431
         return $dataInfo;
431
         return $dataInfo;
432
     }
432
     }
433
-
433
+    
434
     /**
434
     /**
435
      * 日志删除
435
      * 日志删除
436
      *
436
      *

+ 2
- 2
application/work/controller/Task.php Zobrazit soubor

333
         # 获取任务的项目信息
333
         # 获取任务的项目信息
334
         $workInfo = Db::name('work')->field(['work_id', 'group_id', 'is_open'])->where('work_id', $taskData['work_id'])->find();
334
         $workInfo = Db::name('work')->field(['work_id', 'group_id', 'is_open'])->where('work_id', $taskData['work_id'])->find();
335
         # 是否是公开项目
335
         # 是否是公开项目
336
-        $userId  = empty($workInfo['is_open'])  ? $userInfo['id'] : 0;
337
-        $groupId = !empty($workInfo['is_open']) ? $workInfo['group_id ']   : 0;
336
+        $userId  = $userInfo['id'];
337
+        $groupId = !empty($workInfo['is_open']) ? $workInfo['group_id'] : 0;
338
         # 获取项目下的权限
338
         # 获取项目下的权限
339
         $taskData['auth'] = !empty($taskData['work_id']) ? $this->getRuleList($workInfo['work_id'], $userId, $groupId) : [];
339
         $taskData['auth'] = !empty($taskData['work_id']) ? $this->getRuleList($workInfo['work_id'], $userId, $groupId) : [];
340
 
340
 

+ 3
- 0
application/work/controller/Tasklable.php Zobrazit soubor

84
             $str = ','.$userInfo['id'].',';
84
             $str = ','.$userInfo['id'].',';
85
             $param['whereStr'] = ' ( task.create_user_id ='.$userInfo['id'].' or (  task.owner_user_id like "%'.$str.'%") or ( task.main_user_id = '.$userInfo['id'].' ) )';
85
             $param['whereStr'] = ' ( task.create_user_id ='.$userInfo['id'].' or (  task.owner_user_id like "%'.$str.'%") or ( task.main_user_id = '.$userInfo['id'].' ) )';
86
         }
86
         }
87
+        # 标签列表只查询项目下的任务
88
+        $param['work_id'] = ['neq', 0];
89
+
87
         $resData = $taskModel->getTaskList($param);
90
         $resData = $taskModel->getTaskList($param);
88
         $taskList = $resData['list'] ? : [];
91
         $taskList = $resData['list'] ? : [];
89
         
92
         

+ 21
- 1
application/work/controller/Work.php Zobrazit soubor

147
         $workInfo = $workModel->getDataById($this->param['work_id']);
147
         $workInfo = $workModel->getDataById($this->param['work_id']);
148
 
148
 
149
         # 是否是公开项目
149
         # 是否是公开项目
150
-        $userId  = empty($workInfo['is_open'])  ? $this->userInfo['id'] : 0;
150
+        $userId  = $this->userInfo['id'];
151
         $groupId = !empty($workInfo['is_open']) ? $workInfo['group_id'] : 0;
151
         $groupId = !empty($workInfo['is_open']) ? $workInfo['group_id'] : 0;
152
 
152
 
153
         # 项目成员
153
         # 项目成员
632
 
632
 
633
         return resultArray(['data' => '操作成功!']);
633
         return resultArray(['data' => '操作成功!']);
634
     }
634
     }
635
+    
636
+    /**
637
+     * 项目排序
638
+     *
639
+     * @author      alvin guogaobo
640
+     * @version     1.0 版本号
641
+     * @since       2021/2/23 0023 15:27
642
+     */
643
+//    public function workStart(){
644
+//        $param=$this->param;
645
+//        $userInfo=$this->userInfo;
646
+//        $param['work']=serialize($param);
647
+//        $param['user_id']=$userInfo['id'];
648
+//        $workStart=new WorkLogic();
649
+//        $res=$workStart->workStart($param);
650
+//        if(!$res){
651
+//            return resultArray(['error'=>'操作失败']);
652
+//        }
653
+//        return resultArray(['data'=>'操作成功']);
654
+//    }
635
 }
655
 }
636
  
656
  

+ 129
- 39
application/work/logic/WorkLogic.php Zobrazit soubor

14
 class WorkLogic
14
 class WorkLogic
15
 {
15
 {
16
     use WorkAuthTrait;
16
     use WorkAuthTrait;
17
-
17
+    
18
     public function index($param)
18
     public function index($param)
19
     {
19
     {
20
         # 排序
20
         # 排序
21
         $orderField = 'work_id';
21
         $orderField = 'work_id';
22
-        $orderSort  = 'asc';
22
+        $orderSort = 'asc';
23
         if (!empty($param['sort_type']) && $param['sort_type'] == 1) {
23
         if (!empty($param['sort_type']) && $param['sort_type'] == 1) {
24
             $orderField = 'work_id';
24
             $orderField = 'work_id';
25
-            $orderSort  = 'asc';
25
+            $orderSort = 'asc';
26
         }
26
         }
27
         if (!empty($param['sort_type']) && $param['sort_type'] == 2) {
27
         if (!empty($param['sort_type']) && $param['sort_type'] == 2) {
28
             $orderField = 'work_id';
28
             $orderField = 'work_id';
29
-            $orderSort  = 'desc';
29
+            $orderSort = 'desc';
30
         }
30
         }
31
         if (!empty($param['sort_type']) && $param['sort_type'] == 3) {
31
         if (!empty($param['sort_type']) && $param['sort_type'] == 3) {
32
             $orderField = 'update_time';
32
             $orderField = 'update_time';
33
-            $orderSort  = 'desc';
33
+            $orderSort = 'desc';
34
         }
34
         }
35
-
35
+        
36
         # 搜索
36
         # 搜索
37
         $searchWhere = '';
37
         $searchWhere = '';
38
-        $dateWhere   = [];
39
-        $userWhere   = [];
38
+        $dateWhere = [];
39
+        $userWhere = [];
40
         $ownerUserId = !empty($param['owner_user_id']) ? $param['owner_user_id'] : '';
40
         $ownerUserId = !empty($param['owner_user_id']) ? $param['owner_user_id'] : '';
41
-        $search      = !empty($param['search'])        ? $param['search']        : '';
42
-        $type        = !empty($param['type'])          ? $param['type']          : 0;
43
-        $startTime   = !empty($param['start_time'])    ? $param['start_time']    : '';
44
-        $endTime     = !empty($param['end_time'])      ? $param['end_time']      : '';
41
+        $search = !empty($param['search']) ? $param['search'] : '';
42
+        $type = !empty($param['type']) ? $param['type'] : 0;
43
+        $startTime = !empty($param['start_time']) ? $param['start_time'] : '';
44
+        $endTime = !empty($param['end_time']) ? $param['end_time'] : '';
45
         unset($param['search']);
45
         unset($param['search']);
46
         unset($param['type']);
46
         unset($param['type']);
47
         unset($param['start_time']);
47
         unset($param['start_time']);
48
         unset($param['end_time']);
48
         unset($param['end_time']);
49
         unset($param['owner_user_id']);
49
         unset($param['owner_user_id']);
50
-
50
+        
51
         switch ($type) {
51
         switch ($type) {
52
             case 1 :
52
             case 1 :
53
                 # 今天
53
                 # 今天
69
                 $dateWhere['update_time'][] = ['egt', strtotime(date('Y-01-01 00:00:00', strtotime('last year')))];
69
                 $dateWhere['update_time'][] = ['egt', strtotime(date('Y-01-01 00:00:00', strtotime('last year')))];
70
                 $dateWhere['update_time'][] = ['elt', strtotime(date('Y-12-31 23:59:59', strtotime('last year')))];
70
                 $dateWhere['update_time'][] = ['elt', strtotime(date('Y-12-31 23:59:59', strtotime('last year')))];
71
         }
71
         }
72
-
72
+        
73
         # 时间区间
73
         # 时间区间
74
         if (!empty($startTime)) $dateWhere['update_time'] = ['egt', strtotime($startTime . '00:00:00')];
74
         if (!empty($startTime)) $dateWhere['update_time'] = ['egt', strtotime($startTime . '00:00:00')];
75
-        if (!empty($endTime))   $dateWhere['update_time'] = ['elt', strtotime($endTime . '23:59:59')];
76
-
75
+        if (!empty($endTime)) $dateWhere['update_time'] = ['elt', strtotime($endTime . '23:59:59')];
76
+        
77
         # 搜索内容
77
         # 搜索内容
78
         if ($search) $searchWhere = '(name like "%' . $search . '%") OR (description like "%' . $search . '%")';
78
         if ($search) $searchWhere = '(name like "%' . $search . '%") OR (description like "%' . $search . '%")';
79
-
79
+        
80
         # 成员
80
         # 成员
81
         if (!empty($ownerUserId)) {
81
         if (!empty($ownerUserId)) {
82
             $userIds = Db::name('work_user')->whereIn('user_id', $ownerUserId)->column('work_id');
82
             $userIds = Db::name('work_user')->whereIn('user_id', $ownerUserId)->column('work_id');
83
             $userWhere['work_id'] = ['in', $userIds];
83
             $userWhere['work_id'] = ['in', $userIds];
84
         }
84
         }
85
-
86
-        $userModel  = new \app\admin\model\User();
85
+        
86
+        $userModel = new \app\admin\model\User();
87
         $perUserIds = $userModel->getUserByPer('work', 'work', 'index');
87
         $perUserIds = $userModel->getUserByPer('work', 'work', 'index');
88
-        $authUser   = array_unique(array_merge([$param['user_id']], $perUserIds));
89
-
88
+        $authUser = array_unique(array_merge([$param['user_id']], $perUserIds));
89
+        
90
         $data = Db::name('work')
90
         $data = Db::name('work')
91
-                ->where(function($query) {
92
-                    $query->where('status', 1);
93
-                    $query->where('ishidden', 0);
94
-                })
95
-                ->where(function ($query) use ($param, $authUser) {
96
-                    $query->whereOr(['create_user_id' => ['in', $authUser]]);
97
-                    $query->whereOr('is_open', 1);
98
-                    $query->whereOr(function ($query) use ($param) {
99
-                        $query->where('is_open', 0);
100
-                        $query->where('owner_user_id', 'like', '%' . $param['user_id'] . '%');
101
-                    });
102
-                })
103
-                ->where($searchWhere)
104
-                ->where($dateWhere)
105
-                ->where($userWhere)
106
-                ->order($orderField, $orderSort)->select();
91
+            ->where(function ($query) {
92
+                $query->where('status', 1);
93
+                $query->where('ishidden', 0);
94
+            })
95
+            ->where(function ($query) use ($param, $authUser) {
96
+                $query->whereOr(['create_user_id' => ['in', $authUser]]);
97
+                $query->whereOr('is_open', 1);
98
+                $query->whereOr(function ($query) use ($param) {
99
+                    $query->where('is_open', 0);
100
+                    $query->where('owner_user_id', 'like', '%' . $param['user_id'] . '%');
101
+                });
102
+            })
103
+            ->where($searchWhere)
104
+            ->where($dateWhere)
105
+            ->where($userWhere)
106
+            ->order($orderField, $orderSort)->select();
107
 
107
 
108
-        foreach ($data AS $key => $value) {
108
+        foreach ($data as $key => $value) {
109
             $data[$key]['authList']['project'] = $this->getRuleList($value['work_id'], $param['user_id'], $value['group_id']);
109
             $data[$key]['authList']['project'] = $this->getRuleList($value['work_id'], $param['user_id'], $value['group_id']);
110
         }
110
         }
111
-
111
+        
112
         return $data;
112
         return $data;
113
     }
113
     }
114
+    
115
+    /**
116
+     * @param $param work 排序数组值 user_id用户
117
+     *
118
+     * @author      alvin guogaobo
119
+     * @version     1.0 版本号
120
+     * @since       2021/2/23 15:42
121
+     */
122
+//    public function workStart($param)
123
+//    {
124
+//        $item = Db::name('workStart')->where('user_id', $param['user_id'])->find();
125
+//        $data = [];
126
+//        $data['datas'] = $param['work'];
127
+//        $data['user_id'] = $param['user_id'];
128
+//        if (!$item) {
129
+//            return Db::name('workStart')->insertGetId($data);
130
+//        } else {
131
+//            return Db::name('workStart')->where('user_id', $param['user_id'])->update([$data]);
132
+//        }
133
+//    }
134
+    
135
+    /**
136
+     * 根据数组指定键名排序数组
137
+     * @param $array array  被排序数组
138
+     * @param $key_name string 数组键名
139
+     * @param $sort   string  desc|asc  升序或者降序
140
+     * @return array 返回排序后的数组
141
+     */
142
+//    function gw_sort($array, $param)
143
+//    {
144
+//        $whilr = array
145
+//        (
146
+//            [0] => ['work_id' => 5,
147
+//                'name' => 222,
148
+//                'status' => 1,
149
+//                'create_time' => 1613628469,
150
+//                'create_user_id' => 7,
151
+//                'description' => 222,
152
+//                'color' => '#53D397',
153
+//                'is_open' => 1,
154
+//                'owner_user_id' => ',1,2,3,4,5,7,',
155
+//                'ishidden' => 0,
156
+//                'archive_time' => 0,
157
+//                'group_id' => 12,
158
+//                'cover_url' => 'http://192.168.1.31/72crm-php/public/uploads/20210218/12ece02733c8684ce987f207062173b5.png',
159
+//                'update_time' => 1613629916,
160
+//                'is_follow' => 0,
161
+//                'is_system_cover' => 0,],
162
+//
163
+//            [1] => [
164
+//
165
+//                'work_id' => 7,
166
+//                'name' => '啊啊',
167
+//                'status' => 1,
168
+//                'create_time' => 1614059388,
169
+//                'create_user_id' => 1,
170
+//                'description' => '',
171
+//                'color' => '#53D397',
172
+//                'is_open' => 0,
173
+//                'owner_user_id' => ',1,3,',
174
+//                'ishidden' => 0,
175
+//                'archive_time' => 0,
176
+//                'group_id' => 12,
177
+//                'cover_url' => 'https://file.72crm.com/static/pc/images/pm/project-cover-1.jpg',
178
+//                'update_time' => 1614059926,
179
+//                'is_follow' => 0,
180
+//                'is_system_cover' => 1,
181
+//            ]
182
+//
183
+//        );
184
+//        $item = Db::name('workStart')->where('user_id', $param['user_id'])->find();
185
+//        $key_name_array = array();//保存被排序数组键名
186
+//        foreach ($whilr as $key => $val) {
187
+//            foreach ($item as $v){
188
+//                $key_name_array[] = array_merge(array_flip($val), $v);
189
+//            }
190
+//        }
191
+//        $key_name_array = array_flip($key_name_array);//反转键名和值得到数组排序后的位置
192
+//        $result = array();
193
+//        foreach($array as $k=>$v){
194
+//            foreach ($item as $vall){
195
+//                $this_key_name_value = $v[$vall];//当前数组键名值依次是20,10,30
196
+//                $save_position = $key_name_array[$this_key_name_value];//获取20,10,30排序后存储位置
197
+//                $result[$save_position] = $v;//当前项存储到数组指定位置
198
+//            }
199
+//        }
200
+//        ksort($result);
201
+//
202
+//        return $result;
203
+//    }
114
 }
204
 }

+ 48
- 36
application/work/model/Task.php Zobrazit soubor

50
         $workModel = model('Work');
50
         $workModel = model('Work');
51
         $userModel = new \app\admin\model\User();
51
         $userModel = new \app\admin\model\User();
52
         $work_id = $request['work_id'];
52
         $work_id = $request['work_id'];
53
+        $map=[];
53
         $ret = $workModel->checkWork($work_id, $user_id);
54
         $ret = $workModel->checkWork($work_id, $user_id);
54
         if (!$ret) {
55
         if (!$ret) {
55
             $this->error = $workModel->getError();
56
             $this->error = $workModel->getError();
68
         } else {
69
         } else {
69
             $newList = $classList['list'];
70
             $newList = $classList['list'];
70
         }
71
         }
71
-
72
-        if ($request['main_user_id']) {
73
-            $map['main_user_id'] = ['in', $request['main_user_id']];
74
-        }
75
-        //截止时间
72
+        
76
         if ($request['stop_time_type']) {
73
         if ($request['stop_time_type']) {
77
             if ($request['stop_time_type'] == '5') { //没有截至日期
74
             if ($request['stop_time_type'] == '5') { //没有截至日期
78
                 $map['stop_time'] = '0';
75
                 $map['stop_time'] = '0';
104
                 $map['stop_time'] = ['between', [$timeAry[0], $timeAry[1]]];
101
                 $map['stop_time'] = ['between', [$timeAry[0], $timeAry[1]]];
105
             }
102
             }
106
         }
103
         }
104
+      
107
         if ($request['lable_id']) {
105
         if ($request['lable_id']) {
108
             $taskIds = [];
106
             $taskIds = [];
109
             $task_ids = [];
107
             $task_ids = [];
125
             }
123
             }
126
             $map['task_id'] = ['in', $task_ids];
124
             $map['task_id'] = ['in', $task_ids];
127
         }
125
         }
126
+        
128
         $data = array();
127
         $data = array();
129
         foreach ($newList as $key => $value) {
128
         foreach ($newList as $key => $value) {
130
             $data[$key]['class_id'] = $value['class_id'] ?: -1;
129
             $data[$key]['class_id'] = $value['class_id'] ?: -1;
131
             $data[$key]['class_name'] = $value['name'];
130
             $data[$key]['class_name'] = $value['name'];
132
-
131
+           
133
             $map['status'] = $map['status'] ?: ['in', ['1', '5']];
132
             $map['status'] = $map['status'] ?: ['in', ['1', '5']];
133
+           
134
             $map['ishidden'] = 0;
134
             $map['ishidden'] = 0;
135
             $map['work_id'] = $request['work_id'];
135
             $map['work_id'] = $request['work_id'];
136
             $map['class_id'] = $value['class_id'];
136
             $map['class_id'] = $value['class_id'];
137
             $map['pid'] = 0;
137
             $map['pid'] = 0;
138
             $map['is_archive'] = 0;
138
             $map['is_archive'] = 0;
139
-
139
+            $map['main_user_id']=$request['main_user_id'];
140
             $taskList = [];
140
             $taskList = [];
141
             $resTaskList = $this->getTaskList($map);
141
             $resTaskList = $this->getTaskList($map);
142
             $data[$key]['count'] = $resTaskList['count'];
142
             $data[$key]['count'] = $resTaskList['count'];
414
             unset($param[$value]);
414
             unset($param[$value]);
415
         }
415
         }
416
         $main_user_id = $param['main_user_id'] ?: $param['create_user_id'];
416
         $main_user_id = $param['main_user_id'] ?: $param['create_user_id'];
417
-
417
+        $param['owner_user_id'] = ','.$main_user_id.','; //参与人
418
         $param['main_user_id'] = $main_user_id; //负责人
418
         $param['main_user_id'] = $main_user_id; //负责人
419
         $param['start_time']   = !empty($param['start_time']) ? strtotime($param['start_time']) : 0;
419
         $param['start_time']   = !empty($param['start_time']) ? strtotime($param['start_time']) : 0;
420
         $param['stop_time']    = !empty($param['stop_time'])  ? strtotime($param['stop_time'])  : 0;
420
         $param['stop_time']    = !empty($param['stop_time'])  ? strtotime($param['stop_time'])  : 0;
443
                 //操作日志
443
                 //操作日志
444
                 actionLog($task_id, '', '', '新建了任务');
444
                 actionLog($task_id, '', '', '新建了任务');
445
                 //抄送站内信
445
                 //抄送站内信
446
-//                (new Message())->send(
447
-//                    Message::TASK_ALLOCATION,
448
-//                    [
449
-//                        'title' => $param['name'],
450
-//                        'action_id' => $task_id
451
-//                    ],
452
-//                    $param['owner_user_id']
453
-//                );
446
+                (new Message())->send(
447
+                    Message::TASK_ALLOCATION,
448
+                    [
449
+                        'title' => $param['name'],
450
+                        'action_id' => $task_id
451
+                    ],
452
+                    trim(',',$param['owner_user_id'])
453
+                );
454
             }
454
             }
455
 
455
 
456
             # 添加活动记录
456
             # 添加活动记录
642
                 //设置负责人
642
                 //设置负责人
643
                 $userdet = $userModel->getDataById($param['main_user_id']);
643
                 $userdet = $userModel->getDataById($param['main_user_id']);
644
                 $data['after'] = '设定' . $userdet['realname'] . '为主要负责人!';
644
                 $data['after'] = '设定' . $userdet['realname'] . '为主要负责人!';
645
-//                (new Message())->send(
646
-//                    Message::TASK_ALLOCATION,
647
-//                    [
648
-//                        'title' => $taskInfo['name'],
649
-//                        'action_id' => $param['task_id']
650
-//                    ],
651
-//                    $param['main_user_id']
652
-//                );
645
+                (new Message())->send(
646
+                    Message::TASK_ALLOCATION,
647
+                    [
648
+                        'title' => $taskInfo['name'],
649
+                        'action_id' => $param['task_id']
650
+                    ],
651
+                   $param['main_user_id']
652
+                );
653
                 break;
653
                 break;
654
         }
654
         }
655
 
655
 
899
      */
899
      */
900
     public function getTaskList($request)
900
     public function getTaskList($request)
901
     {
901
     {
902
-        $search = $request['search'];
902
+       
903
+        $search = $request['search']?:'';
903
         $whereStr = $request['whereStr'] ?: [];
904
         $whereStr = $request['whereStr'] ?: [];
904
         $lable_id = $request['lable_id'] ?: '';
905
         $lable_id = $request['lable_id'] ?: '';
906
+        $main_user_id = $request['main_user_id'] ?: '';
905
         $taskSearch = !empty($request['taskSearch']) ? $request['taskSearch'] : '';
907
         $taskSearch = !empty($request['taskSearch']) ? $request['taskSearch'] : '';
906
         $isArchive = !empty($request['is_archive']) ? $request['is_archive'] : 0;
908
         $isArchive = !empty($request['is_archive']) ? $request['is_archive'] : 0;
907
-        unset($request['search']);
908
-        unset($request['whereStr']);
909
-        unset($request['lable_id']);
910
-        unset($request['taskSearch']);
909
+//        unset($request['search']);
910
+//        unset($request['whereStr']);
911
+//        unset($request['lable_id']);
912
+        unset($request['main_user_id']);
911
         $request = $this->fmtRequest($request);
913
         $request = $this->fmtRequest($request);
912
         $requestMap = $request['map'] ?: [];
914
         $requestMap = $request['map'] ?: [];
913
         $userModel = new \app\admin\model\User();
915
         $userModel = new \app\admin\model\User();
924
         }
926
         }
925
         $dataCount = db('task')->alias('task')->where($map)->where($whereStr)->where($taskSearch)->count();
927
         $dataCount = db('task')->alias('task')->where($map)->where($whereStr)->where($taskSearch)->count();
926
         $taskList = [];
928
         $taskList = [];
929
+        $logWhere='';
930
+        if ($main_user_id) {
931
+            foreach ($main_user_id as $key => $value) {
932
+                $logWhere.= '( task.owner_user_id like "%,' . $value . ',%") OR ';
933
+            }
934
+            if (!empty($logWhere)) $logWhere = '(' . rtrim($logWhere, 'OR ') . ')';
935
+        }
927
         if ($dataCount) {
936
         if ($dataCount) {
928
             $taskList = db('task')
937
             $taskList = db('task')
929
                 ->alias('task')
938
                 ->alias('task')
932
                 ->field('task.task_id,task.name,task.main_user_id,task.is_top,task.work_id,task.lable_id,task.priority,task.stop_time,task.status,task.pid,task.create_time,task.owner_user_id,u.realname as main_user_name,u.thumb_img,w.name as work_name,color')
941
                 ->field('task.task_id,task.name,task.main_user_id,task.is_top,task.work_id,task.lable_id,task.priority,task.stop_time,task.status,task.pid,task.create_time,task.owner_user_id,u.realname as main_user_name,u.thumb_img,w.name as work_name,color')
933
                 ->where($map)
942
                 ->where($map)
934
                 ->where($whereStr)
943
                 ->where($whereStr)
944
+                ->where($logWhere)
935
                 ->where($taskSearch)
945
                 ->where($taskSearch)
936
                 ->order('task.status asc,task.order_id asc')
946
                 ->order('task.status asc,task.order_id asc')
937
                 ->select();
947
                 ->select();
1036
                 ->where($labelWhere)
1046
                 ->where($labelWhere)
1037
                 ->order($order)
1047
                 ->order($order)
1038
                 ->select();
1048
                 ->select();
1039
-
1040
             foreach ($taskList as $key => $value) {
1049
             foreach ($taskList as $key => $value) {
1041
                 if ($value['pid'] > 0) {
1050
                 if ($value['pid'] > 0) {
1042
                     $p_det = $this->field('task_id,name')->where(['task_id' => $value['pid']])->find();
1051
                     $p_det = $this->field('task_id,name')->where(['task_id' => $value['pid']])->find();
1084
 
1093
 
1085
         # 今天
1094
         # 今天
1086
         if ($type == 1) {
1095
         if ($type == 1) {
1087
-            $result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
1096
+            $result = '(task.stop_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' AND task.stop_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
1088
         }
1097
         }
1089
 
1098
 
1090
         # 明天
1099
         # 明天
1091
         if ($type == 2) {
1100
         if ($type == 2) {
1092
             $tomorrow = date("Y-m-d 23:59:59", strtotime("+1 day"));
1101
             $tomorrow = date("Y-m-d 23:59:59", strtotime("+1 day"));
1093
-            $result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime($tomorrow) . ')';
1102
+            $start = date("Y-m-d 00:00:00", strtotime("+1 day"));
1103
+            $result = '(task.stop_time >= ' . strtotime($start) . ' AND task.stop_time <= ' . strtotime($tomorrow) . ')';
1094
         }
1104
         }
1095
 
1105
 
1096
         # 本周
1106
         # 本周
1097
         if ($type == 3) {
1107
         if ($type == 3) {
1098
             $week = mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"));
1108
             $week = mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"));
1099
-            $result = '(task.stop_time > 0 AND task.stop_time <= ' . $week . ')';
1109
+            $start_week=mktime(0, 0, 0, date('m'), date('d') - date('w') + 1, date('Y'));
1110
+            $result = '(task.stop_time >= ' . $start_week . ' AND task.stop_time <= ' . $week . ')';
1100
         }
1111
         }
1101
 
1112
 
1102
         # 本月
1113
         # 本月
1103
         if ($type == 4) {
1114
         if ($type == 4) {
1115
+            $timestamp = mktime(0, 0, 0, date('m'), 1, date('Y'));
1104
             $month = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
1116
             $month = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
1105
-            $result = '(task.stop_time > 0 AND task.stop_time <= ' . $month . ')';
1117
+            $result = '(task.stop_time > ' . $timestamp . ' AND task.stop_time <= ' . $month . ')';
1106
         }
1118
         }
1107
 
1119
 
1108
         # 未设置截止日期
1120
         # 未设置截止日期
1109
         if ($type == 5) {
1121
         if ($type == 5) {
1110
-            $result = $result = '(task.stop_time = 0)';;
1122
+            $result = '(task.stop_time = 0)';;
1111
         }
1123
         }
1112
 
1124
 
1113
         # 已延期
1125
         # 已延期
1114
         if ($type == 6) {
1126
         if ($type == 6) {
1115
-            $result = '(task.status = 2 OR task.stop_time >= ' . time() . ')';
1127
+            $result = '(task.status = 2 OR task.stop_time < ' . time() . ')'.'AND task.stop_time <> 0 AND task.status = 1';
1116
         }
1128
         }
1117
 
1129
 
1118
         # 今日更新
1130
         # 今日更新

+ 6
- 1
application/work/model/Work.php Zobrazit soubor

75
 			$ownerData['work_id']        = $workId;
75
 			$ownerData['work_id']        = $workId;
76
 			$ownerData['create_user_id'] = $createUserId;
76
 			$ownerData['create_user_id'] = $createUserId;
77
 			$ownerData['owner_user_id']  = $ownerUserId;
77
 			$ownerData['owner_user_id']  = $ownerUserId;
78
+			$ownerData['group_id']       = !empty($param['group_id']) ? $param['group_id'] : 0;
78
             # 创建项目下的相关成员
79
             # 创建项目下的相关成员
79
 			$this->addOwner($ownerData);
80
 			$this->addOwner($ownerData);
80
 
81
 
129
             $ownerData['is_open']        = $param['is_open'];
130
             $ownerData['is_open']        = $param['is_open'];
130
             $ownerData['group_id']       = $param['group_id'];
131
             $ownerData['group_id']       = $param['group_id'];
131
             $this->addOwner($ownerData);
132
             $this->addOwner($ownerData);
133
+        }
134
+        # 公开项目更新时的权限变更
135
+        if ($param['is_open'] == 1 && !empty($param['group_id']) && $param['group_id'] != $workInfo['group_id']) {
136
+            db('work_user')->where(['work_id' => $workInfo['work_id'], 'user_id' => ['neq', $workInfo['create_user_id']]])->update(['group_id' => $param['group_id']]);
132
         }
137
         }
133
 		$resUpdata = $this->where($map)->update($param);
138
 		$resUpdata = $this->where($map)->update($param);
134
 		if ($resUpdata) {
139
 		if ($resUpdata) {
307
 				$group_id = 1;
312
 				$group_id = 1;
308
 			} else {
313
 			} else {
309
 				# 默认角色
314
 				# 默认角色
310
-				$group_id = db('admin_group')->where(['pid' => 5, 'system' => 1])->order('id asc')->value('id');
315
+				$group_id = !empty($param['group_id']) ? $param['group_id'] : db('admin_group')->where(['pid' => 5, 'system' => 1])->order('id asc')->value('id');
311
 			}
316
 			}
312
 			$data['group_id'] = $group_id;
317
 			$data['group_id'] = $group_id;
313
 			$saveData[] = $data;
318
 			$saveData[] = $data;

+ 4
- 1
config/config.php Zobrazit soubor

265
     // 商业智能查询缓存时间(秒)
265
     // 商业智能查询缓存时间(秒)
266
     'bi_cache_time' => 1800,
266
     'bi_cache_time' => 1800,
267
     // 商业智能慢查询查询时间(查询超过该时间进行数据缓存)(毫秒)
267
     // 商业智能慢查询查询时间(查询超过该时间进行数据缓存)(毫秒)
268
-    'bi_slow_query_time' => 500
268
+    'bi_slow_query_time' => 500,
269
+    'public_key' => '-----BEGIN PUBLIC KEY-----
270
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkqKFcAQtIp4rlkB5LOMnViyVY/hhA6x0R9ftwtEXsAFu4hBZrm9txdEvxSrDCUsx3Zwv/gdimeOzTtfSKffdoE/DwllNP9Zu6nsr2kGRgPrRwjtlO+j2FOM0b9UY1SQ/bWE+a9oQL2jL9xMSbtX1xG/+HcMo1bT+pa6FNQzs3egmvMt75/jaxINPSraj4kgNFawSBk7qDBEqDYiQwtPTuaNW1YZIs++/gZHsCRgGs/JrAbxNpl7+v/+Z503I3I2rs/8eUM5d16NXR8M7vtobUDCTIiQOgRahO8WMadgFlwavyVCYhy/TBXyj5RUfWaS26LrEN3vkj4TjoJu5m9LQ5QIDAQAB
271
+-----END PUBLIC KEY-----',  
269
 ];
272
 ];

+ 1
- 0
config/route_admin.php Zobrazit soubor

15
     'admin/install/step2' => ['admin/install/step2', ['method' => 'GET']],
15
     'admin/install/step2' => ['admin/install/step2', ['method' => 'GET']],
16
     'admin/install/step3' => ['admin/install/step3', ['method' => 'GET']],
16
     'admin/install/step3' => ['admin/install/step3', ['method' => 'GET']],
17
  	'admin/install/step4' => ['admin/install/step4', ['method' => 'POST|AJAX']],
17
  	'admin/install/step4' => ['admin/install/step4', ['method' => 'POST|AJAX']],
18
+    'admin/install/step5' => ['admin/install/step5', ['method' => 'GET']],
18
  	'admin/install/progress' => ['admin/install/progress', ['method' => 'POST']], 	
19
  	'admin/install/progress' => ['admin/install/progress', ['method' => 'POST']], 	
19
 
20
 
20
     //子部门列表
21
     //子部门列表

+ 2
- 0
config/route_crm.php Zobrazit soubor

233
     'crm/receivables/system' => ['crm/receivables/system', ['method' => 'POST']],
233
     'crm/receivables/system' => ['crm/receivables/system', ['method' => 'POST']],
234
     // 【回款】菜单数量
234
     // 【回款】菜单数量
235
     'crm/receivables/count' => ['crm/receivables/count', ['method' => 'POST']],
235
     'crm/receivables/count' => ['crm/receivables/count', ['method' => 'POST']],
236
+    //【回款】导出
237
+    'crm/receivables/excelExport' => ['crm/receivables/excelExport', ['method' => 'POST']],
236
 
238
 
237
     // 【回款计划】列表
239
     // 【回款计划】列表
238
     'crm/receivables_plan/index' => ['crm/receivables_plan/index', ['method' => 'POST']],
240
     'crm/receivables_plan/index' => ['crm/receivables_plan/index', ['method' => 'POST']],

+ 2
- 2
config/version.php Zobrazit soubor

1
 <?php
1
 <?php
2
 return array(
2
 return array(
3
-'VERSION'=>'11.0.0',
4
-'RELEASE'=>'20210205',
3
+'VERSION'=>'11.0.1',
4
+'RELEASE'=>'20210227',
5
 );
5
 );

+ 10
- 10
public/sql/5kcrm.sql Zobrazit soubor

1708
 INSERT INTO `5kcrm_admin_scene` (`types`, `name`, `user_id`, `order_id`, `data`, `is_hide`, `type`, `bydata`, `create_time`, `update_time`) VALUES ('crm_visit', '下属负责的回访', '0', '1', '', '0', '1', 'sub', '1546272000', '1551515457');
1708
 INSERT INTO `5kcrm_admin_scene` (`types`, `name`, `user_id`, `order_id`, `data`, `is_hide`, `type`, `bydata`, `create_time`, `update_time`) VALUES ('crm_visit', '下属负责的回访', '0', '1', '', '0', '1', 'sub', '1546272000', '1551515457');
1709
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'number', '回访编号', 'text', '', '0', '0', '1', '', NULL, '1', '1', '1553788800', '1553788800', '0', NULL, '0');
1709
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'number', '回访编号', 'text', '', '0', '0', '1', '', NULL, '1', '1', '1553788800', '1553788800', '0', NULL, '0');
1710
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'visit_time', '回访时间', 'date', '', '0', '0', '1', '', '', '2', '1', '1553788800', '1553788800', '0', '', '0');
1710
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'visit_time', '回访时间', 'date', '', '0', '0', '1', '', '', '2', '1', '1553788800', '1553788800', '0', '', '0');
1711
-INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'visit_user_id', '回访人', 'user', '', '0', '0', '1', '', '', '3', '1', '1553788800', '1553788800', '0', '', '0');
1711
+INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'owner_user_id', '回访人', 'single_user', '', '0', '0', '1', '', '', '9', '3', '1553788800', '1553788800', '0', '', '0');
1712
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'shape', '回访形式', 'select', '', '0', '0', '0', '', '见面拜访\r\n电话\r\n短信\r\n邮件\r\n微信', '4', '1', '1553788800', '1553788800', '0', NULL, '0');
1712
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'shape', '回访形式', 'select', '', '0', '0', '0', '', '见面拜访\r\n电话\r\n短信\r\n邮件\r\n微信', '4', '1', '1553788800', '1553788800', '0', NULL, '0');
1713
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'customer_id', '客户名称', 'customer', '', '0', '0', '1', '', '', '5', '1', '1553788800', '1553788800', '0', '', '0');
1713
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'customer_id', '客户名称', 'customer', '', '0', '0', '1', '', '', '5', '1', '1553788800', '1553788800', '0', '', '0');
1714
-INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'contacts_id', '联系人', 'contacts', '', '0', '0', '0', '', '', '6', '1', '1553788800', '1553788800', '0', '', '0');
1714
+INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'contacts_id', '联系人', 'contacts', '', '0', '0', '0', '', '', '6', '3', '1553788800', '1553788800', '0', '', '0');
1715
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'contract_id', '合同编号', 'contract', '', '0', '0', '1', '', '', '7', '1', '1553788800', '1553788800', '0', '', '0');
1715
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'contract_id', '合同编号', 'contract', '', '0', '0', '1', '', '', '7', '1', '1553788800', '1553788800', '0', '', '0');
1716
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'satisfaction', '客户满意度', 'select', '', '0', '0', '0', '', '很满意\r\n满意\r\n一般不满意\r\n很不满意', '8', '1', '1553788800', '1553788800', '0', NULL, '0');
1716
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'satisfaction', '客户满意度', 'select', '', '0', '0', '0', '', '很满意\r\n满意\r\n一般不满意\r\n很不满意', '8', '1', '1553788800', '1553788800', '0', NULL, '0');
1717
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'feedback', '客户反馈', 'textarea', '', '0', '0', '0', '', '', '9', '1', '1553788800', '1553788800', '0', '', '0');
1717
 INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'feedback', '客户反馈', 'textarea', '', '0', '0', '0', '', '', '9', '1', '1553788800', '1553788800', '0', '', '0');
1751
 CREATE TABLE `5kcrm_crm_visit` (
1751
 CREATE TABLE `5kcrm_crm_visit` (
1752
   `visit_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '回访id',
1752
   `visit_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '回访id',
1753
   `owner_user_id` int(11) NOT NULL COMMENT '负责人',
1753
   `owner_user_id` int(11) NOT NULL COMMENT '负责人',
1754
-  `visit_user_id` int(11) NOT NULL COMMENT '回访人',
1754
+  `owner_user_id` int(11) NOT NULL COMMENT '回访人',
1755
   `create_user_id` int(11) NOT NULL COMMENT '创建人id',
1755
   `create_user_id` int(11) NOT NULL COMMENT '创建人id',
1756
   `customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户名称',
1756
   `customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户名称',
1757
   `contract_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '合同编号',
1757
   `contract_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '合同编号',
1840
 ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0  comment '1表示已读 0表示未读';
1840
 ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0  comment '1表示已读 0表示未读';
1841
 ALTER TABLE `5kcrm_oa_examine_category` ADD COLUMN `icon` varchar(255) NOT NULL  COMMENT '类型图标和颜色';
1841
 ALTER TABLE `5kcrm_oa_examine_category` ADD COLUMN `icon` varchar(255) NOT NULL  COMMENT '类型图标和颜色';
1842
 
1842
 
1843
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='1', `title`='普通审批', `remark`='普通审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612576450', `update_time`='1612576450', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='65' ,`icon`='wk wk-leave,#00CAAB' WHERE (`category_id`='1');
1844
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='2', `title`='请假审批', `remark`='请假审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612518097', `update_time`='1612518097', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='63' ,`icon`='wk wk-l-record,#3ABCFB' WHERE (`category_id`='2');
1845
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='3', `title`='出差审批', `remark`='出差审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-trip,#3ABCFB' WHERE (`category_id`='3');
1846
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='4', `title`='加班审批', `remark`='加班审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-overtime,#FAAD14' WHERE (`category_id`='4');
1847
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='5', `title`='差旅报销', `remark`='差旅报销', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-reimbursement,#3ABCFB' WHERE (`category_id`='5');
1848
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='6', `title`='借款申请', `remark`='借款申请', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-go-out,#FF6033' WHERE (`category_id`='6');
1843
+UPDATE `5kcrm_oa_examine_category` SET `category_id`='1', `title`='普通审批', `remark`='普通审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612576450', `update_time`='1612576450', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-leave,#00CAAB' WHERE (`category_id`='1');
1844
+UPDATE `5kcrm_oa_examine_category` SET `category_id`='2', `title`='请假审批', `remark`='请假审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612518097', `update_time`='1612518097', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='2' ,`icon`='wk wk-l-record,#3ABCFB' WHERE (`category_id`='2');
1845
+UPDATE `5kcrm_oa_examine_category` SET `category_id`='3', `title`='出差审批', `remark`='出差审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='3' ,`icon`='wk wk-trip,#3ABCFB' WHERE (`category_id`='3');
1846
+UPDATE `5kcrm_oa_examine_category` SET `category_id`='4', `title`='加班审批', `remark`='加班审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='4' ,`icon`='wk wk-overtime,#FAAD14' WHERE (`category_id`='4');
1847
+UPDATE `5kcrm_oa_examine_category` SET `category_id`='5', `title`='差旅报销', `remark`='差旅报销', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='5' ,`icon`='wk wk-reimbursement,#3ABCFB' WHERE (`category_id`='5');
1848
+UPDATE `5kcrm_oa_examine_category` SET `category_id`='6', `title`='借款申请', `remark`='借款申请', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='6' ,`icon`='wk wk-go-out,#FF6033' WHERE (`category_id`='6');
1849
 
1849
 
1850
 INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
1850
 INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
1851
 INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
1851
 INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
1955
   `receivables_id` int(10) unsigned NOT NULL,
1955
   `receivables_id` int(10) unsigned NOT NULL,
1956
   `file_id` int(10) unsigned NOT NULL,
1956
   `file_id` int(10) unsigned NOT NULL,
1957
   PRIMARY KEY (`r_id`) USING BTREE
1957
   PRIMARY KEY (`r_id`) USING BTREE
1958
-) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
1958
+) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
1959
 
1959
 
1960
 INSERT INTO `5kcrm_crm_config` (`name`, `value`, `description`) VALUES ('activity_phrase', 'a:5:{i:0;s:18:\\\"电话无人接听\\\";i:1;s:15:\\\"客户无意向\\\";i:2;s:42:\\\"客户意向度适中,后续继续跟进\\\";i:3;s:42:\\\"客户意向度较强,成交几率较大\\\";i:4;s:3:\\\"312\\\";}', '跟进记录常用语');
1960
 INSERT INTO `5kcrm_crm_config` (`name`, `value`, `description`) VALUES ('activity_phrase', 'a:5:{i:0;s:18:\\\"电话无人接听\\\";i:1;s:15:\\\"客户无意向\\\";i:2;s:42:\\\"客户意向度适中,后续继续跟进\\\";i:3;s:42:\\\"客户意向度较强,成交几率较大\\\";i:4;s:3:\\\"312\\\";}', '跟进记录常用语');
1961
 INSERT INTO `5kcrm_crm_config` (`name`, `value`, `description`) VALUES ('visit_config', '1', '是否开启回访提醒:1开启;0不开启');
1961
 INSERT INTO `5kcrm_crm_config` (`name`, `value`, `description`) VALUES ('visit_config', '1', '是否开启回访提醒:1开启;0不开启');

+ 2
- 2
public/sql/install.sql Zobrazit soubor

1
-insert into `5kcrm_admin_user` (`username`, `password`, `salt`, `realname`, `create_time`, `status`, `structure_id`, `parent_id`, `type`) values ( '18888888888', '302dd3f6dba54513f2a5a1bf696e2d8d', '1b2d', '管理员', '1487217060', 1, 1, 0, 1);
1
+insert into `5kcrm_admin_user` (`username`, `password`, `salt`, `realname`, `create_time`, `status`, `structure_id`, `parent_id`, `type`) values ( '18888888888', '05a9918b455b2209673c36676422bb81', '7217', '管理员', '1613611667', 1, 1, 0, 1);
2
 
2
 
3
-insert into `5kcrm_hrm_user_det` (`user_id`, `join_time`, `type`, `status`, `userstatus`, `create_time`, `update_time`) values ( 1, '1487217060', 1, 1, 2, '1487217060', '1487217060');
3
+insert into `5kcrm_hrm_user_det` (`user_id`, `join_time`, `type`, `status`, `userstatus`, `create_time`, `update_time`) values ( 1, '1613611667', 1, 1, 2, '1613611667', '1613611667');

+ 0
- 7
public/sql/update_sql_20210207.sql Zobrazit soubor

380
 ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0  comment '1表示已读 0表示未读';
380
 ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0  comment '1表示已读 0表示未读';
381
 ALTER TABLE `5kcrm_oa_examine_category` ADD COLUMN `icon` varchar(255) NOT NULL  COMMENT '类型图标和颜色';
381
 ALTER TABLE `5kcrm_oa_examine_category` ADD COLUMN `icon` varchar(255) NOT NULL  COMMENT '类型图标和颜色';
382
 
382
 
383
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='1', `title`='普通审批', `remark`='普通审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612576450', `update_time`='1612576450', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='65' ,`icon`='wk wk-leave,#00CAAB' WHERE (`category_id`='1');
384
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='2', `title`='请假审批', `remark`='请假审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612518097', `update_time`='1612518097', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='63' ,`icon`='wk wk-l-record,#3ABCFB' WHERE (`category_id`='2');
385
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='3', `title`='出差审批', `remark`='出差审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-trip,#3ABCFB' WHERE (`category_id`='3');
386
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='4', `title`='加班审批', `remark`='加班审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-overtime,#FAAD14' WHERE (`category_id`='4');
387
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='5', `title`='差旅报销', `remark`='差旅报销', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-reimbursement,#3ABCFB' WHERE (`category_id`='5');
388
-UPDATE `5kcrm_oa_examine_category` SET `category_id`='6', `title`='借款申请', `remark`='借款申请', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-go-out,#FF6033' WHERE (`category_id`='6');
389
-
390
 INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
383
 INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
391
 INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
384
 INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
392
 INSERT INTO `5kcrm_admin_rule` VALUES ('156', '0', '设置欢迎语', 'setWelcome', '3', '154', '0');
385
 INSERT INTO `5kcrm_admin_rule` VALUES ('156', '0', '设置欢迎语', 'setWelcome', '3', '154', '0');

+ 2
- 0
public/sql/update_sql_20210227.sql Zobrazit soubor

1
+UPDATE `5kcrm_admin_field` SET `operating`= 3, `field` = 'owner_user_id', `form_type` = 'single_user' WHERE `types` = 'crm_visit' AND `field` = 'visit_user_id';
2
+UPDATE `5kcrm_admin_field` SET `operating`= 3 WHERE `types` = 'crm_visit' AND `field` = 'contacts_id';

binární
public/static/icon/success_gray.png Zobrazit soubor


binární
public/static/img/bg.png Zobrazit soubor


+ 37
- 32
public/static/js/step2.js Zobrazit soubor

45
     required: true,
45
     required: true,
46
     regexp: /^(?=.*[a-zA-Z])(?=.*\d).{6,20}$/,
46
     regexp: /^(?=.*[a-zA-Z])(?=.*\d).{6,20}$/,
47
     label: '管理员密码(6~20位字母加数字组合)'
47
     label: '管理员密码(6~20位字母加数字组合)'
48
-  }
48
+  },
49
+  wkcode: {
50
+    required: false,
51
+    regexp: null,
52
+    label: '序列号'
53
+  },  
49
 };
54
 };
50
 
55
 
51
 var timer = null;
56
 var timer = null;
63
   // 校验form数据 true 校验通过  false 校验失败
68
   // 校验form数据 true 校验通过  false 校验失败
64
   var forms = getFormData();
69
   var forms = getFormData();
65
   var result = checkForm();
70
   var result = checkForm();
66
-  console.log('result---', result, forms);
71
+  // console.log('result---', result, forms);
67
   if (result) {
72
   if (result) {
68
-    $.ajax({
69
-      cache: true,
70
-      type: "POST",
71
-      dataType: 'json',
72
-      url: "./step4",
73
-      data: {
74
-        form: forms
75
-      },
76
-      async: false,
77
-      success: function (result) {
78
-        if (result.code == '200') {
79
-          alert(result.data);
80
-          window.location = '../../../index.html';
81
-        } else if (result.code == '400') {
82
-          alert(result.error); //失败
83
-          return false;
84
-          // window.location = 'step3.html'
85
-        } else {
86
-          window.location = 'step3.html'
87
-          alert('安装失败');
73
+    
74
+    $('#cover').css('display', 'block');//显示遮罩层
75
+    setTimeout(()=>{
76
+      $.ajax({
77
+        cache: true,
78
+        type: "POST",
79
+        dataType: 'json',
80
+        url: "./step4",
81
+        data: {
82
+          form: forms
83
+        },
84
+        async: false,
85
+        success: function (result) {
86
+          if (result.code == '200') {
87
+            window.location = 'step5.html';
88
+          } else if (result.code == '400') {
89
+            $('#cover').css('display', 'none');
90
+            alert(result.error); //失败
91
+            return false;
92
+            // window.location = 'step3.html'
93
+          } else {
94
+            window.location = 'step3.html'
95
+            alert('安装失败');
96
+          }
88
         }
97
         }
89
-      }
90
-      // getRes();
91
-    });    
98
+        // getRes();
99
+      }); 
100
+    })   
92
   }
101
   }
93
 });
102
 });
94
 
103
 
168
  * @return {form}
177
  * @return {form}
169
  */
178
  */
170
 function getFormData() {
179
 function getFormData() {
171
-  $('input').each(function (index, item) {
180
+  $('.wkform').each(function (index, item) {
172
     form[item.name] = item.value;
181
     form[item.name] = item.value;
173
     // 重置表单状态
182
     // 重置表单状态
174
     $(item).removeClass('input-error');
183
     $(item).removeClass('input-error');
186
  * @return {boolean}
195
  * @return {boolean}
187
  */
196
  */
188
 function checkForm() {
197
 function checkForm() {
198
+
189
   var result = {};
199
   var result = {};
190
   for (var key in rules) {
200
   for (var key in rules) {
191
     var rule = rules[key];
201
     var rule = rules[key];
228
       $(item).addClass('input-error')
238
       $(item).addClass('input-error')
229
     }
239
     }
230
   })
240
   })
231
-}
232
-
233
-/**
234
- * 提交表单
235
- */
236
-function submitForm() {}
241
+}

+ 52
- 12
public/static/style/base.css Zobrazit soubor

10
   background-color: #f2f2f2;
10
   background-color: #f2f2f2;
11
   font-family: 微软雅黑,Microsoft Yahei,LiHei Pro,Hiragino Sans,GBHelvetica Neue,Helvetica,Arial,PingFang SC,WenQuanYi Micro Hei,sans-serif;
11
   font-family: 微软雅黑,Microsoft Yahei,LiHei Pro,Hiragino Sans,GBHelvetica Neue,Helvetica,Arial,PingFang SC,WenQuanYi Micro Hei,sans-serif;
12
 }
12
 }
13
+body {
14
+  background-image: url('../img/bg.png');
15
+  background-size: 100% 100%;
16
+  background-repeat: no-repeat;
17
+}
13
 
18
 
14
 li {
19
 li {
15
   list-style: none;
20
   list-style: none;
72
 .top {
77
 .top {
73
   width: 790px;
78
   width: 790px;
74
   height: 65px;
79
   height: 65px;
75
-  margin: 0 auto;
80
+  margin:40px auto 20px auto;
81
+  border: 1px solid white;
82
+  border-radius: 5px ;
83
+  background-color: #fff ;
76
 }
84
 }
77
 
85
 
78
 /* container */
86
 /* container */
81
   min-height: 493px;
89
   min-height: 493px;
82
   background-color: white;
90
   background-color: white;
83
   border: 1px solid #e1e1e1;
91
   border: 1px solid #e1e1e1;
92
+  border-radius:5px;
84
   margin: 0 auto;
93
   margin: 0 auto;
85
 }
94
 }
86
 
95
 
93
   width: 820px;
102
   width: 820px;
94
   text-align: center;
103
   text-align: center;
95
   font-size: 15px;
104
   font-size: 15px;
96
-  color: #8c8c8c;
105
+  color: #fff;
97
   line-height: 30px;
106
   line-height: 30px;
98
   margin: 0 auto;
107
   margin: 0 auto;
99
   padding: 30px 0;
108
   padding: 30px 0;
112
   text-align: center;
121
   text-align: center;
113
   margin: 20px 0;
122
   margin: 20px 0;
114
   float: left;
123
   float: left;
124
+  display: flex;
125
+  align-items: center;
126
+  justify-content: center;
115
 }
127
 }
116
 .step.line {
128
 .step.line {
117
   width: 10%;
129
   width: 10%;
122
 .step .sort {
134
 .step .sort {
123
   width: 25px;
135
   width: 25px;
124
   height: 25px;
136
   height: 25px;
125
-  color: white;
137
+  color: #8c8c8c;
126
   line-height: 25px;
138
   line-height: 25px;
127
   text-align: center;
139
   text-align: center;
128
   font-size: 14px;
140
   font-size: 14px;
129
   border-radius: 50%;
141
   border-radius: 50%;
130
-  background-color: #d1d1d1;
142
+  /* background-color: #d1d1d1; */
131
   margin-right: 5px;
143
   margin-right: 5px;
132
   display: inline-block;
144
   display: inline-block;
133
 }
145
 }
139
 }
151
 }
140
 
152
 
141
 .step.active .sort {
153
 .step.active .sort {
142
-  background-color: #3e84e9;
154
+  background-color: #fff;
143
 }
155
 }
144
 .step.active .desc {
156
 .step.active .desc {
145
-  color: #3e84e9;
157
+  color: black;
146
 }
158
 }
147
 .step.active.line {
159
 .step.active.line {
148
-  background-color: #3e84e9;
160
+  /* background-color: #fff; */
149
 }
161
 }
150
 
162
 
151
 
163
 
156
   line-height: 40px;
168
   line-height: 40px;
157
   font-size: 16px;
169
   font-size: 16px;
158
   color: #3e84e9;
170
   color: #3e84e9;
159
-  border-radius: 40px;
171
+  border-radius: 5px;
160
   background-color: white;
172
   background-color: white;
161
   border: 1px solid #3e84e9;
173
   border: 1px solid #3e84e9;
162
   display: inline-block;
174
   display: inline-block;
172
   width: 100%;
184
   width: 100%;
173
   height: 54px;
185
   height: 54px;
174
   line-height: 54px;
186
   line-height: 54px;
175
-  background-color: #f7f7f7;
187
+  /* background-color: #f7f7f7; */
176
   padding: 0 26px;
188
   padding: 0 26px;
177
-  border-bottom: 1px solid #e1e1e1;
189
+  /* border-bottom: 1px solid #e1e1e1; */
190
+  font-weight: 600;
178
 }
191
 }
179
 .base-top .title {
192
 .base-top .title {
180
-  color: #8c8c8c;
193
+  /* color: #8c8c8c; */
181
   font-size: 16px;
194
   font-size: 16px;
182
 }
195
 }
183
 .base-top .version {
196
 .base-top .version {
184
   font-size: 13px;
197
   font-size: 13px;
185
-  color: #d1d1d1;
198
+  color: #8c8c8c;
186
   float: right;
199
   float: right;
187
 }
200
 }
201
+
202
+.base-des {
203
+  margin: 0 auto;
204
+  line-height: 35px;
205
+  width: 790px;
206
+  background-color: #fff;
207
+  padding: 0 40px;
208
+  margin-bottom: 20px;
209
+  color: #8c8c8c;
210
+}
211
+
212
+.base-a{
213
+  cursor: pointer;
214
+  user-select: none;
215
+  text-decoration: none;
216
+  color: #3e84e9;
217
+}
218
+ 
219
+#cover{ 
220
+  position:absolute;left:0px;top:0px;
221
+  background:rgba(0, 0, 0, 0.4);
222
+  width:100%;  /*宽度设置为100%,这样才能使隐藏背景层覆盖原页面*/
223
+  height:100%;
224
+  opacity:0.6;  /*非IE浏览器下设置透明度为60%*/
225
+  display:none; 
226
+  z-Index:99;
227
+}

+ 1
- 0
public/static/style/index.css Zobrazit soubor

1
 .container {
1
 .container {
2
   padding: 20px;
2
   padding: 20px;
3
+  border-radius: 10px;
3
 }
4
 }
4
 .agreement-title {
5
 .agreement-title {
5
   width: 100%;
6
   width: 100%;

+ 52
- 0
public/static/style/loading.css Zobrazit soubor

1
+#loader-container {
2
+  width: 200px;
3
+  height: 200px;
4
+  color: white;
5
+  margin: 0 auto;
6
+  position: fixed;
7
+  top: 50%;
8
+  left: 50%;
9
+  margin-right: -50%;
10
+  transform: translate(-50%, -50%);
11
+  border: 5px solid #3498db;
12
+  border-radius: 50%;
13
+  -webkit-animation: borderScale 1s infinite ease-in-out;
14
+  animation: borderScale 1s infinite ease-in-out;
15
+  z-index: 100;
16
+  opacity:1
17
+}
18
+
19
+#loadingText {
20
+  font-family: 'Raleway', sans-serif;
21
+  font-weight: bold;
22
+  font-size: 2em;
23
+  position: absolute;
24
+  top: 50%;
25
+  left: 50%;
26
+  margin-right: -50%;
27
+  transform: translate(-50%, -50%);
28
+}
29
+
30
+@-webkit-keyframes borderScale {
31
+  0% {
32
+    border: 5px solid white;
33
+  }
34
+  50% {
35
+    border: 25px solid #3498db;
36
+  }
37
+  100% {
38
+    border: 5px solid white;
39
+  }
40
+}
41
+
42
+@keyframes borderScale {
43
+  0% {
44
+    border: 5px solid white;
45
+  }
46
+  50% {
47
+    border: 25px solid #3498db;
48
+  }
49
+  100% {
50
+    border: 5px solid white;
51
+  }
52
+}

+ 9
- 4
public/static/style/step1.css Zobrazit soubor

15
 table {
15
 table {
16
   width: 100%;
16
   width: 100%;
17
   border: 1px solid #e1e1e1;
17
   border: 1px solid #e1e1e1;
18
-  border-collapse: collapse;
18
+  /* border-collapse: collapse; */
19
+  border-collapse: separate;
20
+  border-spacing: 0;
21
+  border-radius:5px;
22
+  overflow: hidden;
19
 }
23
 }
20
 .table tr {
24
 .table tr {
21
   height: 34px;
25
   height: 34px;
22
   text-align: center;
26
   text-align: center;
23
 }
27
 }
24
 th, td {
28
 th, td {
25
-  border: 1px solid #e1e1e1;
29
+  border-bottom: 1px solid #f7f7f7;
26
   width: 30%;
30
   width: 30%;
27
 }
31
 }
28
 th:first-child, td:first-child, th:last-child, td:last-child {
32
 th:first-child, td:first-child, th:last-child, td:last-child {
31
 
35
 
32
 th {
36
 th {
33
   font-weight: normal;
37
   font-weight: normal;
34
-  background-color: #3e84e9;
35
-  color: white;
38
+  background-color: #f7f7f7;
39
+  /* color: white; */
40
+  font-weight: 600;
36
 }
41
 }
37
 
42
 
38
 
43
 

+ 29
- 8
public/static/style/step2.css Zobrazit soubor

28
   float: left;
28
   float: left;
29
 }
29
 }
30
 .content .form .form-item input {
30
 .content .form .form-item input {
31
-  width: 276px;
32
-  height: 34px;
33
-  line-height: 34px;
31
+  width: 550px;
32
+  height: 40px;
33
+  line-height: 40px;
34
   border: 1px solid #d7d7d7;
34
   border: 1px solid #d7d7d7;
35
   padding: 0 10px;
35
   padding: 0 10px;
36
-  margin-right: 20px;
36
+  /* margin-right: 20px; */
37
   float: left;
37
   float: left;
38
+  border-radius: 5px;
39
+  color: #8c8c8c;
38
 }
40
 }
39
 .content .form .form-item input:focus {
41
 .content .form .form-item input:focus {
40
   border-color: transparent !important;
42
   border-color: transparent !important;
51
   float: left;
53
   float: left;
52
 }
54
 }
53
 .content .form .form-item .remind {
55
 .content .form .form-item .remind {
54
-  width: 292px;
55
-  line-height: 34px;
56
+  font-size: 12px;
57
+  margin-top: 10px;
58
+  margin-left: 120px;
59
+  width: 550px;
60
+  line-height: 20px;
56
   color: #777;
61
   color: #777;
57
-  background-color: #ecf8ff;
58
-  padding: 0 16px;
62
+  background-color: #fff6e7;
63
+  padding: 0 12px;
59
   border-radius: 3px;
64
   border-radius: 3px;
60
   float: left;
65
   float: left;
66
+  border:1px solid #d7d7d7;
61
 }
67
 }
62
 
68
 
63
 .install_progress_a {
69
 .install_progress_a {
69
   text-align: center;
75
   text-align: center;
70
   padding: 20px 0;
76
   padding: 20px 0;
71
   color: #777;
77
   color: #777;
78
+}
72
 
79
 
80
+.content .form .form-item textarea {
81
+  height: 100px;
82
+  width: 550px;
83
+  line-height: 25px;
84
+  border: 1px solid #d7d7d7;
85
+  padding: 0 10px;
86
+  /* margin-right: 20px; */
87
+  float: left;
88
+  border-radius: 5px;
89
+  color: #8c8c8c;
73
 }
90
 }
91
+.content .form .form-item textarea:focus {
92
+  border-color: transparent !important;
93
+  outline-color: #3e84e9;
94
+}

+ 2
- 0
update_sql_20210227.sql Zobrazit soubor

1
+UPDATE `5kcrm_admin_field` SET `operating`= 3, `field` = 'owner_user_id', `form_type` = 'single_user' WHERE `types` = 'crm_visit' AND `field` = 'visit_user_id';
2
+UPDATE `5kcrm_admin_field` SET `operating`= 3 WHERE `types` = 'crm_visit' AND `field` = 'contacts_id';