@param Money $money

@return Money
@throws CurrencyMismatchException
508101
public function add(Money $money) : Money
    {
        $this->verifySameCurrency(__METHOD__, $money);

        return new Money($this->amount + $money->amount, $this->currency);
    }
1268295
public function setCurrency(string $currency): self
    {
        $this->isValidCurrency($currency);

        $this->currency = $currency;

        return $this;
    }
330836
public function convert(Money $money, Currency $counterCurrency, $roundingMode = Money::ROUND_HALF_UP)
    {
        $baseCurrency = $money->getCurrency();
        $ratio = $this->exchange->quote($baseCurrency, $counterCurrency)->getConversionRatio();

        $baseCurrencySubunit = $this->currencies->subunitFor($baseCurrency);
        $counterCurrencySubunit = $this->currencies->subunitFor($counterCurrency);
        $subunitDifference = $baseCurrencySubunit - $counterCurrencySubunit;

        $ratio = (string) Number::fromFloat($ratio)->base10($subunitDifference);

        $counterValue = $money->multiply($ratio, $roundingMode);

        return new Money($counterValue->getAmount(), $counterCurrency);
    }
137498
private static function getCoin($money, $currency = 'CNY')
    {
        $coin = $money;
        if ($currency == 'CNY') {//10比1
            if ($money >= 200 && $money < 500) {
                $coin += $coin * 0.5;
            } else if ($money >= 500) {//冲多少送多少
                $coin += $coin;
            }
        } else if ($currency == 'USD') {//2比1
            if ($money >= 20) {
                $coin += $coin * 0.1;
            } else if ($money >= 50 && $money < 100) {
                $coin += $coin * 0.2;
            } else if ($money >= 100) {//冲多少送多少
                $coin += $coin;
            }
        }
        //test
        if ($money == 0.01) {
            $coin = 0.01;
        }
        return $coin;
    }
169862
public function subtract(Money $subtrahend)
    {
        $this->assertSameCurrency($subtrahend);

        return new Money(bcsub($this->amount, $subtrahend->getAmountString(), self::GAAP_PRECISION), $this->currency);
    }
1307920
public function money($amount, $decimals = 2, $sourceCurrency = null)
    {
        return str_replace(
            ['{number}', '{currency}'],
            [$this->number($decimals), $this->currency()],
            $this->get('money')['format']
        );
    }
496620
public function equals(Money $money)
  {
    return $this->isSameCurrency($money) && $this->cents == $money->cents;
  }
661474
public function create($amount, $currency)
    {
        $result = new Money($amount, $currency);
        $this->validator->validateMoney($result);
        return $result;
    }
1179969
public function setCurrency($currency)
    {
        if ($currency) {
            $currency = strtoupper($currency);
            Currency::getNumericCode($currency); // ensure currency support
            $this->currency = $currency;
        } else {
            $this->currency = null;
        }

        return $this;
    }
22732
public function formatMoney(Money $value)
    {
        $currencies = new ISOCurrencies();
        $moneyFormatter = new DecimalMoneyFormatter($currencies);

        return $moneyFormatter->format($value);
    }
90990
public function equals(Money $money)
    {
        return $this->isSameCurrency($money) &&
            $this->amount->equals($money->amount, $this->getInnerPrecision());
    }
948789
public function compare(Money $other)
    {
        $this->assertSameCurrency($other);

        return $this->getCalculator()->compare($this->amount, $other->amount);
    }
1212330
public function setTotalPrice(Money $money = null): OrderInterface
    {
        $this->totalPrice = $money->getAmount();

        return $this;
    }
886662
public function subtract(MoneyContainer $money) : MoneyBag
    {
        foreach ($money->getAmounts() as $currencyCode => $amount) {
            $this->amounts[$currencyCode] = $this->getAmount($currencyCode)->minus($amount);
        }

        return $this;
    }
26387
def convert_money(self, money: Money, to: str, reverse: bool=False) -> Money:
        """"""
        converted = self.convert(money.amount, money.currency, to, reverse)
        return Money(converted, to)
387542
public function equals(Money $money)
    {
        if (!$this->currency->equals($money->getCurrency())) {
            return false;
        }

        return (0 == $this->compare($money));
    }
1162544
public function setGiftCertificateAmount(Money $money = null): OrderInterface
    {
        $this->giftCertificateAmount = $money->getAmount();

        return $this;
    }