new files

This commit is contained in:
panchengyong
2026-03-07 22:29:07 +08:00
parent cd7e80b502
commit 7acbf45ff7
12516 changed files with 1808447 additions and 194 deletions

View File

@@ -0,0 +1,75 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\statistic;
use app\controller\admin\AuthController;
use app\services\user\UserMoneyServices;
use think\annotation\Inject;
class BalanceStatistic extends AuthController
{
#[Inject]
protected UserMoneyServices $services;
/**
* 余额统计基础信息
* @return mixed
*/
public function getBasic()
{
$where = $this->request->getMore([
['time', '']
]);
$data = $this->services->getBasic($where);
return app('json')->success($data);
}
/**
* 余额统计趋势图
* @return mixed
*/
public function getTrend()
{
$where = $this->request->getMore([
['time', '']
]);
$data = $this->services->getTrend($where);
return app('json')->success($data);
}
/**
* 余额来源
* @return mixed
*/
public function getChannel()
{
$where = $this->request->getMore([
['time', '']
]);
$data = $this->services->getChannel($where);
return app('json')->success($data);
}
/**
* 余额类型
* @return mixed
*/
public function getType()
{
$where = $this->request->getMore([
['time', '']
]);
$data = $this->services->getType($where);
return app('json')->success($data);
}
}

View File

@@ -0,0 +1,90 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\controller\admin\v1\statistic;
use app\controller\admin\AuthController;
use app\services\statistic\OrderStatisticServices;
use think\annotation\Inject;
class OrderStatistic extends AuthController
{
/**
* @var OrderStatisticServices
*/
#[Inject]
protected OrderStatisticServices $services;
/**
* 订单统计基础信息
* @return mixed
*/
public function getBasic()
{
$where = $this->request->getMore([
['time', '']
]);
if($this->supplierId > 0){
$where['supplier_id'] = $this->supplierId;
}
$data = $this->services->getBasic($where);
return app('json')->success($data);
}
/**
* 订单统计趋势图
* @return mixed
*/
public function getTrend()
{
$where = $this->request->getMore([
['time', '']
]);
if($this->supplierId > 0){
$where['supplier_id'] = $this->supplierId;
}
$data = $this->services->getTrend($where);
return app('json')->success($data);
}
/**
* 订单来源
* @return mixed
*/
public function getChannel()
{
$where = $this->request->getMore([
['time', '']
]);
if($this->supplierId > 0){
$where['supplier_id'] = $this->supplierId;
}
$data = $this->services->getChannel($where);
return app('json')->success($data);
}
/**
* 订单类型
* @return mixed
*/
public function getType()
{
$where = $this->request->getMore([
['time', '']
]);
if($this->supplierId > 0){
$where['supplier_id'] = $this->supplierId;
}
$data = $this->services->getType($where);
return app('json')->success($data);
}
}

View File

@@ -0,0 +1,115 @@
<?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\controller\admin\v1\statistic;
use app\controller\admin\AuthController;
use app\services\product\category\StoreProductCategoryServices;
use app\services\statistic\ProductStatisticServices;
use think\annotation\Inject;
/**
* Class ProductStatistic
* @package app\controller\admin\v1\statistic
*/
class ProductStatistic extends AuthController
{
/**
* @var ProductStatisticServices
*/
#[Inject]
protected ProductStatisticServices $services;
/**
* 商品基础
* @return mixed
*/
public function getBasic()
{
$where = $this->request->getMore([
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getBasic($where));
}
/**
* 商品趋势
* @return mixed
*/
public function getTrend()
{
$where = $this->request->getMore([
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getTrend($where));
}
/**
* 商品排行
* @return mixed
*/
public function getProductRanking(StoreProductCategoryServices $storeCategoryServices)
{
$where = $this->request->getMore([
['cate_id', ''],
['data', '', '', 'time'],
['sort', '']
]);
$cateId = $where['cate_id'];
if ($cateId) {
$cateId = is_string($cateId) ? [$cateId] : $cateId;
$cateId = array_merge($cateId, $storeCategoryServices->getColumn(['pid' => $cateId], 'id'));
$cateId = array_unique(array_diff($cateId, [0]));
}
$where['cate_id'] = $cateId;
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getProductRanking($where));
}
/**
* 导出
* @return mixed
*/
public function getExcel()
{
$where = $this->request->getMore([
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getTrend($where, true));
}
/**
* 格式化时间
* @param $time
* @return string
*/
public function getDay($time)
{
if (strstr($time, '-') !== false) {
[$startTime, $endTime] = explode('-', $time);
if (!$startTime && !$endTime) {
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d 23:59:59", time());
} else {
if (strtotime($endTime) == strtotime(date('Y-m-d', strtotime($endTime)))) {
$endTime = $endTime . ' 23:59:59';
}
return $startTime . '-' . $endTime;
}
} else {
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d 23:59:59", time());
}
}
}

View File

@@ -0,0 +1,70 @@
<?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\controller\admin\v1\statistic;
use app\controller\admin\AuthController;
use app\services\statistic\TradeStatisticServices;
use think\annotation\Inject;
/**
* Class TradeStatistic
* @package app\controller\admin\v1\statistic
*/
class TradeStatistic extends AuthController
{
/**
* @var TradeStatisticServices
*/
#[Inject]
protected TradeStatisticServices $services;
/**
* 顶部数据
* @return mixed
*/
public function topTrade()
{
$leftToday = $this->services->getTopLeftTrade(['time' => 'today']);
$leftyestoday = $this->services->getTopLeftTrade(['time' => 'yestoday']);
$rightOne = $this->services->getTopRightOneTrade();
$rightTwo = $this->services->getTopRightTwoTrade();
$right = ['today' => $rightOne, 'month' => $rightTwo];
$totalleft = [$leftToday, $leftyestoday];
$left = [];
foreach ($totalleft as $k => $v) {
$left['name'] = "当日订单金额";
$left['x'] = $v['curve']['x'];
$left['series'][$k]['money'] = round($v['total_money'], 2);
$left['series'][$k]['value'] = array_values($v['curve']['y']);
}
$data['left'] = $left;
$data['right'] = $right;
return $this->success($data);
}
/**
* 底部数据
* @return mixed
*/
public function bottomTrade()
{
$day = $this->request->getMore([
['data', ""],
]);
$bottom = $this->services->getBottomTrade($day);
return $this->success($bottom);
}
}

View File

@@ -0,0 +1,152 @@
<?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\controller\admin\v1\statistic;
use app\controller\admin\AuthController;
use app\services\statistic\UserStatisticServices;
use think\annotation\Inject;
/**
* Class UserStatistic
* @package app\controller\admin\v1\statistic
*/
class UserStatistic extends AuthController
{
/**
* @var UserStatisticServices
*/
#[Inject]
protected UserStatisticServices $services;
/**
* 用户基础信息
* @return mixed
*/
public function getBasic()
{
$where = $this->request->getMore([
['channel_type', ''],
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getBasic($where));
}
/**
* 用户趋势
* @return mixed
*/
public function getTrend()
{
$where = $this->request->getMore([
['channel_type', ''],
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getTrend($where));
}
/**
* 微信用户信息
* @return mixed
*/
public function getWechat()
{
$where = $this->request->getMore([
['channel_type', ''],
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getWechat($where));
}
/**
* 微信用户趋势
* @return mixed
*/
public function getWechatTrend()
{
$where = $this->request->getMore([
['channel_type', ''],
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getWechatTrend($where));
}
/**
* 用户地域
* @return mixed
*/
public function getRegion()
{
$where = $this->request->getMore([
['channel_type', ''],
['data', '', '', 'time'],
['sort', 'allNum']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getRegionV1($where));
}
/**
* 用户性别
* @return mixed
*/
public function getSex()
{
$where = $this->request->getMore([
['channel_type', ''],
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getSex($where));
}
/**
* 用户统计导出
* @return mixed
*/
public function getExcel()
{
$where = $this->request->getMore([
['channel_type', ''],
['data', '', '', 'time']
]);
$where['time'] = $this->getDay($where['time']);
return $this->success($this->services->getTrend($where, true));
}
/**
* 格式化时间
* @param $time
* @return string
*/
public function getDay($time)
{
if (strstr($time, '-') !== false) {
[$startTime, $endTime] = explode('-', $time);
if (!$startTime && !$endTime) {
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d 23:59:59", time());
} else {
if (strtotime($endTime) == strtotime(date('Y-m-d', strtotime($endTime)))) {
$endTime = $endTime . ' 23:59:59';
}
return $startTime . '-' . $endTime;
}
} else {
return date("Y/m/d", strtotime("-30 days", time())) . '-' . date("Y/m/d 23:59:59", time());
}
}
}