Esempio n. 1
0
        public JsonResult OftenBuy(string userId, string entId, string searchValue, int pageIndex = 1, int pageSize = 15)
        {
            try
            {
                if (string.IsNullOrEmpty(entId) || string.IsNullOrEmpty(userId))
                {
                    return(Json(new { success = false, message = "请先登录" }));
                }
                //获取用户信息
                UserInfoDal     dal  = new UserInfoDal();
                List <UserInfo> user = new List <UserInfo>();
                if (!string.IsNullOrEmpty(userId))
                {
                    user = dal.GetUserInfo(userId, entId);
                }
                string jgjb = "", clientlimit = "", KhType = "";
                bool   landing    = false;
                bool   staleDated = false;
                if (user.Count > 0)
                {
                    entId       = user[0].EntId;
                    jgjb        = user[0].Pricelevel;
                    clientlimit = user[0].ClientLimit;
                    KhType      = user[0].KhType;
                    staleDated  = user[0].StaleDated;
                    landing     = true;
                }

                GoodsInfoDal infoDal = new GoodsInfoDal();
                if (searchValue.Trim().Contains(" "))
                {
                    int    length = searchValue.Length;
                    int    index = searchValue.IndexOf(" ");
                    string goodsValue, factoryValue;
                    goodsValue   = searchValue.Substring(0, index).Trim();
                    factoryValue = searchValue.Substring(index, length - index).ToString().Trim();
                    searchValue  = goodsValue + ',' + factoryValue;
                }
                List <GoodsList> lists = new List <GoodsList>();
                lists = infoDal.OftenBuy(userId, entId, searchValue, jgjb, KhType, landing, staleDated, pageIndex, pageSize, out int pageCount, out int recordCount);
                return(Json(new { success = true, message = "常购商品获取成功", lists, pageCount, recordCount }));
            }
            catch (Exception ex)
            {
                LogQueue.Write(LogType.Error, "Search/OftenBuy", $"{ex.Message}");
                return(Json(new { success = false, message = "常购商品获取失败!" }));
            }
        }