private HotPageData <List <GoodsViewModel> > GetGoodsList(HQRequestHeader header, HotGoodsSearchCondition condition) { HotPageData <List <HotGoodsModel> > pageData = GoodsProviderFactory.GetInstance(header.platType).GetGoodsList(condition, out string errMsg); HotPageData <List <GoodsViewModel> > pageViewData = new HotPageData <List <GoodsViewModel> >(); pageViewData.PageCount = pageData.PageCount; pageViewData.PageIndex = pageData.PageIndex; pageViewData.PageSize = pageData.PageSize; pageViewData.Total = pageData.Total; List <GoodsViewModel> viewList = new List <GoodsViewModel>(); foreach (HotGoodsModel goodsInfo in pageData.Rows) { GoodsViewModel viewInfo = new GoodsViewModel(); viewInfo.couponPrice = goodsInfo.CouponDiscount.ToString("F2"); viewInfo.earnMoney = goodsInfo.PromotionAmount.ToString("F2");//????要乘一个百分比 viewInfo.finalPrice = goodsInfo.CouponedPrice.ToString("F2"); viewInfo.goodsId = goodsInfo.GoodsId; viewInfo.goodsIntro = goodsInfo.GoodsDesc; viewInfo.goodsPrice = goodsInfo.MinGroupPrice.ToString("F2"); viewInfo.imgs = goodsInfo.GoodsGalleryUrls.ToArray(); viewInfo.imgSrc = goodsInfo.GoodsThumbnailUrl; viewInfo.isFav = false;//???赋值 viewInfo.platform = header.platType; viewInfo.salesVolume = goodsInfo.SoldQuantity; viewInfo.title = goodsInfo.GoodsName; viewList.Add(viewInfo); } pageViewData.Rows = viewList; return(pageViewData); }
/// <summary> /// 根据分组ID和名称来查询图片列表 /// </summary> /// <param name="customerId">商户ID</param> /// <param name="groupId">分组ID</param> /// <param name="callback">回调</param> /// <param name="name">图片名称</param> /// <param name="page">页码</param> /// <param name="pageSize">页码大小</param> /// <returns></returns> public ActionResult GetPhotoList(int customerId, int groupId, string callback, string name, int page, int pageSize) { string resultJson = ""; string json = ""; try { HotPageData <ResultGallery[]> list = GalleryBLL.Instance.GetPhotoList(customerId, groupId, name, page, pageSize); if (list != null) { json = JsonConvert.SerializeObject(list); } else { json = JsonConvert.SerializeObject(new ApiResult(HQEnums.ResultOptionType.没有信息)); } } catch (Exception ex) { LogHelper.WriteError(string.Format("get GetGroupList --->StackTrace:{0},error:{1}", ex.StackTrace, ex.Message)); json = JsonConvert.SerializeObject(new ApiResult(HQEnums.ResultOptionType.务器错误)); } if (!string.IsNullOrEmpty(callback)) { resultJson = callback + "(" + json + ")"; } else { resultJson = json; } return(Content(resultJson, "application/json")); }
/// <summary> /// 根据Sql语句获取Json /// </summary> /// <param name="sql"></param> /// <param name="page"></param> /// <param name="pageSize"></param> /// <returns></returns> public string getJson(string sql, int page, int pageSize) { HotPageData <DataTable> data = this.getPageData(sql, page, pageSize); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" }; return(JsonConvert.SerializeObject(data, timeConverter)); }
private void button2_Click(object sender, EventArgs e) { HotPageData <List <HotGoodsModel> > pageData = GoodsProviderFactory.GetInstance(HQEnums.PlatformTypeOptions.拼多多).GetGoodsList(new HotGoodsSearchCondition() { SortField = HotGoodsSortFieldOptions.默认, SortType = HotGoodsSortTypeOptions.ASC }, out string errMsg); MessageBox.Show(JsonConvert.SerializeObject(pageData)); //HotGoodsModel goodsInfo = GoodsProviderFactory.Current.GetGoodsDetail(1523581237, out string errDetailMsg); //MessageBox.Show(JsonConvert.SerializeObject(goodsInfo)); }
public static HotPageData <T> Convert(E dt, int total, int pageSize, int page, Func <E, T> converter) { HotPageData <T> data = new HotPageData <T>(); int pageCount = total / pageSize; if (total % pageSize != 0) { ++pageCount; } data.Rows = converter(dt); data.PageCount = pageCount; data.Total = total; data.PageSize = pageSize; data.PageIndex = page; return(data); }
private void LoadList() { HotGoodsSearchCondition condition = this.GetSearchCondition(); this.BindSearchCondition(condition); HotPageData <List <HotGoodsModel> > pageData = GoodsProviderFactory.GetInstance(HQEnums.PlatformTypeOptions.拼多多).GetGoodsList(condition, out string errMsg); if (errMsg != "") { Response.Write(errMsg); Response.End(); return; } recordCount = pageData.Total; rptList.DataSource = pageData.Rows; rptList.DataBind(); pageCount = pageData.PageCount; }
public HotPageData <ResultGallery[]> GetPhotoList(int customerId, int groupId, string name, int page, int pageSize) { //PdMallSystemConfigModel configModel = PdMallSystemConfigProvider.Instance.GetCurrentConfig(); //todo string resourceSiteAddr = ""; string where = ""; if (!string.IsNullOrEmpty(name)) { where += " and Callery_Name like '%" + name + "%'"; } // string sql = string.Format(@"select Callery_ID,Callery_Customer_ID,Callery_Size,Callery_Name,Callery_ThumbnailPic,Callery_SmallPic,Callery_BigPic, // Callery_Time,Callery_UpdateTime,Photo_FatherID from HQ_Gallery where Callery_Customer_ID={0} and Photo_FatherID={1} {2} order by Callery_Time desc", customerId, groupId, where); string sql = string.Format(@"select Callery_ID,Callery_Customer_ID,Callery_Size,Callery_Name,Callery_ThumbnailPic,Callery_SmallPic,Callery_BigPic, Callery_Time,Callery_UpdateTime,Photo_FatherID from HQ_Gallery where Callery_Customer_ID={0} and Photo_FatherID={1} {2} order by Callery_ID desc", customerId, groupId, where); List <ResultGallery> list = new List <ResultGallery>(); HotPageData <ResultGallery[]> dataPager = null; HotPageData <DataTable> pager = base.getPageData(sql, page, pageSize); if (pager != null) { DataTable dt = pager.Rows; if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { ResultGallery model = DataRowToModel(row, resourceSiteAddr); list.Add(model); } } dataPager = new HotPageData <ResultGallery[]>(); dataPager.PageCount = pager.PageCount; dataPager.PageIndex = pager.PageIndex; dataPager.PageSize = pager.PageSize; dataPager.Total = pager.Total; dataPager.Rows = list.Count > 0 ? list.ToArray() : null; } return(dataPager); }
/// <summary> /// 分页获取PageData对象 /// </summary> /// <param name="sql"></param> /// <param name="page"></param> /// <param name="pageSize"></param> /// <returns></returns> public HotPageData <DataTable> getPageData(string sql, int page, int pageSize) { HotPageData <DataTable> data = new HotPageData <DataTable>(); int pageCount = 0; //页码数 int maxCount = 0; //总记录数 DataTable table = DbHelperSQL.GetSplitDataTable(sql, pageSize, page, out maxCount); if (table != null && table.Rows.Count > 0) { pageCount = maxCount / pageSize; if (maxCount % pageSize != 0) { ++pageCount; } } data.Rows = table; data.PageCount = pageCount; data.Total = maxCount; data.PageSize = pageSize; data.PageIndex = page; return(data); }
/// <summary> /// 获取图片资源库 GET: /gallery/get /// </summary> /// <param name="ownerId">业务ID</param> /// <param name="callback">此参数支持Jsonp方式 Jsonp callback参数</param> /// <param name="page">页面</param> /// <param name="pagesize">页面大小</param> /// <returns>返回json格式</returns> //[ApiAuthorizeAttribute] public ActionResult get(int ownerId, string callback, int page = 1, int pagesize = 20) { string resultJson = ""; string json = ""; try { if (ownerId == 7944) {//特殊处理 ownerId = 5020; } HotPageData <DataTable> obj = GalleryBLL.Instance.GetImgList(ownerId, "", page, pagesize); if (obj != null) { json = JsonConvert.SerializeObject(obj); } else { json = JsonConvert.SerializeObject(new ApiResult(HQEnums.ResultOptionType.没有信息)); } } catch (Exception ex) { LogHelper.WriteError(string.Format("get error --->StackTrace:{0},error:{1}", ex.StackTrace, ex.Message)); json = JsonConvert.SerializeObject(new ApiResult(HQEnums.ResultOptionType.务器错误)); } if (!string.IsNullOrEmpty(callback)) { resultJson = callback + "(" + json + ")"; } else { resultJson = json; } return(Content(resultJson, "application/json")); }
public HotPageData <List <HotGoodsModel> > GetGoodsList(HotGoodsSearchCondition condition, out string errMsg) { errMsg = ""; try { //排序转换 GoodsSortTypeOptions goodsSortType = GoodsSortTypeOptions.综合排序; switch (condition.SortField) { case HotGoodsSortFieldOptions.默认: goodsSortType = GoodsSortTypeOptions.综合排序; break; case HotGoodsSortFieldOptions.价格: goodsSortType = condition.SortType == HotGoodsSortTypeOptions.ASC ? GoodsSortTypeOptions.价格升序 : GoodsSortTypeOptions.价格降序; break; case HotGoodsSortFieldOptions.优惠券金额: goodsSortType = condition.SortType == HotGoodsSortTypeOptions.ASC ? GoodsSortTypeOptions.优惠券金额排序升序 : GoodsSortTypeOptions.优惠券金额排序降序; break; case HotGoodsSortFieldOptions.佣金比例: goodsSortType = condition.SortType == HotGoodsSortTypeOptions.ASC ? GoodsSortTypeOptions.佣金比率升序 : GoodsSortTypeOptions.佣金比例降序; break; case HotGoodsSortFieldOptions.佣金金额: goodsSortType = condition.SortType == HotGoodsSortTypeOptions.ASC ? GoodsSortTypeOptions.佣金金额升序排序 : GoodsSortTypeOptions.佣金金额降序排序; break; case HotGoodsSortFieldOptions.券后价: goodsSortType = condition.SortType == HotGoodsSortTypeOptions.ASC ? GoodsSortTypeOptions.券后价升序排序 : GoodsSortTypeOptions.券后价降序排序; break; case HotGoodsSortFieldOptions.加入时间: goodsSortType = condition.SortType == HotGoodsSortTypeOptions.ASC ? GoodsSortTypeOptions.照加入多多进宝时间升序 : GoodsSortTypeOptions.照加入多多进宝时间降序; break; case HotGoodsSortFieldOptions.销量: goodsSortType = condition.SortType == HotGoodsSortTypeOptions.ASC ? GoodsSortTypeOptions.销量升序 : GoodsSortTypeOptions.销量降序; break; } //接口数据拉取 DdkAppsModel appInfo = DdkAppProvider.Instance.GetModelByDefault(); GoodsSearchListJsonResult goodsSearchListJsonResult = DdkApi.GetGoodsList(appInfo.ClientId, appInfo.ClientSecret, new GoodsSearchConditionEntity() { cat_id = condition.CatId, goods_id_list = condition.GoodsIdList, keyword = condition.Keyword, opt_id = condition.OptId, page = condition.Page, page_size = condition.PageSize, range_list = null, with_coupon = condition.WithCoupon, sort_type = goodsSortType }); //数据加工 GoodsSearchListEntity searchListEntity = goodsSearchListJsonResult.goods_search_response; HotPageData <List <HotGoodsModel> > pageData = HotPageDataHelper <List <HotGoodsModel>, List <GoodsDetailItemEntity> > .Convert( searchListEntity.goods_list, searchListEntity.total_count, condition.PageSize, condition.Page, dt => { List <HotGoodsModel> list = new List <HotGoodsModel>(); foreach (GoodsDetailItemEntity item in dt) { list.Add(this.ConvertGoods(item)); } return(list); }); return(pageData); } catch (Exception ex) { errMsg = ex.Message; return(null); } }