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

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

修改 兑换接口

parent 7e82e7e1
...@@ -8,7 +8,9 @@ import com.liquidnet.service.goblin.constant.GoblinRedisConst; ...@@ -8,7 +8,9 @@ import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.constant.NftAccStatusEnum; import com.liquidnet.service.goblin.constant.NftAccStatusEnum;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo; import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinMarketingZhengzaiRelationVo; import com.liquidnet.service.goblin.dto.vo.GoblinMarketingZhengzaiRelationVo;
import com.liquidnet.service.goblin.dto.vo.GoblinNftSkuVo;
import com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo; import com.liquidnet.service.goblin.dto.vo.GoblinSelfMarketingVo;
import com.liquidnet.service.goblin.entity.GoblinGoodsSku;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -165,6 +167,7 @@ public class GoblinRedisUtils { ...@@ -165,6 +167,7 @@ public class GoblinRedisUtils {
} }
} }
//获取 nft序号站位list
public List<String> getNftList(String routerType, String skuId) { public List<String> getNftList(String routerType, String skuId) {
String redisKey = GoblinRedisConst.GOBLIN_NUM_LIST.concat(routerType).concat(":").concat(skuId); String redisKey = GoblinRedisConst.GOBLIN_NUM_LIST.concat(routerType).concat(":").concat(skuId);
Object obj = redisDataSourceUtil.getRedisGoblinUtil().get(redisKey); Object obj = redisDataSourceUtil.getRedisGoblinUtil().get(redisKey);
...@@ -175,6 +178,7 @@ public class GoblinRedisUtils { ...@@ -175,6 +178,7 @@ public class GoblinRedisUtils {
} }
} }
//添加 nft序号站位list
public void addNftList(String routerType, String skuId, String num) { public void addNftList(String routerType, String skuId, String num) {
String redisKey = GoblinRedisConst.GOBLIN_NUM_LIST.concat(routerType).concat(":").concat(skuId); String redisKey = GoblinRedisConst.GOBLIN_NUM_LIST.concat(routerType).concat(":").concat(skuId);
List<String> voList = getNftList(routerType, skuId); List<String> voList = getNftList(routerType, skuId);
...@@ -182,6 +186,7 @@ public class GoblinRedisUtils { ...@@ -182,6 +186,7 @@ public class GoblinRedisUtils {
redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, voList); redisDataSourceUtil.getRedisGoblinUtil().set(redisKey, voList);
} }
//覆盖 站位宾哥要dto
public void setNftNumDetails(String num, String skuId, GalaxyNftPublishAndBuyReqDto dto) { public void setNftNumDetails(String num, String skuId, GalaxyNftPublishAndBuyReqDto dto) {
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);
......
...@@ -38,15 +38,17 @@ public class GoblinInnerNftController { ...@@ -38,15 +38,17 @@ public class GoblinInnerNftController {
return iGoblinNftOrderService.exchange(code, userId, "systemAdmin", 4); return iGoblinNftOrderService.exchange(code, userId, "systemAdmin", 4);
} }
@PostMapping("airdrop") @PostMapping("airdropInner")
@ApiOperation("空投") @ApiOperation("空投")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "skuId", value = "skuId", example = "0"),
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "userId", value = "用户ID", example = "1"), @ApiImplicitParam(type = "from", required = true, dataType = "String", name = "userId", value = "用户ID", example = "1"),
}) })
public ResponseDto<Boolean> exchange( public ResponseDto<Boolean> exchangeInner(
@RequestParam("skuId") @NotBlank(message = "skuId不能为空") String skuId,
@RequestParam("userId") @NotBlank(message = "用户ID不能为空") String userId @RequestParam("userId") @NotBlank(message = "用户ID不能为空") String userId
) { ) {
return iGoblinNftOrderService.exchange("EXCODE", userId, "systemAdmin", 4); return iGoblinNftOrderService.exchange(skuId, userId, "systemAdmin", 5);
} }
} }
...@@ -12,6 +12,7 @@ import com.liquidnet.service.goblin.constant.GoblinStatusConst; ...@@ -12,6 +12,7 @@ import com.liquidnet.service.goblin.constant.GoblinStatusConst;
import com.liquidnet.service.goblin.constant.NftAccStatusEnum; import com.liquidnet.service.goblin.constant.NftAccStatusEnum;
import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo; import com.liquidnet.service.goblin.dto.GoblinUserNftAccInfoVo;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinGoodsSku;
import com.liquidnet.service.goblin.entity.GoblinNftOrder; import com.liquidnet.service.goblin.entity.GoblinNftOrder;
import com.liquidnet.service.goblin.param.GoblinNftOrderPayAgainParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayAgainParam;
import com.liquidnet.service.goblin.param.GoblinNftOrderPayCallbackParam; import com.liquidnet.service.goblin.param.GoblinNftOrderPayCallbackParam;
...@@ -504,7 +505,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -504,7 +505,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
orderVo.setCreatedAt(nftOrder.getCreatedAt()); orderVo.setCreatedAt(nftOrder.getCreatedAt());
// 待支付发送队列 // 待支付发送队列
queueUtils.sendMsgByRedisGoblinStock(orderVo.getOrderId(), nftOrder.getCreatedAt(), "NFT",5); queueUtils.sendMsgByRedisGoblinStock(orderVo.getOrderId(), nftOrder.getCreatedAt(), "NFT", 5);
// redis 订单详情 // redis 订单详情
nftOrderUtils.setNftOrder(orderVo); nftOrderUtils.setNftOrder(orderVo);
...@@ -828,34 +829,48 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService { ...@@ -828,34 +829,48 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
return ResponseDto.failure("处理未完成,请稍等~"); return ResponseDto.failure("处理未完成,请稍等~");
} else { } else {
try { try {
// 验证 1code是否存在 2是否未兑换的状态 3是否在生效日期内 4兑换限购
GoblinNftExCodeVo goblinNftExCodeVo = nftOrderUtils.getGoblinNftExCodeVo(code);
if (null == goblinNftExCodeVo || goblinNftExCodeVo.getState() != 1) {
return ResponseDto.failure("兑换码不正确或已失效");
}
LocalDateTime nowTime = LocalDateTime.now(); LocalDateTime nowTime = LocalDateTime.now();
if (nowTime.isBefore(goblinNftExCodeVo.getExStartTime()) || nowTime.isAfter(goblinNftExCodeVo.getExStopTime())) { GoblinNftExCodeVo goblinNftExCodeVo = GoblinNftExCodeVo.getNew();
return ResponseDto.failure("不在允许兑换时间内");
}
int buyCount = nftOrderUtils.incrExCountByUid(uid, goblinNftExCodeVo.getSkuId(), goblinNftExCodeVo.getActivityId(), 1);
if (null != goblinNftExCodeVo.getExLimit() && goblinNftExCodeVo.getExLimit() > 0) {
if (buyCount > goblinNftExCodeVo.getExLimit()) {
nftOrderUtils.decrExCountByUid(uid, goblinNftExCodeVo.getSkuId(), goblinNftExCodeVo.getActivityId(), 1);
return ResponseDto.failure("您已超出兑换限制数量~");
}
}
// 使用
goblinNftExCodeVo.setState(2);
goblinNftExCodeVo.setRedeemUid(uid);
goblinNftExCodeVo.setRedeemAt(nowTime);
goblinNftExCodeVo.setUpdatedAt(nowTime);
nftOrderUtils.setGoblinNftExCodeVo(goblinNftExCodeVo);
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin_nft_ex_code.update")); sqls.add(SqlMapping.get("goblin_nft_ex_code.update"));
LinkedList<Object[]> sqlDataCode = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlDataCode = CollectionUtil.linkedListObjectArr();
sqlDataCode.add(new Object[]{ if (5 == orderType) {
2, uid, nowTime, nowTime, goblinNftExCodeVo.getCodeId() orderType = 4;
}); GoblinGoodsSkuInfoVo skuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(code);
goblinNftExCodeVo.setState(2);
goblinNftExCodeVo.setRedeemUid(uid);
goblinNftExCodeVo.setRedeemAt(nowTime);
goblinNftExCodeVo.setUpdatedAt(nowTime);
goblinNftExCodeVo.setSkuId(code);
goblinNftExCodeVo.setBoxSkuId("");
goblinNftExCodeVo.setSpuId(skuInfoVo.getSpuId());
goblinNftExCodeVo.setStoreId(skuInfoVo.getStoreId());
} else {
// 验证 1code是否存在 2是否未兑换的状态 3是否在生效日期内 4兑换限购
goblinNftExCodeVo = nftOrderUtils.getGoblinNftExCodeVo(code);
if (null == goblinNftExCodeVo || goblinNftExCodeVo.getState() != 1) {
return ResponseDto.failure("兑换码不正确或已失效");
}
if (nowTime.isBefore(goblinNftExCodeVo.getExStartTime()) || nowTime.isAfter(goblinNftExCodeVo.getExStopTime())) {
return ResponseDto.failure("不在允许兑换时间内");
}
int buyCount = nftOrderUtils.incrExCountByUid(uid, goblinNftExCodeVo.getSkuId(), goblinNftExCodeVo.getActivityId(), 1);
if (null != goblinNftExCodeVo.getExLimit() && goblinNftExCodeVo.getExLimit() > 0) {
if (buyCount > goblinNftExCodeVo.getExLimit()) {
nftOrderUtils.decrExCountByUid(uid, goblinNftExCodeVo.getSkuId(), goblinNftExCodeVo.getActivityId(), 1);
return ResponseDto.failure("您已超出兑换限制数量~");
}
}
// 使用
goblinNftExCodeVo.setState(2);
goblinNftExCodeVo.setRedeemUid(uid);
goblinNftExCodeVo.setRedeemAt(nowTime);
goblinNftExCodeVo.setUpdatedAt(nowTime);
nftOrderUtils.setGoblinNftExCodeVo(goblinNftExCodeVo);
sqlDataCode.add(new Object[]{
2, uid, nowTime, nowTime, goblinNftExCodeVo.getCodeId()
});
}
// 下单 // 下单
GoblinNftOrderPayParam payParam = GoblinNftOrderPayParam.getNew(); GoblinNftOrderPayParam payParam = GoblinNftOrderPayParam.getNew();
payParam.setPayType(""); payParam.setPayType("");
......
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