const system = require("../../../system");
const applyDao = system.getObject("db.invoice.applyDao");
const invoiceDao = system.getObject("db.invoice.invoiceDao");
const delivererDao = system.getObject("db.invoice.delivererDao");
const common = require("./common");
//待审核 1060
module.exports.unAuditedForDeliverer=async (params)=>{
  console.log("待审核 1060");
  let obj = await common.delivererVerification(params);
  if(obj.status==-1){return obj;}
  let invoiceData = {}, applyData = {};
  invoiceData.status = params.nextStatus;
  invoiceData.id = params.id;
  if (params.invoiceNo) {
    invoiceData.invoiceNo = common.trim(params.invoiceNo);
  }
  if (params.invoiceTime) {
    invoiceData.invoiceTime = common.trim(params.invoiceTime);
  }
  if (params.invoiceImg) {
    invoiceData.invoiceImg = common.trim(params.invoiceImg);
  }
  applyData.status = params.nextStatus;
  applyData.id = params.id;
  await delivererDao.db.transaction(async (t) => {
    //更新申请表状态
    await applyDao.update(applyData, t);
    //更新发票表状态
    await invoiceDao.update(invoiceData, t);
  }).catch(error => {
    return system.getResult(null, `系统错误 错误信息 ${error}`);
  });
  return system.getResultSuccess();
}