Browse Source

Merge branch 'master' of http://git.jhcs888.com/ph/zh_esign

# Conflicts:
#	app/Servers/Wps/PdfServer.php
USER-20230908AJ\Administrator 1 year ago
parent
commit
b196ba3c63

+ 72 - 0
app/Console/Commands/TestCommand.php

@@ -0,0 +1,72 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Mail\ExampleEmail;
+use App\Models\Factoring;
+use App\Models\FactoringContract;
+use App\Models\FactoringContractFile;
+use App\Models\FactoringProperty;
+use App\Models\Firm;
+use App\Models\IndentNum;
+use App\Models\Member;
+use App\Models\SignMember;
+use App\Models\SignSeal;
+use App\Models\SignSealAuth;
+use App\Servers\ESign\comm\EsignLogHelper;
+use App\Servers\ESign\ESignContractServer;
+use App\Servers\ESign\ESignFirmServer;
+use App\Servers\ESign\ESignServer;
+use App\Servers\Financing\ContractServer;
+use App\Servers\Financing\FinancingServer;
+use App\Servers\Firm\FirmServer;
+use App\Servers\System\EmailServer;
+use App\Servers\System\JobServer;
+use App\Servers\System\RedisDataServer;
+use App\Servers\System\SmsServer;
+use App\Servers\Wps\ExcelServer;
+use App\Servers\Wps\WordServer;
+use App\Servers\Wps\WpsServer;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Log;
+use Illuminate\Support\Facades\Storage;
+
+class TestCommand extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'test';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = '测试命令';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        $file_path = 'storage/contract/测试.docx';
+        $json = '{"name": "江雨","text":"测试一下","phone":"13012341234"}';
+        $file = WordServer::creatServer()->replaceWordText($file_path,'123.docx',$json);
+        dd($file);
+    }
+}

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

@@ -0,0 +1,102 @@
+<?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','');//合同名称
+        if (empty($name)) return $this->apiResponseError('请填写合同名称');
+        if (mb_strlen($name) > 100) return $this->apiResponseError('合同名称最大100');
+
+        $file =request()->file('file','');//文件
+        if (empty($file)){
+            return $this->apiResponseError('请选择文件');
+        }
+
+        //检查合同名称是否存在
+        $info = Contract::where('name',$name)->where('is_del',0)->select(['id'])->first();
+        if (!empty($info)) {
+            return $this->apiResponseError('合同名称已存在');
+        }
+
+        $extension = request()->file->extension();//获取文件扩展名
+        $file_name = $name.'.'.$extension;
+        $contracts_file = request()->file->storeAs('public/contract', $file_name);
+
+
+
+        $data = compact('name','contracts_file');
+
+        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 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('删除失败');
+        }
+    }
+}

+ 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('密码修改成功');
+        }
+    }
+}

+ 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;
+}

+ 0 - 0
app/Http/Controllers/Api/MemberController.php


+ 9 - 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
@@ -44,6 +46,13 @@ class Kernel extends HttpKernel
             'throttle:api',
             \Illuminate\Routing\Middleware\SubstituteBindings::class,
         ],
+
+        //后台验证
+        'adminApiVerify'=>[
+            AdminAuthMiddleware::class,
+            AdminLogMiddleware::class,
+//            PermissionMiddleware::class
+        ],
     ];
 
     /**

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

@@ -0,0 +1,71 @@
+<?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',
+    ];
+    /**
+     * 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);
+    }
+}

+ 49 - 0
app/Models/AdminLog.php

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

+ 30 - 0
app/Models/Contract.php

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

+ 15 - 0
app/Providers/RouteServiceProvider.php

@@ -40,6 +40,7 @@ class RouteServiceProvider extends ServiceProvider
 
         $this->mapApiRoutes();
         $this->mapWpsRoutes();
+        $this->mapAdminApiRoutes();
 
         $this->routes(function () {
 
@@ -88,4 +89,18 @@ class RouteServiceProvider extends ServiceProvider
                 ->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}") );
+        }
+    }
 }

+ 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),
+            ]
+        );
+    }
+}

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

@@ -0,0 +1,416 @@
+<?php
+
+
+namespace App\Servers\System;
+
+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;
+    }
+
+
+}

+ 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;
+    }
+
+
+}

+ 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;
+    }
+
+
+
+
+
+
+}

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

@@ -0,0 +1,225 @@
+<?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');
+        $phpWord->saveAs(public_path('storage/contractComplete/'.$file_name));
+        return true;
+    }
+
+
+    /**
+     * 获取相关收益信息
+     * @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;
+        }
+    }
+}

+ 2 - 1
composer.json

@@ -12,7 +12,8 @@
         "guzzlehttp/guzzle": "^7.0.1",
         "laravel/framework": "^8.75",
         "laravel/sanctum": "^2.11",
-        "laravel/tinker": "^2.5"
+        "laravel/tinker": "^2.5",
+        "phpoffice/phpword": "^1.2"
     },
     "require-dev": {
         "facade/ignition": "^2.5",

File diff suppressed because it is too large
+ 396 - 154
composer.lock


+ 0 - 21
public/.htaccess

@@ -1,21 +0,0 @@
-<IfModule mod_rewrite.c>
-    <IfModule mod_negotiation.c>
-        Options -MultiViews -Indexes
-    </IfModule>
-
-    RewriteEngine On
-
-    # Handle Authorization Header
-    RewriteCond %{HTTP:Authorization} .
-    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
-
-    # Redirect Trailing Slashes If Not A Folder...
-    RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteCond %{REQUEST_URI} (.+)/$
-    RewriteRule ^ %1 [L,R=301]
-
-    # Send Requests To Front Controller...
-    RewriteCond %{REQUEST_FILENAME} !-d
-    RewriteCond %{REQUEST_FILENAME} !-f
-    RewriteRule ^ index.php [L]
-</IfModule>

+ 3 - 0
public/nginx.htaccess

@@ -0,0 +1,3 @@
+location / {
+    try_files $uri $uri/ /index.php?$query_string;
+}

+ 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'); //找回密码
+
+});
+
+

+ 14 - 0
routes/adminApi/contract.php

@@ -0,0 +1,14 @@
+<?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'); //删除
+
+});
+
+

+ 0 - 2
storage/app/public/.gitignore

@@ -1,2 +0,0 @@
-*
-!.gitignore

Some files were not shown because too many files changed in this diff