panghu 1 ano atrás
pai
commit
38a1ece129
53 arquivos alterados com 5198 adições e 4 exclusões
  1. 56 0
      Models/AdminLog.php
  2. 42 0
      Models/Contract.php
  3. 37 0
      Models/Firm.php
  4. 37 0
      Models/FirmSeal.php
  5. 37 0
      Models/Member.php
  6. 37 0
      Models/MemberSeal.php
  7. 58 0
      Models/SignContract.php
  8. 38 0
      Models/SignRecord.php
  9. 44 0
      Models/User.php
  10. 108 0
      app/Http/Controllers/AdminApi/CommonController.php
  11. 133 0
      app/Http/Controllers/AdminApi/ContractController.php
  12. 124 0
      app/Http/Controllers/AdminApi/FirmController.php
  13. 115 0
      app/Http/Controllers/AdminApi/LoginController.php
  14. 119 0
      app/Http/Controllers/AdminApi/MemberController.php
  15. 103 0
      app/Http/Controllers/AdminApi/NotifyController.php
  16. 156 0
      app/Http/Controllers/AdminApi/SignContractController.php
  17. 10 0
      app/Http/Controllers/AdminController.php
  18. 10 0
      app/Http/Controllers/ApiController.php
  19. 61 0
      app/Http/Controllers/Traits/ApiResponseTrait.php
  20. 10 0
      app/Http/Kernel.php
  21. 72 0
      app/Http/Middleware/AdminAuthMiddleware.php
  22. 23 0
      app/Http/Middleware/AdminLogMiddleware.php
  23. 48 4
      app/Providers/RouteServiceProvider.php
  24. 409 0
      app/Servers/ESign/ESignContractServer.php
  25. 410 0
      app/Servers/ESign/ESignFirmServer.php
  26. 311 0
      app/Servers/ESign/ESignServer.php
  27. 102 0
      app/Servers/ESign/comm/EsignHttpCfgHelper.php
  28. 140 0
      app/Servers/ESign/comm/EsignHttpHelper.php
  29. 32 0
      app/Servers/ESign/comm/EsignLogHelper.php
  30. 62 0
      app/Servers/ESign/comm/EsignResponse.php
  31. 94 0
      app/Servers/ESign/comm/EsignUtilHelper.php
  32. 14 0
      app/Servers/ESign/emun/HttpEmun.php
  33. 36 0
      app/Servers/Logs/AdminLogsServer.php
  34. 74 0
      app/Servers/Logs/MemberLogsServer.php
  35. 110 0
      app/Servers/System/BaiduServer.php
  36. 466 0
      app/Servers/System/CommonServer.php
  37. 63 0
      app/Servers/System/JobServer.php
  38. 157 0
      app/Servers/System/PassServer.php
  39. 232 0
      app/Servers/System/RedisDataServer.php
  40. 130 0
      app/Servers/System/SmsServer.php
  41. 99 0
      app/Servers/Wps/ExcelServer.php
  42. 179 0
      app/Servers/Wps/PdfServer.php
  43. 226 0
      app/Servers/Wps/WordServer.php
  44. 224 0
      app/Servers/Wps/WpsServer.php
  45. 14 0
      routes/adminApi/auth.php
  46. 15 0
      routes/adminApi/common.php
  47. 15 0
      routes/adminApi/contract.php
  48. 15 0
      routes/adminApi/firm.php
  49. 16 0
      routes/adminApi/member.php
  50. 13 0
      routes/adminApi/notify.php
  51. 16 0
      routes/adminApi/signContract.php
  52. 18 0
      routes/api/common.php
  53. 28 0
      routes/wps/wps.php

+ 56 - 0
Models/AdminLog.php

@@ -0,0 +1,56 @@
+<?php
+
+namespace App\Models;
+
+use DateTimeInterface;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * App\Models\AdminLog
+ *
+ * @property int $id
+ * @property int $m_id
+ * @property string $url 请求路由
+ * @property string $msg 说明
+ * @property string $ip 请求IP
+ * @property string $data 请求参数
+ * @property \Illuminate\Support\Carbon|null $created_at
+ * @property \Illuminate\Support\Carbon|null $updated_at
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog newModelQuery()
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog newQuery()
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog query()
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereCreatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereData($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereIp($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereMId($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereMsg($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Eloquent\Builder|AdminLog whereUrl($value)
+ * @mixin \Eloquent
+ */
+class AdminLog extends Model
+{
+    use HasFactory;
+    protected $guarded = ['id', 'updated_at', 'created_at'];
+
+
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected $table = 'admin_logs';
+
+    /**
+     * 为数组 / JSON 序列化准备日期。
+     *
+     * @param \DateTimeInterface $date
+     * @return string
+     */
+    protected function serializeDate(DateTimeInterface $date)
+    {
+        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
+    }
+}

+ 42 - 0
Models/Contract.php

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

+ 37 - 0
Models/Firm.php

@@ -0,0 +1,37 @@
+<?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'];
+
+
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected $table = 'firms';
+
+    /**
+     * 为数组 / JSON 序列化准备日期。
+     *
+     * @param \DateTimeInterface $date
+     * @return string
+     */
+    protected function serializeDate(DateTimeInterface $date)
+    {
+        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
+    }
+}

+ 37 - 0
Models/FirmSeal.php

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

+ 37 - 0
Models/Member.php

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

+ 37 - 0
Models/MemberSeal.php

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

+ 58 - 0
Models/SignContract.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace App\Models;
+
+use DateTimeInterface;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+/**
+ * App\Models\Contract
+ *
+ * @mixin \Eloquent
+ */
+class SignContract extends Model
+{
+    use HasFactory;
+    protected $guarded = ['id', 'updated_at', 'created_at'];
+
+
+    /**
+     * The table associated with the model.
+     *
+     * @var string
+     */
+    protected $table = 'sign_contracts';
+
+
+    /**
+     * 为数组 / JSON 序列化准备日期。
+     *
+     * @param \DateTimeInterface $date
+     * @return string
+     */
+    protected function serializeDate(DateTimeInterface $date)
+    {
+        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
+    }
+
+    private $statusEnum=[
+        0=>'文件生成中',
+        1=>'待签署',
+        2=>'已签署',
+        3=>'已撤销',
+        4=>'已拒签',
+        5=>'已过期',
+        7=>'已拒签',
+        10=>'签署失败',
+    ];
+
+    /**
+     * 序列化数据字典
+     */
+    function initializeModel(){
+        if($this->{'status'}!==null){
+            $this->{'status_str'}=empty($this->statusEnum[$this->{'status'}])?'无':$this->statusEnum[$this->{'status'}];
+        }
+    }
+}

+ 38 - 0
Models/SignRecord.php

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

+ 44 - 0
Models/User.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Contracts\Auth\MustVerifyEmail;
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Foundation\Auth\User as Authenticatable;
+use Illuminate\Notifications\Notifiable;
+use Laravel\Sanctum\HasApiTokens;
+
+class User extends Authenticatable
+{
+    use HasApiTokens, HasFactory, Notifiable;
+
+    /**
+     * The attributes that are mass assignable.
+     *
+     * @var array<int, string>
+     */
+    protected $fillable = [
+        'name',
+        'email',
+        'password',
+    ];
+
+    /**
+     * The attributes that should be hidden for serialization.
+     *
+     * @var array<int, string>
+     */
+    protected $hidden = [
+        'password',
+        'remember_token',
+    ];
+
+    /**
+     * The attributes that should be cast.
+     *
+     * @var array<string, string>
+     */
+    protected $casts = [
+        'email_verified_at' => 'datetime',
+    ];
+}

+ 108 - 0
app/Http/Controllers/AdminApi/CommonController.php

@@ -0,0 +1,108 @@
+<?php
+
+namespace App\Http\Controllers\AdminApi;
+
+use App\Http\Controllers\AdminController;
+use App\Servers\System\BaiduServer;
+use App\Servers\System\CommonServer;
+use App\Servers\System\SmsServer;
+use Illuminate\Support\Facades\Storage;
+
+class CommonController extends AdminController
+{
+
+    /**
+     * 发送短信
+     * @return \Illuminate\Http\JsonResponse
+     * @throws \End01here\EasySms\Exceptions\CodeErrorException
+     * @throws \End01here\EasySms\Exceptions\GatewayErrorException
+     * @throws \End01here\EasySms\Exceptions\MessageException
+     */
+    function sendSms()
+    {
+        $phone = request()->input('phone', '');
+        $send_type = request()->input('send_type', 'default');
+        if (empty($phone)) {
+            return $this->apiResponseError('请输入手机号码');
+        }
+        $send_server = SmsServer::creatServer();
+        $ret = $send_server->sendCode($phone, $send_type);
+        if (!$ret) {
+            return $this->apiResponseError($send_server->getErrorMsg() ?: '短信发送失败');
+        } else {
+            return $this->apiResponseSuccess('短信发送成功');
+        }
+    }
+
+    /**
+     * 获取身份证orc识别
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getCardFrontOrc()
+    {
+        $commonServer = CommonServer::creatServer();
+        $id_card = $commonServer->filtrationStr('id_card');//身份证正面
+        if (empty($id_card))  return $this->apiResponseError( '请上传身份证正面');
+
+        $result = BaiduServer::creatServer()->idCard($id_card);
+        if ($result['code'] == 1){
+
+            return $this->apiResponseSuccess($result['msg'],$result['data']);
+        }else{
+
+            return $this->apiResponseError($result['msg']);
+        }
+
+    }
+
+    /**
+     * 获取营业执照orc识别
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getLicenseOrc()
+    {
+        $commonServer = CommonServer::creatServer();
+        $license_img = $commonServer->filtrationStr('license_img');//营业执照
+        if (empty($license_img))  return $this->apiResponseError( '请上传营业执照');
+
+        $result = BaiduServer::creatServer()->businessLicense($license_img);
+        if ($result['code'] == 1){
+
+            return $this->apiResponseSuccess($result['msg'],$result['data']);
+        }else{
+
+            return $this->apiResponseError($result['msg']);
+        }
+
+    }
+
+    /**
+     * 获取阿里云临时权限
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getAliSts()
+    {
+        $ret = CommonServer::creatServer()->getAliSts();
+        if (empty($ret['code'])) {
+            return $this->apiResponseError($ret['msg']);
+        } else {
+            return $this->apiResponseSuccess($ret['msg'], $ret['data']);
+        }
+    }
+
+    /**
+     * 获取腾讯云临时权限
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getTxySts()
+    {
+        $ret = CommonServer::creatServer()->getTxySts();
+        if (empty($ret['code'])) {
+            return $this->apiResponseError($ret['msg']);
+        } else {
+            return $this->apiResponseSuccess($ret['msg'], $ret['data']);
+        }
+    }
+
+
+}

+ 133 - 0
app/Http/Controllers/AdminApi/ContractController.php

@@ -0,0 +1,133 @@
+<?php
+
+namespace App\Http\Controllers\AdminApi;
+
+use App\Http\Controllers\AdminController;
+use App\Models\Contract;
+use App\Servers\System\CommonServer;
+use Illuminate\Support\Facades\Storage;
+
+class ContractController extends AdminController
+{
+
+
+    /**
+     * 获取项目合同
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getContractList(){
+
+        $where = [['is_del',0]];
+
+        $list = Contract::where($where)
+            ->select(['id','name','created_at'])
+            ->paginate(10);
+        return $this->apiResponseSuccess('获取列表成功', [
+            'items' => $list->items(),
+            'total' => $list->total(),
+            'limit' => 10,
+        ]);
+    }
+
+
+    /**
+     * 添加&编辑项目对应合同
+     * @return \Illuminate\Http\JsonResponse
+     * @throws \Throwable
+     */
+    function saveContract(){
+
+        $id=request()->input('id','');//id
+        $name=request()->input('name');//合同名称
+        $sign_party=request()->input('sign_party',[]);//签署区域关键词
+        $texts=request()->input('texts',[]);//乙方方签署区域关键词
+        if (empty($name)) return $this->apiResponseError('请填写合同名称');
+        if (mb_strlen($name) > 100) return $this->apiResponseError('合同名称最大100');
+        if (empty($sign_party)) return $this->apiResponseError('请填写签署区信息');
+
+        $file_url =request()->input('file_url','');//文件
+        if (empty($file_url)){
+            return $this->apiResponseError('请上传文件');
+        }
+        if (empty($texts)){
+            return $this->apiResponseError('请填写变量');
+        }
+
+        $wordData = file_get_contents($file_url);
+
+        //检查合同名称是否存在
+        $info = Contract::where('name',$name)->where('is_del',0)->select(['id'])->first();
+        if (!empty($info)) {
+            return $this->apiResponseError('合同名称已存在');
+        }
+
+        $pathInfo = pathinfo($file_url);
+        $extension = $pathInfo['extension'];//获取文件扩展名
+        $file_name = $name.'.'.$extension;
+
+        $file_path = 'storage/contract/'.date('Ymd').'/';
+        CommonServer::creatServer()->creatDir($file_path);
+        $path=public_path($file_path);
+        file_put_contents($path . $file_name,$wordData);
+
+        $contracts_file = $file_path.$file_name;
+
+
+        $data = compact('name','contracts_file','sign_party','texts');
+
+        if(empty($id)){//不存在id就创建
+
+            $res = Contract::create($data);
+        }else{//存在就更新
+            $info = Contract::where('id',$id)->first();
+            if (empty($info)) {
+                return $this->apiResponseError('没有找到该记录');
+            }
+            $res = $info->update($data);
+        }
+
+        if ($res) {
+            return $this->apiResponseSuccess('操作成功');
+        } else {
+            return $this->apiResponseError('操作失败');
+        }
+    }
+
+    /**
+     * 获取项目详情
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getContractInfo()
+    {
+        $id = request()->input('id','');//获取需要删除的id
+        if(empty($id)) return $this->apiResponseError('缺少必要参数');
+
+        $info = Contract::where('id',$id)->first();
+        if (empty($info)) {
+            return $this->apiResponseError('没有找到该记录');
+        }
+
+        return $this->apiResponseSuccess('成功',$info);
+    }
+
+    /**
+     * 删除
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function delContract(){
+        $id = request()->input('id','');//获取需要删除的id
+        if(empty($id)) return $this->apiResponseError('缺少必要参数');
+
+        $info = Contract::where('id',$id)->select(['id'])->first();
+        if (empty($info)) {
+            return $this->apiResponseError('没有找到该记录');
+        }
+
+        $res = Contract::where('id',$id)->update(['is_del'=>1]);
+        if ($res) {
+            return $this->apiResponseSuccess('删除成功');
+        } else {
+            return $this->apiResponseError('删除失败');
+        }
+    }
+}

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

@@ -0,0 +1,124 @@
+<?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;
+use App\Servers\System\JobServer;
+
+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
+     */
+    function noticeFirmAuth(){
+        $id=request()->input('id','');//id
+        if(empty($id)) return $this->apiResponseError('缺少必要参数');
+
+        $info = Firm::where('id',$id)->select(['id','firm_name','phone','license_number','license_img','registered_address','authType','legal_identity_one','legal_identity_two','legal_id_number'])->first();
+        if (empty($info)) {
+            return $this->apiResponseError('没有找到该记录');
+        }
+
+        //查询个人认证信息
+        ESignFirmServer::creatServer()->organizationsIdentityInfo($id,$info->{'firm_name'});
+
+        return $this->apiResponseSuccess('成功');
+    }
+
+    /**
+     * 添加&编辑用户
+     * @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('操作失败');
+        }
+    }
+
+    /**
+     * 获取详情
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getFirmInfo()
+    {
+        $id = request()->input('id','');//获取需要删除的id
+        if(empty($id)) return $this->apiResponseError('缺少必要参数');
+
+        $info = Firm::where('id',$id)->select(['id','firm_name','phone','license_number','license_img','registered_address','authType','legal_identity_one','legal_identity_two','legal_id_number'])->first();
+        if (empty($info)) {
+            return $this->apiResponseError('没有找到该记录');
+        }
+
+        return $this->apiResponseSuccess('成功',$info);
+    }
+
+}

+ 115 - 0
app/Http/Controllers/AdminApi/LoginController.php

@@ -0,0 +1,115 @@
+<?php
+
+namespace App\Http\Controllers\AdminApi;
+
+use App\Http\Controllers\AdminController;
+use App\Models\User;
+use App\Servers\System\CommonServer;
+use App\Servers\System\PassServer;
+use App\Servers\System\SmsServer;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Validator;
+use Illuminate\Support\Str;
+
+class LoginController extends AdminController
+{
+
+    /**
+     * 基本路由
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function login(){
+//        $mobile = request()->input('phone', '');
+//        if (empty($mobile)) {
+//            return $this->apiResponseError('请输入手机号码');
+//        }
+//        $password = request()->input('password', '');
+//        if (empty($password)) {
+//            return $this->apiResponseError('请输入登录密码');
+//        }
+        $data=request()->input();
+        $rules = [
+            'account'=>'required|max:255',
+            'password'=>'required',
+        ];
+        $rulesMsg = [
+            'account.required' => '请输入账号',
+            'account.max' => '账号最大255',
+            'password.required' => '请输入登录密码',
+        ];
+        $validator = Validator::make($data, $rules,$rulesMsg);
+        if ($validator->fails()) {
+            return $this->apiResponseError($validator->errors()->first());
+        }
+        $validatedData = $validator->validated();
+        $user = User::where('account', $validatedData['account'])->where('is_del',0)->select(['id', 'password', 'encrypt'])->first();
+        if(empty($user)){
+            return $this->apiResponseError('用户信息不存在');
+        }
+
+        $pass_server = PassServer::creatServer($validatedData['password'], $user->{'encrypt'});
+        if (!$pass_server->verifyPass($user->{'password'})) {
+            return $this->apiResponseError('登陆密码错误');
+        }
+
+        $token = Str::random(60);
+        $api_token = hash('sha256', $token);
+
+        $ret = $user->forceFill(['api_token' => $api_token])->save();
+        if (empty($ret)) {
+            return $this->apiResponseError('登陆失效');
+        }
+        Auth::loginUsingId($user->{'id'});
+        return $this->apiResponseSuccess('登陆成功', ['u_id' =>$user->{'id'}, 'token' => $api_token]);
+    }
+
+    /**
+     * 修改登录密码-忘记密码
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function retrievePassword()
+    {
+        $mobile = request()->input('phone', '');
+        $password = request()->input('password', '');
+        $confirm_password =  request()->input('confirm_password','');
+        $password = str_replace(' ', '', $password);
+        $confirm_password = str_replace(' ', '', $confirm_password);
+        if (empty($password)) {
+            return $this->apiResponseError('请设置登录密码');
+        }
+        if (strlen($password) < 6 || strlen($password) > 12) {
+            return $this->apiResponseError('密码为6-12位');
+        }
+        if ($password != $confirm_password){
+            return $this->apiResponseError('确认密码错误');
+        }
+        if (empty($mobile)) {
+            return $this->apiResponseError('请输入手机号码');
+        }
+        if (!CommonServer::creatServer()->verifyPhoneNumber($mobile)) {
+            return $this->apiResponseError('手机号码格式错误');
+        }
+        $code = request()->input('code', '');
+        if (empty($code)) {
+            return $this->apiResponseError('请输入验证码');
+        }
+        $send_server = SmsServer::creatServer();
+        $code_ret = $send_server->verifyCode($mobile, $code, 'retrieve');
+        if (empty($code_ret)) {
+            return $this->apiResponseError($send_server->getErrorMsg() ?: '验证码错误');
+        }
+
+        $user = User::where('phone', $mobile)->where('is_del',0)->first();
+        if(empty($user)){
+            return $this->apiResponseError('账户信息不存在');
+        }
+        $pass_server = PassServer::creatServer($password, $user->{'encrypt'});
+        $new_pass = $pass_server->creatPassword();
+        $ret = $user->update(['password' => $new_pass['password']]);
+        if (empty($ret)) {
+            return $this->apiResponseError('密码修改失败');
+        } else {
+            return $this->apiResponseSuccess('密码修改成功');
+        }
+    }
+}

+ 119 - 0
app/Http/Controllers/AdminApi/MemberController.php

@@ -0,0 +1,119 @@
+<?php
+
+namespace App\Http\Controllers\AdminApi;
+
+use App\Http\Controllers\AdminController;
+use App\Models\Member;
+use App\Servers\ESign\ESignServer;
+use App\Servers\System\CommonServer;
+use App\Servers\System\JobServer;
+
+class MemberController extends AdminController
+{
+    /**
+     * 获取用户列表
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getMemberList(){
+
+        $where = [['is_del',0]];
+
+        $list = Member::where($where)
+            ->select(['id','name','phone','id_number','psnId','realnameStatus','authorizeUserInfo','created_at'])
+            ->paginate(10);
+        return $this->apiResponseSuccess('获取列表成功', [
+            'items' => $list->items(),
+            'total' => $list->total(),
+            'limit' => 10,
+        ]);
+    }
+
+    /**
+     * 通知用户认证
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function noticeMemberAuth(){
+        $id=request()->input('id','');//id
+        if(empty($id)) return $this->apiResponseError('缺少必要参数');
+
+        $info = Member::where('id',$id)->first();
+        if (empty($info)) {
+            return $this->apiResponseError('没有找到该记录');
+        }
+
+        //查询个人认证信息
+        ESignServer::creatServer()->personsidentityinfo($id,$info->{'phone'},$info->{'name'},$info->{'id_number'});
+
+        return $this->apiResponseSuccess('成功');
+    }
+
+    /**
+     * 添加&编辑用户
+     * @return \Illuminate\Http\JsonResponse
+     * @throws \Throwable
+     */
+    function saveMember(){
+
+        $id=request()->input('id','');//id
+        $name=request()->input('name','');//姓名
+        $phone=request()->input('phone','');//电话
+        $id_number=request()->input('id_number','');//身份证号
+        if (empty($name)) return $this->apiResponseError('请填写姓名');
+        if (mb_strlen($name) > 100) return $this->apiResponseError('姓名最大100');
+
+        if (empty($phone)) return $this->apiResponseError('请填写手机号');
+        if (!CommonServer::creatServer()->verifyPhoneNumber($phone)) return $this->apiResponseError('手机号错误');
+        if (empty($id_number)) return $this->apiResponseError('请填写身份证号');
+
+
+        $authType = 'PSN';
+        $data = compact('name','phone','id_number','authType');
+
+        if(empty($id)){//不存在id就创建
+            //检查该身份证号是否存在
+            $member = Member::where('id_number',$id_number)->where('is_del',0)->select(['id'])->first();
+            if (!empty($member)){
+                return $this->apiResponseError('身份证号已存在');
+            }
+
+            $res = Member::create($data);
+        }else{//存在就更新
+            $info = Member::where('id',$id)->select(['id'])->first();
+            if (empty($info)) {
+                return $this->apiResponseError('没有找到该记录');
+            }
+            //检查该身份证号是否存在
+            $member = Member::where('id_number',$id_number)->where('id','<>',$id)->where('is_del',0)->select(['id'])->first();
+            if (!empty($member)){
+                return $this->apiResponseError('身份证号已存在');
+            }
+            $res = $info->update($data);
+        }
+        $m_id = $res->{'id'};
+        //查询个人认证信息
+        ESignServer::creatServer()->personsidentityinfo($m_id,$phone,$name,$id_number);
+
+        if ($res) {
+            return $this->apiResponseSuccess('操作成功');
+        } else {
+            return $this->apiResponseError('操作失败');
+        }
+    }
+
+    /**
+     * 获取详情
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getMemberInfo()
+    {
+        $id = request()->input('id','');//获取需要删除的id
+        if(empty($id)) return $this->apiResponseError('缺少必要参数');
+
+        $info = Member::where('id',$id)->where('is_del',0)->select(['name','phone','id_number','id'])->first();
+        if (empty($info)) {
+            return $this->apiResponseError('没有找到该记录');
+        }
+
+        return $this->apiResponseSuccess('成功',$info);
+    }
+}

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

@@ -0,0 +1,103 @@
+<?php
+
+namespace App\Http\Controllers\AdminApi;
+
+
+use App\Http\Controllers\ApiController;
+use App\Models\Firm;
+use App\Models\Member;
+use App\Models\SignContract;
+use App\Models\SignRecord;
+use App\Servers\ESign\comm\EsignLogHelper;
+use App\Servers\System\JobServer;
+
+class NotifyController extends ApiController
+{
+
+    /**
+     * e签宝回调通知
+     * @return false|string
+     */
+    function esignNotify()
+    {
+        $data = file_get_contents('php://input');
+        EsignLogHelper::writeLog($data,3);
+        $data = json_decode($data,true);
+        //回调错误
+        if (!isset($data['action'])){
+            return json_encode(['code'=>'0','msg'=>'error']);
+        }
+        if ($data['action'] == 'AUTH_PASS'){//实名认证通过通知
+            $authFlowId = $data['authFlowId'];
+
+            if ($data['authType'] == 'PSN'){
+                $psnId = $data['psnInfo']['psnId'];
+                //更新数据
+                $info = Member::where('authType','PSN')
+                    ->where('authFlowId',$authFlowId)
+                    ->update(['realnameStatus'=>1,'psnId'=>$psnId]);
+
+            }elseif ($data['authType'] == 'ORG'){
+                $orgId = $data['organization']['orgId'];
+                $orgName = $data['organization']['orgName'];
+                //更新数据
+                $info = Firm::where('authType','ORG')
+                    ->where('firm_name',$orgName)
+                    ->where('realnameStatus',0)
+                    ->update(['realnameStatus'=>1,'orgId'=>$orgId]);
+
+            }
+
+        }elseif ($data['action'] == 'AUTHORIZE_FINISH'){//授权通知
+            $authFlowId = $data['authFlowId'];
+            $psnId = $data['psnId'];
+            $orgId = $data['orgId'] ?? '';
+            $authorizedInfo = json_encode($data['authorizedInfo']);
+
+            if($orgId){
+                Firm::where('authFlowId',$authFlowId)->update(['authorizeUserInfo'=>1,'realnameStatus'=>1,'orgId'=>$orgId,'authorizedInfo'=>$authorizedInfo]);
+
+                //检测系统内部的企业印章信息
+                JobServer::creatServer()->createFirmSealJob($orgId);
+            }else{
+                Member::where('authFlowId',$authFlowId)->update(['authorizeUserInfo'=>1,'realnameStatus'=>1,'psnId'=>$psnId,'authorizedInfo'=>$authorizedInfo]);
+                //检测系统内部的企业印章信息
+                JobServer::creatServer()->createMemberSealJob($psnId);
+            }
+
+
+        }elseif ($data['action'] == 'AUTHORIZE_CHANGE'){
+            //授权变更通知
+
+        }elseif ($data['action'] == 'SIGN_FLOW_COMPLETE'){
+            //合同签署
+            $signFlowStatus = $data['signFlowStatus'];
+            $signFlowId = $data['signFlowId'];
+            SignContract::where('flow_id',$signFlowId)->update(['status'=>$signFlowStatus]);
+        }elseif ($data['action'] == 'SIGN_MISSON_COMPLETE'){
+            //合同签署
+            $signFlowStatus = $data['signResult'];
+            $signFlowId = $data['signFlowId'];
+            $organization = $data['organization'];
+            $operator = $data['operator'];
+            if (!empty($signFlowId)){
+                $sign = SignContract::where('flow_id',$signFlowId)->first();
+                $sign_id = $sign->{'id'};
+                if (!empty($operator)){
+                    $psnId = $operator['psnId'];
+                    SignRecord::where('sign_id',$sign_id)->where('authType','PSN')->where('id_no',$psnId)->update(['status'=>$signFlowStatus]);
+                }
+                if (!empty($organization)){
+                    $orgId = $organization['orgId'];
+                    SignRecord::where('sign_id',$sign_id)->where('authType','ORG')->where('id_no',$orgId)->update(['status'=>$signFlowStatus]);
+                }
+            }
+        }elseif ($data['action']=='SEAL_AUTH_SIGN'){
+//            SealServer::creatServer()->sealNotify($data['authStatus'],$data['sealAuthBizId']);
+        }
+
+        return json_encode(['code'=>'200','msg'=>'success']);
+    }
+
+
+}

+ 156 - 0
app/Http/Controllers/AdminApi/SignContractController.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace App\Http\Controllers\AdminApi;
+
+use App\Http\Controllers\AdminController;
+use App\Models\Contract;
+use App\Models\Firm;
+use App\Models\Member;
+use App\Models\SignContract;
+use App\Servers\ESign\ESignContractServer;
+use App\Servers\Wps\WordServer;
+
+class SignContractController extends AdminController
+{
+
+    /**
+     * 获取项目合同
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getContractList()
+    {
+
+        $search=request()->input('search');
+
+        $where = [['is_del',0]];
+        if(!empty($search)){
+            $where[] = ['name','like','%'.$search.'%'];
+        }
+
+        $list = Contract::where($where)
+            ->select(['id','name','texts','sign_party'])
+            ->paginate(10);
+        return $this->apiResponseSuccess('获取列表成功', [
+            'items' => $list->items(),
+            'total' => $list->total(),
+            'limit' => 10,
+        ]);
+    }
+
+    /**
+     * 获取机构列表
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getFirmList(){
+
+        $search=request()->input('search');
+
+        $where = [['is_del',0], ['realnameStatus',1], ['authorizeUserInfo',1]];
+        if(!empty($search)){
+            $where[] = ['firm_name','like','%'.$search.'%'];
+        }
+
+        $list = Firm::where($where)
+            ->select(['id','firm_name','license_number','legal_name','authType','orgId','realnameStatus','authorizeUserInfo','created_at'])
+            ->paginate(10);
+        return $this->apiResponseSuccess('获取列表成功', [
+            'items' => $list->items(),
+            'total' => $list->total(),
+            'limit' => 10,
+        ]);
+    }
+
+    /**
+     * 获取用户列表
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getMemberList(){
+        $search=request()->input('search');
+
+        $where = [['is_del',0], ['realnameStatus',1], ['authorizeUserInfo',1]];
+        if(!empty($search)){
+            $where[] = ['name','like','%'.$search.'%'];
+        }
+
+        $list = Member::where($where)
+            ->select(['id','name','phone','id_number','authType','psnId','realnameStatus','authorizeUserInfo','created_at'])
+            ->paginate(10);
+        return $this->apiResponseSuccess('获取列表成功', [
+            'items' => $list->items(),
+            'total' => $list->total(),
+            'limit' => 10,
+        ]);
+    }
+
+    /**
+     * 获取签署列表
+     * @return \Illuminate\Http\JsonResponse
+     */
+    function getSignContractList()
+    {
+        $search=request()->input('search');
+
+        $where = [['is_del',0]];
+        if(!empty($search)){
+            $where[] = ['contracts_no','like','%'.$search.'%'];
+        }
+
+        $list = SignContract::where($where)
+            ->select(['id','contract_no','status','contract_id','created_at'])
+            ->paginate(10);
+
+        foreach ($list as $key => $value) {
+            $value->{'contracts_name'} = Contract::where('id',$value->contracts_id)->value('name');
+        }
+
+        return $this->apiResponseSuccess('获取列表成功', [
+            'items' => $list->items(),
+            'total' => $list->total(),
+            'limit' => 10,
+        ]);
+    }
+
+    /**
+     * 创建合同签署
+     * @return \Illuminate\Http\JsonResponse
+     * @throws \PhpOffice\PhpWord\Exception\Exception
+     */
+    function createSignContract()
+    {
+        $contract_id=request()->input('contract_id','');//合同id
+        $contract_no=request()->input('contract_no','');//合同编号
+        $text_json=request()->input('textsJson','');//替换文本json
+        $sign_json=request()->input('signJson','');//签署区域信息
+        if(empty($contract_id)){
+            return $this->apiResponseError('请选择合同');
+        }
+        if(empty($text_json)){
+            return $this->apiResponseError('请填写合同信息');
+        }
+        if(empty($sign_json)){
+            return $this->apiResponseError('请选择签署信息');
+        }
+        //获取合同信息
+        $contract = Contract::where(['id'=>$contract_id])->first();
+        if (empty($contract)){
+            return $this->apiResponseError('合同不存在');
+        }
+        //替换合同信息
+        $file_path = $contract->{'contracts_file'};
+        // 获取所有信息
+        $pathInfo = pathinfo($file_path);
+        $file_name = $pathInfo['filename'].$contract_no.'.'.$pathInfo['extension'];
+        //替换合同信息
+        $local_file = WordServer::creatServer()->replaceWordText($file_path,$file_name,$text_json);
+        //上传文件到e签宝并获得文件id
+        $file_id = ESignContractServer::creatServer()->fileUploadUrl($local_file);
+
+        $data = compact('contract_id','contract_no','file_id','text_json','sign_json','local_file');
+        //存入数据库
+        $sign = SignContract::create($data);
+        if (empty($sign)){
+            return $this->apiResponseError('保存失败');
+        }
+        return $this->apiResponseSuccess('保存成功');
+    }
+}

+ 10 - 0
app/Http/Controllers/AdminController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Http\Controllers\Traits\ApiResponseTrait;
+
+class AdminController extends Controller
+{
+    use ApiResponseTrait;
+}

+ 10 - 0
app/Http/Controllers/ApiController.php

@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use App\Http\Controllers\Traits\ApiResponseTrait;
+
+class ApiController extends Controller
+{
+    use ApiResponseTrait;
+}

+ 61 - 0
app/Http/Controllers/Traits/ApiResponseTrait.php

@@ -0,0 +1,61 @@
+<?php
+
+
+namespace App\Http\Controllers\Traits;
+
+
+
+trait ApiResponseTrait
+{
+    /**
+     * @param array $data                       ## 返回数据
+     * @param string $msg                       ## 返回信息 如:auth.failed
+     * @param int $code                         ## 响应编码 1:成功 0:失败
+     * @param int $status                       ## HTTP响应状态 200:请求成功
+     * @param array $header                     ## 响应头
+     * @param int $options                      ## 其他信息
+     * @return \Illuminate\Http\JsonResponse
+     *
+     * 接口返回格式 | 成功
+     */
+    public function apiResponseSuccess( $msg = '',$data = [], $code = 1, $status = 200, $header = [], $options = 0)
+    {
+//        $this->lang();
+//        $msg=__($msg);
+        return response()->json([
+            'msg'   => $msg,
+            'data'  => empty($data) ? [] : $data,
+            'code'  => $code,
+        ], $status, $header, $options);
+    }
+
+    /**
+     * @param array $data                       ## 返回数据
+     * @param string $msg                       ## 返回信息 如:auth.failed
+     * @param int $code                         ## 响应编码 1:成功 0:失败
+     * @param int $status                       ## HTTP响应状态 200:请求成功
+     * @param array $header                     ## 响应头
+     * @param int $options                      ## 其他信息
+     * @return \Illuminate\Http\JsonResponse
+     *
+     * 接口返回格式 | 失败
+     */
+    public function apiResponseError( $msg = '',$data = [], $code = 0, $status = 200, $header = [], $options = 0)
+    {
+//        $this->lang();
+//        $msg=__($msg);
+        return response()->json([
+            'msg'   => $msg,
+            'data'  => empty($data) ? [] : $data,
+            'code'  => $code,
+        ], $status, $header, $options);
+    }
+
+    /**
+     * 双语设置
+     */
+    protected function lang()
+    {
+        app()->setLocale(request()->input('lang', 'zh'));
+    }
+}

+ 10 - 0
app/Http/Kernel.php

@@ -2,6 +2,8 @@
 
 namespace App\Http;
 
+use App\Http\Middleware\AdminAuthMiddleware;
+use App\Http\Middleware\AdminLogMiddleware;
 use Illuminate\Foundation\Http\Kernel as HttpKernel;
 
 class Kernel extends HttpKernel
@@ -43,6 +45,14 @@ class Kernel extends HttpKernel
             'throttle:api',
             \Illuminate\Routing\Middleware\SubstituteBindings::class,
         ],
+
+
+        //后台验证
+        'adminApiVerify'=>[
+            AdminAuthMiddleware::class,
+            AdminLogMiddleware::class,
+//            PermissionMiddleware::class
+        ],
     ];
 
     /**

+ 72 - 0
app/Http/Middleware/AdminAuthMiddleware.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Exceptions\MemberAuthException;
+use App\Models\User;
+use App\Servers\System\PermissionServer;
+use Closure;
+use Illuminate\Support\Facades\Auth;
+
+class AdminAuthMiddleware
+{
+    private $noAuth = [
+        'adminApi.auth.login',
+        'adminApi.auth.retrieve',//忘记密码
+        'adminApi.common.send',
+        'adminApi.auth.retrieve',
+        'adminApi.notify.esignNotify'
+    ];
+    /**
+     * Handle an incoming request.
+     *
+     * @param \Illuminate\Http\Request $request
+     * @param \Closure $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+        $clientRoute = request()->route()->getName();//获取当前路由
+
+        if (in_array($clientRoute, $this->noAuth)) {//不需要验证的路由
+            return $next($request);
+        }
+        $apiToken=$request->input('api_token','');
+        if(empty($apiToken)){
+            $apiToken=$request->header('Authorization');
+        }
+        $user=User::where('api_token',$apiToken)->where('is_del',0)->select(['id','name','status','roles_id'])->first();
+        if(empty($user)){
+            return response()->json([
+                'msg'   => '请先登录',
+                'code'  => 401,
+                'data' => []
+            ]);
+        }
+        if(empty($user->{'status'})){
+            return response()->json([
+                'msg'   => '当前账户已锁定',
+                'code'  => 401,
+                'data' => []
+            ]);
+        }
+        Auth::loginUsingId($user->{'id'});
+
+
+        //进行路由验证
+//        $ret = PermissionServer::creatServer()->verifyPermission($user->{'id'}, $clientRoute,0);
+//        if (empty($ret) ) {
+//            if($request->ajax()){
+//                return response()->json([
+//                    'msg'   => '暂无权限',
+//                    'code'  => 0,
+//                    'data' => []
+//                ]);
+//            }else{
+//                return $next($request);
+//            }
+//
+//        }
+        return $next($request);
+    }
+}

+ 23 - 0
app/Http/Middleware/AdminLogMiddleware.php

@@ -0,0 +1,23 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use App\Servers\Logs\AdminLogsServer;
+use Closure;
+
+class AdminLogMiddleware
+{
+    /**
+     * Handle an incoming request.
+     *
+     * @param  \Illuminate\Http\Request  $request
+     * @param  \Closure  $next
+     * @return mixed
+     */
+    public function handle($request, Closure $next)
+    {
+        //记录访问日志
+        AdminLogsServer::write();
+        return $next($request);
+    }
+}

+ 48 - 4
app/Providers/RouteServiceProvider.php

@@ -37,11 +37,12 @@ class RouteServiceProvider extends ServiceProvider
     {
         $this->configureRateLimiting();
 
+
+        $this->mapApiRoutes();
+        $this->mapWpsRoutes();
+        $this->mapAdminApiRoutes();
+
         $this->routes(function () {
-            Route::prefix('api')
-                ->middleware('api')
-                ->namespace($this->namespace)
-                ->group(base_path('routes/api.php'));
 
             Route::middleware('web')
                 ->namespace($this->namespace)
@@ -60,4 +61,47 @@ class RouteServiceProvider extends ServiceProvider
             return Limit::perMinute(60);
         });
     }
+
+
+    protected function mapApiRoutes()
+    {
+        Route::prefix('api')
+            ->middleware('api')
+            ->namespace($this->namespace)
+            ->group(base_path('routes/api.php'));
+//dd($this->namespace);
+        foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) {
+            $fileName = basename( $fileName );
+            Route::middleware('api_verify')
+                ->namespace( $this->namespace."\\Api" )
+                ->prefix('api')
+                ->group( base_path('routes'.DIRECTORY_SEPARATOR.'api'.DIRECTORY_SEPARATOR."{$fileName}") );
+        }
+    }
+
+    /**
+     * Wps回调地址
+     */
+    function mapWpsRoutes(){
+        foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'wps'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) {
+            $fileName = basename( $fileName );
+            Route::namespace( $this->namespace."\\Wps" )
+                ->prefix('wps')
+                ->group( base_path('routes'.DIRECTORY_SEPARATOR.'wps'.DIRECTORY_SEPARATOR."{$fileName}") );
+        }
+    }
+
+    /**
+     * 总后台API路由
+     */
+    protected function mapAdminApiRoutes(){
+        foreach ( glob(base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR).'*.php' ) as $fileName ) {
+            $fileName = basename( $fileName );
+            //中间件过滤加载
+            Route::middleware('adminApiVerify')
+                ->namespace( $this->namespace."\\AdminApi" )
+                ->prefix('adminApi')
+                ->group( base_path('routes'.DIRECTORY_SEPARATOR.'adminApi'.DIRECTORY_SEPARATOR."{$fileName}") );
+        }
+    }
 }

+ 409 - 0
app/Servers/ESign/ESignContractServer.php

@@ -0,0 +1,409 @@
+<?php
+
+
+namespace App\Servers\ESign;
+
+
+
+use App\Models\Firm;
+use App\Models\FirmSeal;
+use App\Models\Member;
+use App\Models\MemberSeal;
+use App\Models\SignContract;
+use App\Models\SignRecord;
+use App\Servers\ESign\comm\EsignHttpHelper;
+use App\Servers\ESign\comm\EsignLogHelper;
+use App\Servers\ESign\comm\EsignUtilHelper;
+use App\Servers\ESign\emun\HttpEmun;
+use App\Servers\System\CommonServer;
+use App\Servers\System\SmsServer;
+
+class ESignContractServer
+{
+    static private $server = null;
+
+    public  $config = [
+        'eSignAppId'=>'', //app id
+        'eSignAppSecret'=>'', // app key
+        'eSignHost'=>'https://smlopenapi.esign.cn', //模拟环境
+        //     'url'=>'https://openapi.esign.cn' //正式环境
+    ];
+
+    function __construct()
+    {
+            $this->config['eSignAppId']=env('E_SIGN_APP_ID');
+            $this->config['eSignAppSecret']=env('E_SIGN_APP_SECRET');
+            $this->config['eSignPublicKey']=env('E_SIGN_PUBLIC_KEY');
+            $this->config['eSignHost']=env('E_SIGN_HOST');
+    }
+
+    /**
+     * 创建对象
+     * @return ESignContractServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new ESignContractServer();
+        return self::$server;
+    }
+
+
+    function contentMd5($filePath){
+        if(!file_exists($filePath)){
+            EsignLogHelper::printMsg($filePath."文件不存在");exit;
+        }
+        return EsignUtilHelper::getContentBase64Md5($filePath);
+    }
+
+
+    /**
+     * 上传合同文件至E签宝
+     * @param $file_url
+     * @return mixed
+     */
+    function fileUploadUrl($file_url){
+        $config=$this->config;
+
+        $file_name=CommonServer::creatServer()->getFileName($file_url);
+        $filePath=public_path($file_url);
+        $contentMd5=$this->contentMd5($filePath);
+        $apiaddr="/v3/files/file-upload-url";
+        $requestType = HttpEmun::POST;
+        $data=[
+            "contentMd5" =>$contentMd5,
+            "contentType" =>"application/pdf",
+            "convertToPDF" =>true,
+            "fileName" =>$file_name,
+            "fileSize" =>filesize($filePath)
+        ];
+        $paramStr = json_encode($data);
+        //生成签名验签+json体的header
+
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //获取文件上传地址
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
+        $fileUploadUrl=json_decode($response->getBody())->data->fileUploadUrl;
+        $fileId=json_decode($response->getBody())->data->fileId;
+        //文件流put上传
+        $response=EsignHttpHelper::upLoadFileHttp($fileUploadUrl,$filePath,"application/pdf");
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
+
+        return $fileId;
+    }
+
+    /**
+     * 获取文件状态
+     * @param $fileId
+     * @return int|mixed
+     */
+    function getFileStatus($fileId)
+    {
+        $config=$this->config;
+        $apiaddr="/v3/files/{$fileId}";
+        $requestType = HttpEmun::GET;
+        //生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+        //发起接口请求
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            return $ret['data']['fileStatus'];
+        }else{
+            return 0;
+        }
+    }
+
+    /**
+     * 获取签署文件对应关键字坐标
+     * @param $fileId
+     * @param $keywords
+     * @return array
+     */
+    function getKeywordPositions($fileId,$keywords)
+    {
+        $config=$this->config;
+        $apiaddr="/v3/files/{$fileId}/keyword-positions";
+        $requestType = HttpEmun::POST;
+        $data=[
+            "keywords" =>$keywords
+        ];
+        $paramStr = json_encode($data);
+        //生成签名验签+json体的header
+
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //获取文件上传地址
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            return ['code'=>'1','msg'=>'ok','data'=>$ret['data']['keywordPositions']];
+        }else{
+            return ['code'=>'0','msg'=>$ret['message']];
+        }
+    }
+
+
+    function setContractContract($sign_id,$fileId,$signJson,$file_name)
+    {
+//        $signJson = '[{"keyword":"fisher", "auth_type":"PSN", "id_no","AAAAA"}, {"keyword":"lily", "auth_type":"ORG", "id_no","AAAAA"}, {"keyword":"bob", "auth_type":"PSN", "id_no","AAAAA"}]';
+        $signData = json_decode($signJson,true);
+
+        $keywords=[];
+        foreach ($signData as $k=>$v){
+            $keywords[]=$v['keyword'];
+        }
+
+        //获取对应关键字定位
+//dd(111);
+        $positionRet=ESignContractServer::creatServer()->getKeywordPositions($fileId,$keywords);
+        if(empty($positionRet['code'])){
+            return ['code'=>0,'msg'=>'签署区域定位失败'];
+        }else{
+            $positionData=$positionRet['data'];
+        }
+
+
+        $signers=[];
+        $signUrl = [];
+        foreach ($signData as $value){
+            //对应关键字做xy坐标匹配
+            foreach ($positionData as $item){
+                if(count($item['positions'])<=0){
+                    continue;
+                }
+                if($item['keyword']==$value['keyword']){
+
+                    $position=end($item['positions']);
+                    $coordinate=end($position['coordinates']);
+                    $value['positionPage'] = $position['pageNum'];
+                    $value['positionX'] = $coordinate['positionX'];
+                    $value['positionY'] = $coordinate['positionY'];
+                }
+            }
+
+            //签署方是机构还是个人
+            if ($value['auth_type'] == 'PSN'){
+                $member = Member::where('psnId',$value['id_no'])->first();
+                //记录需要手动签署的
+                $signUrl[]=[
+                    'promissoryName'=>$member['name'],
+                    'psnAccount'=>$member['phone'],
+                    'orgName'=>'',
+                ];
+                //获取签章
+                $m_id = $member->{'id'};
+                $seal=MemberSeal::where('m_id',$m_id)->where('seal_status',1)->select(['id','seal_id'])->first();
+                //印章ID
+                $assignedSealId=$seal->{'seal_id'};
+                //组装信息
+                $signersData = [
+                    "signerType" => 0,
+                    "psnSignerInfo" => [
+                        "psnAccount" => $member->{'phone'},
+                        'psnInfo'=>[
+                            'psnName'=>$member->{'name'},
+                            'psnIDCardNum'=>$member->{'id_number'},
+                            'psnIDCardType'=>'CRED_PSN_CH_IDCARD',
+                        ],
+                    ],
+                    "signFields" =>[
+                        [
+                            "fileId" =>$fileId,
+                            "normalSignFieldConfig" => [
+                                "autoSign" =>false,
+                                "signFieldStyle" =>1,
+                                "assignedSealId"=>$assignedSealId,    // 在signFields中设置 assignedSealId为授权企业印章id
+                                "signFieldPosition" => [
+                                    "positionPage" =>$value['positionPage'].'',
+                                    "positionX" =>(int)$value['positionX'],
+                                    "positionY" =>(int)$value['positionY'],
+                                ]
+                            ]
+                        ]
+                    ],
+                ];
+            }else{
+                $firm = Firm::where('orgId',$value['id_no'])-first();
+                //记录需要手动签署的
+                $signUrl[]=[
+                    'promissoryName'=>$firm['legal_name'],
+                    'psnAccount'=>$firm['phone'],
+                    'orgName'=>$firm['firm_name'],
+                ];
+                //获取用户签章
+                $firm_id = $firm->{'id'};
+                $seal=FirmSeal::where('firm_id',$firm_id)->where('seal_type','CONTRACT')->select(['id','seal_id'])->first();
+                //印章ID
+                $assignedSealId=$seal->{'seal_id'};
+                $signersData = [
+                    "signerType" => 1,
+                    "orgSignerInfo" => [
+                        "orgName" => $firm->{'firm_name'},
+                        'orgInfo'=>[
+                            'orgIDCardNum'=>$firm->{'license_number'},
+                            'orgIDCardType'=>'CRED_ORG_USCC',
+                        ],
+                        "transactorInfo"=>[
+                            "psnAccount"=>$firm['phone'],
+                            'psnInfo'=>[
+                                'psnIDCardNum'=>$firm['legal_id_number'],
+                                'psnIDCardType'=>'CRED_PSN_CH_IDCARD'
+                            ]
+                        ]
+                    ],
+                    "signFields" =>[
+                        [
+                            "fileId" =>$fileId,
+                            "normalSignFieldConfig" => [
+                                "autoSign" =>false,
+                                "signFieldStyle" =>1,
+                                "assignedSealId"=>$assignedSealId,    // 在signFields中设置 assignedSealId为授权企业印章id
+                                "signFieldPosition" => [
+                                    "positionPage" =>$value['positionPage'].'',
+                                    "positionX" =>(int)$value['positionX'],
+                                    "positionY" =>(int)$value['positionY'],
+                                ]
+                            ]
+                        ]
+                    ],
+                ];
+            }
+
+            $signers[]=$signersData;
+            //对应签署方做记录
+            SignRecord::create([
+                'sign_id' => $sign_id,
+                'authType' => $value['auth_type'],
+                'id_no' => $value['id_no'],
+                'keyword' => $value['keyword'],
+                'page_num' => $value['positionPage'],
+                'position_x' => $value['positionX'],
+                'position_y' => $value['positionY'],
+            ]);
+        }
+        if(empty($signers)){
+            return ['code'=>0,'msg'=>'暂无可执行电签印章'];
+        }
+        $flowId=  $this->createByFile($fileId,$file_name.'.pdf',$file_name,$signers);
+
+        if($flowId){
+            SignContract::where('id',$sign_id)->update(['flow_id'=>$flowId,'status'=>1]);
+            foreach ($signUrl as $item){
+                $urlRet= $this->getSignUrl($flowId,$item['psnAccount'],$item['orgName']);
+                if($urlRet){
+                    $content='尊敬的'.$item['promissoryName'].',您有待签署合同《'.$file_name.'》,点击签署 '.$urlRet;
+                    SmsServer::creatServer()->sendContent($item['psnAccount'],$content);
+                    SignContract::where('id',$sign_id)->update(['sign_url'=>$urlRet]);
+                }
+            }
+
+            return ['code'=>1,'msg'=>'发起签署成功'];
+        }else{
+            return ['code'=>0,'msg'=>'发起签署失败'];
+        }
+    }
+
+
+    /**
+     * 合同签署
+     * @param $fileId
+     * @return false
+     */
+    function createByFile($fileId,$fileName,$signFlowTitle,$signers)
+    {
+        EsignLogHelper::printMsg("**********基于文件发起签署调用开始**********");
+        $config=$this->config;
+        $apiaddr="/v3/sign-flow/create-by-file";
+        $requestType = HttpEmun::POST;
+
+        $data = [
+            "docs" =>[
+                [
+                    "fileId" =>$fileId,
+                    "fileName" =>$fileName
+                ]
+            ],
+            "signFlowConfig" => [
+                "signFlowTitle" =>$signFlowTitle,
+                "autoStart"=>true,
+                "autoFinish"=>true,
+                'notifyUrl'=>route('adminApi.notify.esignNotify')
+            ],
+            "signers"=>$signers
+        ];
+//        dd($data);
+        $paramStr = json_encode($data);
+
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+//        EsignLogHelper::printMsg($response->getStatus());
+        EsignLogHelper::printMsg($response->getBody());
+        $signFlowId = false;
+        if($response->getStatus() == 200){
+            $result = json_decode($response->getBody());
+            if($result->code==0){
+                $signFlowId = $result->data->signFlowId;
+                EsignLogHelper::printMsg("基于文件发起签署接口调用成功,flowId: ".$signFlowId);
+            }else{
+                EsignLogHelper::printMsg("基于文件发起签署接口调用失败,错误信息: ".$result->message);
+            }
+        }else{
+            EsignLogHelper::printMsg("基于文件发起签署接口调用失败,HTTP错误码".$response->getStatus());
+        }
+        EsignLogHelper::printMsg("**********基于文件发起签署调用结束**********");
+        return $signFlowId;
+    }
+
+    /**
+     * 合同签署链接
+     * @param $flowId
+     * @param $psnAccount
+     * @param $orgName
+     * @return null
+     */
+    function getSignUrl($flowId,$psnAccount,$orgName){
+        EsignLogHelper::printMsg("**********获取合同文件签署链接开始**********");
+        $config=$this->config;
+
+        $apiaddr="/v3/sign-flow/%s/sign-url";
+        $apiaddr = sprintf($apiaddr,$flowId);
+        $requestType = HttpEmun::POST;
+        $data = [
+            "signFlowId" =>$flowId,
+            "clientType" =>"ALL",
+            "needLogin" =>false,
+            "operator" => [
+                "psnAccount" =>$psnAccount
+            ],
+            'organization'=>[
+                'orgName'=>$orgName
+            ],
+            "urlType" =>2
+        ];
+        $paramStr = json_encode($data);
+
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+
+        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+        EsignLogHelper::printMsg($response->getStatus());
+        EsignLogHelper::printMsg($response->getBody());
+        $url= null;
+        if($response->getStatus() == 200){
+            $url =  json_decode($response->getBody())->data->shortUrl;
+            EsignLogHelper::printMsg("获取合同文件签署链接调用成功,url: ".$url);
+        }else{
+            EsignLogHelper::printMsg("获取合同文件签署链接接口调用失败,HTTP错误码".$response->getStatus());
+        }
+        EsignLogHelper::printMsg("**********获取合同文件签署链接调用结束**********");
+        return  $url;
+    }
+}

+ 410 - 0
app/Servers/ESign/ESignFirmServer.php

@@ -0,0 +1,410 @@
+<?php
+
+
+namespace App\Servers\ESign;
+
+
+
+
+
+use App\Models\Firm;
+use App\Models\FirmSeal;
+use App\Models\Member;
+use App\Servers\ESign\comm\EsignHttpHelper;
+use App\Servers\ESign\comm\EsignLogHelper;
+use App\Servers\ESign\emun\HttpEmun;
+use App\Servers\System\CommonServer;
+use App\Servers\System\JobServer;
+use App\Servers\System\RedisDataServer;
+use App\Servers\System\SmsServer;
+
+class ESignFirmServer
+{
+    static private $server = null;
+
+    public  $config = [
+        'eSignAppId'=>'', //app id
+        'eSignAppSecret'=>'', // app key
+        'eSignHost'=>'https://smlopenapi.esign.cn', //模拟环境
+        //     'url'=>'https://openapi.esign.cn' //正式环境
+    ];
+
+    function __construct()
+    {
+            $this->config['eSignAppId']=env('E_SIGN_APP_ID');
+            $this->config['eSignAppSecret']=env('E_SIGN_APP_SECRET');
+            $this->config['eSignPublicKey']=env('E_SIGN_PUBLIC_KEY');
+            $this->config['eSignHost']=env('E_SIGN_HOST');
+    }
+
+    /**
+     * 创建对象
+     * @return ESignFirmServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new ESignFirmServer();
+        return self::$server;
+    }
+
+
+    /**
+     * 查询企业授权详情
+     * @param $orgId
+     * @return \App\Servers\ESign\comm\EsignResponse
+     */
+    function organizationsAuthorizedInfo($orgId){
+        $config=$this->config;
+        $apiaddr="/v3/organizations/".$orgId."/authorized-info";
+        $requestType = HttpEmun::GET;
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+        //发起接口请求
+        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        EsignLogHelper::printMsg($response->getStatus());
+        EsignLogHelper::printMsg($response->getBody());
+        return $response;
+    }
+
+    /**
+     * 查询企业实名状态
+     * @param $orgName
+     * @return mixed
+     */
+    function organizationsIdentityInfo($firm_id,$orgName){
+        $info =  Firm::where('id',$firm_id)->where('authType','ORG')->select(['realnameStatus','authorizeUserInfo','orgId'])->first();
+        if($info->{'realnameStatus'}==1  && $info->{'authorizeUserInfo'} == 1 && $info->{'orgId'}!=''){
+            return $info->{'realnameStatus'};
+        }
+
+        $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';
+        $requestType = HttpEmun::GET;
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+        //发起接口请求
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            //realnameStatus 0 - 未实名,1 - 已实名
+            $this->setSignFirm($ret['data']);
+
+            //realnameStatus 0 - 未实名,1 - 已实名
+            $realnameStatus = $ret['data']['realnameStatus'];
+            //true - 已授权,false - 未授权
+            $authorizeUserInfo = $ret['data']['authorizeUserInfo'] ? 1 : 0;
+            //个人账号ID
+            $orgId = $ret['data']['orgId'];
+            //更新认证信息
+            Firm::where('id',$firm_id)->where('authType','ORG')->update([
+                'realnameStatus'=>$realnameStatus,
+                'authorizeUserInfo'=>$authorizeUserInfo,
+                'orgId'=>$orgId,
+            ]);
+
+            if (empty($realnameStatus) || empty($authorizeUserInfo)){//走认证授权流程
+                $this->orgAuthUrl($firm_id,$orgName);
+            }
+        }else{//证明从来没有在e签宝注册过
+            //realnameStatus 0 - 未实名,1 - 已实名
+            $realnameStatus = 0;
+            //true - 已授权,false - 未授权
+            $authorizeUserInfo = 0;
+            //个人账号ID
+            $orgId = '';
+            //走认证授权流程
+            $this->orgAuthUrl($firm_id,$orgName);
+        }
+
+        return $realnameStatus;
+    }
+
+    /**
+     * 企业实名
+     * @param $orgName
+     */
+    function orgAuthUrl($firm_id,$orgName){
+        $authShortUrl=RedisDataServer::creatServer()->getData($firm_id.'_firmUrl');
+        if($authShortUrl){
+            return true;
+        }
+        $config=$this->config;
+        $apiaddr="/v3/org-auth-url";
+        $requestType = HttpEmun::POST;
+        $firm=Firm::where('id',$firm_id)->first();
+        $data=[
+            "orgAuthConfig"=>[
+                "orgName"=>$orgName,
+                "orgInfo"=>[
+                    "orgIDCardNum"=>$firm['license_number'],
+                    "legalRepName"=>$firm['legal_name'],
+                    "orgIDCardType"=>"CRED_ORG_USCC",
+
+                ],
+                "transactorInfo"=>[
+                    "psnAccount"=>$firm['phone'],
+                    "psnInfo"=>[
+                        "psnIDCardNum"=>$firm['legal_id_number'],
+                        "psnName"=>$firm['legal_name'],
+                        "psnIDCardType"=>"CRED_PSN_CH_IDCARD"
+                    ]
+                ],
+            ],
+            "authorizeConfig"=>[
+                "authorizedScopes"=>[
+                    "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('adminApi.notify.esignNotify'),
+            "clientType"=>"ALL",
+            "appScheme"=>""
+        ];
+        if($firm['auth_bank']){
+            $data['orgAuthConfig']['orgInfo']['orgBankAccountNum']=$firm['auth_bank'];
+            $data['orgAuthConfig']['orgAuthPageConfig']['orgDefaultAuthMode']='ORG_BANK_TRANSFER';
+            $data['orgAuthConfig']['orgAuthPageConfig']['orgAvailableAuthModes']=['ORG_BANK_TRANSFER'];
+        }else{
+            $data['orgAuthConfig']['orgInfo']['legalRepIDCardNum']=$firm['legal_id_number'];
+            $data['orgAuthConfig']['orgInfo']['legalRepIDCardType']='CRED_PSN_CH_IDCARD';
+        }
+        $paramStr = json_encode($data);
+        //生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //发起接口请求
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
+
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            $authShortUrl=RedisDataServer::creatServer()->getData($firm_id.'_firmUrl');
+            if($authShortUrl){
+                return true;
+            }
+            $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;
+        }
+    }
+
+    /**
+     * 企业授权
+     * @param $orgName
+     */
+    function orgAuthorizehUrl($orgName){
+        $config=$this->config;
+        $apiaddr="/v3/org-auth-url";
+        $requestType = HttpEmun::POST;
+        $data=[
+            "orgAuthConfig"=>[
+                "orgName"=>$orgName,
+                "orgInfo"=>[
+                    "orgIDCardNum"=>"",
+                    "orgIDCardType"=>" "
+
+                ],
+                "transactorInfo"=>[
+                    "psnAccount"=>"",
+                    "psnInfo"=>[
+                        "psnIDCardNum"=>"",
+                        "psnName"=>""
+                    ]
+                ],
+            ],
+            "authorizeConfig"=>[
+                "authorizedScopes"=>[
+                    "get_org_identity_info","get_psn_identity_info","org_initiate_sign","psn_initiate_sign","manage_org_resource","manage_psn_resource","use_org_order"
+                ]
+            ],
+            "notifyUrl"=>route('notify.esignNotify'),
+            "clientType"=>"ALL",
+            "appScheme"=>""
+        ];
+        $paramStr = json_encode($data);
+        //生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //发起接口请求
+        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+        EsignLogHelper::printMsg($response->getStatus());
+        EsignLogHelper::printMsg($response->getBody());
+    }
+
+
+
+    /**
+     * 获取企业内部使用签章列表
+     * @param $firmId
+     * @param $orgId
+     * @param $pageNum
+     * @return array|string[]
+     */
+    function internalAuthInfo($firmId,$orgId,$pageNum=1){
+
+        $config=$this->config;
+        $apiaddr="/v3/seals/org-own-seal-list?orgId=".$orgId."&pageNum={$pageNum}&pageSize=20";
+        $requestType = HttpEmun::GET;
+        //生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+        //发起接口请求
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            //存入签章信息
+            $this->setSealList($firmId,$ret['data']['seals']);
+            return ['code'=>'1','msg'=>'ok','data'=>['total'=>$ret['data']['total'],'items'=>$ret['data']['seals']]];
+        }else{
+            return ['code'=>'0','msg'=>$ret['message']];
+        }
+    }
+
+    /**
+     * 设置企业签章信息
+     * @param $firmId
+     * @param $list
+     * @return void
+     */
+    public function setSealList($firmId,$list)
+    {
+        if($list){
+            foreach ($list as $item){
+                $sealRow=[
+                    'firm_id'=>$firmId,
+                    'seal_id'=>$item['sealId'],
+                    'seal_name'=>$item['sealName'],
+                    'seal_type'=>$item['sealBizType'],
+                    'seal_status'=>$item['sealStatus'],
+                    'seal_url'=>$item['sealImageDownloadUrl'],
+                ];
+                $sealModel=FirmSeal::where('firm_id',$firmId)->where('seal_id',$item['sealId'])->first();
+                if(empty($sealModel)){
+                    $sealModel=FirmSeal::create($sealRow);
+                }else{
+                    $sealModel->update($sealRow);
+                }
+                $this->setSealImg($sealModel);
+            }
+        }
+    }
+
+
+    /**
+     * 保持印章图片
+     * @param FirmSeal $firmSeal
+     * @return void
+     */
+    function setSealImg(FirmSeal  $firmSeal)
+    {
+        $path=public_path('storage/seal/'.date('Ymd').'/');
+        if(!is_dir($path)){
+            mkdir($path,0777,true);
+        }
+        $name=$firmSeal['seal_id'].'.png';
+        file_put_contents($path.$name,file_get_contents($firmSeal['seal_url']));
+        $url=env('APP_URL').'/storage/seal/'.date('Ymd').'/'.$name;
+        $firmSeal->update(['seal_url'=>$url]);
+    }
+
+
+    /**
+     * 创建企业合同印章
+     * @param $firmId
+     * @param $orgId
+     * @return string[]|void
+     */
+    function createOrgsealsbyTemplate($firmId,$orgId){
+        $sealNum=FirmSeal::where('firm_id',$firmId)->where('seal_type','CONTRACT')->count();
+        if($sealNum>0){
+            return ['code'=>'0','msg'=>'合同印章已创建'];
+        }
+
+        $license_number=Firm::where('id',$firmId)->value('license_number');
+        $config=$this->config;
+        $apiaddr="/v3/seals/org-seals/create-by-template";
+        $requestType = HttpEmun::POST;
+//生成签名验签+json体的header
+        $data=[
+            "orgId"=>$orgId,
+            "sealName"=>"合同印章",//机构印章名称(用户自定义,且名称不可重复)
+            "sealTemplateStyle"=>"CONTRACT_ROUND_STAR",//机构模板印章样式
+            "sealSize"=>"38_38",
+            "sealColor"=>"RED",//机构印章颜色,默认是红色
+            "sealHorizontalText"=>"合同专用章",//自定义印章横向文,示例值:XX专用章
+            "sealBottomText" =>$license_number,//印章下弦文(实体印章防伪码),示例值:9133********1
+            "sealOpacity" =>80
+        ];
+        $paramStr = json_encode($data);
+        //请求参数
+        // EsignLogHelper::printMsg($paramStr);
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //发起接口请求头
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            //realnameStatus 0 - 未实名,1 - 已实名
+            FirmSeal::create([
+                'firm_id' => $firmId,
+                'seal_id' => $ret['data']['sealId'],
+                'seal_name' => "合同印章",
+                'seal_type' => 'CONTRACT'
+            ]);
+            //获取完成印章以后重新拉取一下印章信息
+            $this->internalAuthInfo($firmId,$orgId);
+            return ['code'=>'1','msg'=>'ok'];
+        }else{
+            return ['code'=>'0','msg'=>$ret['message']];
+        }
+    }
+
+
+    /**
+     * 添加企业机构成员
+     * @param $orgId
+     * @param $psnId
+     * @param $name
+     * @return void
+     */
+    function addMembers($orgId,$psnId,$name){
+        $config=$this->config;
+        $apiaddr="/v3/organizations/".$orgId."/members";
+        $requestType = HttpEmun::POST;
+        //生成签名验签+json体的header
+        $data=[
+            "members"=>[
+                [
+                    "psnId"=>$psnId,
+                    "memberName"=>$name,//员工昵称,用于区分企业成员
+                    'role'=>'4'
+                ]
+            ]
+        ];
+        $paramStr = json_encode($data);
+         EsignLogHelper::writeLog($paramStr);
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //发起接口请求
+        //发起接口请求
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+        EsignLogHelper::writeLog($response->getStatus());
+        EsignLogHelper::writeLog($response->getBody());
+    }
+
+
+
+}

+ 311 - 0
app/Servers/ESign/ESignServer.php

@@ -0,0 +1,311 @@
+<?php
+
+
+namespace App\Servers\ESign;
+
+
+
+use App\Models\Member;
+use App\Models\MemberSeal;
+use App\Servers\ESign\comm\EsignHttpHelper;
+use App\Servers\ESign\comm\EsignLogHelper;
+use App\Servers\ESign\emun\HttpEmun;
+use App\Servers\System\RedisDataServer;
+use App\Servers\System\SmsServer;
+
+class ESignServer
+{
+    static private $server = null;
+
+    public  $config = [
+        'eSignAppId'=>'', //app id
+        'eSignAppSecret'=>'', // app key
+        'eSignHost'=>'https://smlopenapi.esign.cn', //模拟环境
+//             'eSignHost'=>'https://openapi.esign.cn' //正式环境
+    ];
+
+    function __construct()
+    {
+            $this->config['eSignAppId']=env('E_SIGN_APP_ID');
+            $this->config['eSignAppSecret']=env('E_SIGN_APP_SECRET');
+            $this->config['eSignPublicKey']=env('E_SIGN_PUBLIC_KEY');
+            $this->config['eSignHost']=env('E_SIGN_HOST');
+    }
+
+    /**
+     * 创建对象
+     * @return ESignServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new ESignServer();
+        return self::$server;
+    }
+
+
+
+    /**
+     * @param $expireTime
+     * @return float
+     */
+    function expireTime($expireTime){
+        list($t1, $t2) = explode(' ', microtime());
+        $nowTime=(float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
+        $num=$expireTime-$nowTime;
+        return $num;
+    }
+
+    /**
+     * 获取个人认证&授权页面链接
+     * @return bool
+     */
+    function psnauthurl($m_id,$phone,$psnName,$id_number,$psnId='')
+    {
+        $authShortUrl=RedisDataServer::creatServer()->getData($m_id.'_memberUrl');
+        if($authShortUrl){
+            return true;
+        }
+        $config=$this->config;
+        $apiaddr="/v3/psn-auth-url";
+        $requestType = HttpEmun::POST;
+        $data=[
+            "psnAuthConfig"=>[
+                "psnAccount"=>$phone ??  '',
+                "psnId"=>$psnId,
+                "psnInfo" => [
+                    "psnName" => $psnName,
+                    "psnIDCardNum" => $id_number,
+                    "psnIDCardType" => "CRED_PSN_CH_IDCARD",
+                ],
+            ],
+            "authorizeConfig" =>[
+                "authorizedScopes" => [
+                    "get_psn_identity_info","psn_initiate_sign","manage_psn_resource","psn_sign_file_storage"
+                ],
+            ],
+            "redirectConfig"=>[
+                "redirectUrl"=>'',
+            ],
+            "notifyUrl"=>route('adminApi.notify.esignNotify'),
+            "clientType"=>"ALL",
+            "appScheme"=>""
+        ];
+        $paramStr = json_encode($data);
+        //生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //发起接口请求
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            $authShortUrl=RedisDataServer::creatServer()->getData($m_id.'_memberUrl');
+            if($authShortUrl){
+                return true;
+            }
+            $signMember=Member::where('id',$m_id)->where('authType','PSN')->where([['updated_at','<=',date('Y-m-d H:i:s',time()-600),'or'],['authShortUrl','=','','or']])->first();
+            if($signMember){
+                $authUrl = $ret['data']['authUrl'];
+                $authShortUrl = $ret['data']['authShortUrl'];
+                RedisDataServer::creatServer()->setData($m_id.'_memberUrl',$authShortUrl,'str',600);
+                $authFlowId = $ret['data']['authFlowId'];
+                $content='尊敬的'.$signMember['name'].',您有待认证信息,点击认证 '.$authShortUrl;
+                 SmsServer::creatServer()->sendContent($signMember['phone'],$content);
+                //存入数据库
+                $signMember->update([
+                    'authUrl'=>$authUrl,
+                    'authShortUrl'=>$authShortUrl,
+                    'authFlowId'=>$authFlowId,
+                ]);
+            }
+
+            return true;
+        }else{//认证授权错误
+            return false;
+        }
+    }
+
+    /**
+     * 查询个人认证信息
+     * @param $phone //手机号
+     * @param $psnName //认证人姓名
+     * @param $id_number //认证人身份证号
+     * @return SignMember|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|object|null
+     */
+    function personsidentityinfo($m_id,$phone,$psnName,$id_number)
+    {
+        $info =  Member::where('id_number',$id_number)->where('id',$m_id)->where('authType','PSN')->select(['realnameStatus','authorizeUserInfo','psnId'])->first();
+        if($info->{'realnameStatus'}==1 && $info->{'authorizeUserInfo'} == 1 && $info->{'psnId'}!=''){
+            return $info->{'realnameStatus'};
+        }
+
+        $config=$this->config;
+        $apiaddr="/v3/persons/identity-info?psnIDCardNum=".$id_number."&psnIDCardType=CRED_PSN_CH_IDCARD";
+        $requestType = HttpEmun::GET;
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+        //发起接口请求
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            //realnameStatus 0 - 未实名,1 - 已实名
+            $realnameStatus = $ret['data']['realnameStatus'];
+            //true - 已授权,false - 未授权
+            $authorizeUserInfo = $ret['data']['authorizeUserInfo'] ? 1 : 0;
+            //个人账号ID
+            $psnId = $ret['data']['psnId'];
+            //更新认证信息
+            Member::where('id_number',$id_number)->update([
+                'realnameStatus'=>$realnameStatus,
+                'authorizeUserInfo'=>$authorizeUserInfo,
+                'psnId'=>$psnId,
+            ]);
+            if (empty($realnameStatus) || empty($authorizeUserInfo)){//走个人认证授权流程
+                $this->psnauthurl($m_id,$phone,$psnName,$id_number,$psnId);
+            }
+            //未授权也注销
+            if(empty($authorizeUserInfo))$realnameStatus=0;
+        }else{//证明从来没有在e签宝注册过
+            //realnameStatus 0 - 未实名,1 - 已实名
+            $realnameStatus = 0;
+            //true - 已授权,false - 未授权
+            $authorizeUserInfo = 0;
+            //个人账号ID
+            $psnId = '';
+            //走认证授权流程
+            $this->psnauthurl($m_id,$phone,$psnName,$id_number);
+        }
+
+        return $realnameStatus;
+    }
+
+
+    /**
+     * 获取用户签章列表
+     * @param $mId
+     * @param $psnId
+     * @param $pageNum
+     * @return array|string[]
+     */
+    function internalAuthInfo($mId,$psnId,$pageNum=1){
+
+        $config=$this->config;
+        $data['psnId'] = $psnId;
+        $data['pageNum'] = $pageNum;
+        $data['pageSize'] = 20;
+
+        ksort($data);
+        $apiaddr="/v3/seals/psn-seal-list?".http_build_query($data);
+//        var_dump($apiaddr);
+        $requestType = HttpEmun::GET;
+        //生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+//        dd($signAndBuildSignAndJsonHeader);
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        //发起接口请求
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        $ret=json_decode($response->getBody(),true);
+
+        if(isset($ret['code']) && $ret['code']==0){
+            //存入签章信息
+            $this->setMemberSealList($mId,$ret['data']['seals'],1);
+            return ['code'=>'1','msg'=>'ok','data'=>['total'=>$ret['data']['total'],'items'=>$ret['data']['seals']]];
+        }else{
+            return ['code'=>'0','msg'=>$ret['message']];
+        }
+    }
+
+
+
+    /**
+     * 设置企业签章信息
+     * @param $mId
+     * @param $list
+     * @param $useType
+     * @return void
+     */
+    public function setMemberSealList($mId,$list)
+    {
+        if($list){
+            foreach ($list as $item){
+                $sealRow=[
+                    'm_id'=>$mId,
+                    'seal_id'=>$item['sealId'],
+                    'seal_name'=>$item['sealName'],
+                    'seal_status'=>$item['sealStatus'],
+                    'seal_url'=>$item['sealImageDownloadUrl'],
+                ];
+                $sealModel=MemberSeal::where('m_id',$mId)->where('seal_id',$item['sealId'])->first();
+                if(empty($sealModel)){
+                    $sealModel=MemberSeal::create($sealRow);
+                }else{
+                    $sealModel->update($sealRow);
+                }
+                $this->setSealImg($sealModel);
+            }
+        }
+    }
+
+
+    /**
+     * 保持印章图片
+     * @param MemberSeal $memberSeal
+     * @return void
+     */
+    function setSealImg(MemberSeal  $memberSeal)
+    {
+        $path=public_path('storage/memberSeal/'.date('Ymd').'/');
+        if(!is_dir($path)){
+            mkdir($path,0777,true);
+        }
+        $name=$memberSeal['seal_id'].'.png';
+        file_put_contents($path.$name,file_get_contents($memberSeal['seal_url']));
+        $url=env('APP_URL').'/storage/memberSeal/'.date('Ymd').'/'.$name;
+        $memberSeal->update(['seal_url'=>$url]);
+    }
+
+
+
+    /**
+     * 创建合同印章
+     * @param $mId
+     * @param $psnId
+     * @return string[]|void
+     */
+    function createOrgsealsbyTemplate($mId,$psnId){
+        $sealNum=MemberSeal::where('m_id',$mId)->count();
+        if($sealNum>0){
+            return ['code'=>'0','msg'=>'印章已创建'];
+        }
+
+        $config=$this->config;
+        $apiaddr="/v3/seals/psn-seals/create-by-template";
+        $requestType = HttpEmun::POST;
+//生成签名验签+json体的header
+        $data=[
+            "psnId"=>$psnId,
+            "sealName"=>"合同印章",//机构印章名称(用户自定义,且名称不可重复)
+            "sealTemplateStyle"=>"RECTANGLE_NO_BORDER",//机构模板印章样式
+            "sealSize"=>"20_10",
+            "sealColor"=>"RED",//机构印章颜色,默认是红色
+            "sealOpacity" =>80
+        ];
+        $paramStr = json_encode($data);
+        //请求参数
+        // EsignLogHelper::printMsg($paramStr);
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
+        //发起接口请求头
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            //realnameStatus 0 - 未实名,1 - 已实名
+            MemberSeal::create([
+                'm_id' => $mId,
+                'seal_id' => $ret['data']['sealId'],
+            ]);
+            //获取完成印章以后重新拉取一下印章信息
+            $this->internalAuthInfo($mId,$psnId);
+            return ['code'=>'1','msg'=>'ok'];
+        }else{
+            return ['code'=>'0','msg'=>$ret['message']];
+        }
+    }
+}

+ 102 - 0
app/Servers/ESign/comm/EsignHttpCfgHelper.php

@@ -0,0 +1,102 @@
+<?php
+namespace App\Servers\ESign\comm;
+
+/**
+ * 网络请求配置工具类
+ * @author  澄泓
+ * @date  2022/08/18 14:27
+ */
+class EsignHttpCfgHelper
+{
+    public static $connectTimeout = 15;//15 second
+    public static $readTimeout = 15;//15 second
+    public static $uploadReadTimeout = 60;
+    public static $uploadConnectTimeout = 60;
+    public static $enableHttpProxy=false;//是否需要代理
+    public static $httpProxyIp;//代理ip
+    public static $httpProxyPort;//代理端口
+
+    //常规请求类
+    public static function sendHttp($reqType, $url, $headers, $param=null)
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $reqType);
+        if (self::$enableHttpProxy) {
+            curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC);
+            curl_setopt($ch, CURLOPT_PROXY, self::$httpProxyIp);
+            curl_setopt($ch, CURLOPT_PROXYPORT, self::$httpProxyPort);
+            curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
+        }
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_FAILONERROR, false);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+        $postData = is_array($param) ? json_encode($param, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) : $param;
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
+        if (self::$readTimeout) {
+            curl_setopt($ch, CURLOPT_TIMEOUT, self::$readTimeout);
+        }
+        if (self::$connectTimeout) {
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, self::$connectTimeout);
+        }
+        //https request
+        if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") {
+            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        }
+        if (is_array($headers) && 0 < count($headers)) {
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+        }
+        $curlRes = curl_exec($ch);
+
+        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
+        curl_close($ch);
+        return new EsignResponse($httpCode,$curlRes);
+    }
+
+    /**
+     * 上传文件
+     * @param $uploadUrls
+     * @param $contentMd5
+     * @param $fileContent
+     * @param $ContenType
+     * @return EsignResponse
+     */
+        public static function upLoadFileHttp($uploadUrls, $contentMd5, $fileContent,$ContenType){
+            $header = array(
+                'Content-Type:'.$ContenType,
+                'Content-Md5:' . $contentMd5
+            );
+
+            $curl_handle = curl_init();
+            curl_setopt($curl_handle, CURLOPT_URL, $uploadUrls);
+            curl_setopt($curl_handle, CURLOPT_FILETIME, true);
+            curl_setopt($curl_handle, CURLOPT_FRESH_CONNECT, false);
+           // curl_setopt($curl_handle, CURLOPT_HEADER, true); // 输出HTTP头 true
+            curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
+
+            if (self::$uploadReadTimeout) {
+                curl_setopt($curl_handle, CURLOPT_TIMEOUT, self::$uploadReadTimeout);
+            }
+            if (self::$uploadConnectTimeout) {
+                curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, self::$uploadConnectTimeout);
+            }
+
+            curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
+            curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false);
+
+            curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $header);
+            curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT');
+
+            curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $fileContent);
+            if (is_array($header) && 0 < count($header)) {
+                curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $header);
+            }
+            $curlRes = curl_exec($curl_handle);
+            $httpCode = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
+
+            curl_close($curl_handle);
+            return new EsignResponse($httpCode,$curlRes);
+    }
+
+
+}

+ 140 - 0
app/Servers/ESign/comm/EsignHttpHelper.php

@@ -0,0 +1,140 @@
+<?php
+namespace App\Servers\ESign\comm;
+
+/**
+ * esignHttp请求类
+ * @author  澄泓
+ * @date  2022/08/18 15:10
+ */
+class EsignHttpHelper
+{
+    /**
+     * 常规请求
+     * @param $host
+     * @param $url
+     * @param $reqType
+     * @param $header
+     * @param $paramStr
+     * @return EsignResponse
+     */
+    public static function doCommHttp($host, $url, $reqType, $header, $paramStr)
+    {
+        //做encode编码防止中文乱码
+        $url = EsignHttpHelper::querySort($url, true);
+        return EsignHttpCfgHelper::sendHttp($reqType, $host . $url, $header, $paramStr);
+    }
+
+    /**
+     * 文件上传
+     * @param $uploadUrls
+     * @param $filePath
+     * @param $ContenType
+     * @return EsignResponse
+     */
+    public static function upLoadFileHttp($uploadUrls, $filePath, $ContenType)
+    {
+        $fileContent = file_get_contents($filePath);
+        $contentBase64Md5 = EsignUtilHelper::getContentBase64Md5($filePath);
+        return EsignHttpCfgHelper::upLoadFileHttp($uploadUrls, $contentBase64Md5, $fileContent, $ContenType);
+    }
+
+
+    /**
+     * 签名计算并且构建一个签名鉴权+json数据的esign请求头
+     * @param $projectId
+     * @param $secret
+     * @param $paramStr
+     * @param $reqType
+     * @param $url
+     * @param string $accept
+     * @param string $contentType
+     * @return array
+     */
+    public static function signAndBuildSignAndJsonHeader($projectId, $secret, $paramStr, $reqType, $url,$accept="*/*",$contentType="application/json; charset=UTF-8")
+    {
+        $contentMd5="";
+
+        //get和delete方式请求不能携带body体
+        if (strtoupper($reqType) == "GET" || strtoupper($reqType) == "DELETE") {
+            $paramStr=null;
+        }else{
+            $contentMd5 = EsignUtilHelper::getContentMd5($paramStr);
+        }
+        //对body体做md5摘要
+        //构造一个初步请求头
+        $buildSignAndJsonHeader = self::buildSignAndJsonHeader($projectId, $contentMd5, $accept, $contentType, "Signature");
+
+        //对url做排序
+        self::querySort($url);
+        //传入生成的bodyMd5,加上其他请求头部信息拼接成字符串,整体做sha256签名
+        $reqSignature = EsignUtilHelper::getSignature($secret, $reqType, $accept, $contentType, $contentMd5, "", "", $url);
+        array_push($buildSignAndJsonHeader,"X-Tsign-Open-Ca-Signature:".$reqSignature);
+        return $buildSignAndJsonHeader;
+}
+
+    /**
+     * 建一个签名鉴权+json数据的esign初步请求头
+     * @param $projectId
+     * @param $contentMD5
+     * @param $accept
+     * @param $contentType
+     * @param $authMode
+     * @return array
+     */
+    public static function buildSignAndJsonHeader($projectId, $contentMD5, $accept, $contentType, $authMode)
+    {
+        $headers = array(
+            'X-Tsign-Open-App-Id:'.$projectId,
+            'X-Tsign-Open-Ca-Timestamp:'.EsignUtilHelper::getMillisecond(),
+            'Accept:'.$accept,
+            'Content-Type:'.$contentType,
+            'X-Tsign-Open-Auth-Mode:'.$authMode,
+            'X-Tsign-Dns-App-Id:'.$projectId
+        );
+        if(!empty($contentMD5)){
+            array_push($headers,'Content-MD5:'.$contentMD5);
+        }
+        return $headers;
+    }
+
+
+    public static function querySort($url,$isEncode=false){
+        #存在query参数
+        if (!strpos($url, "?") === false) {
+            $query_arr = [];
+            $url_path = substr($url, 0, strpos($url, "?"));
+            $url_query = substr($url, strpos($url, "?") + 1, mb_strlen($url));
+            parse_str($url_query, $query_arr);
+            ksort($query_arr);
+            //reset()内部指针指向数组中的第一个元素
+            reset($query_arr);
+            $query_str = http_build_query($query_arr);
+            if(!$isEncode){
+                $query_str = urldecode($query_str);
+            }
+            $url = $url_path . '?' . $query_str;
+            return $url;
+        }
+        return $url;
+    }
+    /**
+     * 构造头部信息
+     * @param $contentMD5
+     * @param $reqSignature
+     * @return array
+     */
+    public static function buildCommHeader($projectId, $contentMD5, $reqSignature)
+    {
+        $headers = array(
+            'X-Tsign-Open-App-Id:' . $projectId,
+            'X-Tsign-Open-Ca-Timestamp:' . EsignUtilHelper::getMillisecond(),
+            'Accept:*/*',
+            'X-Tsign-Open-Ca-Signature:' . $reqSignature,
+            'Content-MD5:' . $contentMD5,
+            'Content-Type:application/json; charset=UTF-8',
+            'X-Tsign-Open-Auth-Mode:Signature'
+        );
+        return $headers;
+    }
+
+}

+ 32 - 0
app/Servers/ESign/comm/EsignLogHelper.php

@@ -0,0 +1,32 @@
+<?php
+namespace App\Servers\ESign\comm;
+
+/**
+ * esign日志类
+ * @author  澄泓
+ * @date  2022/08/18 15:10
+ */
+class EsignLogHelper
+{
+    static function writeLog($text,$type=1) {
+        if(is_array($text) || is_object($text)){
+            $text = json_encode($text);
+        }
+        $logDir = public_path('/storage/e-sign/log/'.$type.'/'.date('Ymd').'/')  ;
+        if(!is_dir($logDir)){
+            mkdir($logDir,0777,true);
+        }
+        file_put_contents ( $logDir.date("Y-m-d").".log", date("Y-m-d H:i:s") . "  日志" . $text . "\r\n------------------\r\n", FILE_APPEND );
+    }
+
+    static function  printMsg($msg)
+    {
+        echo "<pre/>";
+        if (is_array($msg) || is_object($msg)) {
+            var_dump($msg);
+        } else {
+            echo $msg . "\n";
+        }
+    }
+
+}

+ 62 - 0
app/Servers/ESign/comm/EsignResponse.php

@@ -0,0 +1,62 @@
+<?php
+
+
+namespace App\Servers\ESign\comm;
+/**
+ * esign响应
+ * @author  澄泓
+ * @date  2022/08/18 9:51
+ */
+
+class EsignResponse
+{
+    private $status;
+    private $body;
+
+    /**
+     * EsignResponse constructor.
+     * @param $status
+     * @param $body
+     */
+    public function __construct($status, $body)
+    {
+        $this->status = $status;
+        $this->body = $body;
+    }
+
+
+
+    /**
+     * @return mixed
+     */
+
+    public function getStatus()
+    {
+        return $this->status;
+    }
+
+    /**
+     * @param mixed $status
+     */
+    public function setStatus($status)
+    {
+        $this->status = $status;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getBody()
+    {
+        return $this->body;
+    }
+
+    /**
+     * @param mixed $body
+     */
+    public function setBody($body)
+    {
+        $this->body = $body;
+    }
+
+}

+ 94 - 0
app/Servers/ESign/comm/EsignUtilHelper.php

@@ -0,0 +1,94 @@
+<?php
+namespace App\Servers\ESign\comm;
+
+/**
+ * 常用工具类
+ * @author  澄泓
+ * @date  2022/08/18 15:40
+ */
+class EsignUtilHelper
+{
+    /**
+     * 获取MD5
+     * @param $bodyData
+     * @return string
+     */
+    public static function getContentMd5($bodyData){
+        return  base64_encode(md5($bodyData,true));
+    }
+
+    /**
+     * 生成签名
+     * @param $projectScert
+     * @param $httpMethod
+     * @param $accept
+     * @param $contentType
+     * @param $contentMd5
+     * @param $date
+     * @param $headers
+     * @param $url
+     * @return string
+     */
+    public static function getSignature($projectScert,$httpMethod,$accept,$contentType,$contentMd5,$date,$headers,$url){
+
+        $stringToSign = $httpMethod . "\n" . $accept . "\n"  . $contentMd5 . "\n" . $contentType . "\n"  . $date . "\n" .$headers  ;
+        if($headers != ''){
+            $stringToSign .= "\n".$url;
+        }else{
+            $stringToSign .= $url;
+        }
+//        EsignLogHelper::printMsg($stringToSign);
+        $signature = hash_hmac("sha256",$stringToSign, $projectScert, true);
+        $signature = base64_encode($signature);
+        return $signature;
+    }
+
+
+    // 判断是网络路径还是文件路径
+    public static function isUrl($url){
+        $parse = parse_url($url);
+        $scheme = $parse['scheme'];
+        $scheme = strtolower($scheme);
+        if("http" == $scheme){
+            return true;
+        }
+
+        if("https" == $scheme){
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 生成13位时间戳
+     * @return float
+     */
+    public static function getMillisecond() {
+        list($t1, $t2) = explode(' ', microtime());
+        return (float)sprintf('%.0f',(floatval($t1)+floatval($t2))*1000);
+    }
+
+    public static function jsonSer($obj){
+    $json = array();
+    foreach ($obj as $key => $value) {
+        if($value==null) {
+            continue;
+        }
+        $json[$key] = $value;
+    }
+    return $json;
+    }
+
+    /**
+    获取文件的Content-MD5
+    原理:1.先计算MD5加密的二进制数组(128位)
+    2.再对这个二进制进行base64编码(而不是对32位字符串编码)
+     */
+    public static function getContentBase64Md5($filePath){
+        //获取文件MD5的128位二进制数组
+        $md5file = md5_file($filePath,true);
+        //计算文件的Content-MD5
+        $contentBase64Md5 = base64_encode($md5file);
+        return $contentBase64Md5;
+    }
+}

+ 14 - 0
app/Servers/ESign/emun/HttpEmun.php

@@ -0,0 +1,14 @@
+<?php
+namespace App\Servers\ESign\emun;
+/**
+ * 请求方法枚举
+ * @author  澄泓
+ * @date  2020/11/19 17:34
+ */
+class HttpEmun
+{
+    const PUT="PUT";
+    const POST="POST";
+    const GET="GET";
+    const DELETE="DELETE";
+}

+ 36 - 0
app/Servers/Logs/AdminLogsServer.php

@@ -0,0 +1,36 @@
+<?php
+
+
+namespace App\Servers\Logs;
+
+
+use App\Models\AdminLog;
+use App\Servers\System\CommonServer;
+use Illuminate\Support\Facades\Auth;
+
+class AdminLogsServer
+{
+
+
+    /**
+     * 后台日志记录
+     * @param string $msg
+     * @return AdminLog|\Illuminate\Database\Eloquent\Model
+     */
+    static public function write($msg='')
+    {
+        $m_id=Auth::id()?:0;
+        $url = request()->url();
+        $data=request()->all();
+        $ip=CommonServer::creatServer()->getClientIp();
+        return AdminLog::create(
+            [
+                'm_id' => $m_id,
+                'url' => $url,
+                'msg' => $msg,
+                'ip' => $ip,
+                'data' => http_build_query($data),
+            ]
+        );
+    }
+}

+ 74 - 0
app/Servers/Logs/MemberLogsServer.php

@@ -0,0 +1,74 @@
+<?php
+
+
+namespace App\Servers\Logs;
+
+
+use App\Models\MemberLog;
+use App\Servers\System\CommonServer;
+use Illuminate\Support\Facades\Auth;
+
+class MemberLogsServer
+{
+    static private $server = null;
+
+    /**
+     * 创建对象
+     * @return MemberLogsServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new MemberLogsServer();
+        return self::$server;
+    }
+
+
+    /**
+     * 添加用户日志信息
+     * @param $m_id
+     * @param $firmId
+     * @param $msg
+     * @return void
+     */
+    function log($m_id,$firmId=0,$msg='')
+    {
+        MemberLog::create(
+            [
+                'm_id' => $m_id,
+                'firm_id' => $firmId,
+                'url' => '',
+                'msg' => $msg,
+                'ip' => '',
+                'data' => '',
+            ]
+        );
+    }
+
+    /**
+     * 会员日志
+
+     * @return $this|\Illuminate\Database\Eloquent\Model
+     */
+    static public function write()
+    {
+        if('common.base64'==request()->route()->getName()){
+//            return  1;
+        }
+        $m_id=request()->member['id'];
+        if(empty($m_id) || !is_numeric($m_id))$m_id=0;
+        $url = request()->url();
+        $data=request()->all();
+        $ip=CommonServer::creatServer()->getClientIp();
+        //广播弹幕-进入队列
+        return MemberLog::create(
+            [
+                'm_id' => $m_id,
+                'url' => $url,
+                'firm_id' => '0',
+                'msg' => '',
+                'ip' => $ip,
+                'data' => http_build_query($data),
+            ]
+        );
+    }
+}

+ 110 - 0
app/Servers/System/BaiduServer.php

@@ -0,0 +1,110 @@
+<?php
+
+
+namespace App\Servers\System;
+
+
+
+use End01here\BaiDuOrc\BaiDuOrcService;
+
+/**
+ * Redis数据缓存类
+ */
+class BaiduServer
+{
+
+    /**
+     * 错误信息
+     * @var string
+     */
+    private $errorMsg = '';
+
+    static private $server = null;
+    private $baiduServer = null;
+
+
+    private function __construct()
+    {
+
+        $this->baiduServer = BaiDuOrcService::getOrcServer();
+    }
+
+    /**
+     * 创建对象
+     * @return BaiduServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new BaiduServer();
+        return self::$server;
+    }
+
+
+    /**
+     * 身份证号码识别
+     * @param $imgUrl
+     * @param $idCardSide
+     */
+    function idCard($imgUrl,$idCardSide='front'){
+        // 如果有可选参数
+        $options = array();
+        $options["detect_direction"] = "true";
+        $options["detect_risk"] = "false";
+
+        // 带参数调用身份证识别
+        $data= $this->baiduServer->idcard($imgUrl, $idCardSide, $options);
+        if(!empty($data['image_status']) && $data['image_status']=='normal'){
+            if($idCardSide=='front'){
+                $userData['name']=$data['words_result']['姓名']['words'];
+                $userData['sex']=$data['words_result']['性别']['words'];
+                $userData['id_number']=$data['words_result']['公民身份号码']['words'];
+                $userData['birthday']=$data['words_result']['出生']['words'];
+            }else{
+                $userData['validity_start']=$data['words_result']['签发日期']['words'];
+                $userData['validity_end']=$data['words_result']['失效日期']['words'];
+            }
+            if(empty($userData)){
+                return ['code'=>0,'msg'=>'身份证识别失败','data'=>[]];
+            }else{
+                return ['code'=>1,'msg'=>'身份证识别成功','data'=>$userData];
+            }
+        }else{
+            return ['code'=>0,'msg'=>'身份证识别失败','data'=>[]];
+        }
+    }
+
+
+    /**
+     * 营业执照识别
+     * @param $imgUrl
+     * @return array
+     */
+    function businessLicense($imgUrl){
+        //营业执照识别
+        $data= $this->baiduServer->businessLicense($imgUrl);
+
+        if(!empty($data['words_result_num']) && $data['words_result_num']>0){
+            $cardData=$data['words_result'];
+
+            $userData['id_number']=empty($cardData['社会信用代码'])?'':$cardData['社会信用代码']['words'];
+            $userData['name']=empty($cardData['单位名称'])?'':$cardData['单位名称']['words'];
+            $userData['registered_capital']=empty($cardData['注册资本'])?'':$cardData['注册资本']['words'];
+            $userData['address']=empty($cardData['地址'])?'':$cardData['地址']['words'];
+            $userData['registration_date']=empty($cardData['成立日期'])?'':$cardData['成立日期']['words'];
+            $userData['firm_type']=empty($cardData['类型'])?'':$cardData['类型']['words'];
+            $userData['paid_capital']=empty($cardData['实收资本'])?'':$cardData['实收资本']['words'];
+
+            if(empty($userData)){
+                return ['code'=>0,'msg'=>'营业执照识别失败','data'=>[]];
+            }else{
+                return ['code'=>1,'msg'=>'营业执照识别成功','data'=>$userData];
+            }
+        }else{
+            return ['code'=>0,'msg'=>'营业执照识别失败','data'=>[]];
+        }
+
+    }
+
+
+
+}

+ 466 - 0
app/Servers/System/CommonServer.php

@@ -0,0 +1,466 @@
+<?php
+
+
+namespace App\Servers\System;
+
+use AlibabaCloud\Client\AlibabaCloud;
+use AlibabaCloud\Client\Exception\ClientException;
+use AlibabaCloud\Client\Exception\ServerException;
+use App\Models\Config;
+use App\Models\Region;
+use Carbon\Carbon;
+use Illuminate\Support\Facades\Storage;
+use QCloud\COSSTS\Sts;
+
+
+/**
+ * Redis数据缓存类
+ */
+class CommonServer
+{
+
+    /**
+     * 错误信息
+     * @var string
+     */
+    private $errorMsg = '';
+
+    static private $server = null;
+
+
+    private function __construct()
+    {
+
+    }
+
+    /**
+     * 创建对象
+     * @return CommonServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new CommonServer();
+        return self::$server;
+    }
+
+    /**
+     * 验证手机号码格式
+     * @param $phone
+     * @return bool
+     */
+    public function verifyPhoneNumber($phone)
+    {
+        if (empty($phone)) return false;
+        if (!preg_match('#^[\d]{11,11}$#', $phone)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 字符串去标签过滤及空格过滤
+     * @param $str_name
+     * @param $default
+     * @return string
+     */
+    function filtrationStr($str_name, $default = '')
+    {
+        $str = request()->input($str_name, $default);
+        if (empty($str)) return $str;
+        if (!is_string($str)) {
+            $str = json_encode($str);
+            $str = strip_tags($str);
+            $str = trim($str);
+            $str = json_decode($str, true);
+        } else {
+            $str = strip_tags($str);
+            $str = trim($str);
+        }
+        return $str;
+    }
+
+    /**
+     * 获取城市名称
+     * @param string $province_id
+     * @param string $city_id
+     * @param string $area_id
+     * @return string
+     */
+    function getCityName($province_id = '', $city_id = '', $area_id = '')
+    {
+        $ids = [$province_id, $city_id, $area_id];
+        $ids = array_filter($ids);
+        if (empty($ids)) return '';
+        $city_name = Region::whereIn('id', $ids)->orderBy('id', 'asc')->pluck('name')->toArray();
+        $city_name = implode(' ', $city_name);
+        return $city_name;
+
+    }
+
+
+    /**
+     * 字符串屏蔽
+     * @param $str
+     * @param int $start_key 开始位置
+     * @param int $end_key 尾数开始位置
+     * @param int $start_num 截取位数
+     * @param int $end_num 倒数截取位数
+     * @param int $conceal_num 最大填充数量
+     * @return string
+     */
+    function concealStr($str, $start_key = 0, $end_key = 1, $start_num = 1, $end_num = 1, $conceal_num = 3)
+    {
+        $str_len = mb_strlen($str);
+
+        $start_str = '';
+        $end_str = '';
+        if (($str_len - $start_num - $end_num) < $conceal_num) {
+            $conceal_num = $str_len - $start_num - $end_num;
+        }
+        $conceal_str = $this->getRandChar($conceal_num, '*');
+        if (empty($conceal_str)) $conceal_str = '*';
+        if ($str_len >= $start_key) {
+            $start_str = mb_substr($str, $start_key, $start_num);
+        }
+        if ($str_len > $end_key) {
+            $end_str = mb_substr($str, $end_key * -1, $end_num);
+        }
+        return $start_str . $conceal_str . $end_str;
+    }
+
+
+    /**
+     * 获取随机字符串
+     * @param int $length
+     * @param string $strPol
+     * @return string|null
+     */
+    public function getRandChar($length = 6, $strPol = '')
+    {
+        if ($length <= 0) $length = 1;
+        $str = null;
+        if (empty($strPol)) $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
+        $max = strlen($strPol) - 1;
+        for ($i = 0; $i < $length; $i++) {
+            $str .= $strPol[rand(0, $max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
+        }
+        return $str;
+    }
+
+    /**
+     * 获取数据库配置信息
+     * @param $key
+     * @return mixed
+     */
+    function getConfigValue($key)
+    {
+        return Config::where('key', $key)->value('value');
+    }
+
+    /**
+     * 创建文件夹
+     * @param $dir
+     * @return bool
+     */
+    function creatDir($dir)
+    {
+        if ($dir == '') return false;
+        if (!file_exists(public_path($dir))) {
+            mkdir(public_path($dir), 0777, true);
+            chmod(public_path($dir), 0777);
+        }
+        return true;
+    }
+
+
+
+
+
+
+
+
+    /**
+     * 验证是否微信浏览器
+     * @return bool
+     */
+    function isWeixin()
+    {
+        $http_user_agent = request()->header('user-agent');
+        if (strpos($http_user_agent, 'MicroMessenger') !== false) {
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * 格式化小数位数
+     * @param $num
+     * @param int $digit
+     * @return string
+     */
+    function setFloatNum($num, $digit = 4)
+    {
+        return sprintf("%.{$digit}f", $num);
+    }
+
+    /**
+     * 获取真实IP
+     * @return mixed
+     */
+    function getClientIp()
+    {
+        $http_x_forwarded_for = request()->header('x-forwarded-for');
+        if (empty($http_x_forwarded_for)) {
+            return request()->getClientIp();
+        } else {
+            $http_x_forwarded_for = explode(',', $http_x_forwarded_for);
+            return $http_x_forwarded_for[0];
+        }
+    }
+
+
+    function delDir($dir)
+    {
+        //先删除目录下的文件:
+        $dh = opendir($dir);
+        while ($file = readdir($dh)) {
+            if ($file != "." && $file != "..") {
+                $fullpath = $dir . "/" . $file;
+                if (!is_dir($fullpath)) {
+                    unlink($fullpath);
+                } else {
+                    $this->deldir($fullpath);
+                }
+            }
+        }
+
+        closedir($dh);
+        //删除当前文件夹:
+        if (rmdir($dir)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 图片base64
+     * @param $image_file
+     * @return string
+     */
+    function base64EncodeImage($image_file)
+    {
+        $image_info = getimagesize($image_file);
+        $image_data = fread(fopen($image_file, 'r'), filesize($image_file));
+        $base64_image = 'data:' . $image_info['mime'] . ';base64,' . chunk_split(base64_encode($image_data));
+        return $base64_image;
+    }
+
+
+    /**
+     * 获取文件名
+     * @param $url
+     * @return string
+     */
+    function getFileName($url)
+    {
+        $name = basename($url);
+        return empty($name) ? '' : $name;
+    }
+
+
+
+
+
+    /**
+     * @param $url
+     * @param string $type 请求方式
+     * @param string $data 数据 数组格式
+     * @param $head
+     * @param $retType
+     * @return mixed
+     */
+    function sendRequest($url, $data = '', $type = 'get',$head=[],$retType='json')
+    {
+
+        $ch = curl_init();
+        if ($type == 'get' && $data) {
+            $url = $url . '?' . http_build_query($data);
+        }
+//        dump(date('Y-m-d H:i:s'));
+//        dump($url);
+
+        curl_setopt($ch, CURLOPT_URL, $url); //设置访问路径
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //设置可以返回字符串
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+        if(empty($head)){
+            $head = [
+                'User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
+                'Content-Type: application/json'
+            ];
+        }
+//        curl_setopt($ch, CURLINFO_HEADER_OUT, true);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $head);
+        if ($type == 'post') {
+            curl_setopt($ch, CURLOPT_POST, TRUE);//post请求
+            $data = json_encode($data, JSON_UNESCAPED_UNICODE);
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);//设置传递的参数
+        }
+        $request = curl_exec($ch);
+//        $header_size = curl_getinfo($ch,);
+//        dump($request);
+        if($request){
+            if($retType=='gzip'){
+                $request=gzdecode($request);
+            }
+            $request=json_decode($request,true);
+        }
+//        dump($request);
+//        dump(date('Y-m-d H:i:s'));
+        curl_close($ch);
+        return $request;
+    }
+
+    function lockCapitalRoutes($mId,$routeName,$type){
+        $routeArr=   [
+
+            'withdraw.add',//提现
+        ];
+        if(in_array($routeName,$routeArr)){
+            $redisName=$mId.'lockCapital';
+            if($type){
+                $row=  RedisDataServer::creatServer()->getData($redisName);
+                $isOutput=  RedisDataServer::creatServer()->getData('dateOutput');
+                if($row || $isOutput){
+                    return false;
+                }
+                RedisDataServer::creatServer()->setData($redisName,time(),'str',3,false);
+            }else{
+                RedisDataServer::creatServer()->delData($redisName);
+            }
+        }
+        return true;
+    }
+
+
+
+
+    function getTxySts()
+    {
+        $data = RedisDataServer::creatServer()->getData('txy_sts_data');
+        if ($data) {
+            $data = json_decode($data, true);
+        } else {
+            $sts = new Sts();
+            $accessKeyId = env('TXY_OSS_ACCESS_ID');
+            $accessSecret = env('TXY_OSS_ACCESS_KEY');
+            $config = array(
+                'url' => 'https://sts.tencentcloudapi.com/', // url和domain保持一致
+                'domain' => 'sts.tencentcloudapi.com', // 域名,非必须,默认为 sts.tencentcloudapi.com
+                'proxy' => '',
+                'secretId' => $accessKeyId, // 固定密钥,若为明文密钥,请直接以'xxx'形式填入,不要填写到getenv()函数中
+                'secretKey' => $accessSecret, // 固定密钥,若为明文密钥,请直接以'xxx'形式填入,不要填写到getenv()函数中
+                'bucket' => env('COSV5_BUCKET'), // 换成你的 bucket
+                'region' => env('COSV5_REGION'), // 换成 bucket 所在园区
+                'durationSeconds' => 1800, // 密钥有效期
+                'allowPrefix' => ['/'], // 这里改成允许的路径前缀,可以根据自己网站的用户登录态判断允许上传的具体路径,例子: a.jpg 或者 a/* 或者 * (使用通配符*存在重大安全风险, 请谨慎评估使用)
+                // 密钥的权限列表。简单上传和分片需要以下的权限,其他权限列表请看 https://cloud.tencent.com/document/product/436/31923
+                'allowActions' => array(
+                    // 简单上传
+                    'name/cos:PutObject',
+                    'name/cos:PostObject',
+                    // 分片上传
+                    'name/cos:InitiateMultipartUpload',
+                    'name/cos:ListMultipartUploads',
+                    'name/cos:ListParts',
+                    'name/cos:UploadPart',
+                    'name/cos:CompleteMultipartUpload'
+                )
+            );
+            try {
+                $result = $sts->getTempKeys($config);
+                if (empty($result['credentials'])) {
+                    return ['code' => 0, 'msg' => '权限生成失败'];
+                }
+                $data = $result['credentials'];
+                $data['StartTime'] = time();
+                $data['ExpiredTime'] = time() + 1700;
+                RedisDataServer::creatServer()->setData('txy_sts_data', $data, 'json', 800);
+            } catch (\Exception $e) {
+                return ['code' => 0, 'msg' => $e->getMessage()];
+            }
+
+
+        }
+        return ['code' => 1, 'msg' => '获取信息成功', 'data' => $data];
+    }
+
+
+    /**
+     * 微信签名
+     */
+    function wxSign($data, $keys)
+    {
+        ksort($data);
+        $str = '';
+        foreach ($data as $key => $val) {
+            if ($val) {
+                if ($str != '') $str .= '&';
+                $str .= "{$key}={$val}";
+            }
+        }
+        $str .= '&key=' . $keys;
+        $sign = strtoupper(MD5($str));
+        return $sign;
+    }
+
+
+
+    /**
+     * 获取阿里云sts临时权限
+     */
+    function getAliSts()
+    {
+        $data = RedisDataServer::creatServer()->getData('sts_data');
+        if ($data) {
+            $data = json_decode($data, true);
+        } else {
+            $accessKeyId = env('ALI_OSS_ACCESS_ID');
+            $accessSecret = env('ALI_OSS_ACCESS_KEY');
+            AlibabaCloud::accessKeyClient($accessKeyId, $accessSecret)->regionId('cn-hangzhou')->asDefaultClient();
+            //设置参数,发起请求。
+            try {
+                $result = AlibabaCloud::rpc()
+                    ->product('Sts')
+                    ->scheme('https') // https | http
+                    ->version('2015-04-01')
+                    ->action('AssumeRole')
+                    ->method('POST')
+                    ->host('sts.aliyuncs.com')
+                    ->options([
+                        'query' => [
+                            'RegionId' => "cn-chengdu",
+                            'RoleArn' => "acs:ram::1470797691368660:role/oss-js",
+                            'RoleSessionName' => "js-oss-serve",
+                            'DurationSeconds' => 900,
+                        ],
+                    ])
+                    ->request();
+                $result = $result->toArray();
+                if (empty($result['Credentials'])) {
+                    return ['code' => 0, 'msg' => '获取token信息失败'];
+                }
+                $data = $result['Credentials'];
+                unset($data['Expiration']);
+                RedisDataServer::creatServer()->setData('sts_data', $data, 'json', 800);
+            } catch (ClientException $e) {
+                return ['code' => 0, 'msg' => $e->getErrorMessage()];
+            } catch (ServerException $e) {
+                return ['code' => 0, 'msg' => $e->getErrorMessage()];
+            }
+        }
+        return ['code' => 1, 'msg' => '获取信息成功', 'data' => $data];
+
+    }
+}

+ 63 - 0
app/Servers/System/JobServer.php

@@ -0,0 +1,63 @@
+<?php
+
+
+namespace App\Servers\System;
+
+
+
+
+use App\Jobs\CreateFirmSealJob;
+use App\Jobs\CreateMemberSealJob;
+use App\Models\Firm;
+
+/**
+ * Redis数据缓存类
+ */
+class JobServer
+{
+
+
+    static private $server = '';
+
+
+    private function __construct()
+    {
+
+    }
+
+    /**
+     * 创建对象
+     * @return JobServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) {
+            self::$server = new  JobServer();
+        }
+        return self::$server;
+    }
+
+    /**
+     * 创建个人印章
+     * @param $psnId
+     * @return void
+     */
+    function createMemberSealJob($psnId)
+    {
+        CreateMemberSealJob::dispatch($psnId)->onConnection('redis')->onQueue('memberSeal')->delay(30);
+    }
+
+
+    /**
+     * 创建企业印章
+     * @param $orgId
+     * @return void
+     */
+    function createFirmSealJob($orgId)
+    {
+        CreateFirmSealJob::dispatch($orgId)->onConnection('redis')->onQueue('firmSeal')->delay(30);
+    }
+
+
+
+}

+ 157 - 0
app/Servers/System/PassServer.php

@@ -0,0 +1,157 @@
+<?php
+
+
+namespace App\Servers\System;
+
+
+/**
+ * Redis数据缓存类
+ */
+class PassServer
+{
+
+    /**
+     * 错误信息
+     * @var string
+     */
+    private $errorMsg = '';
+
+    private $password = '';
+
+
+    private function __construct($password = '', $encrypt = '')
+    {
+        $this->setPassword($password);
+        $this->setEncrypt($encrypt);
+    }
+
+    /**
+     * 创建对象
+     * @param string $password
+     * @param string $encrypt
+     * @return PassServer
+     */
+    static function creatServer($password = '', $encrypt = '')
+    {
+        return new PassServer($password, $encrypt);
+    }
+
+    /**
+     * @return string
+     */
+    public function getPassword(): string
+    {
+        return $this->password;
+    }
+
+    /**
+     * @param string $password
+     */
+    public function setPassword($password = ''): void
+    {
+        if (!empty($password)) $this->password = $password;
+    }
+
+    /**
+     * @return string
+     */
+    public function getEncrypt(): string
+    {
+        return $this->encrypt;
+    }
+
+    /**
+     * @param string $encrypt
+     */
+    public function setEncrypt($encrypt = ''): void
+    {
+        if (!empty($encrypt)) $this->encrypt = $encrypt;
+    }
+
+    private $encrypt = '';
+
+
+    /**
+     * @return string
+     */
+    public function getErrorMsg(): string
+    {
+        return $this->errorMsg;
+    }
+
+    /**
+     * 加密字符串
+     * @param $length
+     * @return null|string
+     */
+    public function getRandChar($length = 6)
+    {
+        $str = null;
+        $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
+        $max = strlen($strPol) - 1;
+        for ($i = 0; $i < $length; $i++) {
+            $str .= $strPol[rand(0, $max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
+        }
+        return $str;
+    }
+
+    /**
+     * 创建会员密码
+     * @return array|false
+     */
+    function creatPassword()
+    {
+        if (empty($this->password)) {
+            $this->errorMsg = "密码不能为空";
+            return false;
+        }
+        if (empty($this->encrypt)) $this->encrypt = $this->getRandChar();
+        $password = $this->memberPassword();
+        return ['password' => $password, 'encrypt' => $this->encrypt];
+    }
+
+    /**
+     * 验证密码
+     * @param $member_pass
+     * @return bool
+     */
+    public function verifyPass($member_pass)
+    {
+        $str = $this->memberPassword();
+        return $member_pass == $str;
+    }
+
+    /**
+     * 密码加密
+     * @return string
+     */
+    private function memberPassword()
+    {
+        $str = md5($this->password) . md5($this->encrypt);
+        return md5($str);
+    }
+
+    /**
+     * 获取推荐码
+     * @return int|string
+     */
+    public function getInviteCode()
+    {
+        return InviteCodeServer::creatServer()->getInviteCode();
+    }
+
+
+
+    /**
+     * 生成会员登录token
+     * @param $m_id
+     * @return string
+     */
+    public function getMemberToken($m_id)
+    {
+        $token = md5($m_id . 'token' . time());
+        return $token;
+    }
+
+
+}

+ 232 - 0
app/Servers/System/RedisDataServer.php

@@ -0,0 +1,232 @@
+<?php
+
+
+namespace App\Servers\System;
+
+use Illuminate\Support\Facades\Redis;
+
+
+/**
+ * Redis数据缓存类
+ */
+class RedisDataServer
+{
+    /**
+     * 单列对象
+     * @var
+     */
+    private static $server;
+
+    private function __construct()
+    {
+
+    }
+
+    /**
+     * 创建对象
+     * @return RedisDataServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) {
+            self::$server = new RedisDataServer();
+        }
+        return self::$server;
+    }
+
+    /**
+     * 获取缓存数据
+     * @param $key
+     * @param string $type
+     * @return mixed
+     */
+    function getData($key, $type = 'str')
+    {
+
+        $value = Redis::get($key);
+        if ($type == 'json') {
+            $value = json_decode($value, true);
+        }
+        return $value;
+    }
+
+    /**
+     * 设置缓存数据
+     * @param $key
+     * @param $value
+     * @param string $type
+     * @param int $time
+     * @param $random
+     */
+    function setData($key, $value, $type = 'str', $time = 10, $random = true)
+    {
+        if (!empty($value)) {
+            if ($type == 'json') {
+                $value = json_encode($value);
+            }
+            if ($time > 1 && $random) $time += $this->getRandom();
+            Redis::setex($key, $time, $value);
+        }
+
+    }
+
+    /**
+     * 长时间存放数据
+     * @param $key
+     * @param $value
+     * @param string $type
+     */
+    function setLongData($key, $value, $type = 'str')
+    {
+        if (!empty($value)) {
+            if ($type == 'json') {
+                $value = json_encode($value);
+            }
+            Redis::set($key, $value);
+        }
+
+    }
+
+    /**
+     * 更新数据
+     * @param $key
+     * @param $value
+     * @param string $type
+     * @param int $start_num
+     */
+    function setSetrange($key, $value, $type = 'str', $start_num = 0)
+    {
+        if (!empty($value)) {
+            if ($type == 'json') {
+                $value = json_encode($value);
+            }
+            Redis::setrange($key, $start_num, $value);
+        }
+    }
+
+    /**
+     * 删除Redis数据
+     * @param $key
+     */
+    function delData($key)
+    {
+        Redis::del($key);
+    }
+
+    /**
+     * 获取随机数
+     * @return int
+     */
+    private function getRandom()
+    {
+        return mt_rand(1, 10);
+    }
+
+    /**
+     * 创建队列序号
+     * @param $key
+     * @param $num
+     * @return mixed
+     */
+    function setQueue($key, $num)
+    {
+        $num_arr = range(1, $num);
+        $key_num = Redis::lpush($key, $num_arr);
+        return $key_num;
+    }
+
+    /**
+     * 添加序号
+     * @param $key
+     * @param $num
+     * @return mixed
+     */
+    function addQueue($key, $num)
+    {
+        $key_num = Redis::lpush($key, $num);
+        return $key_num;
+    }
+
+    /**
+     * 弹出队列数据
+     * @param $key
+     * @return false
+     */
+    function getQueue($key)
+    {
+        $key_num = Redis::rpop($key);
+        if (empty($key_num)) $key_num = false;
+        return $key_num;
+    }
+
+    /**
+     * 队列阻塞弹出
+     * @param $key
+     * @param int $wait_time
+     * @return false
+     */
+    function getWaitQueue($key, $wait_time = 5)
+    {
+        $key_num = Redis::brpop($key, $wait_time);
+        if (empty($key_num)) $key_num = false;
+        return $key_num;
+    }
+
+    /**
+     * 获取队列数据长度
+     * @param $key
+     * @return mixed
+     */
+    function getQueueList($key)
+    {
+        $key_num = Redis::llen($key);
+        return $key_num;
+    }
+
+    /**
+     * 获取过期时间
+     * @param $key
+     * @return mixed
+     */
+    function getTime($key)
+    {
+        $key_num = Redis::ttl($key);
+        return $key_num;
+    }
+
+    /**
+     * 缓存清除
+     * @return mixed
+     */
+    function flushdb()
+    {
+        return Redis::flushdb();
+    }
+
+
+    /**
+     * key加锁
+     * @param $key
+     * @param $value
+     * @param int $time
+     * @return mixed
+     */
+    function lockKey($key,$value,$time = 10){
+        return Redis::set($key, $value, 'ex', $time, 'nx');
+    }
+
+    /**
+     * 解锁
+     * @param $key
+     * @param $value
+     * @return mixed
+     */
+    function unLockKey($key, $value)
+    {
+        $res = $this->getData($key);
+
+        if ($res == $value) {
+            return Redis::del($key);
+        }
+    }
+}

+ 130 - 0
app/Servers/System/SmsServer.php

@@ -0,0 +1,130 @@
+<?php
+
+
+namespace App\Servers\System;
+
+use End01here\EasySms\EasySmsService;
+
+
+/**
+ * Redis数据缓存类
+ */
+class SmsServer
+{
+
+
+    /**
+     * 错误信息
+     * @var string
+     */
+    private $errorMsg = '';
+
+
+    private function __construct()
+    {
+    }
+
+    /**
+     * 创建对象
+     * @return SmsServer
+     */
+    static function creatServer()
+    {
+        return new SmsServer();
+    }
+
+    /**
+     * @return string
+     */
+    public function getErrorMsg(): string
+    {
+        return $this->errorMsg;
+    }
+
+    /**
+     * 发送短信
+     * @param $phone_num
+     * @param $send_type
+     * @return bool
+     * @throws \End01here\EasySms\Exceptions\CodeErrorException
+     * @throws \End01here\EasySms\Exceptions\GatewayErrorException
+     * @throws \End01here\EasySms\Exceptions\MessageException
+     */
+    function sendCode($phone_num,$send_type='default')
+    {
+        $wxCode = CommonServer::creatServer()->filtrationStr('wxCode');
+        if(empty($wxCode)){
+            $this->errorMsg = '缺少验证信息';
+            return false;
+        }
+//        $openInfo = WeixinServer::creatServer()->getAppletsOpenId($wxCode);
+        $openInfo = [];
+        if(!isset($openInfo['openid'])){
+            $this->errorMsg = '授权验证失败';
+            return false;
+        }
+        $send_type='default';
+        try {
+            $phone = EasySmsService::getPhoneSever($phone_num);
+            $code_server = EasySmsService::getCodeSever($phone)->setCode($send_type);
+            $message_server = EasySmsService::getMessageServer();
+            $content = '尊敬的客户,验证码为'.$code_server->getCode().',请妥善保管,10分钟内有效!' ;
+            $message_server->setContent($content);
+            $send_info = EasySmsService::getSmsServer()->creatQybSms()->send($phone, $message_server);
+        }catch (\Exception $e){
+            $this->errorMsg=$e->getMessage();
+            return false;
+        }
+
+        if (!empty($send_info['code']) && $send_info['code'] != 1) {
+            $this->errorMsg = '短信发送失败';
+            return false;
+        }
+        return true;
+    }
+
+
+    /**
+     * 发送短信模板内容
+     * @param $phone_num
+     * @param $content
+     * @return bool
+     */
+    function sendContent($phone_num,$content)
+    {
+        try {
+            $phone = EasySmsService::getPhoneSever($phone_num);
+            $message_server = EasySmsService::getMessageServer();
+            $message_server->setContent($content);
+            $send_info = EasySmsService::getSmsServer()->creatQybSms()->send($phone, $message_server);
+        }catch (\Exception $e){
+            $this->errorMsg=$e->getMessage();
+            return false;
+        }
+
+        if (!empty($send_info['code']) && $send_info['code'] != 1) {
+            $this->errorMsg = '短信发送失败';
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * 验证码验证
+     * @param $phone_num
+     * @param $code
+     * @param $send_type
+     * @return bool
+     */
+    public function verifyCode($phone_num, $code,$send_type='default')
+    {
+        $send_type='default';
+        $phone = EasySmsService::getPhoneSever($phone_num);
+        $code_sever= EasySmsService::getCodeSever($phone);
+        $ret_code = $code_sever->verifyCode($code,$send_type);
+        $this->errorMsg=$code_sever->getErrorMsg();
+        return $ret_code;
+    }
+
+
+}

+ 99 - 0
app/Servers/Wps/ExcelServer.php

@@ -0,0 +1,99 @@
+<?php
+
+
+namespace App\Servers\Wps;
+
+
+
+use App\Imports\ExcelImport;
+use App\Servers\Financing\PropertyServer;
+use App\Servers\Firm\FirmServer;
+use App\Servers\System\CommonServer;
+
+class ExcelServer
+{
+    static private $server = null;
+
+    function __construct()
+    {
+
+    }
+
+    /**
+     * 创建对象
+     * @return ExcelServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new ExcelServer();
+        return self::$server;
+    }
+
+    /**
+     * 企业信息导入
+     * @param $excel
+     * @throws \Throwable
+     */
+    function importCooperationData($excel){
+        $clientImport=new ExcelImport();
+        $data=$clientImport->toArray($excel);
+        if(!empty($data[0])){
+            foreach ($data[0] as $key=>$item){
+                if(empty($item[0])){
+                    break;
+                }
+                if($key>1){
+                    FirmServer::creatServer()->saveCooperation($item[0],'',$item[1],$item[2],$item[3]);
+                }
+
+            }
+        }
+    }
+
+    /**
+     * 资产信息导入
+     * @param $excel
+     * @param $factoringId
+     */
+    function importPropertyData($excel,$factoringId){
+        if(strstr($excel,'http')!==false){
+            $fileName=CommonServer::creatServer()->getFileName($excel);
+            $path=public_path('storage/excel/'.date('Ymd').'/');
+            if(!is_dir($path))mkdir($path,0777,true);
+            file_put_contents($path.$fileName,file_get_contents($excel));
+            $excel=$path.$fileName;
+        }
+        $clientImport=new ExcelImport();
+        $data=$clientImport->toArray($excel);
+        $row=['total'=>0,'succeed'=>0,'error'=>0,'list'=>[]];
+        if(!empty($data[0])){
+            foreach ($data[0] as $key=>$item){
+                if(empty($item[0])){
+                    break;
+                }
+                if($key>1){
+                    if(count($item)<16){
+                        continue;
+                    }
+                    ++$row['total'];
+
+                    $ret=PropertyServer::creatServer()->importPropertyItem($item,$factoringId);
+                    $row['list'][]=$ret;
+                    if($ret['status']==1){
+                        ++$row['succeed'];
+                    }else{
+                        ++$row['error'];
+                    }
+                }
+
+            }
+        }
+        return $row;
+    }
+
+
+
+
+
+
+}

+ 179 - 0
app/Servers/Wps/PdfServer.php

@@ -0,0 +1,179 @@
+<?php
+
+
+namespace App\Servers\Wps;
+
+
+
+use App\Models\FactoringContract;
+use App\Models\FactoringContractFile;
+use App\Models\FileManager;
+use App\Servers\System\CommonServer;
+
+use Illuminate\Support\Facades\DB;
+use PhpOffice\PhpWord\IOFactory;
+
+
+class PdfServer
+{
+    static private $server = null;
+
+
+
+
+
+    function __construct()
+    {
+
+    }
+
+    /**
+     * 创建对象
+     * @return PdfServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new PdfServer();
+        return self::$server;
+    }
+
+
+
+
+    /**
+     * word转pdf
+     * @param $wordUrl
+     * @param $id
+     * @param $type
+     * @return string
+     */
+    function wordToPdf($wordUrl){
+        $path=public_path('/storage/pdf/'.date('Ymd'));
+        $file='/home/www/4.8.docx';
+        $command = "libreoffice --headless --convert-to pdf  --outdir {$path}  {$file}";
+        exec($command);
+//        $fileName=CommonServer::creatServer()->getFileName($wordUrl);
+//        return WpsServer::creatServer()->fileConvertPdf($wordUrl,$fileName);
+//        $storageUrl='storage/pdf/'.date('Ymd').'/';
+//        $path=public_path($storageUrl);
+//        $fileUrl=$path.time().$fileName;
+//        if(!is_dir($path)){
+//            mkdir($path,0777,true);
+//        }
+//        $extension = pathinfo($fileName);
+////        file_put_contents($fileUrl ,file_get_contents($wordUrl));
+//////        $content = file_get_contents('https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/git.docx');
+//////        dd($content);
+////        dd($fileUrl);
+////        $phpWord = IOFactory::load($fileUrl);
+////        $wordHtml = IOFactory::createWriter($phpWord,'HTML');
+////        $fileHtml=$path.$fileName.'.html';
+////        $wordHtml->save($fileHtml);
+////        $html=file_get_contents($fileHtml);
+////        // 设置Dompdf选项
+////        $dompdf = new Dompdf();
+////        $dompdf->loadHtml($html,'UTF-8');
+////        $dompdf->setPaper('A4', 'portrait');
+////        $dompdf->render();
+////        $pdf = $dompdf->output();
+////
+////// 将PDF写入文件
+////        file_put_contents($path.$fileName.'.pdf', $pdf);
+//        // 创建一个新的Word文档实例
+//        file_put_contents($fileUrl ,file_get_contents($wordUrl));
+//        $phpWord = IOFactory::load($fileUrl);
+//
+//        // 创建一个新的FPDF实例
+////        $pdf = new \FPDF();
+//        $pdf = new \PDF_Chinese();
+//        $pdf->AddGBFont('simhei','黑体');
+//        $pdf->AddGBFont('simkai','楷体_GB2312');
+//
+//        // 遍历Word文档中的所有部分并转换为PDF
+//        foreach ($phpWord->getSections() as $section) {
+//            // 添加一页PDF
+//             $pdf->AddPage();
+////             $pdf->setFont('freeserif');
+//            $pdf->SetFont('simhei','',16);
+////            $pdf->AddFont('GB','', 'song.cng.php');
+////            $pdf->AddFont('GB','B', 'song.cnb.php');
+//            // 遍历文档部分中的所有元素
+//            foreach ($section->getElements() as $element) {
+//                // 处理文本元素
+//
+//                if (method_exists($element, 'getText')) {
+//                    $text = $element->getText();
+//                    $text = mb_convert_encoding($text, 'GBK', 'UTF-8');
+//                    $pdf->Cell(0, 5, $text, 0, 1, 'L');
+//                }
+//
+//                // 处理图像元素
+//                if (method_exists($element, 'getImage')) {
+//                    $image = $element->getImage(0);
+//                    $pdf->Image($image->getSource(), $pdf->GetX(), $pdf->GetY(), $image->getWidth(), $image->getHeight());
+//                }
+//
+//                // 处理其他元素类型...
+//            }
+//        }
+//        $fileName=str_replace($extension['extension'],'',$fileName);
+//        // 保存PDF到文件
+//        $pdf->Output($path.$fileName.'pdf', 'F');
+//        return 'http://'.env('APP_ADMIN_HOST').'/'.$storageUrl.$fileName.'pdf';
+    }
+
+
+    /**
+     * 图片转pdf
+     * @param $imgUrl
+     * @return string
+     */
+    function imgToPdf($imgUrl){
+        $fileName=CommonServer::creatServer()->getFileName($imgUrl);
+        $storageUrl='storage/pdf/'.date('Ymd').'/';
+        $path=public_path($storageUrl);
+        if(!is_dir($path)){
+            mkdir($path,0777,true);
+        }
+//        $base64Img=base64_encode(file_get_contents($imgUrl));
+//        $extension = pathinfo($fileName);
+//        $htmlContent = '<html><body><img src="data:image/'.$extension['extension'].';base64,'.$base64Img.'" /></body></html>';
+//        dd($htmlContent);
+//        $dompdf = new Dompdf();
+//        $dompdf->loadHtml($htmlContent,'UTF-8');
+//        $dompdf->setPaper('A4', 'portrait');
+//        $dompdf->render();
+//        $pdf = $dompdf->output();
+//        // 将PDF写入文件
+//        $fileName=str_replace($extension['extension'],'',$fileName);
+//        file_put_contents($path.$fileName.'pdf', $pdf);
+        $pdf = new \FPDF();
+        $pdf->AddPage();
+        // 获取图片尺寸
+        list($width, $height) = getimagesize($imgUrl);
+        $extension = pathinfo($fileName);
+        // 获取PDF页面宽度
+        $pageWidth = $pdf->getPageWidth()-10;
+        $pageHeight = $pdf->GetPageHeight()-10;
+        // 计算图片缩放比例,使其宽度与页面宽度相匹配
+        $scale = $pageWidth / $width;
+        // 计算缩放后的高度
+        $newHeight = $height * $scale;
+        if($pageHeight<$newHeight){
+            $newHeight=$pageHeight;
+            $scale = $newHeight / $height;
+            $newWidth=$width * $scale;
+        }else{
+            $newWidth=$pageWidth;
+        }
+
+        // 将图片添加到PDF,并设置缩放比例
+        $pdf->Image($imgUrl, 5, 5, $newWidth, $newHeight, strtoupper($extension['extension']));
+
+        $fileName=str_replace($extension['extension'],'',$fileName);
+        $pdf->Output('F', $path.$fileName.'pdf');
+        return 'https://'.env('APP_ADMIN_HOST').'/'.$storageUrl.$fileName.'pdf';
+    }
+
+
+}

+ 226 - 0
app/Servers/Wps/WordServer.php

@@ -0,0 +1,226 @@
+<?php
+
+
+namespace App\Servers\Wps;
+
+
+
+use App\Servers\System\CommonServer;
+use App\Servers\System\RedisDataServer;
+use PhpOffice\PhpWord\IOFactory;
+use PhpOffice\PhpWord\TemplateProcessor;
+use PhpOffice\PhpWord\Writer\HTML;
+
+class WordServer
+{
+    static private $server = null;
+    private $propertyKey = [
+        'property_id',
+        'property_contract_sn',
+        'property_name',
+        'property_original_credit',
+        'property_original_debtor',
+        'end_date',
+    ];
+
+    function __construct()
+    {
+
+    }
+
+    /**
+     * 创建对象
+     * @return WordServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new WordServer();
+        return self::$server;
+    }
+
+
+    /**
+     * 验证word文件是否包含某个字符串
+     * @param $filePath
+     * @param $searchChar
+     * @return bool
+     */
+    function containText($filePath,$searchChar)
+    {
+        $path=public_path('storage/word_html/'.date('Ymd').'/');
+        if(!is_dir($path)){
+            CommonServer::creatServer()->creatDir('storage/word_html/'.date('Ymd').'/');
+        }
+        $htmlPath=$path.md5($filePath).'.html';
+        if(!is_file($htmlPath)){
+            $phpWord = IOFactory::load($filePath);
+            $htmlWriter =new HTML($phpWord);
+            $htmlWriter->save($htmlPath);
+        }
+        $htmlContent = file_get_contents($htmlPath);
+        $htmlContent=strip_tags($htmlContent);
+        return !strpos($htmlContent,$searchChar)===false;
+    }
+
+
+    /**
+     * 合同保存的时候生成文本替换内容
+     * @throws \PhpOffice\PhpWord\Exception\Exception
+     */
+    function replaceWordText($file_path,$file_name,$json)
+    {
+        $filePath=public_path($file_path);
+        $phpWord = new  TemplateProcessor($filePath);
+
+        $data = json_decode($json,true);
+        foreach ($data as $key=>$text){
+            $custom='{$' . $key . '}';
+            $phpWord->setValue($custom, $text);
+        }
+        CommonServer::creatServer()->creatDir('storage/contractComplete');
+        $new_path = 'storage/contractComplete/'.$file_name;
+        $phpWord->saveAs(public_path($new_path));
+        return $new_path;
+    }
+
+
+    /**
+     * 获取相关收益信息
+     * @param $factoring
+     * @param $type
+     * @return string
+     */
+    function getEarningTextKey($factoring,$type)
+    {
+        $str='0%';
+        $type=str_replace($type,'earning_type',$type);
+        if(empty($type) || !is_numeric($type)){
+            return $str;
+        }
+        $model=FactoringEarning::where('factoring_id',$factoring['id'])->where('earning_type',$type)->first();
+        if(empty($model)){
+            return $str;
+        }
+        return $model->{'earning_num'}.'%('.$model->{'earning_msg'}.')';
+    }
+
+    /**
+     * 企业基本信息匹配
+     * @param $propertys
+     * @param $key
+     * @param $type
+     * @return false|string
+     */
+    function getPropertyFirmTextKey($propertys,$key,$type)
+    {
+        $data=[];
+        foreach ($propertys as $property){
+            if($type=='zrf'){
+                $firmName=Firm::where('id',$property['firm_id'])->value('firm_name');
+            }elseif ($type=='yszw'){
+                $firmName=$property['original_debtor'];
+            }elseif ($type=='hxqy'){
+                $firmName=$property['core_enterprise'];
+            }elseif ($type=='bls'){
+                $firmName=Firm::where('id',$property['factor_id'])->value('firm_name');
+            }
+            if(empty($firmName)){
+                return false;
+            }
+            if($key=='firm_name'){
+                $data[]=$firmName;
+            }else{
+                $firm=$this->getFirmTextKey($firmName);
+                if(empty($firm)){
+                    $data[]='无';
+                }else{
+                    $data[]=empty($firm[$key])?'无':$firm[$key];
+                }
+            }
+        }
+        $data=array_unique($data);
+        return  implode(';',$data);
+    }
+
+    /**
+     * 获取企业基本信息
+     * @param $firmName
+     * @return Firm|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|mixed|object|null
+     */
+    function getFirmTextKey($firmName)
+    {
+        $firmData=RedisDataServer::creatServer()->getData(md5($firmName),'json');
+        if(empty($firmData)){
+            $firmData=FirmServer::creatServer()->queryFirm($firmName);
+            RedisDataServer::creatServer()->setData(md5($firmName),$firmData,'json');
+        }
+        return $firmData;
+    }
+
+    /**
+     * 合同信息获取
+     * @param $factoring_contract
+     * @param $key
+     * @return mixed|string
+     */
+    function getContractTextKey($factoring_contract,$key)
+    {
+        $str='';
+        if($key=='contract_sn'){
+            $str=$factoring_contract->{'contract_sn'};
+        }
+        return $str;
+    }
+
+    /**
+     * 获取基础替换信息
+     * @param $key
+     * @param $factoring_contract
+     * @param $factoring
+     * @return mixed|void
+     */
+    function getTextKey($key,$factoring_contract,$factoring)
+    {
+        if (isset($factoring_contract[$key])){
+            return $factoring_contract[$key];
+        }
+        if (isset($factoring[$key])){
+            return $factoring[$key];
+        }
+        return '';
+    }
+
+    /**
+     * 获取资产替换信息
+     * @param $property
+     * @param $key
+     * @return string
+     */
+    function getPropertyTextKey($property,$key)
+    {
+        $data=[];
+        foreach ($property as $value){
+            if($key=='id'){
+                $data[]=$value->{'id'} . '('.$value->{'property_name'}.')';
+            }elseif ($key=='name'){
+                $data[]=$value->{'property_name'};
+            }elseif ($key=='contract_sn'){
+                $data[]=$value->{'contract_sn'} . '('.$value->{'property_name'}.')';
+            }elseif ($key=='original_credit'){
+                $data[]=$value->{'original_credit'} . '('.$value->{'property_name'}.')';
+            }elseif ($key=='original_debtor'){
+                $data[]=$value->{'original_debtor'} . '('.$value->{'property_name'}.')';
+            }elseif ($key=='end_date'){
+                $data[]=$value->{'end_date'} . '('.$value->{'property_name'}.')';
+            }elseif ($key=='due_date'){
+                $data[]=$value->{'due_date'} . '('.$value->{'property_name'}.')';
+            }elseif ($key=='property_sn'){
+                $data[]=$value->{'property_sn'} . '('.$value->{'property_name'}.')';
+            }
+        }
+        return implode(';',$data);
+    }
+
+
+
+}

+ 224 - 0
app/Servers/Wps/WpsServer.php

@@ -0,0 +1,224 @@
+<?php
+
+
+namespace App\Servers\Wps;
+
+
+
+
+use App\Models\FactoringContractFile;
+use App\Models\FileManager;
+use App\Servers\System\CommonServer;
+
+class WpsServer
+{
+    static private $server = null;
+
+    private $url='https://solution.wps.cn';
+
+    private $edit_app_id='';
+    private $edit_app_secret='';
+
+    private $to_app_id='';
+    private $to_app_secret='';
+
+    function __construct()
+    {
+            $this->edit_app_id=env('WPS_EDIT_APP_ID');
+            $this->edit_app_secret=env('WPS_EDIT_APP_SECRET');
+            $this->to_app_id=env('WPS_TO_APP_ID');
+            $this->to_app_secret=env('WPS_TO_APP_SECRET');
+    }
+
+    /**
+     * 创建对象
+     * @return WpsServer
+     */
+    static function creatServer()
+    {
+        if (empty(self::$server)) self::$server = new WpsServer();
+        return self::$server;
+    }
+
+    /**
+     * 回调验签
+     * @return bool
+     */
+    function verificationSing(){
+        $app_id=request()->header('X-App-Id');
+        $app_secret=$app_id==$this->edit_app_id?$this->edit_app_secret:$this->to_app_secret;
+        $authorization=request()->header('Authorization');
+        $md5=request()->header('Content-Md5');
+        $type=request()->header('Content-Type');
+        $date=request()->header('Date');
+        $sign='WPS-2:'.$app_id.':'.sha1($app_secret.$md5.$type.$date);
+        return $authorization==$sign;
+    }
+
+
+    function getTemplate(){
+        $uri='/api/developer/v1/files/w/template';
+        $url=$this->url.$uri;
+        $head=$this->wpsSing(1,'uri='.$uri);
+        $ret=CommonServer::creatServer()->sendRequest($url,[],'get',$head);
+        dd($ret);
+    }
+
+
+    /**
+     * 请求签名
+     * @param $type
+     * @param $text
+     * @return string[]
+     */
+    function wpsSing($type,$text){
+        if($type==1){
+            $app_id=$this->edit_app_id;
+            $app_secret=$this->edit_app_secret;
+        }else{
+            $app_id=$this->to_app_id;
+            $app_secret=$this->to_app_secret;
+        }
+        $md5=md5($text);
+        $date= gmdate('D, d M Y H:i:s'). ' GMT';
+        $type='application/json';
+        $data=[
+            'Content-Md5:'.$md5,
+            'Content-Type:'.$type,
+            'DATE:'.$date,
+            'Authorization:'.'WPS-2:'.$app_id.':'.sha1($app_secret.$md5.$type.$date),
+        ];
+        return $data;
+    }
+
+
+    /**
+     * 更新合同文件版本号
+     * @param $file_id
+     * @return FactoringContractFile|false|\Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Query\Builder|object
+     */
+    function setContractFileVersion($file_id){
+        //检查该文件编号是否存在
+        $fileInfo = FactoringContractFile::where('file_no',$file_id)
+            ->select(['id','file_no','file_name','file_path','file_url','version'])
+            ->orderBy('id','desc')
+            ->orderBy('version','desc')
+            ->first();
+        if (empty($fileInfo)) {
+            return false;
+        }
+        //组装新版本文件
+//        $fileNameArr = explode('-', $fileInfo->{'file_name'});
+        $version = $fileInfo->{'version'} + 1;
+        $res = FactoringContractFile::create([
+            'file_no' => $file_id,
+            'file_name' => $fileInfo->{'file_name'},
+            'file_url' => $fileInfo->{'file_url'},
+            'file_path' => $fileInfo->{'file_path'},
+            'version' => $version,
+            'type' => 1,
+            'is_end' => 1,
+        ]);
+        if (!$res){
+            return false;
+        }
+        return $fileInfo;
+    }
+
+
+    function createFileConvert(){
+        $list = FileManager::where('status',0)
+            ->whereNotNull('task_id')
+            ->orderBy('id','asc')
+            ->limit(20)
+            ->get();
+        foreach ($list as $value){
+            $extension = pathinfo($value->{'name'}, PATHINFO_EXTENSION);
+            if (in_array($extension,['pptx','ppt','docx','doc','xlsx','xls'])){//走文档转pdf
+
+            }elseif (in_array($extension,['png','jpg','jpeg','bmp','tif','tiff','gif'])){//走图片转文档
+
+            }
+        }
+    }
+
+    function imgConvertDocx($img_url,$office_type='docx'){
+        $uri='/api/developer/v1/office/img/convert/to/'.$office_type;
+        $url=$this->url.$uri;
+
+        $data['img_urls'] = [$img_url];
+        $head=$this->wpsSing(2,json_encode($data, JSON_UNESCAPED_UNICODE));
+        $ret=CommonServer::creatServer()->sendRequest($url,$data,'post',$head);
+        dd($ret);
+    }
+
+    /**
+     * PDF转换文档
+     * @param $pdf_url
+     * @param $office_type
+     * @return void
+     */
+    function pdfConvertDocx($pdf_url,$office_type='xlsx'){
+        $uri='/api/developer/v1/office/pdf/convert/to/'.$office_type;
+        $url=$this->url.$uri;
+
+        $data['url'] = $pdf_url;
+        if($office_type=='xlsx'){
+            $data['sheet_option'] = 1;
+        }
+        $head=$this->wpsSing(2,json_encode($data, JSON_UNESCAPED_UNICODE));
+        $ret=CommonServer::creatServer()->sendRequest($url,$data,'post',$head);
+        dd($ret);
+    }
+
+    function queryConvertDocx($task_id,$office_type='xlsx'){
+        $uri='/api/developer/v1/tasks/convert/to/'.$office_type.'/'.$task_id;
+        $url=$this->url.$uri;
+        $head=$this->wpsSing(2,'uri='.$uri);
+        $ret=CommonServer::creatServer()->sendRequest($url,[],'get',$head);
+        dd($ret);
+    }
+
+    function fileConvertPdf($file_url,$file_name){
+        $uri='/api/developer/v1/office/convert/to/pdf';
+        $url=$this->url.$uri;
+        $data['url'] = $file_url;
+        $data['filename'] = $file_name;
+        $head=$this->wpsSing(2,json_encode($data));
+        $ret=CommonServer::creatServer()->sendRequest($url,$data,'post',$head);
+        if(isset($ret['code']) && $ret['code']==0){
+
+            return $ret['data']['task_id'];
+        }else{
+            return false;
+        }
+    }
+
+
+    /**
+     * 查询Pdf转换结果
+     * @param $task_id
+     * @return bool|mixed
+     */
+    function queryConvertPdf($task_id){
+        $uri='/api/developer/v1/tasks/'.$task_id;
+        $url=$this->url.$uri;
+        $head=$this->wpsSing(2,'uri='.$uri);
+        $ret=CommonServer::creatServer()->sendRequest($url,[],'get',$head);
+        if(isset($ret['code']) && $ret['code']==0){
+            if($ret['data']['status']=='success' && !empty($ret['data']['result']) && count($ret['data']['result']['pdfs'])>0){
+                $file_path = 'contractFile/wpspdf/' . date('Ymd') . '/'.$task_id.'/';
+                CommonServer::creatServer()->creatDir($file_path);
+                $file_name = md5($ret['data']['result']['pdfs'][0]['url'].time()).'.pdf';
+                $file_path = $file_path . $file_name;
+                file_put_contents(public_path($file_path), file_get_contents($ret['data']['result']['pdfs'][0]['url'])); // 写入文件
+                $file_url = 'https://'.env('APP_ADMIN_HOST').'/'.$file_path;
+                return $file_url;
+            }else{
+                return  false;
+            }
+        }else{
+            return false;
+        }
+    }
+}

+ 14 - 0
routes/adminApi/auth.php

@@ -0,0 +1,14 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'auth'],function($router){
+
+    Route::match(['get','post'],'login', 'LoginController@login')->name('adminApi.auth.login');                    // 登录
+    Route::match(['get','post'],'logout', 'LoginController@logout')->name('adminApi.auth.logout');      // 登出
+    Route::match(['get','post'],'retrieve', 'LoginController@retrievePassword')->name('adminApi.auth.retrieve'); //找回密码
+
+});
+
+

+ 15 - 0
routes/adminApi/common.php

@@ -0,0 +1,15 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'common'],function($router){
+
+    Route::match(['get','post'],'send', 'CommonController@sendSms')->name('adminApi.common.send');//
+    Route::match(['get','post'],'card_front', 'CommonController@getCardFrontOrc')->name('adminApi.common.card_front');//获取身份证orc识别
+    Route::match(['get','post'],'license', 'CommonController@getLicenseOrc')->name('adminApi.common.license'); //
+    Route::match(['get','post'],'sts', 'CommonController@getAliSts')->name('adminApi.common.sts'); //
+
+});
+
+

+ 15 - 0
routes/adminApi/contract.php

@@ -0,0 +1,15 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'contract'],function($router){
+
+    Route::match(['get','post'],'list', 'ContractController@getContractList')->name('adminApi.contract.list');// 列表
+    Route::match(['get','post'],'save', 'ContractController@saveContract')->name('adminApi.contract.save');// 添加&编辑
+    Route::match(['get','post'],'del', 'ContractController@delContract')->name('adminApi.contract.del'); //删除
+    Route::match(['get','post'],'info', 'ContractController@getContractInfo')->name('adminApi.contract.info'); //
+
+});
+
+

+ 15 - 0
routes/adminApi/firm.php

@@ -0,0 +1,15 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'firm'],function($router){
+
+    Route::match(['get','post'],'list', 'FirmController@getFirmList')->name('adminApi.firm.list');// 列表
+    Route::match(['get','post'],'save', 'FirmController@saveFirm')->name('adminApi.firm.save');// 添加&编辑
+    Route::match(['get','post'],'info', 'FirmController@getFirmInfo')->name('adminApi.firm.info');//
+    Route::match(['get','post'],'notice', 'FirmController@noticeFirmAuth')->name('adminApi.firm.notice');//
+
+});
+
+

+ 16 - 0
routes/adminApi/member.php

@@ -0,0 +1,16 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'member'],function($router){
+
+    Route::match(['get','post'],'list', 'MemberController@getMemberList')->name('adminApi.member.list');// 列表
+    Route::match(['get','post'],'save', 'MemberController@saveMember')->name('adminApi.member.save');// 添加&编辑
+    Route::match(['get','post'],'info', 'MemberController@getMemberInfo')->name('adminApi.member.info');//
+
+    Route::match(['get','post'],'notice', 'MemberController@noticeMemberAuth')->name('adminApi.member.notice');//通知用户认证
+
+});
+
+

+ 13 - 0
routes/adminApi/notify.php

@@ -0,0 +1,13 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'notify'],function($router){
+
+
+    Route::match(['post','get'],'esignNotify', 'NotifyController@esignNotify')->name('adminApi.notify.esignNotify');
+
+});
+
+

+ 16 - 0
routes/adminApi/signContract.php

@@ -0,0 +1,16 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'signContract'],function($router){
+
+    Route::match(['get','post'],'contract', 'SignContractController@getContractList')->name('adminApi.signContract.contract');//
+    Route::match(['get','post'],'firm', 'SignContractController@getFirmList')->name('adminApi.signContract.firm');//
+    Route::match(['get','post'],'member', 'SignContractController@getMemberList')->name('adminApi.signContract.member'); //
+    Route::match(['get','post'],'create', 'SignContractController@createSignContract')->name('adminApi.signContract.create'); //
+    Route::match(['get','post'],'list', 'SignContractController@getSignContractList')->name('adminApi.signContract.list'); //
+
+});
+
+

+ 18 - 0
routes/api/common.php

@@ -0,0 +1,18 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+
+/** 会员 **/
+Route::group(['domain' => env('APP_HOST_API'), 'prefix' => 'common'],function (){
+    Route::match(['get','post'],'send', 'CommonController@sendSms')->name('common.send');//发送短信
+    Route::match(['get','post'],'image_orc', 'CommonController@getImageOrc')->name('common.image_orc');//百度orc识别
+
+});
+
+
+
+
+
+

+ 28 - 0
routes/wps/wps.php

@@ -0,0 +1,28 @@
+<?php
+
+use Illuminate\Support\Facades\Route;
+
+
+
+/** 会员 **/
+Route::group(['domain' => env('APP_ADMIN_HOST'), 'prefix' => '/v3/3rd/'],function (){
+    Route::get('files/{file_id}', 'WpsController@getFiles')->name('wps.files');
+    Route::get('files/{file_id}/download', 'WpsController@downloadFiles')->name('wps.download');
+    Route::get('files/{file_id}/permission', 'WpsController@permissionFiles')->name('wps.permission');
+    Route::post('files/{file_id}/upload', 'WpsController@uploadFiles')->name('wps.upload');
+    Route::get('files/{file_id}/versions', 'WpsController@versionsFiles')->name('wps.versions');
+    Route::get('users', 'WpsController@getUsers')->name('wps.users');
+
+});
+
+
+
+Route::group( ['domain' => env('APP_ADMIN_HOST'), 'prefix' => 'esign'],function($router){
+
+
+    Route::match(['post','get'],'esignNotify', 'EsignController@esignNotify')->name('wps.esignNotify');
+    Route::match(['post','get'],'sealNotify', 'EsignController@sealNotify')->name('wps.sealNotify');
+
+});
+
+