|
|
@@ -1,33 +1,19 @@
|
|
|
package com.izouma.ticketExchange.service;
|
|
|
|
|
|
-import com.google.gson.Gson;
|
|
|
-import com.izouma.ticketExchange.domain.Cinema;
|
|
|
-import com.izouma.ticketExchange.domain.Location;
|
|
|
-import com.izouma.ticketExchange.domain.Schedule;
|
|
|
-import com.izouma.ticketExchange.domain.Show;
|
|
|
import com.izouma.ticketExchange.exception.BusinessException;
|
|
|
-import com.izouma.ticketExchange.repo.CinemaRepo;
|
|
|
-import com.izouma.ticketExchange.repo.LocationRepo;
|
|
|
-import com.izouma.ticketExchange.repo.ScheduleRepo;
|
|
|
-import com.izouma.ticketExchange.repo.ShowRepo;
|
|
|
-import com.izouma.ticketExchange.utils.DateTimeUtils;
|
|
|
import com.taobao.api.TaobaoClient;
|
|
|
import com.taobao.api.request.*;
|
|
|
import com.taobao.api.response.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
-import org.springframework.cache.annotation.Cacheable;
|
|
|
-import org.springframework.remoting.RemoteAccessException;
|
|
|
import org.springframework.retry.annotation.Backoff;
|
|
|
import org.springframework.retry.annotation.Retryable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@@ -37,17 +23,10 @@ public class TppService {
|
|
|
private Long tbUserId;
|
|
|
@Autowired
|
|
|
private TaobaoClient client;
|
|
|
- @Autowired
|
|
|
- private LocationRepo locationRepo;
|
|
|
- @Autowired
|
|
|
- private ShowRepo showRepo;
|
|
|
- @Autowired
|
|
|
- private CinemaRepo cinemaRepo;
|
|
|
- @Autowired
|
|
|
- private ScheduleRepo scheduleRepo;
|
|
|
|
|
|
@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 500, maxDelay = 3000))
|
|
|
public List<FilmDataThirdPartyRegionsGetResponse.Region> getLocations() {
|
|
|
+ log.info("获取城市列表");
|
|
|
FilmDataThirdPartyRegionsGetRequest req = new FilmDataThirdPartyRegionsGetRequest();
|
|
|
req.setUserId(tbUserId);
|
|
|
req.setPlatform(platform);
|
|
|
@@ -55,6 +34,7 @@ public class TppService {
|
|
|
try {
|
|
|
rsp = client.execute(req);
|
|
|
if (rsp.getResult() != null && rsp.getResult().getReturnCode().equals("0")) {
|
|
|
+ log.info("获取城市列表成功");
|
|
|
return rsp.getResult().getReturnValue().getRegions();
|
|
|
}
|
|
|
log.error("获取城市列表失败\n\t{}", rsp.getBody());
|
|
|
@@ -76,6 +56,7 @@ public class TppService {
|
|
|
try {
|
|
|
rsp = client.execute(req);
|
|
|
if (rsp.getResult() != null && rsp.getResult().getReturnCode().equals("0")) {
|
|
|
+ log.info("获取即将上映影片成功");
|
|
|
return rsp.getResult().getReturnValue().getSoonShows();
|
|
|
}
|
|
|
log.error("获取即将上映影片失败\n\t{}", rsp.getBody());
|
|
|
@@ -87,6 +68,7 @@ public class TppService {
|
|
|
|
|
|
@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 500, maxDelay = 3000))
|
|
|
public List<FilmDataThirdPartyHotshowsGetResponse.Show> getHotShows(Long cityCode) {
|
|
|
+ log.info("获取热映影片 {}", cityCode);
|
|
|
FilmDataThirdPartyHotshowsGetRequest req = new FilmDataThirdPartyHotshowsGetRequest();
|
|
|
req.setUserId(tbUserId);
|
|
|
req.setCityCode(cityCode);
|
|
|
@@ -96,6 +78,7 @@ public class TppService {
|
|
|
try {
|
|
|
rsp = client.execute(req);
|
|
|
if (rsp.getResult() != null && rsp.getResult().getReturnCode().equals("0")) {
|
|
|
+ log.info("获取热映影片成功");
|
|
|
return rsp.getResult().getReturnValue().getHotShows();
|
|
|
}
|
|
|
log.error("获取热映影片失败\n\t{}", rsp.getBody());
|
|
|
@@ -106,9 +89,9 @@ public class TppService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 500, maxDelay = 3000))
|
|
|
public List<FilmDataThirdPartyCinemasGetResponse.MtopCinema> getCinemas(Integer page) {
|
|
|
+ log.info("获取影院 page: {}", page);
|
|
|
FilmDataThirdPartyCinemasGetRequest req = new FilmDataThirdPartyCinemasGetRequest();
|
|
|
req.setUserId(tbUserId);
|
|
|
req.setPlatform(platform);
|
|
|
@@ -130,6 +113,7 @@ public class TppService {
|
|
|
if (rsp.getResult().getReturnValue().getTotalCount() > page) {
|
|
|
getCinemas(page + 1);
|
|
|
}
|
|
|
+ log.info("获取影院成功");
|
|
|
return list;
|
|
|
}
|
|
|
log.error("获取影院失败\n\t{}", rsp.getBody());
|
|
|
@@ -141,6 +125,7 @@ public class TppService {
|
|
|
|
|
|
@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 500, maxDelay = 3000))
|
|
|
public List<FilmDataThirdPartySchedulesGetResponse.Schedule> getSchedules(Long cinemaId) {
|
|
|
+ log.info("获取影院 {}", cinemaId);
|
|
|
FilmDataThirdPartySchedulesGetRequest req = new FilmDataThirdPartySchedulesGetRequest();
|
|
|
req.setUserId(tbUserId);
|
|
|
req.setCinemaId(cinemaId);
|
|
|
@@ -150,6 +135,7 @@ public class TppService {
|
|
|
try {
|
|
|
rsp = client.execute(req);
|
|
|
if (rsp.getResult() != null && rsp.getResult().getReturnCode().equals("0")) {
|
|
|
+ log.info("获取影院成功");
|
|
|
return rsp.getResult().getReturnValue().getSchedules();
|
|
|
}
|
|
|
log.error("获取排片失败\n\t{}", rsp.getBody());
|
|
|
@@ -161,6 +147,7 @@ public class TppService {
|
|
|
|
|
|
@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 500, maxDelay = 3000))
|
|
|
public FilmDataThirdPartySeatMapResponse.TopSeatMap getSeatMap(Long scheduleId) {
|
|
|
+ log.info("获取座位图 {}", scheduleId);
|
|
|
FilmDataThirdPartySeatMapRequest req = new FilmDataThirdPartySeatMapRequest();
|
|
|
req.setPlatform(platform);
|
|
|
req.setParamsString("{}");
|
|
|
@@ -170,6 +157,7 @@ public class TppService {
|
|
|
try {
|
|
|
rsp = client.execute(req);
|
|
|
if (rsp.getResult() != null && rsp.getResult().getReturnCode().equals("0")) {
|
|
|
+ log.info("获取座位图成功");
|
|
|
return rsp.getResult().getReturnValue();
|
|
|
}
|
|
|
log.error("获取座位图失败\n\t{}", rsp.getBody());
|
|
|
@@ -180,6 +168,7 @@ public class TppService {
|
|
|
}
|
|
|
|
|
|
public FilmDataThirdPartyLockSeatResponse.SeatLocked lockSeat(Long scheduleId, String seatIds, String seatNames, String mobile, Long userId) {
|
|
|
+ log.info("锁座");
|
|
|
FilmDataThirdPartyLockSeatRequest req = new FilmDataThirdPartyLockSeatRequest();
|
|
|
req.setUserId(tbUserId);
|
|
|
req.setPlatform(platform);
|
|
|
@@ -193,6 +182,7 @@ public class TppService {
|
|
|
try {
|
|
|
rsp = client.execute(req);
|
|
|
if (rsp.getResult() != null && rsp.getResult().getReturnCode().equals("0")) {
|
|
|
+ log.info("锁座成功");
|
|
|
return rsp.getResult().getReturnValue();
|
|
|
}
|
|
|
log.error("锁座失败\n\t{}", rsp.getBody());
|
|
|
@@ -203,6 +193,7 @@ public class TppService {
|
|
|
}
|
|
|
|
|
|
public void unlockSeat(String applyKey, Long userId) {
|
|
|
+ log.info("解锁 {}", applyKey);
|
|
|
FilmDataThirdPartyUnlockSeatRequest req = new FilmDataThirdPartyUnlockSeatRequest();
|
|
|
req.setPlatform(platform);
|
|
|
req.setParamsString("{}");
|
|
|
@@ -213,9 +204,10 @@ public class TppService {
|
|
|
try {
|
|
|
rsp = client.execute(req);
|
|
|
if (rsp.getReturnCode() != null && rsp.getReturnCode().equals("0")) {
|
|
|
+ log.info("解锁成功");
|
|
|
return;
|
|
|
}
|
|
|
- log.error("锁座失败\n\t{}", rsp.getBody());
|
|
|
+ log.error("解锁失败\n\t{}", rsp.getBody());
|
|
|
} catch (Exception e) {
|
|
|
log.error("解锁失败", e);
|
|
|
}
|