GroupRelationController.java 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. package com.cyksj.web.controller.group;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.core.date.DateTime;
  4. import cn.hutool.core.date.DateUnit;
  5. import cn.hutool.core.date.DateUtil;
  6. import cn.hutool.core.lang.Assert;
  7. import cn.hutool.core.thread.ThreadUtil;
  8. import cn.hutool.core.util.StrUtil;
  9. import cn.hutool.extra.servlet.ServletUtil;
  10. import cn.hutool.json.JSONObject;
  11. import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  12. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  13. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  14. import com.cyksj.common.annotation.NoSubmit;
  15. import com.cyksj.common.constant.Constant;
  16. import com.cyksj.common.exception.BusinessRuntimeException;
  17. import com.cyksj.common.snowflake.Sequence;
  18. import com.cyksj.common.task.GlobalThreadPoolTaskExecutor;
  19. import com.cyksj.common.util.GoogleGenerator;
  20. import com.cyksj.common.util.Jsons;
  21. import com.cyksj.common.util.StringUtil;
  22. import com.cyksj.dto.Result;
  23. import com.cyksj.enums.GatewayResponse;
  24. import com.cyksj.mapper.*;
  25. import com.cyksj.mapper.manage.form.FormFieldsDataMapper;
  26. import com.cyksj.mapper.manage.form.QuestionnairePromotionMapper;
  27. import com.cyksj.model.dto.DoubleVerifyDto;
  28. import com.cyksj.model.dto.QuestionnaireView;
  29. import com.cyksj.model.entity.*;
  30. import com.cyksj.model.manage.views.AccountView;
  31. import com.cyksj.model.manage.views.GroupsRelationView;
  32. import com.cyksj.model.request.*;
  33. import com.cyksj.model.response.GptStandbyResp;
  34. import com.cyksj.model.response.NetflixErrorAccountStatus;
  35. import com.cyksj.model.response.NetflixRecoverResp;
  36. import com.cyksj.model.response.NetflixRefundInfoResp;
  37. import com.cyksj.model.views.*;
  38. import com.cyksj.redis.RedisService;
  39. import com.cyksj.service.chatgpt.ChatGptAuthService;
  40. import com.cyksj.service.mange.CmsOrderDonService;
  41. import com.cyksj.service.mange.coupon.CouponCommonService;
  42. import com.cyksj.service.mange.ticket.TicketAdvertiseConfigClickRecordService;
  43. import com.cyksj.service.order.OrderDonService;
  44. import com.cyksj.service.relation.GroupRelationFrontService;
  45. import com.cyksj.service.relation.GroupsRelationNetflixService;
  46. import com.cyksj.service.user.UserBindRelationService;
  47. import com.cyksj.service.user.UserService;
  48. import com.cyksj.web.util.StpUserUtil;
  49. import com.ejlchina.searcher.BeanSearcher;
  50. import com.ejlchina.searcher.SearchResult;
  51. import com.ejlchina.searcher.operator.LessEqual;
  52. import com.ejlchina.searcher.param.Operator;
  53. import com.ejlchina.searcher.util.MapBuilder;
  54. import com.ejlchina.searcher.util.MapUtils;
  55. import lombok.RequiredArgsConstructor;
  56. import lombok.extern.slf4j.Slf4j;
  57. import org.springframework.transaction.annotation.Transactional;
  58. import org.springframework.validation.annotation.Validated;
  59. import org.springframework.web.bind.annotation.*;
  60. import javax.servlet.http.HttpServletRequest;
  61. import javax.validation.constraints.NotEmpty;
  62. import javax.validation.constraints.NotNull;
  63. import java.math.BigDecimal;
  64. import java.math.RoundingMode;
  65. import java.util.*;
  66. import java.util.concurrent.TimeUnit;
  67. import java.util.concurrent.atomic.AtomicInteger;
  68. import java.util.concurrent.atomic.AtomicLong;
  69. import java.util.stream.Collectors;
  70. /**
  71. * @author chan
  72. * @date 2022/9/27 11:48 AM
  73. */
  74. @Slf4j
  75. @RequiredArgsConstructor
  76. @RestController
  77. @RequestMapping("/applets/group/relation")
  78. public class GroupRelationController {
  79. private final BeanSearcher beanSearcher;
  80. private final OrderDonService orderDonService;
  81. private final GroupsRelationMapper relationMapper;
  82. private final GroupRelationFrontService groupRelationFrontService;
  83. private final UserService userService;
  84. private final UserBindRelationService userBindRelationService;
  85. private final TicketPwdViewRecordMapper ticketPwdViewRecordMapper;
  86. private final HttpServletRequest request;
  87. private final AccountDoubleVerifyRecordMapper accountDoubleVerifyRecordMapper;
  88. private final DoubleVerifyClickRecordMapper doubleVerifyRecordMapper;
  89. private final RedisService redisService;
  90. private final DoubleVerifyClickRefreshRecordMapper refreshRecordMapper;
  91. private final QuestionResponseRecordMapper questionResponseRecordMapper;
  92. private final CouponCommonService couponCommonService;
  93. private final FormFieldsDataMapper formFieldsDataMapper;
  94. private final QuestionnairePromotionMapper questionnairePromotionMapper;
  95. private final TicketAdvertiseConfigClickRecordService ticketAdvertiseConfigClickRecordService;
  96. private final GlobalThreadPoolTaskExecutor THREAD_POOL;
  97. private final ChatGptAuthService chatGptAuthService;
  98. private final GoodsCoursewareFileMapper goodsCoursewareFileMapper;
  99. private final GptTicketStandbyMapper gptTicketStandbyMapper;
  100. private final CmsOrderDonService cmsOrderDonService;
  101. private final GoodsDonSkuMapper goodsDonSkuMapper;
  102. private final AccountBlockedReplaceRecordMapper accountBlockedReplaceRecordMapper;
  103. private final OrderDonMapper orderDonMapper;
  104. private final UserGoodsNewbieGuideRecordMapper userGoodsNewbieGuideRecordMapper;
  105. private final GroupsRelationNetflixService groupsRelationNetflixService;
  106. private final ChatgptUserMapper chatgptUserMapper;
  107. private final UpgradeOrderDonMapper upgradeOrderDonMapper;
  108. private final UserBenefitsOrderRecordMapper userBenefitsOrderRecordMapper;
  109. private final ClaudeUserMapper claudeUserMapper;
  110. private final static Sequence SEQUENCE = new Sequence(0);
  111. @RequestMapping("/get/renewal")
  112. public Result<SearchResult<RenewalView>> get(Boolean isLoginPopularize, String customId, String account, String orderNo, Integer cmt) {
  113. long userId = StpUserUtil.getLoginIdAsLong();
  114. SearchResult<RenewalView> list = groupRelationFrontService.getMyTicket(userId, isLoginPopularize, customId, account, orderNo, cmt);
  115. return GatewayResponse.SUCCESS.newBuilder().toResult(list);
  116. }
  117. @GetMapping("/get/pay/goods")
  118. public Result<List<RenewalView>> getHasPayGoods() {
  119. long userId = StpUserUtil.getLoginIdAsLong();
  120. List<RenewalView> hasPayGoods = groupRelationFrontService.getHasPayGoods(userId);
  121. return GatewayResponse.SUCCESS.newBuilder().toResult(hasPayGoods);
  122. }
  123. @PostMapping("/post/renewal")
  124. public Result<OrderDon> renewal(@RequestBody OrderPayRequest payRequest) throws Exception {
  125. long userId = StpUserUtil.getLoginIdAsLong();
  126. payRequest.setUserId(userId);
  127. String ip = ServletUtil.getClientIP(request);
  128. payRequest.setIp(ip);
  129. OrderDon orderDon = orderDonService.renewal(payRequest);
  130. return GatewayResponse.SUCCESS.newBuilder().toResult(orderDon);
  131. }
  132. @PutMapping("/update/set/account")
  133. public Result<String> setAccount(@RequestBody GroupsRelation relation) {
  134. long userId = StpUserUtil.getLoginIdAsLong();
  135. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  136. GroupsRelation re = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
  137. .eq(GroupsRelation::getId, relation.getId())
  138. .in(GroupsRelation::getUserId, userIds)
  139. .last(" limit 1"));
  140. if (re == null) {
  141. throw new BusinessRuntimeException("该车票不存在,请联系客服.");
  142. }
  143. LambdaUpdateWrapper<GroupsRelation> updateWrapper = Wrappers.lambdaUpdate(GroupsRelation.class)
  144. .set(GroupsRelation::getAccount, relation.getAccount())
  145. .set(GroupsRelation::getPassword, relation.getPassword())
  146. .set(GroupsRelation::getContact, relation.getContact())
  147. .eq(GroupsRelation::getId, relation.getId());
  148. if (re.getRechargeStatus() != null) {
  149. if (re.getRechargeStatus() == GroupsRelation.RechargeStatus.complete) {
  150. throw BusinessRuntimeException.getInstance("代充账号已充值");
  151. }
  152. if (StrUtil.isEmpty(relation.getAccount()) || StrUtil.isEmpty(relation.getPassword())) {
  153. throw BusinessRuntimeException.getInstance("请输入正确的账号密码信息");
  154. }
  155. if (re.getRechargeStatus() == GroupsRelation.RechargeStatus.error) {
  156. updateWrapper.set(GroupsRelation::getRechargeStatus, GroupsRelation.RechargeStatus.waiting);
  157. }
  158. }
  159. relationMapper.update(relation, updateWrapper);
  160. return GatewayResponse.SUCCESS.newBuilder().toResult();
  161. }
  162. /**
  163. * 查询是否加入了企业微信 并是否买了奈飞
  164. */
  165. @GetMapping("/check/joinCorpWx")
  166. public Result<Boolean> isJoinCorpWx() {
  167. long userId = StpUserUtil.getLoginIdAsLong();
  168. Boolean flag = groupRelationFrontService.isJoinCorpWx(userId, false, false);
  169. return GatewayResponse.SUCCESS.newBuilder().toResult(flag);
  170. }
  171. /**
  172. * 获取全部车票
  173. */
  174. @GetMapping("/get")
  175. public Result<List<UserTicketView>> getUserTicketView(Long goodsId, Long skuId) {
  176. long userId = StpUserUtil.getLoginIdAsLong();
  177. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  178. List<UserTicketView> tickets = relationMapper.selectUserTickets(userIds, goodsId, skuId);
  179. return GatewayResponse.SUCCESS.newBuilder().toResult(tickets);
  180. }
  181. /**
  182. * 记录查看ChatGPT车票密码
  183. */
  184. @GetMapping("/recordView/{relationId}")
  185. public Result<String> recordGPTPwdView(@PathVariable Long relationId) {
  186. long userId = StpUserUtil.getLoginIdAsLong();
  187. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  188. GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
  189. .field(GroupsRelationView::getUserId, userIds).op(Operator.InList)
  190. .field(GroupsRelationView::getId, relationId).build());
  191. if (groupsRelationView == null) {
  192. log.info("userId:{}查看relationId:{}车票不存在", userId, relationId);
  193. throw BusinessRuntimeException.getInstance("该车票已不存在");
  194. }
  195. if (groupsRelationView.getAccountId() == null) throw BusinessRuntimeException.getInstance("该车队未配置账号");
  196. if (groupRelationFrontService == null) throw BusinessRuntimeException.getInstance("车票已不存在");
  197. TicketPwdViewRecord viewRecord = new TicketPwdViewRecord();
  198. viewRecord.setUserId(userId);
  199. viewRecord.setRelationId(relationId);
  200. viewRecord.setSkuId(groupsRelationView.getSkuId());
  201. viewRecord.setOperateLocation(ServletUtil.getClientIP(request));
  202. viewRecord.setAccount(groupsRelationView.getTripsAccount());
  203. viewRecord.setPassword(groupsRelationView.getTripsPassword());
  204. ticketPwdViewRecordMapper.insert(viewRecord);
  205. if (groupsRelationView.getGoodsId() == 18 && StrUtil.isEmpty(groupsRelationView.getApiSecret())) {
  206. THREAD_POOL.execute(() -> {
  207. //车队所有人查看密码
  208. Integer num = groupsRelationView.getGtNum();
  209. Integer viewNum = relationMapper.selectViewPwdCount(groupsRelationView.getGroupsId());
  210. if (num <= viewNum) {
  211. AccountDoubleVerifyRecord exist = accountDoubleVerifyRecordMapper.selectOne(Wrappers.lambdaQuery(AccountDoubleVerifyRecord.class)
  212. .eq(AccountDoubleVerifyRecord::getAccountId, groupsRelationView.getAccountId())
  213. .eq(AccountDoubleVerifyRecord::getDeleted, true).last("limit 1"));
  214. if (exist == null) {
  215. if (redisService.setNx(String.format("%s-%s", groupsRelationView.getAccountId(), groupsRelationView.getId()), groupsRelationView.getId(), 60l)) {
  216. //记录
  217. AccountDoubleVerifyRecord accountDoubleVerifyRecord = new AccountDoubleVerifyRecord();
  218. accountDoubleVerifyRecord.setAccountId(groupsRelationView.getAccountId());
  219. accountDoubleVerifyRecord.setAccount(groupsRelationView.getTripsAccount());
  220. accountDoubleVerifyRecord.setGroupsId(groupsRelationView.getGroupsId());
  221. accountDoubleVerifyRecord.setSkuId(groupsRelationView.getSkuId());
  222. accountDoubleVerifyRecord.setRemark("车队所有人看过密码");
  223. accountDoubleVerifyRecordMapper.insert(accountDoubleVerifyRecord);
  224. }
  225. }
  226. }
  227. });
  228. }
  229. return GatewayResponse.SUCCESS.newBuilder().toResult(groupsRelationView.getTripsPassword());
  230. }
  231. /**
  232. * 获取AI类 ChatGPT产品谷歌验证码
  233. */
  234. @GetMapping("/get/authCode")
  235. public Result<String> getAuthCode(Long relationId) {
  236. long userId = StpUserUtil.getLoginIdAsLong();
  237. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  238. if (relationId == null) throw BusinessRuntimeException.getInstance("车票不存在");
  239. GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
  240. .field(GroupsRelationView::getId, relationId)
  241. .field(GroupsRelationView::getUserId, userIds).op(Operator.InList).build());
  242. if (groupsRelationView == null) throw BusinessRuntimeException.getInstance("车票不存在");
  243. if (StrUtil.isEmpty(groupsRelationView.getApiSecret())) throw BusinessRuntimeException.getInstance("未开启验证");
  244. DateTime now = DateTime.now();
  245. Integer count = doubleVerifyRecordMapper.selectCount(Wrappers.lambdaQuery(DoubleVerifyClickRecord.class)
  246. .in(DoubleVerifyClickRecord::getUserId, userIds)
  247. .eq(DoubleVerifyClickRecord::getRelationId, relationId)
  248. .eq(DoubleVerifyClickRecord::getAccountId, groupsRelationView.getAccountId())
  249. .between(DoubleVerifyClickRecord::getCreatedTime, DateUtil.beginOfMonth(now), DateUtil.endOfMonth(now)));
  250. //获取双重验证码
  251. Boolean isHasVerifyCode = StrUtil.isNotBlank(groupsRelationView.getVerifyCode()) ? true : false;
  252. //出去亚马逊 获取限制
  253. if (groupsRelationView.getGoodsId() != 6) {
  254. Integer num = groupRelationFrontService.getUserCodeNumBySkuId(userId, groupsRelationView.getSkuId(), isHasVerifyCode);
  255. if (count >= num) throw BusinessRuntimeException.getInstance("获取双重验证码次数上限");
  256. }
  257. //一分钟内 只能一人获取
  258. boolean b = redisService.setNx(RedisService.key.DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY.getName() + groupsRelationView.getTripsAccount(), relationId, RedisService.key.DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY.getTimeout());
  259. if (!b) {
  260. throw BusinessRuntimeException.getInstance("一分钟内已有人获取该账号验证码,请稍后获取..");
  261. }
  262. int second = now.second();
  263. if (second < 30 && 30 - second < 3) {
  264. ThreadUtil.sleep(30 - second + 1, TimeUnit.SECONDS);
  265. } else if (second > 30 && 60 - second < 3) {
  266. ThreadUtil.sleep(60 - second + 1, TimeUnit.SECONDS);
  267. }
  268. StringBuilder sb = new StringBuilder();
  269. JSONObject re = new JSONObject();
  270. try {
  271. long code = GoogleGenerator.getCode(groupsRelationView.getApiSecret(), now.getTime());
  272. sb.append(code);
  273. while (sb.length() < 6) {
  274. sb.insert(0, 0);
  275. }
  276. re.putOpt("code", sb.toString());
  277. int nowSecond = DateTime.now().second();
  278. int time = 0;
  279. if (nowSecond < 30) {
  280. time = 30 - nowSecond;
  281. } else {
  282. time = 60 - nowSecond;
  283. }
  284. re.putOpt("time", time);
  285. DoubleVerifyClickRecord doubleVerifyClickRecord = new DoubleVerifyClickRecord();
  286. doubleVerifyClickRecord.setRelationId(relationId);
  287. doubleVerifyClickRecord.setUserId(userId);
  288. doubleVerifyClickRecord.setAccountId(groupsRelationView.getAccountId());
  289. doubleVerifyClickRecord.setAccount(groupsRelationView.getTripsAccount());
  290. doubleVerifyClickRecord.setSkuId(groupsRelationView.getSkuId());
  291. doubleVerifyClickRecord.setCode(sb.toString());
  292. doubleVerifyClickRecord.setRemainTime(time);
  293. doubleVerifyRecordMapper.insert(doubleVerifyClickRecord);
  294. DoubleVerifyDto doubleVerifyDto = new DoubleVerifyDto();
  295. doubleVerifyDto.setClickId(doubleVerifyClickRecord.getId());
  296. doubleVerifyDto.setApiSecret(groupsRelationView.getApiSecret());
  297. redisService.set(String.format("%s-%s", userId, sb.toString()), 0, 60 * 10l);
  298. redisService.set(String.format("%s/%s", userId, sb.toString()), Jsons.toJson(doubleVerifyDto), 60 * 10l);
  299. } catch (Exception e) {
  300. throw BusinessRuntimeException.getInstance("获取双重验证码错误,请联系客服");
  301. }
  302. return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
  303. }
  304. /**
  305. * 刷新验证码
  306. */
  307. @GetMapping("/refresh/code")
  308. public Result<String> refreshCode(String code) {
  309. long userId = StpUserUtil.getLoginIdAsLong();
  310. String numKey = String.format("%s-%s", userId, code);
  311. Object num = redisService.get(numKey);
  312. String objKey = String.format("%s/%s", userId, code);
  313. Object objValue = redisService.get(objKey);
  314. if (objValue == null || num == null) {
  315. throw BusinessRuntimeException.getInstance("请重新获取双重验证码");
  316. }
  317. Integer refreshNum = Integer.parseInt(num.toString());
  318. String apiSecret = null;
  319. Long clickId = 0l;
  320. try {
  321. DoubleVerifyDto dto = Jsons.parseObject(objValue.toString(), DoubleVerifyDto.class);
  322. apiSecret = dto.getApiSecret();
  323. clickId = dto.getClickId();
  324. } catch (Exception e) {
  325. apiSecret = objValue.toString();
  326. }
  327. if (refreshNum >= 3) {
  328. redisService.del(numKey);
  329. redisService.del(objKey);
  330. throw BusinessRuntimeException.getInstance("刷新次数已达到3次,请重新获取验证码");
  331. }
  332. if (apiSecret == null) {
  333. throw BusinessRuntimeException.getInstance("请重新获取双重验证码");
  334. }
  335. StringBuilder sb = new StringBuilder();
  336. try {
  337. long c = GoogleGenerator.getCode(apiSecret, DateTime.now().getTime());
  338. sb.append(c);
  339. while (sb.length() < 6) {
  340. sb.insert(0, 0);
  341. }
  342. redisService.incr(numKey, 1l);
  343. } catch (Exception e) {
  344. throw BusinessRuntimeException.getInstance("刷新双重验证码错误,请联系客服");
  345. }
  346. if (clickId != 0) {
  347. int nowSecond = DateTime.now().second();
  348. int time = 0;
  349. if (nowSecond < 30) {
  350. time = 30 - nowSecond;
  351. } else {
  352. time = 60 - nowSecond;
  353. }
  354. //刷新双重验证码记录
  355. DoubleVerifyClickRefreshRecord refreshRecord = new DoubleVerifyClickRefreshRecord();
  356. refreshRecord.setClickId(clickId);
  357. refreshRecord.setUserId(userId);
  358. refreshRecord.setCode(sb.toString());
  359. refreshRecord.setRemainTime(time);
  360. refreshRecordMapper.insert(refreshRecord);
  361. }
  362. return GatewayResponse.SUCCESS.newBuilder().toResult(sb.toString());
  363. }
  364. /**
  365. * 获取双重验证码记录
  366. */
  367. @GetMapping("/get/doubleVerify/codeList")
  368. public Result<List<DoubleVerifyCodeView>> getDoubleVerifyCodeList(Long relationId) {
  369. long userId = StpUserUtil.getLoginIdAsLong();
  370. List<DoubleVerifyCodeView> views = doubleVerifyRecordMapper.getDoubleVerifyCodeList(userId, relationId);
  371. return GatewayResponse.SUCCESS.newBuilder().toResult(views);
  372. }
  373. /**
  374. * 用户是不是自然流量渠道
  375. * 且未回答答题
  376. */
  377. @GetMapping("/natural/channel")
  378. public Result<Boolean> isNaturalChannel() {
  379. long userId = StpUserUtil.getLoginIdAsLong();
  380. String question_key = RedisService.key.QUESTION_RESPONSE_KEY.getNameFormat(userId);
  381. if (redisService.get(question_key) != null) {
  382. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  383. }
  384. User user = userService.getById(userId);
  385. if (user.getPopularizeId() != 0) {
  386. redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
  387. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  388. }
  389. if (user.getPopularizeId() == 0) {
  390. QuestionResponseRecord record = questionResponseRecordMapper.selectOne(Wrappers.lambdaQuery(QuestionResponseRecord.class)
  391. .eq(QuestionResponseRecord::getUserId, userId).select(QuestionResponseRecord::getId).last("limit 1"));
  392. if (record != null) {
  393. redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
  394. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  395. }
  396. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  397. }
  398. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  399. }
  400. /**
  401. * 问卷记录
  402. */
  403. @PostMapping("/record/replyQuestion")
  404. public Result<String> recordReplyQuestion(@RequestBody @Validated QuestionResponseRecord record) {
  405. long userId = StpUserUtil.getLoginIdAsLong();
  406. User user = userService.getById(userId);
  407. String nickname = user.getNickname();
  408. String question_key = RedisService.key.QUESTION_RESPONSE_KEY.getNameFormat(userId);
  409. QuestionResponseRecord dbRecord = questionResponseRecordMapper.selectOne(Wrappers.lambdaQuery(QuestionResponseRecord.class)
  410. .eq(QuestionResponseRecord::getUserId, userId).select(QuestionResponseRecord::getId).last("limit 1"));
  411. if (dbRecord == null) {
  412. if (redisService.setNx(String.format("%s-%s", userId, nickname), userId, 10l)) {
  413. record.setUserId(userId);
  414. record.setNickname(nickname);
  415. questionResponseRecordMapper.insert(record);
  416. //发放优惠券
  417. couponCommonService.sendCouponToUser(userId, 100l, 0l, 0l, 0l, CouponUser.Channel.ques_response);
  418. redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
  419. }
  420. }
  421. return GatewayResponse.SUCCESS.newBuilder().toResult();
  422. }
  423. /**
  424. * 获取对应的动态问卷
  425. */
  426. @GetMapping("/get/questionnaire")
  427. public Result<List<QuestionnaireView>> getQuestionnaireView(Long promotionId) {
  428. QuestionnairePromotion promotion = questionnairePromotionMapper.selectById(promotionId);
  429. if (promotion == null || !promotion.getDeleted()) throw BusinessRuntimeException.getInstance("问卷不存在");
  430. Long templateId = promotion.getTemplateId();
  431. List<QuestionnaireView> questionnaireViews = beanSearcher.searchAll(QuestionnaireView.class, MapUtils.builder()
  432. .field(QuestionnaireView::getPromotionId, promotionId)
  433. .orderBy(QuestionnaireView::getSorted).asc()
  434. .orderBy(QuestionnaireView::getFieldsId).asc()
  435. .build());
  436. return GatewayResponse.SUCCESS.newBuilder().toResult(questionnaireViews);
  437. }
  438. /**
  439. * 记录问卷
  440. */
  441. @PostMapping("/record/questionnaire/{promotionId}")
  442. @Transactional(rollbackFor = Exception.class)
  443. @NoSubmit
  444. public Result<String> recordQuestionnaire(@PathVariable Long promotionId, String showId, @RequestBody List<FormFieldsData> answers) {
  445. Long userId = StpUserUtil.getUserIdAfterLogin();
  446. Long groupsId = SEQUENCE.nextId();
  447. List<QuestionnairePromotionFieldsListView> promotionFieldsListViews = beanSearcher.searchAll(QuestionnairePromotionFieldsListView.class, MapUtils.builder().field(QuestionnairePromotionFieldsListView::getPromotionId, promotionId).build());
  448. if (CollUtil.isEmpty(promotionFieldsListViews)) throw BusinessRuntimeException.getInstance("问卷已结束");
  449. if (promotionFieldsListViews.size() != answers.size()) throw BusinessRuntimeException.getInstance("请完成所有问题");
  450. log.info("开始记录问卷:{}", promotionId);
  451. answers.forEach(answer -> {
  452. // if (StringUtil.isNotBlank(showId)) {
  453. // answer.setUserId(userService.getUserIdByShowId(showId));
  454. // }
  455. answer.setUserId(userId);
  456. Long fieldsId = answer.getFieldsId();
  457. String content = answer.getContent();
  458. if (fieldsId == null || StrUtil.isBlank(content)) {
  459. throw BusinessRuntimeException.getInstance("必填项为空");
  460. }
  461. answer.setPromotionId(promotionId);
  462. answer.setGroupsId(groupsId);
  463. formFieldsDataMapper.insert(answer);
  464. });
  465. return GatewayResponse.SUCCESS.newBuilder().toResult();
  466. }
  467. /**
  468. * 查询用户是否填写问卷
  469. */
  470. @GetMapping("/check/questionnaire/{promotionId}")
  471. public Result<Boolean> checkQuestionnaire(@PathVariable Long promotionId) {
  472. long userId = StpUserUtil.getLoginIdAsLong();
  473. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  474. Integer count = formFieldsDataMapper.selectCount(Wrappers.lambdaQuery(FormFieldsData.class).in(FormFieldsData::getUserId, userIdList).eq(FormFieldsData::getPromotionId, promotionId));
  475. return GatewayResponse.SUCCESS.newBuilder().toResult(count > 0);
  476. }
  477. /**
  478. * 对应平台车票 广告配置列表
  479. */
  480. @GetMapping("/get/advertise")
  481. public Result<List<TicketAdvertiseConfigFrontView>> getTicketAdvertiseConfig() {
  482. long userId = StpUserUtil.getLoginIdAsLong();
  483. List<RenewalView> hasPayGoods = groupRelationFrontService.getHasPayGoods(userId);
  484. if (CollUtil.isEmpty(hasPayGoods)) {
  485. return GatewayResponse.SUCCESS.newBuilder().toResult();
  486. }
  487. List<Long> goodsIds = hasPayGoods.stream().map(RenewalView::getGoodsId).collect(Collectors.toList());
  488. log.info("userId:{}获取广告位配置", userId);
  489. List<TicketAdvertiseConfigFrontView> views = beanSearcher.searchAll(TicketAdvertiseConfigFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
  490. .field(TicketAdvertiseConfigFrontView::getGoodsId, goodsIds).op(Operator.InList)
  491. .orderBy(TicketAdvertiseConfigFrontView::getSorted).desc()
  492. .orderBy(TicketAdvertiseConfigFrontView::getGoodsId).asc()
  493. .orderBy(TicketAdvertiseConfigFrontView::getConfigId).desc()
  494. .build());
  495. return GatewayResponse.SUCCESS.newBuilder().toResult(views);
  496. }
  497. /**
  498. * 记录用户点击车票广告
  499. */
  500. @PostMapping("/click/ticket/advertise/record/{configId}")
  501. public Result<String> recordClickTicketAdvertise(@PathVariable Long configId) {
  502. long userId = StpUserUtil.getLoginIdAsLong();
  503. ticketAdvertiseConfigClickRecordService.recordUserClickTicketAdvertise(userId, configId);
  504. return GatewayResponse.SUCCESS.newBuilder().toResult();
  505. }
  506. /**
  507. * 推荐平台
  508. */
  509. @GetMapping("/get/recommend/goods")
  510. public Result<Page<UserRecommendGoodsFrontView>> getRecommendGoodsViews(@RequestParam(defaultValue = "0") Integer start, @RequestParam(defaultValue = "5") Integer limit) {
  511. //推荐用户未购买的车票平台 优先展示ai类平台 然后是影视流媒体
  512. long userId = StpUserUtil.getLoginIdAsLong();
  513. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  514. List<Long> filter_goods_id = relationMapper.getTicketGoodsId(userIds, List.of("validity", "overdue", "outside"));
  515. //用户是否购买过奈飞产品
  516. Boolean isPayNf = false;
  517. if (filter_goods_id.contains(1l)) {
  518. isPayNf = true;
  519. } else {
  520. int count = orderDonService.count(Wrappers.lambdaQuery(OrderDon.class)
  521. .eq(OrderDon::getGoodsId, 1)
  522. .eq(OrderDon::getUserId, userId)
  523. .notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
  524. if (count > 0) {
  525. //优先展示路由器、ai、流媒体
  526. isPayNf = true;
  527. }
  528. }
  529. Boolean filterCourseGoods = false;
  530. //GPT Plus基础2月 课程不展示
  531. Integer orders = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  532. .in(OrderDon::getUserId, userIds)
  533. .eq(OrderDon::getSkuId, 444)
  534. .notIn(OrderDon::getStatus, Constant.noOrderStatus));
  535. if (orders > 0) {
  536. filterCourseGoods = true;
  537. }
  538. Page<UserRecommendGoodsFrontView> page = groupRelationFrontService.getRecommendGoodsViews(isPayNf, filter_goods_id, filterCourseGoods, start, limit);
  539. return GatewayResponse.SUCCESS.newBuilder().toResult(page);
  540. }
  541. /**
  542. * 查看GPT token
  543. */
  544. @GetMapping("/get/gptAccessToken")
  545. public Result<String> getGptAccessToken(Long relationId) throws Exception {
  546. long userId = StpUserUtil.getLoginIdAsLong();
  547. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  548. //存在该车票
  549. RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
  550. .field(RenewalView::getRelationId, relationId)
  551. .field(RenewalView::getUserId, userIds).op(Operator.InList).build());
  552. Assert.notNull(renewalView, "您的车票不存在");
  553. if (renewalView.getGoodsId() != 42) {
  554. throw BusinessRuntimeException.getInstance("该平台类型车票无法获取GPT直连token");
  555. }
  556. String account = renewalView.getAccount();
  557. String accessToken = chatGptAuthService.getAccessToken(account);
  558. return GatewayResponse.SUCCESS.newBuilder().toResult(accessToken);
  559. }
  560. /**
  561. * 获取特殊类型课程 通过邮件发送课程
  562. * 领取课件
  563. */
  564. @PostMapping("/courseware")
  565. public Result<String> getCourseWare(@RequestBody SpecialGoodsTicketReq request) throws Exception {
  566. long userId = StpUserUtil.getLoginIdAsLong();
  567. request.setUserId(userId);
  568. groupRelationFrontService.sendCourseWare(request);
  569. return GatewayResponse.SUCCESS.newBuilder().toResult();
  570. }
  571. //获取课程云盘链接
  572. @GetMapping("/get/courseware")
  573. public Result<GoodsCoursewareFile> getGoodsCourseware(Long relationId) {
  574. long userId = StpUserUtil.getLoginIdAsLong();
  575. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  576. RenewalView relationView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
  577. .field(RenewalView::getUserId, userIdList).op(Operator.InList)
  578. .field(RenewalView::getRelationId, relationId).build());
  579. if (relationView == null) {
  580. throw BusinessRuntimeException.getInstance("您的车票不存在");
  581. }
  582. GoodsCoursewareFile goodsCoursewareFile = goodsCoursewareFileMapper.selectOne(Wrappers.lambdaQuery(GoodsCoursewareFile.class)
  583. .eq(GoodsCoursewareFile::getGoodsId, relationView.getGoodsId())
  584. .eq(GoodsCoursewareFile::getStatus, true)
  585. .select(GoodsCoursewareFile::getLink, GoodsCoursewareFile::getCode)
  586. .last("limit 1"));
  587. if (goodsCoursewareFile == null) {
  588. throw BusinessRuntimeException.getInstance("暂未配置课件链接地址,请联系客服");
  589. }
  590. return GatewayResponse.SUCCESS.newBuilder().toResult(goodsCoursewareFile);
  591. }
  592. /**
  593. * 读取车票账号登录验证码
  594. */
  595. @PostMapping("/get/verifyCode")
  596. public Result<String> getAiVerifyCode(@RequestBody TicketLoginReq loginReq) throws Exception {
  597. long userId = StpUserUtil.getLoginIdAsLong();
  598. loginReq.setUserId(userId);
  599. return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.getAiVerifyCode(loginReq));
  600. }
  601. /**
  602. * 车票后台登录
  603. */
  604. @PostMapping("/ticket/login")
  605. public Result<GroupsRelation> ticketLogin(@RequestBody TicketLoginReq loginReq) {
  606. GroupsRelation relation = groupRelationFrontService.ticketLogin(loginReq);
  607. return GatewayResponse.SUCCESS.newBuilder().toResult(relation);
  608. }
  609. /**
  610. * 奈飞验证校验
  611. */
  612. @PostMapping("/ticket/verify")
  613. public Result<String> outsideTicketVerify(@RequestBody TicketLoginReq loginReq) {
  614. return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.outsideTicketVerify(loginReq));
  615. }
  616. /**
  617. * 是否有mid车票可候补
  618. */
  619. @GetMapping("/get/standby")
  620. public Result<GptStandbyResp> getGptStandby() {
  621. long userId = StpUserUtil.getLoginIdAsLong();
  622. List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
  623. String condition = "(a.account like '%@yinhe.ac.cn%' or exists (select id from account_blocked_replace_record abrr where abrr.account = a.account and abrr.goods_id = g.id limit 1))";
  624. List<RenewalView> renewalViewList = beanSearcher.searchAll(RenewalView.class, MapUtils.builder()
  625. .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
  626. .field(RenewalView::getGoodsId, 26)
  627. .put("condition", condition)
  628. .field(RenewalView::getExpiryTime).op(Operator.NotNull)
  629. .onlySelect(RenewalView::getAccount, RenewalView::getExpiryTime)
  630. .build());
  631. GptStandbyResp gptStandbyResp = new GptStandbyResp();
  632. if (renewalViewList.isEmpty()) {
  633. gptStandbyResp.setIsHasAccount(false);
  634. return GatewayResponse.SUCCESS.newBuilder().toResult(gptStandbyResp);
  635. }
  636. List<RenewalView> overTen = new ArrayList<>();
  637. List<RenewalView> underTen = new ArrayList<>();
  638. DateTime now = DateTime.now();
  639. renewalViewList.forEach(e -> {
  640. if (e.getExpiryTime().compareTo(DateUtil.offsetDay(now, 10)) > 0) {
  641. overTen.add(e);
  642. } else underTen.add(e);
  643. });
  644. Integer accountBlockedCount = 1;
  645. if (overTen.size() > 1) {
  646. List<String> accountList = overTen.stream().map(RenewalView::getAccount).distinct().collect(Collectors.toList());
  647. accountBlockedCount = accountBlockedReplaceRecordMapper.selectCount(Wrappers.lambdaQuery(AccountBlockedReplaceRecord.class)
  648. .eq(AccountBlockedReplaceRecord::getGoodsId, 26)
  649. .in(AccountBlockedReplaceRecord::getAccount, accountList));
  650. }
  651. if (accountBlockedCount > 1) {
  652. gptStandbyResp.setIsHasAccount(false);
  653. return GatewayResponse.SUCCESS.newBuilder().toResult(gptStandbyResp);
  654. }
  655. gptStandbyResp.setIsHasAccount(true);
  656. gptStandbyResp.setOverTen(overTen);
  657. gptStandbyResp.setUnderTen(underTen);
  658. Integer count = gptTicketStandbyMapper.selectCount(Wrappers.lambdaQuery(GptTicketStandby.class)
  659. .in(GptTicketStandby::getUserId, relationUserIdList));
  660. gptStandbyResp.setIsApply(count > 0 ? true : false);
  661. return GatewayResponse.SUCCESS.newBuilder().toResult(gptStandbyResp);
  662. }
  663. /**
  664. * 申请候补
  665. */
  666. @PostMapping("/apply/standby")
  667. @NoSubmit
  668. public Result<Boolean> applyGptStandby() {
  669. long userId = StpUserUtil.getLoginIdAsLong();
  670. List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
  671. String condition = "(a.account like '%@yinhe.ac.cn%' or exists (select id from account_blocked_replace_record abrr where abrr.account = a.account and abrr.goods_id = g.id limit 1))";
  672. List<RenewalView> renewalViewList = beanSearcher.searchAll(RenewalView.class, MapUtils.builder()
  673. .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
  674. .field(RenewalView::getGoodsId, 26)
  675. .put("condition", condition)
  676. .field(RenewalView::getExpiryTime, DateUtil.offsetDay(DateTime.now(), 10)).op(Operator.GreaterThan)
  677. .onlySelect(RenewalView::getAccount)
  678. .build());
  679. if (renewalViewList.isEmpty()) {
  680. throw BusinessRuntimeException.getInstance("你未有车票账号");
  681. }
  682. Integer count = gptTicketStandbyMapper.selectCount(Wrappers.lambdaQuery(GptTicketStandby.class)
  683. .in(GptTicketStandby::getUserId, relationUserIdList));
  684. if (count > 0) {
  685. throw BusinessRuntimeException.getInstance("你已申请车票账号候补");
  686. }
  687. if (renewalViewList.size() > 1) {
  688. Set<String> accountSet = renewalViewList.stream().map(RenewalView::getAccount).collect(Collectors.toSet());
  689. Integer accountBlockedCount = accountBlockedReplaceRecordMapper.selectCount(Wrappers.lambdaQuery(AccountBlockedReplaceRecord.class)
  690. .eq(AccountBlockedReplaceRecord::getGoodsId, 26)
  691. .in(AccountBlockedReplaceRecord::getAccount, accountSet));
  692. if (accountBlockedCount > 1) {
  693. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  694. }
  695. }
  696. GptTicketStandby gptTicketStandby = new GptTicketStandby();
  697. gptTicketStandby.setUserId(userId);
  698. gptTicketStandbyMapper.insert(gptTicketStandby);
  699. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  700. }
  701. /**
  702. * midjourney车票退款
  703. */
  704. @PutMapping("/refund/ticketOrder/{relationId}")
  705. @NoSubmit
  706. public Result<String> ticketRefundOrders(@PathVariable Long relationId) throws Exception {
  707. long userId = StpUserUtil.getLoginIdAsLong();
  708. List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
  709. String condition = "(a.account like '%@yinhe.ac.cn%' or exists (select id from account_blocked_replace_record abrr where abrr.account = a.account and abrr.goods_id = g.id limit 1))";
  710. RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
  711. .field(RenewalView::getRelationId, relationId)
  712. .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
  713. .put("condition", condition)
  714. .field(RenewalView::getGoodsId, 26)
  715. .field(RenewalView::getExpiryTime, DateUtil.offsetDay(DateTime.now(), 10)).op(Operator.LessEqual)
  716. .build());
  717. if (renewalView == null) {
  718. throw BusinessRuntimeException.getInstance("你车票不存在或不符合退款要求");
  719. }
  720. OrderDon orderDon = orderDonService.getOne(Wrappers.lambdaQuery(OrderDon.class)
  721. .in(OrderDon::getUserId, relationUserIdList)
  722. .eq(OrderDon::getRelationId, relationId)
  723. .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
  724. .orderByDesc(OrderDon::getId)
  725. .last("limit 1"));
  726. if (orderDon == null) {
  727. throw BusinessRuntimeException.getInstance("你对应车票的订单不存在");
  728. }
  729. GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
  730. if (sku == null) {
  731. throw BusinessRuntimeException.getInstance("该车票规格不存在,请联系客服进行人工退款..");
  732. }
  733. Date expiryTime = renewalView.getExpiryTime();
  734. long remainDay = DateUtil.between(DateTime.now(), expiryTime, DateUnit.DAY) + 1;
  735. BigDecimal money = orderDon.getMoney();
  736. BigDecimal refundMoney = null;
  737. BigDecimal refundBalance= null;
  738. String refundType = null;
  739. if (money.compareTo(BigDecimal.ZERO) > 0) {
  740. BigDecimal dayMoney = money.divide(BigDecimal.valueOf(sku.getMonths()).multiply(BigDecimal.valueOf(30)), 2, RoundingMode.HALF_DOWN);
  741. refundMoney = BigDecimal.valueOf(remainDay).multiply(dayMoney);
  742. refundType = "money";
  743. }
  744. OrderRefundReq refundReq = new OrderRefundReq();
  745. if (orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
  746. BigDecimal dayMoney = orderDon.getBalance().divide(BigDecimal.valueOf(sku.getMonths()).multiply(BigDecimal.valueOf(30)), 2, RoundingMode.HALF_DOWN);
  747. refundBalance = BigDecimal.valueOf(remainDay).multiply(dayMoney);
  748. refundReq.setIsOnly(true);
  749. }
  750. refundReq.setOrderId(orderDon.getId());
  751. refundReq.setRefundDesc("失效车票退款");
  752. refundReq.setRefundMoney(Optional.ofNullable(refundMoney).orElse(BigDecimal.ZERO));
  753. refundReq.setRefundBalance(Optional.ofNullable(refundBalance).orElse(BigDecimal.ZERO));
  754. refundReq.setRefundType(Optional.ofNullable(refundType).orElse("balance"));
  755. cmsOrderDonService.unifiedRefund(refundReq);
  756. return GatewayResponse.SUCCESS.newBuilder().toResult();
  757. }
  758. /**
  759. * 每日车票到期弹窗
  760. */
  761. @GetMapping("/get/expiry/notify")
  762. public Result<List<RenewalView>> getExpiryRenewalNotify() {
  763. Long userId = StpUserUtil.getLoginIdAsLong();
  764. List<RenewalView> expiryRenewals = groupRelationFrontService.getExpiryRenewalNotify(userId);
  765. return GatewayResponse.SUCCESS.newBuilder().toResult(expiryRenewals);
  766. }
  767. /**
  768. * 车票详情
  769. */
  770. @GetMapping("/get/detail")
  771. public Result<RenewalView> getTicketDetail(Long relationId) {
  772. if (relationId == null) {
  773. return GatewayResponse.SUCCESS.newBuilder().toResult();
  774. }
  775. long userId = StpUserUtil.getLoginIdAsLong();
  776. RenewalView ticketDetail = groupRelationFrontService.getTicketDetail(userId, relationId);
  777. return GatewayResponse.SUCCESS.newBuilder().toResult(ticketDetail);
  778. }
  779. /**
  780. * 车票售后常见问题
  781. */
  782. @GetMapping("/get/questions/{goodsId}")
  783. public Result<List<GoodsDonQaFrontView>> getTicketQuestions(@PathVariable Long goodsId, @RequestParam(defaultValue = "1") Integer type) {
  784. long userId = StpUserUtil.getLoginIdAsLong();
  785. log.info("userId:{}查看车票:{}售后问题", userId, goodsId);
  786. if (type < 1 || type > 2) {
  787. return GatewayResponse.SUCCESS.newBuilder().toResult();
  788. }
  789. String key = RedisService.key.YH_GOODS_QUESTIONS_DETAIL.getNameFormat(type, goodsId);
  790. Object o = redisService.get(key);
  791. if (o == null) {
  792. List<GoodsDonQaFrontView> donQaFrontViews = beanSearcher.searchAll(GoodsDonQaFrontView.class, MapUtils.builder().field(GoodsDonQaFrontView::getGoodsId, goodsId).field(GoodsDonQaFrontView::getType, type).build());
  793. if (CollUtil.isEmpty(donQaFrontViews)) {
  794. return GatewayResponse.SUCCESS.newBuilder().toResult();
  795. }
  796. redisService.setNx(key, donQaFrontViews, RedisService.key.YH_GOODS_QUESTIONS_DETAIL.getTimeout());
  797. o = redisService.get(key);
  798. }
  799. List<GoodsDonQaFrontView> donQaFrontViews = Jsons.parseList(o, GoodsDonQaFrontView.class);
  800. return GatewayResponse.SUCCESS.newBuilder().toResult(donQaFrontViews);
  801. }
  802. /**
  803. * 车票所有常见问题
  804. */
  805. @GetMapping("/get/questions")
  806. public Result<List<GoodsDonQaFrontView>> getAllTicketQuestions(String participle) {
  807. MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap());
  808. if (StrUtil.isNotBlank(participle)) {
  809. char[] charArray = participle.toCharArray();
  810. StringBuilder p = new StringBuilder();
  811. p.append("and (");
  812. for (int i = 0; i < charArray.length; i++) {
  813. char c = charArray[i];
  814. p.append(String.format(" ga.problem like '%%%s%%'", c));
  815. if (i != charArray.length - 1) {
  816. p.append(" or ");
  817. }
  818. }
  819. p.append(")");
  820. builder.put("p", p);
  821. }
  822. List<GoodsDonQaFrontView> donQaFrontViews = beanSearcher.searchAll(GoodsDonQaFrontView.class, builder.build());
  823. return GatewayResponse.SUCCESS.newBuilder().toResult(donQaFrontViews);
  824. }
  825. /**
  826. * 是否首次购买车票
  827. */
  828. @GetMapping("/get/first/pay/{goodsId}")
  829. public Result<Boolean> getFirstPay(@PathVariable Long goodsId) {
  830. long userId = StpUserUtil.getLoginIdAsLong();
  831. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  832. Number number = beanSearcher.searchCount(OrderDon.class, MapUtils.builder()
  833. .field(OrderDon::getGoodsId, goodsId)
  834. .field(OrderDon::getCreatedTime, new DateTime().toDateStr()).op(Operator.LessEqual)
  835. .field(OrderDon::getUserId, userIdList).op(Operator.InList)
  836. .field(OrderDon::getStatus, Constant.noOrderStatus).op(Operator.NotIn)
  837. .build());
  838. if (number.intValue() == 0) {
  839. UserGoodsNewbieGuideRecord userGoodsNewbieGuideRecord = new UserGoodsNewbieGuideRecord();
  840. userGoodsNewbieGuideRecord.setGoodsId(goodsId);
  841. userGoodsNewbieGuideRecord.setUserId(userId);
  842. userGoodsNewbieGuideRecordMapper.insert(userGoodsNewbieGuideRecord);
  843. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  844. }
  845. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  846. }
  847. /**
  848. * 设置pin码
  849. */
  850. @PutMapping("/set/pin/{relationId}")
  851. public Result<String> setPin(@PathVariable Long relationId, String code) {
  852. long userId = StpUserUtil.getLoginIdAsLong();
  853. JSONObject data = groupsRelationNetflixService.setNetflixPin(relationId, userId, code);
  854. return GatewayResponse.SUCCESS.newBuilder().toResult(data.toString());
  855. }
  856. /**
  857. * 查询是否设置成功
  858. */
  859. @GetMapping("/get/pin/status/{taskId}")
  860. public Result<Integer> getPinStatus(@PathVariable String taskId) throws Exception {
  861. long userId = StpUserUtil.getLoginIdAsLong();
  862. log.info("userId:{}查看设置pin码状态", userId);
  863. return GatewayResponse.SUCCESS.newBuilder().toResult(groupsRelationNetflixService.getPinStatus(taskId));
  864. }
  865. /**
  866. * 踢出奈飞设备
  867. */
  868. @PostMapping("/kickOut/nf/{relationId}")
  869. public Result<String> nfKickOut(@PathVariable Long relationId) {
  870. long userId = StpUserUtil.getLoginIdAsLong();
  871. JSONObject data = groupsRelationNetflixService.nfKickOut(userId, relationId);
  872. return GatewayResponse.SUCCESS.newBuilder().toResult(data.toString());
  873. }
  874. /**
  875. * 奈飞同户装置链接
  876. */
  877. @GetMapping("/get/nf/household/device")
  878. public Result<String> getNfHouseholdDevice(@NotNull Long relationId) throws Exception {
  879. long userId = StpUserUtil.getLoginIdAsLong();
  880. String url = groupRelationFrontService.getNfHouseholdDevice(userId, relationId);
  881. return GatewayResponse.SUCCESS.newBuilder().toResult(url);
  882. }
  883. /**
  884. * 代点奈飞同户装置
  885. */
  886. @PostMapping("/click/nf/household/device")
  887. public void clickNfHouseholdDevice(@RequestBody NfDeviceReq nfDeviceReq) {
  888. groupsRelationNetflixService.clickNfHouseholdDevice(nfDeviceReq);
  889. }
  890. /**
  891. * 可选 续费升级车票
  892. */
  893. @GetMapping("/get/renew/skus/{relationId}/{skuId}")
  894. public Result<List<RenewUpgradePackageFrontView>> getRenewSkus(@PathVariable Long relationId, @PathVariable Long skuId) {
  895. long userId = StpUserUtil.getLoginIdAsLong();
  896. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  897. ChatgptUser chatgptUser = chatgptUserMapper.selectOne(Wrappers.lambdaQuery(ChatgptUser.class)
  898. .eq(ChatgptUser::getRelationId, relationId)
  899. .last("limit 1"));
  900. if (chatgptUser == null) return GatewayResponse.SUCCESS.newBuilder().toResult();
  901. //目前续费升级的规格
  902. Long renewSkuId = chatgptUser.getRenewSkuId();
  903. GoodsDonSku sku = goodsDonSkuMapper.selectById(skuId);
  904. AtomicInteger minMonths = new AtomicInteger(sku.getMonths());
  905. AtomicInteger minNum = new AtomicInteger(chatgptUser.getLimitNum());
  906. AtomicLong minTime = new AtomicLong(chatgptUser.getLimitTime());
  907. if (renewSkuId != null) {
  908. GoodsDonSku presentRenew = goodsDonSkuMapper.selectById(renewSkuId);
  909. minMonths.set(presentRenew.getMonths());
  910. }
  911. if (chatgptUser.getPackageId() != 0) {
  912. Long packageId = chatgptUser.getPackageId();
  913. UpgradeOrderDon upgradeOrderDon = upgradeOrderDonMapper.selectOne(Wrappers.lambdaQuery(UpgradeOrderDon.class)
  914. .eq(UpgradeOrderDon::getPackageId, packageId)
  915. .eq(UpgradeOrderDon::getRelationId, relationId)
  916. .in(UpgradeOrderDon::getUserId, userIdList)
  917. .last("limit 1"));
  918. Long upgradeOrderDonSkuId = upgradeOrderDon.getSkuId();
  919. GoodsDonSku upgradeSku = goodsDonSkuMapper.selectById(upgradeOrderDonSkuId);
  920. if (upgradeSku != null) {
  921. if (upgradeSku.getMonths() > minMonths.get()) {
  922. minMonths.set(upgradeSku.getMonths());
  923. }
  924. }
  925. }
  926. List<RenewUpgradePackageFrontView> renewUpgradePackageFrontViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.class, MapUtils.builder().field(RenewUpgradePackageFrontView::getSkuId, skuId).build());
  927. renewUpgradePackageFrontViews.forEach(renew -> {
  928. try {
  929. List<Long> upgradeSkuIds = Jsons.parseList(renew.getUpgradeSkuIds(), Long.class);
  930. //年付展示
  931. MapBuilder builder = MapUtils.builder();
  932. // if (minMonths.get() == 12) {
  933. // builder.field(RenewUpgradePackageFrontView.RenewSkuView::getMonths, minMonths.get()).op(Operator.GreaterEqual);
  934. // if (renewSkuId != null) {
  935. // upgradeSkuIds.remove(renewSkuId);
  936. // }
  937. // } else {
  938. // builder.field(RenewUpgradePackageFrontView.RenewSkuView::getMonths, minMonths.get()).op(Operator.GreaterEqual);
  939. // }
  940. //GPT镜像2月规格 特殊处理
  941. if (sku.getGoodsId() == 18 && sku.getMonths() == 2) {
  942. } else {
  943. //同续费时间规格
  944. builder.field(RenewUpgradePackageFrontView.RenewSkuView::getMonths, minMonths.get()).op(Operator.GreaterEqual);
  945. }
  946. if (renewSkuId != null) {
  947. upgradeSkuIds.remove(renewSkuId);
  948. }
  949. List<RenewUpgradePackageFrontView.RenewSkuView> renewSkuViews = new ArrayList<>();
  950. if (CollUtil.isNotEmpty(upgradeSkuIds)) {
  951. renewSkuViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.RenewSkuView.class, builder
  952. .field(RenewUpgradePackageFrontView.RenewSkuView::getGptLimitNum, minNum.get()).op(Operator.GreaterEqual)
  953. .field(RenewUpgradePackageFrontView.RenewSkuView::getGptLimitTime, minTime.get()).op(LessEqual.class)
  954. .field(RenewUpgradePackageFrontView.RenewSkuView::getSkuId, upgradeSkuIds).op(Operator.InList)
  955. .build());
  956. }
  957. renew.setRenewSkus(renewSkuViews);
  958. } catch (Exception e) {
  959. }
  960. });
  961. return GatewayResponse.SUCCESS.newBuilder().toResult(renewUpgradePackageFrontViews);
  962. }
  963. /**
  964. * 独立规格续费套餐列表
  965. */
  966. @GetMapping("/get/independent/renew/skus/{skuId}")
  967. public Result<List<RenewUpgradePackageFrontView>> getRenewSkus(@PathVariable Long skuId) {
  968. long userId = StpUserUtil.getLoginIdAsLong();
  969. List<RenewUpgradePackageFrontView> renewUpgradePackageFrontViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.class, MapUtils.builder().field(RenewUpgradePackageFrontView::getSkuId, skuId).build());
  970. renewUpgradePackageFrontViews.forEach(renew -> {
  971. try {
  972. List<Long> upgradeSkuIds = Jsons.parseList(renew.getUpgradeSkuIds(), Long.class);
  973. MapBuilder builder = MapUtils.builder();
  974. List<RenewUpgradePackageFrontView.RenewSkuView> renewSkuViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.RenewSkuView.class, builder
  975. .field(RenewUpgradePackageFrontView.RenewSkuView::getSkuId, upgradeSkuIds).op(Operator.InList)
  976. .build());
  977. renew.setRenewSkus(renewSkuViews);
  978. } catch (Exception e) {
  979. }
  980. });
  981. return GatewayResponse.SUCCESS.newBuilder().toResult(renewUpgradePackageFrontViews);
  982. }
  983. /**
  984. * claude pro续费升级
  985. */
  986. @GetMapping("/get/claude/renew/skus/{relationId}/{skuId}")
  987. public Result<List<RenewUpgradePackageFrontView> > getClaudeRenewSkus(@PathVariable Long relationId, @PathVariable Long skuId) {
  988. long userId = StpUserUtil.getLoginIdAsLong();
  989. ClaudeUser claudeUser = claudeUserMapper.selectOne(Wrappers.lambdaQuery(ClaudeUser.class)
  990. .eq(ClaudeUser::getRelationId, relationId)
  991. .last("limit 1"));
  992. if (claudeUser == null) return GatewayResponse.SUCCESS.newBuilder().toResult();
  993. List<RenewUpgradePackageFrontView> renewUpgradePackageFrontViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.class, MapUtils.builder().field(RenewUpgradePackageFrontView::getSkuId, skuId).build());
  994. renewUpgradePackageFrontViews.forEach(renew -> {
  995. try {
  996. List<Long> upgradeSkuIds = Jsons.parseList(renew.getUpgradeSkuIds(), Long.class);
  997. MapBuilder builder = MapUtils.builder();
  998. List<RenewUpgradePackageFrontView.RenewSkuView> renewSkuViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.RenewSkuView.class, builder
  999. .field(RenewUpgradePackageFrontView.RenewSkuView::getSkuId, upgradeSkuIds).op(Operator.InList)
  1000. .field(RenewUpgradePackageFrontView.RenewSkuView::getGptLimitNum, claudeUser.getLimitNum()).op(Operator.GreaterEqual)
  1001. .build());
  1002. renew.setRenewSkus(renewSkuViews);
  1003. } catch (Exception e) {
  1004. }
  1005. });
  1006. return GatewayResponse.SUCCESS.newBuilder().toResult(renewUpgradePackageFrontViews);
  1007. }
  1008. /**
  1009. * 已配置的续费升级规格ids
  1010. */
  1011. @GetMapping("/get/renew/skus/configured")
  1012. public Result<List<Long> > getClaudeRenewSkus() {
  1013. long userId = StpUserUtil.getLoginIdAsLong();
  1014. List<RenewUpgradePackageFrontView> renewUpgradePackageFrontViews = beanSearcher.searchAll(RenewUpgradePackageFrontView.class, MapUtils.builder().onlySelect(RenewUpgradePackageFrontView::getSkuId).build());
  1015. List<Long> collect = renewUpgradePackageFrontViews.stream().map(RenewUpgradePackageFrontView::getSkuId).collect(Collectors.toList());
  1016. return GatewayResponse.SUCCESS.newBuilder().toResult(collect);
  1017. }
  1018. /**
  1019. * 获取GPT PLUS登录验证码
  1020. */
  1021. @GetMapping("/get/verify/code")
  1022. public Result<String> getVerifyCode(@NotEmpty String account) throws Exception {
  1023. String code = groupRelationFrontService.getVerifyCode(account);
  1024. if (StrUtil.isEmpty(code)) {
  1025. throw BusinessRuntimeException.getInstance("请重新发送验证码");
  1026. }
  1027. return GatewayResponse.SUCCESS.newBuilder().toResult(code);
  1028. }
  1029. /**
  1030. * 独立规格续费减免
  1031. */
  1032. @GetMapping("/get/renew/reduce")
  1033. public Result<UserBenefitsFrontView> getRenewReduce(Long skuId, Long relationId) {
  1034. long userId = StpUserUtil.getLoginIdAsLong();
  1035. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  1036. UserBenefitsFrontView data = beanSearcher.searchFirst(UserBenefitsFrontView.class, MapUtils.builder().field(UserBenefitsFrontView::getSkuId, skuId).field(UserBenefitsFrontView::getType, UserBenefits.Type.RENEW.name()).build());
  1037. if (data == null) {
  1038. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1039. }
  1040. Date startTime = null;
  1041. if (relationId != null) {
  1042. GroupsRelation relation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
  1043. .eq(GroupsRelation::getId, relationId)
  1044. .in(GroupsRelation::getUserId, userIdList));
  1045. if (relation == null) {
  1046. throw BusinessRuntimeException.getInstance("车票不存在");
  1047. }
  1048. startTime = relation.getStartTime();
  1049. }
  1050. Integer renewCount = userBenefitsOrderRecordMapper.selectUseComboRecordByUid(userIdList, data.getType(), data.getGoodsId(), data.getSkuId(), Constant.noOrderAllStatus, null, startTime, relationId);
  1051. data.setRenewCount(renewCount);
  1052. return GatewayResponse.SUCCESS.newBuilder().toResult(data);
  1053. }
  1054. /**
  1055. * 申请更换车票
  1056. */
  1057. @PostMapping("/change/ticket")
  1058. @Deprecated
  1059. public Result<String> changeTicket(@RequestBody ChangeTicketReq changeTicketReq) {
  1060. long userId = StpUserUtil.getLoginIdAsLong();
  1061. List<Long> relationIds = changeTicketReq.getRelationIds();
  1062. if (CollUtil.isEmpty(relationIds)) {
  1063. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1064. }
  1065. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  1066. //奈飞超过3帐车票不给看
  1067. Number number = beanSearcher.searchCount(RenewalView.class, MapUtils.builder()
  1068. .field(RenewalView::getUserId, userIdList).op(Operator.InList)
  1069. .field(RenewalView::getGoodsId, 1)
  1070. .field(RenewalView::getExpiryTime, DateTime.now()).op(Operator.GreaterThan)
  1071. .build());
  1072. if (number.intValue() > 2) {
  1073. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1074. }
  1075. relationIds.forEach(relationId -> {
  1076. try {
  1077. groupRelationFrontService.changeTicket(userId, relationId);
  1078. } catch (Exception e) {
  1079. log.error("更换车票失败:{}", StringUtil.getErrorText(e));
  1080. if (relationIds.size() == 1) {
  1081. throw BusinessRuntimeException.getInstance(e.getMessage());
  1082. }
  1083. }
  1084. });
  1085. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1086. }
  1087. /**
  1088. * 查看临时账号
  1089. */
  1090. @GetMapping("/get/temp/account/{relationId}")
  1091. public Result<AccountView> getTempAccount(@PathVariable Long relationId) {
  1092. long userId = StpUserUtil.getLoginIdAsLong();
  1093. AccountView accountView = groupRelationFrontService.getTempAccount(userId, relationId);
  1094. return GatewayResponse.SUCCESS.newBuilder().toResult(accountView);
  1095. }
  1096. /**
  1097. * 申请提交记录
  1098. */
  1099. @GetMapping("/get/netflix/get/error/submit/record")
  1100. public Result<List<NetflixUserAccountStatusRecord>> getUserNetflixSubmitRecord() {
  1101. long userId = StpUserUtil.getLoginIdAsLong();
  1102. List<NetflixUserAccountStatusRecord> netflixUserAccountStatusRecords = groupRelationFrontService.getUserNetflixSubmitRecord(userId);
  1103. return GatewayResponse.SUCCESS.newBuilder().toResult(netflixUserAccountStatusRecords);
  1104. }
  1105. /**
  1106. * 奈飞账号异常检测提交
  1107. */
  1108. @PostMapping("/netflix/error/account/submit/{relationId}")
  1109. public Result<String> nfErrorAccountSubmit(@PathVariable Long relationId) {
  1110. long userId = StpUserUtil.getLoginIdAsLong();
  1111. groupRelationFrontService.nfErrorAccountSubmit(userId, relationId);
  1112. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1113. }
  1114. /**
  1115. * 奈飞账号检测结果
  1116. */
  1117. @GetMapping("/get/netflix/error/account/status/{relationId}")
  1118. public Result<NetflixErrorAccountStatus> getNetflixErrorAccountStatus(@PathVariable Long relationId) {
  1119. long userId = StpUserUtil.getLoginIdAsLong();
  1120. NetflixErrorAccountStatus status = groupRelationFrontService.getNetflixErrorAccountStatus(userId, relationId);
  1121. return GatewayResponse.SUCCESS.newBuilder().toResult(status);
  1122. }
  1123. /**
  1124. * 奈飞可替换其他规格车票列表
  1125. */
  1126. @GetMapping("/get/netflix/replace/other/skus/{relationId}")
  1127. public Result<List<GoodsCategorySkuView>> getNetflixReplaceOtherSkus(@PathVariable Long relationId) throws Exception {
  1128. long userId = StpUserUtil.getLoginIdAsLong();
  1129. List<GoodsCategorySkuView> goodsCategorySkuViews = groupRelationFrontService.getNetflixReplaceOtherSkus(userId, relationId);
  1130. return GatewayResponse.SUCCESS.newBuilder().toResult(goodsCategorySkuViews);
  1131. }
  1132. /**
  1133. * 奈飞账号申请恢复
  1134. */
  1135. @PostMapping("/netflix/submit/recover")
  1136. public Result<NetflixRecoverResp> netflixSubmitRecover(@RequestBody ErrorNetflixChangeReq req) {
  1137. long userId = StpUserUtil.getLoginIdAsLong();
  1138. req.setUserId(userId);
  1139. NetflixRecoverResp recoverResp = groupRelationFrontService.netflixSubmitRecover(req);
  1140. return GatewayResponse.SUCCESS.newBuilder().toResult(recoverResp);
  1141. }
  1142. /**
  1143. * 奈飞更换其他车票
  1144. */
  1145. @PostMapping("/netflix/submit/change/otherTicket")
  1146. public Result<Integer> errorNetflixSubmitChangeOtherTicket(@RequestBody ErrorNetflixChangeReq req) throws Exception {
  1147. long userId = StpUserUtil.getLoginIdAsLong();
  1148. req.setUserId(userId);
  1149. groupRelationFrontService.errorNetflixSubmitChangeOtherTicket(req);
  1150. return GatewayResponse.SUCCESS.newBuilder().toResult();
  1151. }
  1152. /**
  1153. * 不超过15天 奈飞退款info
  1154. */
  1155. @GetMapping("/netflix/refund/info/{relationId}")
  1156. public Result<NetflixRefundInfoResp> refundNetflixInfo(@PathVariable Long relationId) {
  1157. long userId = StpUserUtil.getLoginIdAsLong();
  1158. //是否可进行退款 true可 false否 走恢复账号流程
  1159. NetflixRefundInfoResp refundInfoResp = groupRelationFrontService.refundNetflixInfo(userId, relationId);
  1160. return GatewayResponse.SUCCESS.newBuilder().toResult(refundInfoResp);
  1161. }
  1162. /**
  1163. * 奈飞不超过15天有效期进行退款
  1164. * 是否可进行退款 true可 false否 走恢复账号流程
  1165. */
  1166. @PostMapping("/netflix/refund")
  1167. public Result<Boolean> refundNetflix(@RequestBody ErrorNetflixChangeReq req) throws Exception {
  1168. long userId = StpUserUtil.getLoginIdAsLong();
  1169. req.setUserId(userId);
  1170. //是否可进行退款 true可 false否 走恢复账号流程
  1171. Boolean availableRefund = groupRelationFrontService.refundNetflix(req);
  1172. return GatewayResponse.SUCCESS.newBuilder().toResult(availableRefund);
  1173. }
  1174. /**
  1175. * AI镜像车票 每周弹窗
  1176. */
  1177. @GetMapping("/get/mirror/popups")
  1178. public Result<Boolean> getMirrorPopups() {
  1179. long userId = StpUserUtil.getLoginIdAsLong();
  1180. Boolean flag = groupRelationFrontService.getMirrorPopups(userId);
  1181. return GatewayResponse.SUCCESS.newBuilder().toResult(flag);
  1182. }
  1183. }