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); }