Beispiel #1
0
        public static PageOfList <TResult> ToList <T, TResult>(this QueryObject <T> query, int pageIndex, int pageSize, string orderBy, Func <T, TResult> selector) where T : new()
        {
            var             totalItemCount = (int)query.Count();
            IEnumerable <T> list           = query.ToList((pageIndex - 1) * pageSize, pageSize, orderBy);

            return(ToList(pageIndex, pageSize, orderBy, selector, list, totalItemCount));
        }
Beispiel #2
0
        public void Query()
        {
            var request = new SystemDealLogRequest();

            if (DealType != Globals.All)
            {
                request.DealType = DealType;
            }
            if (State != SystemDealLogStates.All)
            {
                request.State = State;
            }
            request.SubmitTimeMin = StartTime;
            request.SubmitTimeMax = EndTime;
            request.UserName      = UserName;
            request.SerialNo      = SerialNo;
            QueryObject <SystemDealLog> query = SystemDealLogService.Query(request);

            List = query.ToList(this, x => new ListSystemDealLog(x));
            var dealways = DealWayService.Query().ToList();

            foreach (var dealLog in List)
            {
                var dealWay = dealways.FirstOrDefault(x => x.DealWayId == dealLog.InnerObject.DealWayId);
                dealLog.HowToDeal = dealWay == null ? dealLog.InnerObject.HowToDeal : dealWay.DisplayName;
            }
        }
Beispiel #3
0
        public List <Order> GetOrder()
        {
            string sql  = "select * from fz_Orders where orderState=@orderState";
            var    list = new QueryObject <Order>(_databaseInstance, sql, new { orderState = OrderStates.shipped });

            if (list != null)
            {
                return(list.ToList());
            }
            return(null);
        }
Beispiel #4
0
        public List <Account> Querys()
        {
            QueryObject <Account> query = InnerQuery();

            return(query.ToList());
        }
Beispiel #5
0
        public bool Rebate(int orderId)
        {
            var Transaction = _databaseInstance.BeginTransaction();

            //try
            //{
            WxPayAPI.Log.Debug("Ecard.SqlServices.SqlRebateService.Rebate", "开始返利");
            var order = _databaseInstance.GetById <Order>("fz_Orders", orderId);

            if (order == null)
            {
                return(false);
            }
            if (order.orderState != OrderStates.complete)
            {
                return(false);
            }
            string sql       = "select  * from fz_OrderDetails where OrderId=@OrderId";
            var    orderDeal = new QueryObject <OrderDetail>(_databaseInstance, sql, new { OrderId = orderId });

            if (orderDeal == null)
            {
                return(false);
            }
            if (orderDeal.ToList().Count <= 0)
            {
                return(false);
            }
            var account = IAccountService.GetById(order.userId);

            if (account == null)
            {
                return(false);
            }
            Account one   = IAccountService.GetById(account.salerId);
            Account two   = null;
            Account three = null;

            if (one != null)
            {
                //WxPayAPI.Log.Debug("Ecard.SqlServices.SqlRebateService.Rebate", "第一层:"+one.name);
                two = IAccountService.GetById(one.salerId);
            }
            if (two != null)
            {
                three = IAccountService.GetById(two.salerId);
            }
            var site = ISiteService.Query(null).FirstOrDefault();

            if (site == null)
            {
                return(false);
            }
            foreach (var item in orderDeal.ToList())
            {
                if (one != null)
                {
                    var oneAmount = item.amount * site.OneRebate;
                    // WxPayAPI.Log.Debug("Ecard.SqlServices.SqlRebateService.Rebate", "第一层金额:" + oneAmount.ToString());
                    if (oneAmount > 0)
                    {
                        one.amount += oneAmount;
                        var fzRebate = new fz_Rebate();
                        fzRebate.accountId     = one.accountId;
                        fzRebate.orderDetailId = item.orderDetailId;
                        fzRebate.payAmount     = item.amount;
                        fzRebate.reateAmount   = oneAmount;
                        fzRebate.reateRatio    = site.OneRebate;
                        fzRebate.state         = RebateState.normal;
                        fzRebate.submitTime    = DateTime.Now;
                        fzRebate.type          = RebateType.one;
                        fzRebate.rebateId      = _databaseInstance.Insert(fzRebate, "fz_Rebate");
                        if (fzRebate.accountId > 0)
                        {
                            var operationAmountLog = new fz_OperationAmountLogs();
                            operationAmountLog.amount     = oneAmount;
                            operationAmountLog.source     = fzRebate.rebateId.ToString();
                            operationAmountLog.userId     = fzRebate.accountId;
                            operationAmountLog.type       = OperationAmountType.Income;
                            operationAmountLog.category   = OperationAmountCategory.rebate;
                            operationAmountLog.submitTime = DateTime.Now;
                            if (_databaseInstance.Insert(operationAmountLog, "fz_OperationAmountLogs") <= 0)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                        //WxPayAPI.Log.Debug("Ecard.SqlServices.SqlRebateService.Rebate", "第一层返利成功:" + fzRebate.rebateId.ToString());
                    }
                }
                if (two != null)
                {
                    var twoAmount = item.amount * site.TwoRebate;
                    if (twoAmount > 0)
                    {
                        two.amount += twoAmount;
                        var fzRebate = new fz_Rebate();
                        fzRebate.accountId     = two.accountId;
                        fzRebate.orderDetailId = item.orderDetailId;
                        fzRebate.payAmount     = item.amount;
                        fzRebate.reateAmount   = twoAmount;
                        fzRebate.reateRatio    = site.TwoRebate;
                        fzRebate.state         = RebateState.normal;
                        fzRebate.submitTime    = DateTime.Now;
                        fzRebate.type          = RebateType.two;
                        fzRebate.rebateId      = _databaseInstance.Insert(fzRebate, "fz_Rebate");
                        if (fzRebate.accountId > 0)
                        {
                            var operationAmountLog = new fz_OperationAmountLogs();
                            operationAmountLog.amount     = twoAmount;
                            operationAmountLog.source     = fzRebate.rebateId.ToString();
                            operationAmountLog.userId     = fzRebate.accountId;
                            operationAmountLog.type       = OperationAmountType.Income;
                            operationAmountLog.category   = OperationAmountCategory.rebate;
                            operationAmountLog.submitTime = DateTime.Now;
                            if (_databaseInstance.Insert(operationAmountLog, "fz_OperationAmountLogs") <= 0)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                if (three != null)
                {
                    var threeAmount = item.amount * site.ThreeRebate;
                    if (threeAmount > 0)
                    {
                        three.amount += threeAmount;
                        var fzRebate = new fz_Rebate();
                        fzRebate.accountId     = three.accountId;
                        fzRebate.orderDetailId = item.orderDetailId;
                        fzRebate.payAmount     = item.amount;
                        fzRebate.reateAmount   = threeAmount;
                        fzRebate.reateRatio    = site.ThreeRebate;
                        fzRebate.state         = RebateState.normal;
                        fzRebate.submitTime    = DateTime.Now;
                        fzRebate.type          = RebateType.three;
                        fzRebate.rebateId      = _databaseInstance.Insert(fzRebate, "fz_Rebate");
                        if (fzRebate.accountId > 0)
                        {
                            var operationAmountLog = new fz_OperationAmountLogs();
                            operationAmountLog.amount     = threeAmount;
                            operationAmountLog.source     = fzRebate.rebateId.ToString();
                            operationAmountLog.userId     = fzRebate.accountId;
                            operationAmountLog.type       = OperationAmountType.Income;
                            operationAmountLog.category   = OperationAmountCategory.rebate;
                            operationAmountLog.submitTime = DateTime.Now;
                            if (_databaseInstance.Insert(operationAmountLog, "fz_OperationAmountLogs") <= 0)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
                item.IsRebate = true;
                if (_databaseInstance.Update(item, "fz_OrderDetails") <= 0)
                {
                    return(false);
                }
            }
            if (one != null)
            {
                _databaseInstance.Update(one, "fz_Accounts");
            }
            if (two != null)
            {
                _databaseInstance.Update(two, "fz_Accounts");
            }
            if (three != null)
            {
                _databaseInstance.Update(three, "fz_Accounts");
            }

            Transaction.Commit();
            Transaction.Dispose();
            return(true);
            //}
            //catch (Exception ex)
            //{
            //    ILog4netService.Insert(ex);
            //    Transaction.Rollback();
            //    return false;
            //}
            //finally
            //{
            //    Transaction.Dispose();
            //}
        }
Beispiel #6
0
 public static PageOfList <TResult> ToList <T, TResult>(this QueryObject <T> query, IQueryRequest queryRequest, Func <T, TResult> selector) where T : new()
 {
     return(query.ToList(queryRequest.PageIndex, queryRequest.PageSize, queryRequest.OrderBy, selector));
 }