package cn.superdesk.uniorder.dubbo.consumer.invoice.customer.invoiced;

import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dto.vo.invoice.customer.invoiced.InvoiceInvoicedExcelExportVo;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.invoice.customer.invoiced.DubboInvoiceInvoicedFieldIsOverdueService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


/**
 * @Description: 简易状态机 星型结构
 * @Author: linjinyu
 * @CreateDate: 10/12/20 4:28 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 10/12/20 4:28 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Component
public class InvoiceInvoicedFieldIsOverdueDubboConsumerService {

	@Reference(version = "1.0.0", timeout = 300000, retries = -1)
	private DubboInvoiceInvoicedFieldIsOverdueService dubboInvoiceInvoicedFieldIsOverdueService;

	@Resource
	private PermissionDubboCustomerService permissionDubboCustomerService;

	/****************************************** 状态机 外部使用 类门面 start ******************************************/
	// 状态流转为 正常(0, "正常")
	public void opInitOrReset(String token, InvoiceInvoicedExcelExportVo form) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsOverdueService.opInitOrReset(form, loginSysUser);
	}

	// 状态流转为 逾期(1, "逾期")
	public void opOverdued(String token, InvoiceInvoicedExcelExportVo form) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsOverdueService.opOverdued(form, loginSysUser);
	}

	/****************************************** 状态机 外部使用 类门面   end ******************************************/

	public void processInvoiceInvoicedsOverdueTask(String token, InvoiceInvoicedExcelExportVo taskParams) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsOverdueService.processInvoiceInvoicedsOverdueTask(taskParams, loginSysUser);
	}

	public void kafkaInvoiceInvoicedsOverdueTaskReceive(String message) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(JwtUtil.FORGED_BACKEND_TOKEN);
		dubboInvoiceInvoicedFieldIsOverdueService.kafkaInvoiceInvoicedsOverdueTaskReceive(message, loginSysUser);
	}

}
