yeawood_consts 1.0.27 → 1.0.29
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 +27 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,6 +15,10 @@ exports.EMAIL_PATTERN = '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'
|
|
|
15
15
|
// 手机号正则
|
|
16
16
|
exports.PHONE_PATTERN = '^1(3\\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\\d|9[0-35-9])\\d{8}$'
|
|
17
17
|
|
|
18
|
+
// 发送HTTP请求时头部中的browser参数
|
|
19
|
+
exports.BROWSER =
|
|
20
|
+
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36'
|
|
21
|
+
|
|
18
22
|
// MongoDB事务参数
|
|
19
23
|
exports.TRANSACTION_OPTIONS = (options = {}) =>
|
|
20
24
|
_.extend(
|
|
@@ -144,9 +148,20 @@ exports.TENDER_CEE_PROJECT_STATE_CALCULATOR = (
|
|
|
144
148
|
}
|
|
145
149
|
}
|
|
146
150
|
|
|
151
|
+
/**
|
|
152
|
+
*
|
|
153
|
+
* @param price - 最新价格
|
|
154
|
+
* @param places_ - 小数位数
|
|
155
|
+
* @param delayCount - 延时次数
|
|
156
|
+
* @param decreaseType - 调价方式:固定金额调价、百分比调价
|
|
157
|
+
* @param decreaseDelay - 延时增幅,一般是百分比
|
|
158
|
+
* @param decreaseBasic - 基础增幅,需要结合decreaseType来确定每次报价是按照什么方式调价多少
|
|
159
|
+
* @returns {{price: *, step: *, ratio: *}|{price: string, step: string, ratio: string}}
|
|
160
|
+
* @constructor
|
|
161
|
+
*/
|
|
147
162
|
exports.TENDER_CEE_PACKAGE_LEADER_PRICE_CALCULATOR = (
|
|
148
163
|
price,
|
|
149
|
-
|
|
164
|
+
places_,
|
|
150
165
|
delayCount,
|
|
151
166
|
decreaseType,
|
|
152
167
|
decreaseDelay,
|
|
@@ -154,22 +169,27 @@ exports.TENDER_CEE_PACKAGE_LEADER_PRICE_CALCULATOR = (
|
|
|
154
169
|
) => {
|
|
155
170
|
let step = new big(0)
|
|
156
171
|
|
|
157
|
-
const
|
|
158
|
-
|
|
172
|
+
const formatter = (number, option = 0) =>
|
|
173
|
+
new big(Math.max(parseFloat(number) || option, 0))
|
|
174
|
+
|
|
175
|
+
const delayDecreases = formatter(decreaseDelay).times(formatter(delayCount)).times(0.01)
|
|
176
|
+
const totalDecreases = formatter(decreaseBasic).times(0.01).add(delayDecreases)
|
|
159
177
|
|
|
160
178
|
switch (decreaseType) {
|
|
161
179
|
case 'fixed':
|
|
162
|
-
step =
|
|
180
|
+
step = formatter(price).times(delayDecreases).add(formatter(decreaseBasic))
|
|
163
181
|
break
|
|
164
182
|
case 'ratio':
|
|
165
|
-
step =
|
|
183
|
+
step = formatter(price).times(totalDecreases)
|
|
166
184
|
break
|
|
167
185
|
}
|
|
168
186
|
|
|
187
|
+
const places = formatter(places_).round().toNumber()
|
|
188
|
+
|
|
169
189
|
return {
|
|
170
190
|
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)
|
|
191
|
+
ratio: step.div(formatter(price, 1)).times(100).toFixed(places),
|
|
192
|
+
price: formatter(price).minus(step.toFixed(places, 3)).toFixed(places, 0)
|
|
173
193
|
}
|
|
174
194
|
}
|
|
175
195
|
|