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

import cn.hutool.core.date.DateUtil;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.common.security.JwtUtil;
import cn.superdesk.uniorder.common.security.dto.LoginSysUser;
import cn.superdesk.uniorder.dao.entity.invoice.customer.InvoiceApply;
import cn.superdesk.uniorder.dao.entity.invoice.customer.fundrestream.InvoiceBankStatement;
import cn.superdesk.uniorder.dao.entity.invoice.customer.fundrestream.InvoiceBankStatementOff;
import cn.superdesk.uniorder.dto.vo.unified.UnifiedInvBankOffVo;
import cn.superdesk.uniorder.dubbo.facade.invoice.customer.fundrestream.DubboInvoiceBankStatementOffService;
import com.alibaba.dubbo.config.annotation.Reference;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @Description: 核销
 * @Author: linjinyu 补充 修改
 * @CreateDate: 4/28/20 2:31 PM
 * @UpdateUser: linjinyu
 * @UpdateDate: 4/28/20 2:31 PM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@Component
public class InvoiceBankStatementOffDubboConsumerService {

	@Reference(version = "1.0.0", timeout = 30000, retries = -1)
	private DubboInvoiceBankStatementOffService dubboInvoiceBankStatementOffService;

	public List<InvoiceBankStatement> getInvoiceBankData(Map<String, Object> params) {
		return dubboInvoiceBankStatementOffService.getInvoiceBankData(params);
	}

	public List<InvoiceApply> getInvoiceApplyData(Map<String, Object> params) {
		return dubboInvoiceBankStatementOffService.getInvoiceApplyData(params);
	}

	/**
	 * 收款核销-回款登记-opt 提交
	 *
	 * @param token
	 * @param param
	 * @return
	 */
	public Map<String, Object> addObjTran(String token, InvoiceBankStatementOff param) {

		LoginSysUser loginSysUser = JwtUtil.getLoginSysUser(token);

		param.setCreateUserId(loginSysUser.getSysUserId());
		param.setCreateTime(DateUtil.date());

		return dubboInvoiceBankStatementOffService.addObjTran(param);
	}

	public R<List<UnifiedInvBankOffVo>> getInvoiceBankOffDataByPage(String token, Map<String, Object> params, int pageNum, int pageSize) {
		return dubboInvoiceBankStatementOffService.getInvoiceBankOffDataByPage(params, pageNum, pageSize);
	}
}
