2025-07-01 19:39:13 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace app\controller;
|
|
|
|
|
|
2025-09-16 10:45:02 +08:00
|
|
|
use app\common\model\Resource;
|
2025-09-15 15:01:19 +08:00
|
|
|
use app\common\service\SysDictService;
|
2025-09-09 16:15:48 +08:00
|
|
|
use app\common\service\UploadService;
|
2025-07-29 09:00:04 +08:00
|
|
|
use app\common\utils\scaffold\Generate;
|
2025-07-01 19:39:13 +08:00
|
|
|
use support\Request;
|
2025-07-14 10:08:29 +08:00
|
|
|
use support\Db;
|
|
|
|
|
use support\Cache;
|
2025-09-23 11:54:26 +08:00
|
|
|
use support\Redis;
|
2025-09-26 15:50:23 +08:00
|
|
|
use GuzzleHttp\Client;
|
2025-07-01 19:39:13 +08:00
|
|
|
|
|
|
|
|
class IndexController
|
|
|
|
|
{
|
2025-07-11 18:01:23 +08:00
|
|
|
|
2025-11-11 16:46:22 +08:00
|
|
|
protected $noNeedLogin = ['index', 'view', 'perm', 'createResource', 'pdf', 'test'];
|
2025-07-29 09:00:04 +08:00
|
|
|
|
2025-11-11 16:46:22 +08:00
|
|
|
protected $noNeedHeaderData = ['index', 'view', 'perm', 'createResource', 'pdf', 'test'];
|
2025-07-11 18:01:23 +08:00
|
|
|
|
2025-07-01 19:39:13 +08:00
|
|
|
public function index(Request $request)
|
|
|
|
|
{
|
2025-07-11 18:01:23 +08:00
|
|
|
return htmlpage();
|
2025-07-01 19:39:13 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-29 09:00:04 +08:00
|
|
|
/**
|
|
|
|
|
* 调试飞书
|
|
|
|
|
*/
|
2025-07-01 19:39:13 +08:00
|
|
|
public function view(Request $request)
|
|
|
|
|
{
|
2025-07-11 18:01:23 +08:00
|
|
|
return view('index/qrcode', ['name' => 'webman']);
|
2025-07-01 19:39:13 +08:00
|
|
|
}
|
|
|
|
|
|
2025-07-29 09:00:04 +08:00
|
|
|
/**
|
|
|
|
|
* 临时增加用户权限
|
|
|
|
|
*/
|
2025-07-14 10:08:29 +08:00
|
|
|
public function perm(Request $request)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$data = $request->get();
|
|
|
|
|
|
|
|
|
|
if (Db::table('user_roles')->where('user_id', $data['user_id'])->first()) {
|
|
|
|
|
Db::table('user_roles')->where('user_id', $data['user_id'])->update([
|
|
|
|
|
'role_id' => $data['role_id']
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
Db::table('user_roles')->insert([
|
|
|
|
|
'user_id' => $data['user_id'],
|
|
|
|
|
'role_id' => $data['role_id']
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!Db::table('user_systems')->where('user_id', $data['user_id'])->where('system_id', $data['system_id'])->first()) {
|
|
|
|
|
Db::table('user_systems')->where('user_id', $data['user_id'])->insert([
|
|
|
|
|
'user_id' => $data['user_id'],
|
|
|
|
|
'system_id' => $data['system_id'],
|
|
|
|
|
'created_at' => time()
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-14 12:00:36 +08:00
|
|
|
Cache::delete("user_resources_{$data['user_id']}");
|
2025-07-14 10:08:29 +08:00
|
|
|
return json(['code' => 0, 'msg' => 'success']);
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
return json(['code' => 1, 'msg' => $e->getMessage()]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-07-15 10:23:05 +08:00
|
|
|
|
2025-07-29 09:00:04 +08:00
|
|
|
/**
|
|
|
|
|
* 生成资源
|
|
|
|
|
*/
|
|
|
|
|
public function createResource()
|
|
|
|
|
{
|
2025-10-10 11:09:37 +00:00
|
|
|
$options = [
|
|
|
|
|
'controller' => [
|
|
|
|
|
'module' => 'common',
|
2025-11-11 16:46:22 +08:00
|
|
|
'name' => 'finance_recon_dubai_files'
|
2025-10-10 11:09:37 +00:00
|
|
|
],
|
|
|
|
|
'model' => [
|
|
|
|
|
'module' => 'common',
|
2025-11-11 16:46:22 +08:00
|
|
|
'name' => 'finance_recon_dubai_files'
|
2025-10-10 11:09:37 +00:00
|
|
|
],
|
|
|
|
|
'service' => [
|
|
|
|
|
'module' => 'common',
|
2025-11-11 16:46:22 +08:00
|
|
|
'name' => 'finance_recon_dubai_files'
|
2025-10-10 11:09:37 +00:00
|
|
|
],
|
|
|
|
|
'logic' => [
|
|
|
|
|
'module' => 'common',
|
2025-11-11 16:46:22 +08:00
|
|
|
'name' => 'finance_recon_dubai_files'
|
2025-10-10 11:09:37 +00:00
|
|
|
],
|
|
|
|
|
'validate' => [
|
|
|
|
|
'module' => 'common',
|
2025-11-11 16:46:22 +08:00
|
|
|
'name' => 'finance_recon_dubai_files'
|
2025-10-10 11:09:37 +00:00
|
|
|
],
|
2025-11-11 16:46:22 +08:00
|
|
|
'table' => 'finance_recon_dubai_files'
|
2025-10-10 11:09:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$result = (new Generate($options))->doGenerate();
|
|
|
|
|
return $result;
|
2025-07-29 09:00:04 +08:00
|
|
|
}
|
|
|
|
|
|
2025-10-12 17:40:37 +08:00
|
|
|
/**
|
|
|
|
|
* 菜单迁移
|
|
|
|
|
*/
|
|
|
|
|
public function doMenu()
|
|
|
|
|
{
|
|
|
|
|
// 菜单迁移 (部分)
|
|
|
|
|
$where[] = ['id', '>', 239];
|
|
|
|
|
(new \app\common\utils\MigrationResources())->do('resources', 'resources_20251012_bak', $where);
|
|
|
|
|
|
|
|
|
|
// 整体
|
|
|
|
|
// $list = (new \app\common\utils\MigrationResources())->getFullResourceTreeOptimized('resources_20250916_bak', []);
|
|
|
|
|
// var_dump($list);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-29 09:00:04 +08:00
|
|
|
|
2025-11-11 16:46:22 +08:00
|
|
|
public function pdf(Request $request)
|
2025-09-16 10:45:02 +08:00
|
|
|
{
|
2025-10-21 14:05:40 +08:00
|
|
|
$id = $request->get('id');
|
|
|
|
|
$service = new \app\common\service\StockOrdersService();
|
|
|
|
|
$service->createdPdfFile($id);
|
2025-10-12 06:22:29 +00:00
|
|
|
return json(['code' => 0, 'msg' => 'success']);
|
2025-09-26 15:50:23 +08:00
|
|
|
}
|
2025-09-24 11:18:59 +08:00
|
|
|
|
2025-09-15 15:01:19 +08:00
|
|
|
|
2025-09-26 15:50:23 +08:00
|
|
|
public function tocurl($url, $header = null, $content = null)
|
|
|
|
|
{
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|
if(substr($url,0,5)=='https'){
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
|
|
|
|
|
curl_setopt($ch, CURLOPT_SSLVERSION, 1);
|
|
|
|
|
}
|
|
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
|
if (is_array($header)) {
|
|
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
|
|
}
|
|
|
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
|
|
|
|
if (!empty($content)) {
|
|
|
|
|
if (is_array($content)) {
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($content));
|
|
|
|
|
} else if (is_string($content)) {
|
|
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$response = curl_exec($ch);
|
|
|
|
|
$error=curl_error($ch);
|
|
|
|
|
if($error){
|
|
|
|
|
die($error);
|
|
|
|
|
}
|
|
|
|
|
$header = curl_getinfo($ch);
|
|
|
|
|
curl_close($ch);
|
|
|
|
|
$data = array('header' => $header,'body' => $response);
|
|
|
|
|
return $data;
|
2025-07-15 10:23:05 +08:00
|
|
|
}
|
2025-11-11 16:46:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function test(Request $request)
|
|
|
|
|
{
|
|
|
|
|
$tmp = (new \app\common\service\OssService)->generatePrivateUrl('fdesk_test/20251104/20251104_财务.xlsx');;
|
|
|
|
|
|
|
|
|
|
$service = new \app\common\service\FinanceRecoDubaiFilesService();
|
|
|
|
|
$result = $service->import($tmp, true);
|
|
|
|
|
|
|
|
|
|
return json(['code' => 0, 'msg' => 'ok', 'data' => $result]);
|
|
|
|
|
}
|
2025-07-11 18:01:23 +08:00
|
|
|
}
|