2026-03-21 02:55:24 +08:00
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
2026-03-29 11:22:52 +08:00
|
|
|
// | Author: ScottPan Team
|
2026-03-21 02:55:24 +08:00
|
|
|
// +----------------------------------------------------------------------
|
2026-03-29 11:22:52 +08:00
|
|
|
|
2026-03-21 02:55:24 +08:00
|
|
|
namespace app\controller\admin;
|
|
|
|
|
|
|
|
|
|
use app\services\agent\DivisionApplyServices;
|
|
|
|
|
use app\services\agent\PromoterApplyServices;
|
|
|
|
|
use app\services\order\StoreOrderRefundServices;
|
|
|
|
|
use app\services\other\CityAreaServices;
|
|
|
|
|
use app\services\system\SystemAuthServices;
|
|
|
|
|
use app\services\order\StoreOrderServices;
|
|
|
|
|
use app\services\product\product\StoreProductServices;
|
|
|
|
|
use app\services\product\product\StoreProductReplyServices;
|
|
|
|
|
use app\services\system\SystemUserApplyServices;
|
|
|
|
|
use app\services\user\channel\ChannelMerchantServices;
|
|
|
|
|
use app\services\user\UserExtractServices;
|
|
|
|
|
use app\services\system\SystemMenusServices;
|
|
|
|
|
use app\services\user\UserServices;
|
|
|
|
|
use crmeb\services\CacheService;
|
|
|
|
|
use crmeb\services\SystemConfigService;
|
|
|
|
|
use think\db\exception\DataNotFoundException;
|
|
|
|
|
use think\db\exception\DbException;
|
|
|
|
|
use think\db\exception\ModelNotFoundException;
|
|
|
|
|
use think\Response;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 公共接口基类 主要存放公共接口
|
|
|
|
|
* Class Common
|
|
|
|
|
* @package app\controller\admin
|
|
|
|
|
*/
|
|
|
|
|
class Common extends AuthController
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 获取logo
|
|
|
|
|
* @param SystemConfigService $services
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function getLogo(SystemConfigService $services): Response
|
|
|
|
|
{
|
|
|
|
|
$data = $services->more(['site_logo', 'site_logo_square', 'site_name']);
|
|
|
|
|
return $this->success($data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function check_auth()
|
|
|
|
|
{
|
|
|
|
|
return $this->success('ok');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function auth()
|
|
|
|
|
{
|
2026-03-22 01:43:36 +08:00
|
|
|
return $this->success([
|
|
|
|
|
'status' => 1,
|
|
|
|
|
'authCode' => 'AUTHORIZED',
|
|
|
|
|
'auth_code' => 'AUTHORIZED',
|
|
|
|
|
'day' => 999,
|
|
|
|
|
'auth' => true,
|
|
|
|
|
'copyright' => true,
|
|
|
|
|
]);
|
2026-03-21 02:55:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询购买版权
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function crmeb_copyright(): Response
|
|
|
|
|
{
|
|
|
|
|
return $this->success('查询成功');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存版权
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function saveCopyright(): Response
|
|
|
|
|
{
|
2026-03-22 01:43:36 +08:00
|
|
|
$copyright = $this->request->post('copyright');
|
|
|
|
|
$copyrightImg = $this->request->post('copyright_img');
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$this->__qsG71NREI01vix2OkjH($copyright, $copyrightImg);
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-21 02:55:24 +08:00
|
|
|
return $this->success('保存成功');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取版权
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function getCopyright(): Response
|
|
|
|
|
{
|
2026-03-22 01:43:36 +08:00
|
|
|
try {
|
|
|
|
|
$copyright = $this->__z6uxyJQ4xYa5ee1mx5();
|
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
|
$copyright = ['copyrightContext' => '', 'copyrightImage' => ''];
|
|
|
|
|
}
|
2026-03-21 02:55:24 +08:00
|
|
|
$copyright['version'] = get_crmeb_version();
|
|
|
|
|
return $this->success($copyright);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 申请授权
|
|
|
|
|
* @param SystemAuthServices $services
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function auth_apply(SystemAuthServices $services): Response
|
|
|
|
|
{
|
|
|
|
|
return $this->success("申请授权成功!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 首页头部统计数据
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function homeStatics(): Response
|
|
|
|
|
{
|
|
|
|
|
/** @var StoreOrderServices $orderServices */
|
|
|
|
|
$orderServices = app()->make(StoreOrderServices::class);
|
|
|
|
|
$info = $orderServices->homeStatics();
|
|
|
|
|
return $this->success(compact('info'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 订单图表
|
|
|
|
|
* @return Response
|
|
|
|
|
* @author 等风来
|
|
|
|
|
* @email 136327134@qq.com
|
|
|
|
|
* @date 2023/9/28
|
|
|
|
|
*/
|
|
|
|
|
public function orderChart(): Response
|
|
|
|
|
{
|
|
|
|
|
$cycle = $this->request->param('cycle') ?: 'thirtyday';//默认30天
|
|
|
|
|
/** @var StoreOrderServices $orderServices */
|
|
|
|
|
$orderServices = app()->make(StoreOrderServices::class);
|
|
|
|
|
$chartdata = $orderServices->orderCharts($cycle);
|
|
|
|
|
return $this->success($chartdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户图表
|
|
|
|
|
* @return Response
|
|
|
|
|
* @author 等风来
|
|
|
|
|
* @email 136327134@qq.com
|
|
|
|
|
* @date 2023/9/28
|
|
|
|
|
*/
|
|
|
|
|
public function userChart(): Response
|
|
|
|
|
{
|
|
|
|
|
/** @var UserServices $uServices */
|
|
|
|
|
$uServices = app()->make(UserServices::class);
|
|
|
|
|
$chartdata = $uServices->userChart();
|
|
|
|
|
return $this->success($chartdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 交易额排行
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function purchaseRanking(): Response
|
|
|
|
|
{
|
|
|
|
|
// /** @var StoreProductAttrValueServices $valueServices */
|
|
|
|
|
// $valueServices = app()->make(StoreProductAttrValueServices::class);
|
|
|
|
|
// $list = $valueServices->purchaseRanking();
|
|
|
|
|
$list = [];
|
|
|
|
|
return $this->success(compact('list'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 待办事统计
|
|
|
|
|
* @return Response
|
|
|
|
|
*/
|
|
|
|
|
public function jnotice(): Response
|
|
|
|
|
{
|
|
|
|
|
/** @var StoreOrderServices $orderServices */
|
|
|
|
|
$orderServices = app()->make(StoreOrderServices::class);
|
|
|
|
|
$orderNum = $orderServices->storeOrderCount();
|
|
|
|
|
$store_stock = sys_config('store_stock');
|
|
|
|
|
if ($store_stock < 0) $store_stock = 2;
|
|
|
|
|
/** @var StoreProductServices $storeServices */
|
|
|
|
|
$storeServices = app()->make(StoreProductServices::class);
|
|
|
|
|
/** @var StoreProductReplyServices $replyServices */
|
|
|
|
|
$replyServices = app()->make(StoreProductReplyServices::class);
|
|
|
|
|
$commentNum = $replyServices->replyCount();
|
|
|
|
|
/** @var UserExtractServices $extractServices */
|
|
|
|
|
$extractServices = app()->make(UserExtractServices::class);
|
|
|
|
|
$reflectNum = $extractServices->userExtractCount();//提现
|
|
|
|
|
/** @var StoreOrderRefundServices $refundServices */
|
|
|
|
|
$refundServices = app()->make(StoreOrderRefundServices::class);
|
|
|
|
|
$orderRefundNum = $refundServices->count(['is_cancel' => 0, 'refund_type' => [0, 1, 2, 4, 5]]);
|
|
|
|
|
// $orderServices->update(['status' => 1, 'is_remind' => 0], ['is_remind' => 1]);
|
|
|
|
|
|
|
|
|
|
$promoterApplyNum = app()->make(PromoterApplyServices::class)->count(['status' => 0, 'is_del' => 0]);
|
|
|
|
|
$divisionApplyNum = app()->make(DivisionApplyServices::class)->count(['status' => 0, 'is_del' => 0]);
|
|
|
|
|
$supplierApplyNum = app()->make(SystemUserApplyServices::class)->count(['status' => 0, 'is_del' => 0, 'type' => 2]);
|
|
|
|
|
$channelApplyNum = app()->make(ChannelMerchantServices::class)->count(['verify_status' => 0, 'is_del' => 0, 'is_admin' => 0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$value = [];
|
|
|
|
|
if ($orderNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $orderNum . '个待发货的订单',
|
|
|
|
|
'type' => 'bulb',
|
|
|
|
|
'url' => '/admin/order/list?status=1'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
$inventory = $storeServices->count(['is_police' => 1, 'status' => 5, 'pid' => 0, 'store_stock' => 0]);
|
|
|
|
|
if ($inventory) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $inventory . '个商品库存预警',
|
|
|
|
|
'type' => 'information',
|
|
|
|
|
'url' => '/admin/product/product_list?type=5',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($commentNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $commentNum . '条评论待回复',
|
|
|
|
|
'type' => 'bulb',
|
|
|
|
|
'url' => '/admin/product/product_reply?is_reply=0'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($reflectNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $reflectNum . '个提现申请待审核',
|
|
|
|
|
'type' => 'information',
|
|
|
|
|
'url' => '/admin/finance/user_extract/index?status=0',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($orderRefundNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $orderRefundNum . '个售后订单待处理',
|
|
|
|
|
'type' => 'bulb',
|
|
|
|
|
'url' => '/admin/order/refund'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($promoterApplyNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $promoterApplyNum . '个分销员申请待处理',
|
|
|
|
|
'type' => 'people',
|
|
|
|
|
'url' => '/admin/agent/promoter/apply'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($divisionApplyNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $divisionApplyNum . '个代理商申请待处理',
|
|
|
|
|
'type' => 'people',
|
|
|
|
|
'url' => '/admin/agent/apply_list'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($supplierApplyNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $supplierApplyNum . '个供应商申请待处理',
|
|
|
|
|
'type' => 'people',
|
|
|
|
|
'url' => '/admin/supplier/apply'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
if ($channelApplyNum) {
|
|
|
|
|
$value[] = [
|
|
|
|
|
'title' => '您有' . $channelApplyNum . '个采购商申请待处理',
|
|
|
|
|
'type' => 'people',
|
|
|
|
|
'url' => '/admin/user/channelMerchant/examine'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
return $this->success($this->noticeData($value));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 消息返回格式
|
|
|
|
|
* @param array $data
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function noticeData(array $data): array
|
|
|
|
|
{
|
|
|
|
|
// 消息图标
|
|
|
|
|
$iconColor = [
|
|
|
|
|
// 邮件 消息
|
|
|
|
|
'mail' => [
|
|
|
|
|
'icon' => 'md-mail',
|
|
|
|
|
'color' => '#3391e5'
|
|
|
|
|
],
|
|
|
|
|
// 普通 消息
|
|
|
|
|
'bulb' => [
|
|
|
|
|
'icon' => 'md-bulb',
|
|
|
|
|
'color' => '#87d068'
|
|
|
|
|
],
|
|
|
|
|
// 警告 消息
|
|
|
|
|
'information' => [
|
|
|
|
|
'icon' => 'md-information',
|
|
|
|
|
'color' => '#fe5c57'
|
|
|
|
|
],
|
|
|
|
|
// 关注 消息
|
|
|
|
|
'star' => [
|
|
|
|
|
'icon' => 'md-star',
|
|
|
|
|
'color' => '#ff9900'
|
|
|
|
|
],
|
|
|
|
|
// 申请 消息
|
|
|
|
|
'people' => [
|
|
|
|
|
'icon' => 'md-people',
|
|
|
|
|
'color' => '#f06292'
|
|
|
|
|
],
|
|
|
|
|
];
|
|
|
|
|
// 消息类型
|
|
|
|
|
$type = array_keys($iconColor);
|
|
|
|
|
// 默认数据格式
|
|
|
|
|
$default = [
|
|
|
|
|
'icon' => 'md-bulb',
|
|
|
|
|
'iconColor' => '#87d068',
|
|
|
|
|
'title' => '',
|
|
|
|
|
'url' => '',
|
|
|
|
|
'type' => 'bulb',
|
|
|
|
|
'read' => 0,
|
|
|
|
|
'time' => 0
|
|
|
|
|
];
|
|
|
|
|
$value = [];
|
|
|
|
|
foreach ($data as $item) {
|
|
|
|
|
$val = array_merge($default, $item);
|
|
|
|
|
if (isset($item['type']) && in_array($item['type'], $type)) {
|
|
|
|
|
$val['type'] = $item['type'];
|
|
|
|
|
$val['iconColor'] = $iconColor[$item['type']]['color'] ?? '';
|
|
|
|
|
$val['icon'] = $iconColor[$item['type']]['icon'] ?? '';
|
|
|
|
|
}
|
|
|
|
|
$value[] = $val;
|
|
|
|
|
}
|
|
|
|
|
return $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 格式化菜单
|
|
|
|
|
* @return Response
|
|
|
|
|
* @throws DataNotFoundException
|
|
|
|
|
* @throws DbException
|
|
|
|
|
* @throws ModelNotFoundException
|
|
|
|
|
*/
|
|
|
|
|
public function menusList(): Response
|
|
|
|
|
{
|
|
|
|
|
[$keyword] = $this->request->getMore([
|
|
|
|
|
['keyword', '']
|
|
|
|
|
], true);
|
|
|
|
|
$keyword = trim($keyword);
|
|
|
|
|
$adminType = $this->adminType;
|
|
|
|
|
$cacheKey = $keyword ? md5('admin_common_menu_list_' . $adminType . '_' . $keyword) : md5('admin_common_menu_list_' . $adminType);
|
|
|
|
|
$list = CacheService::redisHandler('system_menus')->remember($cacheKey, function () use ($keyword, $adminType) {
|
|
|
|
|
/** @var SystemMenusServices $menusServices */
|
|
|
|
|
$menusServices = app()->make(SystemMenusServices::class);
|
|
|
|
|
return $menusServices->getSelectList($adminType, $keyword);
|
|
|
|
|
});
|
|
|
|
|
return app('json')->success($list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param CityAreaServices $services
|
|
|
|
|
* @return Response
|
|
|
|
|
* @throws DataNotFoundException
|
|
|
|
|
* @throws DbException
|
|
|
|
|
* @throws ModelNotFoundException
|
|
|
|
|
*/
|
|
|
|
|
public function city(CityAreaServices $services): Response
|
|
|
|
|
{
|
|
|
|
|
$pid = $this->request->get('pid', 0);
|
|
|
|
|
return $this->success($services->getCityTreeList((int)$pid));
|
|
|
|
|
}
|
|
|
|
|
}
|