panghu vor 1 Jahr
Ursprung
Commit
df657c4cba

+ 88 - 0
app/Http/Controllers/AdminApi/FirmController.php

@@ -0,0 +1,88 @@
+<?php
+
+namespace App\Http\Controllers\AdminApi;
+
+use App\Http\Controllers\AdminController;
+use App\Models\Firm;
+use App\Servers\ESign\ESignFirmServer;
+use App\Servers\System\CommonServer;
+
+class FirmController extends AdminController
+{
+    /**
+     * 获取机构列表
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getFirmList(){
+
+        $where = [['is_del',0]];
+
+        $list = Firm::where($where)
+            ->select(['id','firm_name','license_number','legal_name','orgId','realnameStatus','authorizeUserInfo','created_at'])
+            ->paginate(10);
+        return $this->apiResponseSuccess('获取列表成功', [
+            'items' => $list->items(),
+            'total' => $list->total(),
+            'limit' => 10,
+        ]);
+    }
+
+    /**
+     * 添加&编辑用户
+     * @return \Illuminate\Http\JsonResponse
+     * @throws \Throwable
+     */
+    function saveFirm(){
+
+        $id=request()->input('id','');//id
+        $firm_name=request()->input('firm_name','');//姓名
+        $phone=request()->input('phone','');//电话
+        $license_number=request()->input('license_number','');//统一社会信用代码
+        $license_img=request()->input('license_img','');//营业执照
+        $registered_address=request()->input('registered_address','');//注册地址
+        $legal_identity_one=request()->input('legal_identity_one','');//法人身份证正明
+        $legal_identity_two=request()->input('legal_identity_two','');//法人身份证背面
+        $legal_id_number=request()->input('legal_id_number','');//身份证号
+
+        if (empty($firm_name)) return $this->apiResponseError('请填写姓名');
+        if (mb_strlen($firm_name) > 100) return $this->apiResponseError('姓名最大100');
+        if (empty($phone)) return $this->apiResponseError('请填写手机号');
+        if (!CommonServer::creatServer()->verifyPhoneNumber($phone)) return $this->apiResponseError('手机号错误');
+        if (empty($license_number)) return $this->apiResponseError('请填写统一社会信用代码');
+        if (empty($license_img)) return $this->apiResponseError('请上传营业执照');
+        if (empty($registered_address)) return $this->apiResponseError('注册地址不能为空');
+        if (empty($legal_identity_one)) return $this->apiResponseError('请传身份证正面');
+        if (empty($legal_identity_two)) return $this->apiResponseError('请传身份证反面');
+        if (empty($legal_id_number)) return $this->apiResponseError('请填身份证号码');
+
+        //检查该统一社会信用代码是否存在
+        $firm = Firm::where('license_number',$license_number)->where('is_del',0)->select(['id'])->first();
+        if (!empty($firm)){
+            return $this->apiResponseError('统一社会信用代码已存在');
+        }
+        $authType = 'ORG';
+        $data = compact('firm_name','phone','license_number','license_img','registered_address','authType','legal_identity_one','legal_identity_two','legal_id_number');
+
+        if(empty($id)){//不存在id就创建
+
+            $res = Firm::create($data);
+        }else{//存在就更新
+            $info = Firm::where('id',$id)->select(['id'])->first();
+            if (empty($info)) {
+                return $this->apiResponseError('没有找到该记录');
+            }
+            $res = $info->update($data);
+        }
+        $firm_id = $res->{'id'};
+        //查询个人认证信息
+        ESignFirmServer::creatServer()->organizationsIdentityInfo($firm_id,$firm_name);
+
+
+        if ($res) {
+            return $this->apiResponseSuccess('操作成功');
+        } else {
+            return $this->apiResponseError('操作失败');
+        }
+    }
+
+}

+ 1 - 0
app/Http/Controllers/AdminApi/NotifyController.php

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\AdminApi;
 
 
 use App\Http\Controllers\ApiController;
+use App\Models\Firm;
 use App\Models\Member;
 use App\Servers\ESign\comm\EsignLogHelper;
 

+ 30 - 0
app/Models/Firm.php

@@ -0,0 +1,30 @@
+<?php
+
+namespace App\Models;
+
+use DateTimeInterface;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * App\Models
+ *
+ * @mixin \Eloquent
+ */
+class Firm extends Model
+{
+    use HasFactory;
+    protected $guarded = ['id', 'updated_at', 'created_at'];
+
+
+    /**
+     * 为数组 / JSON 序列化准备日期。
+     *
+     * @param \DateTimeInterface $date
+     * @return string
+     */
+    protected function serializeDate(DateTimeInterface $date)
+    {
+        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
+    }
+}

+ 27 - 64
app/Servers/ESign/ESignFirmServer.php

@@ -75,42 +75,12 @@ class ESignFirmServer
      * @param $orgName
      * @return mixed
      */
-    function organizationsIdentityInfo($m_id,$firm_id,$orgName){
-        $info =  SignMember::where('firm_id',$firm_id)->where('authType','ORG')->first();
-        if (empty($info)){
-            //入库
-            $info= SignMember::create([
-                'm_id' => $m_id,
-                'firm_id' => $firm_id,
-                'firm_name' => $orgName,
-                'phone' => '',
-                'id_number' => '',
-                'realnameStatus'=>0,
-                'authorizeUserInfo'=>0,
-                'psnId'=>'',
-                'orgId'=>'',
-                'authShortUrl'=>'',
-                'authType' => 'ORG',
-            ]);
-        }else{
-            if($info->{'realnameStatus'}==1 && $info->{'orgId'}!=''){
-                FirmServer::creatServer()->updateFirmStatus($firm_id);
-                $signFirm=SignFirm::where('firm_id',$firm_id)->first();
-                if(empty($signFirm)){
-                    SignFirm::create([
-                       'firm_id' => $firm_id,
-                       'org_id' => $info->{'orgId'},
-                        'realname_status'=>1
-                    ]);
-                }else{
-                    $signFirm->update([
-                        'org_id' => $info->{'orgId'},
-                        'realname_status'=>1
-                    ]);
-                }
-                return $info;
-            }
+    function organizationsIdentityInfo($firm_id,$orgName){
+        $info =  Firm::where('id',$firm_id)->where('authType','ORG')->first();
+        if($info->{'realnameStatus'}==1 && $info->{'orgId'}!=''){
+            return $info;
         }
+
         $config=$this->config;
         $firm=Firm::where('id',$firm_id)->select(['id','license_number','firm_name'])->first();
         $apiaddr="/v3/organizations/identity-info?orgIDCardNum=".$firm['license_number'].'&orgIDCardType=CRED_ORG_USCC';
@@ -130,21 +100,18 @@ class ESignFirmServer
             //个人账号ID
             $orgId = $ret['data']['orgId'];
             //更新认证信息
-            SignMember::where('m_id',$m_id)->where('firm_id',$firm_id)->where('authType','ORG')->update([
+            Firm::where('id',$firm_id)->where('authType','ORG')->update([
                 'realnameStatus'=>$realnameStatus,
                 'authorizeUserInfo'=>$authorizeUserInfo,
                 'orgId'=>$orgId,
             ]);
 
-            if ($realnameStatus == 1){//更新企业认证状态
-                FirmServer::creatServer()->updateFirmStatus($firm_id);
-            }
             if (empty($realnameStatus) || empty($authorizeUserInfo)){//走认证授权流程
-                $this->orgAuthUrl($m_id,$firm_id,$orgName);
+                $this->orgAuthUrl($firm_id,$orgName);
             }
         }else{
             //走认证授权流程
-            $this->orgAuthUrl($m_id,$firm_id,$orgName);
+            $this->orgAuthUrl($firm_id,$orgName);
         }
 
         return $info;
@@ -154,7 +121,7 @@ class ESignFirmServer
      * 企业实名
      * @param $orgName
      */
-    function orgAuthUrl($m_id,$firm_id,$orgName){
+    function orgAuthUrl($firm_id,$orgName){
         $authShortUrl=RedisDataServer::creatServer()->getData($firm_id.'_firmUrl');
         if($authShortUrl){
             return true;
@@ -163,7 +130,6 @@ class ESignFirmServer
         $apiaddr="/v3/org-auth-url";
         $requestType = HttpEmun::POST;
         $firm=Firm::where('id',$firm_id)->first();
-        $member=Member::where('id',$m_id)->select(['id','promissory_name','promissory_id_number','phone'])->first();
         $data=[
             "orgAuthConfig"=>[
                 "orgName"=>$orgName,
@@ -174,10 +140,10 @@ class ESignFirmServer
 
                 ],
                 "transactorInfo"=>[
-                    "psnAccount"=>$member['phone'],
+                    "psnAccount"=>$firm['phone'],
                     "psnInfo"=>[
-                        "psnIDCardNum"=>$member['promissory_id_number'],
-                        "psnName"=>$member['promissory_name'],
+                        "psnIDCardNum"=>$firm['legal_id_number'],
+                        "psnName"=>$firm['legal_name'],
                         "psnIDCardType"=>"CRED_PSN_CH_IDCARD"
                     ]
                 ],
@@ -187,7 +153,7 @@ class ESignFirmServer
                     "get_org_identity_info","get_psn_identity_info","org_initiate_sign","psn_initiate_sign","manage_org_resource","manage_psn_resource","psn_sign_file_storage","org_sign_file_storage","org_approval_info","use_org_order"
                 ]
             ],
-            "notifyUrl"=>route('wps.esignNotify'),
+            "notifyUrl"=>route('notify.esignNotify'),
             "clientType"=>"ALL",
             "appScheme"=>""
         ];
@@ -214,23 +180,20 @@ class ESignFirmServer
             if($authShortUrl){
                 return true;
             }
-            $signMember=  SignMember::where('m_id',$m_id)->where('firm_id',$firm_id)->where('authType','ORG')->first();
-            if(!empty($signMember)){
-                $authShortUrl = $ret['data']['authShortUrl'];
-                RedisDataServer::creatServer()->setData($firm_id.'_firmUrl',$authShortUrl,'str',600);
-                $authUrl = $ret['data']['authUrl'];
-                $authFlowId = $ret['data']['authFlowId'];
-                $member=Member::where('id',$m_id)->select(['phone','promissory_name'])->first();
-                $content='尊敬的'.$member['promissory_name'].',您有关联的企业信息待认证,点击认证 '.$authShortUrl;
-                SmsServer::creatServer()->sendContent($member['phone'],$content);
-                //存入数据库
-                $signMember->update([
-                    'authUrl'=>$authUrl,
-                    'authShortUrl'=>$authShortUrl,
-                    'authFlowId'=>$authFlowId,
-                ]);
-
-            }
+            $authShortUrl = $ret['data']['authShortUrl'];
+            RedisDataServer::creatServer()->setData($firm_id.'_firmUrl',$authShortUrl,'str',600);
+            $authUrl = $ret['data']['authUrl'];
+            $authFlowId = $ret['data']['authFlowId'];
+
+            $content='尊敬的'.$firm['legal_name'].',您有关联的企业信息待认证,点击认证 '.$authShortUrl;
+            SmsServer::creatServer()->sendContent($firm['phone'],$content);
+
+            //存入数据库
+            Firm::where('id',$firm_id)->update([
+                'authUrl'=>$authUrl,
+                'authShortUrl'=>$authShortUrl,
+                'authFlowId'=>$authFlowId,
+            ]);
             return true;
         }else{//认证授权错误
             return false;