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

import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.accounting.unified.supplier.AccountingUnifiedSupplier;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.accounting.supplier.DubboAccountingUnifiedSupplierFieldAccountingStatusService;
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 AccountingUnifiedSupplierFieldAccountingStatusDubboConsumerService {

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

	@Resource
	private PermissionDubboCustomerService permissionDubboCustomerService;

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

	// 状态流转为 待提交(3, "待提交")
	public void opInitOrReset(String token, AccountingUnifiedSupplier entity) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboAccountingUnifiedSupplierFieldAccountingStatusService.opInitOrReset(entity, loginSysUser);
	}

	// 状态流转为 未确认(0, "未确认")
	public void opSubmit(String token, AccountingUnifiedSupplier entity) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboAccountingUnifiedSupplierFieldAccountingStatusService.opSubmit(entity, loginSysUser);
	}

	// 状态流转为 已确认(1, "已确认")
	public void opConfirm(String token, AccountingUnifiedSupplier entity) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboAccountingUnifiedSupplierFieldAccountingStatusService.opConfirm(entity, loginSysUser);
	}

	// 状态流转为 已拒绝(2, "已拒绝")
	public void opReject(String token, AccountingUnifiedSupplier entity) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboAccountingUnifiedSupplierFieldAccountingStatusService.opReject(entity, loginSysUser);
	}

	// 状态流转为 已取消(-1, "已取消")
	public void opCancel(String token, AccountingUnifiedSupplier entity) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboAccountingUnifiedSupplierFieldAccountingStatusService.opCancel(entity, loginSysUser);
	}

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