记得上下班打卡 | git大法好,push需谨慎

Commit db10662a authored by 胡佳晨's avatar 胡佳晨

增加 分批购 支持盲盒配置

parent 0a936419
......@@ -40,7 +40,7 @@ public class GoblinNftBoxUtils {
*
* @return
*/
public Map<String, Integer> getSkuHitRatio(Integer exStock, Map<String, BigDecimal> map) {
private Map<String, Integer> getSkuHitRatio(Integer exStock, Map<String, BigDecimal> map) {
// 获取sku总概率
BigDecimal hitRatioCount = new BigDecimal(0);
......@@ -49,10 +49,10 @@ public class GoblinNftBoxUtils {
// Map<String, Map<String, Object>> mapMap = new HashMap<>();
// sku --> 概率/库存
int countStockNumber = 0;
Integer countStockNumber = 0;
HashMap<String, Map<String, Object>> mapMap = CollectionUtil.mapHashMap();
for (String key : map.keySet()) {
BigDecimal skuHitRatio = BigDecimal.valueOf(Double.parseDouble(map.get(key).toString()));
BigDecimal skuHitRatio = BigDecimal.valueOf(Double.valueOf(map.get(key).toString()));
HashMap<String, Object> objectMap = CollectionUtil.mapStringObject();
if (skuHitRatio == null) {
continue;
......@@ -92,7 +92,7 @@ public class GoblinNftBoxUtils {
for (String key : mapMap.keySet()) {
Object stock = mapMap.get(key).get("stock");
Object hitRatio = mapMap.get(key).get("hitRatio");
if (Integer.parseInt(stock.toString()) <= 0) {
if (Integer.valueOf(stock.toString()) <= 0) {
continue;
}
......@@ -102,19 +102,19 @@ public class GoblinNftBoxUtils {
// 要减去的库存
int subStock = BigDecimal.valueOf(exStock).multiply((new BigDecimal(hitRatio.toString()).divide(hitRatioCount, 2, BigDecimal.ROUND_HALF_UP))).setScale(0, BigDecimal.ROUND_UP).intValue();
if (subStock > Integer.parseInt(stock.toString())) {
subNumber += Integer.parseInt(stock.toString());
countStockNumber -= Integer.parseInt(stock.toString());
if (subStock > Integer.valueOf(stock.toString())) {
subNumber += Integer.valueOf(stock.toString());
countStockNumber -= Integer.valueOf(stock.toString());
mapMap.get(key).put("stock", 0);
if (stockMap.get(key) == null) {
stockMap.put(key, Integer.valueOf(stock.toString()));
} else {
stockMap.put(key, stockMap.get(key) + Integer.parseInt(stock.toString()));
stockMap.put(key, stockMap.get(key) + Integer.valueOf(stock.toString()));
}
} else {
countStockNumber -= subStock;
mapMap.get(key).put("stock", Integer.parseInt(stock.toString()) - subStock);
mapMap.get(key).put("stock", Integer.valueOf(stock.toString()) - subStock);
subNumber += subStock;
if (stockMap.get(key) == null) {
stockMap.put(key, subStock);
......@@ -130,11 +130,12 @@ public class GoblinNftBoxUtils {
for (int k = 0; k < usNumber; k++) {
String subKey = "";
double maxValue = Double.MAX_VALUE;
for (String key : bigDecimalHashMap.keySet()) {
if (skuIdList.contains(key)) {
if (skuIdList.contains(key) || stockMap.get(key) == 0) {
continue;
}
double compare = Double.parseDouble(bigDecimalHashMap.get(key).toString());
Double compare = Double.valueOf(bigDecimalHashMap.get(key).toString());
if (maxValue > compare) {
maxValue = compare;
subKey = key;
......@@ -153,7 +154,7 @@ public class GoblinNftBoxUtils {
for (String key : mapMap.keySet()) {
Object hitRatio = mapMap.get(key).get("hitRatio");
Object stock = mapMap.get(key).get("stock");
if (Integer.parseInt(stock.toString()) <= 0 && !eliminateSkuIdList.contains(key)) {
if (Integer.valueOf(stock.toString()) <= 0 && !eliminateSkuIdList.contains(key)) {
eliminateSkuIdList.add(key);
hitRatioCount = hitRatioCount.subtract(new BigDecimal(hitRatio.toString()));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment