yeawood_consts 1.0.26 → 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 +45 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -144,6 +144,51 @@ 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
|
+
*/
|
|
158
|
+
exports.TENDER_CEE_PACKAGE_LEADER_PRICE_CALCULATOR = (
|
|
159
|
+
price,
|
|
160
|
+
places_,
|
|
161
|
+
delayCount,
|
|
162
|
+
decreaseType,
|
|
163
|
+
decreaseDelay,
|
|
164
|
+
decreaseBasic
|
|
165
|
+
) => {
|
|
166
|
+
let step = new big(0)
|
|
167
|
+
|
|
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)
|
|
173
|
+
|
|
174
|
+
switch (decreaseType) {
|
|
175
|
+
case 'fixed':
|
|
176
|
+
step = formatter(price).times(delayDecreases).add(formatter(decreaseBasic))
|
|
177
|
+
break
|
|
178
|
+
case 'ratio':
|
|
179
|
+
step = formatter(price).times(totalDecreases)
|
|
180
|
+
break
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const places = formatter(places_).round().toNumber()
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
step: step.toFixed(places, 3),
|
|
187
|
+
ratio: step.div(formatter(price, 1)).times(100).toFixed(places),
|
|
188
|
+
price: formatter(price).minus(step.toFixed(places, 3)).toFixed(places, 0)
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
147
192
|
exports.TENDER_COMPANY_FILTER = (company, company_curr) => {
|
|
148
193
|
switch (company) {
|
|
149
194
|
case company_curr:
|