public virtual GoodsListModel PrepareGoodsListModel(GoodsSearchModel searchModel, ConsignmentOrder entity)
        {
            if (null == searchModel)
            {
                throw new ArgumentNullException(nameof(searchModel));
            }

            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            var list = entity.Goods
                       .OrderByDescending(x => x.CTime)
                       .ToList();

            var model = new GoodsListModel
            {
                Data = list.PaginationByRequestModel(searchModel).Select(x =>
                {
                    var modelItem   = x.ToModel <GoodsModel>();
                    modelItem.CTime = dateTimeHelper.ConvertToUserTime(modelItem.CTime, DateTimeKind.Utc);

                    return(modelItem);
                }),
                Total = list.Count
            };

            return(model);
        }
Exemple #2
0
        /// <summary>
        /// 根据查询条件,搜索商品
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public List <GoodsInfo> SearchGoodsList(GoodsSearchModel searchModel)
        {
            string sqlWhere = " where isDel = 0 ";
            var    sqlParam = new List <DbParameter>();

            if (searchModel.GbId != null)
            {
                sqlWhere += " and GbId = @GbId ";
                sqlParam.Add(new MySqlParameter("@GbId", searchModel.GbId));
            }

            if (!string.IsNullOrEmpty(searchModel.GoodsTypeCode))
            {
                sqlWhere += " and GoodsTypeCode = @GoodsTypeCode ";
                sqlParam.Add(new MySqlParameter("@GoodsTypeCode", searchModel.GoodsTypeCode));
            }
            if (!string.IsNullOrEmpty(searchModel.Key))
            {
                sqlWhere += " and (GoodsName like @Key or GoodsDesc like @Key)  ";
                sqlParam.Add(new MySqlParameter("@Key", "%" + searchModel.Key + "%"));
            }

            string sql = @"select * from GoodsInfo " + sqlWhere + " limit 8 ";

            var list = _context.Database.SqlQuery <GoodsInfo>(sql, sqlParam.ToArray());

            return(list);
        }
        public ApiPageResultModel GetSaleList([FromUri] GoodsSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //该门店销售中的商品
                    Expression <Func <T_ShopSale, bool> > where = s => s.GoodsCategory.ShopId == model.ShopId && s.InSales == 1;
                    //如果选择了商品分类
                    if (model.GoodsCategoryId > 0)
                    {
                        where = PredicateBuilder.And(where, s => s.GoodsCategoryId == model.GoodsCategoryId);
                    }
                    //获取指定门店指定类别的商品列表
                    IShopSaleBLL SaleBll = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                    resultModel.Total  = SaleBll.Count(where);
                    resultModel.result = SaleBll.GetPageList(where, "Id", false, model.PageIndex).ToList().Select(s => new
                    {
                        GoodsId        = s.Id,
                        GoodsName      = s.Title,
                        GoodsDesc      = s.Content,
                        RemainingAmout = s.RemainingAmout,
                        SellAmout      = s.OrderDetails.Where(od => od.Order.OrderStatus == ConstantParam.OrderStatus_FINISH).Select(od => od.SaledAmount).ToArray().Sum(),
                        GoodsCoverImg  = string.IsNullOrEmpty(s.ImgThumbnail) ? "" : s.ImgThumbnail.Split(';')[0],
                        GoodsOtherImg  = string.IsNullOrEmpty(s.ImgPath) ? "" : s.ImgPath,
                        Price          = s.Price
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemple #4
0
        public virtual IActionResult GetGoods(GoodsSearchModel searchModel)
        {
            if (!permissionService.Authorize(StandardPermissionProvider.ManageConsignmentOrders))
            {
                return(AccessDeniedKendoGridJson());
            }

            var entity = consignmentOrderService.Get(searchModel.OrderId)
                         ?? throw new ArgumentException("Not found");

            var model = consignmentOrderFactory.PrepareGoodsListModel(searchModel, entity);

            return(Json(model));
        }
        public async Task <ResponseModel <Pager <Goods> > > GetGoodsPage(GoodsSearchModel request)
        {
            ResponseModel <Pager <Goods> > result = new ResponseModel <Pager <Entity.Goods> >();

            result.Code = 1;

            Goods goods = new Entity.Goods()
            {
                ID = request.ID
            };

            result.Data = await goodsService.GetGoods(goods, request.PageCount, request.PageNumber);

            return(result);
        }
Exemple #6
0
        public async ValueTask <RequestResult <List <Goods> > > GoodsSearch(GoodsSearchModel model)
        {
            var result = new RequestResult <List <Goods> >();

            try
            {
                result.RequestData = await _goodsStorage.GoodsSearch(model);

                result.IsOk = true;
            }
            catch (Exception ex)
            {
                result.ExMessage = ex.Message;
            }
            return(result);
        }
        protected virtual GoodsSearchModel PrepareGoodsSearchModel(GoodsSearchModel model, ConsignmentOrder entity)
        {
            if (null == model)
            {
                throw new ArgumentNullException(nameof(model));
            }

            if (null == entity)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            model.OrderId = entity.Id;
            model.SetGridPageSize();

            return(model);
        }
Exemple #8
0
        public async Task <ApiResult> Search(GoodsSearchModel model)
        {
            string            parm   = doMain;
            GoodsSearchResult result = await goodsService.SearchAsync(model.KeyWord, null, null, model.PageIndex, model.PageSize);

            List <SearchResultModel> lists;

            lists = result.Goods.Select(g => new SearchResultModel {
                id = g.Id, inventory = g.Inventory, name = g.Name, price = g.Price, realityPrice = g.RealityPrice, saleNum = g.SaleNum, imgUrl = parm + goodsImgService.GetFirstImg(g.Id)
            }).ToList();
            GoodsSearchApiModel apiModel = new GoodsSearchApiModel();

            apiModel.goods     = lists;
            apiModel.pageCount = result.PageCount;
            return(new ApiResult {
                status = 1, data = apiModel
            });
        }
Exemple #9
0
        public async ValueTask <List <Goods> > GoodsSearch(GoodsSearchModel dataModel)
        {
            DynamicParameters parameters = new DynamicParameters(new
            {
                dataModel.Id,
                dataModel.Brand,
                dataModel.Model,
                dataModel.Price,
                dataModel.CategoryId,
                dataModel.SubcategoryId
            });
            var result = await connection.QueryAsync <Goods, Category, Goods>(
                SpName.GoodsSearch,
                (g, c) =>
            {
                Goods goods    = g;
                goods.Category = c;
                return(goods);
            },
                param : parameters,
                commandType : CommandType.StoredProcedure);

            return(result.ToList());
        }
Exemple #10
0
        public ApiPageResultModel GetGoodsList([FromUri] GoodsSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

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

                T_ShopUser user = userBll.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")));
                    userBll.Update(user);

                    Expression <Func <T_ShopSale, bool> > where = s => s.InSales == model.InSales && s.GoodsCategory.ShopId == model.ShopId;

                    if (model.GoodsCategoryId > 0)
                    {
                        where = PredicateBuilder.And(where, s => s.GoodsCategoryId == model.GoodsCategoryId);
                    }

                    IOrderBLL orderBll = BLLFactory <IOrderBLL> .GetBLL("OrderBLL");

                    IShopSaleBLL shopSaleBLL = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                    var list = shopSaleBLL.GetPageList(where, "CreateTime", false, model.PageIndex).Select(
                        s => new
                    {
                        Id             = s.Id,
                        ImgThumbnail   = string.IsNullOrEmpty(s.ImgThumbnail) ? "" : s.ImgThumbnail.Split(';').FirstOrDefault(),
                        Title          = s.Title,
                        Price          = s.Price,
                        RemainingAmout = s.RemainingAmout,
                        SaledCount     = s.OrderDetails.Where(od => od.Order.OrderStatus == ConstantParam.OrderStatus_FINISH).Select(od => od.SaledAmount).ToArray().Sum(),
                        CreateDate     = s.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        UnShelveTime   = s.UnShelveTime.HasValue ? s.UnShelveTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                        InSales        = s.InSales
                    });

                    resultModel.result = list;
                    resultModel.Total  = shopSaleBLL.Count(where);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
Exemple #11
0
        /// <summary>
        /// 根据查询条件 查询商品列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public IActionResult SearchGoodsList(GoodsSearchModel searchModel)
        {
            var list = _goodsInfoRepository.SearchGoodsList(searchModel);

            return(JsonOk(list));
        }
Exemple #12
0
        /// <summary>
        /// 根据查询条件,搜索商品
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public PageModel <GoodsInfo> SearchGoodsList(GoodsSearchModel searchModel, PageInfo page)
        {
            string sqlWhere = " where isDel = 0 ";
            string orderStr = "";
            var    sqlParam = new List <DbParameter>();

            if (!string.IsNullOrEmpty(searchModel.GoodsTypeCode))
            {
                sqlWhere += " and GoodsTypeCode like @GoodsTypeCode ";
                sqlParam.Add(new MySqlParameter("@GoodsTypeCode", searchModel.GoodsTypeCode + "%"));
            }
            if (!string.IsNullOrEmpty(searchModel.Key))
            {
                sqlWhere += " and (GoodsName like @Key or GoodsDesc like @Key)  ";
                sqlParam.Add(new MySqlParameter("@Key", "%" + searchModel.Key + "%"));
            }
            if (searchModel.BeginPrice != null)
            {
                sqlWhere += " and (BeginDisplayPrice >= @BeginPrice or EndDisplayPrice >=@BeginPrice )";
                sqlParam.Add(new MySqlParameter("@Consignee", searchModel.BeginPrice));
            }
            if (searchModel.EndPrice != null)
            {
                sqlWhere += " and (BeginDisplayPrice <= @EndPrice or EndDisplayPrice <= @EndPrice )";
                sqlParam.Add(new MySqlParameter("@EndPrice", searchModel.EndPrice));
            }

            if (searchModel.OrderBy == GoodsOrderByEnum.价格排序)
            {
                orderStr += " order by  BeginDisplayPrice ";
            }
            if (searchModel.OrderBy == GoodsOrderByEnum.综合排序)
            {
                /*
                 * 商品综合排序跟10项因素相关(会变化),具体如下 影响宝贝排名的重要因素的权重占比(会变化):
                 *  成交量:15%
                 *  好评率:10%
                 *  收藏量:8%
                 *  上下架:12%
                 *  转化率:14%
                 *  橱窗推荐:10%
                 *  回购率:10%
                 *  DSR:8% 卖家服务评级系统(Detail Seller Rating)
                 */

                orderStr += " order by  SalesVolume desc ,BeginDisplayPrice desc  ";
            }
            if (searchModel.OrderBy == GoodsOrderByEnum.销量排序)
            {
                orderStr += " order by  SalesVolume ";
            }

            if (searchModel.OrderBy == GoodsOrderByEnum.综合排序 && searchModel.IsDesc)
            {
                orderStr += " Desc ";
            }

            string sql = @"select * from GoodsInfo " + sqlWhere + orderStr;
            //string sqlCount = "select count(*) from GoodsInfo o " + sqlWhere;

            var list = _context.Database.SqlQuery <GoodsInfo>(sql.ToPaginationSql(page), sqlParam.ToArray());

            //var count = _context.Database.ExcuteSclare(sqlCount, sqlParam.ToArray());

            return(new PageModel <GoodsInfo>(list, page.PageIndex, page.PageSize, null));
        }
Exemple #13
0
        /// <summary>
        /// 根据查询条件 查询商品列表
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public IActionResult SearchGoodsList(GoodsSearchModel searchModel, PageInfo page)
        {
            var list = _goodsInfoRepository.SearchGoodsList(searchModel, page);

            return(Json(list));
        }