/// <summary> /// 获取奖品接口 /// </summary> /// <param name="context"></param> /// <returns></returns> private string GetPrize(HttpContext context) { if (!bllUser.IsLogin) { resp.errcode = (int)APIErrCode.UserIsNotLogin; resp.errmsg = "请先登录"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } else { currentUserInfo = bllUser.GetCurrentUserInfo(); } VoteInfo voteInfo = bllVote.GetVoteInfo(voteId);//主投票信息 if (!string.IsNullOrEmpty(voteInfo.StopDate)) { if (DateTime.Now > DateTime.Parse(voteInfo.StopDate)) { VoteObjectInfo myInfo = bllVote.GetVoteObjectInfo(voteId, currentUserInfo.UserID); if (myInfo == null) { resp.errcode = 1; resp.errmsg = "未参加"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (myInfo.Ex1 == "1")//Ex1 表示是否已领奖 { resp.errcode = 1; resp.errmsg = "已领奖"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } if (myInfo.Rank == 1) { //领取奖品 ZentCloud.ZCBLLEngine.BLLTransaction tran = new ZCBLLEngine.BLLTransaction(); try { #region 获得积分 if (voteInfo.Ex1 == "0")//获得积分 { if (string.IsNullOrEmpty(voteInfo.Ex2) && (int.Parse(voteInfo.Ex2) > 0)) { int addScore = int.Parse(voteInfo.Ex2);//增加的积分 if (bllUser.Update(currentUserInfo, string.Format(" TotalScore+={0}", addScore), string.Format(" AutoID={0}", currentUserInfo.AutoID), tran) <= 0) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "更新用户积分失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } 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, tran)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "插入积分记录表失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } #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 } } #endregion #region 获得优惠券 if (voteInfo.Ex1 == "1")//获得积分 { if (string.IsNullOrEmpty(voteInfo.Ex2) && (int.Parse(voteInfo.Ex2) > 0)) { int cardCouponId = int.Parse(voteInfo.Ex2); //优惠券编号 CardCoupons cardCoupon = bllCardCoupon.GetCardCoupon(cardCouponId); //主卡券编号 MyCardCoupons myCard = new MyCardCoupons(); myCard.CardCouponNumber = string.Format("No.{0}{1}", DateTime.Now.ToString("yyyyMMdd"), new Random().Next(11111, 99999).ToString()); myCard.CardCouponType = cardCoupon.CardCouponType; myCard.CardId = cardCouponId; myCard.InsertDate = DateTime.Now; myCard.UserId = currentUserInfo.UserID; myCard.WebSiteOwner = bllUser.WebsiteOwner; if (!bllCardCoupon.Add(myCard, tran)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "领取优惠券失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } } #endregion } catch (Exception) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "领取失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } //最后更新选手领奖状态为已经领奖 myInfo.Ex1 = "1"; if (!bllVote.Update(myInfo)) { tran.Rollback(); resp.errcode = 1; resp.errmsg = "更新领奖状态失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } tran.Commit(); resp.errcode = 0; resp.errmsg = voteInfo.Prize; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } else { resp.errcode = 1; resp.errmsg = "还未到截止时间"; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); } } resp.errcode = 1; resp.errmsg = ""; return(ZentCloud.Common.JSONHelper.ObjectToJson(resp)); }
/// <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)); }