|
|
@@ -1,5 +1,6 @@
|
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
@@ -103,6 +104,8 @@ public class OrderService {
|
|
|
private UserBankCardRepo userBankCardRepo;
|
|
|
private CacheService cacheService;
|
|
|
private UserPropertyRepo userPropertyRepo;
|
|
|
+ private HeatInfoRepo heatInfoRepo;
|
|
|
+ private ShowroomRepo showroomRepo;
|
|
|
|
|
|
public Page<Order> all(PageQuery pageQuery) {
|
|
|
return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
@@ -143,7 +146,7 @@ public class OrderService {
|
|
|
|
|
|
Long id = snowflakeIdWorker.nextId();
|
|
|
SendResult result = rocketMQTemplate.syncSend(generalProperties.getCreateOrderTopic(),
|
|
|
- new CreateOrderEvent(id, userId, collectionId, qty, addressId, userCouponId, invitor, vip), 100000);
|
|
|
+ new CreateOrderEvent(id, userId, collectionId, qty, addressId, userCouponId, invitor, vip, showroomId), 100000);
|
|
|
|
|
|
log.info("发送订单到队列: {}, userId={}, result={}", id, userId, result);
|
|
|
return String.valueOf(id);
|
|
|
@@ -352,6 +355,17 @@ public class OrderService {
|
|
|
userRepo.addVipPoint(userId, -usePoint);
|
|
|
cacheService.clearUserMy(userId);
|
|
|
}
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(showroomId)) {
|
|
|
+ //通过展厅的购买数量
|
|
|
+ heatInfoRepo.save(HeatInfo.builder()
|
|
|
+ .showroomId(showroomId)
|
|
|
+ .userId(userId)
|
|
|
+ .type(HeatType.BUY)
|
|
|
+ .value(0)
|
|
|
+ .orderId(order.getId())
|
|
|
+ .build());
|
|
|
+ }
|
|
|
rocketMQTemplate.syncSend(generalProperties.getUpdateStockTopic(), collectionId, 10000);
|
|
|
log.info("订单创建完成, id={}, {}ms", order.getId(), System.currentTimeMillis() - t);
|
|
|
return order;
|
|
|
@@ -692,6 +706,17 @@ public class OrderService {
|
|
|
if (collection.getAssetId() == null) {
|
|
|
collectionService.increaseSale(order.getCollectionId(), order.getQty());
|
|
|
}
|
|
|
+
|
|
|
+ //通过展厅购买加热力值
|
|
|
+ List<HeatInfo> heatInfos = heatInfoRepo.findByUserIdAndOrderIdAndType(order.getUserId(), orderId, HeatType.BUY);
|
|
|
+ if (CollUtil.isNotEmpty(heatInfos)) {
|
|
|
+ HeatInfo heatInfo = heatInfos.get(0);
|
|
|
+ int weight = sysConfigService.getInt("heat_buy_weight");
|
|
|
+ heatInfo.setValue(weight);
|
|
|
+ heatInfoRepo.save(heatInfo);
|
|
|
+ showroomRepo.addHeat(heatInfo.getShowroomId(), weight);
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
throw new BusinessException("状态错误 " + order.getStatus());
|
|
|
}
|
|
|
@@ -837,6 +862,7 @@ public class OrderService {
|
|
|
collectionService.decreaseQuota(order.getCollectionId(), 1);
|
|
|
log.info("取消加藏品额度CollectionId:{}", order.getCollectionId());
|
|
|
}
|
|
|
+
|
|
|
rocketMQTemplate.syncSend(generalProperties.getUpdateQuotaTopic(), order.getCollectionId(), 10000);
|
|
|
log.info("取消订单{}", order.getId());
|
|
|
} catch (Exception e) {
|