旭晓耿 5 лет назад
Родитель
Сommit
97662ba32e
77 измененных файлов: 3142 добавлений и 1981 удалений
  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. Двоичные данные
      public/static/icon/success_gray.png
  70. Двоичные данные
      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 Просмотреть файл

@@ -170,3 +170,25 @@ function sendRequest($url, $params = array() , $headers = array()) {
170 170
     curl_close($ch);
171 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 Просмотреть файл

@@ -84,7 +84,7 @@ class Field extends ApiCommon
84 84
      * 自定义字段数据
85 85
      */
86 86
     public function read()
87
-    {        
87
+    {
88 88
         $fieldModel = model('Field');
89 89
         $param = $this->param;
90 90
         $data = $fieldModel->getDataList($param);    
@@ -116,14 +116,22 @@ class Field extends ApiCommon
116 116
         $types_id   = $param['types_id'] ? : 0;
117 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 125
         $i = 0;
125 126
         foreach ($data AS $k => $v) {
126 127
             $i++;
128
+
129
+            # 必填的字段不可以隐藏
130
+            if (!empty($v['is_null']) && !empty($v['is_hidden'])) {
131
+                $errorMessage = '必填的字段不可以隐藏!';
132
+                break;
133
+            }
134
+
127 135
             if ($v['field_id']) {
128 136
                 if (isset($v['is_deleted']) && $v['is_deleted'] == '1') {
129 137
                     # 删除
@@ -143,8 +151,8 @@ class Field extends ApiCommon
143 151
             }
144 152
         }
145 153
 
146
-        # 错误数据
147
-        $errorMessage = [];
154
+        # 必填的字段不可以隐藏
155
+        if ($errorMessage) return resultArray(['error' => $errorMessage]);
148 156
 
149 157
         # 兼容前端11.*.*版本的删除条件处理,通过比较差异,来确定谁被前端给删除了 todo 这段代码需要写在新增上面,不然会把新增的给删除掉
150 158
         $oldFieldIds = Db::name('admin_field')->where('types', $types)->column('field_id');
@@ -170,7 +178,7 @@ class Field extends ApiCommon
170 178
         # 删除
171 179
         if (!empty($delParam)) {
172 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,12 +320,17 @@ class Field extends ApiCommon
312 320
                     case 'crm_visit' :
313 321
                         $visit = new \app\crm\model\Visit();
314 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 329
                         $auth_user_ids = $userModel->getUserByPer('crm', 'visit', $param['action']);
317 330
                         //读写权限
318 331
                         $roPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'read');
319 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 334
                             header('Content-Type:application/json; charset=utf-8');
322 335
                             exit(json_encode(['code'=>102,'error'=>'无权操作']));
323 336
                         }
@@ -614,6 +627,10 @@ class Field extends ApiCommon
614 627
         $userFieldModel = model('UserField');
615 628
         $width = $param['width'] > 10 ? $param['width'] : '';
616 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 634
         if (!in_array($param['field'],$unField)) {
618 635
             $res = $userFieldModel->setColumnWidth($param['types'], $param['field'], $width, $userInfo['id']);
619 636
             if (!$res) {

+ 1
- 0
application/admin/controller/Index.php Просмотреть файл

@@ -52,6 +52,7 @@ class Index extends ApiCommon
52 52
             if ($value['field'] == 'address')      $field_arr[$key]['form_type'] = 'map_address';
53 53
             if ($value['field'] == 'deal_status')  $field_arr[$key]['form_type'] = 'deal_status';
54 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 58
         return resultArray(['data' => $field_arr]);

+ 58
- 12
application/admin/controller/Install.php Просмотреть файл

@@ -27,15 +27,15 @@ class Install extends Controller
27 27
         $param = Request::instance()->param();          
28 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 41
     private $upgrade_site = "http://message.72crm.com/";
@@ -73,7 +73,7 @@ class Install extends Controller
73 73
     public function version()
74 74
     {
75 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 79
     public function step2(){
@@ -114,6 +114,7 @@ class Install extends Controller
114 114
         
115 115
         $username = $param['root'];
116 116
         $password = $param['pwd'];
117
+        $wkcode = $param['wkcode'];
117 118
         if (empty($db_config['hostname'])) {
118 119
             return resultArray(['error' => '请填写数据库主机!']);
119 120
         }           
@@ -141,6 +142,17 @@ class Install extends Controller
141 142
         if (empty($username)) {
142 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 156
         if (empty($password)) {
145 157
             return resultArray(['error' => '请填写管理员密码!']);
146 158
         }
@@ -161,6 +173,7 @@ class Install extends Controller
161 173
         }
162 174
 		$db_config['database'] = $database;
163 175
         self::mkDatabase($db_config);
176
+        self::mkLicense($wkcode);
164 177
         $C_Patch = substr($_SERVER['SCRIPT_FILENAME'],0,-10);
165 178
         $sql = file_get_contents( $C_Patch.'/public/sql/5kcrm.sql');
166 179
         $sqlList = parse_sql($sql, 0, ['5kcrm_' => $db_config['prefix']]);
@@ -185,9 +198,14 @@ class Install extends Controller
185 198
 		//插入信息
186 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 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 202
         return resultArray(['data'=>'安装成功']);
190 203
     }
204
+
205
+    public function step5()
206
+    {
207
+        return $this->fetch();
208
+    }
191 209
 	
192 210
 	//ajax 进度条
193 211
     public function progress()
@@ -314,7 +332,7 @@ INFO;
314 332
     {
315 333
         $items = [
316 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 336
             'gd'      => ['gd', '开启', '开启', 'ok'],
319 337
             'openssl' => ['openssl', '开启', '开启', 'ok'],
320 338
             'pdo' => ['pdo', '开启', '开启', 'ok'],
@@ -379,4 +397,32 @@ INFO;
379 397
         }
380 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 Просмотреть файл

@@ -91,7 +91,8 @@ class Users extends ApiCommon
91 91
         $data = $userModel->getDataById($param['id']);
92 92
         if (!$data) {
93 93
             return resultArray(['error' => $userModel->getError()]);
94
-        } 
94
+        }
95
+        $data['serverUserInfo'] = $this->queryLoginUser();
95 96
         return resultArray(['data' => $data]);
96 97
     }
97 98
 
@@ -500,6 +501,7 @@ class Users extends ApiCommon
500 501
         $data['username'] = $param['username'];
501 502
         $data['password'] = user_md5($param['password'], $userData['salt'], $param['username']);
502 503
         $data['userInfo'] = $userData;
504
+        $data['mobile'] = $param['username'];
503 505
         $resSync = model('Sync')->syncData($data);
504 506
         if ($resSync) {
505 507
             unset($data['userInfo']);
@@ -658,9 +660,6 @@ class Users extends ApiCommon
658 660
     /**
659 661
      * 设置关注
660 662
      *
661
-     * @return \think\response\Json
662
-     * @throws \think\Exception
663
-     * @throws \think\exception\PDOException
664 663
      */
665 664
     public function userStar()
666 665
     {
@@ -700,10 +699,6 @@ class Users extends ApiCommon
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 703
     public function subordinate()
709 704
     {
@@ -720,4 +715,21 @@ class Users extends ApiCommon
720 715
 
721 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 Просмотреть файл

@@ -535,7 +535,7 @@ class FieldGrantLogic
535 535
     {
536 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 541
         foreach ($visitList AS $key => $value) {
@@ -551,14 +551,19 @@ class FieldGrantLogic
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 563
         $content[] = ['name' => '创建时间', 'field' => 'create_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
559 564
         $content[] = ['name' => '编辑时间', 'field' => 'update_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
560 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 568
         Db::name('admin_field_grant')->insert([
564 569
             'role_id'     => $roleId,

+ 38
- 48
application/admin/logic/MessageLogic.php Просмотреть файл

@@ -10,7 +10,7 @@ class MessageLogic
10 10
     {
11 11
         $where = '';
12 12
         switch ($label) {
13
-
13
+            
14 14
             case '1':  //任务
15 15
                 $where = array('in', [1, 2, 3]);//
16 16
                 break;
@@ -21,7 +21,7 @@ class MessageLogic
21 21
                 $where = array('in', [6, 7, 8]);
22 22
                 break;
23 23
             case '4':  //公告
24
-                $where = array('eq', 9);
24
+                $where = 9;
25 25
                 break;
26 26
             case '5' :  //日程
27 27
                 $where = 10;
@@ -36,14 +36,14 @@ class MessageLogic
36 36
         }
37 37
         return $where;
38 38
     }
39
-
39
+   
40 40
     public function getDataList($param)
41 41
     {
42 42
         $userId = $param['user_id'];
43 43
         unset($param['user_id']);
44 44
         //types 1表示已读 0表示未读
45 45
         if (isset($param['is_read'])) {
46
-            $where['m.read_time'] = ['=', 0];
46
+            $where['m.read_time'] = 0;
47 47
         }
48 48
         $where['m.to_user_id'] = $userId;
49 49
         $where['m.is_delete'] = ['eq', 1];
@@ -74,11 +74,11 @@ class MessageLogic
74 74
                 ->page($param['page'], $param['limit'])
75 75
                 ->order($order)
76 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 82
         //1表示已读 0表示未读
83 83
         foreach ($list as $k => $v) {
84 84
             if ($v['read_time'] == 0) {
@@ -90,48 +90,38 @@ class MessageLogic
90 90
             if ($v['type'] == 4) {
91 91
                 $content = db('admin_comment')
92 92
                     ->where(
93
-                        [   'status' => 1,
94
-                            'comment_id' => $v['action_id'],
93
+                        ['status' => 1,
94
+                            'type_id' => $v['action_id'],
95 95
                             'type' => ['like', '%' . $v['controller_name' . '%']],
96 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 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 102
                 if ($content['content']) {
105 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 118
             if (in_array($v['type'], ['17', '18', '19', '20', '27'])) {
132 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 126
                 $list[$k]['error_file_path'] = $error_file_path['error_data_file_path'];
137 127
             }
@@ -151,7 +141,7 @@ class MessageLogic
151 141
         }
152 142
         return $data;
153 143
     }
154
-
144
+    
155 145
     /**
156 146
      * 修改状态变为已读
157 147
      * @param $param
@@ -173,7 +163,7 @@ class MessageLogic
173 163
         $data['list'] = $list;
174 164
         return $data;
175 165
     }
176
-
166
+    
177 167
     /**
178 168
      * 删除
179 169
      *
@@ -190,7 +180,7 @@ class MessageLogic
190 180
         }
191 181
         return db('admin_message')->where(['message_id' => $param['message_id']])->update(['is_delete' => 2]);
192 182
     }
193
-
183
+    
194 184
     /**
195 185
      * 批量更新
196 186
      * @param $param
@@ -200,7 +190,7 @@ class MessageLogic
200 190
      */
201 191
     public function readAllMessage($param)
202 192
     {
203
-
193
+        
204 194
         $where = [
205 195
             'to_user_id' => $param['user_id'],
206 196
             'read_time' => 0
@@ -220,7 +210,7 @@ class MessageLogic
220 210
         $data['list'] = $list;
221 211
         return $data;
222 212
     }
223
-
213
+    
224 214
     /**
225 215
      * 批量删除已读
226 216
      * @param $param
@@ -244,7 +234,7 @@ class MessageLogic
244 234
         $data['list'] = $list;
245 235
         return $data;
246 236
     }
247
-
237
+    
248 238
     public function unreadCount($param)
249 239
     {
250 240
         $userId = $param['user_id'];
@@ -253,7 +243,7 @@ class MessageLogic
253 243
         $label = '';
254 244
         $where['to_user_id'] = ['eq', $userId];
255 245
         $where['is_delete'] = ['eq', 1];
256
-
246
+        
257 247
         $where['type'] = $this->label('');
258 248
         $allCount = db('admin_message')->where($where)->count();
259 249
         $where['type'] = $this->label(1);
@@ -265,10 +255,10 @@ class MessageLogic
265 255
         $where['type'] = 9;
266 256
         $announceCount = db('admin_message')->where($where)->count();
267 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 259
         $where['type'] = $this->label(6);
270 260
         $crmCount = db('admin_message')->where($where)->count();
271
-
261
+        
272 262
         $data = [];
273 263
         $data['allCount'] = $allCount ?: 0;
274 264
         $data['taskCount'] = $taskCount ?: 0;

+ 7
- 0
application/admin/logic/WorkLogic.php Просмотреть файл

@@ -109,6 +109,13 @@ class WorkLogic
109 109
 
110 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 119
         return ['status' => true];
113 120
     }
114 121
 }

+ 2
- 1
application/admin/model/Common.php Просмотреть файл

@@ -295,6 +295,7 @@ class Common extends Model
295 295
 	 */
296 296
 	public function exportHandle($list, $field_list, $type = '')
297 297
 	{
298
+	 
298 299
 		foreach ($list as &$val) {
299 300
 			foreach ($field_list as $field) {
300 301
 				switch ($field['form_type']) {
@@ -310,7 +311,7 @@ class Common extends Model
310 311
 						$val[$field['field']] = implode(',', array_column($temp, 'name'));
311 312
 						break;
312 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 315
 						break;
315 316
 					case 'customer':
316 317
 					case 'business':

+ 2
- 1
application/admin/model/ExamineStep.php Просмотреть файл

@@ -324,7 +324,7 @@ class ExamineStep extends Common
324 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 328
             $is_check = 1;
329 329
         }
330 330
 
@@ -339,6 +339,7 @@ class ExamineStep extends Common
339 339
 
340 340
                 $createUserInfo['check_type'] = 3;
341 341
                 $newlist[0]['type'] = '3'; //创建
342
+                $newlist[0]['status'] = '5'; //创建,前端要求给创建人加一个status字段,定义为5
342 343
             }
343 344
             $newlist[0]['user_id_info'] = array($createUserInfo);
344 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
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 33
- 14
application/admin/model/Field.php Просмотреть файл

@@ -182,10 +182,6 @@ class Field extends Model
182 182
         if ($param['types'] == 'crm_customer') {
183 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 185
         $list = Db::name('AdminField')->where($map)->order('order_id')->select();
190 186
         foreach ($list as $k => $v) {
191 187
             $list[$k]['setting'] = $v['setting'] ? explode(chr(10), $v['setting']) : [];
@@ -655,7 +651,7 @@ class Field extends Model
655 651
             }
656 652
 
657 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 657
             if (in_array($param['types'], ['crm_customer'])) {
@@ -754,7 +750,16 @@ class Field extends Model
754 750
                     ];
755 751
                 } elseif ($v['form_type'] == 'user') {
756 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 763
                     $value = $structureModel->getListByStr($dataInfo[$v['field']]) ?: [];
759 764
                 } elseif ($v['form_type'] == 'file') {
760 765
                     $fileIds = [];
@@ -882,7 +887,8 @@ class Field extends Model
882 887
         $userModel = new \app\admin\model\User();
883 888
         $user_id = $param['user_id'];
884 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 892
         $field_list = db('admin_field')
887 893
             ->where($map)
888 894
             ->whereOr(['types' => ''])
@@ -1026,12 +1032,16 @@ class Field extends Model
1026 1032
         $userLevel = isSuperAdministrators($user_id);
1027 1033
 
1028 1034
         $fieldList = $this->getFieldList($types, $types_id);
1029
-
1030 1035
         $where = [];
1031 1036
         if ($userFieldData) {
1032 1037
             $fieldArr = [];
1033 1038
             $i = 0;
1034 1039
             foreach ($userFieldData as $k => $v) {
1040
+                if (empty($fieldList[$k])) {
1041
+                    unset($userFieldData[$k]);
1042
+                    continue;
1043
+                }
1044
+
1035 1045
                 if (empty($v['is_hide'])) {
1036 1046
                     $fieldArr[$i]['field'] = $k;
1037 1047
                     $fieldArr[$i]['name'] = $fieldList[$k]['name'];
@@ -1081,8 +1091,9 @@ class Field extends Model
1081 1091
                 'form_type' => ['not in', ['file', 'form']],
1082 1092
                 'field' => ['not in', $unField],
1083 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 1097
             ->order('order_id asc')
1087 1098
             ->select();
1088 1099
 
@@ -1192,7 +1203,6 @@ class Field extends Model
1192 1203
         } else {
1193 1204
             $listArr = $dataList;
1194 1205
         }
1195
-
1196 1206
         $typesArray = explode('_', $types);
1197 1207
         $type = array_pop($typesArray);
1198 1208
         if (isset($this->orther_field_list[$types])) {
@@ -1257,6 +1267,11 @@ class Field extends Model
1257 1267
                 if ($unFormType) $data['form_type'] = array('not in', $unFormType);
1258 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 1275
         return $field_arr;
1261 1276
     }
1262 1277
 
@@ -1315,9 +1330,12 @@ class Field extends Model
1315 1330
 
1316 1331
         $where = [];
1317 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 1340
         if ($res = $dataModel->where($where)->find()) {
1323 1341
             $this->error = '该数据已存在,请修改后提交!';
@@ -1378,7 +1396,7 @@ class Field extends Model
1378 1396
             case 'userStr' :
1379 1397
                 $val = explode(',', $val);
1380 1398
                 $val = count($userModel->getUserNameByArr($val)) > 1 ? ArrayToString($userModel->getUserNameByArr($val)) : implode(',', $userModel->getUserNameByArr($val));
1381
-                break;                
1399
+                break;
1382 1400
             case 'structure' :
1383 1401
                 $val = ArrayToString($structureModel->getStructureNameByArr($val));
1384 1402
                 break;
@@ -1648,6 +1666,7 @@ class Field extends Model
1648 1666
                         break;
1649 1667
                     case 'owner_user_id' :
1650 1668
                         $data[$key]['fieldName'] = 'owner_user_name';
1669
+                        $data[$key]['name'] = '回访人';
1651 1670
                         break;
1652 1671
                     case 'contacts_id' :
1653 1672
                         $data[$key]['fieldName'] = 'contacts_name';

+ 1
- 1
application/admin/model/Record.php Просмотреть файл

@@ -609,7 +609,7 @@ class Record extends Common
609 609
 		}
610 610
 		$fileModel = new \app\admin\model\File();
611 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 614
         $fileModel->delRFileByModule('crm_activity',$record_ids);
615 615
 		return true;

+ 13
- 5
application/admin/model/Scene.php Просмотреть файл

@@ -53,10 +53,10 @@ class Scene extends Common
53 53
             foreach ($value AS $k => $v) {
54 54
                 $sceneData[$k] = [
55 55
                     'condition' => trim($v['condition']),
56
-                    'value' => $v['value'],
56
+                    'value'     => $v['value'],
57 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,7 +200,13 @@ class Scene extends Common
200 200
         $sceneData = [];
201 201
         foreach ($param['data'] AS $key => $value) {
202 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 212
         if (!empty($sceneData)) $param['data'] = $sceneData;
@@ -210,7 +216,9 @@ class Scene extends Common
210 216
 		$res = $this->allowField(true)->save($param, ['scene_id' => $id]);
211 217
 		if ($param['is_default'] == 1) {
212 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 222
 		if ($res) {
215 223
 			return true;
216 224
 		} else {

+ 7
- 4
application/admin/model/User.php Просмотреть файл

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

+ 13
- 1
application/admin/model/UserField.php Просмотреть файл

@@ -147,7 +147,7 @@ class UserField extends Model
147 147
             $field_list[$v['field']]['name'] = $v['name'];
148 148
             $fieldArr[$k]['width'] = '';
149 149
         }
150
-       
150
+
151 151
         //已设置字段
152 152
         $value = $this->where(['types' => $types,'user_id' => $user_id])->value('datas');
153 153
         $value = $value ? json_decode($value, true) : [];
@@ -162,6 +162,8 @@ class UserField extends Model
162 162
             $a = 0;
163 163
             $b = 0;
164 164
             foreach ($value as $k=>$v) {
165
+                if (empty($field_list[$k]['name'])) continue;
166
+
165 167
                 if (empty($v['is_hide'])) {
166 168
                     $valueList[] = $k;
167 169
                     $value_list[$a]['field'] = $k; 
@@ -193,6 +195,16 @@ class UserField extends Model
193 195
         $data = [];
194 196
         $data['value_list'] = $value_list ? : []; //展示列
195 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 208
         return $data ? : [];
197 209
     }    
198 210
 }

+ 1
- 1
application/admin/view/install/index.html Просмотреть файл

@@ -28,7 +28,7 @@
28 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 29
 			官方电话:400-0812-558<br>
30 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 32
 			官方社群:<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=f4687b809bf63f08f707aa1c56dee8dbcb9526237c429c4532222021d65bf83c">悟空CRM交流10群(486745026)</a><br>
33 33
 		<br>
34 34
 		<p>一、协议中提到的名词约定</p>

+ 10
- 4
application/admin/view/install/step1.html Просмотреть файл

@@ -16,17 +16,23 @@
16 16
         <div class="top">
17 17
             <div class="step-group">
18 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 22
                     <div class="desc">检查安装环境</div>
21 23
                 </div>
22 24
                 <div class="step line"></div>
23 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 29
                     <div class="desc">创建数据库</div>
26 30
                 </div>
27 31
                 <div class="step line"></div>
28 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 36
                     <div class="desc">安装成功</div>
31 37
                 </div>
32 38
             </div>
@@ -34,7 +40,7 @@
34 40
         <div class="container">
35 41
             <div class="content">
36 42
                 <div class="base-top">
37
-                    <span class="title">1 检查安装环境</span>
43
+                    <span class="title">检查安装环境</span>
38 44
                     <span class="version">当前版本:{$data['version']['VERSION']} {$data['version']['RELEASE']}</span>
39 45
                 </div>
40 46
                 <div class="table">

+ 70
- 43
application/admin/view/install/step2.html Просмотреть файл

@@ -7,87 +7,114 @@
7 7
         <link rel="shortcut icon" href="__STATIC__/icon/favicon.ico">
8 8
         <link rel="stylesheet" href="__STATIC__/style/base.css">
9 9
         <link rel="stylesheet" href="__STATIC__/style/step2.css">
10
+        <link rel="stylesheet" href="__STATIC__/style/loading.css">
10 11
         <script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
11 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 21
         <div class="header-wrapper">
14 22
             {include file="public/header"}   
15 23
         </div>
16 24
         <div class="top">
17 25
             <div class="step-group">
18 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 30
                     <div class="desc">检查安装环境</div>
21 31
                 </div>
22 32
                 <div class="step active line"></div>
23 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 37
                     <div class="desc">创建数据库</div>
26 38
                 </div>
27 39
                 <div class="step line"></div>
28 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 44
                     <div class="desc">安装成功</div>
31 45
                 </div>
32 46
             </div>
33 47
         </div>
34
-
35
-        <div class="container">
48
+        <div class="container">         
36 49
             <div class="content">
37 50
                 <div class="base-top">
38
-                    <span class="title">2 创建数据库</span>
51
+                    <span class="title">创建数据库</span>
39 52
                     <span class="version">当前版本:{$envir_data['version']['VERSION']} {$envir_data['version']['RELEASE']}</span>
40 53
                 </div>
41 54
                 <div class="form">
42 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 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 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 102
                         <div class="form-label">管理员密码:</div>
79
-                        <input type="password" name="pwd">
103
+                        <input type="password" class="wkform" name="pwd" placeholder="6~20位字母加数字组合">
80 104
                     </div>
105
+                    
81 106
                 </div>
107
+                <div class="base-des">
108
+                </div>                
82 109
                 <div class="install_progress_a">
83 110
                 <!-- <progress class="install_progress" max="97" value="8"></progress> -->
84 111
                 </div>
85 112
                 <div class="control">
86 113
                     <div class="prev btn">上一步</div>
87
-                    <div class="next btn primary">下一步</div>
114
+                    <div class="next btn primary">安装</div>
88 115
                 </div>
89 116
             </div>
90
-        </div>
117
+        </div>     
91 118
         <div class="footer-wrapper">
92 119
             {include file="public/footer"}
93 120
         </div>

+ 9
- 3
application/admin/view/install/step3.html Просмотреть файл

@@ -16,17 +16,23 @@
16 16
         <div class="top">
17 17
             <div class="step-group">
18 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 22
                     <div class="desc">检查安装环境</div>
21 23
                 </div>
22 24
                 <div class="step active line"></div>
23 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 29
                     <div class="desc">创建数据库</div>
26 30
                 </div>
27 31
                 <div class="step line active"></div>
28 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 36
                     <div class="desc">安装成功</div>
31 37
                 </div>
32 38
             </div>

+ 64
- 0
application/admin/view/install/step5.html Просмотреть файл

@@ -0,0 +1,64 @@
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 Просмотреть файл

@@ -1,6 +1,6 @@
1 1
 <footer class="footer">
2 2
   <div class="content">
3 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 5
   </div>
6 6
 </footer>

+ 2
- 1
application/bi/controller/Examine.php Просмотреть файл

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

+ 30
- 7
application/common.php Просмотреть файл

@@ -165,10 +165,29 @@ function where_arr($array = [], $m = '', $c = '', $a = '')
165 165
                 if (!empty($v['start'])) $v['start'] = date('Y-m-d', $v['start']);
166 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 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 191
                 switch ($k) {
173 192
                     case 'business_id' :
174 193
                         $k = 'name';
@@ -186,11 +205,11 @@ function where_arr($array = [], $m = '', $c = '', $a = '')
186 205
                         break;
187 206
                 }
188 207
             }
189
-            if ($types == 'receivables' && $v['name'] == '合同编号') {
208
+            if ($types == 'receivables' && $v['name'] == '合同编号' && !empty($v['value'])) {
190 209
                 $k = 'num';
191 210
                 $c = 'contract.';
192 211
             }
193
-            if ($types == 'receivables' && $k == 'plan_id') {
212
+            if ($types == 'receivables' && $k == 'plan_id' && !empty($v['value'])) {
194 213
                 $planIds = [];
195 214
                 foreach ($v['value'] AS $kk => $vv) {
196 215
                     $planIdArray = db('crm_receivables_plan')->whereLike('num', '%' . $vv . '%')->column('plan_id');
@@ -200,17 +219,21 @@ function where_arr($array = [], $m = '', $c = '', $a = '')
200 219
                 }
201 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 223
                 foreach ($v['value'] AS $kk => $vv) {
205 224
                     if ($vv == '已开票') $v['value'][$kk] = 1;
206 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 229
                 $k = 'num';
211 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 237
                 $v['value'] = $checkStatusArray[$v['value'][0]] ?: '0';
215 238
             }
216 239
             if (is_array($v)) {

+ 19
- 6
application/crm/controller/Business.php Просмотреть файл

@@ -276,11 +276,6 @@ class Business extends ApiCommon
276 276
                 $errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:无权限;';
277 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 281
             teamUserId(
@@ -291,7 +286,25 @@ class Business extends ApiCommon
291 286
                 $is_remove,
292 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 309
             updateActionLog($userInfo['id'], 'crm_business', $business_id, '', '', '将商机转移给:'.$ownerUserName);       
297 310
         }

+ 30
- 21
application/crm/controller/Contract.php Просмотреть файл

@@ -214,12 +214,6 @@ class Contract extends ApiCommon
214 214
         if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
215 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 217
             if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
224 218
                 //将合同审批状态至为待审核,提交后重新进行审批
225 219
                 //审核判断(是否有符合条件的审批流)
@@ -244,7 +238,7 @@ class Contract extends ApiCommon
244 238
                 } else {
245 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 243
                     $param['check_status'] = 5;
250 244
                     $param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
@@ -257,7 +251,7 @@ class Contract extends ApiCommon
257 251
                 }
258 252
                 $param['flow_user_id'] = '';
259 253
             }
260
-        }
254
+        
261 255
 
262 256
         if ($contractModel->updateDataById($param, $param['id'])) {
263 257
             //将审批记录至为无效
@@ -314,7 +308,7 @@ class Contract extends ApiCommon
314 308
                 $isDel = false;
315 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 312
                 $isDel = false;
319 313
                 $errorMessage[] = '名称为'.$data['name'].'的合同删除失败,错误原因:当前状态为审批中或已审批通过,不可删除';
320 314
             }
@@ -335,9 +329,9 @@ class Contract extends ApiCommon
335 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 336
             $actionRecordModel->delDataById(['types'=>'crm_contract','action_id'=>$delIds]);
343 337
             // 删除回款记录
@@ -395,15 +389,10 @@ class Contract extends ApiCommon
395 389
                 $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:无权限;';
396 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 398
             teamUserId(
@@ -411,9 +400,29 @@ class Contract extends ApiCommon
411 400
                 $contract_id,
412 401
                 $type,
413 402
                 [$contractInfo['owner_user_id']],
414
-                $is_remove,
403
+                ($is_remove == 1) ? 1 : '',
415 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 427
             updateActionLog($userInfo['id'], 'crm_contract', $contract_id, '', '', '将合同转移给:'.$ownerUserName);        
419 428
         }

+ 16
- 3
application/crm/controller/Customer.php Просмотреть файл

@@ -316,7 +316,20 @@ class Customer extends ApiCommon
316 316
             if (!$resCustomer) {
317 317
                 $errorMessage[] = $customerInfo['name'].'转移失败,错误原因:数据出错;';
318 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 334
             if (in_array('crm_contacts',$types)) {
322 335
                 $contactsIds = [];
@@ -339,7 +352,7 @@ class Customer extends ApiCommon
339 352
                     if ($resBusiness !== true) {
340 353
                         $errorMessage = $errorMessage ? array_merge($errorMessage,$resBusiness) : $resBusiness;
341 354
                         continue;                        
342
-                    }                    
355
+                    }
343 356
                 }
344 357
             }
345 358
 
@@ -677,7 +690,7 @@ class Customer extends ApiCommon
677 690
         $file = request()->file('file');
678 691
         // $res = $excelModel->importExcel($file, $param, $this);
679 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 Просмотреть файл

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

+ 5
- 1
application/crm/controller/Leads.php Просмотреть файл

@@ -226,7 +226,8 @@ class Leads extends ApiCommon
226 226
             $data['deal_time'] = time();
227 227
             $data['create_time'] = time();
228 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 232
             $data['obtain_time'] = time();
232 233
             //权限判断
@@ -404,6 +405,9 @@ class Leads extends ApiCommon
404 405
         $file = request()->file('file');
405 406
         // $res = $excelModel->importExcel($file, $param);
406 407
         $res = $excelModel->batchImportData($file, $param, $this);
408
+        if (!$res) {
409
+            return resultArray(['error' => $excelModel->getError()]);
410
+        }
407 411
         return resultArray(['data' => $excelModel->getError()]);
408 412
     }
409 413
 

+ 3
- 0
application/crm/controller/Product.php Просмотреть файл

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

+ 201
- 154
application/crm/controller/Receivables.php Просмотреть файл

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

+ 2
- 4
application/crm/controller/Visit.php Просмотреть файл

@@ -68,9 +68,8 @@ class Visit extends ApiCommon
68 68
             if (empty($numberInfo['number'])) return resultArray(['error' => '请填写回访编号!']);
69 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 72
         $param['create_user_id'] = $userInfo['id'];
73
-        $param['visit_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
74 73
         $param['update_time'] = time();
75 74
         $res = $Visit->createData($param);
76 75
         if ($res) {
@@ -119,8 +118,7 @@ class Visit extends ApiCommon
119 118
         $param = $this->param;
120 119
         $userInfo = $this->userInfo;
121 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 123
         $numberInfo = [];
126 124
         if (empty($param['number'])) {

+ 4
- 3
application/crm/logic/ActivityLogic.php Просмотреть файл

@@ -359,8 +359,9 @@ class ActivityLogic
359 359
         $fileModel = new \app\admin\model\File();
360 360
         foreach ($dataArray AS $key => $value) {
361 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 367
             if ($value['type'] = 1) {
@@ -785,7 +786,7 @@ class ActivityLogic
785 786
         # 审批
786 787
         if ($activityType == 9) {
787 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 792
         if ($activityType == 10) {

+ 161
- 54
application/crm/logic/CommonLogic.php Просмотреть файл

@@ -12,11 +12,12 @@ use app\admin\controller\ApiCommon;
12 12
 use app\admin\model\User;
13 13
 use app\crm\model\Customer;
14 14
 use think\Db;
15
+use think\Validate;
15 16
 
16 17
 class CommonLogic
17 18
 {
18 19
     public $error = '操作失败!';
19
-
20
+    
20 21
     /**
21 22
      * 快捷编辑【线索、客户、联系人、商机、合同、回款、回访、产品】
22 23
      *
@@ -37,56 +38,113 @@ class CommonLogic
37 38
          * $param['name']      字段中文名,用作提示
38 39
          * $param['value]      字段值
39 40
          */
40
-
41
+        
41 42
         $actionId = $param['action_id'];
42
-        $types    = $param['types'];
43
+        $types = $param['types'];
43 44
         unset($param['action_id']);
44 45
         unset($param['types']);
45
-
46
+        
46 47
         # 模型
47 48
         $model = db($types);
48
-
49
+        
49 50
         # 主键
50 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 93
         $apiCommon = new ApiCommon();
61 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 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 124
             $auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'update');
67 125
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
68 126
             $wherePool = (new Customer())->getWhereByPool();
69 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 129
                 $this->error = '无权操作!';
72 130
                 return false;
73 131
             }
74 132
         }
75
-
133
+        
76 134
         # 商机模块快捷编辑权限验证
77 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 137
             $auth_user_ids = $userModel->getUserByPer('crm', 'business', 'update');
80 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 140
                 $this->error = '无权操作!';
83 141
                 return false;
84 142
             }
85 143
         }
86
-
144
+        
87 145
         # 合同模块快捷编辑权限验证
88 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 148
             $auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'update');
91 149
             $rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
92 150
             if (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre) {
@@ -95,51 +153,100 @@ class CommonLogic
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 195
         $data = [];
196
+        $item=[];
124 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 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 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 Просмотреть файл

@@ -23,6 +23,10 @@ class IndexLogic extends Common
23 23
         '12' => 'december',
24 24
     ];
25 25
 
26
+    /**
27
+     * @param $param
28
+     * @return array
29
+     */
26 30
     public function index($param)
27 31
     {
28 32
         $adminModel = new \app\admin\model\Admin();
@@ -69,17 +73,16 @@ class IndexLogic extends Common
69 73
         $contract_auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'index');
70 74
         $receivables_auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'index');
71 75
         $record_auth_user_ids = $userModel->getUserByPer('crm', 'activity', 'index');
72
-
73 76
         $resCount = queryCache(
74 77
             $this->getCountSql([
75 78
                 'start_time' => $between_time[0],
76 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 Просмотреть файл

@@ -54,12 +54,7 @@ class VisitLogic extends Common
54 54
 
55 55
         //高级筛选
56 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 58
         $authMap = [];
64 59
         if (!$partMap) {
65 60
             $a = 'index';
@@ -68,20 +63,20 @@ class VisitLogic extends Common
68 63
                 if (!is_array($map['visit.owner_user_id'][1])) {
69 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 67
                     $auth_user_ids = array_diff($auth_user_ids, $map['visit.owner_user_id'][1]) ?: [];    //取差集
73 68
                 } else {
74 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 71
                 $auth_user_ids = array_merge(array_unique(array_filter($auth_user_ids))) ?: ['-1'];
78 72
                 $authMap['visit.owner_user_id'] = array('in', $auth_user_ids);
73
+                unset($map['visit.owner_user_id']);
79 74
             } else {
80 75
                 $authMapData = [];
81 76
                 $authMapData['auth_user_ids'] = $auth_user_ids;
82 77
                 $authMapData['user_id'] = $user_id;
83 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 80
                         ->whereOr('visit.ro_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'))
86 81
                         ->whereOr('visit.rw_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'));
87 82
                 };
@@ -96,6 +91,7 @@ class VisitLogic extends Common
96 91
         //人员类型
97 92
         $userField = $fieldModel->getFieldByFormType('crm_visit', 'user'); //人员类型
98 93
         $structureField = $fieldModel->getFieldByFormType('crm_visit', 'structure');  //部门类型
94
+        $datetimeField = $fieldModel->getFieldByFormType('crm_visit', 'datetime'); //日期时间类型
99 95
 
100 96
         //排序
101 97
         if ($order_type && $order_field) {
@@ -118,12 +114,11 @@ class VisitLogic extends Common
118 114
             ->where($partMap)
119 115
             ->where($authMap)
120 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 122
             ->orderRaw($order)
128 123
             ->group('visit.visit_id')
129 124
             ->select();
@@ -140,10 +135,15 @@ class VisitLogic extends Common
140 135
             $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
141 136
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
142 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 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 148
             $list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
149 149
             $list[$k]['contract_id_info']['name'] = $v['contract_name'];
@@ -161,7 +161,7 @@ class VisitLogic extends Common
161 161
             $is_update = 0;
162 162
             $is_delete = 0;
163 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 165
             if (in_array($v['owner_user_id'], $deleteAuthIds)) $is_delete = 1;
166 166
             $permission['is_read'] = $is_read;
167 167
             $permission['is_update'] = $is_update;
@@ -198,6 +198,11 @@ class VisitLogic extends Common
198 198
         $dataInfo['contacts_id_info'] = db('crm_contacts')->where(['contacts_id' => $dataInfo['contacts_id']])->field('contacts_id,name')->find();
199 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 206
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
202 207
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
203 208
         return $dataInfo;
@@ -330,7 +335,7 @@ class VisitLogic extends Common
330 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 340
             $actionRecordModel->delDataById(['types' => 'crm_visit', 'visit_id' => $delIds]);
336 341
             actionLog($delIds, '', '', '');

+ 440
- 417
application/crm/model/Business.php
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 18
- 18
application/crm/model/Contacts.php Просмотреть файл

@@ -85,7 +85,7 @@ class Contacts extends Common
85 85
 			if (!is_array($map['contacts.owner_user_id'][1])) {
86 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 89
 				$auth_user_ids = array_diff($auth_user_ids, $map['contacts.owner_user_id'][1]) ? : [];	//取差集	
90 90
 			} else {
91 91
 				$auth_user_ids = array_intersect($map['contacts.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集	
@@ -107,7 +107,8 @@ class Contacts extends Common
107 107
 		//列表展示字段
108 108
 		$indexField = $fieldModel->getIndexField('crm_contacts', $user_id, 1) ? : array('name');
109 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 114
 		if ($order_type && $order_field) {
@@ -130,7 +131,7 @@ class Contacts extends Common
130 131
         			->where($searchMap)
131 132
         			->where($authMap)
132 133
         			->where($customerWhere)
133
-        			->count('contacts_id'); 
134
+        			->count('contacts_id');
134 135
 		if ($getCount == 1) {
135 136
 			$data['dataCount'] = $dataCount ? : 0;
136 137
 	        return $data;
@@ -144,7 +145,6 @@ class Contacts extends Common
144 145
 				->where($customerWhere)
145 146
         		->limit($request['offset'], $request['length'])
146 147
         		->field('contacts.*,customer.name as customer_name')
147
-        		->field(implode(',',$indexField).',customer.name as customer_name')
148 148
         		->orderRaw($order)
149 149
         		->select();
150 150
         
@@ -154,11 +154,16 @@ class Contacts extends Common
154 154
         	$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'] ? : '';
155 155
         	$list[$k]['customer_id_info']['name'] = $v['customer_name'] ? : '';
156 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 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 169
 			$permission = [];
@@ -173,9 +178,6 @@ class Contacts extends Common
173 178
 	        $permission['is_delete'] = $is_delete;
174 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 182
             $starWhere = ['user_id' => $user_id, 'target_id' => $v['contacts_id'], 'type' => 'crm_contacts'];
181 183
             $star = Db::name('crm_star')->where($starWhere)->value('star_id');
@@ -227,9 +229,6 @@ class Contacts extends Common
227 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 233
 		$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
235 234
 		foreach ($arrFieldAtt as $k=>$v) {
@@ -249,7 +248,7 @@ class Contacts extends Common
249 248
                 'create_user_id'   => $param['create_user_id'],
250 249
                 'update_time'      => time(),
251 250
                 'create_time'      => time(),
252
-                'customer_ids'      => $param['customer_id']
251
+                'customer_ids'     => $param['customer_id']
253 252
             ]);
254 253
 
255 254
             # 处理商机首要联系人
@@ -319,9 +318,6 @@ class Contacts extends Common
319 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 322
 		$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
327 323
 		foreach ($arrFieldAtt as $k=>$v) {
@@ -382,7 +378,11 @@ class Contacts extends Common
382 378
         # 处理决策人显示问题
383 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 386
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
387 387
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
388 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 Просмотреть файл

@@ -99,7 +99,7 @@ class Contract extends Common
99 99
 				if (!is_array($map['contract.owner_user_id'][1])) {
100 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 103
 					$auth_user_ids = array_diff($auth_user_ids, $map['contract.owner_user_id'][1]) ? : [];	//取差集	
104 104
 				} else {
105 105
 					$auth_user_ids = array_intersect($map['contract.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
@@ -127,6 +127,7 @@ class Contract extends Common
127 127
 		//人员类型
128 128
 		$userField = $fieldModel->getFieldByFormType('crm_contract', 'user');
129 129
 		$structureField = $fieldModel->getFieldByFormType('crm_contract', 'structure');  //部门类型
130
+        $datetimeField = $fieldModel->getFieldByFormType('crm_contract', 'datetime'); //日期时间类型
130 131
 		//排序
131 132
 		if ($order_type && $order_field) {
132 133
 			$order = $fieldModel->getOrderByFormtype('crm_contract','contract',$order_field,$order_type);
@@ -186,11 +187,16 @@ class Contract extends Common
186 187
         	$list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
187 188
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
188 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 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 200
         	$list[$k]['business_id_info']['business_id'] = $v['business_id'];
195 201
         	$list[$k]['business_id_info']['name'] = $v['business_name'];
196 202
         	$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
@@ -226,6 +232,9 @@ class Contract extends Common
226 232
             $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
227 233
             $list[$k]['update_time'] = !empty($v['update_time']) ? date('Y-m-d H:i:s', $v['update_time']) : null;
228 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 239
             $orderNames = Db::name('admin_user')->whereIn('id', trim($v['order_user_id'], ','))->column('realname');
231 240
             $list[$k]['order_user_name'] = implode(',', $orderNames);
@@ -488,6 +497,11 @@ class Contract extends Common
488 497
         $orderNames = Db::name('admin_user')->whereIn('id', trim($dataInfo['order_user_id'], ','))->column('realname');
489 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 505
         $dataInfo['next_time']   = !empty($dataInfo['next_time'])   ? date('Y-m-d H:i:s', $dataInfo['next_time'])   : null;
492 506
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
493 507
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
@@ -510,10 +524,10 @@ class Contract extends Common
510 524
     	foreach ($ids as $id) {
511 525
     		$contractInfo = [];
512 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 532
 	        $teamData = [];
519 533
             $teamData['type'] = $type; //权限 1只读2读写
@@ -529,7 +543,19 @@ class Contract extends Common
529 543
 	        if (!db('crm_contract')->where(['contract_id' => $id])->update($data)) {
530 544
 				$errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:数据出错;';
531 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 560
     	if ($errorMessage) {
535 561
 			return $errorMessage;

+ 67
- 67
application/crm/model/Customer.php Просмотреть файл

@@ -127,7 +127,7 @@ class Customer extends Common
127 127
 			    	if (!is_array($map['customer.owner_user_id'][1])) {
128 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 131
 						$auth_user_ids = array_diff($auth_user_ids, $map['customer.owner_user_id'][1]) ? : [];	//取差集
132 132
 					} else {
133 133
 						$auth_user_ids = array_intersect($map['customer.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
@@ -169,6 +169,7 @@ class Customer extends Common
169 169
 		$indexField = $fieldModel->getIndexField('crm_customer', $user_id, 1) ? : array('name');
170 170
 		$userField = $fieldModel->getFieldByFormType('crm_customer', 'user'); //人员类型
171 171
 		$structureField = $fieldModel->getFieldByFormType('crm_customer', 'structure'); //部门类型
172
+        $datetimeField = $fieldModel->getFieldByFormType('crm_customer', 'datetime'); //日期时间类型
172 173
 		//排序
173 174
 		if ($order_type && $order_field) {
174 175
 			$order = $fieldModel->getOrderByFormtype('crm_customer','customer',$order_field,$order_type);
@@ -190,8 +191,7 @@ class Customer extends Common
190 191
 				->where($poolMap)
191 192
 				->where($otherMap)
192 193
         		->limit($request['offset'], $request['length'])
193
-        		->field(implode(',',$indexField))
194
-        		->order($order_t) /*置顶*/
194
+        		->field('customer.*')
195 195
         		->orderRaw($order)
196 196
 				->select();
197 197
         //保护规则
@@ -228,14 +228,19 @@ class Customer extends Common
228 228
                 $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
229 229
 				foreach ($userField as $key => $val) {
230 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 235
 				foreach ($structureField as $key => $val) {
235 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 245
 				$list[$k]['business_count'] = $business_count[$v['customer_id']]['count'] ?: 0;
241 246
 	        	//距进入公海天数
@@ -268,9 +273,6 @@ class Customer extends Common
268 273
 		        $permission['is_delete'] = $is_delete;
269 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 277
                 $starWhere = ['user_id' => $user_id, 'target_id' => $v['customer_id'], 'type' => 'crm_customer'];
276 278
                 $star = Db::name('crm_star')->where($starWhere)->value('star_id');
@@ -327,9 +329,6 @@ class Customer extends Common
327 329
 			return false;
328 330
 		}
329 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 334
 		$arrFieldAtt = $fieldModel->getArrayField('crm_customer');
@@ -377,71 +376,68 @@ class Customer extends Common
377 376
 	 * @author Michael_xu
378 377
 	 * @param  
379 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 390
         $userModel = new \app\admin\model\User();
392 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 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 397
         if ($resPool || (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre)) {
399 398
             $this->error = '无权操作';
400 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 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,7 +491,11 @@ class Customer extends Common
495 491
         $primaryId = Db::name('crm_contacts')->where(['customer_id' => $id, 'primary' => 1])->value('contacts_id');
496 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 499
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
500 500
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
501 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 Просмотреть файл

@@ -14,6 +14,7 @@ class Invoice extends Common
14 14
 {
15 15
     protected $name = 'crm_invoice';
16 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 Просмотреть файл

@@ -90,7 +90,7 @@ class Leads extends Common
90 90
             if (!is_array($map['leads.owner_user_id'][1])) {
91 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 94
                 $auth_user_ids = array_diff($auth_user_ids, $map['leads.owner_user_id'][1]) ?: [];    //取差集
95 95
             } else {
96 96
                 $auth_user_ids = array_intersect($map['leads.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
@@ -104,6 +104,7 @@ class Leads extends Common
104 104
         $indexField = $fieldModel->getIndexField('crm_leads', $user_id, 1) ?: array('name');
105 105
         $userField = $fieldModel->getFieldByFormType('crm_leads', 'user'); //人员类型
106 106
         $structureField = $fieldModel->getFieldByFormType('crm_leads', 'structure');  //部门类型
107
+        $datetimeField = $fieldModel->getFieldByFormType('crm_leads', 'datetime'); //日期时间类型
107 108
 
108 109
         //排序
109 110
         if ($order_type && $order_field) {
@@ -139,10 +140,15 @@ class Leads extends Common
139 140
             $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
140 141
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
141 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 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 154
             $permission = [];
@@ -156,8 +162,6 @@ class Leads extends Common
156 162
             $permission['is_update'] = $is_update;
157 163
             $permission['is_delete'] = $is_delete;
158 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 166
             $starWhere = ['user_id' => $user_id, 'target_id' => $v['leads_id'], 'type' => 'crm_leads'];
163 167
             $star = Db::name('crm_star')->where($starWhere)->value('star_id');
@@ -210,9 +214,6 @@ class Leads extends Common
210 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 217
         if ($this->data($param)->allowField(true)->isUpdate(false)->save()) {
217 218
             //修改记录
218 219
             updateActionLog($param['create_user_id'], 'crm_leads', $this->leads_id, '', '', '创建了线索');
@@ -276,9 +277,6 @@ class Leads extends Common
276 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 281
         $arrFieldAtt = $fieldModel->getArrayField('crm_leads');
284 282
         foreach ($arrFieldAtt as $k => $v) {
@@ -323,7 +321,11 @@ class Leads extends Common
323 321
         $starId = empty($userId) ? 0 : Db::name('crm_star')->where(['user_id' => $userId, 'target_id' => $id, 'type' => 'crm_leads'])->value('star_id');
324 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 329
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
328 330
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
329 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 Просмотреть файл

@@ -35,7 +35,7 @@ class Product extends Common
35 35
      * @return array
36 36
      */
37 37
 	public function getDataList($request)
38
-    {  	
38
+    {
39 39
     	$userModel = new \app\admin\model\User();
40 40
     	$structureModel = new \app\admin\model\Structure();
41 41
     	$fieldModel = new \app\admin\model\Field();
@@ -48,8 +48,8 @@ class Product extends Common
48 48
     	$isStatus = !empty($request['is_status']) ? $request['is_status'] : 0;
49 49
 		unset($request['scene_id']);
50 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 53
 		unset($request['order_type']);
54 54
 		unset($request['is_status']);
55 55
 
@@ -87,7 +87,7 @@ class Product extends Common
87 87
             if (!is_array($map['product.owner_user_id'][1])) {
88 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 91
                 $auth_user_ids = array_diff($auth_user_ids, $map['product.owner_user_id'][1]) ?: [];    //取差集
92 92
             } else {
93 93
                 $auth_user_ids = array_intersect($map['product.owner_user_id'][1], $auth_user_ids) ?: [];    //取交集
@@ -102,25 +102,26 @@ class Product extends Common
102 102
 		$indexField = $fieldModel->getIndexField('crm_product', $user_id, 1) ? : ['name'];
103 103
 		$userField = $fieldModel->getFieldByFormType('crm_product', 'user'); //人员类型
104 104
 		$structureField = $fieldModel->getFieldByFormType('crm_product', 'structure');  //部门类型
105
-					
105
+        $datetimeField = $fieldModel->getFieldByFormType('crm_product', 'datetime'); //日期时间类型
106
+		
106 107
 		//排序
107 108
 		if ($order_type && $order_field) {
108 109
 			$order = $fieldModel->getOrderByFormtype('crm_product','product',$order_field,$order_type);
109 110
 		} else {
110 111
 			$order = 'product.update_time desc';
111
-		}		
112
+		}
112 113
 
113 114
 		$join = [
114 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 118
 		$list = db('crm_product')->alias('product')
118 119
 				->join($join)
119 120
 				->where($map)
120 121
 				->where($authMap)
121 122
         		->limit($request['offset'], $request['length'])
122 123
 				->field($indexField)
123
-				->field(array_merge($indexField, ['product_category.name' => 'category_name']))
124
+				->field('product.*,product_category.name as category_name')
124 125
         		->orderRaw($order)
125 126
         		->select();
126 127
         $dataCount = db('crm_product')->alias('product')
@@ -132,11 +133,16 @@ class Product extends Common
132 133
         	$list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : '';
133 134
             $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : '';
134 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 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 147
 			$list[$k]['category_id_info'] = $v['category_name'];
142 148
             # 处理日期格式
@@ -153,23 +159,25 @@ class Product extends Common
153 159
 	/**
154 160
 	 * 创建产品主表信息
155 161
 	 * @author Michael_xu
156
-	 * @param  
157
-	 * @return                            
158
-	 */	
162
+	 * @param
163
+	 * @return
164
+	 */
159 165
 	public function createData($param)
160 166
 	{
161 167
 		$fieldModel = new \app\admin\model\Field();
162 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 182
 		$arrFieldAtt = $fieldModel->getArrayField('crm_product');
175 183
 		foreach ($arrFieldAtt as $k=>$v) {
@@ -200,17 +208,18 @@ class Product extends Common
200 208
 		} else {
201 209
 			$this->error = '添加失败';
202 210
 			return false;
203
-		}			
211
+		}
204 212
 	}
205 213
 
206 214
 	/**
207 215
 	 * 编辑产品主表信息
208 216
 	 * @author Michael_xu
209
-	 * @param  
210
-	 * @return                            
211
-	 */	
217
+	 * @param
218
+	 * @return
219
+	 */
212 220
 	public function updateDataById($param, $product_id = '')
213 221
 	{
222
+        $userModel = new \app\admin\model\User();
214 223
 		$dataInfo = $this->getDataById($product_id);
215 224
 		$productCategoryModel = model('ProductCategory');
216 225
 		if (!$dataInfo) {
@@ -222,7 +231,7 @@ class Product extends Common
222 231
         if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
223 232
             $this->error = '无权操作';
224 233
             return false;
225
-        }		
234
+        }
226 235
 
227 236
 		$param['product_id'] = $product_id;
228 237
 		//过滤不能修改的字段
@@ -232,15 +241,16 @@ class Product extends Common
232 241
 		}
233 242
 		
234 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 256
 		$arrFieldAtt = $fieldModel->getArrayField('crm_product');
@@ -250,17 +260,16 @@ class Product extends Common
250 260
 
251 261
 		//产品分类
252 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 267
         if(!is_int($category_id)){
258 268
             $list=db('crm_product_category')->column('category_id','name');
269
+            $param['category_id']=1;
259 270
             foreach ($list as $k=>$v){
260
-                if($k==$param['category_id']){
271
+                if($k==$category_id){
261 272
                     $param['category_id']=$v;
262
-                }else{
263
-                    $param['category_id']=0;
264 273
                 }
265 274
             }
266 275
         }
@@ -274,7 +283,7 @@ class Product extends Common
274 283
 			$this->rollback();
275 284
 			$this->error = '编辑失败';
276 285
 			return false;
277
-		}					
286
+		}
278 287
 	}
279 288
 
280 289
     /**
@@ -287,8 +296,9 @@ class Product extends Common
287 296
      * @throws \think\exception\DbException
288 297
      */
289 298
    	public function getDataById($id = '')
290
-   	{   		
299
+   	{
291 300
    		$map['product_id'] = $id;
301
+   		$map['delete_user_id'] = 0;
292 302
 		$dataInfo = db('crm_product')->where($map)->find();
293 303
 		if (!$dataInfo) {
294 304
 			$this->error = '暂无此数据';
@@ -302,8 +312,13 @@ class Product extends Common
302 312
 
303 313
 		$userModel = new \app\admin\model\User();
304 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 322
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
308 323
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
309 324
         return $dataInfo;
@@ -320,19 +335,15 @@ class Product extends Common
320 335
      */
321 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 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,10 +357,10 @@ class Product extends Common
346 357
      * @param  subtotal 小计(折扣后价格)
347 358
      * @param  unit 单位
348 359
      * @param  total_price 折扣后整单总价
349
-     * @param  discount_rate 整单折扣 
360
+     * @param  discount_rate 整单折扣
350 361
      * @param  objId 关联对象ID
351
-     * @return 
352
-     */ 
362
+     * @return
363
+     */
353 364
     public function createObject($types, $param, $objId)
354 365
     {
355 366
     	switch ($types) {
@@ -375,7 +386,7 @@ class Product extends Common
375 386
 		    		$product[$key]['discount'] = $value['discount']; //折扣
376 387
 		    		$product[$key]['unit'] = $value['unit'] ? : ''; //单位
377 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 390
 		    		$product[$key][$db_id] = $objId;
380 391
 		    	}
381 392
 
@@ -388,18 +399,18 @@ class Product extends Common
388 399
 				//产品合计
389 400
 				$rData['discount_rate'] = !empty($param['discount_rate']) ? $param['discount_rate'] : 0.00; //整单折扣
390 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 407
     			Db::commit();
397
-		    	return true;    			
408
+		    	return true;
398 409
 			} catch (\Exception $e) {
399 410
 				$this->error = '产品数据创建出错';
400 411
 				// 回滚事务
401
-			    Db::rollback();					
402
-	    		return false;   				    
412
+			    Db::rollback();
413
+	    		return false;
403 414
 			}
404 415
     	} else {
405 416
     		//删除产品信息
@@ -425,7 +436,7 @@ class Product extends Common
425 436
         $perUserIds = $userModel->getUserByPer('bi', 'product', 'read'); //权限范围内userIds
426 437
         $whereData = $adminModel->getWhere($param, '', $perUserIds); //统计条件
427 438
         $userIds = $whereData['userIds'];
428
-        $between_time = $whereData['between_time'];     
439
+        $between_time = $whereData['between_time'];
429 440
         $where = [];
430 441
 		//时间段
431 442
 		$where['contract.create_time'] = ['between', $between_time];
@@ -457,7 +468,7 @@ class Product extends Common
457 468
 			$list[$k]['contract_id_info'] = $contract_info ? : array();
458 469
 			//产品
459 470
 			$product_info = [];
460
-			$product_info['name'] = $v['product_name']; 
471
+			$product_info['name'] = $v['product_name'];
461 472
 			$product_info['product_id'] = $v['product_id'];
462 473
 			$list[$k]['product_id_info'] = $product_info ? : array();
463 474
 			//负责人
@@ -467,14 +478,14 @@ class Product extends Common
467 478
 			$list[$k]['owner_user_name'] = $owner_user_id_info['realname'];
468 479
 		}
469 480
         return $list;
470
-    }  
481
+    }
471 482
 
472 483
 	/**
473 484
      * [根据产品类别ID,查询父级ID]
474 485
      * @author Michael_xu
475
-     * @param 
476
-     * @return                   
477
-     */		
486
+     * @param
487
+     * @return
488
+     */
478 489
 	public function getPidStr($category_id, $idArr, $first = '')
479 490
 	{
480 491
 		if ($first == 1) $idArr = [];

+ 16
- 5
application/crm/model/Receivables.php Просмотреть файл

@@ -83,7 +83,7 @@ class Receivables extends Common
83 83
 			if (!is_array($map['receivables.owner_user_id'][1])) {
84 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 87
 				$auth_user_ids = array_diff($auth_user_ids, $map['receivables.owner_user_id'][1]) ? : [];	//取差集	
88 88
 			} else {
89 89
 				$auth_user_ids = array_intersect($map['receivables.owner_user_id'][1], $auth_user_ids) ? : [];	//取交集
@@ -97,7 +97,8 @@ class Receivables extends Common
97 97
 		$indexField = $fieldModel->getIndexField('crm_receivables', $user_id, 1) ? : array('number');    
98 98
 		//人员类型
99 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 103
 		if ($request['order_type'] && $request['order_field']) {
103 104
 			$order = $fieldModel->getOrderByFormtype('crm_receivables','receivables',$order_field,$order_type);
@@ -134,7 +135,7 @@ class Receivables extends Common
134 135
 				->where($map)
135 136
 				->where($authMap)
136 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 139
 				->orderRaw($order)
139 140
 				->select();	
140 141
 
@@ -150,11 +151,16 @@ class Receivables extends Common
150 151
         	$list[$k]['contract_id_info']['money'] = $v['contract_money'] ? : '0.00';
151 152
         	$list[$k]['contract_money'] = $v['contract_money'] ? : '0.00';  
152 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 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 164
         	$list[$k]['check_status_info'] = $this->statusArr[$v['check_status']];
159 165
         	//期数
160 166
         	$plan_num = db('crm_receivables_plan')->where(['plan_id' => $v['plan_id']])->value('num');
@@ -403,6 +409,11 @@ class Receivables extends Common
403 409
         $dataInfo['contract_id_info'] = $dataInfo['contract_id'] ? db('crm_contract')->where(['contract_id' => $dataInfo['contract_id']])->field('contract_id,name,money')->find() : [];  		
404 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 417
         $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
407 418
         $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
408 419
 		return $dataInfo;

+ 3
- 1
application/oa/controller/Event.php Просмотреть файл

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

+ 5
- 4
application/oa/controller/Examine.php Просмотреть файл

@@ -468,7 +468,7 @@ class Examine extends ApiCommon
468 468
                     $is_end = 1;
469 469
                     //审批结束
470 470
                     $checkData['check_status'] = !empty($status) ? 2 : 3;
471
-                    $examineData['check_user_id'] = '';
471
+//                    $examineData['check_user_id'] = '';
472 472
                 } else {
473 473
                     //修改主体相关审批信息
474 474
                     $examineData['check_user_id'] = arrayToString($next_user_ids);
@@ -484,7 +484,7 @@ class Examine extends ApiCommon
484 484
             }
485 485
             if ($is_end == 1) {
486 486
                 $checkData['check_status'] = !empty($status) ? 2 : 3;
487
-                $examineData['check_user_id'] = '';
487
+//                $examineData['check_user_id'] = '';
488 488
                 $examineData['check_status'] = 2;
489 489
             }
490 490
         } else {
@@ -588,8 +588,9 @@ class Examine extends ApiCommon
588 588
         $checkData['status'] = $status;
589 589
 
590 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 594
         $resExamine = db('oa_examine')->where(['examine_id' => $examine_id])->update($examineData);
594 595
         if ($resExamine) {
595 596
             //将审批记录至为无效

+ 58
- 58
application/oa/controller/Task.php Просмотреть файл

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

+ 314
- 38
application/oa/logic/ExamineLogic.php Просмотреть файл

@@ -10,7 +10,193 @@ use think\Validate;
10 10
 class ExamineLogic extends Common
11 11
 {
12 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 202
      * @param $param
@@ -19,35 +205,125 @@ class ExamineLogic extends Common
19 205
     public function excelExport($param)
20 206
     {
21 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 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 329
      * @param $param
@@ -65,9 +341,9 @@ class ExamineLogic extends Common
65 341
                 $query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
66 342
             };
67 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 348
         } elseif ($param['status'] == 3) {
73 349
             $where['a.check_status'] = ['lt', 5];
@@ -98,7 +374,7 @@ class ExamineLogic extends Common
98 374
                     $list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
99 375
                     $list[$k]['customer_id_info']['name'] = $v['customer_name'];
100 376
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
101
-
377
+                    
102 378
                 }
103 379
                 $dataCount = db('crm_contract')
104 380
                     ->alias('a')
@@ -135,7 +411,7 @@ class ExamineLogic extends Common
135 411
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
136 412
                     $list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
137 413
                     $list[$k]['contract_id_info']['name'] = $v['contract_name'];
138
-
414
+                    
139 415
                 }
140 416
                 break;
141 417
             case '3':
@@ -153,7 +429,7 @@ class ExamineLogic extends Common
153 429
                     ->select();
154 430
                 foreach ($list as $k => $v) {
155 431
                     $list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
156
-
432
+                    
157 433
                 }
158 434
                 $dataCount = db('crm_invoice')
159 435
                     ->alias('a')
@@ -162,13 +438,13 @@ class ExamineLogic extends Common
162 438
                     ->where($whereOr)
163 439
                     ->count();
164 440
                 break;
165
-
441
+            
166 442
         }
167
-
443
+        
168 444
         foreach ($list as $key => $v) {
169 445
             $list[$key]['create_time'] = date('Y-m-d H:i:s', $v['create_time']) ?: '';
170 446
         }
171
-
447
+        
172 448
         $data = [];
173 449
         $data['page']['list'] = $list;
174 450
         $data['page']['dataCount'] = $dataCount ?: 0;
@@ -184,5 +460,5 @@ class ExamineLogic extends Common
184 460
         }
185 461
         return $data;
186 462
     }
187
-
463
+    
188 464
 }

+ 31
- 46
application/oa/logic/LogLogic.php Просмотреть файл

@@ -38,15 +38,8 @@ class LogLogic extends Common
38 38
     public function getDataList($request)
39 39
     {
40 40
         $userModel = new \app\admin\model\User();
41
-        $structureModel = new \app\admin\model\Structure();
42
-        $fileModel = new \app\admin\model\File();
43 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 42
         $recordModel = new \app\admin\model\Record();
49
-
50 43
         $user_id = $request['read_user_id'];
51 44
         $by = $request['by'] ?: '';
52 45
 
@@ -78,44 +71,39 @@ class LogLogic extends Common
78 71
         }
79 72
         $requestData = $this->requestData();
80 73
         //获取权限范围内的员工
74
+        //获取权限范围内的员工
81 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 101
         $list = Db::name('OaLog')
114 102
             ->where($map)
103
+            ->where($logMap)
115 104
             ->where($searchMap)
116 105
             ->alias('log')
117 106
             ->join('__ADMIN_USER__ user', 'user.id = log.create_user_id', 'LEFT')
118
-            ->page($request['page'], $request['limit'])
119 107
             ->field('log.*,user.realname')
120 108
             ->order('log.update_time desc')
121 109
             ->select();
@@ -651,11 +639,8 @@ class LogLogic extends Common
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 645
     public function activityCount($param)
661 646
     {
@@ -665,17 +650,18 @@ class LogLogic extends Common
665 650
         if (empty($param['log_id'])) {
666 651
             $between_time = [$start_time['start_time'], $start_time['end_time']];
667 652
             $map['create_time'] = array('between', $between_time);
653
+            $map['create_user_id'] =$user_id;
668 654
         } else {
669
-
670 655
             $start_time = strtotime(date("Y-m-d", $item['create_time']));
671 656
             $end_time = strtotime(date("Y-m-d H:i:s", $item['create_time']));
672 657
             $between_time = [$start_time, $end_time];
673 658
             $map['create_time'] = array('between', $between_time);
659
+            $map['create_user_id'] =  $item['create_user_id'];
674 660
         }
675 661
         $map['status']=1;
676 662
         $typesList = ['1', '2', '3', '5', '6'];
677 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 665
                 if($v==1){
680 666
                     $arr[$k]['types'] ='crm_leads';
681 667
                     $arr[$k]['activity_type'] =1;
@@ -693,7 +679,6 @@ class LogLogic extends Common
693 679
                     $arr[$k]['activity_type'] =6;
694 680
                 }
695 681
                 $arr[$k]['dataCount'] = $activityData;
696
-
697 682
             }
698 683
             $data = $arr;
699 684
         return $data;

+ 39
- 41
application/oa/logic/TaskLogic.php Просмотреть файл

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

+ 33
- 27
application/oa/logic/UserLogic.php Просмотреть файл

@@ -27,42 +27,49 @@ class UserLogic
27 27
         $initials_type = ($param['initials'] == 1) ? 1 : 2;
28 28
         $where['user.status'] = 1;
29 29
         if ($search) {
30
-            $where = function ($query) use ($search) {
30
+            $whereMap = function ($query) use ($search) {
31 31
                 $query->where('user.realname', array('like', '%' . $search . '%'))
32 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 67
         } else {
61 68
             $list = Db::name('admin_user')
62 69
                 ->alias('user')
63 70
                 ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
64 71
                 ->where($where)
65
-                ->where('structure.id', $param['structure_id'])
72
+                ->where($whereMap)
66 73
                 ->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name')
67 74
                 ->page($param['page'], $param['limit'])
68 75
                 ->select();
@@ -70,7 +77,6 @@ class UserLogic
70 77
                 ->alias('user')
71 78
                 ->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
72 79
                 ->where($where)
73
-                ->where('structure.id', $param['structure_id'])
74 80
                 ->count();
75 81
             foreach ($list as $k => $v) {
76 82
                 $starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];

+ 120
- 118
application/oa/model/Event.php Просмотреть файл

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

+ 75
- 63
application/oa/model/Examine.php Просмотреть файл

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

+ 24
- 24
application/oa/model/Log.php Просмотреть файл

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

+ 2
- 2
application/work/controller/Task.php Просмотреть файл

@@ -333,8 +333,8 @@ class Task extends ApiCommon
333 333
         # 获取任务的项目信息
334 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 339
         $taskData['auth'] = !empty($taskData['work_id']) ? $this->getRuleList($workInfo['work_id'], $userId, $groupId) : [];
340 340
 

+ 3
- 0
application/work/controller/Tasklable.php Просмотреть файл

@@ -84,6 +84,9 @@ class Tasklable extends ApiCommon
84 84
             $str = ','.$userInfo['id'].',';
85 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 90
         $resData = $taskModel->getTaskList($param);
88 91
         $taskList = $resData['list'] ? : [];
89 92
         

+ 21
- 1
application/work/controller/Work.php Просмотреть файл

@@ -147,7 +147,7 @@ class work extends ApiCommon
147 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 151
         $groupId = !empty($workInfo['is_open']) ? $workInfo['group_id'] : 0;
152 152
 
153 153
         # 项目成员
@@ -632,5 +632,25 @@ class work extends ApiCommon
632 632
 
633 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 Просмотреть файл

@@ -14,40 +14,40 @@ use think\Db;
14 14
 class WorkLogic
15 15
 {
16 16
     use WorkAuthTrait;
17
-
17
+    
18 18
     public function index($param)
19 19
     {
20 20
         # 排序
21 21
         $orderField = 'work_id';
22
-        $orderSort  = 'asc';
22
+        $orderSort = 'asc';
23 23
         if (!empty($param['sort_type']) && $param['sort_type'] == 1) {
24 24
             $orderField = 'work_id';
25
-            $orderSort  = 'asc';
25
+            $orderSort = 'asc';
26 26
         }
27 27
         if (!empty($param['sort_type']) && $param['sort_type'] == 2) {
28 28
             $orderField = 'work_id';
29
-            $orderSort  = 'desc';
29
+            $orderSort = 'desc';
30 30
         }
31 31
         if (!empty($param['sort_type']) && $param['sort_type'] == 3) {
32 32
             $orderField = 'update_time';
33
-            $orderSort  = 'desc';
33
+            $orderSort = 'desc';
34 34
         }
35
-
35
+        
36 36
         # 搜索
37 37
         $searchWhere = '';
38
-        $dateWhere   = [];
39
-        $userWhere   = [];
38
+        $dateWhere = [];
39
+        $userWhere = [];
40 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 45
         unset($param['search']);
46 46
         unset($param['type']);
47 47
         unset($param['start_time']);
48 48
         unset($param['end_time']);
49 49
         unset($param['owner_user_id']);
50
-
50
+        
51 51
         switch ($type) {
52 52
             case 1 :
53 53
                 # 今天
@@ -69,46 +69,136 @@ class WorkLogic
69 69
                 $dateWhere['update_time'][] = ['egt', strtotime(date('Y-01-01 00:00:00', strtotime('last year')))];
70 70
                 $dateWhere['update_time'][] = ['elt', strtotime(date('Y-12-31 23:59:59', strtotime('last year')))];
71 71
         }
72
-
72
+        
73 73
         # 时间区间
74 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 78
         if ($search) $searchWhere = '(name like "%' . $search . '%") OR (description like "%' . $search . '%")';
79
-
79
+        
80 80
         # 成员
81 81
         if (!empty($ownerUserId)) {
82 82
             $userIds = Db::name('work_user')->whereIn('user_id', $ownerUserId)->column('work_id');
83 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 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 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 109
             $data[$key]['authList']['project'] = $this->getRuleList($value['work_id'], $param['user_id'], $value['group_id']);
110 110
         }
111
-
111
+        
112 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 Просмотреть файл

@@ -50,6 +50,7 @@ class Task extends Common
50 50
         $workModel = model('Work');
51 51
         $userModel = new \app\admin\model\User();
52 52
         $work_id = $request['work_id'];
53
+        $map=[];
53 54
         $ret = $workModel->checkWork($work_id, $user_id);
54 55
         if (!$ret) {
55 56
             $this->error = $workModel->getError();
@@ -68,11 +69,7 @@ class Task extends Common
68 69
         } else {
69 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 73
         if ($request['stop_time_type']) {
77 74
             if ($request['stop_time_type'] == '5') { //没有截至日期
78 75
                 $map['stop_time'] = '0';
@@ -104,6 +101,7 @@ class Task extends Common
104 101
                 $map['stop_time'] = ['between', [$timeAry[0], $timeAry[1]]];
105 102
             }
106 103
         }
104
+      
107 105
         if ($request['lable_id']) {
108 106
             $taskIds = [];
109 107
             $task_ids = [];
@@ -125,18 +123,20 @@ class Task extends Common
125 123
             }
126 124
             $map['task_id'] = ['in', $task_ids];
127 125
         }
126
+        
128 127
         $data = array();
129 128
         foreach ($newList as $key => $value) {
130 129
             $data[$key]['class_id'] = $value['class_id'] ?: -1;
131 130
             $data[$key]['class_name'] = $value['name'];
132
-
131
+           
133 132
             $map['status'] = $map['status'] ?: ['in', ['1', '5']];
133
+           
134 134
             $map['ishidden'] = 0;
135 135
             $map['work_id'] = $request['work_id'];
136 136
             $map['class_id'] = $value['class_id'];
137 137
             $map['pid'] = 0;
138 138
             $map['is_archive'] = 0;
139
-
139
+            $map['main_user_id']=$request['main_user_id'];
140 140
             $taskList = [];
141 141
             $resTaskList = $this->getTaskList($map);
142 142
             $data[$key]['count'] = $resTaskList['count'];
@@ -414,7 +414,7 @@ class Task extends Common
414 414
             unset($param[$value]);
415 415
         }
416 416
         $main_user_id = $param['main_user_id'] ?: $param['create_user_id'];
417
-
417
+        $param['owner_user_id'] = ','.$main_user_id.','; //参与人
418 418
         $param['main_user_id'] = $main_user_id; //负责人
419 419
         $param['start_time']   = !empty($param['start_time']) ? strtotime($param['start_time']) : 0;
420 420
         $param['stop_time']    = !empty($param['stop_time'])  ? strtotime($param['stop_time'])  : 0;
@@ -443,14 +443,14 @@ class Task extends Common
443 443
                 //操作日志
444 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,14 +642,14 @@ class Task extends Common
642 642
                 //设置负责人
643 643
                 $userdet = $userModel->getDataById($param['main_user_id']);
644 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 653
                 break;
654 654
         }
655 655
 
@@ -899,15 +899,17 @@ class Task extends Common
899 899
      */
900 900
     public function getTaskList($request)
901 901
     {
902
-        $search = $request['search'];
902
+       
903
+        $search = $request['search']?:'';
903 904
         $whereStr = $request['whereStr'] ?: [];
904 905
         $lable_id = $request['lable_id'] ?: '';
906
+        $main_user_id = $request['main_user_id'] ?: '';
905 907
         $taskSearch = !empty($request['taskSearch']) ? $request['taskSearch'] : '';
906 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 913
         $request = $this->fmtRequest($request);
912 914
         $requestMap = $request['map'] ?: [];
913 915
         $userModel = new \app\admin\model\User();
@@ -924,6 +926,13 @@ class Task extends Common
924 926
         }
925 927
         $dataCount = db('task')->alias('task')->where($map)->where($whereStr)->where($taskSearch)->count();
926 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 936
         if ($dataCount) {
928 937
             $taskList = db('task')
929 938
                 ->alias('task')
@@ -932,6 +941,7 @@ class Task extends Common
932 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 942
                 ->where($map)
934 943
                 ->where($whereStr)
944
+                ->where($logWhere)
935 945
                 ->where($taskSearch)
936 946
                 ->order('task.status asc,task.order_id asc')
937 947
                 ->select();
@@ -1036,7 +1046,6 @@ class Task extends Common
1036 1046
                 ->where($labelWhere)
1037 1047
                 ->order($order)
1038 1048
                 ->select();
1039
-
1040 1049
             foreach ($taskList as $key => $value) {
1041 1050
                 if ($value['pid'] > 0) {
1042 1051
                     $p_det = $this->field('task_id,name')->where(['task_id' => $value['pid']])->find();
@@ -1084,35 +1093,38 @@ class Task extends Common
1084 1093
 
1085 1094
         # 今天
1086 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 1100
         if ($type == 2) {
1092 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 1107
         if ($type == 3) {
1098 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 1114
         if ($type == 4) {
1115
+            $timestamp = mktime(0, 0, 0, date('m'), 1, date('Y'));
1104 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 1121
         if ($type == 5) {
1110
-            $result = $result = '(task.stop_time = 0)';;
1122
+            $result = '(task.stop_time = 0)';;
1111 1123
         }
1112 1124
 
1113 1125
         # 已延期
1114 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 Просмотреть файл

@@ -75,6 +75,7 @@ class Work extends Common
75 75
 			$ownerData['work_id']        = $workId;
76 76
 			$ownerData['create_user_id'] = $createUserId;
77 77
 			$ownerData['owner_user_id']  = $ownerUserId;
78
+			$ownerData['group_id']       = !empty($param['group_id']) ? $param['group_id'] : 0;
78 79
             # 创建项目下的相关成员
79 80
 			$this->addOwner($ownerData);
80 81
 
@@ -129,6 +130,10 @@ class Work extends Common
129 130
             $ownerData['is_open']        = $param['is_open'];
130 131
             $ownerData['group_id']       = $param['group_id'];
131 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 138
 		$resUpdata = $this->where($map)->update($param);
134 139
 		if ($resUpdata) {
@@ -307,7 +312,7 @@ class Work extends Common
307 312
 				$group_id = 1;
308 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 317
 			$data['group_id'] = $group_id;
313 318
 			$saveData[] = $data;

+ 4
- 1
config/config.php Просмотреть файл

@@ -265,5 +265,8 @@ return [
265 265
     // 商业智能查询缓存时间(秒)
266 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 Просмотреть файл

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

+ 2
- 0
config/route_crm.php Просмотреть файл

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

+ 2
- 2
config/version.php Просмотреть файл

@@ -1,5 +1,5 @@
1 1
 <?php
2 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 Просмотреть файл

@@ -1708,10 +1708,10 @@ INSERT INTO `5kcrm_admin_scene` (`types`, `name`, `user_id`, `order_id`, `data`,
1708 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 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 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 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 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 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 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 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,7 +1751,7 @@ DROP TABLE IF EXISTS `5kcrm_crm_visit`;
1751 1751
 CREATE TABLE `5kcrm_crm_visit` (
1752 1752
   `visit_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '回访id',
1753 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 1755
   `create_user_id` int(11) NOT NULL COMMENT '创建人id',
1756 1756
   `customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户名称',
1757 1757
   `contract_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '合同编号',
@@ -1840,12 +1840,12 @@ ALTER TABLE `5kcrm_oa_examine` ADD COLUMN `last_user_id` varchar(200) not null d
1840 1840
 ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0  comment '1表示已读 0表示未读';
1841 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 1850
 INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
1851 1851
 INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
@@ -1955,7 +1955,7 @@ CREATE TABLE `5kcrm_crm_receivables_file` (
1955 1955
   `receivables_id` int(10) unsigned NOT NULL,
1956 1956
   `file_id` int(10) unsigned NOT NULL,
1957 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 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 1961
 INSERT INTO `5kcrm_crm_config` (`name`, `value`, `description`) VALUES ('visit_config', '1', '是否开启回访提醒:1开启;0不开启');

+ 2
- 2
public/sql/install.sql Просмотреть файл

@@ -1,3 +1,3 @@
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 Просмотреть файл

@@ -380,13 +380,6 @@ ALTER TABLE `5kcrm_oa_examine` ADD COLUMN `last_user_id` varchar(200) not null d
380 380
 ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0  comment '1表示已读 0表示未读';
381 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 383
 INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
391 384
 INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
392 385
 INSERT INTO `5kcrm_admin_rule` VALUES ('156', '0', '设置欢迎语', 'setWelcome', '3', '154', '0');

+ 2
- 0
public/sql/update_sql_20210227.sql Просмотреть файл

@@ -0,0 +1,2 @@
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';

Двоичные данные
public/static/icon/success_gray.png Просмотреть файл


Двоичные данные
public/static/img/bg.png Просмотреть файл


+ 37
- 32
public/static/js/step2.js Просмотреть файл

@@ -45,7 +45,12 @@ var rules = {
45 45
     required: true,
46 46
     regexp: /^(?=.*[a-zA-Z])(?=.*\d).{6,20}$/,
47 47
     label: '管理员密码(6~20位字母加数字组合)'
48
-  }
48
+  },
49
+  wkcode: {
50
+    required: false,
51
+    regexp: null,
52
+    label: '序列号'
53
+  },  
49 54
 };
50 55
 
51 56
 var timer = null;
@@ -63,32 +68,36 @@ $('.next').click(function () {
63 68
   // 校验form数据 true 校验通过  false 校验失败
64 69
   var forms = getFormData();
65 70
   var result = checkForm();
66
-  console.log('result---', result, forms);
71
+  // console.log('result---', result, forms);
67 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,7 +177,7 @@ function _initFormValue() {
168 177
  * @return {form}
169 178
  */
170 179
 function getFormData() {
171
-  $('input').each(function (index, item) {
180
+  $('.wkform').each(function (index, item) {
172 181
     form[item.name] = item.value;
173 182
     // 重置表单状态
174 183
     $(item).removeClass('input-error');
@@ -186,6 +195,7 @@ function getFormData() {
186 195
  * @return {boolean}
187 196
  */
188 197
 function checkForm() {
198
+
189 199
   var result = {};
190 200
   for (var key in rules) {
191 201
     var rule = rules[key];
@@ -228,9 +238,4 @@ function renderErrorMsg(key, msg) {
228 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 Просмотреть файл

@@ -10,6 +10,11 @@ html, body {
10 10
   background-color: #f2f2f2;
11 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 19
 li {
15 20
   list-style: none;
@@ -72,7 +77,10 @@ li {
72 77
 .top {
73 78
   width: 790px;
74 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 86
 /* container */
@@ -81,6 +89,7 @@ li {
81 89
   min-height: 493px;
82 90
   background-color: white;
83 91
   border: 1px solid #e1e1e1;
92
+  border-radius:5px;
84 93
   margin: 0 auto;
85 94
 }
86 95
 
@@ -93,7 +102,7 @@ li {
93 102
   width: 820px;
94 103
   text-align: center;
95 104
   font-size: 15px;
96
-  color: #8c8c8c;
105
+  color: #fff;
97 106
   line-height: 30px;
98 107
   margin: 0 auto;
99 108
   padding: 30px 0;
@@ -112,6 +121,9 @@ li {
112 121
   text-align: center;
113 122
   margin: 20px 0;
114 123
   float: left;
124
+  display: flex;
125
+  align-items: center;
126
+  justify-content: center;
115 127
 }
116 128
 .step.line {
117 129
   width: 10%;
@@ -122,12 +134,12 @@ li {
122 134
 .step .sort {
123 135
   width: 25px;
124 136
   height: 25px;
125
-  color: white;
137
+  color: #8c8c8c;
126 138
   line-height: 25px;
127 139
   text-align: center;
128 140
   font-size: 14px;
129 141
   border-radius: 50%;
130
-  background-color: #d1d1d1;
142
+  /* background-color: #d1d1d1; */
131 143
   margin-right: 5px;
132 144
   display: inline-block;
133 145
 }
@@ -139,13 +151,13 @@ li {
139 151
 }
140 152
 
141 153
 .step.active .sort {
142
-  background-color: #3e84e9;
154
+  background-color: #fff;
143 155
 }
144 156
 .step.active .desc {
145
-  color: #3e84e9;
157
+  color: black;
146 158
 }
147 159
 .step.active.line {
148
-  background-color: #3e84e9;
160
+  /* background-color: #fff; */
149 161
 }
150 162
 
151 163
 
@@ -156,7 +168,7 @@ li {
156 168
   line-height: 40px;
157 169
   font-size: 16px;
158 170
   color: #3e84e9;
159
-  border-radius: 40px;
171
+  border-radius: 5px;
160 172
   background-color: white;
161 173
   border: 1px solid #3e84e9;
162 174
   display: inline-block;
@@ -172,16 +184,44 @@ li {
172 184
   width: 100%;
173 185
   height: 54px;
174 186
   line-height: 54px;
175
-  background-color: #f7f7f7;
187
+  /* background-color: #f7f7f7; */
176 188
   padding: 0 26px;
177
-  border-bottom: 1px solid #e1e1e1;
189
+  /* border-bottom: 1px solid #e1e1e1; */
190
+  font-weight: 600;
178 191
 }
179 192
 .base-top .title {
180
-  color: #8c8c8c;
193
+  /* color: #8c8c8c; */
181 194
   font-size: 16px;
182 195
 }
183 196
 .base-top .version {
184 197
   font-size: 13px;
185
-  color: #d1d1d1;
198
+  color: #8c8c8c;
186 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 Просмотреть файл

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

+ 52
- 0
public/static/style/loading.css Просмотреть файл

@@ -0,0 +1,52 @@
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 Просмотреть файл

@@ -15,14 +15,18 @@
15 15
 table {
16 16
   width: 100%;
17 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 24
 .table tr {
21 25
   height: 34px;
22 26
   text-align: center;
23 27
 }
24 28
 th, td {
25
-  border: 1px solid #e1e1e1;
29
+  border-bottom: 1px solid #f7f7f7;
26 30
   width: 30%;
27 31
 }
28 32
 th:first-child, td:first-child, th:last-child, td:last-child {
@@ -31,8 +35,9 @@ th:first-child, td:first-child, th:last-child, td:last-child {
31 35
 
32 36
 th {
33 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 Просмотреть файл

@@ -28,13 +28,15 @@
28 28
   float: left;
29 29
 }
30 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 34
   border: 1px solid #d7d7d7;
35 35
   padding: 0 10px;
36
-  margin-right: 20px;
36
+  /* margin-right: 20px; */
37 37
   float: left;
38
+  border-radius: 5px;
39
+  color: #8c8c8c;
38 40
 }
39 41
 .content .form .form-item input:focus {
40 42
   border-color: transparent !important;
@@ -51,13 +53,17 @@
51 53
   float: left;
52 54
 }
53 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 61
   color: #777;
57
-  background-color: #ecf8ff;
58
-  padding: 0 16px;
62
+  background-color: #fff6e7;
63
+  padding: 0 12px;
59 64
   border-radius: 3px;
60 65
   float: left;
66
+  border:1px solid #d7d7d7;
61 67
 }
62 68
 
63 69
 .install_progress_a {
@@ -69,5 +75,20 @@
69 75
   text-align: center;
70 76
   padding: 20px 0;
71 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 Просмотреть файл

@@ -0,0 +1,2 @@
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';