productBundle.js 1.88 KB
module.exports = function (app) {

    app.get("/product/bundle/index", "product.productBundle.Index", function(req, res) {
        this.$extend = {
            moduleName: "营销管理",
            pageName: "套餐管理"
        }
    });

    app.get("/product/bundle/add", "product.productBundle.Edit", function(req, res) {
        this.$extend = {
            moduleName: "营销管理",
            pageName: "增加套餐",
            action: "/product/bundle/save"
        }
        
    });

    app.get("/product/bundle/import", "product.productBundle.Import", function(req, res) {
        this.$extend = {
            moduleName: "营销管理",
            pageName: "套餐导入"
        }
    });

    app.get("/product/bundle/:id", "product.productBundle.Edit", "productBundle_findProductBundleByID", function(apiReq) {

        // 日期处理
        apiReq.data.beginTimeStr = toDate(apiReq.data.startTime);
        apiReq.data.endTimeStr = toDate(apiReq.data.endTime);

        if (apiReq.data.productSkn) {
            apiReq.data.skns = apiReq.data.productSkn.split(",");
        }

        this.$extend = {
            moduleName: "营销管理",
            pageName: "编辑套餐",
            action: "/product/bundle/save",
            data: apiReq.data
        }
    });

    app.post("/product/bundle/list", "productBundle_productBundleList");

    app.post("/product/bundle/stop", "productBundle_productBundleStop");

    app.post("/product/bundle/save", "productBundle_productBundleSaveOrUpdate");

    app.post("/product/bundle/sync", "productBundle_syncProductBundleToFront");
    
}

function toDate(seconds) {
    if (!seconds || seconds <= 0) { return ''; }
    var date = new Date(seconds * 1000);
    return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate());
}

function fixTwo(number) {
    return number < 10? "0" + number: number;
}