package cn.superdesk.uniorder.dubbo.consumer.invoice.supplier;

import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.supplier.InvoiceApplySupplier;
import cn.superdesk.uniorder.dto.param.invoice.supplier.status.InvoiceApplySupplierOpReceiveInvoiceStatusForm;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.invoice.supplier.DubboInvoiceApplySupplierFieldReceiveInvoiceStatusService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;


/**
 * @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 InvoiceApplySupplierFieldReceiveInvoiceStatusDubboConsumerService {

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

	@Resource
	private PermissionDubboCustomerService permissionDubboCustomerService;

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

	// 状态流转为 未收票(0, "未收票")
	public void opInit(InvoiceApplySupplier entity, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceApplySupplierFieldReceiveInvoiceStatusService.opInit(entity, loginSysUser);
	}

	// 状态流转为 已收票(1, "已收票")
	public void opReceive(InvoiceApplySupplier entity, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceApplySupplierFieldReceiveInvoiceStatusService.opReceive(entity, loginSysUser);
	}

	// 状态流转为 已收票(1, "已收票")
	public void opReceive(List<InvoiceApplySupplier> entitys, InvoiceApplySupplierOpReceiveInvoiceStatusForm form, String token) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceApplySupplierFieldReceiveInvoiceStatusService.opReceive(entitys, form, loginSysUser);
	}

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