当前位置:网站首页>[strategic mode] like Zhugeliang's brocade bag
[strategic mode] like Zhugeliang's brocade bag
2022-07-25 10:40:00 【InfoQ】
function getPrice(originalPrice, status) {
if (status === 'pre-sale') { // Pre sale 8 fold
return originalPrice * 0.8
}
if (status === 'promotion') { // The sales promotion is 9 Discount or cheap 20
if (origialPrice <= 100) {
return origialPrice * 0.9
} else {
return originalPrice - 20
}
}
if (status === 'black-friday') { // There are many discount strategies on Friday
if (origialPrice >= 100 && originalPrice < 200) {
return origialPrice - 20
} else if (originalPrice >= 200) {
return originalPrice - 50
} else {
return originalPrice * 0.8
}
}
if (status === 'default') { // No discount by default
return originalPrice
}
}
function preSalePrice(origialPrice) { // Pre sale 8 fold
return originalPrice * 0.8
}
function promotionPrice(origialPrice) { // The sales promotion is 9 Discount or cheap 20
if (origialPrice <= 100) {
return origialPrice * 0.9
} else {
return originalPrice - 20
}
}
function blackFridayPrice(origialPrice) { // There are many discount strategies on Friday
if (origialPrice >= 100 && originalPrice < 200) {
return origialPrice - 20
} else if (originalPrice >= 200) {
return originalPrice - 50
} else {
return originalPrice * 0.8
}
}
function defaultPrice(origialPrice) { // No discount by default
return origialPrice
}
let priceStrategies = { // Discount strategy
'pre-sale': preSalePrice,
'promotion': promotionPrice,
'black-friday': blackFridayPrice,
'default': defaultPrice
}
function getPrice(originalPrice, status) { // Get the price according to the strategy
return priceStrategies[status](originalPrice)
}


边栏推荐
猜你喜欢

Angr (III) - angr_ ctf

2021 京东笔试总结

【蓝桥杯集训100题】scratch太极图 蓝桥杯scratch比赛专项预测编程题 集训模拟练习题第22题

Configuration of static routes (take Huawei ENSP as an example)

Erlang (offline deployment)

4.FTP服务配置与原理

MySQL solves the problem of not supporting Chinese

3. Like you, DNS domain name resolution service!!!

Hucang integrated e-commerce project (II): project use technology, version and basic environment preparation

使用px2rem不生效
随机推荐
Mysql离线部署
Qt | 鼠标事件和滚轮事件 QMouseEvent、QWheelEvent
Add CONDA virtual environment env to the Jupiter kernel
6. PXE combines kickstart principle and configuration to realize unattended automatic installation
3. Believe you can understand! Circular statements and functions of shell scripts, arrays, bubble sorting
Angr (VII) -- angr_ ctf
MySQL solves the problem of not supporting Chinese
2、 What does the unittest framework do
4. Children next door will know all kinds of shell symbols {}[], etc
Open虚拟专线网络负载均衡
Configuration of static routes (take Huawei ENSP as an example)
C# 类库的生成,使用类库对象对DataGridView 进行数据绑定
Fastdfs离线部署(图文)
2. Introduce the deployment of lamp platform +discuz Forum
The ultimate summary of jsonobject parsing JSON format
js 哈希表 01
Storage, computing and distributed computing (collection and sorting is suitable for Xiaobai)
配置FTP虚拟用户及访问控制
1. Shell programming specifications and variables
CONDA configures the deep learning environment pytorch transformers