Example #1
0
        private void bindCurrencyLink(IBlock block, String lbl, Object data)
        {
            UserIncomeLog x          = data as UserIncomeLog;
            long          currencyId = x.CurrencyId == 0 ? tempKeyCurrencyId : x.CurrencyId;

            block.Set("x.CurrencyLink", to(IncomeLog, currencyId));
        }
        public virtual Result Buy(int buyerId, int creatorId, ForumTopic topic)
        {
            Result result = new Result();

            if (userIncomeService.HasEnoughKeyIncome(buyerId, topic.Price) == false)
            {
                result.Add(String.Format(alang.get(typeof(ForumApp), "exIncome"), KeyCurrency.Instance.Name));
                return(result);
            }

            // 日志:买方减少收入
            UserIncomeLog log = new UserIncomeLog();

            log.UserId     = buyerId;
            log.CurrencyId = KeyCurrency.Instance.Id;
            log.Income     = -topic.Price;
            log.DataId     = topic.Id;
            log.ActionId   = actionId;
            db.insert(log);

            // 日志:卖方增加收入
            UserIncomeLog log2 = new UserIncomeLog();

            log2.UserId     = creatorId;
            log2.CurrencyId = KeyCurrency.Instance.Id;
            log2.Income     = topic.Price;
            log2.DataId     = topic.Id;
            log2.ActionId   = actionId;
            db.insert(log2);

            userIncomeService.AddKeyIncome(buyerId, -topic.Price);
            userIncomeService.AddKeyIncome(creatorId, topic.Price);

            return(result);
        }
        public virtual Result Buy( int buyerId, int creatorId, ForumTopic topic )
        {
            Result result = new Result();
            if (userIncomeService.HasEnoughKeyIncome( buyerId, topic.Price ) == false) {
                result.Add( String.Format( alang.get( typeof( ForumApp ), "exIncome" ), KeyCurrency.Instance.Name ) );
                return result;
            }

            // 日志:买方减少收入
            UserIncomeLog log = new UserIncomeLog();
            log.UserId = buyerId;
            log.CurrencyId = KeyCurrency.Instance.Id;
            log.Income = -topic.Price;
            log.DataId = topic.Id;
            log.ActionId = actionId;
            db.insert( log );

            // 日志:卖方增加收入
            UserIncomeLog log2 = new UserIncomeLog();
            log2.UserId = creatorId;
            log2.CurrencyId = KeyCurrency.Instance.Id;
            log2.Income = topic.Price;
            log2.DataId = topic.Id;
            log2.ActionId = actionId;
            db.insert( log2 );

            userIncomeService.AddKeyIncome( buyerId, -topic.Price );
            userIncomeService.AddKeyIncome( creatorId, topic.Price );

            return result;
        }
        public virtual void Insert( int postId, int userId, int operatorId, String operatorName, int currencyId, int income, String reason )
        {
            UserIncomeLog log = new UserIncomeLog();
            log.UserId = userId;
            log.CurrencyId = currencyId;
            log.Income = income;
            log.DataId = postId;
            log.OperatorId = operatorId;
            log.OperatorName = operatorName;
            log.Note = reason;
            log.ActionId = 100;

            db.insert(log);
        }
        public virtual void Insert(int postId, int userId, int operatorId, String operatorName, int currencyId, int income, String reason)
        {
            UserIncomeLog log = new UserIncomeLog();

            log.UserId       = userId;
            log.CurrencyId   = currencyId;
            log.Income       = income;
            log.DataId       = postId;
            log.OperatorId   = operatorId;
            log.OperatorName = operatorName;
            log.Note         = reason;
            log.ActionId     = 100;

            db.insert(log);
        }
Example #6
0
        private void insertInitIncome(User user, ICurrency c)
        {
            UserIncome income = new UserIncome();

            income.UserId     = user.Id;
            income.CurrencyId = c.Id;
            income.Income     = c.InitValue;
            InsertIncome(income);

            // save log
            UserIncomeLog incomeLog = new UserIncomeLog();

            incomeLog.UserId     = user.Id;
            incomeLog.CurrencyId = c.Id;
            incomeLog.Income     = c.InitValue;
            incomeLog.Note       = "注册奖励";
            incomeLog.insert();
        }
Example #7
0
        public virtual int UpdateUserIncome(User user, long currencyId, int income, string msg)
        {
            UserIncome userIncome = this.GetUserIncome(user.Id, currencyId);

            userIncome.Income += income;
            this.UpdateUserIncome(userIncome);

            // save log
            UserIncomeLog incomeLog = new UserIncomeLog();

            incomeLog.UserId     = user.Id;
            incomeLog.CurrencyId = currencyId;
            incomeLog.Income     = income;
            incomeLog.Note       = msg;
            incomeLog.insert();

            return(userIncome.Income); // return total income
        }
        private void insertInitIncome( User user, ICurrency c )
        {
            UserIncome income = new UserIncome();
            income.UserId = user.Id;
            income.CurrencyId = c.Id;
            income.Income = c.InitValue;
            InsertIncome( income );

            // save log
            UserIncomeLog incomeLog = new UserIncomeLog();
            incomeLog.UserId = user.Id;
            incomeLog.CurrencyId = c.Id;
            incomeLog.Income = c.InitValue;
            incomeLog.Note = "注册奖励";
            incomeLog.insert();
        }
        public virtual int UpdateUserIncome( User user, long currencyId, int income, long actionId, string msg )
        {
            UserIncome userIncome = this.GetUserIncome( user.Id, currencyId );
            userIncome.Income += income;
            this.UpdateUserIncome( userIncome );

            // save log
            UserIncomeLog incomeLog = new UserIncomeLog();
            incomeLog.UserId = user.Id;
            incomeLog.CurrencyId = currencyId;
            incomeLog.ActionId = actionId;
            incomeLog.Income = income;
            incomeLog.Note = msg;
            incomeLog.insert();

            return userIncome.Income; // return total income
        }
Example #10
0
 private Boolean hasActiveEmailLog(User user)
 {
     return(UserIncomeLog.find("UserId=" + user.Id + " and ActionId=" + UserAction.User_ConfirmEmail.Id).first() != null);
 }