Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shouzhouServer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjinjing
shouzhouServer
Commits
b5aaf815
Commit
b5aaf815
authored
Jul 26, 2024
by
Leo Zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 paymentMethodAnalysis 和 ticketAnalysis 接口的参数
parent
a2b78e4f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
11 deletions
+17
-11
getData.ts
src/biz/getData.ts
+1
-1
paymentMethodAnalysisStrategy.ts
...biz/map2/strategies/left/paymentMethodAnalysisStrategy.ts
+2
-2
ticketAnalysisStrategy.ts
src/biz/map2/strategies/left/ticketAnalysisStrategy.ts
+14
-8
No files found.
src/biz/getData.ts
View file @
b5aaf815
...
...
@@ -13,7 +13,7 @@ import { strategyFactory } from "./strategyFactory";
* @param strategyType - The type of strategy to be used.
*/
export
function
getData
(
req
,
res
,
strategyType
:
string
)
{
console
.
log
(
`Request received from IP:
${
req
.
ip
}
, Request:
${
JSON
.
stringify
(
req
.
query
)}
`
);
console
.
log
(
`Request received from IP:
${
req
.
ip
}
, Request:
${
strategyType
}
, Params:
${
JSON
.
stringify
(
req
.
query
)}
`
);
const
strategy
=
strategyFactory
.
createStrategy
(
strategyType
);
let
ret
=
strategy
.
execute
(
req
);
res
.
setHeader
(
'Content-Type'
,
'application/json; charset=utf-8'
);
...
...
src/biz/map2/strategies/left/paymentMethodAnalysisStrategy.ts
View file @
b5aaf815
...
...
@@ -8,7 +8,7 @@ export default class paymentMethodAnalysisStrategy extends abstractDataStrategyL
execute
(
params
?:
any
):
any
{
paramChecker
.
checkDiscreteParam
(
params
,
'timeFrame'
,
'12month'
,
'3year'
);
paramChecker
.
checkDiscreteParam
(
params
,
'type'
,
'amount'
,
'ticket
Number
'
);
paramChecker
.
checkDiscreteParam
(
params
,
'type'
,
'amount'
,
'ticket
Count
'
);
paramChecker
.
checkDiscreteParam
(
params
,
'ticketCategory'
,
'sales'
,
'verified'
,
'refund'
);
const
data
=
this
.
extractor
.
getData
(
paymentMethodAnalysisStrategy
.
FILENAME
,
paymentMethodAnalysisStrategy
.
SHEETNAME
);
return
this
.
processData
(
data
,
params
.
query
[
'timeFrame'
],
params
.
query
[
'type'
],
params
.
query
[
'ticketCategory'
]);
...
...
@@ -70,7 +70,7 @@ export default class paymentMethodAnalysisStrategy extends abstractDataStrategyL
return
{
paymentMethod
:
key
,
amount
:
parseFloat
(
amount
.
toFixed
(
2
)),
percentage
:
`
${
percentage
}
%`
,
percentage
:
parseFloat
(
parseFloat
(
percentage
).
toFixed
(
0
))
,
unit
:
type
===
'amount'
?
'元'
:
'张'
};
});
...
...
src/biz/map2/strategies/left/ticketAnalysisStrategy.ts
View file @
b5aaf815
import
{
abstractDataStrategyLeft
}
from
"./abstractDataStrategyLeft"
;
import
paramChecker
from
"../../../../util/paramChecker"
;
import
excelSerialToJSDate
from
"../../../../util/excelDateToJSDate"
;
export
default
class
ticketAnalysisStrategy
extends
abstractDataStrategyLeft
{
static
readonly
FILENAME
=
'票务系统.xlsx'
;
...
...
@@ -9,18 +8,18 @@ export default class ticketAnalysisStrategy extends abstractDataStrategyLeft {
execute
(
params
?:
any
):
any
{
paramChecker
.
checkDiscreteParam
(
params
,
'category'
,
'total'
,
'group'
,
'solo'
);
paramChecker
.
checkDiscreteParam
(
params
,
'timeFrame'
,
'12month'
,
'3year'
);
paramChecker
.
checkDiscreteParam
(
params
,
'type'
,
'amount'
,
'ticket
Number
'
);
paramChecker
.
checkDiscreteParam
(
params
,
'type'
,
'amount'
,
'ticket
Count
'
);
paramChecker
.
checkDiscreteParam
(
params
,
'ticketCategory'
,
'sales'
,
'verified'
,
'refund'
,
'conversion'
);
const
data
=
this
.
extractor
.
getData
(
ticketAnalysisStrategy
.
FILENAME
,
ticketAnalysisStrategy
.
SHEETNAME
);
return
this
.
processData
(
data
,
params
.
query
[
'category'
],
params
.
query
[
'timeFrame'
],
params
.
query
[
'type'
],
params
.
query
[
'ticketCategory'
]);
}
processData
(
data
:
any
,
category
:
string
,
timeFrame
:
string
,
type
:
string
,
ticketCategory
:
string
):
any
{
return
this
.
processTrendData
(
data
,
timeFrame
);
return
this
.
processTrendData
(
data
,
timeFrame
,
category
);
}
private
processTrendData
(
data
:
any
,
timeFrame
:
string
):
any
{
private
processTrendData
(
data
:
any
,
timeFrame
:
string
,
category
:
string
):
any
{
const
currentDate
=
new
Date
();
const
startMonth
=
currentDate
.
getMonth
()
+
1
;
let
startDate
=
new
Date
();
...
...
@@ -34,19 +33,26 @@ export default class ticketAnalysisStrategy extends abstractDataStrategyLeft {
for
(
let
i
=
0
;
i
<
12
;
i
++
)
{
const
date
=
new
Date
(
startDate
);
date
.
setMonth
(
startDate
.
getMonth
()
+
i
-
(
line
-
1
)
*
12
);
const
month
=
(
date
.
getMonth
()
+
1
).
toString
().
padStart
(
2
,
'0'
);
// Format the month to MM
const
month
=
(
date
.
getMonth
()
+
1
).
toString
().
padStart
(
2
,
'0'
);
monthlyTrend
.
push
({
key
:
month
,
value
:
Math
.
floor
(
Math
.
random
()
*
100
)
+
20
});
}
// monthlyTrend.sort((a, b) => parseInt(a.key) - parseInt(b.key));
trendData
.
push
({
line
,
monthlyTrend
:
monthlyTrend
});
}
return
trendData
;
const
totalSolo
=
800
;
const
totalGroup
=
750
;
const
total
=
totalSolo
+
totalGroup
;
const
soloRatio
=
((
totalSolo
/
total
)
*
100
).
toFixed
(
0
);
const
ratioData
=
category
===
'group'
?
{
name
:
'团客占比'
,
value
:
100
-
parseFloat
(
soloRatio
)
}
:
category
===
'solo'
?
{
name
:
'散客占比'
,
value
:
parseFloat
(
soloRatio
)
}
:
null
;
return
ratioData
?
{
trendData
,
ratioData
}
:
{
trendData
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment