Beispiel #1
0
        public ActionResult PersonalRankList(int pageIndex)
        {
            int pageCount = 0;

            using (MyDbContext dbc = new MyDbContext())
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@pageIndex",  SqlDbType.Int, 4),
                    new SqlParameter("@pageSize",   SqlDbType.Int, 4),
                    new SqlParameter("@pageCount",  SqlDbType.Int, 4),
                    new SqlParameter("@totalCount", SqlDbType.Int, 4)
                };
                parameters[0].Value     = pageIndex;
                parameters[1].Value     = pageSize;
                parameters[2].Direction = ParameterDirection.Output;
                parameters[3].Direction = ParameterDirection.Output;

                var list = dbc.Database.SqlQuery <PersonalRankModel>("exec proc_PersonalRankList @pageIndex = @pageIndex,@pageSize =@pageSize,@pageCount = @pageCount output, @totalCount = @totalCount output", parameters).ToList();

                pageIndex -= 1;

                int i = pageIndex * pageSize;
                list.ForEach(s => s.rankNo = ++i);

                int.TryParse(parameters[2].Value.ToString(), out pageCount);
                PersonalResultModel teamRank = new PersonalResultModel();
                teamRank.List      = list.ToArray();
                teamRank.PageCount = pageCount;

                return(Json(new AjaxResult {
                    Status = 1, Data = teamRank
                }));
            }
        }
Beispiel #2
0
        public APIResponse Personal(int userId, int merchantId, string deviceId)
        {
            PersonalResultModel model = new PersonalResultModel();

            var posMachine = CurrentDb.PosMachine.Where(m => m.DeviceId == deviceId).FirstOrDefault();

            if (posMachine == null)
            {
                model.PosMachineStatus = Enumeration.MerchantPosMachineStatus.NotMatch;
                return(ResponseResult(ResultType.Failure, ResultCode.Failure, "设备ID不存在"));
            }



            var merchant           = CurrentDb.Merchant.Where(m => m.Id == merchantId).FirstOrDefault();
            var userAccount        = CurrentDb.SysClientUser.Where(m => m.Id == userId).FirstOrDefault();
            var merchantFund       = CurrentDb.Fund.Where(m => m.UserId == merchant.UserId && m.MerchantId == merchant.Id).FirstOrDefault();
            var merchantPosMachine = CurrentDb.MerchantPosMachine.Where(m => m.MerchantId == merchantId && m.PosMachineId == posMachine.Id).FirstOrDefault();
            var merchantOrder      = CurrentDb.Order.Where(m => m.UserId == merchant.UserId && m.MerchantId == merchant.Id && (m.Status == Enumeration.OrderStatus.Follow || m.Status == Enumeration.OrderStatus.WaitPay && ((int)m.ProductType).ToString().StartsWith("201"))).ToList();

            //var
            Log.Info("测试通过1");


            model.PosMachineStatus = merchantPosMachine.Status;

            PersonalInfo personalInfo = new PersonalInfo();

            personalInfo.PhoneNumber     = userAccount.PhoneNumber.NullToEmpty();
            personalInfo.FullName        = userAccount.FullName.NullToEmpty();
            personalInfo.MerchantName    = merchant.YYZZ_Name.NullToEmpty();
            personalInfo.MerchantAddress = merchant.YYZZ_Address.NullToEmpty();

            model.PersonalInfo = personalInfo;

            model.WithdrawRuleUrl = BizFactory.Withdraw.GetWithrawRuleUrl();

            if (merchant != null)
            {
                //资金详细
                if (merchantFund != null)
                {
                    FundDetails fundDetails = new FundDetails();

                    fundDetails.Balance   = merchantFund.Balance;
                    fundDetails.Arrearage = merchantFund.Arrearage;

                    model.Fund = fundDetails;
                }

                //订单数据
                if (merchantOrder != null)
                {
                    OrderStatusCount orderStatusCount = new OrderStatusCount();
                    orderStatusCount.Follow  = merchantOrder.Where(m => m.Status == Enumeration.OrderStatus.Follow).Count();
                    orderStatusCount.WaitPay = merchantOrder.Where(m => m.Status == Enumeration.OrderStatus.WaitPay).Count();

                    model.OrderStatusCount = orderStatusCount;
                }
                Log.Info("测试通过2");
                //租金
                if (merchantPosMachine != null)
                {
                    model.RentDue = BizFactory.Merchant.GetRentOrder(merchant.Id, posMachine.Id);
                }
                Log.Info("测试通过3");

                //续保数量
                DateTime periodEndMax = DateTime.Now.AddDays(-7);
                model.RenewalCount = CurrentDb.OrderToCarInsure.Where(m => m.MerchantId == merchant.Id && m.Status == Enumeration.OrderStatus.Completed && m.PeriodEnd >= periodEndMax).Count();
            }

            model.CustomerPhone = "020-88888888";

            APIResult result = new APIResult()
            {
                Result = ResultType.Success, Code = ResultCode.Success, Message = "获取成功", Data = model
            };

            return(new APIResponse(result));
        }