Пример #1
0
        public ActionResult getListMyFavoriteMsg()
        {
            returnObj = new Return_Msg_APP();
            string appId     = Context.GetRequest("appId", string.Empty);
            int    userId    = Context.GetRequestInt("userId", 0);//帖子信息Id
            int    pageSize  = Context.GetRequestInt("pageSize", 10);
            int    pageIndex = Context.GetRequestInt("pageIndex", 1);

            if (string.IsNullOrEmpty(appId) || userId <= 0)
            {
                returnObj.code = "200";
                returnObj.Msg  = "参数错误";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.code = "200";
                returnObj.Msg  = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            int            totalCount = 0;
            List <CityMsg> list       = CityUserFavoriteMsgBLL.SingleModel.getListMyFavoriteMsg(r.Id, userId, out totalCount, pageSize, pageIndex);

            list.ForEach(x =>
            {
                CityUserFavoriteMsg _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, x.Id, userId, 1);
                x.isDzed = (_userFavoriteMsg != null);
                CityMsgReport city_MsgReport = CityMsgReportBLL.SingleModel.GetCityMsgReport(userId, x.Id);
                x.isReported = (city_MsgReport != null);
            });
            returnObj.isok    = true;
            returnObj.Msg     = "获取成功";
            returnObj.dataObj = new { totalCount = totalCount, list = list.OrderByDescending(x => x.FavoriteId) };
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public ActionResult getMsgList()
        {
            returnObj      = new Return_Msg_APP();
            returnObj.code = "200";
            int    userId    = Context.GetRequestInt("userId", 0);
            string appId     = Context.GetRequest("appId", string.Empty);
            string keyMsg    = Context.GetRequest("keyMsg", string.Empty);
            int    orderType = Context.GetRequestInt("orderType", 0); //默认为0 表示最新发布  1表示距离最近
            int    msgTypeId = Context.GetRequestInt("msgTypeId", 0); //默认为0 表示获取所有
            int    pageSize  = Context.GetRequestInt("pageSize", 10);
            int    pageIndex = Context.GetRequestInt("pageIndex", 1);
            string latStr    = Context.GetRequest("lat", string.Empty);
            string lngStr    = Context.GetRequest("lng", string.Empty);

            if (string.IsNullOrEmpty(appId))
            {
                returnObj.Msg = "参数错误";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.Msg = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }
            int commentTotalCount = 0;
            int totalCount        = 0;

            List <CityMsg> list = new List <CityMsg>();

            if (orderType == 1)
            {
                double lat = 0.00;
                double lng = 0.00;
                //表示按照距离最近的
                //表示没有传坐标 通过客户端IP获取经纬度
                // log4net.LogHelper.WriteInfo(this.GetType(), $"!!!!orderType={orderType};{lat},{lng}");
                if (!double.TryParse(latStr, out lat) || !double.TryParse(lngStr, out lng) || lat == 0 || lng == 0)
                {
                    string IP = WebHelper.GetIP();

                    IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP);
                    if (iPToPoint != null && iPToPoint.result != null)
                    {
                        lat = iPToPoint.result.location.lat;
                        lng = iPToPoint.result.location.lng;
                        //log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}");
                    }
                }
                //log4net.LogHelper.WriteInfo(this.GetType(),$"orderType={orderType};{lat},{lng}" );
                list = CityMsgBLL.SingleModel.getListCity_Msg(r.Id, out totalCount, pageSize, pageIndex, msgTypeId, keyMsg, 1, lat, lng);
                list.ForEach(x =>
                {
                    x.distance = CityMsgBLL.SingleModel.GetDistance(Convert.ToDouble(x.lat), Convert.ToDouble(x.lng), lat, lng);
                    if (x.distance < 1)
                    {
                        x.distanceStr = (x.distance * 1000).ToString("0.00") + "m";
                    }
                    else
                    {
                        x.distanceStr = x.distance.ToString("0.00") + "km";
                    }
                    CityUserFavoriteMsg _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, x.Id, userId, 1);
                    x.isDzed = (_userFavoriteMsg != null);

                    CityMsgReport city_MsgReport = CityMsgReportBLL.SingleModel.GetCityMsgReport(userId, x.Id);
                    x.isReported = (city_MsgReport != null);


                    x.Comments = CityMsgCommentBLL.SingleModel.GetCityMsgComment(x.aid, out commentTotalCount, string.Empty, 1000, 1, x.Id);
                });
            }
            else
            {
                list = CityMsgBLL.SingleModel.getListCity_Msg(r.Id, out totalCount, pageSize, pageIndex, msgTypeId, keyMsg);

                list.ForEach(x =>
                {
                    CityUserFavoriteMsg _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, x.Id, userId, 1);
                    x.isDzed = (_userFavoriteMsg != null);
                    CityMsgReport city_MsgReport = CityMsgReportBLL.SingleModel.GetCityMsgReport(userId, x.Id);
                    x.isReported = (city_MsgReport != null);


                    x.Comments = CityMsgCommentBLL.SingleModel.GetCityMsgComment(x.aid, out commentTotalCount, string.Empty, 1000, 1, x.Id);
                });
            }

            returnObj.isok    = true;
            returnObj.Msg     = "获取成功";
            returnObj.dataObj = new { totalCount = totalCount, list = list };
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
        public ActionResult getMsgDetail()
        {
            returnObj = new Return_Msg_APP();
            string appId  = Context.GetRequest("appId", string.Empty);
            int    msgId  = Context.GetRequestInt("msgId", 0);  //帖子信息Id
            int    userId = Context.GetRequestInt("userId", 0); //用户Id
            string latStr = Context.GetRequest("lat", string.Empty);
            string lngStr = Context.GetRequest("lng", string.Empty);

            if (string.IsNullOrEmpty(appId) || msgId <= 0)
            {
                returnObj.code = "200";
                returnObj.Msg  = "参数错误";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            XcxAppAccountRelation r = _xcxAppAccountRelationBLL.GetModelByAppid(appId);

            if (r == null)
            {
                returnObj.code = "200";
                returnObj.Msg  = "小程序未授权";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }


            CityMsg model = CityMsgBLL.SingleModel.getMsg(r.Id, msgId);

            if (model == null)
            {
                returnObj.code = "200";
                returnObj.Msg  = "找不到数据";
                return(Json(returnObj, JsonRequestBehavior.AllowGet));
            }

            double lat = 0.00;
            double lng = 0.00;

            //表示按照距离最近的
            //表示没有传坐标 通过客户端IP获取经纬度
            // log4net.LogHelper.WriteInfo(this.GetType(), $"!!!!orderType={orderType};{lat},{lng}");
            if (!double.TryParse(latStr, out lat) || !double.TryParse(lngStr, out lng) || lat <= 0 || lng <= 0)
            {
                string IP = WebHelper.GetIP();

                IPToPoint iPToPoint = CommondHelper.GetLoctionByIP(IP);
                if (iPToPoint != null)
                {
                    lat = iPToPoint.result.location.lat;
                    lng = iPToPoint.result.location.lng;
                    // log4net.LogHelper.WriteInfo(this.GetType(), $"IP={IP};{lat},{lng}");
                }
            }
            model.distance = CityMsgBLL.SingleModel.GetDistance(Convert.ToDouble(model.lat), Convert.ToDouble(model.lng), lat, lng);

            CityUserFavoriteMsg _userFavoriteMsg = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, msgId, userId);

            model.isFavorited = (_userFavoriteMsg != null);
            _userFavoriteMsg  = CityUserFavoriteMsgBLL.SingleModel.getCity_UserFavoriteMsg(r.Id, msgId, userId, 1);
            model.isDzed      = (_userFavoriteMsg != null);
            CityMsgReport city_MsgReport = CityMsgReportBLL.SingleModel.GetCityMsgReport(userId, msgId);

            model.isReported = (city_MsgReport != null);
            int commentTotalCount = 0;

            model.Comments    = CityMsgCommentBLL.SingleModel.GetCityMsgComment(r.Id, out commentTotalCount, string.Empty, 1000, 1, model.Id);
            returnObj.isok    = true;
            returnObj.Msg     = "获取成功";
            returnObj.dataObj = new { msg = model };
            return(Json(returnObj, JsonRequestBehavior.AllowGet));
        }
Пример #4
0
        /// <summary>
        /// 获取商品评论
        /// </summary>
        /// <param name="aid"></param>
        /// <param name="goodsid"></param>
        /// <param name="storeid"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <param name="reflesh"></param>
        /// <returns></returns>
        public List <GoodsComment> GetGoodsCommentListApi(int aid, int goodsid, int userid, int storeid, int pageIndex, int pageSize, int haveimg, ref int count, bool reflesh = true)
        {
            string paramsqlwhere = "";

            if (haveimg >= 0)
            {
                paramsqlwhere = $" and gc.haveimg={haveimg}";
                reflesh       = true;
            }

            RedisModel <GoodsComment> model = new RedisModel <GoodsComment>();

            model = RedisUtil.Get <RedisModel <GoodsComment> >(string.Format(_redis_GoodsCommentApiKey, aid, storeid, goodsid, pageSize, pageIndex));
            int dataversion = RedisUtil.GetVersion(string.Format(_redis_GoodsCommentVersion, aid));

            if (reflesh || model == null || model.DataList == null || model.DataList.Count <= 0 || model.DataVersion != dataversion)
            {
                model = new RedisModel <GoodsComment>();
                List <GoodsComment> list = new List <GoodsComment>();

                string sqlcount = $" select Count(*) from GoodsComment gc";
                string sql      = $" select gc.*,cu.HeadImgUrl from GoodsComment gc left join c_userinfo cu on gc.userid = cu.Id ";
                string sqlwhere = $" where gc.state>-1 and gc.aid = {aid} and gc.storeid={storeid} and gc.goodsid={goodsid} and gc.hidden=0 {paramsqlwhere}";
                string sqllimit = $" ORDER BY gc.addtime desc LIMIT {(pageIndex - 1) * pageSize},{pageSize} ";

                using (MySqlDataReader dr = SqlMySql.ExecuteDataReaderMaster(connName, CommandType.Text, sql + sqlwhere + sqllimit))
                {
                    while (dr.Read())
                    {
                        GoodsComment amodel = base.GetModel(dr);
                        if (amodel != null)
                        {
                            amodel.HeadImgUrl  = dr["HeadImgUrl"].ToString();
                            amodel.CommentImgs = C_AttachmentBLL.SingleModel.GetListByCache(amodel.Id, (int)AttachmentItemType.小程序商品评论轮播图);
                            list.Add(amodel);
                        }
                    }
                }

                if (list == null || list.Count <= 0)
                {
                    return(new List <GoodsComment>());
                }

                //点赞
                string ids = string.Join(",", list.Select(s => s.Id));
                List <CityUserFavoriteMsg> pointslist = CityUserFavoriteMsgBLL.SingleModel.GetListByaidAndMIds(aid, userid, ids, 1, (int)PointsDataType.评论);
                if (pointslist != null && pointslist.Count > 0)
                {
                    foreach (GoodsComment item in list)
                    {
                        CityUserFavoriteMsg pmodel = pointslist.FirstOrDefault(f => f.msgId == item.Id);
                        if (pmodel != null && pmodel.state == 0)
                        {
                            item.UserPoints = true;
                        }
                    }
                }

                count             = base.GetCountBySql(sqlcount + sqlwhere);
                model.DataList    = list;
                model.DataVersion = dataversion;
                model.Count       = count;

                if (paramsqlwhere == "")
                {
                    RedisUtil.Set <RedisModel <GoodsComment> >(string.Format(_redis_GoodsCommentApiKey, aid, storeid, goodsid, pageSize, pageIndex), model);
                }
            }
            else
            {
                count = model.Count;
            }


            return(model.DataList);
        }