//给用户增加积分(负值为减积分),同时写入积分历史,返回修改的delta分值, //并调用微信模板消息通知用户 public double UpdateUserScoreWithWXTMNotify(UserScore userScore, string accessToken) { double deltaScore = UpdateUserScore(userScore); if ((int)deltaScore != 0 && accessToken != string.Empty) { switch (userScore.UserScoreType) { case UserScoreType.ShareActivityToWXFriendGroup: case UserScoreType.ShareArticleToWXFriendGroup: case UserScoreType.SharePositionToWXFriendGroup: case UserScoreType.ShareTutorToWXFriendGroup: case UserScoreType.TutorShareActivityToWXFriendGroup: case UserScoreType.TutorShareArticleToWXFriendGroup: case UserScoreType.TutorShareTutorToWXFriendGroup: case UserScoreType.TutorSharePositionToWXFriendGroup: System.Threading.Thread.Sleep(30 * 1000); break; default: break; } BLLJIMP.BLLWeixin bllWeixin = new BLLWeixin(""); BLLWeixin.TMScoreNotification notificaiton = new BLLWeixin.TMScoreNotification(); notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/Index.aspx", System.Web.HttpContext.Current.Request.Url.Host); notificaiton.TemplateId = "8JLCEV3HmIYV3C3bDiGARxRBJqAZosnQEOI4C0d5He4"; notificaiton.First = "您有新的积分变化,详情如下"; notificaiton.Account = userInfo.WXNickname; notificaiton.Time = DateTime.Now.ToString(); notificaiton.Type = userScore.RecordTypeString; notificaiton.CreditChange = "变化"; notificaiton.Number = userScore.Score.ToString(); notificaiton.Amount = userInfo.TotalScore.ToString(); notificaiton.Remark = "您可以点击下方菜单进入五步会,赚取更多积分!"; bllWeixin.SendTemplateMessage(accessToken, userInfo.WXOpenId, notificaiton); } return(deltaScore); }
public static string SendTMUserScoreDailyAccountBillNotify(string receiverUserId, string websiteOwner) { BLLWeixin bllWeixin = new BLLWeixin(""); BLLWeixin.TMScoreNotification notificaiton = new BLLWeixin.TMScoreNotification(); notificaiton.Url = string.Format("http://{0}/WuBuHui/MyCenter/Index.aspx", System.Web.HttpContext.Current.Request.Url.Host); notificaiton.TemplateId = "8JLCEV3HmIYV3C3bDiGARxRBJqAZosnQEOI4C0d5He4"; notificaiton.First = "您今日的积分对账单,详情如下"; notificaiton.Account = "积分账户"; notificaiton.Time = DateTime.Now.ToString(); notificaiton.Type = "每日积分对账单"; //notificaiton.CreditChange = "每日积分对账单"; UserInfo userInfo = bllWeixin.Get <UserInfo>(string.Format("UserId='{0}' and WebsiteOwner='{1}'", receiverUserId, websiteOwner)); if (userInfo == null) { return(string.Format("用户 {0} 不存在", receiverUserId)); } notificaiton.Number = userInfo.TotalScore.ToString(); notificaiton.Amount = userInfo.TotalScore.ToString(); notificaiton.Remark = "您可以点击下方菜单进入五步会,赚取更多积分!"; return(bllWeixin.SendTemplateMessage(bllWeixin.GetAccessToken(), userInfo.WXOpenId, notificaiton)); }