var APIBase = require("../../api.base");
var system = require("../../../system");

class TestAPI extends APIBase {
  constructor() {
    super();
    this.orderSve = system.getObject("service.saas.orderSve");
    this.invocieSve = system.getObject("service.saas.orderSve");
  }

  async statusNotify(pobj, query, req) {
    if (!pobj.source_no) {
      return system.getResult(null, "订单号不存在");
    }
    if (pobj.status == "1190") {
      let data = {
        id: pobj.source_no,
        sve_deliver_express_no: pobj.guest_mail_no,
        sve_deliver_express_img: pobj.guest_mail_img
      };
      // 客户交付交付订单状态是1190时的推送信息
      return await this.orderSve.sveDeliver(data);
    } else if (pobj.status == "1000000" || "2000000") {  //建账信息
      let res = await this.orderSve.sveBusinessmen(pobj);
      return res;
    }else if(pobj.status="3000000"){
      //发票完成推送
      let res = await this.invoiceSve.saveSaasInvoice(pobj);
      return res;
    }
    return pobj;
  }

  exam() {
    return "";
  }

  classDesc() {
    return {
      groupName: "",
      groupDesc: "",
      name: "",
      desc: "",
      exam: "",
    };
  }

  methodDescs() {
    return [
      {
        methodDesc: "",
        methodName: "",
        paramdescs: [
          {
            paramDesc: "",
            paramName: "",
            paramType: "",
            defaultValue: "",
          }
        ],
        rtnTypeDesc: "",
        rtnType: ""
      }
    ];
  }
}

module.exports = TestAPI;