/// <summary> /// 增加第三方抽奖所得20积分 /// </summary> /// <param name="memberid">会员id</param> /// <returns></returns> public string AddJifenFromActivity(int memberId, string adddDate) { string sql = string.Format("update RegistMember Set LeaveIntegral = LeaveIntegral + {0}, TotalIntegral = TotalIntegral + {0} where MemberId = {1}", 20, memberId); int effect = SqlHelper.ExecuteNonQuery(CommandType.Text, sql); if (effect == 1) { MemberIntegralDetail model = new MemberIntegralDetail(); model.CreatDate = Convert.ToDateTime(adddDate); model.InvalidDate = Convert.ToDateTime(adddDate); model.IntegralNum = 20; model.IntegralSource = "世界厨师日"; model.IntegralType = 1; model.Remark = "世界厨师日"; model.MemberId = memberId; model.ScanHotelName = ""; model.ScanMemberCode = ""; db.MemberIntegralDetail.Add(model); db.SaveChanges(); return("succ"); } else { return("fail"); } }
/// <summary> /// 扫码增加积分 /// </summary> /// <param name="memberId">会员ID</param> /// <param name="integral">增加积分</param> /// <param name="opation">操作项</param> /// <param name="remark">增加积分备注</param> /// <param name="memberCode">会员编码</param> /// <param name="hotelName">酒店名称</param> /// <returns></returns> public bool IntegralPlus(int memberId, int integral, string opation, string remark = "", string memberCode = "", string hotelName = "") { var sql = string.Format("update RegistMember Set LeaveIntegral = LeaveIntegral + {0}, TotalIntegral = TotalIntegral + {0} where MemberId = {1}", integral, memberId); var count = dataContext.ExecuteNonQuery(CommandType.Text, sql); MemberIntegralDetail model = new MemberIntegralDetail(); model.CreatDate = DateTime.Now; model.InvalidDate = DateTime.Now; model.IntegralNum = integral; model.IntegralSource = opation; model.IntegralType = 1; model.Remark = remark; model.MemberId = memberId; model.ScanMemberCode = memberCode; model.ScanHotelName = hotelName; db.MemberIntegralDetail.Add(model); db.SaveChanges(); if ((int)count > 0) { return(true); } return(false); }
/// <summary> /// 操作会员积分 /// </summary> /// <param name="requestData"></param> /// <returns></returns> public string UpdateMemberIntegral(dynamic requestData) { string operation = requestData.Operation; int integral = requestData.Integral; int memberId = requestData.MemberId; string integralSource = requestData.IntegralSource; string remark = requestData.Remark; try { string sql = string.Empty; int count = 0; if (operation == "plus") { sql = string.Format("update RegistMember Set LeaveIntegral = LeaveIntegral + {0}, TotalIntegral = TotalIntegral + {0} where MemberId = {1}", integral, memberId); count = dataContext.ExecuteNonQuery(CommandType.Text, sql); MemberIntegralDetail model = new MemberIntegralDetail(); model.CreatDate = DateTime.Now; model.InvalidDate = DateTime.Now; model.IntegralNum = integral; model.IntegralSource = integralSource; model.IntegralType = 1; model.Remark = remark; model.MemberId = memberId; model.ScanHotelName = ""; model.ScanMemberCode = ""; db.MemberIntegralDetail.Add(model); db.SaveChangesAsync(); } else if (operation == "minus") { sql = string.Format("update RegistMember Set LeaveIntegral = LeaveIntegral - {0} where MemberId = {1}", integral, memberId); count = dataContext.ExecuteNonQuery(CommandType.Text, sql); MemberIntegralDetail model = new MemberIntegralDetail(); model.CreatDate = DateTime.Now; model.InvalidDate = DateTime.Now; model.IntegralNum = integral; model.IntegralSource = integralSource; model.IntegralType = 2; model.Remark = remark; model.MemberId = memberId; model.ScanHotelName = ""; model.ScanMemberCode = ""; db.MemberIntegralDetail.Add(model); db.SaveChangesAsync(); } return("Excute Success"); } catch (Exception ex) { return(ex.Message); } }
public string AddJifenTemp() { //从数据库表查询要创建的用户 string sql = string.Format(@"SELECT a.Id,a.OpenId,c.MemberId FROM TempAddJiFen a JOIN dbo.OpenIdAssociated b ON b.OpenId = a.OpenId AND b.UserType=2 JOIN dbo.RegistMember c ON c.MemberId=b.UserId WHERE (a.Status IS NULL or LEN(a.Status) =0) AND b.UserType=2 order by Id"); DataTable dt = SqlHelper.ExecuteDataTable(sql); foreach (DataRow dr in dt.Rows) { try { sql = string.Format("update RegistMember Set LeaveIntegral = LeaveIntegral + {0}, TotalIntegral = TotalIntegral + {0} where MemberId = {1}", 20, Convert.ToInt32(dr["MemberId"])); int a = SqlHelper.ExecuteNonQuery(CommandType.Text, sql); if (a == 1) { MemberIntegralDetail model = new MemberIntegralDetail(); model.CreatDate = DateTime.Now; model.InvalidDate = DateTime.Now; model.IntegralNum = 20; model.IntegralSource = "匠心寻百味抽奖"; model.IntegralType = 1; model.Remark = "匠心寻百味抽奖"; model.MemberId = Convert.ToInt32(dr["MemberId"]); model.ScanHotelName = ""; model.ScanMemberCode = ""; db.MemberIntegralDetail.Add(model); db.SaveChanges(); sql = string.Format(@"UPDATE dbo.TempAddJiFen SET Status = 'succ',Remark='{0}' WHERE Id = {1}", "succ", dr["Id"].ToString()); SqlHelper.ExecuteNonQuery(CommandType.Text, sql); Common.LogHelper.WriteLog(dr["OpenId"].ToString() + "RegistMember增加20积分SUCC"); } else { sql = string.Format(@"UPDATE dbo.TempAddJiFen SET Status = 'fail',Remark='{0}' WHERE Id = {1}", "RegistMember增加20积分失败", dr["Id"].ToString()); SqlHelper.ExecuteNonQuery(CommandType.Text, sql); Common.LogHelper.WriteLog(dr["OpenId"].ToString() + "RegistMember增加20积分失败"); } } catch (Exception ex) { sql = string.Format(@"UPDATE dbo.TempAddJiFen SET Status = 'fail',Remark='{0}' WHERE Id = {1}", ex.ToString(), dr["Id"].ToString()); SqlHelper.ExecuteNonQuery(CommandType.Text, sql); Common.LogHelper.WriteLog(dr["OpenId"].ToString() + ex.ToString()); } } return("执行完成"); }