Explorar el Código

调整移交客户功能,调整上传功能

yb hace 6 meses
padre
commit
e258f24c27
Se han modificado 2 ficheros con 65 adiciones y 20 borrados
  1. 47 7
      app/admin/service/consultant/CustomService.php
  2. 18 13
      app/common/storage/LocalAdapter.php

+ 47 - 7
app/admin/service/consultant/CustomService.php

@@ -18,7 +18,7 @@ use Tinywan\Jwt\JwtToken;
 
 class CustomService
 {
-    const DIFF_TIME = (60 * 60 * 24 * 30);
+    const DIFF_TIME = (60 * 60 * 24 * 30); //调入团队公池 x4 = 调入集团公池
     /**
      * Notes: 返回选项配置信息
      * User: yb
@@ -222,10 +222,35 @@ class CustomService
                         ->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2)");
                 }];
             } else {
-                //已经流入公池
-                $where[] = [function($query) use ($diffNums, $currentTime){
-                    $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
-                }];
+                if (true === $deptIds) {
+                    if (!empty($params['pub_status'])) {
+                        if ($params['pub_status'] == 2) {
+                            //仅检索团队公池
+                            $where[] = [function($query) use ($diffNums, $currentTime){
+                                $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
+                            }];
+                        } else {
+                            //仅检索集团公池
+                            $where[] = [function($query) use ($diffNums, $currentTime){
+                                $query->orWhereRaw("((visit_time + ({$diffNums} * 4)) - {$currentTime} <= 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
+                            }];
+                        }
+                    } else {
+                        //超管权限
+                        $where[] = [function($query) use ($diffNums, $currentTime){
+                            $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
+                        }];
+                    }
+
+                } else if (is_array($deptIds)) {
+                    //团队权限
+                    $where[] = [function($query) use ($diffNums, $currentTime){
+                        $query->orWhereRaw("((visit_time + {$diffNums}) - {$currentTime} <= 0 AND (visit_time + ({$diffNums} * 4)) - {$currentTime} > 0 AND current_status = 2 AND check_status = 2 AND belong_status = 1)")->whereOr('belong_status','<>', 1);
+                    }];
+                } else {
+                    //无权限
+                }
+
             }
         }
 
@@ -289,6 +314,15 @@ class CustomService
                 $visitTime = $item->visit_time;
                 $visitTimeStamp = strtotime($visitTime);
                 $diff = ($visitTimeStamp + $diffNums) - $currentTime;
+                if ($diff > 0) {
+                    $item->belong_status = 1;
+                } else {
+                    if (abs($diff) - (4*$diffNums) > 0) {
+                        $item->belong_status = 3;
+                    } else {
+                        $item->belong_status = 2;
+                    }
+                }
                 $item->diff_nums =  ($diff > 0) ? $diff : 0;
                 $item->consultant_name = $consultantKeys[$item->consultant_id]['name'] ?? '';
                 $item->consultant_mobile = $consultantKeys[$item->consultant_id]['mobile'] ?? '';
@@ -606,7 +640,7 @@ class CustomService
                 $query->whereIn('consultant_id', $consultantIds);
             }];
         }
-        $customList = MarketCustomer::where($whereCustom)->select(['id','consultant_id','dept_id'])->get();
+        $customList = MarketCustomer::where($whereCustom)->select(['id','consultant_id','dept_id','visit_time'])->get();
         if (!$customList->isEmpty()) {
             foreach ($customList as$item) {
                 $logsInertData[] = [
@@ -627,13 +661,19 @@ class CustomService
         if (empty($logsInertData)) {
             return json_fail('移交记录不能为空');
         }
+        $diffTime = self::DIFF_TIME;
         Db::beginTransaction();
         $result = false;
         try {
             foreach ($customList as $item) {
                 if ($currentConsultantId != 0) {
                     //移交至指定顾问
-                    $item->visit_time = time();
+                    //判断一下是否到了到访的过期时间,如果过期了就更新到访时间,没过期时间就不变
+                    $visitTime = $item->visit_time;
+                    $diff = strtotime($visitTime) + $diffTime - time();
+                    if ($diff <= 0) {
+                        $item->visit_time = time();
+                    }
                 } else {
                     //移交至其他团队
                     $item->visit_time = time() - self::DIFF_TIME;

+ 18 - 13
app/common/storage/LocalAdapter.php

@@ -32,14 +32,18 @@ class LocalAdapter extends AdapterAbstract
         }
 
         $baseUrl = $this->config['domain'] . $this->config['uri'] . str_replace(DIRECTORY_SEPARATOR, '/', $this->config['dirname']) . DIRECTORY_SEPARATOR;
+        $imageType = ['jpeg', 'jpg', 'png', 'gif'];
         foreach ($this->files as $key => $file) {
-            // 缩略
-            $image = Image::make($file);
-
+            //读取文件后缀
+            $extension = strtolower($file->getUploadExtension());
+            if (in_array($extension, $imageType)) {
+                // 缩略
+                $image = Image::make($file);
+            }
             $uniqueId = hash_file($this->algo, $file->getPathname());
             $saveFilename = $uniqueId . '.' . $file->getUploadExtension();
             $originSavePath = $basePath . $saveFilename;
-            $thumbSavePath = $basePath . 'thumb' . DIRECTORY_SEPARATOR . $saveFilename;
+            $thumbSavePath = in_array($extension, $imageType) ? ($basePath . 'thumb' . DIRECTORY_SEPARATOR . $saveFilename) : ($basePath . DIRECTORY_SEPARATOR . $saveFilename);
             $temp = [
                 'key' => $key,
                 'origin_name' => $file->getUploadName(),
@@ -53,15 +57,16 @@ class LocalAdapter extends AdapterAbstract
             ];
             // 保存原图
             $file->move($originSavePath);
-            // 保存缩略图
-            $imgWidth = $image->width();
-            $imgHeight = $image->height();
-            $rate = round($imgWidth / 200, 2);
-            $height = intval($imgHeight / $rate);
-            $image = $image->resize(200, $height);
-            $encoded = $image->encode('jpg');
-            $encoded->save($thumbSavePath);
-
+            if (in_array($extension, $imageType)) {
+                // 保存缩略图
+                $imgWidth = $image->width();
+                $imgHeight = $image->height();
+                $rate = round($imgWidth / 200, 2);
+                $height = intval($imgHeight / $rate);
+                $image = $image->resize(200, $height);
+                $encoded = $image->encode('jpg');
+                $encoded->save($thumbSavePath);
+            }
 //            $file->move($savePath);
             array_push($result, $temp);
         }