Exemplo n.º 1
0
        /// <summary>
        /// 获取京东商品列表
        /// </summary>
        /// <param name="user_id">用户id</param>
        /// <param name="eliteId">频道id:1-好券商品,2-超级大卖场,10-9.9专区,22-热销爆品,23-为你推荐,24-数码家电,25-超市,26-母婴玩具,27-家具日用,28-美妆穿搭,29-医药保健,30-图书文具,31-今日必推,32-品牌好货,33-秒杀商品,34-拼购商品,109-新品首发,110-自营,125-首购商品</param>
        /// <param name="pageIndex">页码,默认1</param>
        /// <param name="pageSize">每页数量,默认20,上限50</param>
        /// <param name="sortname">排序字段(price:单价, commissionShare:佣金比例, commission:佣金, inOrderCount30DaysSku:sku维度30天引单量,comments:评论数,goodComments:好评数)</param>
        /// <param name="sort">asc,desc升降序,默认降序</param>
        /// <returns></returns>
        public ActionResult Get_JD_GoodList(int user_id, int eliteId, int pageIndex = 1, int pageSize = 20, string sortname = "price", string sort = "desc")
        {
            try
            {
                string appid    = CheckAPPID();
                string cacheKey = Md5Helper.Hash("JDGoodList" + eliteId + pageIndex + pageSize + sortname + sort);
                List <JFGoodsRespRow> jFGoodsRespRows      = redisCache.Read <List <JFGoodsRespRow> >(cacheKey, 7L);
                dm_basesettingEntity  dm_BasesettingEntity = dM_BaseSettingIBLL.GetEntityByCache(appid);
                if (jFGoodsRespRows == null)
                {
                    JDApi jDApi = new JDApi(dm_BasesettingEntity.jd_appkey, dm_BasesettingEntity.jd_appsecret, dm_BasesettingEntity.jd_sessionkey);
                    jFGoodsRespRows = jDApi.GetGoodList(eliteId, pageIndex, pageSize, sortname, sort);

                    if (jFGoodsRespRows.Count > 0)
                    {
                        redisCache.Write(cacheKey, jFGoodsRespRows, DateTime.Now.AddHours(2.0), 7L);
                    }
                    else
                    {
                        return(Fail("没有更多数据了"));
                    }
                }
                dm_userEntity dm_UserEntity = dm_userIBLL.GetEntityByCache(user_id);

                return(SuccessList("获取成功!", jFGoodsRespRows.Select(t => { t.LevelCommission = GetJDCommissionRate(t.couponCommission, dm_UserEntity.userlevel, dm_BasesettingEntity); t.SuperCommission = GetJDCommissionRate(t.couponCommission, 2, dm_BasesettingEntity); return t; })));
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }
        public ActionResult Search_JD_Good(string AppID, int EliteID, int PageNo = 1, int PageSize = 20, string SortName = "price", string Sort = "desc")
        {
            try
            {
                s_application_settingEntity s_Application_SettingEntity = application_SettingIBLL.GetEntityByApplicationId(AppID);
                JDApi jDApi   = new JDApi(s_Application_SettingEntity.F_JD_AppKey, s_Application_SettingEntity.F_JD_Secret, s_Application_SettingEntity.F_JD_SessionKey);
                var   jDGoods = jDApi.GetGoodList(EliteID, PageNo, PageSize, SortName, Sort);

                return(Success("商品查询成功!", jDGoods));
            }
            catch (Exception ex)
            {
                return(Fail(ex.Message));
            }
        }