UnionSettleUpdateConsumer.java 1.6 KB
package com.yoho.unions.server.mqconsumer;

import com.yoho.core.common.utils.JsonUtil;
import com.yoho.core.rabbitmq.YhConsumer;
import com.yoho.service.model.union.bo.ShareSettlementBo;
import com.yoho.unions.server.service.IUnionShareService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by mingdan.ge on 2018/5/10.
 */
@Component
public class UnionSettleUpdateConsumer implements YhConsumer {

    private Logger logger = LoggerFactory.getLogger(UnionSettleUpdateConsumer.class);

    @Autowired
    private IUnionShareService unionShareService;

    @Override
    public void handleMessage(Object o) throws Exception{
        logger.info("UnionSettleUpdateConsumer,handleMessage {}", o);
        try {
            if (null == o) {
                return;
            }
            List<Object> list = JsonUtil.jsonToObject(o.toString(), List.class);
            list.forEach(l->{
                try {
                    ShareSettlementBo bo = JsonUtil.jsonToObject(l.toString(), ShareSettlementBo.class);
                    //TODO 提现结算单状态变更
                    unionShareService.updateSettlementStatus(bo);
                } catch (Exception e) {
                    logger.warn("UnionSettleUpdateConsumer,handleMessage fail! obj is {}, e {}",l,e.getMessage());
                }
            });

        } catch (Exception e) {
            logger.warn("UnionSettleUpdateConsumer,handleMessage fail! obj is {}, e {}",o,e.getMessage());
        }
    }
}