|
|
@@ -3,6 +3,8 @@ package com.cyksj.service.relation.impl;
|
|
|
import cn.hutool.core.date.BetweenFormater;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
+import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -11,11 +13,14 @@ import com.cyksj.enums.GatewayApiCode;
|
|
|
import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.model.entity.CouponUser;
|
|
|
+import com.cyksj.model.entity.GoodsDon;
|
|
|
import com.cyksj.model.entity.GroupsRelation;
|
|
|
import com.cyksj.model.entity.User;
|
|
|
+import com.cyksj.model.request.SpecialGoodsTicketReq;
|
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.chatgpt.ChatGptAuthService;
|
|
|
+import com.cyksj.service.mail.MailService;
|
|
|
import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
@@ -25,6 +30,7 @@ import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
@@ -54,6 +60,8 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
|
|
|
private final RedisService redisService;
|
|
|
|
|
|
+ private final MailService mailService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<RenewalView> getMyTicket(long userId, Boolean isLoginPopularize) {
|
|
|
User u = userMapper.selectById(userId);
|
|
|
@@ -186,4 +194,37 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
|
|
|
public Page<UserRecommendGoodsFrontView> getRecommendGoodsViews(Boolean isPayNf, List<Long> filter_goods_id, Integer start, Integer limit) {
|
|
|
return groupsRelationMapper.getRecommendGoodsViews(new Page<>(start, limit),filter_goods_id, isPayNf);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
+ public void sendCourseWare(SpecialGoodsTicketReq request) throws Exception {
|
|
|
+ Long userId = request.getUserId();
|
|
|
+ Long relationId = request.getRelationId();
|
|
|
+ String email = request.getEmail();
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ RenewalView relation = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder().field(RenewalView::getRelationId, relationId).build());
|
|
|
+ Assert.notNull(relation, "您的车票不存在");
|
|
|
+ Long relationUserId = relation.getUserId();
|
|
|
+ if (!userIdList.contains(relationUserId)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("您的车票不存在");
|
|
|
+ }
|
|
|
+ if (relation.getSpecialType() != GoodsDon.SpecialType.courseware) {
|
|
|
+ throw BusinessRuntimeException.getInstance("");
|
|
|
+ }
|
|
|
+ //是否已发送
|
|
|
+ if (StrUtil.isNotBlank(relation.getAccount())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("已领取课件,请前往邮箱查看");
|
|
|
+ }
|
|
|
+ if (!Validator.isEmail(email)) {
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入正确的邮箱");
|
|
|
+ }
|
|
|
+ int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getAccount, email)
|
|
|
+ .isNull(GroupsRelation::getAccount)
|
|
|
+ .eq(GroupsRelation::getId, relationId));
|
|
|
+ if (update > 0) {
|
|
|
+ Long goodsId = relation.getGoodsId();
|
|
|
+ mailService.sendCoursewareByGoodsId(goodsId, relation.getTitle(), email);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|