| | |
| | | import com.dsh.communityWorldCup.entity.WorldCup; |
| | | import com.dsh.communityWorldCup.entity.WorldCupPayment; |
| | | import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant; |
| | | import com.dsh.communityWorldCup.entity.WorldCupStore; |
| | | import com.dsh.communityWorldCup.feignclient.account.StudentClient; |
| | | import com.dsh.communityWorldCup.feignclient.account.model.TStudent; |
| | | import com.dsh.communityWorldCup.feignclient.competition.ParticipantClient; |
| | | import com.dsh.communityWorldCup.feignclient.competition.model.Participant; |
| | | import com.dsh.communityWorldCup.feignclient.other.StoreClient; |
| | | import com.dsh.communityWorldCup.feignclient.other.model.Store; |
| | | import com.dsh.communityWorldCup.mapper.WorldCupPaymentParticipantMapper; |
| | | import com.dsh.communityWorldCup.model.MyWorldCupInfo; |
| | | import com.dsh.communityWorldCup.model.MyWorldCupList; |
| | |
| | | import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService; |
| | | import com.dsh.communityWorldCup.service.IWorldCupPaymentService; |
| | | import com.dsh.communityWorldCup.service.IWorldCupService; |
| | | import com.dsh.communityWorldCup.service.IWorldCupStoreService; |
| | | import com.dsh.communityWorldCup.util.GeodesyUtil; |
| | | import com.dsh.communityWorldCup.util.ToolUtil; |
| | | import org.springframework.beans.BeanUtils; |
| | | 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.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | @Autowired |
| | | private IWorldCupService worldCupService; |
| | | |
| | | @Autowired |
| | | private IWorldCupPaymentParticipantService worldCupPaymentParticipantService; |
| | | |
| | | @Autowired |
| | | private IWorldCupStoreService worldCupStoreService; |
| | | |
| | | @Resource |
| | | private StoreClient storeClient; |
| | | |
| | | |
| | | |
| | |
| | | int pageNo = (myWorldCupList.getPageNo() - 1) * myWorldCupList.getPageSize(); |
| | | myWorldCupList.setPageNo(pageNo); |
| | | myWorldCupList.setIsStudent(myWorldCupList.getIsStudent() == 0 ? 2 : 1); |
| | | return this.baseMapper.getMyWorldCupList(myWorldCupList); |
| | | List<WorldCupListVo> myWorldCupList1 = this.baseMapper.getMyWorldCupList(myWorldCupList); |
| | | for (WorldCupListVo worldCupListVo : myWorldCupList1) { |
| | | Integer worldCupId = worldCupListVo.getWorldCupId(); |
| | | List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("worldCupId", worldCupId).eq("payStatus", 2).eq("state", 1)); |
| | | List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList()); |
| | | Integer heat = worldCupListVo.getHeat(); |
| | | if(collect.size() > 0){ |
| | | int count = worldCupPaymentParticipantService.count(new QueryWrapper<WorldCupPaymentParticipant>().in("worldCupPaymentId", collect)); |
| | | heat += count; |
| | | } |
| | | worldCupListVo.setHeat(heat); |
| | | } |
| | | return myWorldCupList1; |
| | | } |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public MyWorldCupInfo getMyWorldCupInfo(String id) { |
| | | public MyWorldCupInfo getMyWorldCupInfo(String id, String lon, String lat) { |
| | | WorldCupPaymentParticipant worldCupPaymentParticipant = this.getById(id); |
| | | Integer worldCupId = worldCupPaymentParticipant.getWorldCupId(); |
| | | WorldCupPayment worldCupPayment = worldCupPaymentService.getById(worldCupPaymentParticipant.getWorldCupPaymentId()); |
| | |
| | | myWorldCupInfo.setExpense(worldCupPayment.getAmount().doubleValue()); |
| | | myWorldCupInfo.setStatus(worldCup.getStatus()); |
| | | myWorldCupInfo.setRevocable(1); |
| | | myWorldCupInfo.setProvince(worldCup.getProvince()); |
| | | myWorldCupInfo.setCity(worldCup.getCity()); |
| | | myWorldCupInfo.setPayType(worldCupPayment.getPayType()); |
| | | //开始前一天不能取消 |
| | | if(worldCup.getStartTime().getTime() < System.currentTimeMillis() + 86400000L){ |
| | | myWorldCupInfo.setRevocable(0); |
| | |
| | | } |
| | | |
| | | myWorldCupInfo.setParticipants(datas); |
| | | List<WorldCupStore> worldCupStores = worldCupStoreService.list(new QueryWrapper<WorldCupStore>().eq("worldCupId", id)); |
| | | ArrayList<Map<String, Object>> objects = new ArrayList<>(); |
| | | for (WorldCupStore worldCupStore : worldCupStores) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | Store store = storeClient.queryStoreById(worldCupStore.getStoreId()); |
| | | map.put("name", store.getName()); |
| | | |
| | | |
| | | String str = store.getAddress(); |
| | | str = str.substring(str.indexOf("省") + 1); |
| | | |
| | | // 去掉第一个“市”及之前的字符串 |
| | | str = str.substring(str.indexOf("市") + 1); |
| | | |
| | | // 去掉第一个“区”及之前的字符串 |
| | | str = str.substring(str.indexOf("区") + 1); |
| | | |
| | | map.put("address", str); |
| | | map.put("storeLon", store.getLon()); |
| | | map.put("storeLat", store.getLat()); |
| | | map.put("storeCoverDrawing", 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(); |
| | | map.put("distance", wgs84); |
| | | } |
| | | objects.add(map); |
| | | } |
| | | worldCupInfo.setStoreInfos(objects); |
| | | return myWorldCupInfo; |
| | | } |
| | | |