const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");

class expressageService extends ServiceBase {
    constructor() {
        super("all", ServiceBase.getDaoName(expressageService));
    }

    async signPage(params) {
        var currentPage = Number(params.currentPage || 0);
        var pageSize = Number(params.pageSize || 10);

        var where = {};
        if (params.company_name) {
            where.company_name = {
                [this.db.Op.like]: "%" + params.company_name + "%"
            };
        }
        if(params.sign_body_id){
            where.sign_body_id = params.sign_body_id;
        }
        if(params.sign_body){
            where.sign_body = params.sign_body;
        }
        if(params.express_nu){
            where.express_nu = params.express_nu;
        }
        if(params.name){
            where.name = {
                [this.db.Op.like]: "%" + params.name + "%"
            };
        }
        this.addWhereTime(where, 'express_time', params.signBegin, params.signEnd, true);
        var orderby = [
            ["express_time", 'desc']
        ];
        var page = await this.getPageList(currentPage, pageSize, where, orderby);
        if (page && page.rows) {
            for (var row of page.rows) {
                let url = "https://www.kuaidi100.com/chaxun?com="+row.express_code+"&nu="+row.express_nu;
                row.url = url;
                this.handleDate(row, ["express_time"]);
            }
        }
        return page;
    }


}

module.exports = expressageService;
