yeawood_consts 1.0.27 → 1.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +23 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -144,9 +144,20 @@ exports.TENDER_CEE_PROJECT_STATE_CALCULATOR = (
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/**
|
|
148
|
+
*
|
|
149
|
+
* @param price - 最新价格
|
|
150
|
+
* @param places_ - 小数位数
|
|
151
|
+
* @param delayCount - 延时次数
|
|
152
|
+
* @param decreaseType - 调价方式:固定金额调价、百分比调价
|
|
153
|
+
* @param decreaseDelay - 延时增幅,一般是百分比
|
|
154
|
+
* @param decreaseBasic - 基础增幅,需要结合decreaseType来确定每次报价是按照什么方式调价多少
|
|
155
|
+
* @returns {{price: *, step: *, ratio: *}|{price: string, step: string, ratio: string}}
|
|
156
|
+
* @constructor
|
|
157
|
+
*/
|
|
147
158
|
exports.TENDER_CEE_PACKAGE_LEADER_PRICE_CALCULATOR = (
|
|
148
159
|
price,
|
|
149
|
-
|
|
160
|
+
places_,
|
|
150
161
|
delayCount,
|
|
151
162
|
decreaseType,
|
|
152
163
|
decreaseDelay,
|
|
@@ -154,22 +165,27 @@ exports.TENDER_CEE_PACKAGE_LEADER_PRICE_CALCULATOR = (
|
|
|
154
165
|
) => {
|
|
155
166
|
let step = new big(0)
|
|
156
167
|
|
|
157
|
-
const
|
|
158
|
-
|
|
168
|
+
const formatter = (number, option = 0) =>
|
|
169
|
+
new big(Math.max(parseFloat(number) || option, 0))
|
|
170
|
+
|
|
171
|
+
const delayDecreases = formatter(decreaseDelay).times(formatter(delayCount)).times(0.01)
|
|
172
|
+
const totalDecreases = formatter(decreaseBasic).times(0.01).add(delayDecreases)
|
|
159
173
|
|
|
160
174
|
switch (decreaseType) {
|
|
161
175
|
case 'fixed':
|
|
162
|
-
step =
|
|
176
|
+
step = formatter(price).times(delayDecreases).add(formatter(decreaseBasic))
|
|
163
177
|
break
|
|
164
178
|
case 'ratio':
|
|
165
|
-
step =
|
|
179
|
+
step = formatter(price).times(totalDecreases)
|
|
166
180
|
break
|
|
167
181
|
}
|
|
168
182
|
|
|
183
|
+
const places = formatter(places_).round().toNumber()
|
|
184
|
+
|
|
169
185
|
return {
|
|
170
186
|
step: step.toFixed(places, 3),
|
|
171
|
-
ratio: step.div(price).times(100).toFixed(places),
|
|
172
|
-
price: price.minus(step.toFixed(places, 3)).toFixed(places, 0)
|
|
187
|
+
ratio: step.div(formatter(price, 1)).times(100).toFixed(places),
|
|
188
|
+
price: formatter(price).minus(step.toFixed(places, 3)).toFixed(places, 0)
|
|
173
189
|
}
|
|
174
190
|
}
|
|
175
191
|
|