|
|
@@ -205,9 +205,11 @@ public class OrderService {
|
|
|
if (collection.getMaxCount() > 0) {
|
|
|
int count;
|
|
|
if (StringUtils.isNotBlank(collection.getCountId())) {
|
|
|
- count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(), Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
+ count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(), Arrays
|
|
|
+ .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
} else {
|
|
|
- count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
+ count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays
|
|
|
+ .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
}
|
|
|
if (count >= collection.getMaxCount()) {
|
|
|
throw new BusinessException("限购" + collection.getMaxCount() + "件");
|
|
|
@@ -224,7 +226,9 @@ public class OrderService {
|
|
|
}
|
|
|
User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
|
|
|
if (vip) {
|
|
|
- int purchase = orderRepo.countByUserIdAndCollectionIdAndVipTrueAndStatusIn(userId, collectionId, Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
+ int purchase = orderRepo
|
|
|
+ .countByUserIdAndCollectionIdAndVipTrueAndStatusIn(userId, collectionId, Arrays
|
|
|
+ .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
if (user.getVipPurchase() - purchase <= 0) {
|
|
|
throw new BusinessException("vip名额已使用完毕!");
|
|
|
}
|
|
|
@@ -270,7 +274,8 @@ public class OrderService {
|
|
|
.contactName(Optional.ofNullable(userAddress).map(UserAddress::getName).orElse(null))
|
|
|
.contactPhone(Optional.ofNullable(userAddress).map(UserAddress::getPhone).orElse(null))
|
|
|
.address(Optional.ofNullable(userAddress).map(u ->
|
|
|
- u.getProvinceName() + " " + u.getCityName() + " " + u.getDistrictName() + " " + u.getAddress())
|
|
|
+ u.getProvinceName() + " " + u.getCityName() + " " + u.getDistrictName() + " " + u
|
|
|
+ .getAddress())
|
|
|
.orElse(null))
|
|
|
.status(OrderStatus.NOT_PAID)
|
|
|
.assetId(collection.getAssetId())
|
|
|
@@ -455,7 +460,8 @@ public class OrderService {
|
|
|
paymentParams.put("goods_desc", collection.getName());
|
|
|
paymentParams.put("time_expire", DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
|
|
|
.format(LocalDateTime.now().plusMinutes(3)));
|
|
|
- paymentParams.put("notify_url", adapayProperties.getNotifyUrl() + "/order/" + adapayProperties.getMerchant() + "/" + order.getId());
|
|
|
+ paymentParams.put("notify_url", adapayProperties.getNotifyUrl() + "/order/" + adapayProperties
|
|
|
+ .getMerchant() + "/" + order.getId());
|
|
|
|
|
|
List<Map<String, Object>> divMembers = new ArrayList<>();
|
|
|
BigDecimal totalAmount = order.getTotalPrice().subtract(order.getGasPrice());
|
|
|
@@ -520,7 +526,8 @@ public class OrderService {
|
|
|
case "alipay_qr":
|
|
|
return MapUtils.getString(MapUtils.getMap(response, "expend"), "qrcode_url");
|
|
|
case "wx_pub":
|
|
|
- JSONObject payParams = JSON.parseObject(MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info"));
|
|
|
+ JSONObject payParams = JSON
|
|
|
+ .parseObject(MapUtils.getString(MapUtils.getMap(response, "expend"), "pay_info"));
|
|
|
payParams.put("timestamp", payParams.get("timeStamp"));
|
|
|
payParams.remove("timeStamp");
|
|
|
return payParams;
|
|
|
@@ -603,15 +610,17 @@ public class OrderService {
|
|
|
orderRepo.save(order);
|
|
|
throw new BusinessException("抽卡失败, 已退款 " + orderId);
|
|
|
}
|
|
|
- log.info("抽卡成功 orderId: {}, collectionId: {}, winCollectionId: {}", orderId, collection.getId(), winItem.getCollectionId());
|
|
|
+ log.info("抽卡成功 orderId: {}, collectionId: {}, winCollectionId: {}", orderId, collection
|
|
|
+ .getId(), winItem.getCollectionId());
|
|
|
order.setWinCollectionId(winItem.getCollectionId());
|
|
|
- orderRepo.save(order);
|
|
|
- assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售",
|
|
|
+ Asset asset = assetService.createAsset(winItem, user, order.getId(), order.getPrice(), "出售",
|
|
|
winItem.getTotal() > 1 ? collectionService.getNextNumber(winItem.getCollectionId()) : null,
|
|
|
collection.getHoldDays());
|
|
|
+ order.setTokenId(asset.getTokenId());
|
|
|
+ orderRepo.save(order);
|
|
|
} else {
|
|
|
if (collection.getSource() == CollectionSource.TRANSFER) {
|
|
|
- orderRepo.save(order);
|
|
|
+
|
|
|
Asset asset = assetRepo.findById(collection.getAssetId()).orElse(null);
|
|
|
assetService.transfer(asset, order.getPrice(), user, "转让", order.getId());
|
|
|
collectionRepo.delete(collection);
|
|
|
@@ -622,14 +631,17 @@ public class OrderService {
|
|
|
if (asset != null && asset.getUserId() != null) {
|
|
|
smsService.sellOut(userRepo.findPhoneById(asset.getUserId()));
|
|
|
}
|
|
|
-
|
|
|
- } else {
|
|
|
+ order.setTokenId(asset.getTokenId());
|
|
|
orderRepo.save(order);
|
|
|
+ } else {
|
|
|
Asset asset = assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
|
|
|
- collection.getTotal() > 1 ? collectionService.getNextNumber(order.getCollectionId()) : null);
|
|
|
+ collection.getTotal() > 1 ? collectionService
|
|
|
+ .getNextNumber(order.getCollectionId()) : null);
|
|
|
if (collection.getType() == CollectionType.SHOWROOM) {
|
|
|
showroomService.save(asset);
|
|
|
}
|
|
|
+ order.setTokenId(asset.getTokenId());
|
|
|
+ orderRepo.save(order);
|
|
|
}
|
|
|
}
|
|
|
commission(order);
|