瀏覽代碼

Merge remote-tracking branch 'origin/master'

彬彬 4 年之前
父節點
當前提交
e5070f2ab1

+ 4 - 6
src/main/java/org/springblade/gateway/goods_gateway/controller/AppHelpGoodsController.java

@@ -2,7 +2,6 @@ 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;
@@ -93,13 +92,12 @@ public class AppHelpGoodsController {
 	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);
+		// 创建图像验证码
+		LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(250, 100);
+//		lineCaptcha.setGenerator(new ChineseGenerator(4));
 		// 重新生成code
 		lineCaptcha.createCode();
-		//创建验证码,并放到缓存中,有效期60秒
+		// 创建验证码,并放到缓存中,有效期60秒
 		bladeRedis.setEx(HelpGoodsConstant.getVerificationCodeKey(userId, productId, helpGoodsId), lineCaptcha.getCode(), HelpGoodsConstant.HELP_GOODS_VERIFICATION_CODE_EXIST_TIME);
 		return R.data(lineCaptcha.getImageBase64Data());
 	}

+ 47 - 0
src/main/java/org/springblade/gateway/goods_gateway/generator/ChineseGenerator.java

@@ -0,0 +1,47 @@
+package org.springblade.gateway.goods_gateway.generator;
+
+import cn.hutool.captcha.generator.AbstractGenerator;
+import org.apache.commons.lang3.StringUtils;
+
+/**
+ * @Author: Silent
+ * @Description 中文生成器
+ * @Date: Created in 14:13 2022/1/5
+ * @Modified By:
+ */
+public class ChineseGenerator extends AbstractGenerator {
+	/**
+	 * 构造方法
+	 *
+	 * @param count
+	 */
+	public ChineseGenerator(int count) {
+		super(count);
+	}
+
+	/**
+	 * 生成中文字符串
+	 *
+	 * @return
+	 */
+	@Override
+	public String generate() {
+		StringBuilder stringBuilder = new StringBuilder();
+		for (int i = 0; i < this.length; i++) {
+			stringBuilder.append((char) (0x4e00 + (int) (Math.random() * (0x9fa5 - 0x4e00 + 1))));
+		}
+		return stringBuilder.toString();
+	}
+
+	/**
+	 * 校验器
+	 *
+	 * @param code
+	 * @param userInputCode
+	 * @return
+	 */
+	@Override
+	public boolean verify(String code, String userInputCode) {
+		return StringUtils.equals(code, userInputCode);
+	}
+}

+ 4 - 0
src/main/java/org/springblade/gateway/goods_gateway/service/impl/AppHelpGoodsServiceImpl.java

@@ -228,6 +228,10 @@ public class AppHelpGoodsServiceImpl implements AppHelpGoodsService {
 
 			//设置状态为支付成功
 			oldCmccPointRecord.setPayStatus(CmccPayStatus.SUCCESS);
+			//设置活动
+			oldCmccPointRecord.setActiveId(activeHelpRecord.getActiveId());
+			//设置作品
+			oldCmccPointRecord.setActiveProductId(activeHelpRecord.getActiveId());
 
 			//更新支付状态
 			Assert.isTrue(cmccPointRecordService.updateById(oldCmccPointRecord));

+ 10 - 0
src/main/java/org/springblade/sing/point/entity/CmccPointRecord.java

@@ -45,6 +45,16 @@ public class CmccPointRecord extends BaseEntity {
 	 */
 	@ApiModelProperty(value = "用户id")
 	private Long userId;
+	/**
+	 * 活动id
+	 */
+	@ApiModelProperty(value = "活动作品id")
+	private Long activeId;
+	/**
+	 * 活动作品id
+	 */
+	@ApiModelProperty(value = "活动作品id")
+	private Long activeProductId;
 	/**
 	 * 商户订单号全局唯一
 	 */

+ 4 - 0
src/main/java/org/springblade/sing/point/vo/CmccPointRecordVO.java

@@ -37,4 +37,8 @@ public class CmccPointRecordVO extends CmccPointRecord {
 
 	private String userName;
 
+	private String activeName;
+
+	private String activeProductName;
+
 }

+ 17 - 0
src/main/java/org/springblade/sing/point/wrapper/CmccPointRecordWrapper.java

@@ -20,6 +20,10 @@ import org.springblade.common.utils.SpringContextHolder;
 import org.springblade.core.mp.support.BaseEntityWrapper;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.sing.active.entity.ActiveProductRecord;
+import org.springblade.sing.active.entity.ActiveRecord;
+import org.springblade.sing.active.service.IActiveProductRecordService;
+import org.springblade.sing.active.service.IActiveRecordService;
 import org.springblade.sing.goods.entity.HelpGoods;
 import org.springblade.sing.goods.service.IHelpGoodsService;
 import org.springblade.sing.point.entity.CmccPointRecord;
@@ -39,6 +43,8 @@ public class CmccPointRecordWrapper extends BaseEntityWrapper<CmccPointRecord, C
 
 	private static final IHelpGoodsService helpGoodsService = SpringContextHolder.getBean(IHelpGoodsService.class);
 	private static final ILoginUserService loginUserService = SpringContextHolder.getBean(ILoginUserService.class);
+	private static final IActiveRecordService activeRecordService = SpringContextHolder.getBean(IActiveRecordService.class);
+	private static final IActiveProductRecordService activeProductRecordService = SpringContextHolder.getBean(IActiveProductRecordService.class);
 
 	public static CmccPointRecordWrapper build() {
 		return new CmccPointRecordWrapper();
@@ -57,6 +63,17 @@ public class CmccPointRecordWrapper extends BaseEntityWrapper<CmccPointRecord, C
 		if (ObjectUtil.isNotEmpty(loginUser)){
 			cmccPointRecordVO.setUserName(loginUser.getNickName());
 		}
+
+		ActiveRecord activeRecord = activeRecordService.getById(cmccPointRecordVO.getActiveId());
+		if(ObjectUtil.isNotEmpty(activeRecord)){
+			cmccPointRecordVO.setActiveName(activeRecord.getTitle());
+		}
+
+		ActiveProductRecord activeProductRecord = activeProductRecordService.getById(cmccPointRecordVO.getActiveProductId());
+		if(ObjectUtil.isNotEmpty(activeProductRecord)){
+			cmccPointRecordVO.setActiveName(activeProductRecord.getTitle());
+		}
+
 		//User createUser = UserCache.getUser(cmccPointRecord.getCreateUser());
 		//User updateUser = UserCache.getUser(cmccPointRecord.getUpdateUser());
 		//cmccPointRecordVO.setCreateUserName(createUser.getName());