Selaa lähdekoodia

适配旧数据

sugangqiang 2 vuotta sitten
vanhempi
commit
8bd34f40dd
2 muutettua tiedostoa jossa 158 lisäystä ja 21 poistoa
  1. 12 2
      app/admin/controller/EnterpriseChangeRecord.php
  2. 146 19
      app/enterprise/controller/Api.php

+ 12 - 2
app/admin/controller/EnterpriseChangeRecord.php

@@ -15,6 +15,8 @@ use app\common\model\TalentCommonFile;
 
 class EnterpriseChangeRecord extends AdminController {
 
+    private $compatible_time = "2022-10-15 23:59:59";
+
     public function gotoEnterpriseChangeRecordPage() {
         $talentTypeList = DictApi::findChildDictByCode("enterprise_tag");
         $industryFieldNewList = DictApi::findChildDictByCode("industry_field");
@@ -81,7 +83,7 @@ class EnterpriseChangeRecord extends AdminController {
           $v['url'] = getStoragePath($v['url']);
           $_files[$v["api"]][] = $v;
           } */
-        $time = "2022-10-14 23:59:59";
+        $time = $this->compatible_time;
         //营业执照
         if (!$ecr["oldImgurl"]) {
             $ecr["oldImgurl"] = $ep["imgurl"];
@@ -102,6 +104,8 @@ class EnterpriseChangeRecord extends AdminController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newImgurl"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newImgurl"] = $ep["imgurl"];
                 }
             }
         }
@@ -131,6 +135,8 @@ class EnterpriseChangeRecord extends AdminController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newBeian"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newBeian"] = $ep["beian"];
                 }
             }
         }
@@ -160,6 +166,8 @@ class EnterpriseChangeRecord extends AdminController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newDomainImg"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newDomainImg"] = $ep["domainImg"];
                 }
             }
         }
@@ -189,6 +197,8 @@ class EnterpriseChangeRecord extends AdminController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newBankImg"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newBankImg"] = $ep["bankImg"];
                 }
             }
         }
@@ -309,7 +319,7 @@ class EnterpriseChangeRecord extends AdminController {
                 if ($modify_files[$_file]) {
                     $modify_files[$_file]["checked"] = true;
                 } else {
-                    if (strtotime($ecr["createTime"]) < strtotime("2022-10-14 23:59:59")) {
+                    if (strtotime($ecr["createTime"]) < strtotime($this->compatible_time)) {
                         //兼容旧的typeid
                         $_file = $oldtypes[$_file];
                     }

+ 146 - 19
app/enterprise/controller/Api.php

@@ -16,6 +16,8 @@ use app\common\api\UploadApi;
 
 class Api extends EnterpriseController {
 
+    private $compatible_time = "2022-10-15 23:59:59";
+
     public function findEnterpriseChangeByPage() {
         $order = trim($this->request->param("order")) ?: "desc";
         $offset = trim($this->request->param("offset")) ?: 0;
@@ -336,15 +338,67 @@ class Api extends EnterpriseController {
                         $record[$fields[$i]] = $data[$key]; //仅可修改选择的字段
                     }
                 }
-                $record["newImgurl"] = $record["newImgurl"] ?: $ep["imgurl"];
-                $record["newBankImg"] = $record["newBankImg"] ?: $ep["bankImg"];
-                $record["newDomainImg"] = $record["newDomainImg"] ?: $ep["domainImg"];
-                $record["newBeian"] = $record["newBeian"] ?: $ep["beian"];
+                if (!$record["newImgurl"]) {
+                    if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                        $where = [];
+                        $where[] = ["mainId", "=", $id];
+                        $where[] = ["api", "=", "businessLicense"];
+                        $where[] = ["active", "=", 1];
+                        $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                        if ($_uploadFile) {
+                            $ecr["newImgurl"] = $_uploadFile["url"];
+                        } else {
+                            $ecr["newImgurl"] = $ep["imgurl"];
+                        }
+                    }
+                }
+                if (!$record["newBankImg"]) {
+                    if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                        $where = [];
+                        $where[] = ["mainId", "=", $id];
+                        $where[] = ["api", "=", "businessBank"];
+                        $where[] = ["active", "=", 1];
+                        $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                        if ($_uploadFile) {
+                            $ecr["newBankImg"] = $_uploadFile["url"];
+                        } else {
+                            $ecr["newBankImg"] = $ep["bankImg"];
+                        }
+                    }
+                }
+                if (!$record["newDomainImg"]) {
+                    if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                        $where = [];
+                        $where[] = ["mainId", "=", $id];
+                        $where[] = ["api", "=", "businessDomain"];
+                        $where[] = ["active", "=", 1];
+                        $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                        if ($_uploadFile) {
+                            $ecr["newDomainImg"] = $_uploadFile["url"];
+                        } else {
+                            $ecr["newDomainImg"] = $ep["domainImg"];
+                        }
+                    }
+                }
+                if (!$record["newBeian"]) {
+                    if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                        $where = [];
+                        $where[] = ["mainId", "=", $id];
+                        $where[] = ["api", "=", "businessBeian"];
+                        $where[] = ["active", "=", 1];
+                        $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                        if ($_uploadFile) {
+                            $ecr["newBeian"] = $_uploadFile["url"];
+                        } else {
+                            $ecr["newBeian"] = $ep["beian"];
+                        }
+                    }
+                }
                 $files = $this->request->file();
                 if ($files) {
                     $uploadapi = new UploadApi();
                     $modify_files = array_filter(explode(",", $record->modify_files));
-                    if (strtotime($record->createTime) < strtotime("2022-10-14 23:59:59")) {
+                    if (strtotime($record->createTime) < strtotime($this->compatible_time)) {
                         //旧typeid需要转换成新的禁用文件格式
                         $oldtypes = ["1161965644164075522" => "newImgurl", "1518753449987148467" => "newImgurl", "1518328155588131269" => "newBankImg", "1518926324960220206" => "newBankImg",
                             "1518941016720463523" => "newDomainImg", "1519109971871948101" => "newBeian", "1519185486755815382" => "newBeian"];
@@ -449,7 +503,8 @@ class Api extends EnterpriseController {
         $ecr = EnterpriseRecord::findOrEmpty($id);
         $ep = Enterprise::where('id', $ecr->mainId)->find();
         $ecr["special"] = $ep["special"];
-        if (strtotime($ecr["createTime"]) < strtotime("2022-10-14 23:59:59")) {
+        $time = $this->compatible_time;
+        if (strtotime($ecr["createTime"]) < strtotime($time)) {
             $_files = explode(",", $ecr["modify_files"]);
             $_new_files = [];
             foreach ($_files as $_file) {
@@ -476,28 +531,92 @@ class Api extends EnterpriseController {
             }
             $ecr["modify_files"] = implode(",", $_new_files);
         }
+        //营业执照
+        if (!$ecr["newImgurl"]) {
+            //兼容旧filetype
+            if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                $where = [];
+                $where[] = ["mainId", "=", $id];
+                $where[] = ["api", "=", "businessLicense"];
+                $where[] = ["active", "=", 1];
+                $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                if ($_uploadFile) {
+                    $ecr["newImgurl"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newImgurl"] = $ep["imgurl"];
+                }
+            }
+        }
         if ($ecr["newImgurl"]) {
-            $extension = pathinfo($ecr["newImgurl"])["extension"];
-            if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
+            $pathinfo = pathinfo($ecr["newImgurl"]);
+            if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
                 $ecr["imgurl_is_img"] = 1;
             }
         }
-        if ($ecr["newBankImg"]) {
-            $extension = pathinfo($ecr["newBankImg"])["extension"];
-            if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
-                $ecr["bankImg_is_img"] = 1;
+        //备案表
+        if (!$ecr["newBeian"]) {
+            //兼容旧filetype
+            if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                $where = [];
+                $where[] = ["mainId", "=", $id];
+                $where[] = ["api", "=", "businessBeian"];
+                $where[] = ["active", "=", 1];
+                $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                if ($_uploadFile) {
+                    $ecr["newBeian"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newBeian"] = $ep["beian"];
+                }
+            }
+        }
+        if ($ecr["newBeian"]) {
+            $pathinfo = pathinfo($ecr["newBeian"]);
+            if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
+                $ecr["beian_is_img"] = 1;
+            }
+        }
+        //行业领域
+        if (!$ecr["newDomainImg"]) {
+            //兼容旧filetype
+            if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                $where = [];
+                $where[] = ["mainId", "=", $id];
+                $where[] = ["api", "=", "businessDomain"];
+                $where[] = ["active", "=", 1];
+                $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                if ($_uploadFile) {
+                    $ecr["newDomainImg"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newDomainImg"] = $ep["domainImg"];
+                }
             }
         }
         if ($ecr["newDomainImg"]) {
-            $extension = pathinfo($ecr["newDomainImg"])["extension"];
-            if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
+            $pathinfo = pathinfo($ecr["newDomainImg"]);
+            if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
                 $ecr["domainImg_is_img"] = 1;
             }
         }
-        if ($ecr["newBeian"]) {
-            $extension = pathinfo($ecr["newBeian"])["extension"];
-            if (in_array($extension, ["jpeg", "jpg", "png", "gif"])) {
-                $ecr["beian_is_img"] = 1;
+        //开户许可证
+        if (!$ecr["newBankImg"]) {
+            //兼容旧filetype
+            if (strtotime($ecr["createTime"]) < strtotime($time)) {
+                $where = [];
+                $where[] = ["mainId", "=", $id];
+                $where[] = ["api", "=", "businessBank"];
+                $where[] = ["active", "=", 1];
+                $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
+                if ($_uploadFile) {
+                    $ecr["newBankImg"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newBankImg"] = $ep["bankImg"];
+                }
+            }
+        }
+        if ($ecr["newBankImg"]) {
+            $pathinfo = pathinfo($ecr["newBankImg"]);
+            if (in_array($pathinfo["extension"], ["jpeg", "jpg", "png", "gif"])) {
+                $ecr["bankImg_is_img"] = 1;
             }
         }
         switch ($ep->special) {
@@ -600,7 +719,7 @@ class Api extends EnterpriseController {
         $ecr['oldStreetName'] = $streetList[$ecr['oldStreet']];
         $ecr['newStreetName'] = $streetList[$ecr['newStreet']];
         //20220918增加根据不同的企业类型显示不同的信息变更界面
-        $time = "2022-10-14 23:59:59";
+        $time = $this->compatible_time;
         //营业执照
         if (!$ecr["oldImgurl"]) {
             $ecr["oldImgurl"] = $ep["imgurl"];
@@ -621,6 +740,8 @@ class Api extends EnterpriseController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newImgurl"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newImgurl"] = $ep["imgurl"];
                 }
             }
         }
@@ -650,6 +771,8 @@ class Api extends EnterpriseController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newBeian"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newBeian"] = $ep["beian"];
                 }
             }
         }
@@ -679,6 +802,8 @@ class Api extends EnterpriseController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newDomainImg"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newDomainImg"] = $ep["domainImg"];
                 }
             }
         }
@@ -708,6 +833,8 @@ class Api extends EnterpriseController {
                 $_uploadFile = TalentCommonFile::alias("tcf")->leftJoin("new_currency_filetype ft", "ft.id=tcf.typeId")->where($where)->order("tcf.createTime desc")->find();
                 if ($_uploadFile) {
                     $ecr["newBankImg"] = $_uploadFile["url"];
+                } else {
+                    $ecr["newBankImg"] = $ep["bankImg"];
                 }
             }
         }