Ejemplo n.º 1
0
        public void Ready()
        {
            LiquidateId = Id;
            _hasError   = true;
            Liquidate   = LiquidateService.GetById(Id);
            State       = ModelHelper.GetBoundText(Liquidate, x => x.State);
            var currentUser = SecurityHelper.GetCurrentUser().CurrentUser;
            var shop        = ShopService.GetById(Liquidate.ShopId);

            var rate = shop.ShopDealLogChargeRate ?? HostSite.ShopDealLogChargeRate;

            RateAmount   = (Liquidate.DealAmount * rate);
            Amount       = (Liquidate.DealAmount - Liquidate.CancelAmount) - RateAmount;
            Formula      = string.Format("({0} - {1}) - {0} * {2}", Liquidate.DealAmount, Liquidate.CancelAmount, rate.ToString("P"));
            DealAmount   = Liquidate.DealAmount;
            CancelAmount = Liquidate.CancelAmount;
            Count        = Liquidate.Count;

            var ids = Liquidate.DealIds.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToArray();

            Items = new ItemList <ListShopDealLog>(this.ShopDealLogService.GetByIds(ids).Select(x => new ListShopDealLog(x)));

            CashAmount = CashDealLogService.GetSummary(currentUser.UserId);


            var dealways = from x in DealWayService.Query()
                           where new ApplyToModel(x.ApplyTo).EnabledShopDealAccount
                           select new IdNamePair {
                Key = x.DealWayId, Name = x.DisplayName
            };

            this.DealWay.Bind(dealways);
            this.DealWay.IsReadOnly = this.Liquidate.State == LiquidateStates.Done;
            _hasError = false;
        }
Ejemplo n.º 2
0
        public void Ready()
        {
            this.Bank.Bind(HostSite.GetBanks());
            var idNamePairs = DealWayService.Query().Where(x => x.State == DealWayStates.Normal && new ApplyToModel(x.ApplyTo).EnabledShop).Select(x => new IdNamePair()
            {
                Key = x.DealWayId, Name = x.DisplayName
            });

            this.DealWay.Bind(idNamePairs);

            if (this._owner != null)
            {
                Mobile.Value1 = _owner.Mobile;
                Mobile.Value2 = _owner.Mobile2;
            }
            Mobile.HasBinding       = !string.IsNullOrWhiteSpace(HostSite.MessageTemplateOfIdentity);
            this.PhoneNumber.Value1 = InnerObject.PhoneNumber;
            this.PhoneNumber.Value2 = InnerObject.PhoneNumber2;
        }
Ejemplo n.º 3
0
 public void Ready()
 {
     DealWays = DealWayService.Query().Where(x => x.State == DealWayStates.Normal && new ApplyToModel(x.ApplyTo).EnabledRecharging).ToList();
 }
Ejemplo n.º 4
0
 public void Ready()
 {
     Sales    = MembershipService.GetSales().ToList();
     DealWays = DealWayService.Query().Where(x => x.State == DealWayStates.Normal && new ApplyToModel(x.ApplyTo).EnabledOpenAccount).ToList();
 }
Ejemplo n.º 5
0
        public AccountServiceResponse Save()
        {
            var    serialNo  = SerialNoHelper.Create();
            string password1 = "";
            string password2 = "";

            var passSvc = UnityContainer.Resolve <IPasswordService>(HostSite.PasswordType);

            passSvc.Decrypto(Password, PasswordConfirm, out password1, out password2);

            if (!string.IsNullOrEmpty(password1) || !string.IsNullOrEmpty(password2))
            {
                if (password1 != password2)
                {
                    return(new OpenAccountServiceResponse(ResponseCode.SystemError)
                    {
                        CodeText = "两次密码输入不一致"
                    });
                }
            }
            string accountName  = AccountName.TrimSafty();
            var    operatorUser = SecurityHelper.GetCurrentUser().CurrentUser;

            //try
            //{
            //    if (CodeHelper.GetObject<string>("sms") != Code || CodeHelper.GetObject<string>("sms_mobile") != Mobile)
            //    {
            //        Mobile = "";
            //    }
            //}
            //catch
            //{

            //}
            if (!string.IsNullOrWhiteSpace(Mobile))
            {
                User u = MembershipService.GetByMobile(Mobile);
                if (u != null)
                {
                    return(new AccountServiceResponse(-1)
                    {
                        CodeText = "手机号已绑定"
                    });
                }
            }

            var command = new OpenAccountCommand(serialNo, accountName, password1, DisplayName, BirthDate, IsActived, HowToDeal, Identify, Remark1, operatorUser.UserId, SaleId, Gender, Mobile);

            UnityContainer.BuildUp(command);
            int code = command.Validate();

            if (code != ResponseCode.Success)
            {
                return(new AccountServiceResponse(code));
            }

            TransactionHelper.BeginTransaction();

            command.Execute(operatorUser);
            decimal?saleFee = 0m;

            if (command.AccountType != null)
            {
                saleFee = HostSite.SaleCardFee;
                // 手续费
                //
                if (saleFee != null && saleFee.Value != 0m)
                {
                    var account = AccountService.GetByName(accountName);
                    account.ChargingAmount += saleFee.Value;
                    AccountService.Update(account);
                    var d             = DealWayService.Query().FirstOrDefault(x => x.State == DealWayStates.Normal);
                    var systemDealLog = new SystemDealLog(serialNo, operatorUser)
                    {
                        Amount = saleFee.Value, DealWayId = (d == null ? 0 : d.DealWayId), DealType = SystemDealLogTypes.SaldCardFee, Addin = account.AccountId.ToString()
                    };
                    SystemDealLogService.Create(systemDealLog);
                    if (d.IsCash)
                    {
                        CashDealLogService.Create(new CashDealLog(systemDealLog.Amount, 0, operatorUser.UserId, systemDealLog.DealType));
                    }
                }
            }

            // sale Id
            //
            var accountShop = ShopService.GetById(command.Account.ShopId);

            Logger.LogWithSerialNo(LogTypes.AccountOpen, serialNo, command.Account.AccountId, command.Account.Name);
            var r = new OpenAccountServiceResponse(ResponseCode.Success, command.DealLog, accountShop, command.Account, command.Owner)
            {
                SaleFee       = saleFee == null ? 0m : saleFee.Value,
                DepositAmount = command.Account.DepositAmount
            };

            if (command.AccountType != null)
            {
                r.AccountType = command.AccountType.DisplayName;
            }

            if (!string.IsNullOrEmpty(this.HostSite.TicketTemplateOfOpen))
            {
                var dealLog = command.DealLog;
                var msg     = this.HostSite.TicketTemplateOfOpen;
                msg        = MessageFormator.FormatForOperator(msg, SecurityHelper.GetCurrentUser());
                msg        = MessageFormator.Format(msg, dealLog);
                msg        = MessageFormator.FormatHowToDeal(msg, command.DealWay.DisplayName);
                msg        = MessageFormator.Format(msg, command.DealLog);
                msg        = MessageFormator.Format(msg, command.AccountType);
                msg        = MessageFormator.Format(msg, command.Owner);
                msg        = MessageFormator.Format(msg, HostSite);
                r.CodeText = msg;
                PrintTicketService.Create(new PrintTicket(LogTypes.AccountOpen, serialNo, msg, command.Account));
            }
            return(TransactionHelper.CommitAndReturn(r));
        }
Ejemplo n.º 6
0
        public ResultMsg Open(int id, DealWay dealWay)
        {
            ResultMsg msgResult = new ResultMsg();

            try
            {
                User operatorUser = SecurityHelper.GetCurrentUser().CurrentUser;
                using (Transaction tran = TransactionHelper.BeginTransaction())
                {
                    string  serialNo = SerialNoHelper.Create();
                    Account account  = AccountService.GetById(id);
                    if (account.State != AccountStates.Ready)
                    {
                        msgResult.CodeText = "不好意思,会员状态不对";
                    }
                    var command = new OpenAccountCommand(serialNo, account.Name, null, null, null, true,
                                                         dealWay.DealWayId, null, "批量开卡", operatorUser.UserId, 0,
                                                         Genders.Male, null);
                    UnityContainer.BuildUp(command);
                    int code = command.Validate();
                    if (code != ResponseCode.Success)
                    {
                        msgResult.CodeText = "不好意思,验证失败";
                    }

                    command.Execute(operatorUser);
                    decimal?saleFee = 0m;
                    if (command.AccountType != null)
                    {
                        saleFee = HostSite.SaleCardFee;
                        // 手续费
                        //
                        if (saleFee != null && saleFee.Value != 0m)
                        {
                            account.ChargingAmount += saleFee.Value;
                            AccountService.Update(account);
                            DealWay d             = DealWayService.Query().FirstOrDefault(x => x.State == States.Normal);
                            var     systemDealLog = new SystemDealLog(serialNo, operatorUser)
                            {
                                Amount    = saleFee.Value,
                                DealWayId = (d == null ? 0 : d.DealWayId),
                                DealType  = SystemDealLogTypes.SaldCardFee,
                                Addin     = account.AccountId.ToString()
                            };
                            SystemDealLogService.Create(systemDealLog);
                            if (d.IsCash)
                            {
                                CashDealLogService.Create(new CashDealLog(systemDealLog.Amount, 0, operatorUser.UserId,
                                                                          systemDealLog.DealType));
                            }
                        }
                    }

                    // sale Id
                    //

                    Logger.LogWithSerialNo(LogTypes.AccountOpen, serialNo, command.Account.AccountId,
                                           command.Account.Name);


                    if (!string.IsNullOrEmpty(HostSite.TicketTemplateOfOpen))
                    {
                        DealLog dealLog = command.DealLog;
                        string  msg     = HostSite.TicketTemplateOfOpen;
                        msg = MessageFormator.FormatForOperator(msg, SecurityHelper.GetCurrentUser());
                        msg = MessageFormator.Format(msg, dealLog);
                        msg = MessageFormator.FormatHowToDeal(msg, command.DealWay.DisplayName);
                        msg = MessageFormator.Format(msg, command.DealLog);
                        msg = MessageFormator.Format(msg, command.AccountType);
                        msg = MessageFormator.Format(msg, command.Owner);
                        msg = MessageFormator.Format(msg, HostSite);
                        PrintTicketService.Create(new PrintTicket(LogTypes.AccountOpen, serialNo, msg, command.Account));
                    }
                    tran.Commit();
                    msgResult.Code     = 1;
                    msgResult.CodeText = "会员建卡 " + account.Name + " 成功";

                    return(msgResult);
                }
            }
            catch (Exception ex)
            {
                msgResult.CodeText = "不好意思,系统异常";
                Logger.Error("批量发放会员卡", ex);
                return(msgResult);
            }
        }
Ejemplo n.º 7
0
        public void Ready()
        {
            //支付方式
            var idNamePairs = DealWayService.Query().Where(x => x.State == DealWayStates.Normal).Select(x => new IdNamePair()
            {
                Key = x.DealWayId, Name = x.DisplayName
            });

            this.DealWay.Bind(idNamePairs);
            //银行
            this.Bank.Bind(HostSite.GetBanks());
            //经销商级别
            var user = this.SecurityHelper.GetCurrentUser();

            if (user is AdminUserModel)
            {
                List <IdNamePair> li = new List <IdNamePair>()
                {
                    new IdNamePair()
                    {
                        Key = 1, Name = "总经销商"
                    }
                };
                this.DistributorLevel.Items = li;
            }
            else if (user is DistributorUserModel)
            {
                List <IdNamePair> li = new List <IdNamePair>()
                {
                    new IdNamePair()
                    {
                        Key = 2, Name = "分经销商"
                    }
                };
                this.DistributorLevel.Items = li;
            }


            if (_owner != null)
            {
                Mobile.Value1 = _owner.Mobile;
                Mobile.Value2 = _owner.Mobile2;
            }
            Mobile.HasBinding  = !string.IsNullOrWhiteSpace(HostSite.MessageTemplateOfIdentity);
            PhoneNumber.Value1 = Owner.PhoneNumber;
            PhoneNumber.Value2 = Owner.PhoneNumber2;
            List <Distributor> distributors =
                DistributorService.Query().Where(x => x.DistributorId != InnerObject.DistributorId).ToList();
            List <User> users = MembershipService.GetByIds(distributors.Select(x => x.UserId).ToArray()).ToList();
            List <Ecard.Models.DistributorAccountLevelRate> rateDtos = this.DistributorService.GetAccountLevelPolicyRates(this.InnerObject.DistributorId);

            if (rateDtos.Count > 0)
            {
                this.AccountLevelPolicyRates = new DistributorAccountLevelRate()
                {
                    AccountLevelPolicyId = rateDtos[0].AccountLevelPolicyId,
                    Rate = rateDtos[0].Rate * 100
                };
            }
            else
            {
                this.AccountLevelPolicyRates = new DistributorAccountLevelRate()
                {
                    AccountLevelPolicyId = 1,
                    Rate = 0
                };
            }

/*
 *          List<Ecard.Models.DistributorAccountLevelRate> rateDtos = this.DistributorService.GetAccountLevelPolicyRates(this.InnerObject.DistributorId);
 *          var rates = AccountLevelPolicyService.Query().Where(x => x.State == AccountLevelPolicyStates.Normal).ToList();
 *          this.AccountLevelPolicyRates = (from x in rates
 *                                          let rateDto = rateDtos.FirstOrDefault(d => d.DistributorId == InnerObject.DistributorId && d.AccountLevelPolicyId == x.AccountLevelPolicyId)
 *                                          select new DistributorAccountLevelRate
 *                                                     {
 *                                                         AccountLevelPolicyId = x.AccountLevelPolicyId,
 *                                                         Rate = rateDto == null ? 0 : rateDto.Rate * 100,
 *                                                         AccountLevelPolicyText = x.DisplayName,
 *                                                     }).FirstOrDefault();
 * */
        }