예제 #1
0
파일: Wallet.cs 프로젝트: zanderphh/Shop
        public void AcceptNewShopCashTransfer(ShopCashTransfer shopCashTransfer)
        {
            var finallyValue = _shopCash;
            //业务逻辑判断
            ShopCashTransferInfo shopCashTransferInfo = shopCashTransfer.GetInfo();
            //统计信息
            var walletStatisticInfo = _walletStatisticInfo;

            if (shopCashTransferInfo.Direction == WalletDirection.Out)
            {
                if (_isFreeze)
                {
                    throw new Exception("钱包冻结,无法出账");
                }
                //如果是出账 判断账号余额是否够
                if (_shopCash < shopCashTransferInfo.Amount)
                {
                    throw new Exception("账户余额不足");
                }
                finallyValue -= shopCashTransferInfo.Amount;
            }
            else
            {
                //进账
                finallyValue += shopCashTransferInfo.Amount;
            }
            finallyValue = Math.Round(finallyValue, 2);
            //新的记录接受后,发出新记录接受的事件
            ApplyEvent(new NewShopCashTransferAcceptedEvent(_userId, shopCashTransfer.Id, finallyValue, walletStatisticInfo));
        }
예제 #2
0
 public ShopCashTransferCreatedEvent(Guid walletId, string number, ShopCashTransferInfo info, ShopCashTransferType type, ShopCashTransferStatus status) : base(walletId, number)
 {
     Info   = info;
     Type   = type;
     Status = status;
 }