Exemplo n.º 1
0
        public bool UpdateSingle(User model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }

            var sql =
                "UPDATE dbo.User_User SET Name=@Name, Email=@Email, Mobile=@Mobile, Status=@Status,GradeId=@GradeId WHERE Id=@Id";
            var parameters = new[]
            {
                RepositoryContext.CreateParameter("@Name", model.Name),
                RepositoryContext.CreateParameter("@Email", model.Email),
                RepositoryContext.CreateParameter("@Mobile", model.Mobile),
                RepositoryContext.CreateParameter("@Status", model.Status),
                RepositoryContext.CreateParameter("@GradeId", model.GradeId),
                RepositoryContext.CreateParameter("@Id", model.Id)
            };
            var count = RepositoryContext.ExecuteNonQuery(sql, parameters);

            if (count > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="moneyTypeid"></param>
        /// <param name="changedAmount"></param>
        public bool ChangeFreezeAmount(long userId, Guid moneyTypeid, decimal changedAmount)
        {
            var sql =
                $"update Asset_Account set FreezeAmount=FreezeAmount+{changedAmount} where UserId={userId} and MoneyTypeId='{moneyTypeid}'";

            return(RepositoryContext.ExecuteNonQuery(sql) > 0);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Updates the account amount.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="moneyTypeId">The money type identifier.</param>
        /// <param name="amount">The amount.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool UpdateAccountAmount(long userId, Guid moneyTypeId, decimal amount)
        {
            var sql = $@"update Asset_Account set Amount={amount},
                            HistoryAmount=(case when {amount}>=Amount then HistoryAmount+{
                    amount
                }-Amount else HistoryAmount end)
                            where UserId={userId} and MoneyTypeId='{moneyTypeId}'";

            return(RepositoryContext.ExecuteNonQuery(sql) > 0);
        }
Exemplo n.º 4
0
        public void SuccessOrder(long shareOrderId)
        {
            var sql        = "update Things_Trade set Status=@Status ,UpdateTime=GETDATE() where Id=@Id";
            var parameters = new[]
            {
                RepositoryContext.CreateParameter("@Id", shareOrderId),
                RepositoryContext.CreateParameter("@Status", Convert.ToInt16(ShareOrderStatus.Handled)),
            };

            RepositoryContext.ExecuteNonQuery(sql, parameters);
        }
Exemplo n.º 5
0
 /// <summary>
 ///     执行脚本
 /// </summary>
 /// <param name="sqlList"></param>
 private void ExecuteSql(List <string> sqlList)
 {
     foreach (var item in sqlList)
     {
         try {
             RepositoryContext.ExecuteNonQuery(item);
         } catch (Exception ex) {
             Trace.WriteLine(ex.Message);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        ///     Errors the order.
        /// </summary>
        /// <param name="shareOrderId">The share order identifier.</param>
        /// <param name="message">The message.</param>
        public void ErrorOrder(long shareOrderId, string message)
        {
            var sql        = "update Things_Trade set Summary=@Summary ,Status=@Status ,UpdateTime=GETDATE() where Id=@Id";
            var parameters = new[]
            {
                RepositoryContext.CreateParameter("@Id", shareOrderId),
                RepositoryContext.CreateParameter("@Status", Convert.ToInt16(ShareOrderStatus.Error)),
                RepositoryContext.CreateParameter("@Summary", message)
            };

            RepositoryContext.ExecuteNonQuery(sql, parameters);
        }
Exemplo n.º 7
0
        public bool UpdateRecommend(List <long> userIds, long parentId)
        {
            var sql    = $" update  user_user set parentId={parentId} where Id in ({userIds.ToSqlString()})";
            var result = RepositoryContext.ExecuteNonQuery(sql);

            if (result > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        public void UpdateMap(long userId, string map)
        {
            var updateMapSql = "UPDATE dbo.User_UserMap SET ParentMap=@ParentMap WHERE UserId=@UserId";
            var parameters2  = new[]
            {
                RepositoryContext.CreateParameter("@UserId", userId),
                RepositoryContext.CreateParameter("@ParentMap", map)
            };

            RepositoryContext.Transation(() => {
                var count = RepositoryContext.ExecuteNonQuery(updateMapSql, parameters2);
            });
        }
Exemplo n.º 9
0
        public void ErrorQueue(long id, string message)
        {
            var sql =
                "update Basic_MessageQueue set Status=@status, Message=@message,RequestTime=GETDATE() where Id=@id";
            var parameters = new[]
            {
                RepositoryContext.CreateParameter("@status", MessageStatus.Error),
                RepositoryContext.CreateParameter("@message", message),
                RepositoryContext.CreateParameter("@id", id)
            };

            RepositoryContext.ExecuteNonQuery(sql, parameters);
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Changes the account amount.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="moneyTypeId">The money type identifier.</param>
        /// <param name="changedAmount">The changed amount.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public bool ChangeAccountAmount(long userId, Guid moneyTypeId, decimal changedAmount)
        {
            var historyUpdateSql = string.Empty;

            if (changedAmount > 0)
            {
                historyUpdateSql = $" ,HistoryAmount=HistoryAmount+{changedAmount}";
            }

            var sql =
                $"update Asset_Account set Amount=Amount+{changedAmount} {historyUpdateSql} where UserId={userId} and MoneyTypeId='{moneyTypeId}'";

            return(RepositoryContext.ExecuteNonQuery(sql) > 0);
        }
Exemplo n.º 11
0
        public bool ChangePassword(long userId, string password)
        {
            var sql        = @"update User_UserDetail set Password=@Password,ModifiedTime=GETDATE() where userId=@userid";
            var parameters = new[]
            {
                RepositoryContext.CreateParameter("@Password", password),
                RepositoryContext.CreateParameter("@userid", userId)
            };
            var count = RepositoryContext.ExecuteNonQuery(sql, parameters);

            if (count > 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 12
0
        public void Pay(DbTransaction transaction, Bill bill, Account account)
        {
            var sqlAccount = $@"UPDATE [dbo].[Asset_Account]
                                    SET [Amount] = {account.Amount}
                                       ,[FreezeAmount] = {account.FreezeAmount}
                                       ,[HistoryAmount] = {account.HistoryAmount}
                                  WHERE Id={account.Id}";
            var sqlBill    =
                $@"INSERT INTO [dbo].[Asset_Bill]([UserId] ,[OtherUserId] ,[Type]  ,[Flow] ,[MoneyTypeId],[Amount] ,[AfterAmount],[Intro] ,[CreateTime] ,[EntityId])
                                 VALUES
                                       ({bill.UserId}
                                       ,{bill.OtherUserId}
                                       ,{(int)bill.Type}
                                       ,{(int)bill.Flow}
                                       ,'{bill.MoneyTypeId}'
                                       ,{bill.Amount}
                                       ,{bill.AfterAmount}
                                       ,'{bill.Intro}'
                                       ,'{bill.CreateTime}'
                                       ,{bill.EntityId})";

            RepositoryContext.ExecuteNonQuery(transaction, sqlBill);
            RepositoryContext.ExecuteNonQuery(transaction, sqlAccount);
        }
Exemplo n.º 13
0
        public void HandleQueueAndUpdateContent(long id, string message = null, string summary = null)
        {
            if (message == null)
            {
                message = string.Empty;
            }

            if (summary == null)
            {
                summary = string.Empty;
            }

            var sql =
                "update Basic_MessageQueue set Status=@status,  Message=@message, Summary=@summary,RequestTime=GETDATE() where Id=@id";
            var parameters = new[]
            {
                RepositoryContext.CreateParameter("@status", MessageStatus.Handled),
                RepositoryContext.CreateParameter("@message", message),
                RepositoryContext.CreateParameter("@summary", summary),
                RepositoryContext.CreateParameter("@id", id)
            };

            RepositoryContext.ExecuteNonQuery(sql, parameters);
        }
Exemplo n.º 14
0
        /// <summary>
        ///     添加商品库存
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="productSkuId"></param>
        /// <param name="count"></param>
        public bool AddStock(long productId, long productSkuId, int count)
        {
            var result = false;

            using (var transaction = RepositoryContext.BeginNativeDbTransaction())
            {
                try
                {
                    var sql = $"update Shop_Product set Stock=Stock+{count} where Id={productId}";
                    RepositoryContext.ExecuteNonQuery(transaction, sql);
                    sql = $"update Shop_ProductSku set Stock=Stock+{count} where Id='{productSkuId}'";
                    RepositoryContext.ExecuteNonQuery(transaction, sql);
                    transaction.Commit();
                    result = true;
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }

            return(result);
        }
Exemplo n.º 15
0
        /// <summary>
        ///     更新分润模块执行次数
        /// </summary>
        /// <param name="shareOrderId">The share order identifier.</param>
        /// <param name="count">The count.</param>
        public void UpdateExcuteCount(long shareOrderId, long count)
        {
            var sql = $"update Things_Trade set ExecuteCount=ExecuteCount+{count}  where Id={shareOrderId}";

            RepositoryContext.ExecuteNonQuery(sql);
        }
Exemplo n.º 16
0
        public void Cancel(long id)
        {
            var sql = $"update Basic_MessageQueue set Status={(byte)MessageStatus.Canceld} where Id={id}";

            RepositoryContext.ExecuteNonQuery(sql);
        }