package com.jpsoft.shinestar.mq.listener;

import cn.hutool.core.date.DateUtil;
import com.jpsoft.shinestar.modules.base.entity.*;
import com.jpsoft.shinestar.modules.base.service.CompanyPaymentInfoService;
import com.jpsoft.shinestar.modules.base.service.OrderInfoService;
import com.jpsoft.shinestar.modules.base.service.PersonInfoService;
import com.jpsoft.shinestar.modules.base.service.PersonRoleIconService;
import com.jpsoft.shinestar.modules.business.entity.BillPush;
import com.jpsoft.shinestar.modules.business.service.BillPushService;
import com.jpsoft.shinestar.modules.common.utils.JwtUtil2;
import com.jpsoft.shinestar.modules.common.utils.WechatMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort.Order;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 墨鱼_mo
 * @date 2020-12-8 15:17
 */
@Slf4j
@Component
@RabbitListener(queues = "billPushQueue",concurrency = "2")
public class BillPushListener {

    @Autowired
    private BillPushService billPushService;

    @Autowired
    private OrderInfoService orderInfoService;

    @RabbitHandler
    public void process(String id) {
        log.warn("账单billPushId:" + id);

        try {

            BillPush billPush = billPushService.get(id);

            OrderInfo orderInfo = orderInfoService.get(billPush.getOrderId());
            if (orderInfo.getPayStatus() == 10){
                billPushService.sendNotPayBillRemind(billPush);
            }

        }
        catch (Exception ex){
            log.error(ex.getMessage(),ex);
        }
    }
}
