| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- package com.cyksj.web.controller.group;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.cyksj.common.constant.Constant;
- import com.cyksj.common.exception.BusinessRuntimeException;
- import com.cyksj.dto.Result;
- import com.cyksj.enums.GatewayResponse;
- import com.cyksj.mapper.GroupsRelationMapper;
- import com.cyksj.model.entity.GroupsRelation;
- import com.cyksj.model.entity.OrderDon;
- import com.cyksj.model.request.OrderPayRequest;
- import com.cyksj.model.views.RenewalView;
- import com.cyksj.service.corp.CorpService;
- import com.cyksj.service.order.OrderDonService;
- import com.cyksj.service.relation.GroupRelationFrontService;
- import com.cyksj.web.util.StpUserUtil;
- import com.ejlchina.searcher.BeanSearcher;
- import lombok.RequiredArgsConstructor;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * @author chan
- * @date 2022/9/27 11:48 AM
- */
- @Slf4j
- @RequiredArgsConstructor
- @RestController
- @RequestMapping("/applets/group/relation")
- public class GroupRelationController {
- private final BeanSearcher beanSearcher;
- private final OrderDonService orderDonService;
- private final GroupsRelationMapper relationMapper;
- private final GroupRelationFrontService groupRelationFrontService;
- private final CorpService corpService;
- @RequestMapping("/get/renewal")
- public Result<List<RenewalView>> get(Boolean isLoginPopularize) {
- long userId = StpUserUtil.getLoginIdAsLong();
- List<RenewalView> list = groupRelationFrontService.getMyTicket(userId, isLoginPopularize);
- list.forEach(data->{
- if (data.getGoodsId() == 1) {
- OrderDon last = orderDonService.getOne(Wrappers.lambdaQuery(OrderDon.class)
- .eq(OrderDon::getGoodsId, 1)
- .notIn(OrderDon::getStatus, Constant.noOrderAllStatus)
- .orderByAsc(OrderDon::getId)
- .select(OrderDon::getCreatedTime)
- .last("limit 1"));
- if (last != null) {
- data.setLastTime(last.getCreatedTime());
- }
- }
- });
- return GatewayResponse.SUCCESS.newBuilder().toResult(list);
- }
- @PostMapping("/post/renewal")
- public Result<OrderDon> renewal(@RequestBody OrderPayRequest request) throws Exception {
- long userId = StpUserUtil.getLoginIdAsLong();
- request.setUserId(userId);
- OrderDon orderDon = orderDonService.renewal(request);
- return GatewayResponse.SUCCESS.newBuilder().toResult(orderDon);
- }
- @PutMapping("/update/set/account")
- public Result<String> setAccount(@RequestBody GroupsRelation relation) {
- long userId = StpUserUtil.getLoginIdAsLong();
- GroupsRelation re = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getId, relation.getId()).eq(GroupsRelation::getUserId, userId).last(" limit 1"));
- if (re == null) {
- throw new BusinessRuntimeException("该车票不存在,请联系客服.");
- }
- relationMapper.update(relation, Wrappers.lambdaUpdate(GroupsRelation.class).set(GroupsRelation::getAccount, relation.getAccount()).eq(GroupsRelation::getId, relation.getId()));
- return GatewayResponse.SUCCESS.newBuilder().toResult();
- }
- /**
- * 查询是否加入了企业微信
- */
- @GetMapping("/check/joinCorpWx")
- public Result<Boolean> isJoinCorpWx() {
- long userId = StpUserUtil.getLoginIdAsLong();
- Boolean flag = corpService.isJoinCorpWx(userId, false);
- return GatewayResponse.SUCCESS.newBuilder().toResult(flag);
- }
- }
|