protected void lbtn_ZF_Click(object sender, EventArgs e) { try { string ids = this.hf_CheckIDS.Value.TrimEnd(','); if (string.IsNullOrEmpty(ids)) { ShowMessage("请至少选择一条记录"); return; } using (IFMPDBContext db = new IFMPDBContext()) { foreach (string id in ids.Split(',')) { int selid = Convert.ToInt32(id); ScoreUser ScoreUser = db.ScoreUser.FirstOrDefault(t => t.ID == selid); ScoreUser.IsDel = true; } db.SaveChanges(); new SysLogDAO().AddLog(LogType.操作日志_删除, "作废积分奖扣信息", UserID); ShowMessage("作废奖扣记录成功"); } } catch (Exception ex) { ShowMessage(ex.Message.ToString()); new SysLogDAO().AddLog(LogType.系统日志, ex.Message); } this.hf_CheckIDS.Value = ""; DataBindList(); }
protected void btn_Delete_Click(object sender, EventArgs e) { string ids = hf_CheckIDS.Value.ToString(); try { ids = ids.TrimEnd(',').TrimStart(','); foreach (string id in ids.Split(',')) { int iddata = Convert.ToInt32(id); ScoreUser model = db.ScoreUser.FirstOrDefault(t => t.ID == iddata); if (model != null) { model.IsDel = true; } else { ShowMessage("删除失败"); return; } } db.SaveChanges(); new SysLogDAO().AddLog(LogType.操作日志_删除, "删除积分奖扣信息"); ShowMessage("删除成功"); DataBindList(); this.hf_CheckIDS.Value = ""; } catch (Exception ex) { ShowMessage(ex.Message.ToString()); new SysLogDAO().AddLog(LogType.系统日志, ex.Message); } }
public void ToScore(int score, int userId) { if (score < 0 || score > 10) { throw new UserFriendlyException("无效的评分范围"); } string userIdStr = userId.ToString(); List <string> userIds = ScoreUser == null ? new List <string>() : ScoreUser.Split("|").ToList(); if (userIds.Any(e => e == userIdStr)) { throw new UserFriendlyException("已评分,无法再次评分"); } if (userIds.Count > 5000) { throw new UserFriendlyException("评分人数已达到上限"); } double sum = Score * ScoreNum; sum = sum + score; ScoreNum++; Score = sum / ScoreNum; userIds.Add(userIdStr); ScoreUser = userIds.JoinAsString("|"); }
public ActionResult ScoreSysUserListProvide(ScoreUser scoreUserDTO) { if (!base.HasPermission("guaguaka", PermissionOperate.view)) { if (base.LoginAdmin.KfNumbers.Count == 0) { return(null); } } PagedList <ScoreUser> list = _scoreUserService.GetPageList(PageIndex, PageSize, scoreUserDTO); var json = new { total = list.TotalItemCount, rows = (from r in list select new ScoreUser() { MpUserId = r.MpUserId, ClientName = r.ClientName, ClientPhone = r.ClientPhone, RecommendName = r.RecommendName, RecommendPhone = r.RecommendPhone, CurrentScore = r.CurrentScore, RecommendScore = r.RecommendScore, DealScore = r.DealScore, IsEmployee = r.IsEmployee, CreateDate = r.CreateDate }).ToArray() }; return(Json(json, JsonRequestBehavior.AllowGet)); //return SwitchJsonList<ScoreUser, ScoreUser>(list, list.TotalItemCount); }
public ActionResult Index() { try { //页面上的Plugins IList <Plugin> plugins = _pluginService.GetALL(); //用isopen 来区分 是传统的抽奖还是 积分系统 Plugin curPlugin = plugins.Where(p => p.IsOpen == 1).FirstOrDefault(); ViewBag.CurPlugin = curPlugin; if (curPlugin == null) { throw new OceanException("对不起,不存在该插件或未开通,请检查!"); } ViewBag.Title = curPlugin.RPluginBase.Name; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(curPlugin.Value); XmlNode pluginNode = xmlDoc.SelectSingleNode("plugin"); GetDataToViewData(pluginNode); ViewBag.MpUserArr = this.MpUserArr; ViewBag.MpUserID = this.MpUserID; ViewBag.CurrentScore = ViewBag.RecommendScore = ViewBag.DealScore = 0; if (MpUserID != Guid.Empty) { PagedList <ScoreConsumeInfo> scoreConsumeInfoList = _scoreConsumeInfoService.GetConsumeScoreList(MpUserID, 1, 30);//"from SceneResult where PluginId='" + Id.ToString() + "'"); ViewBag.ScoreConsumeInfoList = scoreConsumeInfoList; ScoreUser scoreUser = _scoreUserService.GetUnique("from ScoreUser where (MpUserId ='" + this.MpUserID + "')"); if (scoreUser != null) { ViewBag.CurrentScore = scoreUser.CurrentScore; ViewBag.RecommendScore = scoreUser.RecommendScore; ViewBag.DealScore = scoreUser.DealScore; } IList <ScorePluginResult> scorePluginResultList = _scorePluginResultService.GetList("from ScorePluginResult where MpUserId='" + MpUserID + "' order by createdate desc"); ViewBag.MyPlugin_SubmitList = scorePluginResultList; } bindScore = ViewData.GetInt("Score_Bind"); // ViewBag.Score_Bind; recommendScore = ViewData.GetInt("Score_Recommend"); // ViewBag.Score_Recommend; TempData["Id"] = curPlugin.Id; TempData["Score_Plugin_Title"] = ViewBag.Score_Plugin_Title; TempData["Score_Plugin_Summary"] = ViewBag.Score_Plugin_Summary; TempData["Score_Plugin_StartDate"] = ViewBag.Score_Plugin_StartDate; TempData["Score_Plugin_EndDate"] = ViewBag.Score_Plugin_EndDate; TempData["Score_Plugin_ZeroPrize"] = ViewBag.Score_Plugin_ZeroPrize; TempData["Score_Plugin_UsePoint"] = ViewData.GetInt("Score_Plugin_UsePoint"); TempData["Score_Plugin_FailsTimes"] = ViewBag.Score_Plugin_FailsTimes; TempData["Score_Plugin_FailsAddOdds"] = ViewBag.Score_Plugin_FailsAddOdds; return(View("Index")); } catch (Exception ex) { throw new OceanException(ex.Message, ex); } }
private bool Validate(ScoreUser user) { if (string.IsNullOrWhiteSpace(user.Name)) { Toast.MakeText(Context, Context.Resources.GetString(Resource.String.RequiredName), ToastLength.Short).Show(); return(false); } return(true); }
public void SaveUser(ScoreUser user) { if (!Exists(user.Name)) { DB.Insert(user); } else { DB.Update(user); } }
private void ContinueButtonOnClick(object sender, EventArgs eventArgs) { var user = new ScoreUser(_nameText.Text, _session.Scores); if (!Validate(user)) { return; } _scores.SaveUser(user); Dismiss(); }
public ActionResult StoreItem(Guid Id) { try { if (Id == Guid.Empty) { throw new OceanException("参数有误,请检查!"); } //if (MpUserID == Guid.Empty) //{ // string rawUrl = "http://wx.ssrcb.com/ScoreSys/StoreItem?Id=" + WebHelper.GetGuid("Id", Guid.Empty); // if (string.IsNullOrEmpty(RQuery["openid"])) // { // return Json(new { isOK = false, isLogin = true, error_code = "ERR_NotLogin", message = WebHelper.GetUrl() }); // //return Json(new { isOK = false, isLogin = true, error_code = "ERR_NotLogin", message = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri=http://wx.ssrcb.com/mpuser/autologin?refUrl={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", MpCenterCache.AppID, rawUrl) }); // } //} TempData["Id"] = Id; //ViewBag.Score_Plugin_Title = TempData["Score_Plugin_Title"].ToString(); //ViewBag.Score_Plugin_EndDate = TempData["Score_Plugin_EndDate"].ToString(); //ViewBag.Score_Plugin_EndDate = TempData["Score_Plugin_EndDate"].ToString(); //ViewBag.Score_Plugin_Summary = TempData["Score_Plugin_Summary"]; //ViewBag.Score_Plugin_ZeroPrize = TempData["Score_Plugin_ZeroPrize"]; //ViewBag.Score_Plugin_UsePoint = TempData["Score_Plugin_UsePoint"]; ScoreUser scoreUser = _scoreUserService.GetUnique("from ScoreUser where MpUserId = '" + MpUserID + "'"); ViewBag.CurrentScore = 0; if (scoreUser != null || scoreUser.ClientPhone != "") { ViewBag.CurrentScore = scoreUser.CurrentScore; ViewBag.RecvName = scoreUser.RecvName; ViewBag.RecvPhone = scoreUser.RecvPhone; ViewBag.RecvAddress = scoreUser.RecvAddress; } IList <ScoreStoreItem> scoreStoreItemList = _scoreStoreItemServiceService.GetList("from ScoreStoreItem where baseId='" + Id.ToString() + "' and VirtualGift = 0"); ViewBag.ScoreStoreItemList = scoreStoreItemList; IList <ScorePluginResult> scorePluginResultList = _scorePluginResultService.GetList("from ScorePluginResult where PluginId='" + Id.ToString() + "' and MpUserId = '" + MpUserID + "'and type = 2"); ViewBag.ScorePluginResultList = scorePluginResultList; } catch (System.Exception ex) { return(View("Index")); } return(View("StoreItem")); }
public void BindInfo() { using (IFMPDBContext db = new IFMPDBContext()) { //ScoreUser ScoreUser = db.ScoreUser.FirstOrDefault(t => t.ID == ScoreUserID && t.IsDel != true); ScoreUser ScoreUser = db.ScoreUser.FirstOrDefault(t => t.ID == ScoreUserID); if (ScoreUser != null) { Score Score = db.Score.FirstOrDefault(t => t.ID == ScoreUser.ScoreID); ScoreEvent ScoreEvent = db.ScoreEvent.FirstOrDefault(t => t.ID == Score.ScoreEventID); this.ltl_AduitState.Text = Enum.GetName(typeof(AuditState), Score.AuditState); this.ltl_BScore.Text = ScoreUser.BScore.ToString(); this.ltl_EventMark.Text = Score.Content; this.ltl_EventName.Text = ScoreEvent.Name; this.ltl_FirstAduitDate.Text = Score.FirstAuditDate == null ? "" : Score.FirstAuditDate.Value.ToString("yyyy-MM-dd"); this.ltl_FirstAduitMark.Text = Score.FirstAuditMark; this.ltl_FirstAduitUser.Text = Score.FirstAuditUserID == null ? "" : db.User.FirstOrDefault(t => t.ID == Score.FirstAuditUserID.Value).RealName; this.ltl_LastAduitDate.Text = Score.LastAuditDate == null ? "" : Score.LastAuditDate.Value.ToString("yyyy-MM-dd"); this.ltl_LastAduitMark.Text = Score.LastAuditMark; this.ltl_LastAduitUser.Text = Score.LastAuditUserID == null ? "" : db.User.FirstOrDefault(t => t.ID == Score.LastAuditUserID.Value).RealName; this.ltl_RewardUser.Text = db.User.FirstOrDefault(t => t.ID == ScoreUser.UserID).RealName; this.ltl_STitle.Text = Score.Title; this.ltl_SState.Text = (ScoreUser.IsDel == true ? "是" : "否"); this.ltl_VDate.Text = Score.CreateDate.Value.ToString("yyyy-MM-dd"); this.ltl_VUser.Text = db.User.FirstOrDefault(t => t.ID == Score.CreateUserID).RealName; if (string.IsNullOrEmpty(Score.Image)) { this.img.ImageUrl = ""; this.img.Visible = false; } else { this.img.ImageUrl = Score.Image.Length < 8 ? Score.Image : (Score.Image.ToString().Substring(0, 8) == "Templete" ? "../../jfz/" + Score.Image : Score.Image); } } } }
protected void btn_Sumbit_Click(object sender, EventArgs e) { try { if (this.hf_UID.Value == "" && SUserID == -1) { ShowMessage("请选择奖扣人员"); return; } int allscore = 0; string alluser = ""; Score model = db.Score.FirstOrDefault(t => t.ID == SUserID && t.IsDel != true); if (model == null) { model = new Score(); model.CreateUserID = UserID; model.AuditState = AuditState.待初审; model.Title = this.txt_STitle.Text.ToString().Trim(); model.ScoreEventID = Convert.ToInt32(this.ddl_EventName.SelectedValue.ToString()); model.Content = this.txt_EventMark.Text.ToString().Trim(); model.FirstAuditUserID = Convert.ToInt32(this.ddl_FirstAduitUser.SelectedValue.ToString()); model.LastAuditUserID = Convert.ToInt32(this.ddl_LastAduitUser.SelectedValue.ToString()); model.IsDel = false; int iisreward = Convert.ToInt32(this.rbl_IsReward.SelectedValue.ToString()); model.IsReward = Convert.ToBoolean(iisreward); model.CreateDate = this.txt_VDate.Text.Trim() == "" ? DateTime.Now : Convert.ToDateTime(this.txt_VDate.Text.Trim()); #region 图片 if (this.fl_UpFile.HasFile) { int upsize = 4000000; try { upsize = Convert.ToInt32(ConfigurationManager.AppSettings["upsize"].ToString()); } catch (Exception) { } string attaurl = ""; string pname = "/uploadfile/"; string path = System.Web.HttpContext.Current.Server.MapPath(pname); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string name = this.fl_UpFile.PostedFile.FileName.ToString(); string[] filename = name[name.Length - 1].ToString().Split('.'); string filepath = path + name; if (this.fl_UpFile.PostedFile.ContentLength < upsize) { this.fl_UpFile.SaveAs(filepath); int j = filepath.IndexOf("uploadfile"); attaurl = filepath.Substring(j - 1); } model.Image = attaurl; } else { model.Image = ""; } #endregion db.Score.Add(model); db.SaveChanges(); //如果当前记录人是初审人则改变信息 List <ScoreAuditUser> list = db.ScoreAuditUser.Where(t => t.ScoreAuditUserType == ScoreAuditUserType.初审人 && t.UserID == model.FirstAuditUserID && model.CreateUserID == model.FirstAuditUserID).ToList(); if (list.Count > 0) { Score score = db.Score.FirstOrDefault(t => t.ID == model.ID && t.IsDel != true); score.AuditState = AuditState.待终审; score.FirstAuditDate = DateTime.Now; db.SaveChanges(); } /*****************************************/ #region 添加奖扣人员 string[] uids = this.hf_UID.Value.Split(','); for (int i = 0; i < uids.Length; i++) { ScoreUser sumodel = new ScoreUser(); sumodel.UserID = Convert.ToInt32(uids[i].ToString()); sumodel.AScore = 0; string[] scores = this.hf_Score.Value.ToString().Split(','); for (int j = 0; j < scores.Length; j++) { if (j == i) { sumodel.BScore = Convert.ToInt32(scores[j].ToString()); if (sumodel.BScore < 0) { model.IsReward = false; } break; } } allscore += sumodel.BScore; alluser += db.User.FirstOrDefault(t => t.ID == sumodel.UserID).RealName + ","; sumodel.ScoreID = model.ID; sumodel.IsPrint = false; sumodel.IsDel = false; db.ScoreUser.Add(sumodel); db.SaveChanges(); } #endregion } else {//没有修改 //model.Title = this.txt_STitle.ToString().Trim(); //model.Content = this.txt_EventMark.ToString().Trim(); //model.ScoreEventID = Convert.ToInt32(this.ddl_EventName.SelectedValue.ToString()); //model.FirstAuditUserID = Convert.ToInt32(this.ddl_FirstAduitUser.SelectedValue.ToString()); //model.LastAuditUserID = Convert.ToInt32(this.ddl_LastAduitUser.SelectedValue.ToString()); //model.IsReward = Convert.ToBoolean(this.rbl_IsReward.SelectedValue); //model.CreateDate = Convert.ToDateTime(this.txt_VDate.Text); //db.SaveChanges(); } #region 添加通知消息 User createuser = db.User.FirstOrDefault(t => t.ID == model.CreateUserID); User firstuser = db.User.FirstOrDefault(t => t.ID == model.FirstAuditUserID); User lastuser = db.User.FirstOrDefault(t => t.ID == model.LastAuditUserID); Notice nmodel = new Notice(); nmodel.SendDate = DateTime.Now; nmodel.SendUserID = 1; nmodel.NoticeType = NoticeType.积分制消息; nmodel.SourceID = model.ID; nmodel.IsSend = false; nmodel.URL = ""; Score scoreaudit = db.Score.FirstOrDefault(t => t.ID == model.ID && t.AuditState == AuditState.待初审); if (scoreaudit != null) { nmodel.Contenet = "当前有一条奖扣记录需要审核|主题:" + this.txt_STitle.Text + "(" + allscore.ToString() + "分)|记录人:" + createuser.RealName + "|参与人:" + alluser + "|初审人:" + firstuser.RealName + "|终审人:" + lastuser.RealName + "|状态:待初审"; nmodel.ReciveUserID = model.FirstAuditUserID.Value; db.Notice.Add(nmodel); db.SaveChanges(); string[] uids = this.hf_UID.Value.Split(','); for (int i = 0; i < uids.Length; i++) { nmodel.Contenet = "当前有一条奖扣记录需要审核|主题:" + this.txt_STitle.Text + "(" + allscore.ToString() + "分)|记录人:" + createuser.RealName + "|参与人:" + alluser + "|初审人:" + firstuser.RealName + "|终审人:" + lastuser.RealName + "|状态:待初审"; nmodel.ReciveUserID = Convert.ToInt32(uids[i].ToString()); db.Notice.Add(nmodel); db.SaveChanges(); } } else { nmodel.Contenet = "当前有一条奖扣记录需要审核|主题:" + this.txt_STitle.Text + "(" + allscore.ToString() + "分)|记录人:" + createuser.RealName + "|参与人:" + alluser + "|初审人:" + firstuser.RealName + "|终审人:" + lastuser.RealName + "|状态:待终审"; nmodel.ReciveUserID = model.LastAuditUserID.Value; db.Notice.Add(nmodel); db.SaveChanges(); string[] uids = this.hf_UID.Value.Split(','); for (int i = 0; i < uids.Length; i++) { nmodel.Contenet = "当前有一条奖扣记录需要审核|主题:" + this.txt_STitle.Text + "(" + allscore.ToString() + "分)|记录人:" + createuser.RealName + "|参与人:" + alluser + "|初审人:" + firstuser.RealName + "|终审人:" + lastuser.RealName + "|状态:待终审"; nmodel.ReciveUserID = Convert.ToInt32(uids[i].ToString()); db.Notice.Add(nmodel); db.SaveChanges(); } } #endregion ShowMessage(); LogType log = (SUserID == 0 ? LogType.操作日志_添加 : LogType.操作日志_修改); new SysLogDAO().AddLog(log, (SUserID == 0 ? "增加" : "修改") + "主题为" + this.txt_STitle.Text + "的积分奖扣信息"); } catch (Exception ex) { new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID); ShowMessage(ex.Message); } }
public ActionResult StoreItemExchange(Guid baseId, Guid itemId, string t) { try { if (baseId == Guid.Empty) { return(Json(new { isOK = false, error_code = "ERR_ArgNotExist" })); } if (MpUserID == Guid.Empty) { string rawUrl = "http://wx.ssrcb.com/ScoreSys/StoreItem?id=" + WebHelper.GetGuid("baseId", Guid.Empty); if (string.IsNullOrEmpty(RQuery["openid"])) { return(Json(new { isOK = false, isLogin = true, error_code = "ERR_NotLogin", message = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri=http://wx.ssrcb.com/mpuser/autologin?refUrl={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", MpCenterCache.AppID, rawUrl) })); } } ScoreStoreItem scoreStoreItem = _scoreStoreItemServiceService.GetUnique("from ScoreStoreItem where Id='" + itemId.ToString() + "'"); if (scoreStoreItem == null) { return(Json(new { isOK = false, error_code = "ERR_StoreItemNotExist" })); } if (scoreStoreItem.LeftCount <= 0) { return(Json(new { isOK = false, error_code = "ERR_StoreItemScoreRunOut" })); } ScoreUser scoreUser = _scoreUserService.GetUnique("from ScoreUser where MpUserId = '" + MpUserID + "'"); if (scoreUser == null) { return(Json(new { isOK = false, error_code = "ERR_StoreItemUserNotExist" })); } if (scoreUser.CurrentScore < scoreStoreItem.NeedPoint) { return(Json(new { isOK = false, error_code = "ERR_StoreItemScoreNotEnough" })); } string Name = Request.Form["Name"]; string Phone = Request.Form["Phone"]; string Address = Request.Form["Address"]; string ResultID = Request.Form["resultId"]; string isDefaultAddr = Request.Form["DefaultAddr"]; if (isDefaultAddr == "true") { scoreUser.RecvName = Name; scoreUser.RecvPhone = Phone; scoreUser.RecvAddress = Address; _scoreUserService.Update(scoreUser); } ScorePluginResult scorePluginResult = null; if (ResultID == "0") { scorePluginResult = new ScorePluginResult(); scorePluginResult.MobilePhone = Phone; scorePluginResult.Address = Address; scorePluginResult.Name = Name; scorePluginResult.Type = 2; scorePluginResult.CreateDate = DateTime.Now; scorePluginResult.MpUserId = this.MpUserID; scorePluginResult.PluginId = baseId; scorePluginResult.Summary = "申请兑奖【" + scoreStoreItem.PluginName + "】" + scoreStoreItem.AliasName; scorePluginResult.Value = "" + scoreStoreItem.PluginName + "++" + scoreStoreItem.AliasName; _scorePluginResultService.Insert(scorePluginResult); ScoreConsumeInfo scoreConSumeInfo = new ScoreConsumeInfo(); scoreConSumeInfo.ConsumeDateTime = scoreConSumeInfo.CreateDate = DateTime.Now; scoreConSumeInfo.MpUserId = this.MpUserID; scoreConSumeInfo.ConsumeType = (int)(ScoreConsume.Exchange); scoreConSumeInfo.ConsumePoints = -Convert.ToInt32(scoreStoreItem.NeedPoint); scoreConSumeInfo.Summary = "兑换消耗了" + Convert.ToInt32(scoreStoreItem.NeedPoint) + "积分"; _scoreConsumeInfoService.Insert(scoreConSumeInfo); scoreUser.CurrentScore -= scoreStoreItem.NeedPoint; _scoreUserService.Update(scoreUser); return(Json(new { isOK = true, error_code = "ERR_RequireSuccess" })); } else { scorePluginResult = _scorePluginResultService.GetUnique("from ScorePluginResult where MpUserId='" + this.MpUserID.ToString() + "' and Id='" + ResultID.ToString() + "'"); if (scorePluginResult == null) { return(Json(new { isOK = false, error_code = "ERR_ScorePluginResultNotExist" })); } if (scorePluginResult.IsUse == 1) { return(Json(new { isOK = false, error_code = "ERR_AlreadySend" }));//对不起,您已经领取完奖! } scorePluginResult.MobilePhone = Phone; scorePluginResult.Address = Address; scorePluginResult.Name = Name; _scorePluginResultService.Update(scorePluginResult); return(Json(new { isOK = true, error_code = "ERR_ModifySuccess" })); } } catch (Exception ex) { throw new OceanException(ex.Message, ex); } }
public ActionResult PluginsLottery(Guid Id, string t) { try { if (Id == Guid.Empty) { Log4NetImpl.Write("ScoreSYS-PluginLottery:ID is NULL"); return(Json(new { isOK = false, error_code = "ERR_ArgNotExist" })); //message = "参数有误,请检查!" }); } if (MpUserID == Guid.Empty) { string rawUrl = "http://wx.ssrcb.com/ScoreSys/PluginLottery?id=" + WebHelper.GetGuid("Id", Guid.Empty); if (string.IsNullOrEmpty(RQuery["openid"])) { Log4NetImpl.Write("ScoreSYS-PluginLottery:Redirect"); return(Json(new { isOK = false, isLogin = true, error_code = "ERR_NotLogin", message = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri=http://wx.ssrcb.com/mpuser/autologin?refUrl={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", MpCenterCache.AppID, rawUrl) })); } } string Score_Plugin_Title = Request.Form["Score_Plugin_Title"]; string Score_Plugin_StartDate = Request.Form["Score_Plugin_StartDate"]; string Score_Plugin_EndDate = Request.Form["Score_Plugin_EndDate"]; string Score_Plugin_UsePoint = Request.Form["Score_Plugin_UsePoint"]; string Score_Plugin_FailsTimes = Request.Form["Score_Plugin_FailsTimes"]; string Score_Plugin_FailsAddOdds = Request.Form["Score_Plugin_FailsAddOdds"]; if (Score_Plugin_Title == "") { return(Json(new { isOK = false, error_code = "ERR_PluginNotExits" })); } if (!string.IsNullOrEmpty(Score_Plugin_StartDate)) { DateTime startDate = TypeConverter.StrToDateTime(Score_Plugin_StartDate); if (startDate > DateTime.Now) { return(Json(new { isOK = false, error_code = "ERR_PluginNotStart" })); } else { if (!string.IsNullOrEmpty(Score_Plugin_EndDate)) { DateTime endDate = TypeConverter.StrToDateTime(Score_Plugin_EndDate); if (endDate < DateTime.Now) { return(Json(new { isOK = false, error_code = "ERR_PluginIsEnd" }));// message = "对不起,抽奖已经结束!" }); } } } } IList <ScoreStoreItem> scoreStoreItems = _scoreStoreItemServiceService.GetList("from ScoreStoreItem where BaseId = '" + Id.ToString() + "'"); scoreStoreItems.OrderBy(storeItems => storeItems.PluginName); ScoreUser scoreUser = _scoreUserService.GetUnique("from ScoreUser where (MpUserId ='" + this.MpUserID.ToString() + "')"); if (scoreUser == null) { return(Json(new { isOK = false, isVertfy = true, error_code = "ERR_UserNotVerify" })); } if (scoreUser.CurrentScore < ViewData.GetInt("Score_Plugin_UsePoint")) { return(Json(new { isOK = false, error_code = "ERR_UserUseOutChance" })); } int prizeItemCount = scoreStoreItems.Count;// TypeConverter.StrToInt(ViewBag.Cst_Plugin_PrizeCount, 12); IList <PrizeGift> prizeGift = new List <PrizeGift>(prizeItemCount); IList <Double> prizeItems = new List <Double>(prizeItemCount); IList <string> prizeItemsName = new List <string>(prizeItemCount); IList <int> prizeAngle = new List <int>(prizeItemCount); prizeItemsName.Add("一"); prizeItemsName.Add("二"); prizeItemsName.Add("三"); prizeItemsName.Add("四"); prizeItemsName.Add("五"); prizeItemsName.Add("六"); prizeItemsName.Add("七"); prizeItemsName.Add("八"); prizeItemsName.Add("九"); prizeItemsName.Add("十"); prizeItemsName.Add("十一"); prizeItemsName.Add("十二"); for (int i = 0; i < prizeItemCount; i++) { ScoreStoreItem storeItem = scoreStoreItems[i]; PrizeGift gift = new PrizeGift(); gift.ID = i; gift.Name = storeItem.PluginName; gift.Alias_Name = storeItem.AliasName; gift.Odds = Convert.ToDouble(storeItem.PrizePercent) / 100; gift.Pic = storeItem.ItemPic; gift.Quantity = storeItem.TotalCount; gift.Leavings_Quantity = storeItem.LeftCount; gift.Angle = Convert.ToInt32(storeItem.PrizeAngle); prizeAngle.Add(gift.Angle); gift.Prize_Name = prizeItemsName[i] + "等奖"; if (!string.IsNullOrEmpty(gift.Alias_Name)) { gift.Prize_Name = gift.Alias_Name; } gift.Has_Gift = 1;// ViewData.GetInt("Cst_Plugin_Items_Has_Gift" + i.ToString()); //gift.Users = ViewData.GetString("Cst_Plugin_Items_SiteUsers" + i.ToString()); //gift.UsersName = ViewData.GetString("Cst_Plugin_Items_SiteUsersName" + i.ToString()); prizeItems.Add(gift.Odds); prizeGift.Add(gift); } prizeItems.OrderBy(d => d); //verifyCodeDetail.LeaveCount = verifyCodeDetail.LeaveCount - 1; //verifyCodeDetail.UseDate = DateTime.Now; //_pluginSceneVerifyCodeDetailService.Update(verifyCodeDetail); int count = _scorePluginResultService.GetCount("from ScorePluginResult where pluginId='" + Id.ToString() + "' and MpUserId='" + this.MpUserID.ToString() + "'"); int tryCount = _scoreConsumeInfoService.GetCount(" from ScoreConsumeInfo where ConsumeType = " + (int)ScoreConsume.Plugins + ""); if (count == 0 && tryCount > Convert.ToInt32(Score_Plugin_FailsTimes)) { PrizeGift _lastGift = prizeGift.Last(); double finalOdds = _lastGift.Odds * (1 + Convert.ToInt32(Score_Plugin_FailsAddOdds)); _lastGift.Odds = finalOdds; prizeItems.RemoveAt(prizeItems.Count - 1); prizeItems.Add(finalOdds); } int result = -1; scoreUser.CurrentScore = scoreUser.CurrentScore - Convert.ToInt32(Score_Plugin_UsePoint);// ViewData.GetInt("Score_Plugin_UsePoint"); scoreUser.LastUpdateDateTime = DateTime.Now; _scoreUserService.Update(scoreUser); #region 更新积分消耗纪录 ScoreConsumeInfo scoreConSumeInfo = new ScoreConsumeInfo(); scoreConSumeInfo.ConsumeDateTime = scoreConSumeInfo.CreateDate = DateTime.Now; scoreConSumeInfo.MpUserId = this.MpUserID; scoreConSumeInfo.ConsumeType = (int)(ScoreConsume.Plugins); scoreConSumeInfo.ConsumePoints = -Convert.ToInt32(Score_Plugin_UsePoint); scoreConSumeInfo.Summary = "抽奖消耗了" + Convert.ToInt32(Score_Plugin_UsePoint) + "积分"; _scoreConsumeInfoService.Insert(scoreConSumeInfo); #endregion result = LotteryUtils.Lottery(prizeItems, prizeGift, prizeItemCount, this.MpUserID, Id); if (result == -1) { return(Json(new { isOK = true, error_code = "ERR_RunOutOfGift" }));//Json(new PrizeGift() { ID = -1, Name = "未中奖", Odds = 0.00d, Pic = "", Quantity = 100000, Angle = 240, Prize_Name = "继续加油" }); } else if (result == -2) { return(Json(new { isOK = true, error_code = "ERR_RunOutOfGift" }));// Json(new PrizeGift() { ID = -2, Name = "未中奖", Odds = 0.00d, Pic = "", Quantity = 100000, Angle = 180, Prize_Name = "继续加油" }); } else if (result == -3) { return(Json(new { isOK = true, error_code = "ERR_RunOutOfGift" }));// Json(new PrizeGift() { ID = -2, Name = "未中奖", Odds = 0.00d, Pic = "", Quantity = 100000, Angle = 180, Prize_Name = "继续加油" }); } else { PrizeGift hasPrizeGift = prizeGift[result]; ScoreStoreItem scoreStoreItem = scoreStoreItems[result]; //ScoreStoreItem scoreStoreItem = _scoreStoreItemServiceService.GetUnique("from ScoreStoreItem where (Id ='" + this.MpUserID.ToString() + "')"); //score hasPrizeGift.Alias_Name = hasPrizeGift.Alias_Name ?? ""; if (scoreStoreItem.LeftCount > 0) { //中奖业务处理 ScorePluginResult pluginSceneResult = new ScorePluginResult(); pluginSceneResult.Address = ""; pluginSceneResult.CreateDate = DateTime.Now; pluginSceneResult.Type = 1; pluginSceneResult.IsUse = 0; pluginSceneResult.MobilePhone = ""; pluginSceneResult.Name = ""; pluginSceneResult.Phone = ""; pluginSceneResult.PluginId = Id; pluginSceneResult.MpUserId = this.MpUserID; pluginSceneResult.SN = ""; pluginSceneResult.UserName = (string.IsNullOrEmpty(this.Name) ? this.NickName : this.Name); if (this.MpUserArr != null) { pluginSceneResult.Summary = "恭喜用户[" + (string.IsNullOrEmpty(this.Name) ? this.NickName : this.Name) + "]获得" + hasPrizeGift.Prize_Name + "[" + hasPrizeGift.Name + "]"; } else { pluginSceneResult.Summary = "恭喜匿名用户获得" + hasPrizeGift.Prize_Name + "[" + hasPrizeGift.Name + "]"; } //pluginSceneResult.Value = "<?xml version=\"1.0\" encoding=\"utf-8\"?><PluginSubmit><Cst_Plugin_ItemIndex>" + result.ToString() + "</Cst_Plugin_ItemIndex><Cst_Plugin_PrizeLevel>" + hasPrizeGift.Prize_Name + "</Cst_Plugin_PrizeLevel><Cst_Plugin_PrizeName>" + hasPrizeGift.Name + "</Cst_Plugin_PrizeName></PluginSubmit>"; pluginSceneResult.Value = hasPrizeGift.Prize_Name + "++" + hasPrizeGift.Name; #region 更新商城数量 scoreStoreItem.LeftCount -= 1; _scoreStoreItemServiceService.Update(scoreStoreItem); #endregion #region 更新中奖纪录 _scorePluginResultService.Insert(pluginSceneResult); #endregion #region 更新虚拟积分纪录 if (scoreStoreItem.VirtualGift > 0) { scoreUser.CurrentScore += scoreStoreItem.VirtualGift; _scoreUserService.Update(scoreUser); ScoreConsumeInfo scoreConSumeInfo2 = new ScoreConsumeInfo(); scoreConSumeInfo2.ConsumeDateTime = scoreConSumeInfo.CreateDate = DateTime.Now; scoreConSumeInfo2.MpUserId = this.MpUserID; scoreConSumeInfo2.ConsumeType = (int)(ScoreConsume.Plugins); scoreConSumeInfo2.ConsumePoints = scoreStoreItem.VirtualGift; scoreConSumeInfo2.Summary = "抽奖中了" + scoreStoreItem.VirtualGift + "积分"; _scoreConsumeInfoService.Insert(scoreConSumeInfo2); } #endregion hasPrizeGift.ResultID = pluginSceneResult.Id; } return(Content(JsonConvert.SerializeObject(hasPrizeGift), "text/javascript")); } } catch (Exception ex) { throw new OceanException(ex.Message, ex); } }
public ActionResult Trans(Guid id, string TransName, string TransPhone, int TransScore) { try { if (MpUserID == Guid.Empty) { string rawUrl = "http://wx.ssrcb.com/ScoreSys/Index"; if (string.IsNullOrEmpty(RQuery["openid"])) { return(Json(new { isOK = false, isLogin = true, error_code = "ERR_NotLogin", message = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri=http://wx.ssrcb.com/mpuser/autologin?refUrl={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", MpCenterCache.AppID, rawUrl) })); } } ScoreUser scoreUser = _scoreUserService.GetUnique("from ScoreUser where (MpUserId ='" + this.MpUserID.ToString() + "')"); if (scoreUser == null) { return(Json(new { isOK = false, error_code = "ERR_UserHadBind" })); } ScoreUser scoreTransUser = _scoreUserService.GetUnique("from ScoreUser where (ClientPhone='" + TransPhone.Trim() + "' and ClientName = '" + TransName + "')"); if (scoreTransUser == null) { return(Json(new { isOK = false, error_code = "ERR_UserNotExist" })); } if (scoreUser.ClientPhone == scoreTransUser.ClientPhone) { return(Json(new { isOK = false, error_code = "ERR_TransSamePerson" })); } if (scoreUser.CurrentScore < TransScore) { return(Json(new { isOK = false, error_code = "ERR_ScoreNotEnough" })); } scoreUser.CurrentScore -= TransScore; _scoreUserService.Update(scoreUser); //转出积分记录 ScoreConsumeInfo scoreConsumeDetail = new ScoreConsumeInfo(); scoreConsumeDetail.MpUserId = this.MpUserID; scoreConsumeDetail.ConsumeType = (int)ScoreConsume.Trans; scoreConsumeDetail.ConsumePoints = -TransScore; scoreConsumeDetail.CreateDate = DateTime.Now; scoreConsumeDetail.ConsumeDateTime = DateTime.Now; scoreConsumeDetail.Summary = "转给[" + TransName + TransPhone + "]" + TransScore + "积分"; _scoreConsumeInfoService.Insert(scoreConsumeDetail); scoreTransUser.CurrentScore += TransScore; _scoreUserService.Update(scoreTransUser); //转入积分记录 ScoreConsumeInfo transScoreConsumeDetail = new ScoreConsumeInfo(); transScoreConsumeDetail.MpUserId = scoreTransUser.MpUserId; transScoreConsumeDetail.ConsumeType = (int)ScoreConsume.Trans; transScoreConsumeDetail.ConsumePoints = TransScore; transScoreConsumeDetail.CreateDate = DateTime.Now; transScoreConsumeDetail.ConsumeDateTime = DateTime.Now; transScoreConsumeDetail.Summary = "从[" + scoreUser.ClientName + scoreUser.ClientPhone + "]获得转入" + TransScore + "积分"; _scoreConsumeInfoService.Insert(transScoreConsumeDetail); return(Json(new { isOK = true, error_code = "ERR_OK", currentScore = scoreUser.CurrentScore, scoreDetail = scoreConsumeDetail.ConsumeDateTime + scoreConsumeDetail.Summary })); } catch (System.Exception ex) { Log4NetImpl.Write("ScoreSys_Trans:" + ex.Message); } return(View()); }
public ActionResult Bind(Guid id, string Name, string Phone, string RecomendName, string RecomendPhone) { try { if (MpUserID == Guid.Empty) { string rawUrl = "http://wx.ssrcb.com/ScoreSys/Index"; if (string.IsNullOrEmpty(RQuery["openid"])) { return(Json(new { isOK = false, isLogin = true, error_code = "ERR_NotLogin", message = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri=http://wx.ssrcb.com/mpuser/autologin?refUrl={1}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect", MpCenterCache.AppID, rawUrl) })); } } ScoreUser scoreUser = _scoreUserService.GetUnique("from ScoreUser where (ClientPhone='" + Phone.Trim() + "' and ClientName = '" + Name + "') or (MpUserId ='" + this.MpUserID.ToString() + "')"); if (scoreUser != null) { return(Json(new { isOK = false, isVertfy = true, error_code = "ERR_UserHadBind" })); } scoreUser = new ScoreUser(); scoreUser.ClientName = Name.Trim(); scoreUser.ClientPhone = Phone.Trim(); scoreUser.RecommendName = RecomendName.Trim(); scoreUser.RecommendPhone = RecomendPhone.Trim(); scoreUser.MpUserId = MpUserID; scoreUser.RecommendScore = 0; scoreUser.CurrentScore = bindScore; scoreUser.DealScore = 0; _scoreUserService.Insert(scoreUser); //首次绑定获得积分 ScoreConsumeInfo scoreConsumeDetail = new ScoreConsumeInfo(); scoreConsumeDetail.MpUserId = this.MpUserID; scoreConsumeDetail.ConsumeType = (int)ScoreConsume.Bind; scoreConsumeDetail.ConsumePoints = bindScore; scoreConsumeDetail.CreateDate = DateTime.Now; scoreConsumeDetail.ConsumeDateTime = DateTime.Now; scoreConsumeDetail.Summary = "首次绑定获得" + bindScore + "积分"; _scoreConsumeInfoService.Insert(scoreConsumeDetail); ScoreUser recommendScoreUser = _scoreUserService.GetUnique("from ScoreUser where ClientPhone='" + RecomendPhone.Trim() + "'"); if (recommendScoreUser != null) { ScoreConsumeInfo recommendScoreConsumeDetail = new ScoreConsumeInfo(); recommendScoreConsumeDetail.MpUserId = recommendScoreUser.MpUserId; recommendScoreConsumeDetail.ConsumeType = (int)ScoreConsume.Recommend; recommendScoreConsumeDetail.ConsumePoints = recommendScore; recommendScoreConsumeDetail.CreateDate = DateTime.Now; recommendScoreConsumeDetail.ConsumeDateTime = DateTime.Now; recommendScoreConsumeDetail.Summary = "推荐用户[" + Phone + "]获得" + recommendScore + "积分"; _scoreConsumeInfoService.Insert(recommendScoreConsumeDetail); recommendScoreUser.RecommendScore += recommendScore; recommendScoreUser.CurrentScore += recommendScore; _scoreUserService.Update(recommendScoreUser); } return(Json(new { isOK = true, error_code = "ERR_OK", currentScore = scoreUser.CurrentScore, scoreDetail = scoreConsumeDetail.ConsumeDateTime + scoreConsumeDetail.Summary })); } catch (System.Exception ex) { Log4NetImpl.Write("ScoreSys_Bind:" + ex.Message); } return(View()); }