sale.js 26.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695
/*
 * @Author: Targaryen
 * @Date:   2016-05-19 10:20:08
 * @Last Modified by:   Targaryen
 * @Last Modified time: 2016-06-20 21:13:00
 */

'use strict';
const api = global.yoho.API;
const Promise = require('bluebird');
const querystring = require('querystring');

const SaleApiModel = require('./sale-api');
const SearchApiModel = require('./search-api');

const publicHandler = require('./public-handler');
const saleHandler = require('./sale-handler');
const listHandler = require('./list-handler');
const seoHandler = require('./seo-handler');
const productProcess = require(`${global.utils}/product-process`);
const imageHandler = require(`${global.utils}/images`).getImageUrl;
const _ = require('lodash');
const headerModel = require('../../../doraemon/models/header');

const handleStaticUrl = require(`${global.utils}/parameter`).fullParamToMinPath;

const limitNum = 40; // 商品每页显示数目

// 下一页图片
const nextPageImg = '//img10.static.yhbimg.com/product/2014/01/15/11/01fa01614784f6239760f1b749663016f1.jpg?imageMogr2/thumbnail/235x314/extent/235x314/background/d2hpdGU=/position/center/quality/90'; // eslint-disable-line

/**
 * 资源位code码
 */
const contentCode = {
    boys: {
        sale: 'f6400250a73a2a1a8764a0d9be73abf2',
        breakCode: 'a97451680222cb1b215de14bbef64921',
        vip: '0400ac0dffbb2fefe84949200cf2be4a',
        newSale: '92a69093a2ce4fc44be36907f57b01ba'
    },
    girls: {
        sale: 'd74adc70f939a6658b68386ee39199e7',
        breakCode: '91e604f06449783a5bd93c6f4f99a396',
        vip: 'e261419fde3613781a3ec9d367a2e534',
        newSale: '1c4b4939334f7f01fea3fd2e0eb311b5'
    },
    kids: {
        sale: '01937a472a5a3ccf7204f734f2506865',
        breakCode: '4c1dff47c68aace0608eb821fbaf40fd',
        vip: '40db7c9a491548fa8d441815cc7a0617',
        newSale: '0f47d972d463822f77f19a3aa5f9e57e'
    },
    lifestyle: {
        sale: '32944e49d627a031f1d7e14a1f90ccac',
        breakCode: 'c605c9d2f1a426cecad232a7d41e6b97',
        vip: '6ac5f0ee1cf0f2dab89c9cf80263028a',
        newSale: '109cd4b3c9ac17e472f3dea22b92b24d'
    }
};

/**
 * 获取Sale首页商品列表数据 仅 Ajax 调用 Controller 调用
 * @return {[type]} [description]
 */
function getSaleGoodsData(params, vipLevel) {
    return this.saleApi.getSaleGoodsList(params).then(result => {
        let finalResult = {};

        if (result.code === 200) {
            finalResult.goods = productProcess.processProductList(result.data.product_list);
            _.forEach(finalResult.goods, (value, key) => {
                delete finalResult.goods[key].tags.isNew; // 屏蔽 new 标签
                delete finalResult.goods[key].tags.isSale;// 屏蔽 sale 标签
                delete finalResult.goods[key].discount; // 屏蔽折扣信息
            });
        }

        finalResult.goods = finalResult.goods || [];

        // 处理 VIP 商品数据
        if (params.saleType === '2') {
            _.forEach(finalResult.goods, (value, key) => {

                switch (_.toString(vipLevel)) {
                    case '1':
                        finalResult.goods[key].sales_price = value.vip1_price;
                        finalResult.goods[key].vip1 = true;
                        break;
                    case '2':
                        finalResult.goods[key].sales_price = value.vip2_price;
                        finalResult.goods[key].vip2 = true;
                        break;
                    case '3':
                        finalResult.goods[key].sales_price = value.vip3_price;
                        finalResult.goods[key].vip3 = true;
                        break;
                    default:
                        finalResult.goods[key].vip = true;
                        delete finalResult.goods[key].sales_price;
                        break;
                }
            });
        }

        // 需要判断是否为今日推荐,今日推荐需要添加最后的全部商品图片
        // 今日推荐没有 sort params 所以判断 sort 即可
        if (_.isEmpty(params.sort)) {

            // 2:VIP 会员专享 1:断码区
            switch (params.saleType) {
                case '5':
                    finalResult.goods.push({
                        thumb: '//cdn.yoho.cn/yohobuy-node/assets/img/sale/all-broken.jpg',
                        url: '/product/sale/breakingYards?channel=' + params.channel,
                        noFollow: true
                    });
                    break;
                case '2':
                    finalResult.goods.push({
                        thumb: '//cdn.yoho.cn/yohobuy-node/assets/img/sale/all-vip.jpg',
                        url: '/product/sale/vip?channel=' + params.channel,
                        vipPicture: true, // 为了处理首页最后一张图片
                        noFollow: true
                    });
                    break;
                case '0':
                    finalResult.goods.push({
                        thumb: '//cdn.yoho.cn/yohobuy-node/assets/img/sale/all-sale.jpg',
                        url: '/product/sale/newSale?channel=' + params.channel,
                        noFollow: true
                    });
                    break;
                default:
                    break;
            }
        }

        return finalResult;
    });
}

/**
 * 获取 Sale 首页数据 Controller 调用
 * @return {[type]} [description]
 */
function getSaleIndexData(channel) {
    return api.all([
        headerModel.requestHeaderData(channel),
        this.saleApi.getSaleActivityList('', channel),
        this.saleApi.getSaleBannerList(contentCode[channel].sale),
        this.saleApi.getSaleGoodsList({channel: channel, saleType: '2', limit: '1'}), // 会员专享分类
        this.saleApi.getSalebreakingYardsSortList({channel: channel}), // 断码区尺码数据
        this.saleApi.getSaleGoodsList({channel: channel, limit: '1'}) // 最新降价分类
    ]).then(async result => {
        var finalResult = result[0];

        // 折扣专场活动处理
        if (result[1].code === 200) {
            if (result[1].data.length > 0) {
                finalResult.brandSale = saleHandler.handleSaleActivityData(result[1].data, channel);
            }
        }

        // 资源位数据处理
        if (result[2].code === 200 && !_.isEmpty(result[2].data)) {
            finalResult.topBanner = saleHandler.handleSaleBannerData(result[2].data);
            finalResult.activityEnter = saleHandler.handleSaleBannerSmallData(result[2].data);
        }

        // 分类处理
        finalResult.saleCategory = [];

        // 会员专享分类处理
        if (result[3].code === 200) {
            finalResult.saleCategory.push(
                Object.assign(
                    saleHandler.handleSaleCategoryData(result[3].data.filter.group_sort, '2', channel),
                    {forVip: true}
                )
            );
        }

        // 断码区分类处理
        if (result[4].code === 200) {
            let breakingSizeSort = saleHandler.handleSaleBreakingSizeData(result[4].data);

            let subResult = await this.saleApi.getSaleGoodsList({
                channel: channel,
                saleType: '5', // app 与 pc 有冲突,为 PC 加一个 5 的选项
                limit: '1',
                breakSize: breakingSizeSort.breakSize,
                breakSort: breakingSizeSort.breakSort
            });

            if (subResult.code === 200) {
                finalResult.saleCategory.push(
                    saleHandler.handleSaleCategoryData(
                        subResult.data.filter.group_sort,
                        '5',
                        channel,
                        breakingSizeSort
                    )
                );
            }
        }

        // 最新降价分类处理
        if (result[5].code === 200) {
            finalResult.saleCategory.push(
                saleHandler.handleSaleCategoryData(result[5].data.filter.group_sort, '3', channel)
            );
        }


        let saleGoods = await Promise.all(_.cloneDeep(finalResult.saleCategory).map(value => {
            return this.getSaleGoodsData(querystring.parse(_.trim(value.urlLocation, '?')));
        }));

        _.zipWith(finalResult.saleCategory, saleGoods, function(category, goods) {
            category.defaultGoods = goods.goods || [];
            return category;
        });

        return finalResult;
    });
}

/**
 * 获取 VIP 会员专享和新降价专区数据 Controller 调用
 * @return {[type]} [description]
 */
function getSaleOthersData(params, channel) {
    let promiseObject;
    let baseUrl = `/${_.toLower(channel)}-sale`;

    params = params || {};

    if (params.saleType === '2') { // 会员专区
        promiseObject = [
            headerModel.requestHeaderData(channel),
            this.saleApi.getSaleGoodsList(params),
            this.saleApi.getSaleBannerList(contentCode[channel].vip),
            this.saleApi.getSaleGoodsList({saleType: '2', limit: '1', channel: channel}),
            this.saleApi.getUserProfile(params.uid)
        ];
        baseUrl += '/vip';
    } else { // 罪行降价
        promiseObject = [
            headerModel.requestHeaderData(channel),
            this.saleApi.getSaleGoodsList(params),
            this.saleApi.getSaleBannerList(contentCode[channel].newSale),
            this.saleApi.getSaleGoodsList({limit: '1', channel: channel})
        ];
        baseUrl += '/newSale';
    }

    return api.all(promiseObject).then(result => {
        let finalResult = result[0];

        // 获取商品数据
        if (result[1].code === 200) {
            finalResult.goods = productProcess.processProductList(result[1].data.product_list);

            if (!_.isEmpty(result[1].data.filter)) {
                // 顶部筛选条件
                finalResult.filters = publicHandler.handleSaleFilterData(result[1].data.filter, params, baseUrl);
            }

            // 处理排序数据
            finalResult.opts = publicHandler.handleSaleOptsData(params, result[1].data.total, '', baseUrl);
            finalResult.totalCount = result[1].data.total;
            finalResult.footPager = listHandler.handlePagerData(finalResult.totalCount, params, true, baseUrl);

            // 处理所有商品标题数据
            finalResult.saleTitle = {
                name: '所有商品',
                count: result[1].data.total
            };

            _.forEach(finalResult.goods, (value, key) => {
                delete finalResult.goods[key].tags.is_new; // 屏蔽 new 标签
                delete finalResult.goods[key].tags.is_sale;// 屏蔽 sale 标签
                delete finalResult.goods[key].discount; // 屏蔽折扣信息
            });
        }

        // 获取焦点图数据
        if (result[2].code === 200) {
            finalResult.topBanner = saleHandler.handleSaleBannerData(result[2].data);
            if (params.saleType !== '2') {
                _.forEach(finalResult.topBanner.list, (value, key) => {
                    delete finalResult.topBanner.list[key].href;
                });
            }
        }

        // 获取分类筛选数据
        if (result[3].code === 200) {

            // 获取左侧类目数据
            finalResult.leftContent = publicHandler.handleSaleSortData(result[3].data.filter.group_sort,
                params, '', baseUrl);

        }

        if (!_.isEmpty(result[4])) {
            // 处理 VIP 商品数据
            if (result[4].code === 200 && parseInt(params.saleType, 10) === 2) {
                let vipInfo = _.get(result, '[4].data.vip_info', {});

                _.forEach(finalResult.goods, (value, key) => {

                    switch (vipInfo.cur_level) {
                        case '1':
                            finalResult.goods[key].sales_price = value.vip1_price;
                            finalResult.goods[key].vip1 = true;
                            break;
                        case '2':
                            finalResult.goods[key].sales_price = value.vip2_price;
                            finalResult.goods[key].vip2 = true;
                            break;
                        case '3':
                            finalResult.goods[key].sales_price = value.vip3_price;
                            finalResult.goods[key].vip3 = true;
                            break;
                        default:
                            finalResult.goods[key].vip = true;
                            delete finalResult.goods[key].sales_price;
                            break;
                    }
                });
            }
        }

        const sortList = _.get(finalResult, 'leftContent.allSort.list');
        const checkedList = _.get(finalResult, 'filters.checkedConditions.conditions');

        Object.assign(finalResult, listHandler.handleListPathNavData(sortList, checkedList,
            params, channel, baseUrl));

        if (finalResult.pathNav) {
            if (finalResult.pathNav.length < 2) { // 无参数添加店铺名
                finalResult.pathNav.push({
                    name: params.saleType === '2' ? 'VIP会员' : '降价优选',
                    useH1: true
                });
            }
        }

        finalResult.seo = seoHandler.getSaleListSeo(sortList, checkedList,
            params.saleType === '2' ? 'vip' : 'newSale');

        return finalResult;
    });
}


/**
 * 设置折扣专场TDK
 * @return {[object]} [tdk]
 */
function _setSaleDiscountData(info) {
    let title = _.get(info, 'saleTitle.title', '');
    let keyWordsArr = [title];

    _.forEach(_.get(info, 'leftContent.allSort.list', []), value => {
        keyWordsArr.push(`潮流折扣${value.name}`);
    });

    return {
        title: `【${title}】潮流折扣商品|YOHO!BUY 有货`,
        keywords: _.take(keyWordsArr, 5).join(','),
        description: `有货网为您提供大量${title}商品,支持货到付款,质量保证,让您全面了解${title}商品价格、品牌、图片、折扣等方面信息,想网购${title}商品就上有货网!`  // eslint-disable-line
    };
}

/**
 * 获取折扣专场数据 Controller 调用
 * @return {[type]} [description]
 */
function getSaleDiscountData(params, channel) {
    return api.all([
        headerModel.requestHeaderData(channel),
        this.saleApi.getSaleActivityList(params, channel)
    ]).then(result => {
        let finalResult = result[0];
        const baseUrl = `/${_.toLower(channel)}-sale/discount`;

        // 默认order: ''
        if (_.isEmpty(params.order)) {
            Object.assign(params, {order: ''});
        }

        // 处理折扣专场标题 banner 数据
        if (result[1].code === 200) {
            if (_.size(result[1].data) === 1) {
                finalResult.saleTitle = saleHandler.handleDiscountTitleData(result[1].data[0]);
                if (result[1].data[0].web_url) {
                    finalResult.topBanner = {
                        list: [
                            {
                                img: result[1].data[0].web_url
                            }
                        ]
                    };
                }
            }

            // 这里把 channel 全都处理掉,因为根据channel查小分类,而传入商品池时,不需要
            return api.all([
                this.saleApi.getSaleGoodsList({
                    channel: null,
                    saleType: '3',
                    limit: '1',
                    productPool: result[1].data[0].product_pool
                }),
                this.saleApi.getSaleGoodsList(Object.assign({}, params, {
                    channel: null,
                    productPool: result[1].data[0].product_pool
                }))
            ]).then(subResult => {
                // 删除无用参数
                _.unset(params, 'channel');
                _.unset(params, 'saleType');

                // 处理分页等筛选信息
                if (subResult[0].code === 200) {
                    Object.assign(finalResult, {
                        leftContent: publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort,
                            params, 'discount', baseUrl),
                        saleList: {
                            footPager: listHandler.handlePagerData(subResult[0].data.total, params, true, baseUrl),
                            opts: publicHandler.handleSaleOptsData(params, subResult[0].data.total, 'default', baseUrl)
                        }
                    });
                }

                // 处理商品数据,顶部分类
                if (subResult[1].code === 200) {
                    let sknArr = [];

                    finalResult.saleList.goods = productProcess.processProductList(subResult[1].data.product_list);
                    finalResult.saleList.totalCount = subResult[1].data.total;
                    _.forEach(finalResult.saleList.goods, (value, key) => {
                        if (sknArr.length < 3) {
                            sknArr.push(value.product_skn);
                        }
                        delete finalResult.saleList.goods[key].tags.is_new; // 屏蔽 new 标签
                        delete finalResult.saleList.goods[key].tags.is_sale;// 屏蔽 sale 标签
                        delete finalResult.saleList.goods[key].discount; // 屏蔽折扣信息
                    });

                    finalResult.criteo = {skn: sknArr}; // 重要:推广列表前三个商品Skn
                }

                finalResult.seo = _setSaleDiscountData(finalResult);

                return finalResult;
            });
        }
        return finalResult;
    });
}

/**
 * 获取断码区数据 Controller 调用
 * @param params
 * @param channel
 * @returns {*|Promise.<TResult>}
 */
function getSalebreakingYardsData(params, channel) {
    const baseUrl = `/${_.toLower(channel)}-sale/breakingYards`;

    return api.all([
        headerModel.requestHeaderData(channel),
        this.saleApi.getSaleBannerList(contentCode[channel].breakCode),
        this.saleApi.getSalebreakingYardsSortList(params)
    ]).then(result => {
        let finalResult = result[0];

        // 处理 banner 数据
        if (result[1].code === 200) {
            finalResult.topBanner = saleHandler.handleSaleBannerData(result[1].data);
            _.forEach(finalResult.topBanner.list, (value, key) => {
                delete finalResult.topBanner.list[key].href;
            });
        }

        // 断码区产品筛选需要断码区尺码数据,改为串行处理
        if (result[2].code === 200) {
            let breakingSizeSort = saleHandler.handleSaleBreakingSizeData(result[2].data);
            let breakParam = {}; // 为断码区筛选参数存储,为了不影响 params ,否则会导致链接过长

            if (params.sort) {
                Object.assign(breakParam, params);
            } else {
                Object.assign(breakParam, params, {
                    breakSize: breakingSizeSort.breakSize,
                    breakSort: breakingSizeSort.breakSort
                });
            }

            return api.all([
                this.saleApi.getSaleGoodsList({
                    channel: channel,
                    saleType: '5', // app 与 pc 有冲突,为 PC 加一个 5 的选项
                    limit: '1',
                    breakSize: breakingSizeSort.breakSize,
                    breakSort: breakingSizeSort.breakSort
                }),
                this.saleApi.getSaleGoodsList(breakParam)
            ]).then(subResult => {
                // 处理筛选条件数据
                if (subResult[0].code === 200) {
                    finalResult.leftContent =
                        publicHandler.handleSaleSortData(subResult[0].data.filter.group_sort,
                            params, '', baseUrl);
                }

                // 处理商品数据
                if (subResult[1].code === 200) {

                    if (!_.isEmpty(subResult[1].data.filter)) {
                        finalResult.filters = publicHandler.handleSaleFilterData(
                            Object.assign(subResult[1].data.filter, {size: result[2].data}),
                            params, baseUrl);
                    }
                    Object.assign(finalResult, {
                        goods: productProcess.processProductList(subResult[1].data.product_list),
                        opts: publicHandler.handleSaleOptsData(params, subResult[1].data.total, '', baseUrl),
                        totalCount: subResult[1].data.total,
                        footPager: listHandler.handlePagerData(subResult[1].data.total, params, true, baseUrl)
                    });

                    // 处理所有商品标题数据
                    finalResult.saleTitle = {
                        name: '所有商品',
                        count: subResult[1].data.total
                    };

                    _.forEach(finalResult.goods, (value, key) => {
                        delete finalResult.goods[key].tags.is_new; // 屏蔽 new 标签
                        delete finalResult.goods[key].tags.is_sale;// 屏蔽 sale 标签
                        delete finalResult.goods[key].discount; // 屏蔽折扣信息
                    });
                }

                const sortList = _.get(finalResult, 'leftContent.allSort.list');
                const checkedList = _.get(finalResult, 'filters.checkedConditions.conditions');

                Object.assign(finalResult, listHandler.handleListPathNavData(sortList, checkedList,
                    params, channel, baseUrl));

                if (finalResult.pathNav) {
                    if (finalResult.pathNav.length < 2) { // 无参数添加店铺名
                        finalResult.pathNav.push({
                            name: '断码特辑',
                            useH1: true
                        });
                    }
                }

                finalResult.seo = seoHandler.getSaleListSeo(sortList, checkedList, 'breakingYards');

                return finalResult;
            });
        } else {
            return Promise.reject();
        }
    });
}


/**
 * 获取sale活动数据(原sale.yohobuy.com)
 * @param params
 * @param channel
 * @returns {*|Promise.<TResult>}
 */
function getSaleSpecialData(id, params, channel) {
    const page = params.page || 1;
    const defaultParam = {specialsale_id: id};
    const baseUrl = '/sale/special';

    params.limit = params.limit || limitNum;

    const limit = params.limit - 1;  // 最后一个商品是翻页

    return this.saleApi.getSaleSpecialAsync(id).then(special => {
        let resData = {
                latestWalk: 6
            },
            apiList = [
                headerModel.requestHeaderData(channel),
                this.searchApi.getSortList(defaultParam)
            ];

        if (special && special.data) {
            let data = special.data,
                condition = Object.assign({}, params, {
                    page: page,
                    limit: limit,
                    attribute_not: 2
                });
            let banner = data.banner_img ? JSON.parse(data.banner_img) : [];

            Object.assign(resData, {
                mainBanner: {
                    src: imageHandler(_.get(banner, '[0].img', ''), 1920, 350, 1, 'couponImg')
                },
                specialHead: {
                    title: '全部商品',
                    count: 0
                },
                node: data.left_ad_code // 水牌node
            });

            // // 传品牌ID参数
            // if (data.brand_id) {
            //     condition.brand = data.brand_id;
            // }

            // 传促销id,促销id为空时传专区id
            if (data.ispromotion) {
                condition.promotion = data.ispromotion;
            }

            // 搜索sale活动商品
            apiList.push(this.searchApi.getProductList(condition, 'promotion'));
        }

        return Promise.all(apiList).then(result => {
            if (!_.isEmpty(result[0])) {
                resData.headerData = Object.assign(result[0].headerData, {header: true});
            }

            if (!_.isEmpty(result[1])) {
                resData.leftContent = listHandler.handleSortData(_.get(result[1],
                    'data', []), defaultParam, params, baseUrl);
            }

            if (!_.isEmpty(result[2])) {
                const total = _.get(result[2], 'data.total', 0);

                resData.specialHead.count = total;
                Object.assign(resData, {
                    filters: listHandler.handleFilterData(_.get(result[2], 'data', {}), params, baseUrl),
                    opts: listHandler.handleOptsData(params, total, {}, baseUrl),
                    goods: productProcess.processProductList(_.get(result[2], 'data.product_list', []),
                        {from: {type: 'saleSpecial', params: params}}),
                    footPager: listHandler.handlePagerData(total, params, false, baseUrl)
                });

                if (_.has(resData, 'filters.checkedConditions')) {
                    _.set(resData, 'filters.checkedConditions.clearUrl',
                        handleStaticUrl(baseUrl, {specialsale_id: id}));
                }

                if (_.get(resData, 'footPager.nextPage')) {
                    resData.hasNextPage = {
                        href: _.get(resData, 'footPager.nextPage.url', ''),
                        src: nextPageImg
                    };
                }
            }

            let specialName = _.get(special, 'data.special_name', '活动专区');

            Object.assign(resData, {
                title: `${specialName}|限时折扣|YOHO!BUY有货`,
                keywords: `${specialName},限时折扣,折扣商品`,
                description: `有货网为您带来限时${specialName},大量限时折扣商品,优惠幅度大,支持货到付款,让您全面了解限时${specialName}商品价格、品牌、图片、折扣等方面信息,想网购限时${specialName}商品就上有货网!` // eslint-disable-line
            });

            return resData;
        });
    });
}

module.exports = class extends global.yoho.BaseModel {
    constructor(ctx) {
        super(ctx);

        this.saleApi = new SaleApiModel(ctx);
        this.searchApi = new SearchApiModel(ctx);

        this.getSaleGoodsData = getSaleGoodsData.bind(this);
        this.getSaleIndexData = getSaleIndexData.bind(this);
        this.getSaleOthersData = getSaleOthersData.bind(this);
        this.getSaleDiscountData = getSaleDiscountData.bind(this);
        this.getSalebreakingYardsData = getSalebreakingYardsData.bind(this);
        this.getSaleSpecialData = getSaleSpecialData.bind(this);
    }
};