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

Commit f5dccfb6 authored by jiangxiulong's avatar jiangxiulong

帮乐乐提交

parent e48577cc
package com.liquidnet.service.platform.service.impl.goblin;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsSkuInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExCodeVo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftExSkuVo;
import com.liquidnet.service.goblin.entity.*;
import com.liquidnet.service.goblin.mapper.*;
import com.liquidnet.service.goblin.entity.GoblinGoodsSku;
import com.liquidnet.service.goblin.entity.GoblinNftExCodeTask;
import com.liquidnet.service.goblin.entity.GoblinNftExCodeTaskRelation;
import com.liquidnet.service.goblin.mapper.GoblinGoodsSkuMapper;
import com.liquidnet.service.goblin.mapper.GoblinNftExCodeTaskMapper;
import com.liquidnet.service.goblin.mapper.GoblinNftExCodeTaskRelationMapper;
import com.liquidnet.service.goblin.param.GoblinNftExSkuParam;
import com.liquidnet.service.goblin.service.IGoblinNftExSkuService;
import com.liquidnet.service.platform.utils.GoblinRedisUtils;
import com.liquidnet.service.platform.utils.ObjectUtil;
import com.microsoft.schemas.office.visio.x2012.main.ShapeSheetType;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: wll
......@@ -124,7 +121,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
}
//是否购买
if (!goblinGoodsSku.getSkuCanbuy().equals("1")){
if (!goblinGoodsSku.getSkuCanbuy().equals("1")) {
continue;
}
// 不能购买的 没库存的 概率是0的 过滤
......@@ -135,7 +132,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
}
}
if (checkNumberSku <= 0){
if (checkNumberSku <= 0) {
return ResponseDto.failure("盲盒下没有可生成兑换码的sku!");
}
......@@ -149,7 +146,6 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
List<GoblinNftExCodeTask> goblinNftExCodeTasks = ObjectUtil.getGoblinNftExCodeTaskArrayList();
// 构建对象
for (GoblinNftExSkuParam goblinNftExSkuParam : goblinNftExSkuParams) {
......@@ -182,6 +178,10 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
Integer sNumber = 0;
for (String key : skuMap.keySet()) {
Integer stockNum = skuMap.get(key);
log.debug("skuId:" + key + "库存:" + stockNum);
if (stockNum <= 0) {
continue;
}
// 根据sku减库存
int stock = goblinRedisUtils.decrSkuStock(null, key, stockNum);
if (stock < 0) {
......@@ -284,28 +284,44 @@ 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", 1000);
objectMap.put("hitRatio", 30);
objectMap.put("stock", 900);
mapMap.put("1", objectMap);
Map<String, Object> objectMap1 = new HashMap<>();
objectMap1.put("hitRatio", 30);
objectMap1.put("stock", 4);
// mapMap.put("2", objectMap1);
objectMap1.put("hitRatio", 0.3);
objectMap1.put("stock", 9);
mapMap.put("2", objectMap1);
Map<String, Object> objectMap2 = new HashMap<>();
objectMap2.put("hitRatio", 30);
objectMap2.put("stock", 1000);
// mapMap.put("3", objectMap2);
objectMap2.put("hitRatio", 23.3);
objectMap2.put("stock", 697);
mapMap.put("3", objectMap2);
Map<String, Object> objectMap3 = new HashMap<>();
objectMap3.put("hitRatio", 10);
objectMap3.put("stock", 1000);
// mapMap.put("4", objectMap3);
objectMap3.put("hitRatio", 2.2);
objectMap3.put("stock", 66);
mapMap.put("4", objectMap3);
Map<String, Object> objectMap4 = new HashMap<>();
objectMap4.put("hitRatio", 26.7);
objectMap4.put("stock", 797);
mapMap.put("5", objectMap4);
Map<String, Object> objectMap5 = new HashMap<>();
objectMap5.put("hitRatio", 2.2);
objectMap5.put("stock", 66);
mapMap.put("6", objectMap5);
Map<String, Object> objectMap6 = new HashMap<>();
objectMap6.put("hitRatio", 15.3);
objectMap6.put("stock", 458);
mapMap.put("7", objectMap6);
Map<String, Integer> stockMap = new HashMap<>();
ArrayList<String> eliminateSkuIdList = CollectionUtil.arrayListString();
getStock(7, new BigDecimal(20), mapMap, stockMap, 1032, eliminateSkuIdList);
getStock(594, new BigDecimal(100), mapMap, stockMap, 2993, eliminateSkuIdList);
for (String key : stockMap.keySet()) {
System.out.println("skuId" + key + "***********数量" + stockMap.get(key));
}
......@@ -369,8 +385,9 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
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.valueOf(bigDecimalHashMap.get(key).toString());
......@@ -411,7 +428,7 @@ public class GoblinNftExSkuServiceImpl implements IGoblinNftExSkuService {
&& info.getShelvesStatus().equals("3")
// && (info.getSkuAppear() == null || info.getSkuAppear().equals("0"))
&& info.getDelFlg().equals("0")
) {
) {
return true;
} else {
return false;
......
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