PushNoPassPayFailureMsgService.java 2.3 KB
package com.zteits.ipay.biz;

import org.apache.commons.lang3.StringUtils;
import com.alibaba.fastjson.JSON;
import com.aliyun.openservices.ons.api.SendResult;
import com.zteits.clouds.api.dto.order.parkorder.dto.OrderParkDTO;
import com.zteits.clouds.api.dto.rocketmq.constants.MQTopicConstants;
import com.zteits.clouds.api.dto.rocketmq.constants.tags.OrderTags;
import com.zteits.order.domain.OrderPark;
import zteits.rocketmq.spring.starter.core.RocketMQTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 账户余额不足导致无感支付失败消息推送服务
 * Copyright: Copyright (c) 2019  zteits
 *
 * @ClassName: PushNoPassPayFailueMsgService
 * @Description:
 * @version: v1.0.0
 * @author: niueb
 * @date: 2020/7/16 15:05
 * Modification History:
 * Date             Author          Version            Description
 * ---------------------------------------------------------*
 * 2020/7/16       niueb           v1.0.0               创建
 */
@Service
public class PushNoPassPayFailureMsgService {

    private static final Logger logger = LoggerFactory.getLogger(PushNoPassPayFailureMsgService.class);

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    public void sendNoPassPayFailureMsg(OrderPark orderPark) {
        String keys = "";
        OrderParkDTO orderParkDTO = new OrderParkDTO();
        BeanUtils.copyProperties(orderPark,orderParkDTO);
        try{
            logger.info("发送无感支付失败消息,参数:"+ JSON.toJSONString(orderPark));
            SendResult sendResult = rocketMQTemplate.syncSend(MQTopicConstants.ZTEITS_RNT_CLOUD, OrderTags.NO_PASS_PAY_FAILURE, keys, orderParkDTO);
            logger.info("发送无感支付失败消息结果:"+JSON.toJSONString(sendResult));
            if(StringUtils.isBlank(sendResult.getMessageId())){
                //发送失败,后期可以使用定时任务辅助,针对发送失败的,定时重发
            }
        }catch (Exception e){
            //发送失败,后期可以使用定时任务辅助,针对发送失败的,定时重发
            logger.error("无感支付失败消息发送失败",e);
        }
    }
}