|
@@ -177,12 +177,6 @@ export class IncomeRecordsService {
|
|
|
agentId?: number
|
|
agentId?: number
|
|
|
): Promise<{
|
|
): Promise<{
|
|
|
dates: string[]
|
|
dates: string[]
|
|
|
- agents: Array<{
|
|
|
|
|
- agentId: number
|
|
|
|
|
- data: number[]
|
|
|
|
|
- tip: number[]
|
|
|
|
|
- commission: number[]
|
|
|
|
|
- }>
|
|
|
|
|
total: number[]
|
|
total: number[]
|
|
|
totalTip: number[]
|
|
totalTip: number[]
|
|
|
totalCommission: number[]
|
|
totalCommission: number[]
|
|
@@ -273,50 +267,45 @@ export class IncomeRecordsService {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- // 构建返回数据
|
|
|
|
|
- const agents: Array<{
|
|
|
|
|
- agentId: number
|
|
|
|
|
- data: number[]
|
|
|
|
|
- tip: number[]
|
|
|
|
|
- commission: number[]
|
|
|
|
|
- }> = []
|
|
|
|
|
-
|
|
|
|
|
- agentIds.forEach(agentId => {
|
|
|
|
|
- const dateMap = agentDataMap.get(agentId)!
|
|
|
|
|
- const agentData = {
|
|
|
|
|
- agentId,
|
|
|
|
|
- data: dates.map(date => {
|
|
|
|
|
- const dayStats = dateMap.get(date)
|
|
|
|
|
- return dayStats ? Number(dayStats.total.toFixed(5)) : 0
|
|
|
|
|
- }),
|
|
|
|
|
- tip: dates.map(date => {
|
|
|
|
|
- const dayStats = dateMap.get(date)
|
|
|
|
|
- return dayStats ? Number(dayStats.tip.toFixed(5)) : 0
|
|
|
|
|
- }),
|
|
|
|
|
- commission: dates.map(date => {
|
|
|
|
|
- const dayStats = dateMap.get(date)
|
|
|
|
|
- return dayStats ? Number(dayStats.commission.toFixed(5)) : 0
|
|
|
|
|
- })
|
|
|
|
|
- }
|
|
|
|
|
- agents.push(agentData)
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
// 计算每天的总计
|
|
// 计算每天的总计
|
|
|
- const total = dates.map((_, index) => {
|
|
|
|
|
- return Number(agents.reduce((sum, agent) => sum + agent.data[index], 0).toFixed(5))
|
|
|
|
|
|
|
+ const total = dates.map(date => {
|
|
|
|
|
+ let dayTotal = 0
|
|
|
|
|
+ agentIds.forEach(agentId => {
|
|
|
|
|
+ const dateMap = agentDataMap.get(agentId)!
|
|
|
|
|
+ const dayStats = dateMap.get(date)
|
|
|
|
|
+ if (dayStats) {
|
|
|
|
|
+ dayTotal += dayStats.total
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ return Number(dayTotal.toFixed(5))
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- const totalTip = dates.map((_, index) => {
|
|
|
|
|
- return Number(agents.reduce((sum, agent) => sum + agent.tip[index], 0).toFixed(5))
|
|
|
|
|
|
|
+ const totalTip = dates.map(date => {
|
|
|
|
|
+ let dayTotal = 0
|
|
|
|
|
+ agentIds.forEach(agentId => {
|
|
|
|
|
+ const dateMap = agentDataMap.get(agentId)!
|
|
|
|
|
+ const dayStats = dateMap.get(date)
|
|
|
|
|
+ if (dayStats) {
|
|
|
|
|
+ dayTotal += dayStats.tip
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ return Number(dayTotal.toFixed(5))
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- const totalCommission = dates.map((_, index) => {
|
|
|
|
|
- return Number(agents.reduce((sum, agent) => sum + agent.commission[index], 0).toFixed(5))
|
|
|
|
|
|
|
+ const totalCommission = dates.map(date => {
|
|
|
|
|
+ let dayTotal = 0
|
|
|
|
|
+ agentIds.forEach(agentId => {
|
|
|
|
|
+ const dateMap = agentDataMap.get(agentId)!
|
|
|
|
|
+ const dayStats = dateMap.get(date)
|
|
|
|
|
+ if (dayStats) {
|
|
|
|
|
+ dayTotal += dayStats.commission
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ return Number(dayTotal.toFixed(5))
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
dates,
|
|
dates,
|
|
|
- agents,
|
|
|
|
|
total,
|
|
total,
|
|
|
totalTip,
|
|
totalTip,
|
|
|
totalCommission
|
|
totalCommission
|