GroupRelationController.java 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877
  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.dto.Result;
  22. import com.cyksj.enums.GatewayResponse;
  23. import com.cyksj.mapper.*;
  24. import com.cyksj.mapper.manage.form.FormFieldsDataMapper;
  25. import com.cyksj.mapper.manage.form.QuestionnairePromotionMapper;
  26. import com.cyksj.model.dto.DoubleVerifyDto;
  27. import com.cyksj.model.dto.QuestionnaireView;
  28. import com.cyksj.model.entity.*;
  29. import com.cyksj.model.manage.views.GroupsRelationView;
  30. import com.cyksj.model.request.OrderPayRequest;
  31. import com.cyksj.model.request.OrderRefundReq;
  32. import com.cyksj.model.request.SpecialGoodsTicketReq;
  33. import com.cyksj.model.request.TicketLoginReq;
  34. import com.cyksj.model.response.GptStandbyResp;
  35. import com.cyksj.model.views.*;
  36. import com.cyksj.redis.RedisService;
  37. import com.cyksj.service.chatgpt.ChatGptAuthService;
  38. import com.cyksj.service.mange.CmsOrderDonService;
  39. import com.cyksj.service.mange.coupon.CouponCommonService;
  40. import com.cyksj.service.mange.ticket.TicketAdvertiseConfigClickRecordService;
  41. import com.cyksj.service.order.OrderDonService;
  42. import com.cyksj.service.relation.GroupRelationFrontService;
  43. import com.cyksj.service.relation.GroupsRelationNetflixService;
  44. import com.cyksj.service.user.UserBindRelationService;
  45. import com.cyksj.service.user.UserService;
  46. import com.cyksj.web.util.StpUserUtil;
  47. import com.ejlchina.searcher.BeanSearcher;
  48. import com.ejlchina.searcher.SearchResult;
  49. import com.ejlchina.searcher.param.Operator;
  50. import com.ejlchina.searcher.util.MapUtils;
  51. import lombok.RequiredArgsConstructor;
  52. import lombok.extern.slf4j.Slf4j;
  53. import org.springframework.transaction.annotation.Transactional;
  54. import org.springframework.validation.annotation.Validated;
  55. import org.springframework.web.bind.annotation.*;
  56. import javax.servlet.http.HttpServletRequest;
  57. import java.math.BigDecimal;
  58. import java.math.RoundingMode;
  59. import java.util.*;
  60. import java.util.concurrent.TimeUnit;
  61. import java.util.stream.Collectors;
  62. /**
  63. * @author chan
  64. * @date 2022/9/27 11:48 AM
  65. */
  66. @Slf4j
  67. @RequiredArgsConstructor
  68. @RestController
  69. @RequestMapping("/applets/group/relation")
  70. public class GroupRelationController {
  71. private final BeanSearcher beanSearcher;
  72. private final OrderDonService orderDonService;
  73. private final GroupsRelationMapper relationMapper;
  74. private final GroupRelationFrontService groupRelationFrontService;
  75. private final UserService userService;
  76. private final UserBindRelationService userBindRelationService;
  77. private final TicketPwdViewRecordMapper ticketPwdViewRecordMapper;
  78. private final HttpServletRequest request;
  79. private final AccountDoubleVerifyRecordMapper accountDoubleVerifyRecordMapper;
  80. private final DoubleVerifyClickRecordMapper doubleVerifyRecordMapper;
  81. private final RedisService redisService;
  82. private final DoubleVerifyClickRefreshRecordMapper refreshRecordMapper;
  83. private final QuestionResponseRecordMapper questionResponseRecordMapper;
  84. private final CouponCommonService couponCommonService;
  85. private final FormFieldsDataMapper formFieldsDataMapper;
  86. private final QuestionnairePromotionMapper questionnairePromotionMapper;
  87. private final TicketAdvertiseConfigClickRecordService ticketAdvertiseConfigClickRecordService;
  88. private final GlobalThreadPoolTaskExecutor THREAD_POOL;
  89. private final ChatGptAuthService chatGptAuthService;
  90. private final GoodsCoursewareFileMapper goodsCoursewareFileMapper;
  91. private final GptTicketStandbyMapper gptTicketStandbyMapper;
  92. private final CmsOrderDonService cmsOrderDonService;
  93. private final GoodsDonSkuMapper goodsDonSkuMapper;
  94. private final AccountBlockedReplaceRecordMapper accountBlockedReplaceRecordMapper;
  95. private final OrderDonMapper orderDonMapper;
  96. private final UserGoodsNewbieGuideRecordMapper userGoodsNewbieGuideRecordMapper;
  97. private final GroupsRelationNetflixService groupsRelationNetflixService;
  98. private final static Sequence SEQUENCE = new Sequence(0);
  99. @RequestMapping("/get/renewal")
  100. public Result<SearchResult<RenewalView>> get(Boolean isLoginPopularize, String customId, String account) {
  101. long userId = StpUserUtil.getLoginIdAsLong();
  102. SearchResult<RenewalView> list = groupRelationFrontService.getMyTicket(userId, isLoginPopularize, customId, account);
  103. return GatewayResponse.SUCCESS.newBuilder().toResult(list);
  104. }
  105. @GetMapping("/get/pay/goods")
  106. public Result<List<RenewalView>> getHasPayGoods() {
  107. long userId = StpUserUtil.getLoginIdAsLong();
  108. List<RenewalView> hasPayGoods = groupRelationFrontService.getHasPayGoods(userId);
  109. return GatewayResponse.SUCCESS.newBuilder().toResult(hasPayGoods);
  110. }
  111. @PostMapping("/post/renewal")
  112. public Result<OrderDon> renewal(@RequestBody OrderPayRequest payRequest) throws Exception {
  113. long userId = StpUserUtil.getLoginIdAsLong();
  114. payRequest.setUserId(userId);
  115. String ip = ServletUtil.getClientIP(request);
  116. payRequest.setIp(ip);
  117. OrderDon orderDon = orderDonService.renewal(payRequest);
  118. return GatewayResponse.SUCCESS.newBuilder().toResult(orderDon);
  119. }
  120. @PutMapping("/update/set/account")
  121. public Result<String> setAccount(@RequestBody GroupsRelation relation) {
  122. long userId = StpUserUtil.getLoginIdAsLong();
  123. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  124. GroupsRelation re = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
  125. .eq(GroupsRelation::getId, relation.getId())
  126. .in(GroupsRelation::getUserId, userIds)
  127. .last(" limit 1"));
  128. if (re == null) {
  129. throw new BusinessRuntimeException("该车票不存在,请联系客服.");
  130. }
  131. LambdaUpdateWrapper<GroupsRelation> updateWrapper = Wrappers.lambdaUpdate(GroupsRelation.class)
  132. .set(GroupsRelation::getAccount, relation.getAccount())
  133. .set(GroupsRelation::getPassword, relation.getPassword())
  134. .eq(GroupsRelation::getId, relation.getId());
  135. if (re.getRechargeStatus() != null) {
  136. if (re.getRechargeStatus() == GroupsRelation.RechargeStatus.complete) {
  137. throw BusinessRuntimeException.getInstance("代充账号已充值");
  138. }
  139. if (StrUtil.isEmpty(relation.getAccount()) || StrUtil.isEmpty(relation.getPassword())) {
  140. throw BusinessRuntimeException.getInstance("请输入正确的账号密码信息");
  141. }
  142. if (re.getRechargeStatus() == GroupsRelation.RechargeStatus.error) {
  143. updateWrapper.set(GroupsRelation::getRechargeStatus, GroupsRelation.RechargeStatus.waiting);
  144. }
  145. }
  146. relationMapper.update(relation, updateWrapper);
  147. return GatewayResponse.SUCCESS.newBuilder().toResult();
  148. }
  149. /**
  150. * 查询是否加入了企业微信
  151. */
  152. @GetMapping("/check/joinCorpWx")
  153. public Result<Boolean> isJoinCorpWx() {
  154. long userId = StpUserUtil.getLoginIdAsLong();
  155. Boolean flag = groupRelationFrontService.isJoinCorpWx(userId, false, false);
  156. return GatewayResponse.SUCCESS.newBuilder().toResult(flag);
  157. }
  158. /**
  159. * 获取全部车票
  160. */
  161. @GetMapping("/get")
  162. public Result<List<UserTicketView>> getUserTicketView() {
  163. long userId = StpUserUtil.getLoginIdAsLong();
  164. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  165. List<UserTicketView> ticketViews = beanSearcher.searchAll(UserTicketView.class, MapUtils.flatBuilder(request.getParameterMap())
  166. .field(UserTicketView::getUserId, userIds).op(Operator.InList)
  167. .field(RenewalView::getStatus, List.of("validity", "outside")).op(Operator.InList)
  168. .orderBy(UserTicketView::getRelationId).asc()
  169. .build());
  170. return GatewayResponse.SUCCESS.newBuilder().toResult(ticketViews);
  171. }
  172. /**
  173. * 记录查看ChatGPT车票密码
  174. */
  175. @GetMapping("/recordView/{relationId}")
  176. public Result<String> recordGPTPwdView(@PathVariable Long relationId) {
  177. long userId = StpUserUtil.getLoginIdAsLong();
  178. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  179. GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
  180. .field(GroupsRelationView::getUserId, userIds).op(Operator.InList)
  181. .field(GroupsRelationView::getId, relationId).build());
  182. if (groupsRelationView == null) {
  183. log.info("userId:{}查看relationId:{}车票不存在", userId, relationId);
  184. throw BusinessRuntimeException.getInstance("该车票已不存在");
  185. }
  186. if (groupsRelationView.getAccountId() == null) throw BusinessRuntimeException.getInstance("该车队未配置账号");
  187. if (groupRelationFrontService == null) throw BusinessRuntimeException.getInstance("车票已不存在");
  188. TicketPwdViewRecord viewRecord = new TicketPwdViewRecord();
  189. viewRecord.setUserId(userId);
  190. viewRecord.setRelationId(relationId);
  191. viewRecord.setSkuId(groupsRelationView.getSkuId());
  192. viewRecord.setOperateLocation(ServletUtil.getClientIP(request));
  193. viewRecord.setAccount(groupsRelationView.getTripsAccount());
  194. viewRecord.setPassword(groupsRelationView.getTripsPassword());
  195. ticketPwdViewRecordMapper.insert(viewRecord);
  196. if (groupsRelationView.getGoodsId() == 18 && StrUtil.isEmpty(groupsRelationView.getApiSecret())) {
  197. THREAD_POOL.execute(() -> {
  198. //车队所有人查看密码
  199. Integer num = groupsRelationView.getGtNum();
  200. Integer viewNum = relationMapper.selectViewPwdCount(groupsRelationView.getGroupsId());
  201. if (num <= viewNum) {
  202. AccountDoubleVerifyRecord exist = accountDoubleVerifyRecordMapper.selectOne(Wrappers.lambdaQuery(AccountDoubleVerifyRecord.class)
  203. .eq(AccountDoubleVerifyRecord::getAccountId, groupsRelationView.getAccountId())
  204. .eq(AccountDoubleVerifyRecord::getDeleted, true).last("limit 1"));
  205. if (exist == null) {
  206. if (redisService.setNx(String.format("%s-%s", groupsRelationView.getAccountId(), groupsRelationView.getId()), groupsRelationView.getId(), 60l)) {
  207. //记录
  208. AccountDoubleVerifyRecord accountDoubleVerifyRecord = new AccountDoubleVerifyRecord();
  209. accountDoubleVerifyRecord.setAccountId(groupsRelationView.getAccountId());
  210. accountDoubleVerifyRecord.setAccount(groupsRelationView.getTripsAccount());
  211. accountDoubleVerifyRecord.setGroupsId(groupsRelationView.getGroupsId());
  212. accountDoubleVerifyRecord.setSkuId(groupsRelationView.getSkuId());
  213. accountDoubleVerifyRecord.setRemark("车队所有人看过密码");
  214. accountDoubleVerifyRecordMapper.insert(accountDoubleVerifyRecord);
  215. }
  216. }
  217. }
  218. });
  219. }
  220. return GatewayResponse.SUCCESS.newBuilder().toResult(groupsRelationView.getTripsPassword());
  221. }
  222. /**
  223. * 获取AI类 ChatGPT产品谷歌验证码
  224. */
  225. @GetMapping("/get/authCode")
  226. public Result<String> getAuthCode(Long relationId) {
  227. long userId = StpUserUtil.getLoginIdAsLong();
  228. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  229. if (relationId == null) throw BusinessRuntimeException.getInstance("车票不存在");
  230. GroupsRelationView groupsRelationView = beanSearcher.searchFirst(GroupsRelationView.class, MapUtils.builder()
  231. .field(GroupsRelationView::getId, relationId)
  232. .field(GroupsRelationView::getUserId, userIds).op(Operator.InList).build());
  233. if (groupsRelationView == null) throw BusinessRuntimeException.getInstance("车票不存在");
  234. if (StrUtil.isEmpty(groupsRelationView.getApiSecret())) throw BusinessRuntimeException.getInstance("未开启验证");
  235. DateTime now = DateTime.now();
  236. Integer count = doubleVerifyRecordMapper.selectCount(Wrappers.lambdaQuery(DoubleVerifyClickRecord.class)
  237. .in(DoubleVerifyClickRecord::getUserId, userIds)
  238. .eq(DoubleVerifyClickRecord::getRelationId, relationId)
  239. .eq(DoubleVerifyClickRecord::getAccountId, groupsRelationView.getAccountId())
  240. .between(DoubleVerifyClickRecord::getCreatedTime, DateUtil.beginOfMonth(now), DateUtil.endOfMonth(now)));
  241. //获取双重验证码
  242. Boolean isHasVerifyCode = StrUtil.isNotBlank(groupsRelationView.getVerifyCode()) ? true : false;
  243. //出去亚马逊 获取限制
  244. if (groupsRelationView.getGoodsId() != 6) {
  245. Integer num = groupRelationFrontService.getUserCodeNumBySkuId(userId, groupsRelationView.getSkuId(), isHasVerifyCode);
  246. if (count >= num) throw BusinessRuntimeException.getInstance("获取双重验证码次数上限");
  247. }
  248. //一分钟内 只能一人获取
  249. boolean b = redisService.setNx(RedisService.key.DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY.getEnvName() + groupsRelationView.getTripsAccount(), relationId, RedisService.key.DOUBLE_VERIFY_CODE_VIEW_MINUTES_KEY.getTimeout());
  250. if (!b) {
  251. throw BusinessRuntimeException.getInstance("一分钟内已有人获取该账号验证码,请稍后获取..");
  252. }
  253. int second = now.second();
  254. if (second < 30 && 30 - second < 3) {
  255. ThreadUtil.sleep(30 - second + 1, TimeUnit.SECONDS);
  256. } else if (second > 30 && 60 - second < 3) {
  257. ThreadUtil.sleep(60 - second + 1, TimeUnit.SECONDS);
  258. }
  259. StringBuilder sb = new StringBuilder();
  260. JSONObject re = new JSONObject();
  261. try {
  262. long code = GoogleGenerator.getCode(groupsRelationView.getApiSecret(), now.getTime());
  263. sb.append(code);
  264. while (sb.length() < 6) {
  265. sb.insert(0, 0);
  266. }
  267. re.putOpt("code", sb.toString());
  268. int nowSecond = DateTime.now().second();
  269. int time = 0;
  270. if (nowSecond < 30) {
  271. time = 30 - nowSecond;
  272. } else {
  273. time = 60 - nowSecond;
  274. }
  275. re.putOpt("time", time);
  276. DoubleVerifyClickRecord doubleVerifyClickRecord = new DoubleVerifyClickRecord();
  277. doubleVerifyClickRecord.setRelationId(relationId);
  278. doubleVerifyClickRecord.setUserId(userId);
  279. doubleVerifyClickRecord.setAccountId(groupsRelationView.getAccountId());
  280. doubleVerifyClickRecord.setAccount(groupsRelationView.getTripsAccount());
  281. doubleVerifyClickRecord.setSkuId(groupsRelationView.getSkuId());
  282. doubleVerifyClickRecord.setCode(sb.toString());
  283. doubleVerifyClickRecord.setRemainTime(time);
  284. doubleVerifyRecordMapper.insert(doubleVerifyClickRecord);
  285. DoubleVerifyDto doubleVerifyDto = new DoubleVerifyDto();
  286. doubleVerifyDto.setClickId(doubleVerifyClickRecord.getId());
  287. doubleVerifyDto.setApiSecret(groupsRelationView.getApiSecret());
  288. redisService.set(String.format("%s-%s", userId, sb.toString()), 0, 60 * 10l);
  289. redisService.set(String.format("%s/%s", userId, sb.toString()), Jsons.toJson(doubleVerifyDto), 60 * 10l);
  290. } catch (Exception e) {
  291. throw BusinessRuntimeException.getInstance("获取双重验证码错误,请联系客服");
  292. }
  293. return GatewayResponse.SUCCESS.newBuilder().toResult(re.toString());
  294. }
  295. /**
  296. * 刷新验证码
  297. */
  298. @GetMapping("/refresh/code")
  299. public Result<String> refreshCode(String code) {
  300. long userId = StpUserUtil.getLoginIdAsLong();
  301. String numKey = String.format("%s-%s", userId, code);
  302. Object num = redisService.get(numKey);
  303. String objKey = String.format("%s/%s", userId, code);
  304. Object objValue = redisService.get(objKey);
  305. if (objValue == null || num == null) {
  306. throw BusinessRuntimeException.getInstance("请重新获取双重验证码");
  307. }
  308. Integer refreshNum = Integer.parseInt(num.toString());
  309. String apiSecret = null;
  310. Long clickId = 0l;
  311. try {
  312. DoubleVerifyDto dto = Jsons.parseObject(objValue.toString(), DoubleVerifyDto.class);
  313. apiSecret = dto.getApiSecret();
  314. clickId = dto.getClickId();
  315. } catch (Exception e) {
  316. apiSecret = objValue.toString();
  317. }
  318. if (refreshNum >= 3) {
  319. redisService.del(numKey);
  320. redisService.del(objKey);
  321. throw BusinessRuntimeException.getInstance("刷新次数已达到3次,请重新获取验证码");
  322. }
  323. if (apiSecret == null) {
  324. throw BusinessRuntimeException.getInstance("请重新获取双重验证码");
  325. }
  326. StringBuilder sb = new StringBuilder();
  327. try {
  328. long c = GoogleGenerator.getCode(apiSecret, DateTime.now().getTime());
  329. sb.append(c);
  330. while (sb.length() < 6) {
  331. sb.insert(0, 0);
  332. }
  333. redisService.incr(numKey, 1l);
  334. } catch (Exception e) {
  335. throw BusinessRuntimeException.getInstance("刷新双重验证码错误,请联系客服");
  336. }
  337. if (clickId != 0) {
  338. int nowSecond = DateTime.now().second();
  339. int time = 0;
  340. if (nowSecond < 30) {
  341. time = 30 - nowSecond;
  342. } else {
  343. time = 60 - nowSecond;
  344. }
  345. //刷新双重验证码记录
  346. DoubleVerifyClickRefreshRecord refreshRecord = new DoubleVerifyClickRefreshRecord();
  347. refreshRecord.setClickId(clickId);
  348. refreshRecord.setUserId(userId);
  349. refreshRecord.setCode(sb.toString());
  350. refreshRecord.setRemainTime(time);
  351. refreshRecordMapper.insert(refreshRecord);
  352. }
  353. return GatewayResponse.SUCCESS.newBuilder().toResult(sb.toString());
  354. }
  355. /**
  356. * 获取双重验证码记录
  357. */
  358. @GetMapping("/get/doubleVerify/codeList")
  359. public Result<List<DoubleVerifyCodeView>> getDoubleVerifyCodeList(Long relationId) {
  360. long userId = StpUserUtil.getLoginIdAsLong();
  361. List<DoubleVerifyCodeView> views = doubleVerifyRecordMapper.getDoubleVerifyCodeList(userId, relationId);
  362. return GatewayResponse.SUCCESS.newBuilder().toResult(views);
  363. }
  364. /**
  365. * 用户是不是自然流量渠道
  366. * 且未回答答题
  367. */
  368. @GetMapping("/natural/channel")
  369. public Result<Boolean> isNaturalChannel() {
  370. long userId = StpUserUtil.getLoginIdAsLong();
  371. String question_key = RedisService.key.QUESTION_RESPONSE_KEY.getNameFormat(userId);
  372. if (redisService.get(question_key) != null) {
  373. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  374. }
  375. User user = userService.getById(userId);
  376. if (user.getPopularizeId() != 0) {
  377. redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
  378. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  379. }
  380. if (user.getPopularizeId() == 0) {
  381. QuestionResponseRecord record = questionResponseRecordMapper.selectOne(Wrappers.lambdaQuery(QuestionResponseRecord.class)
  382. .eq(QuestionResponseRecord::getUserId, userId).select(QuestionResponseRecord::getId).last("limit 1"));
  383. if (record != null) {
  384. redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
  385. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  386. }
  387. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  388. }
  389. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  390. }
  391. /**
  392. * 问卷记录
  393. */
  394. @PostMapping("/record/replyQuestion")
  395. public Result<String> recordReplyQuestion(@RequestBody @Validated QuestionResponseRecord record) {
  396. long userId = StpUserUtil.getLoginIdAsLong();
  397. User user = userService.getById(userId);
  398. String nickname = user.getNickname();
  399. String question_key = RedisService.key.QUESTION_RESPONSE_KEY.getNameFormat(userId);
  400. QuestionResponseRecord dbRecord = questionResponseRecordMapper.selectOne(Wrappers.lambdaQuery(QuestionResponseRecord.class)
  401. .eq(QuestionResponseRecord::getUserId, userId).select(QuestionResponseRecord::getId).last("limit 1"));
  402. if (dbRecord == null) {
  403. if (redisService.setNx(String.format("%s-%s", userId, nickname), userId, 10l)) {
  404. record.setUserId(userId);
  405. record.setNickname(nickname);
  406. questionResponseRecordMapper.insert(record);
  407. //发放优惠券
  408. couponCommonService.sendCouponToUser(userId, 100l, 0l, 0l, 0l, CouponUser.Channel.ques_response);
  409. redisService.set(question_key, userId, RedisService.key.QUESTION_RESPONSE_KEY.getTimeout());
  410. }
  411. }
  412. return GatewayResponse.SUCCESS.newBuilder().toResult();
  413. }
  414. /**
  415. * 获取对应的动态问卷
  416. */
  417. @GetMapping("/get/questionnaire")
  418. public Result<List<QuestionnaireView>> getQuestionnaireView(Long promotionId) {
  419. QuestionnairePromotion promotion = questionnairePromotionMapper.selectById(promotionId);
  420. if (promotion == null || !promotion.getDeleted()) throw BusinessRuntimeException.getInstance("问卷不存在");
  421. Long templateId = promotion.getTemplateId();
  422. List<QuestionnaireView> questionnaireViews = beanSearcher.searchAll(QuestionnaireView.class, MapUtils.builder()
  423. .field(QuestionnaireView::getPromotionId, promotionId)
  424. .orderBy(QuestionnaireView::getSorted).asc()
  425. .orderBy(QuestionnaireView::getFieldsId).asc()
  426. .build());
  427. return GatewayResponse.SUCCESS.newBuilder().toResult(questionnaireViews);
  428. }
  429. /**
  430. * 记录问卷
  431. */
  432. @PostMapping("/record/questionnaire/{promotionId}")
  433. @Transactional(rollbackFor = Exception.class)
  434. @NoSubmit
  435. public Result<String> recordQuestionnaire(@PathVariable Long promotionId, @RequestBody List<FormFieldsData> answers) {
  436. Long groupsId = SEQUENCE.nextId();
  437. List<QuestionnairePromotionFieldsListView> promotionFieldsListViews = beanSearcher.searchAll(QuestionnairePromotionFieldsListView.class, MapUtils.builder().field(QuestionnairePromotionFieldsListView::getPromotionId, promotionId).build());
  438. if (CollUtil.isEmpty(promotionFieldsListViews)) throw BusinessRuntimeException.getInstance("问卷已结束");
  439. if (promotionFieldsListViews.size() != answers.size()) throw BusinessRuntimeException.getInstance("请完成所有问题");
  440. answers.forEach(answer -> {
  441. Long fieldsId = answer.getFieldsId();
  442. String content = answer.getContent();
  443. if (fieldsId == null || StrUtil.isBlank(content)) {
  444. throw BusinessRuntimeException.getInstance("必填项为空");
  445. }
  446. answer.setPromotionId(promotionId);
  447. answer.setGroupsId(groupsId);
  448. formFieldsDataMapper.insert(answer);
  449. });
  450. return GatewayResponse.SUCCESS.newBuilder().toResult();
  451. }
  452. /**
  453. * 对应平台车票 广告配置列表
  454. */
  455. @GetMapping("/get/advertise/{goodsId}")
  456. public Result<List<TicketAdvertiseConfigFrontView>> getTicketAdvertiseConfig(@PathVariable Long goodsId) {
  457. List<TicketAdvertiseConfigFrontView> views = beanSearcher.searchAll(TicketAdvertiseConfigFrontView.class, MapUtils.flatBuilder(request.getParameterMap())
  458. .field(TicketAdvertiseConfig::getGoodsId, goodsId)
  459. .orderBy(TicketAdvertiseConfig::getSorted).desc()
  460. .orderBy(TicketAdvertiseConfig::getId).desc()
  461. .build());
  462. return GatewayResponse.SUCCESS.newBuilder().toResult(views);
  463. }
  464. /**
  465. * 记录用户点击车票广告
  466. */
  467. @PostMapping("/click/ticket/advertise/record/{configId}")
  468. public Result<String> recordClickTicketAdvertise(@PathVariable Long configId) {
  469. long userId = StpUserUtil.getLoginIdAsLong();
  470. ticketAdvertiseConfigClickRecordService.recordUserClickTicketAdvertise(userId, configId);
  471. return GatewayResponse.SUCCESS.newBuilder().toResult();
  472. }
  473. /**
  474. * 推荐平台
  475. */
  476. @GetMapping("/get/recommend/goods")
  477. public Result<Page<UserRecommendGoodsFrontView>> getRecommendGoodsViews(@RequestParam(defaultValue = "0") Integer start, @RequestParam(defaultValue = "5") Integer limit) {
  478. //推荐用户未购买的车票平台 优先展示ai类平台 然后是影视流媒体
  479. long userId = StpUserUtil.getLoginIdAsLong();
  480. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  481. List<Long> filter_goods_id = relationMapper.getTicketGoodsId(userIds, List.of("validity", "overdue", "outside"));
  482. //用户是否购买过奈飞产品
  483. Boolean isPayNf = false;
  484. if (filter_goods_id.contains(1l)) {
  485. isPayNf = true;
  486. } else {
  487. int count = orderDonService.count(Wrappers.lambdaQuery(OrderDon.class)
  488. .eq(OrderDon::getGoodsId, 1)
  489. .eq(OrderDon::getUserId, userId)
  490. .notIn(OrderDon::getStatus, Constant.noOrderAllStatus));
  491. if (count > 0) {
  492. //优先展示路由器、ai、流媒体
  493. isPayNf = true;
  494. }
  495. }
  496. Boolean filterCourseGoods = false;
  497. //GPT Plus基础2月 课程不展示
  498. Integer orders = orderDonMapper.selectCount(Wrappers.lambdaQuery(OrderDon.class)
  499. .in(OrderDon::getUserId, userIds)
  500. .eq(OrderDon::getSkuId, 444)
  501. .notIn(OrderDon::getStatus, Constant.noOrderStatus));
  502. if (orders > 0) {
  503. filterCourseGoods = true;
  504. }
  505. Page<UserRecommendGoodsFrontView> page = groupRelationFrontService.getRecommendGoodsViews(isPayNf, filter_goods_id, filterCourseGoods, start, limit);
  506. return GatewayResponse.SUCCESS.newBuilder().toResult(page);
  507. }
  508. /**
  509. * 查看GPT token
  510. */
  511. @GetMapping("/get/gptAccessToken")
  512. public Result<String> getGptAccessToken(Long relationId) throws Exception {
  513. long userId = StpUserUtil.getLoginIdAsLong();
  514. List<Long> userIds = userBindRelationService.getRelationUserIdList(userId, null);
  515. //存在该车票
  516. RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
  517. .field(RenewalView::getRelationId, relationId)
  518. .field(RenewalView::getUserId, userIds).op(Operator.InList).build());
  519. Assert.notNull(renewalView, "您的车票不存在");
  520. if (renewalView.getGoodsId() != 42) {
  521. throw BusinessRuntimeException.getInstance("该平台类型车票无法获取GPT直连token");
  522. }
  523. String account = renewalView.getAccount();
  524. String accessToken = chatGptAuthService.getAccessToken(account);
  525. return GatewayResponse.SUCCESS.newBuilder().toResult(accessToken);
  526. }
  527. /**
  528. * 获取特殊类型课程 通过邮件发送课程
  529. * 领取课件
  530. */
  531. @PostMapping("/courseware")
  532. public Result<String> getCourseWare(@RequestBody SpecialGoodsTicketReq request) throws Exception {
  533. long userId = StpUserUtil.getLoginIdAsLong();
  534. request.setUserId(userId);
  535. groupRelationFrontService.sendCourseWare(request);
  536. return GatewayResponse.SUCCESS.newBuilder().toResult();
  537. }
  538. //获取课程云盘链接
  539. @GetMapping("/get/courseware")
  540. public Result<GoodsCoursewareFile> getGoodsCourseware(Long relationId) {
  541. long userId = StpUserUtil.getLoginIdAsLong();
  542. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  543. RenewalView relationView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
  544. .field(RenewalView::getUserId, userIdList).op(Operator.InList)
  545. .field(RenewalView::getRelationId, relationId).build());
  546. if (relationView == null) {
  547. throw BusinessRuntimeException.getInstance("您的车票不存在");
  548. }
  549. GoodsCoursewareFile goodsCoursewareFile = goodsCoursewareFileMapper.selectOne(Wrappers.lambdaQuery(GoodsCoursewareFile.class)
  550. .eq(GoodsCoursewareFile::getGoodsId, relationView.getGoodsId())
  551. .eq(GoodsCoursewareFile::getStatus, true)
  552. .select(GoodsCoursewareFile::getLink, GoodsCoursewareFile::getCode)
  553. .last("limit 1"));
  554. if (goodsCoursewareFile == null) {
  555. throw BusinessRuntimeException.getInstance("暂未配置课件链接地址,请联系客服");
  556. }
  557. return GatewayResponse.SUCCESS.newBuilder().toResult(goodsCoursewareFile);
  558. }
  559. /**
  560. * 读取车票账号登录验证码
  561. */
  562. @PostMapping("/get/verifyCode")
  563. public Result<String> getAiVerifyCode(@RequestBody @Validated TicketLoginReq loginReq) throws Exception {
  564. long userId = StpUserUtil.getLoginIdAsLong();
  565. loginReq.setUserId(userId);
  566. return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.getAiVerifyCode(loginReq));
  567. }
  568. /**
  569. * 车票后台登录
  570. */
  571. @PostMapping("/ticket/login")
  572. public Result<GroupsRelation> ticketLogin(@RequestBody @Validated TicketLoginReq loginReq) {
  573. GroupsRelation relation = groupRelationFrontService.ticketLogin(loginReq);
  574. return GatewayResponse.SUCCESS.newBuilder().toResult(relation);
  575. }
  576. /**
  577. * 奈飞验证校验
  578. */
  579. @PostMapping("/ticket/verify")
  580. public Result<String> outsideTicketVerify(@RequestBody @Validated TicketLoginReq loginReq) {
  581. return GatewayResponse.SUCCESS.newBuilder().toResult(groupRelationFrontService.outsideTicketVerify(loginReq));
  582. }
  583. /**
  584. * 是否有mid车票可候补
  585. */
  586. @GetMapping("/get/standby")
  587. public Result<GptStandbyResp> getGptStandby() {
  588. long userId = StpUserUtil.getLoginIdAsLong();
  589. List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
  590. 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))";
  591. List<RenewalView> renewalViewList = beanSearcher.searchAll(RenewalView.class, MapUtils.builder()
  592. .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
  593. .field(RenewalView::getGoodsId, 26)
  594. .put("condition", condition)
  595. .field(RenewalView::getExpiryTime).op(Operator.NotNull)
  596. .onlySelect(RenewalView::getAccount, RenewalView::getExpiryTime)
  597. .build());
  598. GptStandbyResp gptStandbyResp = new GptStandbyResp();
  599. if (renewalViewList.isEmpty()) {
  600. gptStandbyResp.setIsHasAccount(false);
  601. return GatewayResponse.SUCCESS.newBuilder().toResult(gptStandbyResp);
  602. }
  603. List<RenewalView> overTen = new ArrayList<>();
  604. List<RenewalView> underTen = new ArrayList<>();
  605. DateTime now = DateTime.now();
  606. renewalViewList.forEach(e -> {
  607. if (e.getExpiryTime().compareTo(DateUtil.offsetDay(now, 10)) > 0) {
  608. overTen.add(e);
  609. } else underTen.add(e);
  610. });
  611. Integer accountBlockedCount = 1;
  612. if (overTen.size() > 1) {
  613. List<String> accountList = overTen.stream().map(RenewalView::getAccount).distinct().collect(Collectors.toList());
  614. accountBlockedCount = accountBlockedReplaceRecordMapper.selectCount(Wrappers.lambdaQuery(AccountBlockedReplaceRecord.class)
  615. .eq(AccountBlockedReplaceRecord::getGoodsId, 26)
  616. .in(AccountBlockedReplaceRecord::getAccount, accountList));
  617. }
  618. if (accountBlockedCount > 1) {
  619. gptStandbyResp.setIsHasAccount(false);
  620. return GatewayResponse.SUCCESS.newBuilder().toResult(gptStandbyResp);
  621. }
  622. gptStandbyResp.setIsHasAccount(true);
  623. gptStandbyResp.setOverTen(overTen);
  624. gptStandbyResp.setUnderTen(underTen);
  625. Integer count = gptTicketStandbyMapper.selectCount(Wrappers.lambdaQuery(GptTicketStandby.class)
  626. .in(GptTicketStandby::getUserId, relationUserIdList));
  627. gptStandbyResp.setIsApply(count > 0 ? true : false);
  628. return GatewayResponse.SUCCESS.newBuilder().toResult(gptStandbyResp);
  629. }
  630. /**
  631. * 申请候补
  632. */
  633. @PostMapping("/apply/standby")
  634. @NoSubmit
  635. public Result<Boolean> applyGptStandby() {
  636. long userId = StpUserUtil.getLoginIdAsLong();
  637. List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
  638. 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))";
  639. List<RenewalView> renewalViewList = beanSearcher.searchAll(RenewalView.class, MapUtils.builder()
  640. .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
  641. .field(RenewalView::getGoodsId, 26)
  642. .put("condition", condition)
  643. .field(RenewalView::getExpiryTime, DateUtil.offsetDay(DateTime.now(), 10)).op(Operator.GreaterThan)
  644. .onlySelect(RenewalView::getAccount)
  645. .build());
  646. if (renewalViewList.isEmpty()) {
  647. throw BusinessRuntimeException.getInstance("你未有车票账号");
  648. }
  649. Integer count = gptTicketStandbyMapper.selectCount(Wrappers.lambdaQuery(GptTicketStandby.class)
  650. .in(GptTicketStandby::getUserId, relationUserIdList));
  651. if (count > 0) {
  652. throw BusinessRuntimeException.getInstance("你已申请车票账号候补");
  653. }
  654. if (renewalViewList.size() > 1) {
  655. Set<String> accountSet = renewalViewList.stream().map(RenewalView::getAccount).collect(Collectors.toSet());
  656. Integer accountBlockedCount = accountBlockedReplaceRecordMapper.selectCount(Wrappers.lambdaQuery(AccountBlockedReplaceRecord.class)
  657. .eq(AccountBlockedReplaceRecord::getGoodsId, 26)
  658. .in(AccountBlockedReplaceRecord::getAccount, accountSet));
  659. if (accountBlockedCount > 1) {
  660. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  661. }
  662. }
  663. GptTicketStandby gptTicketStandby = new GptTicketStandby();
  664. gptTicketStandby.setUserId(userId);
  665. gptTicketStandbyMapper.insert(gptTicketStandby);
  666. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  667. }
  668. /**
  669. * midjourney车票退款
  670. */
  671. @PutMapping("/refund/ticketOrder/{relationId}")
  672. @NoSubmit
  673. public Result<String> ticketRefundOrders(@PathVariable Long relationId) throws Exception {
  674. long userId = StpUserUtil.getLoginIdAsLong();
  675. List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
  676. 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))";
  677. RenewalView renewalView = beanSearcher.searchFirst(RenewalView.class, MapUtils.builder()
  678. .field(RenewalView::getRelationId, relationId)
  679. .field(RenewalView::getUserId, relationUserIdList).op(Operator.InList)
  680. .put("condition", condition)
  681. .field(RenewalView::getGoodsId, 26)
  682. .field(RenewalView::getExpiryTime, DateUtil.offsetDay(DateTime.now(), 10)).op(Operator.LessEqual)
  683. .build());
  684. if (renewalView == null) {
  685. throw BusinessRuntimeException.getInstance("你车票不存在或不符合退款要求");
  686. }
  687. OrderDon orderDon = orderDonService.getOne(Wrappers.lambdaQuery(OrderDon.class)
  688. .in(OrderDon::getUserId, relationUserIdList)
  689. .eq(OrderDon::getRelationId, relationId)
  690. .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
  691. .orderByDesc(OrderDon::getId)
  692. .last("limit 1"));
  693. if (orderDon == null) {
  694. throw BusinessRuntimeException.getInstance("你对应车票的订单不存在");
  695. }
  696. GoodsDonSku sku = goodsDonSkuMapper.selectById(orderDon.getSkuId());
  697. if (sku == null) {
  698. throw BusinessRuntimeException.getInstance("该车票规格不存在,请联系客服进行人工退款..");
  699. }
  700. Date expiryTime = renewalView.getExpiryTime();
  701. long remainDay = DateUtil.between(DateTime.now(), expiryTime, DateUnit.DAY) + 1;
  702. BigDecimal money = orderDon.getMoney();
  703. BigDecimal refundMoney = null;
  704. BigDecimal refundBalance= null;
  705. String refundType = null;
  706. if (money.compareTo(BigDecimal.ZERO) > 0) {
  707. BigDecimal dayMoney = money.divide(BigDecimal.valueOf(sku.getMonths()).multiply(BigDecimal.valueOf(30)), 2, RoundingMode.HALF_DOWN);
  708. refundMoney = BigDecimal.valueOf(remainDay).multiply(dayMoney);
  709. refundType = "money";
  710. }
  711. OrderRefundReq refundReq = new OrderRefundReq();
  712. if (orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
  713. BigDecimal dayMoney = orderDon.getBalance().divide(BigDecimal.valueOf(sku.getMonths()).multiply(BigDecimal.valueOf(30)), 2, RoundingMode.HALF_DOWN);
  714. refundBalance = BigDecimal.valueOf(remainDay).multiply(dayMoney);
  715. refundReq.setIsOnly(true);
  716. }
  717. refundReq.setOrderId(orderDon.getId());
  718. refundReq.setRefundDesc("失效车票退款");
  719. refundReq.setRefundMoney(Optional.ofNullable(refundMoney).orElse(BigDecimal.ZERO));
  720. refundReq.setRefundBalance(Optional.ofNullable(refundBalance).orElse(BigDecimal.ZERO));
  721. refundReq.setRefundType(Optional.ofNullable(refundType).orElse("balance"));
  722. cmsOrderDonService.unifiedRefund(refundReq);
  723. return GatewayResponse.SUCCESS.newBuilder().toResult();
  724. }
  725. /**
  726. * 每日车票到期弹窗
  727. */
  728. @GetMapping("/get/expiry/notify")
  729. public Result<List<RenewalView>> getExpiryRenewalNotify() {
  730. Long userId = StpUserUtil.getLoginIdAsLong();
  731. List<RenewalView> expiryRenewals = groupRelationFrontService.getExpiryRenewalNotify(userId);
  732. return GatewayResponse.SUCCESS.newBuilder().toResult(expiryRenewals);
  733. }
  734. /**
  735. * 车票详情
  736. */
  737. @GetMapping("/get/detail")
  738. public Result<RenewalView> getTicketDetail(Long relationId) {
  739. if (relationId == null) {
  740. return GatewayResponse.SUCCESS.newBuilder().toResult();
  741. }
  742. long userId = StpUserUtil.getLoginIdAsLong();
  743. RenewalView ticketDetail = groupRelationFrontService.getTicketDetail(userId, relationId);
  744. return GatewayResponse.SUCCESS.newBuilder().toResult(ticketDetail);
  745. }
  746. /**
  747. * 车票售后常见问题
  748. */
  749. @GetMapping("/get/questions/{goodsId}")
  750. public Result<List<GoodsDonQaFrontView>> getTicketQuestions(@PathVariable Long goodsId, @RequestParam(defaultValue = "1") Integer type) {
  751. if (type < 1 || type > 2) {
  752. return GatewayResponse.SUCCESS.newBuilder().toResult();
  753. }
  754. String key = RedisService.key.YH_GOODS_QUESTIONS_DETAIL.getNameFormat(type, goodsId);
  755. Object o = redisService.get(key);
  756. if (o == null) {
  757. List<GoodsDonQaFrontView> donQaFrontViews = beanSearcher.searchAll(GoodsDonQaFrontView.class, MapUtils.builder().field(GoodsDonQaFrontView::getGoodsId, goodsId).field(GoodsDonQaFrontView::getType, type).build());
  758. if (CollUtil.isEmpty(donQaFrontViews)) {
  759. return GatewayResponse.SUCCESS.newBuilder().toResult();
  760. }
  761. redisService.setNx(key, donQaFrontViews, RedisService.key.YH_GOODS_QUESTIONS_DETAIL.getTimeout());
  762. o = redisService.get(key);
  763. }
  764. List<GoodsDonQaFrontView> donQaFrontViews = Jsons.parseList(o, GoodsDonQaFrontView.class);
  765. return GatewayResponse.SUCCESS.newBuilder().toResult(donQaFrontViews);
  766. }
  767. /**
  768. * 是否首次购买车票
  769. */
  770. @GetMapping("/get/first/pay/{goodsId}")
  771. public Result<Boolean> getFirstPay(@PathVariable Long goodsId) {
  772. long userId = StpUserUtil.getLoginIdAsLong();
  773. List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
  774. Number number = beanSearcher.searchCount(OrderDon.class, MapUtils.builder()
  775. .field(OrderDon::getGoodsId, goodsId)
  776. .field(OrderDon::getCreatedTime, new DateTime().toDateStr()).op(Operator.LessEqual)
  777. .field(OrderDon::getUserId, userIdList).op(Operator.InList)
  778. .field(OrderDon::getStatus, Constant.noOrderStatus).op(Operator.NotIn)
  779. .build());
  780. if (number.intValue() == 0) {
  781. UserGoodsNewbieGuideRecord userGoodsNewbieGuideRecord = new UserGoodsNewbieGuideRecord();
  782. userGoodsNewbieGuideRecord.setGoodsId(goodsId);
  783. userGoodsNewbieGuideRecord.setUserId(userId);
  784. userGoodsNewbieGuideRecordMapper.insert(userGoodsNewbieGuideRecord);
  785. return GatewayResponse.SUCCESS.newBuilder().toResult(true);
  786. }
  787. return GatewayResponse.SUCCESS.newBuilder().toResult(false);
  788. }
  789. /**
  790. * 设置pin码
  791. */
  792. @PutMapping("/set/pin/{relationId}")
  793. public Result<String> setPin(@PathVariable Long relationId, String code) {
  794. long userId = StpUserUtil.getLoginIdAsLong();
  795. JSONObject data = groupsRelationNetflixService.setNetflixPin(relationId, userId, code);
  796. return GatewayResponse.SUCCESS.newBuilder().toResult(data.toString());
  797. }
  798. /**
  799. * 查询是否设置成功
  800. */
  801. @GetMapping("/get/pin/status/{taskId}")
  802. public Result<Integer> getPinStatus(@PathVariable String taskId) throws Exception {
  803. return GatewayResponse.SUCCESS.newBuilder().toResult(groupsRelationNetflixService.getPinStatus(taskId));
  804. }
  805. }