无法使RETURNS功能起作用

时间:2016-11-15 10:00:40

标签: javascript

我似乎无法让RETURNS工作。我已经指出了订单类型,但脚本只识别交货类型。我希望使用STANDARD参数将退货定价为+20。

我该如何解决?看起来它没有读取我为退货设置的“订单类型”参数!

function calculate(deliveryType, orderType, timeslotType, size, weight, fromZone, toZone) {

    var price = 0.0

    var params = {
        from: fromZone.getBillingZone(),
        to: toZone.getBillingZone()
    }

    var record = undefined

    if (orderType == "NORMAL" || "C2C") {

        record = util.zones.findRecord(deliveryType, params)

        if (size == "S") {
            return record.pouchRate
        }

    } else if (orderType == "RETURN") {

        record = util.zones.findRecord("STANDARD", params)

    } else {
        throw "Unknown order type " + orderType
    }

    if (deliveryType == "STANDARD") {
        price = price
    }

    if (deliveryType == "EXPRESS") {
        price = price
    }

    if (orderType == "RETURN") {
        price = price + 20.0
    }

    return price

    var standardCSV = expressCSV = [{
        "from": "else",
        "to": "else",
        "pouchRate": 50.0
    }, {
        "from": "else",
        "to": "there",
        "pouchRate": 60.0
    }]

    var nextDayCSV = [{
        "from": "else",
        "to": "else",
        "pouchRate": 70.0
    }]

    var sameDayCSV = [{
        "from": "else",
        "to": "else",
        "pouchRate": 90.0
    }]

1 个答案:

答案 0 :(得分:3)

你的条件错了。 if (orderType == "NORMAL" || "C2C")始终为true(因为"C2C"的计算结果为true)。你可能想要的是:

if (orderType == "NORMAL" || orderType == "C2C")