新增卡片工艺
This commit is contained in:
@@ -3613,6 +3613,34 @@ public class PriceUtils {
|
||||
return price == 0 ? last_price : price;
|
||||
}
|
||||
|
||||
public double calcByTargetN(int startN, double highPrice, int endN, double lowPrice, int targetN) {
|
||||
// 高价商品个数线性插值
|
||||
double a = startN * (double) (endN - targetN) / (endN - startN);
|
||||
double b = targetN - a;
|
||||
double total = a * highPrice + b * lowPrice;
|
||||
return total;
|
||||
}
|
||||
|
||||
public double TableCountCenterPrice(int area, double[] price_list, int[] areas) {
|
||||
double price = 0;
|
||||
int startIndex = 0;
|
||||
int endIndex = 0;
|
||||
for (int i = 0; i < areas.length; i++) {
|
||||
if (area > areas[i]) {
|
||||
startIndex = endIndex;
|
||||
endIndex = Math.min(i + 1, areas.length - 1);
|
||||
}
|
||||
}
|
||||
if (startIndex == endIndex && startIndex == 0) {
|
||||
price = price_list[endIndex];
|
||||
} else if (startIndex == endIndex) {
|
||||
price = (price_list[endIndex] / areas[endIndex]) * area;
|
||||
} else {
|
||||
price = ((areas[endIndex] - (double) area) / (areas[endIndex] - areas[startIndex])) * price_list[startIndex] + (((double) area - areas[startIndex]) / (areas[endIndex] - areas[startIndex])) * price_list[endIndex];
|
||||
}
|
||||
return price;
|
||||
}
|
||||
|
||||
public double TablePrice(double area, int[] price_list, double[] areas) {
|
||||
double price = 0;
|
||||
int startIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user