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

Commit fd0b7a49 authored by wanglele's avatar wanglele

批量空投

parent 50de8c27
......@@ -249,7 +249,8 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
// sku ---> 库存
HashMap<String, Integer> stockMap = CollectionUtil.mapStringInteger();
getStock(exStock, hitRatioCount, mapMap, stockMap,countStockNumber);
ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(exStock, hitRatioCount, mapMap, stockMap, countStockNumber, eliminateSkuIdList);
return stockMap;
}
......@@ -261,19 +262,28 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Map<String, Map<String, Object>> mapMap = new HashMap<>();
Map<String, Object> objectMap = new HashMap<>();
objectMap.put("hitRatio", 20);
objectMap.put("stock", 3);
objectMap.put("hitRatio", 30);
objectMap.put("stock", 16);
mapMap.put("1", objectMap);
Map<String, Object> objectMap1 = new HashMap<>();
objectMap1.put("hitRatio", 20);
objectMap1.put("stock", 100);
objectMap1.put("hitRatio", 30);
objectMap1.put("stock", 15);
mapMap.put("2", objectMap1);
Map<String, Object> objectMap2 = new HashMap<>();
objectMap2.put("hitRatio", 20);
objectMap2.put("stock", 2);
objectMap2.put("hitRatio", 30);
objectMap2.put("stock", 1000);
mapMap.put("3", objectMap2);
Map<String, Object> objectMap3 = new HashMap<>();
objectMap3.put("hitRatio", 10);
objectMap3.put("stock", 1);
mapMap.put("4", objectMap3);
Map<String, Integer> stockMap = new HashMap<>();
getStock(20, new BigDecimal(60), mapMap, stockMap,15);
ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(50, new BigDecimal(100), mapMap, stockMap, 1032, eliminateSkuIdList);
for (String key : stockMap.keySet()) {
System.out.println("skuId" + key + "***********数量" + stockMap.get(key));
}
......@@ -288,7 +298,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
* @param mapMap
* @return
*/
private static void getStock(Integer exStock, BigDecimal hitRatioCount, Map<String, Map<String, Object>> mapMap, Map<String, Integer> stockMap,Integer countStockNumber) {
private static void getStock(Integer exStock, BigDecimal hitRatioCount, Map<String, Map<String, Object>> mapMap, Map<String, Integer> stockMap, Integer countStockNumber, ArrayList<String> eliminateSkuIdList) {
if (exStock <= 0 || countStockNumber == 0) {
return;
}
......@@ -360,11 +370,12 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
for (String key : mapMap.keySet()) {
Object hitRatio = mapMap.get(key).get("hitRatio");
Object stock = mapMap.get(key).get("stock");
if (Integer.valueOf(stock.toString()) <= 0) {
if (Integer.valueOf(stock.toString()) <= 0 && !eliminateSkuIdList.contains(key)) {
eliminateSkuIdList.add(key);
hitRatioCount = hitRatioCount.subtract(new BigDecimal(hitRatio.toString()));
}
}
getStock(exStock, hitRatioCount, mapMap, stockMap,countStockNumber);
getStock(exStock, hitRatioCount, mapMap, stockMap, countStockNumber, eliminateSkuIdList);
}
}
......
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