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

Commit 2aa46f40 authored by 张禹's avatar 张禹

Merge branch 'pre' into 'master'

Pre

See merge request !302
parents a39000b7 7e9644eb
......@@ -75,6 +75,7 @@ public class GoblinGagoController extends BaseController {
public AjaxResult listByStatus(@RequestParam(value = "skuId") String skuId, @RequestParam(value = "nftNum") int nftNum, @RequestParam(value = "uid") String uid) {
//当前 nft序号
GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(skuId);
String routeType = skuInfoVo.getRouteType();
int cNufCount = goblinRedisUtils.getNftCountBySku(skuInfoVo.getRouteType(), skuId);
if (cNufCount >= nftNum) {
return AjaxResult.error("该序号已售卖");
......@@ -90,9 +91,9 @@ public class GoblinGagoController extends BaseController {
return AjaxResult.error("该序号已被占用");
}
//
int count = goblinRedisUtils.decrSkuStock(null,skuId,1);
if(count<0){
goblinRedisUtils.incrSkuStock(null,skuId,1);
int count = goblinRedisUtils.decrSkuStock(null, skuId, 1);
if (count < 0) {
goblinRedisUtils.incrSkuStock(null, skuId, 1);
goblinRedisUtils.removeNftList(skuId, nftNum + "");
return AjaxResult.error("已售罄");
}
......@@ -113,6 +114,7 @@ public class GoblinGagoController extends BaseController {
dto.setNftOrderPayId(innerReturnVo.getData());
dto.setSkuId(skuId);
dto.setUserId(uid);
dto.setRouterType(routeType);
goblinRedisUtils.setNftNumDetails(nftNum + "", skuId, dto);
return AjaxResult.success();
} else {
......
......@@ -8,12 +8,13 @@ import com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBindBo;
import com.liquidnet.service.galaxy.dto.bo.GalaxySeriesNftInfoBo;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyReqDto;
import com.liquidnet.service.galaxy.dto.param.GalaxyNftPublishAndBuyRespDto;
import com.liquidnet.service.galaxy.router.zxin.biz.ZxinTradeCommonBiz;
import com.liquidnet.service.galaxy.service.IGalaxyTradeService;
import com.liquidnet.service.galaxy.utils.GalaxyDataUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
......@@ -32,8 +33,8 @@ public class GalaxyTradeBiz {
@Autowired
private GalaxyDataUtils dataUtils;
@Autowired
private ZxinTradeCommonBiz zxinTradeCommonBiz;
@Resource(name = "galaxyTradeServiceImpl")
private IGalaxyTradeService galaxyTradeService;
/**
* 根据skuid和nftIndex判断是否切换nft购买订单
* @param skuid
......@@ -71,7 +72,7 @@ public class GalaxyTradeBiz {
//执行nft购买订单切换
log.info("开始执行nft购买订单切换===>>>>> reqParam:{}", JsonUtils.toJson(reqDto));
ResponseDto<GalaxyNftPublishAndBuyRespDto> responseDto = zxinTradeCommonBiz.nftPublishAndBuy(reqDto);
ResponseDto<GalaxyNftPublishAndBuyRespDto> responseDto = galaxyTradeService.nftPublishAndBuy(reqDto);
log.info("执行nft购买订单切换结果===>>>>> response:{}",JsonUtils.toJson(responseDto));
}
}
......@@ -13,6 +13,7 @@ import com.liquidnet.commons.lang.util.StringUtil;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.galaxy.biz.GalaxyBeanTransferBiz;
import com.liquidnet.service.galaxy.biz.GalaxyEnumBiz;
import com.liquidnet.service.galaxy.biz.GalaxyTradeBiz;
import com.liquidnet.service.galaxy.constant.GalaxyEnum;
import com.liquidnet.service.galaxy.constant.GalaxyErrorEnum;
import com.liquidnet.service.galaxy.dto.bo.GalaxyNftOrderBindBo;
......@@ -30,6 +31,8 @@ import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
......@@ -55,6 +58,11 @@ public class XuperTradeCommonBiz {
@Autowired
private GalaxyBeanTransferBiz galaxyBeanTransferBiz;
@Autowired
private GalaxyTradeBiz galaxyTradeBiz;
private ExecutorService executorService = Executors.newFixedThreadPool(10);
/**
* 发行和购买
* @param reqDto
......@@ -139,6 +147,17 @@ public class XuperTradeCommonBiz {
//发行失败
throw new GalaxyNftPublishException(GalaxyErrorEnum.NFT_PUBLISH_ERROR.getCode(),"该sku:"+reqDto.getSkuId()+" 总共"+seriesNftInfoBo.getNftTotalCount()+"个NFT已经发行完毕,没有剩余库存!");
}
//判断是否切换订单
while(galaxyTradeBiz.isNeedSwitch(reqDto.getSkuId(),String.valueOf(nftIdNo))){
long finalNftIdNo = nftIdNo;
//开启新线程去执行购买
executorService.submit(() -> {
galaxyTradeBiz.switchBuyRouterBySkuId(reqDto.getSkuId(),String.valueOf(finalNftIdNo),seriesNftInfoBo);
});
nftIdNo = dataUtils.incrNftIdNo(reqDto.getRouterType(),reqDto.getSkuId());
}
nftOrderBindBo = GalaxyNftOrderBindBo.getNew();
nftOrderBindBo.setNftOrderPayId(reqDto.getNftOrderPayId());
nftOrderBindBo.setSeriesId(seriesNftInfoBo.getSeriesId());
......
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