|
|
@@ -1,5 +1,8 @@
|
|
|
package org.springblade.gateway.goods_gateway.controller;
|
|
|
|
|
|
+import cn.hutool.captcha.CaptchaUtil;
|
|
|
+import cn.hutool.captcha.LineCaptcha;
|
|
|
+import cn.hutool.captcha.generator.RandomGenerator;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
import io.swagger.annotations.Api;
|
|
|
@@ -9,7 +12,9 @@ import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springblade.core.log.annotation.ApiLog;
|
|
|
import org.springblade.core.log.logger.BladeLogger;
|
|
|
+import org.springblade.core.redis.cache.BladeRedis;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.gateway.goods_gateway.constant.HelpGoodsConstant;
|
|
|
import org.springblade.gateway.goods_gateway.service.AppHelpGoodsService;
|
|
|
import org.springblade.gateway.goods_gateway.util.HelpGoodsUtil;
|
|
|
import org.springblade.payment.cmcc.request.CmccDectOrderRequest;
|
|
|
@@ -46,6 +51,7 @@ public class AppHelpGoodsController {
|
|
|
private final IHelpGoodsService helpGoodsService;
|
|
|
private final IActiveRecordService activeRecordService;
|
|
|
private final BladeLogger bladeLogger;
|
|
|
+ private final BladeRedis bladeRedis;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -59,6 +65,7 @@ public class AppHelpGoodsController {
|
|
|
@ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
@ApiParam(value = "购买数量", required = true) @RequestParam BigDecimal num,
|
|
|
@ApiParam(value = "作品ID", required = true) @RequestParam Long productId,
|
|
|
+ @ApiParam(value = "验证码") @RequestParam(required = false) String code,
|
|
|
CmccDectOrderRequest cmccDectOrderRequest) {
|
|
|
try {
|
|
|
CmccPointRecord cmccPointRecord = new CmccPointRecord();
|
|
|
@@ -67,7 +74,7 @@ public class AppHelpGoodsController {
|
|
|
cmccPointRecord.setNum(num);
|
|
|
//加锁
|
|
|
synchronized (cmccPointRecord.getUserId().toString().intern()) {
|
|
|
- appHelpGoodsService.exchangeProps(cmccPointRecord, cmccDectOrderRequest, productId, null);
|
|
|
+ appHelpGoodsService.exchangeProps(cmccPointRecord, cmccDectOrderRequest, productId, null, code);
|
|
|
}
|
|
|
return R.success("兑换成功");
|
|
|
} catch (Exception e) {
|
|
|
@@ -76,12 +83,34 @@ public class AppHelpGoodsController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建道具验证码
|
|
|
+ */
|
|
|
+ @ApiLog("创建道具验证码")
|
|
|
+ @GetMapping("/createPropsVerificationCode")
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperation(value = "创建道具验证码")
|
|
|
+ public R<String> createPropsVerificationCode(@ApiParam(value = "道具ID", required = true) @RequestParam Long helpGoodsId,
|
|
|
+ @ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
+ @ApiParam(value = "作品ID", required = true) @RequestParam Long productId) {
|
|
|
+ // 自定义纯数字的验证码(随机4位数字,可重复)
|
|
|
+ RandomGenerator randomGenerator = new RandomGenerator("0123456789", 4);
|
|
|
+ LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
|
|
|
+ lineCaptcha.setGenerator(randomGenerator);
|
|
|
+ // 重新生成code
|
|
|
+ lineCaptcha.createCode();
|
|
|
+ //创建验证码,并放到缓存中,有效期60秒
|
|
|
+ bladeRedis.setEx(HelpGoodsConstant.getVerificationCodeKey(userId, productId, helpGoodsId), lineCaptcha.getCode(), HelpGoodsConstant.HELP_GOODS_VERIFICATION_CODE_EXIST_TIME);
|
|
|
+ return R.data(lineCaptcha.getImageBase64Data());
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 创建现金道具订单
|
|
|
*/
|
|
|
@ApiLog("创建现金道具订单")
|
|
|
@PostMapping("/createCashPropsOrder")
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperationSupport(order = 2)
|
|
|
@ApiOperation(value = "创建现金道具订单")
|
|
|
public R<YeepayOrder> createCashPropsOrder(@ApiParam(value = "道具ID", required = true) @RequestParam Long helpGoodsId,
|
|
|
@ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
@@ -112,7 +141,7 @@ public class AppHelpGoodsController {
|
|
|
*/
|
|
|
@ApiLog("现金支付回调地址")
|
|
|
@RequestMapping(value = "/callbackUrl", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperationSupport(order = 3)
|
|
|
@ApiOperation(value = "现金支付回调地址")
|
|
|
public String callbackUrl(HttpServletRequest request) {
|
|
|
bladeLogger.info("道具订单支付回调", request.getParameterMap().toString());
|
|
|
@@ -128,7 +157,7 @@ public class AppHelpGoodsController {
|
|
|
*/
|
|
|
@ApiLog("创建道具订单")
|
|
|
@PostMapping("/createPropsOrder")
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
@ApiOperation(value = "创建道具订单")
|
|
|
public R<String> createPropsOrder(@ApiParam(value = "道具ID", required = true) @RequestParam Long helpGoodsId,
|
|
|
@ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|
|
|
@@ -162,7 +191,7 @@ public class AppHelpGoodsController {
|
|
|
*/
|
|
|
@ApiLog("发送验证码")
|
|
|
@PostMapping("/sendCmccSms")
|
|
|
- @ApiOperationSupport(order = 1)
|
|
|
+ @ApiOperationSupport(order = 5)
|
|
|
@ApiOperation(value = "发送验证码")
|
|
|
public R<String> sendCmccSms(@ApiParam(value = "手机号码", required = true) @RequestParam String mobile,
|
|
|
@ApiParam(value = "订单号ID", required = true) @RequestParam String outOrderId) {
|
|
|
@@ -196,7 +225,7 @@ public class AppHelpGoodsController {
|
|
|
* 获取道具助力列表
|
|
|
*/
|
|
|
@GetMapping("/getHelpGoodsList")
|
|
|
- @ApiOperationSupport(order = 2)
|
|
|
+ @ApiOperationSupport(order = 6)
|
|
|
@ApiOperation(value = "获取道具助力列表")
|
|
|
public R<List<HelpGoodsVO>> getHelpGoodsList(@ApiParam(value = "活动ID", required = true) @RequestParam Long activeId,
|
|
|
@ApiParam(value = "用户ID", required = true) @RequestParam Long userId,
|