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

Commit 3c3f3c99 authored by jiangxiulong's avatar jiangxiulong

ex add

parent 57ccd0ca
......@@ -137,6 +137,7 @@ public class GoblinRedisConst {
public static final String REDIS_GOBLIN_NFT_ORDER_USER_ID_LIST = PREFIX.concat("nft:order:idList:");// nft用户订单id列表 userId
public static final String REDIS_GOBLIN_NFT_ORDER_REFUND_INFO = PREFIX.concat("nft:order:refund:");// nft退款订单详情 orderId
public static final String REDIS_GOBLIN_NFT_ORDER_BUG_LOCK = PREFIX.concat("nft:order:lock:");// nft购买用户锁 userId
public static final String REDIS_GOBLIN_NFT_ORDER_EX_LOCK = PREFIX.concat("nft:order:exLock:");// nft兑换码锁 code
public static final String REDIS_GOBLIN_NFT_GOODS_LIST = PREFIX.concat("nft:goodsList");// nft商品列表
public static final String REDIS_GOBLIN_NFT_NUM_ACCOUNT = PREFIX.concat("nft:account:");// nft用户数字账户是否开通 userId
......
......@@ -26,5 +26,5 @@ public interface IGoblinNftOrderService {
String refundSyncOrder(GoblinNftOrderRefundCallbackParam refundCallbackParam);
Boolean exchange(String code);
ResponseDto<Boolean> exchange(String code, String uid);
}
......@@ -78,29 +78,7 @@ public class GoblinNftOrderController {
public ResponseDto<Boolean> exchange(
@RequestParam("code") @NotBlank(message = "兑换码不能为空") String code
) {
Boolean res = iGoblinNftOrderService.exchange(code);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure();
}
return iGoblinNftOrderService.exchange(code, null);
}
/*@PostMapping("exchange")
@ApiOperation("兑换")
@ApiImplicitParams({
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "code", value = "兑换码", example = "1"),
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "user", value = "兑换码", example = "1"),
})
public ResponseDto<Boolean> exchange(
@RequestParam("code") @NotBlank(message = "兑换码不能为空") String code
) {
Boolean res = iGoblinNftOrderService.exchange(code);
if (res) {
return ResponseDto.success();
} else {
return ResponseDto.failure();
}
}*/
}
package com.liquidnet.service.order.controller.inner;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.service.IGoblinNftOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank;
@Api(tags = "NFT-支付相关")
@RestController
@Validated
@RequestMapping("/goblin/nft")
public class GoblinInnerNftController {
@Autowired
IGoblinNftOrderService iGoblinNftOrderService;
@PostMapping("airdrop")
@ApiOperation("空投")
@ApiImplicitParams({
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "code", value = "兑换码", example = "1"),
@ApiImplicitParam(type = "from", required = true, dataType = "String", name = "userId", value = "用户ID", example = "1"),
})
public ResponseDto<Boolean> exchange(
@RequestParam("code") @NotBlank(message = "兑换码不能为空") String code,
@RequestParam("userId") @NotBlank(message = "用户ID不能为空") String userId
) {
return iGoblinNftOrderService.exchange(code, userId);
}
}
......@@ -749,16 +749,23 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
}
@Override
public Boolean exchange(String code) {
try {
// 加锁
// 验证 1code是否存在 2是否在生效日期内 3是否未兑换的状态 4兑换限购
// 使用
// 下单
return true;
} catch (Exception e) {
log.error("Error", e);
return false;
public ResponseDto<Boolean> exchange(String code, String uid) {
// 验证 1code是否存在 2是否在生效日期内 3是否未兑换的状态 4兑换限购
// 使用
// 下单
boolean isLock = nftOrderUtils.setNftOrderExLock(code);
if (!isLock) {
return ResponseDto.failure("处理未完成,请稍等~");
} else {
try {
return ResponseDto.success();
} catch (Exception e) {
log.error("NFT兑换异常 e:{}", e);
return ResponseDto.failure("兑换失败,请稍后重试!");
} finally {
// 执行完毕。释放锁
nftOrderUtils.delNftOrderExLock(uid);
}
}
}
......@@ -806,7 +813,7 @@ public class GoblinNftOrderServiceImpl implements IGoblinNftOrderService {
GoblinGoodsSkuInfoVo goodsSkuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(skuId);
if ("0".equals(goodsSkuInfoVo.getUnbox())) {// 非盲盒,NFT发行购买
ObjectNode bizNftBuyNode = JsonUtils.OM().createObjectNode().put("nftOrderPayId", orderId).put("routerType", goodsSkuInfoVo.getRouteType())
.put("skuId", skuId).put("userId", uid).put("buyTimestamp", DateUtil.Formatter.yyyyMMddHHmmss.format(now));;
.put("skuId", skuId).put("userId", uid).put("buyTimestamp", DateUtil.Formatter.yyyyMMddHHmmss.format(now));
queueUtils.sendMsgByRedis(MQConst.GalaxyQueue.JSON_NFT_PUBLISH_AND_BUY.getKey(), bizNftBuyNode.toString());
}
......
......@@ -133,12 +133,24 @@ public class GoblinNftOrderUtils {
return redisUtil.lock(redisKey, 1, 60);
}
public boolean setNftOrderExLock(String code) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_EX_LOCK
.concat(code);
return redisUtil.lock(redisKey, 1, 60);
}
public void delNftOrderBuyLock(String userId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_BUG_LOCK
.concat(userId);
redisUtil.uLock(redisKey);
}
public void delNftOrderExLock(String code) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_NFT_ORDER_EX_LOCK
.concat(code);
redisUtil.uLock(redisKey);
}
/**
* 使用平台优惠券 只支持代金券
*
......
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