Sha256: fdce93a8a0156476b5274d234028178380b529aa6a11356e976946da8b065a84
Contents?: true
Size: 528 Bytes
Versions: 1
Compression:
Stored size: 528 Bytes
Contents
# 折扣价格 module Trade module Model::PromoteCharge::DiscountPromoteCharge # 用户输入参数可为 # 正数的折扣,原价 * 折扣, 如 100 * 0.7, parameter 为0.7 # 负数的折扣,原价 * (1+折扣),如 100 * (1-0.3), parameter 为 -0.3 def final_price(amount) if parameter < 0 && parameter > -1 (amount * parameter).round(2) elsif parameter > 0 && parameter < 1 -(amount * (1 - parameter)).round(2) else amount end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_trade-0.0.3 | app/models/trade/model/promote_charge/discount_promote_charge.rb |