|
@@ -75,13 +75,14 @@ public class OrderService {
|
|
|
private CommissionRecordRepo commissionRecordRepo;
|
|
private CommissionRecordRepo commissionRecordRepo;
|
|
|
private AdapayProperties adapayProperties;
|
|
private AdapayProperties adapayProperties;
|
|
|
private GeneralProperties generalProperties;
|
|
private GeneralProperties generalProperties;
|
|
|
|
|
+ private SnowflakeIdWorker snowflakeIdWorker;
|
|
|
|
|
|
|
|
public Page<Order> all(PageQuery pageQuery) {
|
|
public Page<Order> all(PageQuery pageQuery) {
|
|
|
return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
|
|
return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public Order create(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor) {
|
|
|
|
|
|
|
+ public Order create(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor, Long id) {
|
|
|
if (qty <= 0) throw new BusinessException("数量必须大于0");
|
|
if (qty <= 0) throw new BusinessException("数量必须大于0");
|
|
|
User user = userRepo.findByIdAndDelFalse(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
User user = userRepo.findByIdAndDelFalse(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("藏品不存在"));
|
|
Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("藏品不存在"));
|
|
@@ -126,6 +127,7 @@ public class OrderService {
|
|
|
|
|
|
|
|
BigDecimal gasFee = sysConfigService.getBigDecimal("gas_fee");
|
|
BigDecimal gasFee = sysConfigService.getBigDecimal("gas_fee");
|
|
|
Order order = Order.builder()
|
|
Order order = Order.builder()
|
|
|
|
|
+ .id(Optional.ofNullable(id).orElse(snowflakeIdWorker.nextId()))
|
|
|
.userId(userId)
|
|
.userId(userId)
|
|
|
.collectionId(collectionId)
|
|
.collectionId(collectionId)
|
|
|
.name(collection.getName())
|
|
.name(collection.getName())
|