public int InsertOrUpdate(B2bcrm_dengjifenlog djflog) { using (var helper = new SqlHelper()) { int m = new InternalB2bcrm_dengjifenlog(helper).InsertOrderUpdate(djflog); return(m); } }
/// <summary> /// 调整用户等积分;记录等积分调整日志;同时根据等积分变动调整会员级别(会员级别只增不降) /// </summary> /// <param name="id"></param> /// <param name="dengjifen"></param> /// <returns></returns> public int Adjust_dengjifen(B2bcrm_dengjifenlog djflog, int id, int comid, decimal dengjifen) { using (var helper = new SqlHelper()) { int r = new InternalB2bCrm(helper).Adjust_dengjifen(djflog, id, comid, dengjifen); return(r); } }
internal int InsertOrderUpdate(B2bcrm_dengjifenlog m) { if (m.id == 0) { string sql = @"INSERT INTO [EtownDB].[dbo].[b2bcrm_dengjifenlog] ([crmid] ,[dengjifen] ,[ptype] ,[opertor] ,[opertime] ,[orderid] ,[ordername] ,[remark]) VALUES (@crmid ,@dengjifen ,@ptype ,@opertor ,@opertime ,@orderid ,@ordername ,@remark);select @@identity;"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@crmid", m.crmid); cmd.AddParam("@dengjifen", m.dengjifen); cmd.AddParam("@ptype", m.ptype); cmd.AddParam("@opertor", m.opertor); cmd.AddParam("@opertime", m.opertime); cmd.AddParam("@orderid", m.orderid); cmd.AddParam("@ordername", m.ordername); cmd.AddParam("@remark", m.remark); object o = cmd.ExecuteScalar(); int id = o == null ? 0 : int.Parse(o.ToString()); return(id); } else { string sql = @"UPDATE [EtownDB].[dbo].[b2bcrm_dengjifenlog] SET [crmid] = @crmid ,[dengjifen] = @dengjifen ,[ptype] =@ptype ,[opertor] = @opertor ,[opertime] = @opertime ,[orderid] = @orderid ,[ordername] = @ordername ,[remark] = @remark WHERE id=@id"; var cmd = sqlHelper.PrepareTextSqlCommand(sql); cmd.AddParam("@id", m.id); cmd.AddParam("@crmid", m.crmid); cmd.AddParam("@dengjifen", m.dengjifen); cmd.AddParam("@ptype", m.ptype); cmd.AddParam("@opertor", m.opertor); cmd.AddParam("@opertime", m.opertime); cmd.AddParam("@orderid", m.orderid); cmd.AddParam("@ordername", m.ordername); cmd.AddParam("@remark", m.remark); cmd.ExecuteNonQuery(); return(m.id); } }
public static string ERNIEZhongjiang(ERNIE_Record Recordinfo) { MemberERNIEData ernieddate = new MemberERNIEData(); string rtstr = "";//返回文字 try { var pror = ernieddate.ERNIERecordInfo(Recordinfo.Id);//查询中奖纪录 if (pror != null) { if (pror.Process_state == 0) { var pro = MemberERNIEData.ERNIEZhongjiang(Recordinfo);//中奖提交 if (pro > 0) { var proernie = MemberERNIEData.ERNIEGetActById(Recordinfo.ERNIE_id);//查询活动 if (proernie != null) { var prow = MemberERNIEData.ERNIEGetAwardById(pror.Awardid);//查询奖品纪录,成功状态修改为中奖奖品级别 if (prow != null) { if (prow.Award_type == 2)//必须是赠送积分的才会自动赠送 { //中奖状态修改,为已处理 var prochuli = MemberERNIEData.ERNIEZhongjiangChuli(Recordinfo.Id); if (prochuli > 0) { //插入积分 MemberIntegralData intdate = new MemberIntegralData(); Member_Integral Intinfo = new Member_Integral() { Id = pror.ERNIE_uid, Comid = proernie.Com_id, Acttype = "add_integral", //操作类型 Money = prow.Award_Get_Num, //交易金额 Admin = proernie.Title, Ip = CommonFunc.GetRealIP(), Ptype = 1, Oid = 0, Remark = "", OrderId = 0, OrderName = "" }; pro = intdate.InsertOrUpdate(Intinfo); //抽奖赠送等积分 B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog { id = 0, crmid = pror.ERNIE_uid, dengjifen = prow.Award_Get_Num, ptype = 1, opertor = "抽奖赠送等积分", opertime = DateTime.Now, orderid = 0, ordername = "抽奖赠送等积分", remark = "抽奖赠送等积分" }; new B2bCrmData().Adjust_dengjifen(djflog, pror.ERNIE_uid, proernie.Com_id, prow.Award_Get_Num); if (pro > 0) { rtstr = "您中奖的" + prow.Award_Get_Num + "元,已经打入您的积分中,请查收!"; } else { rtstr = "中奖信息已经提交成功!"; } } else { rtstr = "中奖信息已经提交成功!"; } } else { rtstr = "中奖信息已经提交成功!"; } } } } } else { return(JsonConvert.SerializeObject(new { rt = -1, msg = "中奖信息提交失败" })); } return(JsonConvert.SerializeObject(new { rt = 1, msg = rtstr })); } else { return(JsonConvert.SerializeObject(new { rt = -1, msg = "中奖信息提交失败!" })); } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { rt = -1, msg = ex.Message })); throw; } }
public static string WriteMoney(int id, int comid, string acttype, string money, decimal orderid, string ordername, string remark = "") { try { //获得操作用户 B2b_company_manageuser user = UserHelper.CurrentUser(); B2b_company company = UserHelper.CurrentCompany; string username = user.Accounts; //获得IP string addressIP = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()).GetValue(0).ToString(); int pro = 0; //判断金额有效性 bool isNum = Domain_def.RegexValidate("^[0-9]*$", money); if (!isNum) { return(JsonConvert.SerializeObject(new { type = 1, msg = "操作错误,金额只能包含数字" })); } //充等积分 if (acttype == "add_dengjifen") { B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog { id = 0, crmid = id, dengjifen = decimal.Parse(money), ptype = 1, opertor = user.Id.ToString(), opertime = DateTime.Now, orderid = int.Parse(orderid.ToString()), ordername = ordername, remark = remark }; pro = new B2bCrmData().Adjust_dengjifen(djflog, id, comid, decimal.Parse(money)); if (pro == 0) { return(JsonConvert.SerializeObject(new { type = 1, msg = "调整用户等积分失败" })); } } //减等积分 else if (acttype == "reduce_dengjifen") { B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog { id = 0, crmid = id, dengjifen = 0 - decimal.Parse(money), ptype = 2, opertor = user.Id.ToString(), opertime = DateTime.Now, orderid = int.Parse(orderid.ToString()), ordername = ordername, remark = remark }; pro = new B2bCrmData().Adjust_dengjifen(djflog, id, comid, 0 - decimal.Parse(money)); if (pro == 0) { return(JsonConvert.SerializeObject(new { type = 1, msg = "调整用户等积分失败" })); } } //充积分 else if (acttype == "add_integral") { MemberIntegralData intdate = new MemberIntegralData(); Member_Integral Intinfo = new Member_Integral() { Id = id, Comid = comid, Acttype = acttype, //操作类型 Money = decimal.Parse(money), //交易金额 Admin = username, Ip = addressIP, Ptype = 1, Oid = 0, Remark = "", OrderId = orderid, OrderName = ordername }; pro = intdate.InsertOrUpdate(Intinfo); if (pro != 0) { //积分变动 触发等积分变动 B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog { id = 0, crmid = id, dengjifen = decimal.Parse(money), ptype = 1, opertor = user.Id.ToString(), opertime = DateTime.Now, orderid = int.Parse(orderid.ToString()), ordername = ordername, remark = "后台调整积分引起等积分变动:" + remark }; new B2bCrmData().Adjust_dengjifen(djflog, id, comid, decimal.Parse(money)); B2bCrmData prodata = new B2bCrmData(); var list = prodata.Readuser(Intinfo.Id, Intinfo.Comid); //微信消息模板 if (list.Weixin != "") { new Weixin_tmplmsgManage().WxTmplMsg_CrmIntegralReward(list.Com_id, list.Weixin, "您好,积分已经打入您的账户", list.Idcard.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "活动赠送", Intinfo.Money.ToString(), list.Integral.ToString(), "如有疑问,请致电客服。"); } SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Intinfo.Money, "充积分", comid);//发送短信 } }//减积分 else if (acttype == "reduce_integral") { MemberIntegralData intdate = new MemberIntegralData(); Member_Integral Intinfo = new Member_Integral() { Id = id, Comid = comid, Acttype = acttype, //操作类型 Money = 0 - decimal.Parse(money), //交易金额 Admin = username, Ip = addressIP, Ptype = 2, Oid = 0, Remark = "", OrderId = orderid, OrderName = ordername }; pro = intdate.InsertOrUpdate(Intinfo); if (pro != 0) { ////积分变动 触发等积分变动 //B2bcrm_dengjifenlog djflog = new B2bcrm_dengjifenlog //{ // id = 0, // crmid = id, // dengjifen = 0-decimal.Parse(money), // ptype = 2, // opertor = user.Id.ToString(), // opertime = DateTime.Now, // orderid = int.Parse(orderid.ToString()), // ordername = ordername, // remark = "后台调整积分引起等积分变动:" + remark //}; //new B2bCrmData().Adjust_dengjifen(djflog, id, comid, 0-decimal.Parse(money)); B2bCrmData prodata = new B2bCrmData(); var list = prodata.Readuser(Intinfo.Id, Intinfo.Comid); //SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Intinfo.Money, "减积分", comid);//发送短信 if (list.Weixin != "") { new Weixin_tmplmsgManage().WxTmplMsg_CrmConsume(list.Com_id, list.Weixin, "名称", "使用积分", "会员卡号", list.Idcard.ToString(), DateTime.Now.ToString(), " 使用" + Intinfo.Money + " 积分,如有疑问,请致电客服。"); } } }//充预付款 else if (acttype == "add_imprest") { MemberImprestData impdate = new MemberImprestData(); Member_Imprest Impinfo = new Member_Imprest() { Id = id, Comid = comid, Acttype = acttype, //操作类型 Money = decimal.Parse(money), //交易金额 Admin = username, Ip = addressIP, Ptype = 1, Oid = 0, Remark = "", OrderId = orderid, OrderName = ordername }; pro = impdate.InsertOrUpdate(Impinfo); if (pro != 0) { B2bCrmData prodata = new B2bCrmData(); var list = prodata.Readuser(Impinfo.Id, Impinfo.Comid); //微信消息模板 if (list.Weixin != "") { new Weixin_tmplmsgManage().WxTmplMsg_CrmRecharge(list.Com_id, list.Weixin, "您好,已成功进行会员卡充值", "会员卡号", list.Idcard.ToString(), Impinfo.Money.ToString() + "元", "充值成功", "如有疑问,请致电客服。"); } SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Impinfo.Money, "充预付款", comid);//发送短信 } }//减预付款 else if (acttype == "reduce_imprest") { MemberImprestData impdate = new MemberImprestData(); Member_Imprest Impinfo = new Member_Imprest() { Id = id, Comid = comid, Acttype = acttype, //操作类型 Money = 0 - decimal.Parse(money), //交易金额 Admin = username, Ip = addressIP, Ptype = 2, Oid = 0, Remark = "", OrderId = orderid, OrderName = ordername }; pro = impdate.InsertOrUpdate(Impinfo); if (pro != 0) { B2bCrmData prodata = new B2bCrmData(); var list = prodata.Readuser(Impinfo.Id, Impinfo.Comid); //SendSmsHelper.GetMember_sms(list.Phone, list.Name, list.Idcard.ToString(), list.Password1, Impinfo.Money, "减预付款", comid);//发送短信 if (list.Weixin != "") { new Weixin_tmplmsgManage().WxTmplMsg_CrmConsume(list.Com_id, list.Weixin, "名称", "使用预付款", "会员卡号", list.Idcard.ToString(), DateTime.Now.ToString(), " 使用" + Impinfo.Money + " 元预付款,如有疑问,请致电客服。"); } } } else { pro = 0;//正常操作返回0错误 } return(JsonConvert.SerializeObject(new { type = 100, msg = pro })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }