当前位置:网站首页>[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)
}


边栏推荐
- 3. Like you, DNS domain name resolution service!!!
- 2021 致景笔试总结
- 2、 What does the unittest framework do
- Implementation of recommendation system collaborative filtering in spark
- Pytorch calculates the loss for each sample in the batch
- 2. Introduce the deployment of lamp platform +discuz Forum
- String longest common prefix
- 【策略模式】就像诸葛亮的锦囊
- Yiwen society, three necessary packet capturing tools for hackers
- User preferences
猜你喜欢

Deadlock event of thread pool

思路再次完美验证!加息临近,趋势明了,好好把握这波行情!

Angr (V) - angr_ ctf

Erlang (offline deployment)

Mysql5.7 master-slave database deployment (offline deployment)

Open virtual private line network load balancing

Pytorch code template (CNN)

Add CONDA virtual environment env to the Jupiter kernel

11.iptables 防火墙

Number theory -- negative Radix conversion
随机推荐
js 双向链表 02
Voxceleb1 dataset Download
UE4 external open EXE file
部署主从数据库
MySQL offline deployment
4. FTP service configuration and principle
Erlang (offline deployment)
Storage, computing and distributed computing (collection and sorting is suitable for Xiaobai)
2021 written examination summary of niuke.com 01
Mysql5.7主从数据库部署(离线部署)
Pytoch separates tensor by the value of one dimension of tensor (simple)
Bug elements
10.expect免交互
Differences between redis and mongodb
Angr (VI) -- angr_ ctf
Detailed explanation of chrome developer tools
3.信你能理解的!shell脚本之循环语句与函数,数组,冒泡排序
使用Numpy进行高程统计及可视化
User preferences
Ansible部署指南