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.param.invoice.excel.InvoiceInvoicedOpBackCollectionForm;
import cn.superdesk.uniorder.dubbo.consumer._permission.PermissionDubboCustomerService;
import cn.superdesk.uniorder.dubbo.facade.invoice.customer.invoiced.DubboInvoiceInvoicedFieldIsBackCollectionService;
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 InvoiceInvoicedFieldIsBackCollectionDubboConsumerService {

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

	@Resource
	private PermissionDubboCustomerService permissionDubboCustomerService;

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

	// 状态流转为 部分回款(1, "部分回款")
	public void opPart(String token, InvoiceInvoicedOpBackCollectionForm form) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsBackCollectionService.opPart(form, loginSysUser);
	}

	public void opPartBatchByExcelImport(String token, List<InvoiceInvoicedOpBackCollectionForm> formList){
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsBackCollectionService.opPartBatchByImportExcel(formList, loginSysUser);
	}

	// 状态流转为 全部回款(2, "全部回款")
	public void opComplete(String token, InvoiceInvoicedOpBackCollectionForm form) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsBackCollectionService.opComplete(form, loginSysUser);
	}

	// 状态流转为 红冲发票(69, "红冲发票")
	public void opRedWriteOff(String token, InvoiceInvoicedOpBackCollectionForm form) {
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsBackCollectionService.opRedWriteOff(form, loginSysUser);
	}

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



	public void opPartBatchByExcelImportLogStep01(String token, List<InvoiceInvoicedOpBackCollectionForm> formList){
		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);
		dubboInvoiceInvoicedFieldIsBackCollectionService.opPartBatchByExcelImportLogStep01(formList, loginSysUser);
	}
}
