2016-11-15 88 views
0

我不能似乎得到的回报工作。我已经指出了订单类型,但脚本只能识别交货类型。我希望使用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

你应该提供一个真正的[mcve]。该代码将无法编译,你还没有告诉我们,你是给什么样的输入功能,你还没有告诉我们您做了什么输出,而你还没有告诉我们,你期待什么样的输出。 – Quentin

+0

你的问题说'RETURNS',但你的代码检查'RETURN'也许这可能是你的问题。 –

回答

3

您的情况有误。 if (orderType == "NORMAL" || "C2C")始终为真(因为"C2C"的计算结果为true)。你可能想要的是:

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