|
@@ -4,6 +4,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.zxing.BarcodeFormat;
|
|
|
+import com.google.zxing.client.j2se.MatrixToImageWriter;
|
|
|
+import com.google.zxing.common.BitMatrix;
|
|
|
+import com.google.zxing.qrcode.QRCodeWriter;
|
|
|
import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
@@ -31,6 +35,8 @@ import com.zhongzheng.modules.mock.domain.MockMajor;
|
|
|
import com.zhongzheng.modules.mock.domain.MockMajorSubject;
|
|
|
import com.zhongzheng.modules.mock.service.IMockMajorService;
|
|
|
import com.zhongzheng.modules.mock.service.IMockMajorSubjectService;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
+import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.user.domain.User;
|
|
|
import com.zhongzheng.modules.user.service.IUserMockSubscribeService;
|
|
|
import com.zhongzheng.modules.user.service.IUserService;
|
|
@@ -38,11 +44,14 @@ import com.zhongzheng.modules.wx.service.IWxLoginService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Base64;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -75,6 +84,10 @@ public class ExamActivityServiceImpl extends ServiceImpl<ExamActivityMapper, Exa
|
|
|
private IUserService userService;
|
|
|
@Autowired
|
|
|
private IUserMockSubscribeService userMockSubscribeService;
|
|
|
+ @Autowired
|
|
|
+ private ISysTenantService sysTenantService;
|
|
|
+ @Value("${liveGotoURL}")
|
|
|
+ private String liveGotoURL;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -204,7 +217,31 @@ public class ExamActivityServiceImpl extends ServiceImpl<ExamActivityMapper, Exa
|
|
|
|
|
|
@Override
|
|
|
public String getActivityApplyCode(Long activityId) {
|
|
|
- return wxLoginService.getActivityApplyCode(activityId);
|
|
|
+ ExamActivity activity = getById(activityId);
|
|
|
+ if (ObjectUtils.isNull(activity)){
|
|
|
+ throw new CustomException("活动不存在");
|
|
|
+ }
|
|
|
+ //H5域名
|
|
|
+ SysTenant tenant = sysTenantService.getById(activity.getTenantId());
|
|
|
+ String hostH5 = tenant.getHostH5();
|
|
|
+ String urlBase64 = "";
|
|
|
+ try {
|
|
|
+ QRCodeWriter qrCodeWriter = new QRCodeWriter();
|
|
|
+ BitMatrix bitMatrix = qrCodeWriter.encode(String.format("%s%s/pages5/mockExam/examApply?tid=%s",liveGotoURL,hostH5,activityId),
|
|
|
+ BarcodeFormat.QR_CODE, 300, 300);
|
|
|
+ // 写到输出流
|
|
|
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
|
+ MatrixToImageWriter.writeToStream(bitMatrix, "jpg", outputStream);
|
|
|
+ //转换为base64
|
|
|
+ Base64.Encoder encoder1 = Base64.getEncoder();
|
|
|
+ urlBase64 = "data:image/jpeg;base64,"
|
|
|
+ + encoder1.encodeToString(outputStream.toByteArray());
|
|
|
+ }catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new CustomException("二维码生成失败");
|
|
|
+ }
|
|
|
+// wxLoginService.getActivityApplyCode(activityId);
|
|
|
+ return urlBase64;
|
|
|
}
|
|
|
|
|
|
@Override
|