Exemplo n.º 1
0
        /// <summary>
        /// 谁看过我,谁关注我,谁收藏我,谁点赞我列表数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetOtherFavoriteList()
        {
            returnObj = new Return_Msg_APP();
            int    actionType = Context.GetRequestInt("actiontype", (int)PointsActionType.收藏);
            int    myCardId   = Context.GetRequestInt("mycardid", 0);
            int    userId     = Context.GetRequestInt("userid", 0);
            int    aid        = Context.GetRequestInt("aid", 0);
            int    dataType   = Context.GetRequestInt("datatype", (int)PointsDataType.片);
            int    pageIndex  = Context.GetRequestInt("pageindex", 1);
            int    pageSize   = Context.GetRequestInt("pagesize", 10);
            int    type       = Context.GetRequestInt("type", 0);
            string lng        = Context.GetRequest("lng", "0");
            string lat        = Context.GetRequest("lat", "0");
            int    ver        = Context.GetRequestInt("ver", 0);

            if (myCardId <= 0)
            {
                returnObj.Msg = "我的名片ID不能小于0";
                return(Json(returnObj));
            }
            if (userId <= 0)
            {
                returnObj.Msg = "userid不能小于0";
                return(Json(returnObj));
            }
            if (aid <= 0)
            {
                returnObj.Msg = "aid不能小于0";
                return(Json(returnObj));
            }
            PlatMyCard myCard = PlatMyCardBLL.SingleModel.GetModelByUserId(userId, aid);

            if (myCard != null)
            {
                lng = myCard.Lng.ToString();
                lat = myCard.Lat.ToString();
            }

            int count = 0;

            switch (dataType)
            {
            case (int)PointsDataType.片:
                if (actionType == (int)PointsActionType.私信)
                {
                    List <PlatUserFavoriteMsg> myCardList = PlatUserFavoriteMsgBLL.SingleModel.GetMyCardUserFavoriteList(ver, myCard.Id, userId, aid, pageIndex, pageSize, ref count);
                    returnObj.dataObj = new { list = myCardList, count = count };
                }
                else
                {
                    List <PlatUserFavoriteMsg> mycardlist = PlatUserFavoriteMsgBLL.SingleModel.GetMyCardUserFavoriteList(myCard.AppId, lng, lat, userId, type, aid, myCardId, actionType, dataType, pageIndex, pageSize, ref count);
                    returnObj.dataObj = new { list = mycardlist, count = count };
                }

                break;

            case (int)PointsDataType.帖子:
                List <PlatUserFavoriteMsg> msgList = PlatUserFavoriteMsgBLL.SingleModel.GetMsgUserFavoriteList(type, aid, myCardId, actionType, dataType, pageIndex, pageSize, ref count);
                returnObj.dataObj = new { list = msgList, count = count };
                break;

            case (int)PointsDataType.店铺:
                List <PlatStore> storeList = PlatUserFavoriteMsgBLL.SingleModel.GetListMyFavoriteStore(aid, userId, out count, pageSize, pageIndex);


                //表示没有传坐标 通过客户端IP获取经纬度
                IPToPoint iPToPoint = new IPToPoint();
                if (lng == "0" || lat == "0")
                {
                    string IP = WebHelper.GetIP();

                    iPToPoint = CommondHelper.GetLoctionByIP(IP);
                    if (iPToPoint != null && iPToPoint.result != null)
                    {
                        lat = iPToPoint.result.location.lat.ToString();
                        lng = iPToPoint.result.location.lng.ToString();
                    }
                }
                double distance = 0.00;
                storeList.ForEach(x =>
                {
                    distance = CommondHelper.GetDistance(x.Lat, x.Lng, Convert.ToDouble(lat), Convert.ToDouble(lng));
                    if (distance < 1)
                    {
                        x.Distance = (distance * 1000).ToString() + "m";
                    }
                    else
                    {
                        x.Distance = distance.ToString() + "km";
                    }
                });

                returnObj.dataObj = new { list = storeList, count = count };
                break;
            }
            returnObj.isok = true;
            return(Json(returnObj));
        }