Beispiel #1
0
        public void Execute(User currentUser)
        {
            var serialNo = SerialNoHelper.Create();

            using (var tran = TransactionHelper.BeginTransaction())
            {
                var liquidate = this.LiquidateService.GetById(LiquidateId);
                if (liquidate == null || liquidate.State != LiquidateStates.Processing)
                {
                    throw new Exception("没有找到相关的清算记录");
                }
                liquidate.State = LiquidateStates.Done;
                LiquidateService.Update(liquidate);

                var shop       = ShopService.GetById(ShopId);
                var rate       = shop.ShopDealLogChargeRate ?? HostSite.ShopDealLogChargeRate;
                var rateAmount = (liquidate.DealAmount * rate);
                var amount     = liquidate.DealAmount - liquidate.CancelAmount;

                var systemDealLog = new SystemDealLog(serialNo, currentUser)
                {
                    Addin     = liquidate.LiquidateId.ToString(),
                    Amount    = -amount,
                    DealType  = SystemDealLogTypes.ShopDealLogDone,
                    DealWayId = DealWayId,
                };
                SystemDealLogService.Create(systemDealLog);

                shop.Amount -= amount;
                var shopDealLog = new ShopDealLog(serialNo, DealTypes.ShopDealLogDone, -amount, null, null, null, shop,
                                                  systemDealLog.SystemDealLogId);
                ShopDealLogService.Create(shopDealLog);

                systemDealLog = new SystemDealLog(serialNo, currentUser)
                {
                    Addin     = liquidate.LiquidateId.ToString(),
                    Amount    = rateAmount,
                    DealType  = SystemDealLogTypes.ShopDealLogCharging,
                    DealWayId = DealWayId,
                };
                SystemDealLogService.Create(systemDealLog);

                shop.RechargingAmount += rateAmount;
                shopDealLog            = new ShopDealLog(serialNo, DealTypes.ShopDealLogDone, rateAmount, null, null, null, shop,
                                                         systemDealLog.SystemDealLogId);
                ShopDealLogService.Create(shopDealLog);

                var dealWay = DealWayService.GetById(this.DealWayId);
                if (dealWay.IsCash)
                {
                    CashDealLogService.Create(new CashDealLog(amount - rateAmount, currentUser.UserId, currentUser.UserId, CashDealLogTypes.ShopDealLogDone));
                }
                ShopService.Update(shop);
                tran.Commit();
            }
        }
Beispiel #2
0
        public IMessageProvider Save()
        {
            var serialNo = SerialNoHelper.Create();
            var item     = DealWayService.GetById(DealWayId);

            if (item == null)
            {
                AddError(LogTypes.DealWayEdit, "nonFoundDealWay");
                return(this);
            }
            TransactionHelper.BeginTransaction();
            OnSave(item);
            DealWayService.Update(item);
            AddMessage("success" /*, InnerObject.DisplayName*/);
            Logger.LogWithSerialNo(LogTypes.DealWayEdit, serialNo, InnerObject.DealWayId, InnerObject.DisplayName);
            return(TransactionHelper.CommitAndReturn(this));
        }
Beispiel #3
0
 public int Validates()
 {
     if (_account.OwnerId.HasValue)
     {
         _owner = MembershipService.GetUserById(_account.OwnerId.Value) as AccountUser;
     }
     _operatorUser = MembershipService.GetUserById(OperatorUserId);
     if (_operatorUser == null || !(_operatorUser is AdminUser))
     {
         return(ResponseCode.InvalidateUser);
     }
     _dealWay = DealWayService.GetById(this.HowToDeal);
     if (_dealWay == null || _dealWay.State != DealWayStates.Normal)
     {
         return(ResponseCode.InvalidateDealWay);
     }
     return(ResponseCode.Success);
 }
Beispiel #4
0
        public int Validate()
        {
            _account = AccountService.GetByName(AccountName);

            if (_account == null || (_account.State != AccountStates.Ready && _account.State != AccountStates.Saled))
            {
                return(ResponseCode.NonFoundAccount);
            }

            _operator = MembershipService.GetUserById(OperatorUserId) as AdminUser;
            if (_operator == null)
            {
                return(ResponseCode.InvalidateUser);
            }
            _dealWay = DealWayService.GetById(DealWayId);

            _accountType  = AccountTypeService.GetById(_account.AccountTypeId);
            _accountLevel = AccountLevelPolicyService.Query().FirstOrDefault(x => x.Level == 0 && x.State == States.Normal && x.AccountTypeId == _account.AccountTypeId);

            _dealLog = new DealLog(SerialNo, DealTypes.Open, -_account.Amount, 0, null, null, _account, null, 0);

            // 用户
            if (!string.IsNullOrEmpty(UserDisplayName))
            {
                _owner              = new AccountUser();
                _owner.DisplayName  = UserDisplayName;
                _owner.IdentityCard = Identify;
                _owner.BirthDate    = BirthDate;
                _owner.Mobile       = Mobile;
                if (!string.IsNullOrWhiteSpace(Mobile))
                {
                    _owner.IsMobileAvailable = true;
                }
                _owner.Gender = Gender;
            }

            return(ResponseCode.Success);
        }
Beispiel #5
0
        public void Read(int id)
        {
            DealWay obj = DealWayService.GetById(id);

            InnerObject = obj;
        }
Beispiel #6
0
 public void Read(int id)
 {
     this.SetInnerObject(DealWayService.GetById(id));
 }