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

Commit 9dc525b9 authored by 胡佳晨's avatar 胡佳晨

站位 减库存

parent 5583f29f
...@@ -90,6 +90,14 @@ public class GoblinGagoController extends BaseController { ...@@ -90,6 +90,14 @@ public class GoblinGagoController extends BaseController {
return AjaxResult.error("该序号已被占用"); return AjaxResult.error("该序号已被占用");
} }
// //
int count = goblinRedisUtils.decrSkuStock(null,skuId,1);
if(count<0){
goblinRedisUtils.incrSkuStock(null,skuId,1);
goblinRedisUtils.removeNftList(skuId, nftNum + "");
return AjaxResult.error("已售罄");
}
//下单
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString(); MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("userId", uid); params.add("userId", uid);
params.add("skuId", skuId); params.add("skuId", skuId);
......
...@@ -158,7 +158,7 @@ public class GoblinRedisUtils { ...@@ -158,7 +158,7 @@ public class GoblinRedisUtils {
} }
//获取 当前xx链上SkuId 发行的数量 //获取 当前xx链上SkuId 发行的数量
public int getNftCountBySku(String routerType,String skuId) { public int getNftCountBySku(String routerType, String skuId) {
String redisKey = GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId); String redisKey = GalaxyConstant.REDIS_KEY_GALAXY_PUBLISH_NFT.concat(routerType).concat(":").concat(skuId);
Object obj = redisDataSourceUtil.getRedisGoblinUtil().get(redisKey); Object obj = redisDataSourceUtil.getRedisGoblinUtil().get(redisKey);
if (obj == null) { if (obj == null) {
...@@ -191,10 +191,19 @@ public class GoblinRedisUtils { ...@@ -191,10 +191,19 @@ public class GoblinRedisUtils {
return true; return true;
} }
//删除 nft序号站位list
public boolean removeNftList(String skuId, String num) {
String redisKey = GoblinRedisConst.GOBLIN_NUM_LIST.concat(skuId);
List<String> voList = getNftList(skuId);
voList.remove(skuId);
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, voList);
return true;
}
public GoblinGoodsSkuInfoVo getGoodsSkuInfoVo(String skuId) { public GoblinGoodsSkuInfoVo getGoodsSkuInfoVo(String skuId) {
String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId); String rk = GoblinRedisConst.BASIC_GOODS_SKU.concat(skuId);
GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisDataSourceUtil.getRedisGoblinUtil().get(rk); GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisDataSourceUtil.getRedisGoblinUtil().get(rk);
if (null == vo ) { if (null == vo) {
return null; return null;
} }
return vo; return vo;
...@@ -205,4 +214,24 @@ public class GoblinRedisUtils { ...@@ -205,4 +214,24 @@ public class GoblinRedisUtils {
String redisKey = GoblinRedisConst.GOBLIN_NUM_DETAILS.concat(num).concat(skuId); String redisKey = GoblinRedisConst.GOBLIN_NUM_DETAILS.concat(num).concat(skuId);
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, dto); redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, dto);
} }
//减少库存
public int decrSkuStock(String marketPre, String skuId, Integer stock) {
String rk = GoblinRedisConst.REAL_STOCK_SKU;
if (marketPre != null && !marketPre.equals("null")) {
rk = rk.concat(marketPre + ":");
}
rk = rk.concat(skuId);
return (int) redisDataSourceUtil.getRedisGoblinUtil().decr(rk, stock);
}
//增加库存
public int incrSkuStock(String marketPre, String skuId, Integer stock) {
String rk = GoblinRedisConst.REAL_STOCK_SKU;
if (marketPre != null && !marketPre.equals("null")) {
rk = rk.concat(marketPre + ":");
}
rk = rk.concat(skuId);
return (int) redisDataSourceUtil.getRedisGoblinUtil().incr(rk, stock);
}
} }
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