341 lines
7.0 KiB
JavaScript
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.

'use strict';
const MainService = require('../main');
class dashboardService extends MainService {
constructor(ctx) {
super(ctx);
const _noNeedLogin = '';
const _noNeedRight = '*';
const _noNeedLog = '*';
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog);
}
async storeStats() {
const data = {
code: 200,
message: '成功',
data: {
todayOrders: 13023,
orderTrend: 2,
// 处理状态
unassignedOrders: 15, // 未分配快递号
unprintedOrders: 32, // 未打印
unpickedOrders: 28, // 未拣货
// 发货相关
pendingShipments: 6542, // 待发货
shipmentProgress: 0, // 发货进度
// 出库相关
todayOutbound: 6480, // 今日出库
outboundRate: 49.77, // 出库完成率
// 异常订单
interceptedOrders: 8, // 拦截订单
exceptionOrders: 10, // 异常订单
},
};
return this.success('ok', data);
}
async warehouseStats() {
const data = {
code: 200,
message: '成功',
data: {
todayOrders: 153023, // 今日订单数(基准)
orderTrend: 3, // 较昨日增长3%
// 处理状态(按百分比计算)
unassignedOrders: 3060, // 未分配快递号(占2%)
unprintedOrders: 4591, // 未打印(占3%)
unpickedOrders: 7651, // 未拣货(占5%)
// 发货相关
pendingShipments: 45907, // 待发货(占30%)
shipmentProgress: 70, // 发货进度70%
// 出库相关
todayOutbound: 107116, // 今日出库(占70%)
outboundRate: 70, // 出库完成率70%
// 异常订单(按比例)
interceptedOrders: 306, // 拦截订单(占0.2%)
exceptionOrders: 1530, // 异常订单(占1%)
},
};
return this.success('ok', data);
}
async hot_order_rank() {
const data = {
code: 200,
message: '成功',
data: [{
id: 1,
name: '新***盒1',
sku: 'SKU202510081',
value: 51516,
trend: 18.5,
},
{
id: 2,
name: '天***g',
sku: 'SKU202401002',
value: 43132,
trend: 12.3,
},
{
id: 3,
name: '定****l',
sku: 'SKU202401003',
value: 39098,
trend: -2.5,
},
{
id: 4,
name: '奥*****膜',
sku: 'SKU202401004',
value: 39087,
trend: 8.7,
},
{
id: 5,
name: '美*****液',
sku: 'SKU202401005',
value: 25776,
trend: 15.2,
},
{
id: 6,
name: '荣耀Magic6 Pro 1TB',
sku: 'SKU202401006',
value: 65,
trend: 5.4,
},
{
id: 7,
name: '三星Galaxy S24 Ultra 512GB',
sku: 'SKU202401007',
value: 54,
trend: -3.8,
},
{
id: 8,
name: '一加12 512GB',
sku: 'SKU202401008',
value: 43,
trend: 22.1,
},
{
id: 9,
name: '真我GT5 Pro 1TB',
sku: 'SKU202401009',
value: 38,
trend: 9.6,
},
{
id: 10,
name: '魅族21 Pro 512GB',
sku: 'SKU202401010',
value: 29,
trend: 4.2,
},
],
};
return this.success('ok', data);
}
async express_ratio() {
const data = {
code: 200,
message: '成功',
data: [{
name: '顺丰速运',
value: 50250,
itemStyle: {
color: '#409EFF',
},
},
{
name: '中通快递',
value: 34089,
itemStyle: {
color: '#67C23A',
},
},
{
name: '圆通速递',
value: 10567,
itemStyle: {
color: '#E6A23C',
},
},
{
name: '韵达快递',
value: 9023,
itemStyle: {
color: '#909399',
},
},
{
name: '申通快递',
value: 8089,
itemStyle: {
color: '#67023A',
},
},
{
name: '邮政EMS',
value: 4089,
itemStyle: {
color: '#97293A',
},
},
{
name: '京东物流',
value: 3023,
itemStyle: {
color: '#F56C6C',
},
},
{
name: '极兔速递',
value: 1089,
itemStyle: {
color: '#67913A',
},
},
{
name: '德邦快递',
value: 357,
itemStyle: {
color: '#9370DB',
},
},
{
name: '其他快递',
value: 5,
itemStyle: {
color: '#67313A',
},
},
],
};
return this.success('ok', data);
}
async platform_distribution() {
const data = {
code: 200,
message: '成功',
data: [{
name: '抖音',
value: 50250,
itemStyle: {
color: '#409EFF',
},
},
{
name: '拼多多',
value: 34089,
itemStyle: {
color: '#67C23A',
},
},
{
name: '小红书',
value: 8089,
itemStyle: {
color: '#67023A',
},
},
{
name: '淘宝',
value: 10567,
itemStyle: {
color: '#E6A23C',
},
},
{
name: '快手',
value: 9023,
itemStyle: {
color: '#909399',
},
},
{
name: '天猫',
value: 4089,
itemStyle: {
color: '#97293A',
},
},
{
name: '视频号',
value: 3023,
itemStyle: {
color: '#606399',
},
},
{
name: '阿里巴巴',
value: 1089,
itemStyle: {
color: '#67913A',
},
},
{
name: '其他',
value: 357,
itemStyle: {
color: '#9370DB',
},
},
{
name: 'TITOK',
value: 55,
itemStyle: {
color: '#17313A',
},
},
{
name: '京东',
value: 45,
itemStyle: {
color: '#F56C6C',
},
},
{
name: '德物',
value: 5,
itemStyle: {
color: '#67313A',
},
},
],
};
return this.success('ok', data);
}
async order_trend() {
const data = {
code: 200,
message: '成功',
data: {
range: 'day',
date: '2024-01-15',
summary: {
total_orders: 1256,
total_shipments: 892,
shipment_rate: 71.0,
peak_hour: '15:00',
peak_orders: 178,
},
categories: [ '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00' ],
orders: [ 138, 84378, 102120, 129156, 153020, 153020, 153020, 153020, 153020, 153020 ],
shipments: [ 0, 30000, 60000, 70000, 86479, 86479, 86479, 86479, 86479, 86479 ],
},
};
return this.success('ok', data);
}
}
module.exports = dashboardService;