示例#1
0
        /// <summary>
        /// 获取名片
        /// </summary>
        /// <returns></returns>
        public ActionResult GetMyCard()
        {
            returnObj = new Return_Msg_APP();
            int userId   = Context.GetRequestInt("userid", 0);
            int myuserId = Context.GetRequestInt("myuserid", 0);
            int aid      = Context.GetRequestInt("aid", 0);

            if (userId <= 0 || myuserId <= 0)
            {
                returnObj.Msg = "userid不能小于0";
                return(Json(returnObj));
            }
            if (aid <= 0)
            {
                returnObj.Msg = "aid不能小于0";
                return(Json(returnObj));
            }

            PlatMyCard platMyCardModel = PlatMyCardBLL.SingleModel.GetMyCardData(userId, myuserId, aid, (int)PointsDataType.片);

            if (platMyCardModel == null || platMyCardModel.Id <= 0)
            {
                returnObj.Msg     = "您还没有创建名片";
                returnObj.dataObj = platMyCardModel;
                return(Json(returnObj));
            }
            //判断是否已保存appid
            if (string.IsNullOrEmpty(platMyCardModel.AppId))
            {
                C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModel(platMyCardModel.UserId);
                platMyCardModel.AppId = userinfo.appId;
                PlatMyCardBLL.SingleModel.Update(platMyCardModel, "appid");
            }

            bool isReload = false;

            //获取服务器商的图片路径
            platMyCardModel.ImgUrl = WxUploadHelper.GetMyServerImgUrl(platMyCardModel.ImgUrl, ref isReload);
            if (isReload)
            {
                PlatMyCardBLL.SingleModel.Update(platMyCardModel, "ImgUrl");
            }

            returnObj.dataObj = platMyCardModel;
            returnObj.isok    = platMyCardModel.Id > 0;
            returnObj.Msg     = returnObj.isok ? "成功" : "失败";
            return(Json(returnObj));
        }
示例#2
0
        /// <summary>
        /// 创建名片
        /// </summary>
        /// <returns></returns>
        public ActionResult AddMyCard()
        {
            returnObj = new Return_Msg_APP();
            string imgUrl      = Context.GetRequest("imgurl", "");
            string companyName = Context.GetRequest("companyname", "");
            int    userId      = Context.GetRequestInt("userid", 0);
            int    jobType     = Context.GetRequestInt("jobtype", 0);
            string lat         = Context.GetRequest("lat", "0");
            string lng         = Context.GetRequest("lng", "0");
            string name        = Context.GetRequest("name", "");
            string address     = Context.GetRequest("address", "");
            string job         = Context.GetRequest("job", "");
            string department  = Context.GetRequest("department", "");
            string desc        = Context.GetRequest("desc", "");
            int    industryIid = Context.GetRequestInt("industryid", 0);
            int    hiddenPhone = Context.GetRequestInt("hiddenphone", 0);
            int    type        = Context.GetRequestInt("type", 0);

            if (userId <= 0)
            {
                returnObj.Msg = "userid不能小于0";
                return(Json(returnObj));
            }
            if (type == 1)
            {
                if (string.IsNullOrEmpty(lat))
                {
                    returnObj.Msg = "lat不能小于0";
                    return(Json(returnObj));
                }
                if (string.IsNullOrEmpty(lng))
                {
                    returnObj.Msg = "lng不能为空";
                    return(Json(returnObj));
                }
                if (string.IsNullOrEmpty(address))
                {
                    returnObj.Msg = "地址不能为空";
                    return(Json(returnObj));
                }
                if (string.IsNullOrEmpty(name))
                {
                    returnObj.Msg = "姓名不能为空";
                    return(Json(returnObj));
                }
                if (industryIid <= 0)
                {
                    returnObj.Msg = "请选择行业";
                    return(Json(returnObj));
                }
            }

            C_UserInfo userinfo = C_UserInfoBLL.SingleModel.GetModel(userId);

            if (userinfo == null)
            {
                returnObj.Msg = "用户已失效";
                return(Json(returnObj));
            }
            XcxAppAccountRelation xcxrelatiion = _xcxAppAccountRelationBLL.GetModelByAppid(userinfo.appId);

            if (xcxrelatiion == null)
            {
                returnObj.Msg = "模板已失效";
                return(Json(returnObj));
            }
            int aid = xcxrelatiion.Id;

            PlatMyCard platMyCardModel = PlatMyCardBLL.SingleModel.GetModelByUserId(userId, aid);

            //地址
            if (!string.IsNullOrEmpty(lng) && lng != "0" && !string.IsNullOrEmpty(lat) && lat != "0")
            {
                AddressApi addressinfo = AddressHelper.GetAddressByApi(lng, lat);
                if (addressinfo != null && addressinfo.result != null && addressinfo.result.address_component != null)
                {
                    string provinceName          = addressinfo.result.address_component.province;
                    string cityName              = addressinfo.result.address_component.city;
                    string countryName           = addressinfo.result.address_component.district;
                    Dictionary <string, int> dic = C_AreaBLL.SingleModel.GetAddressCode(provinceName, cityName, countryName);
                    if (platMyCardModel == null)
                    {
                        platMyCardModel = new PlatMyCard();
                    }
                    platMyCardModel.ProvinceCode = dic["provincename"];
                    platMyCardModel.ProvinceCode = dic["cityname"];
                    platMyCardModel.ProvinceCode = dic["countryName"];
                }
            }
            imgUrl = string.IsNullOrEmpty(imgUrl) ? userinfo.HeadImgUrl : imgUrl;
            //获取服务器商的图片路径
            bool isreload = false;

            imgUrl = WxUploadHelper.GetMyServerImgUrl(imgUrl, ref isreload);

            if (platMyCardModel == null || platMyCardModel.Id <= 0)
            {
                platMyCardModel             = new PlatMyCard();
                platMyCardModel.AddTime     = DateTime.Now;
                platMyCardModel.Address     = address;
                platMyCardModel.AId         = aid;
                platMyCardModel.CompanyName = companyName;
                platMyCardModel.Desc        = desc;
                platMyCardModel.ImgUrl      = imgUrl;
                platMyCardModel.JobType     = jobType;
                platMyCardModel.Lat         = Convert.ToDouble(lat);
                platMyCardModel.Lng         = Convert.ToDouble(lng);
                platMyCardModel.Name        = name;
                platMyCardModel.NickName    = userinfo.NickName;
                platMyCardModel.Phone       = userinfo.TelePhone;
                platMyCardModel.UpdateTime  = DateTime.Now;
                platMyCardModel.UserId      = userId;
                platMyCardModel.Job         = job;
                platMyCardModel.Department  = department;
                platMyCardModel.IndustryId  = industryIid;
                platMyCardModel.HiddenPhone = hiddenPhone;
                platMyCardModel.AppId       = userinfo.appId;
                platMyCardModel.Id          = Convert.ToInt32(PlatMyCardBLL.SingleModel.Add(platMyCardModel));
                returnObj.isok = platMyCardModel.Id > 0;
            }
            else
            {
                platMyCardModel.AddTime     = DateTime.Now;
                platMyCardModel.Address     = address;
                platMyCardModel.AId         = aid;
                platMyCardModel.CompanyName = companyName;
                platMyCardModel.Desc        = "";
                platMyCardModel.ImgUrl      = imgUrl;
                platMyCardModel.JobType     = jobType;
                platMyCardModel.Lat         = Convert.ToDouble(lat);
                platMyCardModel.Lng         = Convert.ToDouble(lng);
                platMyCardModel.Name        = name;
                platMyCardModel.NickName    = userinfo.NickName;
                platMyCardModel.Phone       = userinfo.TelePhone;
                platMyCardModel.UpdateTime  = DateTime.Now;
                platMyCardModel.UserId      = userId;
                platMyCardModel.IndustryId  = industryIid;
                platMyCardModel.HiddenPhone = hiddenPhone;
                if (!string.IsNullOrEmpty(job))
                {
                    platMyCardModel.Job = job;
                }
                if (!string.IsNullOrEmpty(department))
                {
                    platMyCardModel.Department = department;
                }
                if (!string.IsNullOrEmpty(companyName))
                {
                    platMyCardModel.CompanyName = companyName;
                }
                if (!string.IsNullOrEmpty(desc))
                {
                    platMyCardModel.Desc = desc;
                }
                returnObj.isok = PlatMyCardBLL.SingleModel.Update(platMyCardModel);
            }
            returnObj.Msg     = returnObj.isok ? "保存成功" : "保存失败";
            returnObj.dataObj = platMyCardModel;
            return(Json(returnObj));
        }