|
|
@@ -1,31 +1,30 @@
|
|
|
package com.izouma.tcg.service.card;
|
|
|
|
|
|
+import com.izouma.tcg.domain.User;
|
|
|
import com.izouma.tcg.domain.card.CardBox;
|
|
|
import com.izouma.tcg.domain.card.CardCase;
|
|
|
import com.izouma.tcg.domain.card.Collection;
|
|
|
+import com.izouma.tcg.domain.customizeStore.Store;
|
|
|
import com.izouma.tcg.dto.CardBoxDTO;
|
|
|
import com.izouma.tcg.dto.GroupDTO;
|
|
|
import com.izouma.tcg.dto.PageQuery;
|
|
|
import com.izouma.tcg.dto.cardCase.CardCaseDTO;
|
|
|
import com.izouma.tcg.dto.cardCase.CardCaseInputDTO;
|
|
|
-import com.izouma.tcg.dto.user.CartDTO;
|
|
|
import com.izouma.tcg.enums.CaseStatus;
|
|
|
import com.izouma.tcg.exception.BusinessException;
|
|
|
import com.izouma.tcg.repo.card.CardBoxRepo;
|
|
|
import com.izouma.tcg.repo.card.CardCaseRepo;
|
|
|
import com.izouma.tcg.repo.card.CollectionRepo;
|
|
|
+import com.izouma.tcg.repo.customizeStore.StoreRepo;
|
|
|
import com.izouma.tcg.utils.JpaUtils;
|
|
|
+import com.izouma.tcg.utils.SecurityUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.logging.log4j.util.SortedArrayStringMap;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
-import java.math.BigDecimal;
|
|
|
-import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
-import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@@ -35,6 +34,7 @@ public class CardCaseService {
|
|
|
private final CardCaseRepo cardCaseRepo;
|
|
|
private final CollectionRepo collectionRepo;
|
|
|
private final CardBoxRepo cardBoxRepo;
|
|
|
+ private final StoreRepo storeRepo;
|
|
|
|
|
|
public Page<CardCase> all(PageQuery pageQuery) {
|
|
|
return cardCaseRepo
|
|
|
@@ -134,7 +134,12 @@ public class CardCaseService {
|
|
|
cardCaseDTO.setEndTime(cardCase.getStartTime());
|
|
|
cardCaseDTO.setCaseStatus(cardCase.getCaseStatus().toString());
|
|
|
Integer preorderCount = cardBoxRepo.countAllByCardCaseIdAndUserIdNotNull(cardCase.getId());
|
|
|
-
|
|
|
+ Store store = storeRepo.findById(cardCase.getStoreId()).orElse(null);
|
|
|
+ if (store != null) {
|
|
|
+ cardCaseDTO.setStoreId(store.getId());
|
|
|
+ cardCaseDTO.setStoreName(store.getStoreName());
|
|
|
+ cardCaseDTO.setStoreLogo(store.getStoreName());
|
|
|
+ }
|
|
|
cardCaseDTO.setPrice(cardCase.getBoxPrice());
|
|
|
if (cardCase.isSpecial()) {
|
|
|
cardCaseDTO.setTotal(cardCase.getCardBoxList().size() / 2);
|
|
|
@@ -167,8 +172,12 @@ public class CardCaseService {
|
|
|
cardCaseDTO.setCaseStatus(cardCase.getCaseStatus().toString());
|
|
|
cardCaseDTO.setSpecial(cardCase.isSpecial());
|
|
|
Integer preorderCount = cardBoxRepo.countAllByCardCaseIdAndUserIdNotNull(cardCase.getId());
|
|
|
-
|
|
|
-
|
|
|
+ Store store = storeRepo.findById(cardCase.getStoreId()).orElse(null);
|
|
|
+ if (store != null) {
|
|
|
+ cardCaseDTO.setStoreId(store.getId());
|
|
|
+ cardCaseDTO.setStoreName(store.getStoreName());
|
|
|
+ cardCaseDTO.setStoreLogo(store.getStoreName());
|
|
|
+ }
|
|
|
if (cardCase.isSpecial()) {
|
|
|
cardCaseDTO.setTotal(cardCase.getCardBoxList().size() / 2);
|
|
|
cardCaseDTO.setPreorder(preorderCount / 2);
|
|
|
@@ -191,6 +200,11 @@ public class CardCaseService {
|
|
|
cardCase = orig;
|
|
|
}
|
|
|
}
|
|
|
+ User user = SecurityUtils.getAuthenticatedUser();
|
|
|
+ Store store = storeRepo.findFirstByUserId(user.getId());
|
|
|
+ if (store != null) {
|
|
|
+ cardCase.setStoreId(store.getId());
|
|
|
+ }
|
|
|
Collection collection = collectionRepo.findById(cardCaseInputDTO.getCollectionId())
|
|
|
.orElseThrow(new BusinessException("无系列信息"));
|
|
|
cardCase.setSeriesId(collection.getSeriesId());
|