dev-discount
胡锐 2 years ago
parent b77e2c82ca
commit bdb342aefa
  1. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  2. 26
      hai-cweb/src/main/java/com/cweb/msg/OrderCancelConsumer.java
  3. 46
      hai-cweb/src/main/java/com/cweb/msg/OrderCreateConsumer.java
  4. 5
      hai-cweb/src/main/resources/dev/application.yml
  5. 4
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java

File diff suppressed because one or more lines are too long

@ -0,0 +1,26 @@
package com.cweb.msg;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.DateUtil;
import com.hai.entity.HighOrder;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "order-cancel-group", topic = "order-topic",selectorExpression = "cancel")
public class OrderCancelConsumer implements RocketMQListener<HighOrder> {
@Override
public void onMessage(HighOrder order) {
/* System.out.println(JSONObject.toJSONString(order));*/
try {
System.out.println(DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + "取消订单:" + order.getOrderNo());
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,46 @@
package com.cweb.msg;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.DateUtil;
import com.hai.entity.HighOrder;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "order-create-group", topic = "order-topic",selectorExpression = "create")
public class OrderCreateConsumer implements RocketMQListener<HighOrder> {
@Resource
private RocketMQTemplate rocketMQTemplate;
@Override
public void onMessage(HighOrder order) {
try {
/* System.out.println(JSONObject.toJSONString(order));*/
System.out.println(DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + " 创建订单:" + order.getOrderNo());
/* org.springframework.messaging.Message message = MessageBuilder.withPayload(order).build();
rocketMQTemplate.syncSend("order-topic:cancel",
message,
this.rocketMQTemplate.getProducer().getSendMsgTimeout(),
4);
System.out.println(DateUtil.date2String(new Date(), "yyyy-MM-dd HH:mm:ss") + "发送成功");*/
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -53,6 +53,11 @@ spring:
#MQTT默认的消息推送主题,实际可在调用接口是指定 #MQTT默认的消息推送主题,实际可在调用接口是指定
# default: # default:
# topic: topic # topic: topic
rocketmq:
name-server: 139.159.177.244:9876
producer:
#必须指定group
group: default-group
#配置日期返回至前台为时间戳 #配置日期返回至前台为时间戳
jackson: jackson:

@ -175,7 +175,7 @@ public class HighOrderServiceImpl implements HighOrderService {
public void insertOrder(HighOrder highOrder) throws Exception { public void insertOrder(HighOrder highOrder) throws Exception {
highOrderMapper.insert(highOrder); highOrderMapper.insert(highOrder);
// 使用优惠券 /* // 使用优惠券
if (highOrder.getMemDiscountId() != null) { if (highOrder.getMemDiscountId() != null) {
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(highOrder.getMemDiscountId()); HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(highOrder.getMemDiscountId());
discountUserRel.setUseTime(new Date()); // 使用时间 discountUserRel.setUseTime(new Date()); // 使用时间
@ -354,7 +354,7 @@ public class HighOrderServiceImpl implements HighOrderService {
// 订单完成业务处理 // 订单完成业务处理
orderBusinessTransaction(highOrder); orderBusinessTransaction(highOrder);
} }
} }*/
} }

Loading…
Cancel
Save