예제 #1
0
        public IHttpActionResult DelCollectSupplier(JObject request)
        {
            Logger.WriterLogger("Supplier.DelCollectSupplier, Params: " + request.ToString(), LoggerType.Info);

            ParamCollectSupplier param = new ParamCollectSupplier();

            try
            {
                param = request.ToObject <ParamCollectSupplier>();
            }
            catch
            {
                // 参数无效
                return(base.JsonFaultResult(new CommonException(40100).GetMessage(), request.ToString()));
            }

            string accessToken = param.accessToken;

            // 验证令牌
            int accessTookenCode = VerifyAccessToken(accessToken);

            if (accessTookenCode > 0)
            {
                return(base.JsonFaultResult(new CommonException(accessTookenCode).GetMessage(), request.ToString()));
            }


            string userId = param.UserId;

            int    channel  = param.channel;
            int    platform = param.platform;
            string ver      = param.ver;

            // 保存访问信息
            base.SaveVisitInfo(userId, channel, platform, ver);

            Member member = GetMember(userId.ToSeesionId());

            if (member != null)
            {
                if (!SupplierHelper.SupplierIsCollect(member.UserId, param.SupplierId))
                {
                    StandardResult <string> result = new StandardResult <string>()
                    {
                        code = 1,
                        msg  = "不存在该收藏",
                        data = ""
                    };

                    return(base.JsonActionResult(result));
                }


                if (SupplierHelper.DelCollectSupplier(member.UserId, param.SupplierId))
                {
                    StandardResult <string> result = new StandardResult <string>()
                    {
                        code = 0,
                        msg  = "店铺取消收藏成功",
                        data = ""
                    };

                    return(base.JsonActionResult(result));
                }

                else
                {
                    StandardResult <string> result = new StandardResult <string>()
                    {
                        code = 1,
                        msg  = "店铺取消收藏失败",
                        data = ""
                    };

                    return(base.JsonActionResult(result));
                }
            }

            else
            {
                return(base.JsonFaultResult(new CommonException(40201).GetMessage(), request.ToString()));
            }
        }