示例#1
0
        public ActionResult OrderList(StoreOrderSearchModel model)
        {
            //获取登录用户的门店
            int      userId  = GetSessionModel().UserID;
            IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

            var shop = shopBll.GetEntity(u => u.ShopUserId == userId);

            //如果该门店存在
            if (shop != null)
            {
                //获取订单状态下拉列表
                model.OrderStatusList = GetOrderStatusList(shop.Type.Contains(ConstantParam.SHOP_TYPE_0.ToString()));

                //获取支付方式下拉列表
                model.PayWayList = GetPayWayList(shop.Type.Contains(ConstantParam.SHOP_TYPE_0.ToString()));

                //初始化默认查询模型
                DateTime today = DateTime.Today;
                if (model.StartDate == null)
                {
                    model.StartDate = today.AddDays(-today.Day + 1);
                }
                if (model.EndDate == null)
                {
                    model.EndDate = today;
                }

                //获取当前门店ID
                var shopId = GetCurrentShopId().Value;

                //根据订单日期查询
                DateTime endDate = model.EndDate.Value.AddDays(1);
                Expression <Func <T_Order, bool> > where = u => u.OrderDate >= model.StartDate.Value && u.OrderDate < endDate && u.ShopId == shopId &&
                                                           u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.IsStoreHided == ConstantParam.DEL_FLAG_DEFAULT;

                //根据订单状态查询
                if (model.OrderStatus != null)
                {
                    where = PredicateBuilder.And(where, u => u.OrderStatus == model.OrderStatus);
                }

                //根据支付方式查询
                if (model.PayWay != null)
                {
                    where = PredicateBuilder.And(where, u => u.PayWay == model.PayWay);
                }

                //根据查询条件调用BLL层 获取分页数据
                IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                var sortName = this.SettingSorting("Id", false);
                model.DataList = orderBll.GetPageList(where, sortName.SortName, sortName.IsAsc, model.PageIndex) as PagedList <T_Order>;
                return(View(model));
            }

            //否则返回首页
            return(RedirectToAction("Index", "ShopPlatform"));
        }
示例#2
0
        public ApiPageResultModel OrderList([FromUri] OrderPagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //获取当前商家用户
                IShopUserBLL shopUserBll = BLLFactory <IShopUserBLL> .GetBLL("ShopUserBLL");

                var user = shopUserBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    shopUserBll.Update(user);
                    //如果该用户还未创建门店
                    if (user.Shops.Count < 1)
                    {
                        resultModel.Msg = APIMessage.SHOP_NOEXIST;
                        return(resultModel);
                    }
                    else
                    {
                        //获取订单列表数据
                        IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                        int shopId = user.Shops.FirstOrDefault().Id;
                        Expression <Func <T_Order, bool> > where = o => o.ShopId == shopId && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && o.IsStoreHided == ConstantParam.DEL_FLAG_DEFAULT;
                        if (model.OrderStatus != null)
                        {
                            where = PredicateBuilder.And(where, o => o.OrderStatus == model.OrderStatus);
                        }
                        resultModel.result = orderBll.GetPageList(where, "OrderDate", false, model.PageIndex).Select(o => new
                        {
                            Id              = o.Id,
                            OrderNo         = o.OrderNo,
                            ShopId          = o.Shop.Id,
                            ShopName        = o.Shop.ShopName,
                            ShopImg         = string.IsNullOrEmpty(o.Shop.ImgThumbnail) ? "" : o.Shop.ImgThumbnail.Split(';')[0],
                            BuyUserName     = o.User.UserName,
                            BuyUserHeadPic  = o.User.HeadPath,
                            BuyUserPhone    = o.ShippingAddress.Telephone,
                            OrderTime       = o.OrderDate.ToString("yyyy-MM-dd HH:mm:ss"),
                            OrderStatus     = o.OrderStatus,
                            RecedeType      = o.RecedeType,
                            RemainingTime   = o.PayDate == null || o.PayDate.Value.AddHours(2) < DateTime.Now ? "0小时0分" : (o.PayDate.Value.AddHours(2) - DateTime.Now).Hours + "小时" + (o.PayDate.Value.AddHours(2) - DateTime.Now).Minutes + "分",
                            ExitOrderReason = o.Reason,
                            OrderPrice      = o.OrderPrice,
                            SendAddress     = o.ShippingAddress.County.City.Province.ProvinceName + o.ShippingAddress.County.City.CityName + o.ShippingAddress.County.CountyName + "  " + o.ShippingAddress.AddressDetails,
                            PayWay          = o.PayWay,
                            RefundStatus    = GetRefundResult(o.Id),
                            PayTradeNo      = o.PayTradeNo,
                            RecedeTime      = o.RecedeTime != null ? o.RecedeTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                            Memo            = string.IsNullOrEmpty(o.Memo) ? "" : o.Memo,
                        });
                        resultModel.Total = orderBll.Count(where);
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }