|
|
|
@ -0,0 +1,60 @@ |
|
|
|
package com.qniao.dam.application.handler.operationlog; |
|
|
|
|
|
|
|
import com.google.common.eventbus.Subscribe; |
|
|
|
import com.qniao.dam.domian.aggregate.operationlog.event.OrderPaymentLogEvent; |
|
|
|
import com.qniao.dam.domian.aggregate.order.event.OrderCompletedEvent; |
|
|
|
import com.qniao.dam.infrastructure.persistent.dao.domain.UserDao; |
|
|
|
import com.qniao.das.domian.aggregate.certificate.constant.CertificationAuditStatusEnum; |
|
|
|
import com.qniao.dau.domain.aggregate.user.entity.User; |
|
|
|
import com.qniao.domain.BaseApplicationService; |
|
|
|
import com.qniao.logging.domain.aggregate.operationlog.constant.OperationLogTypeEnum; |
|
|
|
import com.qniao.logging.domain.aggregate.operationlog.event.UserOperatedEvent; |
|
|
|
import com.qniao.logging.infrastructure.persistent.constant.OperationLogConstants; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
public class OperationLogEventHandler extends BaseApplicationService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private UserDao userDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* 订单已支付事件 |
|
|
|
*/ |
|
|
|
@Subscribe |
|
|
|
public void handle(OrderCompletedEvent event) { |
|
|
|
try { |
|
|
|
OrderPaymentLogEvent logEvent = new OrderPaymentLogEvent(); |
|
|
|
//预约单号 |
|
|
|
logEvent.setTargetId(event.getId()); |
|
|
|
Map<String, Object> logOperatorParams = event.getLogOperatorParams(); |
|
|
|
handleOperator(logEvent, logOperatorParams); |
|
|
|
//操作时间 |
|
|
|
logEvent.setOperateTime(LocalDateTime.now()); |
|
|
|
logEvent.setOperationLogType(OperationLogTypeEnum.ORDER_PAYMENT); |
|
|
|
logEvent.setEventSummaryName("支付"); |
|
|
|
this.sendEvent(logEvent); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("订单已支付事件日志处理异常"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void handleOperator(UserOperatedEvent logEvent, Map<String, Object> logOperatorParams) { |
|
|
|
Long userId = (Long) logOperatorParams.get(OperationLogConstants.USER_ID); |
|
|
|
if (Objects.nonNull(userId)) { |
|
|
|
logEvent.setOperatorId(String.valueOf(userId)); |
|
|
|
User user = userDao.selectById(userId); |
|
|
|
if (Objects.nonNull(user)) { |
|
|
|
String operatorName = user.getRealName() != null ? user.getRealName() : user.getNickName(); |
|
|
|
logEvent.setOperatorName(operatorName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |