Files
huangjingfen/pro_v3.5.1_副本/app/services/system/log/SystemFileServices.php
apple 434aa8c69d feat(fsgx): 完成全部24项开发任务 Phase1-7
Phase1 后端核心:
- 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess)
- SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机)
- StoreOrderCreateServices 周期循环佣金计算
- StoreOrderTakeServices 佣金发放后同步冻结积分
- StoreProductServices/StoreProduct 保存 is_queue_goods

Phase2 后端接口:
- GET /api/hjf/brokerage/progress 佣金周期进度
- GET /api/hjf/assets/overview 资产总览
- HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务
- PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口
- GET /adminapi/hjf/points/release_log 积分日志接口

Phase3 前端清理:
- hjfCustom.js 路由精简(仅保留 points/log)
- hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口
- pages.json 公排→推荐佣金/佣金记录/佣金规则

Phase4-5 前端改造:
- queue/status.vue 推荐佣金进度页整体重写
- 商品详情/订单确认/支付结果页文案与逻辑改造
- 个人中心/资产页/引导页/规则页文案改造
- HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造
- 推广中心嵌入佣金进度摘要
- hjfMockData.js 全量更新(公排字段→佣金字段)

Phase6 Admin 增强:
- 用户列表新增 frozen_points/available_points 列及不考核操作按钮
- hjfPoints.js USE_MOCK=false 对接真实积分日志接口

Phase7 配置文档:
- docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单

Made-with: Cursor
2026-03-23 22:32:19 +08:00

256 lines
8.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\services\system\log;
use app\dao\system\log\SystemFileDao;
use app\services\BaseServices;
use crmeb\exceptions\AdminException;
use crmeb\services\CacheService;
use crmeb\services\FileService as FileClass;
use think\annotation\Inject;
/**
* 文件校验
* Class SystemFileServices
* @package app\services\system\log
* @mixin SystemFileDao
*/
class SystemFileServices extends BaseServices
{
/**
* @var SystemFileDao
*/
#[Inject]
protected SystemFileDao $dao;
/**
* 获取文件校验列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getFileList()
{
$rootPath = app()->getRootPath();
$key = 'system_file_app_crmeb_public';
$arr = CacheService::get(md5($key));
if (!$arr) {
$app = $this->getDir($rootPath . 'app');
$extend = $this->getDir($rootPath . 'crmeb');
$arr = array_merge($app, $extend);
CacheService::set(md5($key), $arr, 3600 * 24);
}
$fileAll = [];//本地文件
$cha = [];//不同的文件
$len = strlen($rootPath);
$fileKey = 'system_file_app_msyql';
$file = CacheService::get(md5($fileKey));
if (!$file) {
$file = $this->dao->getAll();//数据库中的文件
CacheService::set(md5($fileKey), $file, 3600 * 24);
}
if (empty($file)) {
foreach ($arr as $k => $v) {
$update_time = stat($v);
$fileAll[$k]['cthash'] = md5_file($v);
$fileAll[$k]['filename'] = substr($v, $len);
$fileAll[$k]['atime'] = $update_time['atime'];
$fileAll[$k]['mtime'] = $update_time['mtime'];
$fileAll[$k]['ctime'] = $update_time['ctime'];
}
$data_num = array_chunk($fileAll, 100);
$res = true;
$res = $this->transaction(function () use ($data_num, $res) {
foreach ($data_num as $k => $v) {
$res = $res && $this->dao->saveAll($v);
}
return $res;
});
if ($res) {
$cha = [];//不同的文件
} else {
$cha = $fileAll;
}
} else {
$file = array_combine(array_column($file, 'filename'), $file);
$insertData = [];
foreach ($arr as $ko => $vo) {
$update_time = stat($vo);
$cthash = md5_file($vo);
$fileName = substr($vo, $len);
$data = [
'filename' => $fileName,
'cthash' => $cthash,
'atime' => $update_time['atime'] ?? 0,
'mtime' => $update_time['mtime'] ?? 0,
'ctime' => $update_time['ctime'] ?? 0,
];
if (isset($file[$fileName])) {
$data ['type'] = $file[$fileName]['cthash'] != $cthash ? '已修改' : '新增的';
unset($file[$fileName]);
} else {//新增
$insertData[] = $data;
$data['type'] = '新增的';
}
$data['atime'] = (int)$data['atime'] ? date('Y-m-d H:i:s', (int)$data['atime']) : '';
$data['mtime'] = (int)$data['mtime'] ? date('Y-m-d H:i:s', (int)$data['mtime']) : '';
$data['ctime'] = (int)$data['ctime'] ? date('Y-m-d H:i:s', (int)$data['ctime']) : '';
$cha[] = $data;
}
if ($insertData) {
$this->dao->saveAll($insertData);
CacheService::delete(md5($fileKey));
}
foreach ($file as $k => $v) {
$cha[] = [
'filename' => $v['filename'],
'cthash' => $v['cthash'],
'atime' => (int)$v['atime'] ? date('Y-m-d H:i:s', (int)$v['atime']) : '',
'mtime' => (int)$v['mtime'] ? date('Y-m-d H:i:s', (int)$v['mtime']) : '',
'ctime' => (int)$v['ctime'] ? date('Y-m-d H:i:s', (int)$v['ctime']) : '',
'type' => '已删除',
];
}
}
$ctime = array_column($cha, 'ctime');
array_multisort($ctime, SORT_DESC, $cha);
return $cha;
}
/**
* 获取文件夹中的文件 包括子文件
* @param $dir
* @return array
*/
public function getDir($dir)
{
$data = [];
$this->searchDir($dir, $data);
return $data;
}
/**
* 获取文件夹中的文件 包括子文件 不能直接用 直接使用 $this->getDir()方法 P156
* @param $path
* @param $data
*/
public function searchDir($path, &$data)
{
if (is_dir($path) && !strpos($path, 'uploads')) {
$files = scandir($path);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
$this->searchDir($path . '/' . $file, $data);
}
}
}
if (is_file($path)) {
$data[] = $path;
}
}
/**
* 打开目录获取文件列表
* @return array
*/
public function opendir()
{
$fileAll = array('dir' => [], 'file' => []);
//根目录
$rootdir = app()->getRootPath();
// return $rootdir;
//当前目录
$request_dir = app('request')->param('dir');
//防止查看站点以外的目录
if (strpos($request_dir, $rootdir) === false) {
$request_dir = $rootdir;
}
//判断是否是返回上级
if (app('request')->param('superior') && !empty($request_dir)) {
if (strpos(dirname($request_dir), $rootdir) !== false) {
$dir = dirname($request_dir);
} else {
$dir = $rootdir;
}
} else {
$dir = !empty($request_dir) ? $request_dir : $rootdir;
$dir = rtrim($dir, DS) . DS . app('request')->param('filedir');
}
$list = scandir($dir);
foreach ($list as $key => $v) {
if ($v != '.' && $v != '..') {
if (is_dir($dir . DS . $v)) {
$fileAll['dir'][] = FileClass::listInfo($dir . DS . $v);
}
if (is_file($dir . DS . $v)) {
$fileAll['file'][] = FileClass::listInfo($dir . DS . $v);
}
}
}
//兼容windows
$uname = php_uname('s');
if (strstr($uname, 'Windows') !== false) {
$dir = ltrim($dir, '\\');
$rootdir = str_replace('\\', '\\\\', $rootdir);
}
$list = array_merge($fileAll['dir'], $fileAll['file']);
foreach ($list as $key => $value) {
$list[$key]['real_path'] = str_replace($rootdir, '', $value['pathname']);
$list[$key]['mtime'] = date('Y-m-d H:i:s', $value['mtime']);
}
return compact('dir', 'list');
}
/**
* 读取文件内容
* @param string $filepath 文件路径
* @return array
*/
public function openfile($filepath)
{
$content = FileClass::readFile($filepath);//防止页面内嵌textarea标签
$ext = FileClass::getExt($filepath);
$extarray = [
'js' => 'text/javascript'
, 'php' => 'text/x-php'
, 'html' => 'text/html'
, 'sql' => 'text/x-mysql'
, 'css' => 'text/x-scss'];
$mode = empty($extarray[$ext]) ? '' : $extarray[$ext];
return compact('content', 'mode', 'filepath');
}
/**
* 保存文件内容
* @param string $filepath 文件路径
* @param string $comment 文件内容
* @return bool
* @throws AdminException
*/
public function savefile($filepath, $comment)
{
//兼容windows
$uname = php_uname('s');
if (strstr($uname, 'Windows') !== false)
$filepath = ltrim(str_replace('/', DS, $filepath), '.');
if (!FileClass::isWritable($filepath)) {
throw new AdminException('没有权限');
}
return FileClass::writeFile($filepath, $comment);
}
}