| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.competition.entity.Competition; |
| | | import com.dsh.competition.entity.Participant; |
| | | import com.dsh.competition.entity.PaymentCompetition; |
| | | import com.dsh.competition.entity.UserCompetition; |
| | | import com.dsh.competition.feignclient.other.StoreClient; |
| | |
| | | import com.dsh.competition.model.CompetitionListVo; |
| | | import com.dsh.competition.model.ParticipantVo; |
| | | import com.dsh.competition.service.CompetitionService; |
| | | import com.dsh.competition.service.IParticipantService; |
| | | import com.dsh.competition.service.IPaymentCompetitionService; |
| | | import com.dsh.competition.service.UserCompetitionService; |
| | | import com.dsh.competition.util.GeodesyUtil; |
| | | import com.dsh.competition.util.ToolUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Autowired |
| | | private UserCompetitionService userCompetitionService; |
| | | |
| | | @Autowired |
| | | private IParticipantService participantService; |
| | | |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public CompetitionInfo queryCompetitionInfo(Integer uid, Integer id) throws Exception { |
| | | public CompetitionInfo queryCompetitionInfo(Integer uid, Integer id, String lon, String lat) throws Exception { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Competition competition = this.getById(id); |
| | | CompetitionInfo competitionInfo = new CompetitionInfo(); |
| | |
| | | competitionInfo.setStoreAddress(store.getAddress()); |
| | | competitionInfo.setStoreLon(store.getLon()); |
| | | competitionInfo.setStoreLat(store.getLat()); |
| | | competitionInfo.setStoreCoverDrawing(store.getCoverDrawing()); |
| | | if(ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)){ |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat()); |
| | | double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | competitionInfo.setDistance(wgs84); |
| | | } |
| | | competitionInfo.setRegisterEndTime(sdf.format(competition.getRegisterEndTime())); |
| | | competitionInfo.setStartTime(sdf.format(competition.getStartTime())); |
| | | competitionInfo.setEndTime(sdf.format(competition.getEndTime())); |
| | |
| | | if(null != one){ |
| | | competitionInfo.setApply(1); |
| | | List<ParticipantVo> participant = new ArrayList<>(); |
| | | // userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("competitionId", id).eq("")) |
| | | List<UserCompetition> list = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("competitionId", id).eq("appUserId", uid)); |
| | | List<Integer> collect = list.stream().map(UserCompetition::getParticipantId).collect(Collectors.toList()); |
| | | List<Participant> participants = participantService.listByIds(collect); |
| | | SimpleDateFormat sdf_year = new SimpleDateFormat("yyyy"); |
| | | for (Participant participant1 : participants) { |
| | | ParticipantVo participantVo = new ParticipantVo(); |
| | | participantVo.setId(participant1.getId()); |
| | | participantVo.setName(participant1.getName()); |
| | | participantVo.setIdcard(participant1.getIdcard()); |
| | | Integer age = Integer.valueOf(sdf_year.format(new Date())) - Integer.valueOf(sdf_year.format(participant1.getBirthday())); |
| | | participantVo.setAge(age); |
| | | participant.add(participantVo); |
| | | } |
| | | competitionInfo.setParticipant(participant); |
| | | } |
| | | |
| | | |
| | | |
| | | return null; |
| | | return competitionInfo; |
| | | } |
| | | } |