Exemplo n.º 1
0
        /// <summary>
        /// 获取当前用户信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string currentuserinfo(HttpContext context)
        {
            try
            {
                currentUserInfo = bllUser.GetUserInfo(bllUser.GetCurrUserID(), bllUser.WebsiteOwner);
                var websiteInfo = bllUser.GetWebsiteInfoModelFromDataBase();
                Open.HongWareSDK.Client hongWareClient = new Open.HongWareSDK.Client(websiteInfo.WebsiteOwner);
                //double totalScore =CurrentUserInfo.TotalScore;
                #region 使用yike积分
                if (bllCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.SyncYike, bllCommRelation.WebsiteOwner, ""))
                {
                    if ((!string.IsNullOrEmpty(currentUserInfo.Ex2)) && (!string.IsNullOrEmpty(currentUserInfo.Phone)))
                    {
                        Open.EZRproSDK.Entity.BonusGetResp yikeUser = yiKeClient.GetBonus(currentUserInfo.Ex1, currentUserInfo.Ex2, currentUserInfo.Phone);
                        if (yikeUser != null)
                        {
                            currentUserInfo.TotalScore = yikeUser.Bonus;
                        }
                        else
                        {
                            currentUserInfo.TotalScore = 0;
                        }
                    }
                }
                #endregion

                #region 使用宏巍积分余额
                if (websiteInfo.IsUnionHongware == 1)
                {
                    var hongWareMemberInfo = hongWareClient.GetMemberInfo(currentUserInfo.WXOpenId);
                    if (hongWareMemberInfo.member != null)
                    {
                        currentUserInfo.TotalScore    = Convert.ToInt32(hongWareMemberInfo.member.point);
                        currentUserInfo.AccountAmount = (decimal)hongWareMemberInfo.member.balance;
                    }
                    else
                    {
                        currentUserInfo.TotalScore    = 0;
                        currentUserInfo.AccountAmount = 0;
                    }
                }
                #endregion


                //var carOwnerInfo = bllUserEx.GetCurrUserCarOwnerInfo();
                //var bankcard = bllUser.Get<BindBankCard>(string.Format("UserId='{0}'", currentUserInfo.UserID));

                var hasidentitycardphoto = !string.IsNullOrWhiteSpace(currentUserInfo.IdentityCardPhotoFront + currentUserInfo.IdentityCardPhotoBehind + currentUserInfo.IdentityCardPhotoHandheld);
                var hasbusinessintelligencecertificatephoto = !string.IsNullOrWhiteSpace(currentUserInfo.BusinessIntelligenceCertificatePhoto1 + currentUserInfo.BusinessIntelligenceCertificatePhoto2
                                                                                         + currentUserInfo.BusinessIntelligenceCertificatePhoto3 + currentUserInfo.BusinessIntelligenceCertificatePhoto4 + currentUserInfo.BusinessIntelligenceCertificatePhoto5);
                var hasinvoicinginformation = bllUserEx.ExistUserExpand(UserExpandType.InvoicingInformation, currentUserInfo.UserID);

                var data = new
                {
                    id                 = currentUserInfo.AutoID,
                    userid             = currentUserInfo.UserID,
                    head_img_url       = bllUser.GetUserDispalyAvatar(currentUserInfo), //GetHeadImgUrl(context,CurrentUserInfo),
                    nickname           = bllUser.GetUserDispalyName(currentUserInfo),   //CurrentUserInfo.WXNickname,
                    wx_nickname        = currentUserInfo.WXNickname,
                    phone              = currentUserInfo.Phone,
                    username           = currentUserInfo.UserID,
                    unionid            = currentUserInfo.WXUnionID,
                    totalscore         = currentUserInfo.TotalScore,
                    history_totalscore = currentUserInfo.HistoryTotalScore,
                    company_name       = currentUserInfo.Company,
                    position           = currentUserInfo.Postion,
                    email              = currentUserInfo.Email,
                    truename           = currentUserInfo.TrueName,
                    ex1                = currentUserInfo.Ex1,
                    ex2                = currentUserInfo.Ex2,
                    ex3                = currentUserInfo.Ex3,
                    ex4                = currentUserInfo.Ex4,
                    ex5                = currentUserInfo.Ex5,
                    wxOpenId           = currentUserInfo.WXOpenId,
                    //carServerType = CurrentUserInfo.CarServerType,
                    //carOwnerInfo = carOwnerInfo == null ? null : new
                    //{

                    //    carModel = carOwnerInfo.CarModel == null ? null : new
                    //    {
                    //        carModelId = carOwnerInfo.CarModel.CarModelId,
                    //        carBrandId = carOwnerInfo.CarModel.CarBrandId,
                    //        carBrandName = bllCar.GetBrand(carOwnerInfo.CarModel.CarBrandId).CarBrandName,
                    //        carSeriesCateId = carOwnerInfo.CarModel.CarSeriesCateId,
                    //        carSeriesId = carOwnerInfo.CarModel.CarSeriesId,
                    //        carSeriesName = bllCar.GetSeriesInfo(carOwnerInfo.CarModel.CarSeriesId).CarSeriesName,
                    //        carModelName = carOwnerInfo.CarModel.CarModelName,
                    //        showName = carOwnerInfo.CarModel.ShowName,
                    //        allName = carOwnerInfo.CarModel.AllName,
                    //        year = carOwnerInfo.CarModel.Year,
                    //        img = carOwnerInfo.CarModel.Img,
                    //        guidePrice = carOwnerInfo.CarModel.GuidePrice,
                    //        colors = string.IsNullOrWhiteSpace(carOwnerInfo.CarModel.Colors) ? null : JsonConvert.DeserializeObject<List<BLLJIMP.Model.CarModelColorInfo>>(carOwnerInfo.CarModel.Colors).Select(c => new { name = c.Name, value = c.Value })
                    //    },
                    //    carNumber = carOwnerInfo.CarNumber,
                    //    carNumberTime = carOwnerInfo.CarNumberTime == null ? "" : carOwnerInfo.CarNumberTime.Value.ToString("yyyy-MM-dd HH:mm"),
                    //    drivingLicenseTime = carOwnerInfo.DrivingLicenseTime == null ? "" : carOwnerInfo.DrivingLicenseTime.Value.ToString("yyyy-MM-dd HH:mm"),
                    //    drivingLicenseType = carOwnerInfo.DrivingLicenseType,
                    //    vin = carOwnerInfo.VIN
                    //},
                    address        = currentUserInfo.Address,
                    imgs           = currentUserInfo.Images,
                    province       = currentUserInfo.Province,
                    province_code  = currentUserInfo.ProvinceCode,
                    city           = currentUserInfo.City,
                    city_code      = currentUserInfo.CityCode,
                    district       = currentUserInfo.District,
                    district_code  = currentUserInfo.DistrictCode,
                    identification = currentUserInfo.Ex5,
                    salary         = currentUserInfo.Salary,
                    birthday       = DateTimeHelper.DateTimeToUnixTimestamp(currentUserInfo.Birthday),
                    birthday_str   = DateTimeHelper.DateTimeToString(currentUserInfo.Birthday),
                    gender         = currentUserInfo.Gender,
                    sex            = currentUserInfo.WXSex.HasValue ? currentUserInfo.WXSex.Value : 0,
                    member_level   = currentUserInfo.MemberLevel,
                    hasqrcode      = bllUser.IsDistributionMember(currentUserInfo),
                    describe       = currentUserInfo.Description,
                    avatar         = currentUserInfo.Avatar,
                    credit_acount  = currentUserInfo.CreditAcount,
                    //hasbankcard = bankcard == null ? false : true,
                    hasidentitycardphoto                     = hasidentitycardphoto,
                    identity_card_photo_front                = currentUserInfo.IdentityCardPhotoFront,
                    identity_card_photo_behind               = currentUserInfo.IdentityCardPhotoBehind,
                    identity_card_photo_handheld             = currentUserInfo.IdentityCardPhotoHandheld,
                    hasbusinessintelligencecertificatephoto  = hasbusinessintelligencecertificatephoto,
                    intelligence_certificate_business        = currentUserInfo.IntelligenceCertificateBusiness,
                    business_intelligence_certificate_photo1 = currentUserInfo.BusinessIntelligenceCertificatePhoto1,
                    business_intelligence_certificate_photo2 = currentUserInfo.BusinessIntelligenceCertificatePhoto2,
                    business_intelligence_certificate_photo3 = currentUserInfo.BusinessIntelligenceCertificatePhoto3,
                    business_intelligence_certificate_photo4 = currentUserInfo.BusinessIntelligenceCertificatePhoto4,
                    business_intelligence_certificate_photo5 = currentUserInfo.BusinessIntelligenceCertificatePhoto5,
                    hasinvoicinginformation                  = hasinvoicinginformation,
                    websiteowner       = bllUser.WebsiteOwner,
                    account_amount     = currentUserInfo.AccountAmount,                        //账户余额
                    is_bind_hongware   = bllUser.IsBindHongWare(currentUserInfo, websiteInfo), //是否已经绑定宏巍
                    memberattribution  = currentUserInfo.MemberAttribution,
                    distribution_owner = currentUserInfo.DistributionOwner
                                         //is_attention_weixin = bllWeiXin.IsWeixinFollower(bllWeiXin.GetAccessToken(), CurrentUserInfo.WXOpenId)
                };
                return(ZentCloud.Common.JSONHelper.ObjectToJson(data));
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 使用积分点赞
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        private string AddVoteCountByScore(HttpContext context)
        {
            if (!bllUser.IsLogin)
            {
                resp.errcode = (int)APIErrCode.UserIsNotLogin;
                resp.errmsg  = "请先登录";
                return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
            }
            else
            {
                currentUserInfo = bllUser.GetCurrentUserInfo();
            }
            int      voteObjectId = int.Parse(context.Request["vote_object_id"]);
            VoteInfo voteInfo     = bllVote.GetVoteInfo(voteId);

            if (voteInfo.VoteStatus.Equals(0))
            {
                resp.errcode = 1;
                resp.errmsg  = "点赞停止";
                goto outoff;
            }
            if (!string.IsNullOrEmpty(voteInfo.StopDate))
            {
                if (DateTime.Now > (DateTime.Parse(voteInfo.StopDate)))
                {
                    resp.errcode = 1;
                    resp.errmsg  = "点赞结束";
                    goto outoff;
                }
            }
            if (voteInfo.UseScore <= 0)
            {
                resp.errcode = 1;
                resp.errmsg  = "暂未设置使用积分点赞";
                goto outoff;
            }
            #region 使用yike 积分

            if (bllCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.SyncYike, bllCommRelation.WebsiteOwner, ""))
            {
                if (!string.IsNullOrEmpty(currentUserInfo.Phone))
                {
                    Open.EZRproSDK.Entity.BonusGetResp yikeUser = yiKeClient.GetBonus(currentUserInfo.Ex1, currentUserInfo.Ex2, currentUserInfo.Phone);
                    if (yikeUser != null)
                    {
                        currentUserInfo.TotalScore = yikeUser.Bonus;
                    }
                }
            }
            #endregion
            if (currentUserInfo.TotalScore < voteInfo.UseScore)
            {
                resp.errcode = 1;
                resp.errmsg  = "很遗憾,您的积分不足";
                goto outoff;
            }
            VoteObjectInfo voteObjInfo = bllVote.GetVoteObjectInfo(voteObjectId);
            if (voteInfo == null)
            {
                resp.errcode = 1;
                resp.errmsg  = "选手编号不存在";
                goto outoff;
            }
            if (voteObjInfo.CreateUserId == currentUserInfo.UserID)
            {
                resp.errcode = 1;
                resp.errmsg  = "不可以为自己点赞哟";
                goto outoff;
            }
            if (!voteObjInfo.Status.Equals(1))
            {
                resp.errcode = 1;
                resp.errmsg  = "审核通过的选手才能点赞";
                goto outoff;
            }
            if (bllVote.UpdateVoteObjectVoteCount(voteId, voteObjectId, currentUserInfo.UserID, 1))
            {
                if (!bllVote.UpdateVoteObjectRank(voteId, "1"))
                {
                    resp.errcode = 1;
                    resp.errmsg  = "更新排名失败";
                    goto outoff;
                }
                resp.errmsg = "点赞成功!";
                currentUserInfo.TotalScore -= voteInfo.UseScore;
                if (bllUser.Update(currentUserInfo, string.Format("TotalScore-={0}", currentUserInfo.TotalScore), string.Format(" AutoID={0}", currentUserInfo.AutoID)) > 0)
                {
                    //插入积分记录
                    WBHScoreRecord scoreRecord = new WBHScoreRecord();
                    scoreRecord.InsertDate   = DateTime.Now;
                    scoreRecord.NameStr      = string.Format("参加今日我最美点赞,使用{0}积分", voteInfo.UseScore);
                    scoreRecord.RecordType   = "1";
                    scoreRecord.ScoreNum     = voteInfo.UseScore.ToString();
                    scoreRecord.UserId       = currentUserInfo.UserID;
                    scoreRecord.WebsiteOwner = bllUser.WebsiteOwner;
                    if (!bllUser.Add(scoreRecord))
                    {
                        resp.errcode = 1;
                        resp.errmsg  = "插入积分记录失败";
                        goto outoff;
                    }
                    //积分记录
                    #region 扣除yike 积分

                    if (bllCommRelation.ExistRelation(BLLJIMP.Enums.CommRelationType.SyncYike, bllCommRelation.WebsiteOwner, ""))
                    {
                        if (!string.IsNullOrEmpty(currentUserInfo.Phone))
                        {
                            yiKeClient.BonusUpdate(currentUserInfo.Ex2, -(voteInfo.UseScore), "参加今日我最美使用积分" + voteInfo.UseScore);
                        }
                    }
                    #endregion
                }
                else
                {
                    resp.errcode = 1;
                    resp.errmsg  = "更新用户积分失败";
                    goto outoff;
                }
            }
            else
            {
                resp.errcode = 1;
                resp.errmsg  = "点赞失败";
            }
outoff:
            return(ZentCloud.Common.JSONHelper.ObjectToJson(resp));
        }