|
|
@@ -24,6 +24,7 @@ import com.izouma.nineth.domain.*;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.enums.*;
|
|
|
import com.izouma.nineth.event.CreateAssetEvent;
|
|
|
+import com.izouma.nineth.event.CreateOrderEvent;
|
|
|
import com.izouma.nineth.event.TransferAssetEvent;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.*;
|
|
|
@@ -36,10 +37,11 @@ import org.apache.commons.codec.EncoderException;
|
|
|
import org.apache.commons.codec.net.URLCodec;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.rocketmq.client.producer.SendResult;
|
|
|
+import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.core.env.Environment;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.Model;
|
|
|
@@ -67,20 +69,28 @@ public class OrderService {
|
|
|
private WxPayProperties wxPayProperties;
|
|
|
private AssetService assetService;
|
|
|
private SysConfigService sysConfigService;
|
|
|
- private BlindBoxItemRepo blindBoxItemRepo;
|
|
|
private AssetRepo assetRepo;
|
|
|
private UserCouponRepo userCouponRepo;
|
|
|
private CollectionService collectionService;
|
|
|
- private RedisTemplate<String, Object> redisTemplate;
|
|
|
private CommissionRecordRepo commissionRecordRepo;
|
|
|
private AdapayProperties adapayProperties;
|
|
|
private GeneralProperties generalProperties;
|
|
|
private SnowflakeIdWorker snowflakeIdWorker;
|
|
|
+ private RocketMQTemplate rocketMQTemplate;
|
|
|
|
|
|
public Page<Order> all(PageQuery pageQuery) {
|
|
|
return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
|
|
|
|
+ public String mqCreate(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor) {
|
|
|
+
|
|
|
+ Long id = snowflakeIdWorker.nextId();
|
|
|
+ SendResult result = rocketMQTemplate.syncSend(generalProperties.getCreateOrderTopic(),
|
|
|
+ new CreateOrderEvent(id, userId, collectionId, qty, addressId, userCouponId, invitor), 100000);
|
|
|
+ log.info("发送订单到队列: {}, result={}", id, result);
|
|
|
+ return String.valueOf(id);
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional
|
|
|
public Order create(Long userId, Long collectionId, int qty, Long addressId, Long userCouponId, Long invitor, Long id) {
|
|
|
if (qty <= 0) throw new BusinessException("数量必须大于0");
|