---
title: "外贸加价算法"
author: "scholltop"
date: "2019-04-11T14:28:13Z"
tags: []
categories: ["数据库"]
slug: "untitled"
draft: false
lastmod: "2019-04-11T14:28:13Z"
id: 2439991
url: "https://schooltop.iteye.com/blog/2439991"
---

```ruby

usd_price = ( case  
                      when data.vendor_amount <= 500   
                      then  (data.vendor_amount + 200) / 6.7 + 9
                      when data.vendor_amount > 500 && data.vendor_amount <= 1500   
                      then  (data.vendor_amount + 300) / 6.7 + 9
                      when data.vendor_amount > 1500 && data.vendor_amount <= 3000   
                      then  (data.vendor_amount * 1.18) / 6.7 + 9
                      when data.vendor_amount > 3000 && data.vendor_amount <= 5000   
                      then  (data.vendor_amount * 1.15) / 6.7 + 9
                      when data.vendor_amount > 5000 && data.vendor_amount <= 7000   
                      then  (data.vendor_amount * 1.13) / 6.7 + 9
                      when data.vendor_amount > 7000 && data.vendor_amount <= 10000   
                      then  (data.vendor_amount * 1.10) / 6.7 + 9
                      end
                      ).to_i

```