|
|
@@ -6,8 +6,10 @@ import com.izouma.ticketExchange.domain.Location;
|
|
|
import com.izouma.ticketExchange.domain.Schedule;
|
|
|
import com.izouma.ticketExchange.domain.Show;
|
|
|
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.izouma.ticketExchange.utils.SnowflakeIdWorker;
|
|
|
import com.taobao.api.ApiException;
|
|
|
import com.taobao.api.response.FilmDataThirdPartyHotshowsGetResponse;
|
|
|
import com.taobao.api.response.FilmDataThirdPartySchedulesGetResponse;
|
|
|
@@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -30,6 +33,8 @@ public class TppServiceTest extends ApplicationTests {
|
|
|
private ShowRepo showRepo;
|
|
|
@Value("${taobao.imagePrefix}")
|
|
|
private String imagePrefix;
|
|
|
+ @Autowired
|
|
|
+ private ScheduleRepo scheduleRepo;
|
|
|
|
|
|
@Test
|
|
|
public void updateLocation() throws ApiException {
|
|
|
@@ -68,26 +73,41 @@ public class TppServiceTest extends ApplicationTests {
|
|
|
|
|
|
@Test
|
|
|
public void test() {
|
|
|
- List<FilmDataThirdPartySchedulesGetResponse.Schedule> list = tppService.getSchedules(4353L);
|
|
|
+ List<FilmDataThirdPartySchedulesGetResponse.Schedule> list = tppService.getSchedules(45100L);
|
|
|
list.forEach(s -> {
|
|
|
- Schedule.builder()
|
|
|
- .id(s.getId())
|
|
|
- .cinemaId(s.getCinemaId())
|
|
|
- .showId(s.getShowId())
|
|
|
- .price(BigDecimal.valueOf(s.getPrice() / 100f))
|
|
|
- .hallName(s.getHallName())
|
|
|
- .maxCanBuy(Math.toIntExact(s.getMaxCanBuy()))
|
|
|
- .showTime(DateTimeUtils.toLocalDateTime(s.getShowTime(), "yyyy-MM-dd HH:mm:ss"))
|
|
|
- .closeTime(DateTimeUtils.toLocalDateTime(s.getCloseTime(), "yyyy-MM-dd HH:mm:ss"))
|
|
|
- .scheduleArea(s.getScheduleArea())
|
|
|
- .sectionId(s.getSectionId())
|
|
|
- .serviceFee(BigDecimal.valueOf(Optional.ofNullable(s.getServiceFee()).orElse(0L) / 100f))
|
|
|
- .showVersion(s.getShowVersion())
|
|
|
- .showDate(DateTimeUtils.toLocalDate(s.getShowDate(), "yyyy-MM-dd"))
|
|
|
- .isExpired(s.getIsExpired())
|
|
|
- .build();
|
|
|
+ Schedule ss = Schedule.builder()
|
|
|
+ .id(s.getId())
|
|
|
+ .cinemaId(s.getCinemaId())
|
|
|
+ .showId(s.getShowId())
|
|
|
+ .price(BigDecimal.valueOf(s.getPrice()).divide(BigDecimal.valueOf(100), RoundingMode.HALF_EVEN))
|
|
|
+ .hallName(s.getHallName())
|
|
|
+ .maxCanBuy(Math.toIntExact(s.getMaxCanBuy()))
|
|
|
+ .showTime(DateTimeUtils.toLocalDateTime(s.getShowTime(), "yyyy-MM-dd HH:mm:ss"))
|
|
|
+ .closeTime(DateTimeUtils.toLocalDateTime(s.getCloseTime(), "yyyy-MM-dd HH:mm:ss"))
|
|
|
+ .scheduleArea(s.getScheduleArea())
|
|
|
+ .sectionId(s.getSectionId())
|
|
|
+ .serviceFee(BigDecimal.valueOf(Optional.ofNullable(s.getServiceFee()).orElse(0L) / 100f))
|
|
|
+ .showVersion(s.getShowVersion())
|
|
|
+ .showDate(DateTimeUtils.toLocalDate(s.getShowDate(), "yyyy-MM-dd"))
|
|
|
+ .isExpired(s.getIsExpired())
|
|
|
+ .build();
|
|
|
+ scheduleRepo.save(ss);
|
|
|
});
|
|
|
System.out.println(list);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testOrder() throws Exception {
|
|
|
+ Long orderId = new SnowflakeIdWorker(1, 1).nextId();
|
|
|
+ System.out.println(orderId);
|
|
|
+ tppService.issueOrder(9L, orderId, "85_44_732009272_[0300000400600701, 0300000400500701]", 5600L);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void addSchedule() {
|
|
|
+ tppService.getSchedules(45100L).forEach(schedule -> {
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|