|
|
@@ -24,6 +24,7 @@ import com.cyksj.model.views.DoubleVerifyCodeView;
|
|
|
import com.cyksj.model.views.RenewalView;
|
|
|
import com.cyksj.model.views.UserTicketView;
|
|
|
import com.cyksj.redis.RedisService;
|
|
|
+import com.cyksj.service.mange.coupon.CouponCommonService;
|
|
|
import com.cyksj.service.order.OrderDonService;
|
|
|
import com.cyksj.service.relation.GroupRelationFrontService;
|
|
|
import com.cyksj.service.user.UserService;
|
|
|
@@ -33,6 +34,7 @@ import com.ejlchina.searcher.param.Operator;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
@@ -73,6 +75,10 @@ public class GroupRelationController {
|
|
|
|
|
|
private final DoubleVerifyClickRefreshRecordMapper refreshRecordMapper;
|
|
|
|
|
|
+ private final QuestionResponseRecordMapper questionResponseRecordMapper;
|
|
|
+
|
|
|
+ private final CouponCommonService couponCommonService;
|
|
|
+
|
|
|
private final GlobalThreadPoolTaskExecutor THREAD_POOL;
|
|
|
|
|
|
@RequestMapping("/get/renewal")
|
|
|
@@ -303,4 +309,56 @@ public class GroupRelationController {
|
|
|
List<DoubleVerifyCodeView> views = doubleVerifyRecordMapper.getDoubleVerifyCodeList(userId, relationId);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(views);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户是不是自然流量渠道
|
|
|
+ * 且未回答答题
|
|
|
+ */
|
|
|
+ @GetMapping("/natural/channel")
|
|
|
+ public Result<Boolean> isNaturalChannel() {
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ String question_key = RedisService.key.QUESTION_RESPONSE_KEY.getNameFormat(userId);
|
|
|
+ if (redisService.get(question_key) != null) {
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
+ }
|
|
|
+ User user = userService.getById(userId);
|
|
|
+ if (user.getPopularizeId() != 0) {
|
|
|
+ redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
+ }
|
|
|
+ if (user.getPopularizeId() == 0) {
|
|
|
+ QuestionResponseRecord record = questionResponseRecordMapper.selectOne(Wrappers.lambdaQuery(QuestionResponseRecord.class)
|
|
|
+ .eq(QuestionResponseRecord::getUserId, userId).select(QuestionResponseRecord::getId).last("limit 1"));
|
|
|
+ if (record != null) {
|
|
|
+ redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(true);
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 问卷记录
|
|
|
+ */
|
|
|
+ @PostMapping("/record/replyQuestion")
|
|
|
+ public Result<String> recordReplyQuestion(@RequestBody @Validated QuestionResponseRecord record) {
|
|
|
+ long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
+ User user = userService.getById(userId);
|
|
|
+ String nickname = user.getNickname();
|
|
|
+ String question_key = RedisService.key.QUESTION_RESPONSE_KEY.getNameFormat(userId);
|
|
|
+ QuestionResponseRecord dbRecord = questionResponseRecordMapper.selectOne(Wrappers.lambdaQuery(QuestionResponseRecord.class)
|
|
|
+ .eq(QuestionResponseRecord::getUserId, userId).select(QuestionResponseRecord::getId).last("limit 1"));
|
|
|
+ if (dbRecord == null) {
|
|
|
+ if (redisService.setNx(String.format("%s-%s", userId, nickname), userId, 10l)) {
|
|
|
+ record.setUserId(userId);
|
|
|
+ record.setNickname(nickname);
|
|
|
+ questionResponseRecordMapper.insert(record);
|
|
|
+ //发放优惠券
|
|
|
+ couponCommonService.sendCouponToUser(userId, 100l, 0l, 0l, 0l, CouponUser.Channel.ques_response);
|
|
|
+ redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
}
|