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
This commit is contained in:
55
pro_v3.5.1_副本/app/http/middleware/AllowOriginMiddleware.php
Normal file
55
pro_v3.5.1_副本/app/http/middleware/AllowOriginMiddleware.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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\http\middleware;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\facade\Config;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 跨域中间件
|
||||
* Class AllowOriginMiddleware
|
||||
* @package app\http\middleware
|
||||
*/
|
||||
class AllowOriginMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* 允许跨域的域名
|
||||
* @var string
|
||||
*/
|
||||
protected $cookieDomain;
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @return Response
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$this->cookieDomain = Config::get('cookie.domain', '');
|
||||
$header = Config::get('cookie.header');
|
||||
$origin = $request->header('origin');
|
||||
|
||||
if ($origin && ('' == $this->cookieDomain || strpos($origin, $this->cookieDomain)))
|
||||
$header['Access-Control-Allow-Origin'] = $origin;
|
||||
if ($request->method(true) == 'OPTIONS') {
|
||||
$response = Response::create('ok')->code(200)->header($header);
|
||||
} else {
|
||||
$response = $next($request)->header($header);
|
||||
}
|
||||
$request->filter(['strip_tags', 'addslashes', 'trim']);
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
34
pro_v3.5.1_副本/app/http/middleware/InstallMiddleware.php
Normal file
34
pro_v3.5.1_副本/app/http/middleware/InstallMiddleware.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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\http\middleware;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* Class InstallMiddleware
|
||||
* @package app\http\middleware
|
||||
*/
|
||||
class InstallMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
//检测是否已安装CRMEB系统
|
||||
if (!is_dir(root_path() . "public/install/") || !is_file(root_path() . "public/install/install.lock")) {
|
||||
return redirect('/install/index');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
32
pro_v3.5.1_副本/app/http/middleware/StationOpenMiddleware.php
Normal file
32
pro_v3.5.1_副本/app/http/middleware/StationOpenMiddleware.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?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\http\middleware;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 站点升级
|
||||
* Class StationOpenMiddleware
|
||||
* @package app\api\middleware
|
||||
*/
|
||||
class StationOpenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
if (!sys_config('station_open', true)) {
|
||||
return app('json')->make(410010, '站点升级中,请稍候访问');
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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\http\middleware\admin;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\system\admin\AdminAuthServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 后台登陆验证中间件
|
||||
* Class AdminAuthTokenMiddleware
|
||||
* @package app\http\middleware\admin
|
||||
*/
|
||||
class AdminAuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
|
||||
/** @var AdminAuthServices $service */
|
||||
$service = app()->make(AdminAuthServices::class);
|
||||
$adminInfo = $service->parseToken($token);
|
||||
|
||||
$request->isAdminLogin = !is_null($adminInfo);
|
||||
$request->adminId = $adminInfo['id'];
|
||||
$request->adminInfo = $adminInfo;
|
||||
$request->adminType = $adminInfo['admin_type'];
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?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\http\middleware\admin;
|
||||
|
||||
use app\Request;
|
||||
use app\services\system\SystemRoleServices;
|
||||
use crmeb\exceptions\AuthException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use crmeb\utils\ApiErrorCode;
|
||||
|
||||
/**
|
||||
* 权限规则验证
|
||||
* Class AdminCkeckRoleMiddleware
|
||||
* @package app\http\middleware
|
||||
*/
|
||||
class AdminCkeckRoleMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
if (!$request->adminId() || !$request->adminInfo())
|
||||
throw new AuthException(ApiErrorCode::ERR_ADMINID_VOID);
|
||||
// $data = [
|
||||
// 'adminapi/channel/merchant/verify'
|
||||
// ];
|
||||
// $noData = [
|
||||
// 'config/storage',
|
||||
// 'print/form',
|
||||
// 'edit_new_build/routine'
|
||||
// ];
|
||||
// $rule = trim(strtolower($request->rule()->getRule()));
|
||||
// foreach ($noData as $tiem){
|
||||
// if (strpos($rule, $tiem) !== false) {
|
||||
// return app('json')->fail('暂无权限');
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if ($request->adminId() != 1 && in_array($request->method(), ['POST', 'PUT', 'DELETE']) && !in_array($rule, $data)){
|
||||
// return app('json')->fail('暂无权限');
|
||||
// }
|
||||
if ($request->adminInfo()['level']) {
|
||||
/** @var SystemRoleServices $systemRoleService */
|
||||
$systemRoleService = app()->make(SystemRoleServices::class);
|
||||
$systemRoleService->verifiAuth($request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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\http\middleware\admin;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\jobs\system\AdminLogJob;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 日志中間件
|
||||
* Class AdminLogMiddleware
|
||||
* @package app\http\middleware\admin
|
||||
*/
|
||||
class AdminLogMiddleware implements MiddlewareInterface
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$module = app('http')->getName();
|
||||
$rule = trim(strtolower($request->rule()->getRule()));
|
||||
//记录后台日志
|
||||
AdminLogJob::dispatch([$request->adminId(), $request->adminInfo()['account'], $module, $rule, $request->ip(), 'system']);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
<?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\http\middleware\api;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\community\CommunityUserServices;
|
||||
use app\services\user\UserAuthServices;
|
||||
use crmeb\exceptions\AuthException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\exception\DbException;
|
||||
|
||||
/**
|
||||
* Class AuthTokenMiddleware
|
||||
* @package app\api\middleware
|
||||
*/
|
||||
class AuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function handle(Request $request, \Closure $next, bool $force = true)
|
||||
{
|
||||
|
||||
$authInfo = null;
|
||||
$token = trim(ltrim($request->header('Authori-zation'), 'Bearer'));
|
||||
if (!$token) $token = trim(ltrim($request->header('Authorization'), 'Bearer'));//正式版,删除此行,某些服务器无法获取到token调整为 Authori-zation
|
||||
try {
|
||||
/** @var UserAuthServices $service */
|
||||
$service = app()->make(UserAuthServices::class);
|
||||
$authInfo = $service->parseToken($token);
|
||||
} catch (AuthException $e) {
|
||||
if ($force)
|
||||
return app('json')->make($e->getCode(), $e->getMessage());
|
||||
}
|
||||
|
||||
if (!is_null($authInfo)) {
|
||||
$request->user = function (string $key = null) use (&$authInfo) {
|
||||
if ($key) {
|
||||
return $authInfo['user'][$key] ?? '';
|
||||
}
|
||||
return $authInfo['user'];
|
||||
};
|
||||
$request->tokenData = $authInfo['tokenData'];
|
||||
}
|
||||
$request->isLogin = !is_null($authInfo);
|
||||
$request->uid = is_null($authInfo) ? 0 : (int)$authInfo['user']->uid;
|
||||
if ($request->uid) {
|
||||
/** @var CommunityUserServices $communityUserServices */
|
||||
$communityUserServices = app()->make(CommunityUserServices::class);
|
||||
$communityUserServices->hasUser($request->uid);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
66
pro_v3.5.1_副本/app/http/middleware/api/BlockerMiddleware.php
Normal file
66
pro_v3.5.1_副本/app/http/middleware/api/BlockerMiddleware.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
namespace app\http\middleware\api;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use crmeb\exceptions\ApiException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use crmeb\services\CacheService;
|
||||
|
||||
/**
|
||||
* reids锁
|
||||
* Class BlockerMiddleware
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/21
|
||||
* @package app\http\middleware\api
|
||||
*/
|
||||
class BlockerMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/21
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$uid = $request->uid();
|
||||
$key = md5($request->rule()->getRule() . $uid. json_encode($request->param()));
|
||||
if (!CacheService::setMutex($key)) {
|
||||
throw new ApiException('请求太过频繁,请稍后再试');
|
||||
}
|
||||
|
||||
$response = $next($request);
|
||||
|
||||
$this->after($response, $key);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $response
|
||||
* @param $key
|
||||
* @author 等风来
|
||||
* @email 136327134@qq.com
|
||||
* @date 2022/11/22
|
||||
*/
|
||||
public function after($response, $key)
|
||||
{
|
||||
CacheService::delMutex($key);
|
||||
}
|
||||
}
|
||||
56
pro_v3.5.1_副本/app/http/middleware/api/ClientMiddleware.php
Normal file
56
pro_v3.5.1_副本/app/http/middleware/api/ClientMiddleware.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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\http\middleware\api;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\UserAuthServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 客户身份验证中间件
|
||||
* Class ClientMiddleware
|
||||
* @package app\http\middleware\api
|
||||
*/
|
||||
class ClientMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$userId = trim(ltrim($request->param('userid')));
|
||||
|
||||
if (!$userId) {
|
||||
return app('json')->fail('缺少Userid');
|
||||
}
|
||||
|
||||
try {
|
||||
/** @var UserAuthServices $service */
|
||||
$service = app()->make(UserAuthServices::class);
|
||||
$authInfo = $service->parseClient($userId);
|
||||
} catch (\Throwable $e) {
|
||||
return app('json')->fail($e->getMessage());
|
||||
}
|
||||
|
||||
$request->clientInfo = function (string $key = null) use ($authInfo) {
|
||||
if ($key) {
|
||||
return $authInfo[$key] ?? null;
|
||||
} else {
|
||||
return $authInfo;
|
||||
}
|
||||
};
|
||||
|
||||
$request->userid = $userId;
|
||||
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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\http\middleware\api;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\community\CommunityUserServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 社区是否开启
|
||||
* Class StationOpenMiddleware
|
||||
* @package app\api\middleware
|
||||
*/
|
||||
class CommunityOpenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
if (!sys_config('community_status', 1)) {
|
||||
return app('json')->make('410010', '社区暂未开放');
|
||||
}
|
||||
//社区用户写入
|
||||
$uid = $request->hasMacro('uid') ? $request->uid() : 0;
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
38
pro_v3.5.1_副本/app/http/middleware/api/CustomerMiddleware.php
Normal file
38
pro_v3.5.1_副本/app/http/middleware/api/CustomerMiddleware.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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\http\middleware\api;
|
||||
|
||||
use app\services\message\service\StoreServiceServices;
|
||||
use app\services\store\DeliveryServiceServices;
|
||||
use app\services\store\SystemStoreStaffServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use app\Request;
|
||||
|
||||
class CustomerMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$uid = (int)$request->uid();
|
||||
/** @var StoreServiceServices $services */
|
||||
$services = app()->make(StoreServiceServices::class);
|
||||
/** @var SystemStoreStaffServices $storeServices */
|
||||
$storeServices = app()->make(SystemStoreStaffServices::class);
|
||||
$rule = trim(strtolower($request->rule()->getRule()));
|
||||
/** @var DeliveryServiceServices $deliveryService */
|
||||
$deliveryService = app()->make(DeliveryServiceServices::class);
|
||||
$isDelivery = $deliveryService->checkoutIsService($uid);
|
||||
$withRule = ['/api/order/order_verific', "/api/admin/order/detail/<orderId>"];
|
||||
if (((!$services->checkoutIsService(['uid' => $uid, 'account_status' => 1, 'customer' => 1]) && !$storeServices->verifyStatus($uid)) && !$isDelivery) && !(in_array($rule, $withRule)))
|
||||
return app('json')->fail('权限不足');
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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\http\middleware\api;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\user\LoginServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 全局修改绑定分销关系
|
||||
* Class ClientMiddleware
|
||||
* @package app\http\middleware\api
|
||||
*/
|
||||
class UserSpreadMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$spread_uid = trim(ltrim($request->param('spread_sid')));
|
||||
//登录存在用户信息
|
||||
$user = $request->hasMacro('user') ? $request->user() : [];
|
||||
//更新绑定关系
|
||||
if ($user && $spread_uid) {
|
||||
/** @var LoginServices $loginServices */
|
||||
$loginServices = app()->make(LoginServices::class);
|
||||
$loginServices->updateUserInfo(['spread_uid' => $spread_uid], $user);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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\http\middleware\kefu;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\kefu\LoginServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* Class KefuAuthTokenMiddleware
|
||||
* @package app\kefu\middleware
|
||||
*/
|
||||
class KefuAuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$authInfo = null;
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
/** @var LoginServices $services */
|
||||
$services = app()->make(LoginServices::class);
|
||||
$kefuInfo = $services->parseToken($token);
|
||||
|
||||
$request->kefuId = (int)$kefuInfo['id'];
|
||||
|
||||
$request->kefuInfo = $kefuInfo;
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?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\http\middleware\out;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\out\OutAccountServices;
|
||||
use app\services\out\OutInterfaceServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* Class AuthTokenMiddleware
|
||||
* @package app\http\middleware\out
|
||||
*/
|
||||
class AuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$authInfo = null;
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
/** @var OutAccountServices $services */
|
||||
$services = app()->make(OutAccountServices::class);
|
||||
$outInfo = $services->parseToken($token);
|
||||
|
||||
$request->outId = (int)$outInfo['out_id'];
|
||||
|
||||
$request->outInfo = $outInfo;
|
||||
|
||||
/** @var OutInterfaceServices $outInterfaceServices */
|
||||
$outInterfaceServices = app()->make(OutInterfaceServices::class);
|
||||
$outInterfaceServices->verifyAuth($request);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?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\http\middleware\supplier;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\services\supplier\LoginServices;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* Class AuthTokenMiddleware
|
||||
* @package app\http\middleware\supplier
|
||||
*/
|
||||
class AuthTokenMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
|
||||
/** @var LoginServices $services */
|
||||
$services = app()->make(LoginServices::class);
|
||||
$outInfo = $services->parseToken($token);
|
||||
$request->supplierId = (int)$outInfo['id'];
|
||||
|
||||
$request->supplierInfo = $outInfo;
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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\http\middleware\supplier;
|
||||
|
||||
use app\Request;
|
||||
|
||||
use app\services\supplier\LoginServices;
|
||||
use crmeb\exceptions\AuthException;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
use crmeb\utils\ApiErrorCode;
|
||||
|
||||
/**
|
||||
* 权限规则验证
|
||||
* Class SupplierCheckRoleMiddleware
|
||||
* @package app\http\middleware\supplier
|
||||
*/
|
||||
class SupplierCheckRoleMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
if (!$request->supplierId() || !$request->supplierInfo())
|
||||
throw new AuthException(ApiErrorCode::ERR_ADMINID_VOID);
|
||||
|
||||
if ($request->supplierInfo()['level'] ?? 0) {
|
||||
/** @var LoginServices $services */
|
||||
$services = app()->make(LoginServices::class);
|
||||
$services->verifiAuth($request);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?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\http\middleware\supplier;
|
||||
|
||||
|
||||
use app\Request;
|
||||
use app\jobs\system\AdminLogJob;
|
||||
use crmeb\interfaces\MiddlewareInterface;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
* Class SupplierLogMiddleware
|
||||
* @package app\http\middleware\supplier
|
||||
*/
|
||||
class SupplierLogMiddleware implements MiddlewareInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, \Closure $next)
|
||||
{
|
||||
$module = app('http')->getName();
|
||||
$rule = trim(strtolower($request->rule()->getRule()));
|
||||
//记录后台日志
|
||||
AdminLogJob::dispatch([$request->supplierId(), $request->supplierInfo()['supplier_name'], $module, $rule, $request->ip(), 'supplier']);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user