|
|
@@ -44,20 +44,21 @@ import java.util.*;
|
|
|
@Slf4j
|
|
|
public class OrderService {
|
|
|
|
|
|
- private OrderRepo orderRepo;
|
|
|
- private CollectionRepo collectionRepo;
|
|
|
- private UserAddressRepo userAddressRepo;
|
|
|
- private UserRepo userRepo;
|
|
|
- private Environment env;
|
|
|
- private AlipayClient alipayClient;
|
|
|
- private AlipayProperties alipayProperties;
|
|
|
- private WxPayService wxPayService;
|
|
|
- private WxPayProperties wxPayProperties;
|
|
|
- private AssetService assetService;
|
|
|
- private SysConfigService sysConfigService;
|
|
|
- private BlindBoxItemRepo blindBoxItemRepo;
|
|
|
- private AssetRepo assetRepo;
|
|
|
- private UserCouponRepo userCouponRepo;
|
|
|
+ private OrderRepo orderRepo;
|
|
|
+ private CollectionRepo collectionRepo;
|
|
|
+ private UserAddressRepo userAddressRepo;
|
|
|
+ private UserRepo userRepo;
|
|
|
+ private Environment env;
|
|
|
+ private AlipayClient alipayClient;
|
|
|
+ private AlipayProperties alipayProperties;
|
|
|
+ private WxPayService wxPayService;
|
|
|
+ private WxPayProperties wxPayProperties;
|
|
|
+ private AssetService assetService;
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
+ private BlindBoxItemRepo blindBoxItemRepo;
|
|
|
+ private AssetRepo assetRepo;
|
|
|
+ private UserCouponRepo userCouponRepo;
|
|
|
+ private CollectionService collectionService;
|
|
|
|
|
|
public Page<Order> all(PageQuery pageQuery) {
|
|
|
return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -232,7 +233,7 @@ public class OrderService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public void notifyOrder(Long orderId, PayMethod payMethod, String transactionId) {
|
|
|
+ public void notifyOrder1(Long orderId, PayMethod payMethod, String transactionId) {
|
|
|
Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
Collection collection = collectionRepo.findById(order.getCollectionId())
|
|
|
.orElseThrow(new BusinessException("藏品不存在"));
|
|
|
@@ -294,7 +295,41 @@ public class OrderService {
|
|
|
order.setTransactionId(transactionId);
|
|
|
order.setPayMethod(payMethod);
|
|
|
orderRepo.save(order);
|
|
|
- Asset asset = assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售");
|
|
|
+ assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售");
|
|
|
+ } else {
|
|
|
+ if (collection.getSource() == CollectionSource.TRANSFER) {
|
|
|
+ Asset asset = assetRepo.findById(collection.getAssetId()).orElse(null);
|
|
|
+ assetService.transfer(asset, user);
|
|
|
+ collectionRepo.delete(collection);
|
|
|
+ } else {
|
|
|
+ order.setStatus(OrderStatus.PROCESSING);
|
|
|
+ order.setPayTime(LocalDateTime.now());
|
|
|
+ order.setTransactionId(transactionId);
|
|
|
+ order.setPayMethod(payMethod);
|
|
|
+ orderRepo.save(order);
|
|
|
+ assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (order.getStatus() == OrderStatus.CANCELLED) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ public void notifyOrder(Long orderId, PayMethod payMethod, String transactionId) {
|
|
|
+ Order order = orderRepo.findById(orderId).orElseThrow(new BusinessException("订单不存在"));
|
|
|
+ Collection collection = collectionRepo.findById(order.getCollectionId())
|
|
|
+ .orElseThrow(new BusinessException("藏品不存在"));
|
|
|
+ User user = userRepo.findById(order.getUserId()).orElseThrow(new BusinessException("用户不存在"));
|
|
|
+ if (order.getStatus() == OrderStatus.NOT_PAID) {
|
|
|
+ if (order.getType() == CollectionType.BLIND_BOX) {
|
|
|
+ BlindBoxItem winItem = collectionService.draw(collection.getId());
|
|
|
+
|
|
|
+ order.setStatus(OrderStatus.PROCESSING);
|
|
|
+ order.setPayTime(LocalDateTime.now());
|
|
|
+ order.setTransactionId(transactionId);
|
|
|
+ order.setPayMethod(payMethod);
|
|
|
+ orderRepo.save(order);
|
|
|
+ assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售");
|
|
|
} else {
|
|
|
if (collection.getSource() == CollectionSource.TRANSFER) {
|
|
|
Asset asset = assetRepo.findById(collection.getAssetId()).orElse(null);
|
|
|
@@ -306,7 +341,7 @@ public class OrderService {
|
|
|
order.setTransactionId(transactionId);
|
|
|
order.setPayMethod(payMethod);
|
|
|
orderRepo.save(order);
|
|
|
- Asset asset = assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售");
|
|
|
+ assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售");
|
|
|
}
|
|
|
}
|
|
|
} else if (order.getStatus() == OrderStatus.CANCELLED) {
|