public static string EnterCardNumber(int issueid, decimal cardnumber, int comid) { string result = ""; Member_Issue issue = new MemberIssueData().GetIssueDetailById(issueid); Member_Card cardinfo = new MemberCardData().GetCardByCardNumber(cardnumber); if (cardinfo == null) { result = "卡号不存在"; return(JsonConvert.SerializeObject(new { type = 1, msg = result })); } else { //判断卡号是否已经录入 bool hasentered = new MemberCardData().IsHasEntered(cardnumber); if (hasentered) { result = "卡号已经录入"; return(JsonConvert.SerializeObject(new { type = 1, msg = result })); } } bool isenter = CommonEnterCardNumber(issueid, cardnumber, comid, out result, issue); if (isenter) { return(JsonConvert.SerializeObject(new { type = 100, msg = result })); } else { return(JsonConvert.SerializeObject(new { type = 1, msg = result })); } }
//当客户的渠道为0时,随机自动分配一个渠道编号(优先未锁定用户的),sendtype= 当为1的时候 有渠道也发送,一般是点击我的顾问时候发送,0=则是留言的时候变更渠道发送 public static int GetFenpeiChannel(int comid, string openid, int sendtype = 1, int companyid = 0, int channleid = 0) { var crmdata = new B2bCrmData(); MemberCardData carddata = new MemberCardData(); var channeldata = new MemberChannelData();//读取渠道信息 decimal idcard = 0; decimal channelid = 0; var userinfo_auto = carddata.GetMemberCardByOpenId(openid);;//获取微信操作账户 if (userinfo_auto != null) { idcard = userinfo_auto.Cardcode;; channelid = userinfo_auto.IssueCard;//获取渠道ID } //判断对 微信注册,网站注册渠道进行归0 var channeltype = channeldata.GetChannelDetail(int.Parse(channelid.ToString())); if (channeltype != null) { if (channeltype.Issuetype == 3 || channeltype.Issuetype == 4 || channeltype.Name == "默认渠道") {//如果渠道时微信注册或网站注册,渠道ID归0,下面自动重新分配有效渠道 channelid = 0; } } return(int.Parse(channelid.ToString())); }
private void GetMenshiDetail(string openid, int comid) { if (openid == "") { errlog = "未获得微信号"; } else { //判断用户身份:1.公司所属门店会员;2.公司会员 Member_Card card = new MemberCardData().GetMemberCardByOpenId(openid); if (card != null) { if (card.IssueCard > 0)//门店会员 { menshi = new MemberChannelcompanyData().GetMenShiByOpenId(openid, comid); if (menshi != null) { menshiimgurl = FileSerivce.GetImgUrl(menshi.Companyimg); } else { errlog = "获得门店信息为空"; } } else //公司会员 { Response.Redirect("OrderinfoTitle.aspx?id=" + comid); } } else { errlog = "未判断初用户身份"; } } }
//当客户的渠道为0时,随机自动分配一个渠道编号(优先未锁定用户的),sendtype= 当为1的时候 有渠道也发送,一般是点击我的顾问时候发送,0=则是留言的时候变更渠道发送 public static int AutoFenpeiChannel(int comid, string openid, int sendtype = 1, int companyid = 0, int channleid = 0) { var crmdata = new B2bCrmData(); MemberCardData carddata = new MemberCardData(); var channeldata = new MemberChannelData();//读取渠道信息 decimal idcard = 0; decimal channelid = 0; var userinfo_auto = carddata.GetMemberCardByOpenId(openid);;//获取微信操作账户 if (userinfo_auto != null) { idcard = userinfo_auto.Cardcode;; channelid = userinfo_auto.IssueCard;//获取渠道ID } //判断对 微信注册,网站注册渠道进行归0 var channeltype = channeldata.GetChannelDetail(int.Parse(channelid.ToString())); if (channeltype != null) { if (channeltype.Issuetype == 3 || channeltype.Issuetype == 4 || channeltype.Name == "默认渠道") {//如果渠道时微信注册或网站注册,渠道ID归0,下面自动重新分配有效渠道 channelid = 0; } } if (channelid == 0) { //查询在线渠道列表, int totalcount = 0; //在线数量 var channellist = channeldata.GetChannelListByComid(comid, companyid, 2, out totalcount, channleid); //先查询渠道列表 锁定客户为空的 if (channellist != null) { if (totalcount > 0) { //随机选择一个渠道 Random rand = new Random(); var channel_temp = channellist[rand.Next(0, totalcount - 1)]; var channelid_temp = channel_temp.Id; //绑定渠道 int upchannel = new MemberCardData().upCardcodeChannel(idcard.ToString(), channelid_temp); channelid = channelid_temp; } } //只有变更时才发送顾问信息 Sendweixinchient(openid, comid); } else { //点击顾问也发送 if (sendtype == 1) { Sendweixinchient(openid, comid); } } return(int.Parse(channelid.ToString())); }
//读取用户信息 private void Readuser(decimal idcard, int comid) { //Today = DateTime.Now.ToString("yyyy-MM-dd"); B2bCrmData dateuser = new B2bCrmData(); var userinfo = dateuser.GetB2bCrmByCardcode(idcard); if (userinfo != null) { uid = userinfo.Id; //Integral = userinfo.Integral.ToString() == "" ? "0" : userinfo.Integral.ToString(); //Imprest = userinfo.Imprest.ToString() == "" ? "0" : userinfo.Imprest.ToString(); //AccountWeixin = userinfo.Weixin; //AccountEmail = userinfo.Email; //Accountphone = userinfo.Phone; //AccountCard = userinfo.Idcard.ToString(); //string a = AccountCard.Substring(0, 1); //if (a != null) //{ // fcard = int.Parse(a.ToString()); //} //当读取用户信息的时候,判断是否有渠道转发信息 if (Request.Cookies["ZF_ChanneId"] != null) { int ZF_ChanneId = 0; ZF_ChanneId = int.Parse(Request.Cookies["ZF_ChanneId"].Value); if (ZF_ChanneId != 0) { //有转发渠道ID //在这判断 用户渠道是否为微信注册过来的 Member_Channel channel2 = new MemberChannelData().GetChannelByOpenId(userinfo.Weixin); if (channel2 != null) { if (channel2.Issuetype == 4) { //如果为微信注册过来的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } } else { //没有渠道的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } //清除Cookies HttpCookie aCookie = new HttpCookie("ZF_ChanneId"); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } } dateuser.WeixinConPass(userinfo.Weixin, comid);//只要包含SESSION登陆成功,清空微信密码 } }
public static string LoadingList(string comid, int pageindex, int pagesize, int userid) { var totalcount = 0; try { var list = new List <Member_Activity_Log>(); B2b_company_manageuser userr = B2bCompanyManagerUserData.GetUser(userid); if (userr != null) { if (userr.Channelcompanyid == 0)//总公司账户 { list = new B2bCrmData().LoadingList(comid, pageindex, pagesize, out totalcount); } else //总公司下面渠道 { list = new B2bCrmData().LoadingList(comid, pageindex, pagesize, int.Parse(userr.Channelcompanyid.ToString()), out totalcount); } IEnumerable result = ""; var memcompany = new MemberChannelcompanyData(); if (list != null) { result = from pro in list select new { ID = pro.ID, CardID = MemberCardData.GetCardId(pro.CardID).Cardcode.ToString(), //CardID =pro.CardID, ACTID = MemberActivityData.GetActById(pro.ACTID).Title.ToString(), OrderId = pro.OrderId, ServerName = pro.ServerName, Sales_admin = pro.Sales_admin, Num_people = pro.Num_people, Usesubdate = pro.Usesubdate, Per_capita_money = pro.Per_capita_money * pro.Num_people, Member_return_money = pro.Member_return_money, username = B2bCrmData.GetCrmCardcode(MemberCardData.GetCardId(pro.CardID).Cardcode) == null ? "--" : B2bCrmData.GetCrmCardcode(MemberCardData.GetCardId(pro.CardID).Cardcode).Name.ToString(), channel = memcompany.UpCompanyById(MemberCardData.GetCardId(pro.CardID).Cardcode.ToString()) } } ; return(JsonConvert.SerializeObject(new { type = 100, totalCount = totalcount, msg = result })); } else { return(JsonConvert.SerializeObject(new { type = 1, msg = "" })); } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
//读取用户信息 private void Readuser(decimal idcard, int comid) { //Today = DateTime.Now.ToString("yyyy-MM-dd"); B2bCrmData dateuser = new B2bCrmData(); var userinfo = dateuser.GetB2bCrmByCardcode(idcard); if (userinfo != null) { //Integral = userinfo.Integral.ToString() == "" ? "0" : userinfo.Integral.ToString(); //Imprest = userinfo.Imprest.ToString() == "" ? "0" : userinfo.Imprest.ToString(); //AccountWeixin = userinfo.Weixin; //AccountEmail = userinfo.Email; //Accountphone = userinfo.Phone; //AccountCard = userinfo.Idcard.ToString(); //string a = AccountCard.Substring(0, 1); //if (a != null) //{ // fcard = int.Parse(a.ToString()); //} weixinopenid = userinfo.Weixin; if (weixinopenid == "") { yonghustate = 0; } else if (weixinopenid != "" && zaixianzhuangtai == "我在线上") { MemberCardData carddata = new MemberCardData(); var cardmodel = carddata.GetCardByCardNumber(decimal.Parse(idcard.ToString())); if (cardmodel != null) { if (cardmodel.IssueCard == channelid) { yonghustate = 1; } else { yonghustate = 2; } } else { yonghustate = 2; } } else { yonghustate = 3; } dateuser.WeixinConPass(userinfo.Weixin, comid);//只要包含SESSION登陆成功,清空微信密码 } }
//读取用户信息 private void Readuser(decimal idcard, int comid) { //Today = DateTime.Now.ToString("yyyy-MM-dd"); B2bCrmData dateuser = new B2bCrmData(); var userinfo = dateuser.GetB2bCrmByCardcode(idcard); if (userinfo != null) { AccountId = userinfo.Id; userid = userinfo.Id.ToString(); //如果是登陆用户则读取用户的实际ID HttpCookie cookie = new HttpCookie("temp_userid"); //实例化HttpCookie类并添加值 cookie.Value = userinfo.Id.ToString(); cookie.Expires = DateTime.Now.AddDays(365); Response.Cookies.Add(cookie); var channeldata = new MemberChannelData(); channelid = channeldata.GetChannelid(userinfo.Com_id, userinfo.Phone); //当读取用户信息的时候,判断是否有渠道转发信息 if (Request.Cookies["ZF_ChanneId"] != null) { int ZF_ChanneId = 0; ZF_ChanneId = int.Parse(Request.Cookies["ZF_ChanneId"].Value); if (ZF_ChanneId != 0) { //有转发渠道ID //在这判断 用户渠道是否为微信注册过来的 Member_Channel channel2 = new MemberChannelData().GetChannelByOpenId(userinfo.Weixin); if (channel2 != null) { if (channel2.Issuetype == 4) { //如果为微信注册过来的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } } else { //没有渠道的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } //清除Cookies HttpCookie aCookie = new HttpCookie("ZF_ChanneId"); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } } dateuser.WeixinConPass(userinfo.Weixin, comid);//只要包含SESSION登陆成功,清空微信密码 } }
/// <summary> /// 公用录入单卡号方法 result:录入成功返回cardid,错误返回错误原因 /// </summary> /// <returns></returns> public static bool CommonEnterCardNumber(int issueid, decimal cardnumber, int comid, out string result, Member_Issue issue) { Member_Card cardinfo = new MemberCardData().GetCardByCardNumber(cardnumber); //判断卡号是否存在属于此次发行的卡片类型 int cardtype = cardinfo.Crid; int issuecardtype = issue.Crid; if (cardtype != issuecardtype) { result = "输入的卡号所属类型和发行需要的卡号类型不相符"; return(false); } Member_Channel channel = new MemberChannelData().GetChannelDetail(issue.Chid); List <Member_Issue_Activity> actlist = new MemberIssueActivityData().GetIssuePromot(issueid); try { var upMemberCardd = new MemberCardData().UPChannelCardCode(channel.Id, cardnumber, issueid);//更改生成卡号表中卡号所属渠道的id和发行id foreach (Member_Issue_Activity issueact in actlist) { Member_Card_Activity cardactinfo = new MemberCardActivityData().GetCardActInfo(cardinfo.Id, issueact.Acid); //防止一张卡重复录入同一次活动 if (cardactinfo == null) { Member_Card_Activity cardact = new Member_Card_Activity() { Id = 0, ACTID = issueact.Acid, Actnum = 1, CardID = cardinfo.Id, USEstate = (int)MemberCardUserState.NotUse, USEsubdate = DateTime.Parse("1900-01-01") }; var insertcardact = new MemberCardActivityData().EditMemberCardActivity(cardact); } } result = upMemberCardd.ToString(); return(true); } catch (Exception ex) { new SqlHelper().Dispose(); result = "意外错误"; return(false); throw; } }
//读取用户信息 private void Readuser(decimal idcard, int comid) { //Today = DateTime.Now.ToString("yyyy-MM-dd"); B2bCrmData dateuser = new B2bCrmData(); var userinfo = dateuser.GetB2bCrmByCardcode(idcard); if (userinfo != null) { //当读取用户信息的时候,判断是否有渠道转发信息 if (Request.Cookies["ZF_ChanneId"] != null) { int ZF_ChanneId = 0; ZF_ChanneId = int.Parse(Request.Cookies["ZF_ChanneId"].Value); if (ZF_ChanneId != 0) { //有转发渠道ID //在这判断 用户渠道是否为微信注册过来的 Member_Channel channel2 = new MemberChannelData().GetChannelByOpenId(userinfo.Weixin); if (channel2 != null) { if (channel2.Issuetype == 4) { //如果为微信注册过来的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } } else { //没有渠道的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } //清除Cookies HttpCookie aCookie = new HttpCookie("ZF_ChanneId"); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } } //读取渠道商户名称 var channelcompany = new MemberChannelcompanyData().GetChannelCompanyByCrmId(userinfo.Id); if (channelcompany != null) { tel = channelcompany.Companyphone; } dateuser.WeixinConPass(userinfo.Weixin, comid);//只要包含SESSION登陆成功,清空微信密码 } }
public static string GetCardFirst(int id) { try { var pro = MemberCardData.GetCardFirst(id); return(JsonConvert.SerializeObject(new { type = 100, msg = pro })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string EditCardInfo(Member_Card cardinfo) { try { var pro = MemberCardData.EditCardInfo(cardinfo); return(JsonConvert.SerializeObject(new { type = 100, msg = pro })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string GetMemberCardList(int comid, decimal cardcode, int pageindex, int pagesize, int issueid, int channelid, int actid, int isopencard) { var totalcount = 0; try { var prodata = new MemberCardData(); if (cardcode.ToString().Trim().Length == 11)//会员电话号码 { var carddata = new B2bCrmData().GetB2bCrmByPhone(comid, cardcode.ToString()); if (carddata != null) { cardcode = carddata.Idcard; } } var list = prodata.GetMemberCardList(comid, cardcode, pageindex, pagesize, issueid, channelid, actid, isopencard, out totalcount); IEnumerable result = ""; if (list != null) { result = from pro in list select new { CardCode = pro.Cardcode, Name = pro.Openstate == 0 ? "--" : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode) == null ? "" : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode).Name, Phone = pro.Openstate == 0 ? "--" : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode) == null ? "" : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode).Phone, Imprest = pro.Openstate == 0 ? 0 : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode) == null ? 0 : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode).Imprest, Integral = pro.Openstate == 0 ? 0 : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode) == null ? 0 : new B2bCrmData().GetB2bCrmByCardcode(pro.Cardcode).Integral, OpenSubDate = pro.Openstate == 0 ? "--" : pro.Opensubdate.ToString("yyyy-MM-dd") == "1900-01-01" ? "--" : pro.Opensubdate.ToString("yyyy-MM-dd"), ChannelName = pro.IssueCard == 0 ? "--" : new MemberChannelData().GetChannelDetail(int.Parse(pro.IssueCard.ToString())).Name, ActStr = pro.IssueCard == 0 ? "--" : new MemberIssueActivityData().GetIssueActStr(pro.IssueId), IssueTitle = pro.IssueCard == 0 ? "--" : new MemberIssueData().GetIssueDetailById(pro.IssueId) == null ? "" : new MemberIssueData().GetIssueDetailById(pro.IssueId).Title, EnteredState = pro.IssueCard == 0 ? "未录入" : "已录入", OpenState = pro.Openstate == 0 ? "未开卡" : "已开卡" } } ; return(JsonConvert.SerializeObject(new { type = 100, totalCount = totalcount, msg = result })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string SearchCard(string pno, int comid, out int userinfo) { try { MemberCardData carddate = new MemberCardData(); var pro = carddate.SearchCard(pno, comid, out userinfo); return(JsonConvert.SerializeObject(new { type = 100, msg = pro })); } catch (Exception ex) { userinfo = 0; return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string GetCardInfo(int logid, int pno, int comid) { try { MemberCardData carddate = new MemberCardData(); var pro = carddate.GetCardInfo(logid, pno, comid); return(JsonConvert.SerializeObject(new { type = 100, msg = pro })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string GetCarValidate(int actid, int cardid, int orderid, string servername, int num_people, int per_capita_money, int menber_return_money, string sales_admin, int comid, string AccountName) { try { MemberCardData carddate = new MemberCardData(); var pro = carddate.GetCarValidate(actid, cardid, orderid, servername, num_people, per_capita_money, menber_return_money, sales_admin, comid, AccountName); return(JsonConvert.SerializeObject(new { type = 100, msg = pro })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string EconfirmCard(int aid, int actid, int cardid, int comid, out Member_Activity actinfo, out string phone, out string name, out decimal idcard, out decimal agcardcode) { try { MemberCardData carddate = new MemberCardData(); var pro = carddate.EconfirmCard(aid, actid, cardid, comid, out actinfo, out phone, out name, out idcard, out agcardcode); Member_Channel channel = new MemberChannelData().GetChannelDetailByCardNo(idcard.ToString());//根据卡号得到所属渠道的详细信息 if (channel != null) { //给渠道表中 开卡数量和总金额赋值 channel.Firstdealnum = channel.Firstdealnum + 1; channel.Summoney = channel.Summoney + channel.RebateConsume; var channeldata = new MemberChannelData().EditChannel(channel); //把返佣日志录入渠道返佣日志表 ChannelRebateLog channelrebatelog = new ChannelRebateLog() { Id = 0, Channelid = channel.Id, Execdate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")), Rebatemoney = channel.RebateConsume, Type = (int)ChannelRebateType.FirstDeal, Summoney = channel.Summoney, Remark = "消费返佣" + channel.RebateConsume + "元" }; var channelrebatelogret = new ChannelRebateLogData().EditChannelRebateLog(channelrebatelog); } return(JsonConvert.SerializeObject(new { type = 100, actinfo = actinfo, phone = phone, name = name, idcard = idcard, agcardcode = agcardcode, msg = pro })); } catch (Exception ex) { actinfo = null; phone = ""; name = ""; idcard = 0; agcardcode = 0; return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string Readuser(int id, int comid) { try { var prodata = new B2bCrmData(); var list = prodata.Readuser(id, comid); var rename = MemberChannelData.GetChannelinfo(int.Parse(MemberCardData.GetCardNumber(list.Idcard).IssueCard.ToString())); var memcard = MemberChannelData.GetChannelinfo(int.Parse(MemberCardData.GetCardNumber(list.Idcard).ServerCard.ToString())); return(JsonConvert.SerializeObject(new { type = 100, msg = list, Namechannl = rename, Mem = memcard })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string CardPageList(string comid, int pageindex, int pagesize) { var totalcount = 0; try { var actdata = new MemberCardData(); var list = actdata.CardPageList(comid, pageindex, pagesize, out totalcount); IEnumerable result = ""; if (list != null) { result = from pro in list select new { Id = pro.Id, Com_id = pro.Com_id, Cname = pro.Cname, Ctype = pro.Ctype == 1 ? "实体卡" : "非实体卡", Printnum = pro.Printnum, Qrcode = pro.Qrcode, Zhuanzeng = pro.Zhuanzeng, Remark = pro.Remark, Exchange = pro.Exchange, CardRule = pro.CardRule, CardRule_First = pro.CardRule_First, CardRule_starnum = pro.CardRule_starnum, Outstate = pro.Outstate == false ? "立即导出" : "已导出", Subdate = pro.Subdate, Createstate = pro.Createstate == false ? "立即生成卡号" : "已生成", } } ; return(JsonConvert.SerializeObject(new { type = 100, totalCount = totalcount, msg = result })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public static string Logcardact(int actid, int cardid, int comid) { var totalcount = 0; try { var prodata = new B2bCrmData(); var list = prodata.Logcardact(actid, cardid, comid, out totalcount); IEnumerable result = ""; var memcompany = new MemberChannelcompanyData(); if (list != null) { result = from pro in list select new { ID = pro.ID, CardID = MemberCardData.GetCardId(pro.CardID).Cardcode, ACTID = MemberActivityData.GetActById(pro.ACTID).Title, //OrderId = pro.OrderId, ServerName = pro.ServerName, //Sales_admin = pro.Sales_admin, //Num_people = pro.Num_people, Usesubdate = pro.Usesubdate, Per_capita_money = pro.Per_capita_money * pro.Num_people, //Member_return_money = pro.Member_return_money, } } ; return(JsonConvert.SerializeObject(new { type = 100, msg = result, totalcount = totalcount })); } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
public int InsertOrUpdate(Member_Card model) { string insertsqltxt = ""; //卡号插入SQL int cardid = 0; //卡管理ID string cardcode = ""; //卡号 int RandomCode = 0; var cmd = sqlHelper.PrepareStoredSqlCommand(SQLInsertOrUpdate); cmd.AddParam("@Id", model.Id); cmd.AddParam("@Com_id", model.Com_id); cmd.AddParam("@cname", model.Cname); cmd.AddParam("@ctype", model.Ctype); cmd.AddParam("@printnum", model.Printnum); cmd.AddParam("@zhuanzeng", model.Zhuanzeng); cmd.AddParam("@qrcode", model.Qrcode); cmd.AddParam("@Exchange", model.Exchange); cmd.AddParam("@remark", model.Remark); cmd.AddParam("@cardRule", model.CardRule); cmd.AddParam("@cardRule_starnum", model.CardRule_starnum); cmd.AddParam("@cardRule_First", model.CardRule_First); var parm = cmd.AddReturnValueParameter("ReturnValue"); cmd.ExecuteNonQuery(); cardid = (int)parm.Value; //是修改操作将不产生卡号 if (model.Id == 0) { //后8位如果是顺序编码2 则执行 if (model.CardRule == 2) { for (int i = model.CardRule_starnum; i < model.CardRule_starnum + model.Printnum; i++) { cardcode = model.CardRule_First + model.CardRule_Second.ToString() + i; insertsqltxt = "insert Member_Card (com_id,crid,cardcode)values(" + model.Com_id + "," + cardid + "," + cardcode + ")"; cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); cmd.ExecuteNonQuery(); } } //后8位采用随机编码1 else { for (int i = 1; i < model.Printnum; i++) { //获得随机码 RandomCode = MemberCardData.GetRandomCode(); //使用随机码时,标记为已使用防止重复码 insertsqltxt = "update RandomCode set state = 1 where code = " + RandomCode; cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); cmd.ExecuteNonQuery(); //插入卡库Member_Card cardcode = model.CardRule_First + model.CardRule_Second.ToString() + RandomCode; insertsqltxt = "insert Member_Card (com_id,crid,cardcode)values(" + model.Com_id + "," + cardid + "," + cardcode + ")"; cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); cmd.ExecuteNonQuery(); } } } return((int)parm.Value); }
/// <summary> /// 上传文件并导入到数据库 /// </summary> protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { int imlogid = 0; bool b = Upload(FileUpload1, out imlogid); if (b) { byte[] fileBytes = FileUpload1.FileBytes; if (ExcelRender.HasData(new MemoryStream(fileBytes))) { Stream excelFileStream = new MemoryStream(fileBytes); int sheetIndex = 0; int headerRowIndex = 0; using (excelFileStream) { using (IWorkbook workbook = new HSSFWorkbook(excelFileStream)) { using (ISheet sheet = workbook.GetSheetAt(sheetIndex)) { StringBuilder builder = new StringBuilder(); IRow headerRow = sheet.GetRow(headerRowIndex); int cellCount = headerRow.LastCellNum; //LastCellNum = PhysicalNumberOfCells int rowCount = sheet.LastRowNum; //LastRowNum = PhysicalNumberOfRows - 1 if (rowCount > 5000) { Literal1.Text = "每次导入限制5000条数据"; } else { this.Button1.Enabled = false; this.Button1.Text = "导入中.."; for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++) { IRow row = sheet.GetRow(i); if (row != null) { string outcardcode = GetCellValue(row.GetCell(0));//外部卡号 if (outcardcode.Trim() != "") { //判断卡号是否存在此商户下 int ishas = new MemberCardData().IsHasOutCardcode(comid, outcardcode); if (ishas == 0) { if (CommonFunc.IsNumber(outcardcode)) { int r = new MemberCardData().InsOutMemberCardcode(outcardcode, 0, comid, imlogid); } } } } } this.Button1.Enabled = true; this.Button1.Text = "导入Excel到数据库"; Literal1.Text = "导入会员卡号成功"; } } } } } else { Literal1.Text = "没有数据可用于导入"; } fileBytes = null; } else { //错误描述在方法 Upload 已经出现 } BindGrid(); } else { Literal1.Text = "请选择导入文件"; } }
protected void Button3_Click(object sender, EventArgs e) { initJavascript(); string id = ((Button)sender).CommandArgument.ToString(); //Response.Write("<script>alert('" + id + "')</script>"); //根据id得到拆分的的记录 ObtainGzListSplit model = new ObtainGzListSplitData().GetObtainGzListSplit(int.Parse(id)); if (model != null) { //根据公司得到会员录入的次数 int MaxImportNum = new ExcelImportLogData().GetMaxImportNum(comid); int rowAffected = 0; //录入正确的条数 int rowerr = 0; //录入错误的条数 string dd = ""; //页面提示内容 string[] str = model.Splitopenid.Split(','); for (int i = 0; i < str.Length; i++) { if (str[i] != "") { int whetherwxfocus = 0; //微信关注状态标注为1(未关注) int whetheractivate = 0; //用户激活状态标注为0(未激活) string name = ""; //姓名 string phone = ""; //手机号 string email = ""; //email string weixin = str[i]; //微信号 if (weixin != "") { whetherwxfocus = 1; whetheractivate = 1; } int importstate = 1; //录入状态默认1:成功;0:出错 string ErrReason = ""; //录入错误原因 bool ishascrmphone = false; bool ishascrmweixin = false; //if (phone != "") //{ // ishascrmphone = new B2bCrmData().IsHasCrmPhone(comid, phone);//判断当前公司会员是否已经绑定当前手机 // if (ishascrmphone == true) // { // ErrReason = "当前公司已有会员绑定过手机" + phone; // } //} if (weixin != "") { ishascrmweixin = new B2bCrmData().IsHasCrmWeiXin(comid, weixin);//判断当前公司会员是否已经绑定当前微信 if (ishascrmweixin == true) { ErrReason = "当前公司已有会员绑定过微信" + weixin; } } if (ishascrmphone == false && ishascrmweixin == false) { if (phone == "" && weixin == "") { ErrReason = "导入会员的手机,微信必须至少有其中一项"; //会员通过excel录入日志 importstate = 0; int importnum = MaxImportNum + 1; string importtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int insertlog = new ExcelImportLogData().InsExcelImportLog(importstate, 0, comid, "0", name, phone, weixin, whetherwxfocus, whetheractivate, importtime, importnum, email, ErrReason); rowerr++; } else { //创建卡号并插入活动 string cardcode = MemberCardData.CreateECard(2, comid); //插入会员表 decimal imprest = 0; //预付款 decimal integral = 0; //积分 string agegroup = ""; //年龄段 string crmlevel = "A"; //会员级别,默认网站注册 string country = ""; string province = ""; string city = ""; string address = ""; //插入会员表 int insb2bcrm = new B2bCrmData().ExcelInsB2bCrm(comid, cardcode, name, phone, weixin, whetherwxfocus, whetheractivate, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), email, imprest, integral, country, province, city, address, agegroup, crmlevel); //插入关注赠送优惠券 int jifen_temp = 0; var InputMoney = MemberCardData.AutoInputMoeny(insb2bcrm, 4, comid, out jifen_temp); //会员通过excel录入日志 int importnum = MaxImportNum + 1; string importtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int insertlog = new ExcelImportLogData().InsExcelImportLog(importstate, insb2bcrm, comid, cardcode, name, phone, weixin, whetherwxfocus, whetheractivate, importtime, importnum, email, ErrReason); rowAffected++; } } else { //会员通过excel录入日志 importstate = 0; int importnum = MaxImportNum + 1; string importtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int insertlog = new ExcelImportLogData().InsExcelImportLog(importstate, 0, comid, "0", name, phone, weixin, whetherwxfocus, whetheractivate, importtime, importnum, email, ErrReason); rowerr++; } } } UnloadJavascript(); dd += "成功导入数据共:" + rowAffected.ToString() + "条;"; if (rowerr > 0) { dd += "重复数据共:" + rowerr.ToString() + "条;"; } Response.Write("<script>alert('" + dd + "');</script>"); } else { UnloadJavascript(); Response.Write("<script>alert('拆分记录为空');</script>"); } }
protected void Page_Load(object sender, EventArgs e) { string phone = Request["etmobile"].ConvertTo <string>(""); string duanxintext = Request["duanxintext1"].ConvertTo <string>(""); int comid = Request["comid"].ConvertTo <int>(0); int userid = Request["userid"].ConvertTo <int>(0); string isqunfa = Request["isqunfa"].ConvertTo <string>("no"); if (isqunfa == "yes") { isqunfa = "1"; } else { isqunfa = "0"; } string msg = ""; int sendstate = 0; //发送结果默认为0 string Invitecode = ""; //验证码 //获取公司微信号 B2b_company com = B2bCompanyData.GetAllComMsg(comid); if (com.B2bcompanyinfo.Weixinname == "") { msg = phone + "公司微信号为空"; } else { duanxintext = duanxintext.Replace("$comweixin$", com.B2bcompanyinfo.Weixinname); //判断手机格式是否正确 bool isphone = Regex.IsMatch(phone, @"^1[358]\d{9}$", RegexOptions.IgnoreCase); if (isphone) { //获得随机码 Invitecode = MemberCardData.GetRandomCode().ToString(); //使用随机码时,标记为已使用 防止重复码 ExcelSqlHelper.ExecuteNonQuery("update RandomCode set state = 1 where code = " + Invitecode); duanxintext = duanxintext.Replace("$invitecode$", Invitecode); sendstate = SendSmsHelper.SendSms(phone, duanxintext, comid, out msg); } else { msg = phone + "手机格式不正确"; } } //录入发送邀请码日志 B2b_invitecodesendlog log = new B2b_invitecodesendlog { Id = 0, Phone = phone, Smscontent = duanxintext, Invitecode = Invitecode, Senduserid = userid, Sendtime = DateTime.Now, Issendsuc = 0, Isqunfa = int.Parse(isqunfa), Remark = msg, Comid = comid }; if (sendstate > 0) { log.Issendsuc = 1; } else { log.Issendsuc = 0; } int result = new B2b_invitecodesendlogData().Inslog(log); }
//读取用户信息 private void Readuser(decimal idcard, int comid) { Today = DateTime.Now.ToString("yyyy-MM-dd"); B2bCrmData dateuser = new B2bCrmData(); var userinfo = dateuser.GetB2bCrmByCardcode(idcard); if (userinfo != null) { Integral = userinfo.Integral.ToString() == "" ? "0" : userinfo.Integral.ToString(); Imprest = userinfo.Imprest.ToString() == "" ? "0" : userinfo.Imprest.ToString(); AccountWeixin = userinfo.Weixin; AccountEmail = userinfo.Email; Accountphone = userinfo.Phone; AccountCard = userinfo.Idcard.ToString(); string a = AccountCard.Substring(0, 1); if (a != null) { fcard = int.Parse(a.ToString()); } MemberCardData carddata = new MemberCardData(); var cardinfo = carddata.GetCardByCardNumber(decimal.Parse(AccountCard)); if (cardinfo != null) { channelid = Int32.Parse(cardinfo.IssueCard.ToString()); } //获取预付款记录 B2bFinanceData fdate = new B2bFinanceData(); int totalcount = 0; var list = fdate.ImprestList(1, 10, comid, out totalcount, userinfo.Id); if (list != null) { Imprestlist = "<ul>"; for (int i = 0; i < list.Count; i++) { if (list[i].Money < 0) { Imprestlist += "<li>" + list[i].Subdate + " 支出:" + list[i].Money.ToString("0.00") + "元</li>"; } else { Imprestlist += "<li>" + list[i].Subdate + " 获得:" + list[i].Money.ToString("0.00") + "元</li>"; } } Imprestlist += "</ul>"; } //获取积分记录 var integrallist = fdate.IntegralList(1, 10, comid, out totalcount, userinfo.Id); if (integrallist != null) { Integrallist = "<ul>"; for (int i = 0; i < integrallist.Count; i++) { if (integrallist[i].Money < 0) { Integrallist += "<li>" + integrallist[i].Subdate + " 支出:" + integrallist[i].Money.ToString("0") + "</li>"; } else { Integrallist += "<li>" + integrallist[i].Subdate + " 获得:" + integrallist[i].Money.ToString("0") + "</li>"; } } Integrallist += "</ul>"; } //消费记录 string proname = ""; string orderstate = ""; B2bOrderData dataorder = new B2bOrderData(); var prodata = new B2bComProData(); var order = dataorder.ConsumerOrderPageList("", 1, 10, userinfo.Id, out totalcount); if (order != null) { Orderlist = "<ul>"; for (int i = 0; i < order.Count; i++) { var promodel = prodata.GetProById(order[i].Pro_id.ToString()); if (promodel != null) { proname = promodel.Pro_name; } orderstate = EnumUtils.GetName((OrderStatus)order[i].Order_state); Orderlist += "<li>" + proname + "(" + order[i].U_subdate + ") " + order[i].U_num + "(" + orderstate + ")</li>"; } Orderlist += "</ul>"; } //当读取用户信息的时候,判断是否有渠道转发信息 if (Request.Cookies["ZF_ChanneId"] != null) { int ZF_ChanneId = 0; ZF_ChanneId = int.Parse(Request.Cookies["ZF_ChanneId"].Value); if (ZF_ChanneId != 0) { //有转发渠道ID //在这判断 用户渠道是否为微信注册过来的 Member_Channel channel2 = new MemberChannelData().GetChannelByOpenId(userinfo.Weixin); if (channel2 != null) { if (channel2.Issuetype == 4) { //如果为微信注册过来的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } } else { //没有渠道的 ,则修改会员渠道即可 int upchannel = new MemberCardData().upCardcodeChannel(userinfo.Idcard.ToString(), ZF_ChanneId); } //清除Cookies HttpCookie aCookie = new HttpCookie("ZF_ChanneId"); aCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(aCookie); } } dateuser.WeixinConPass(userinfo.Weixin, comid);//只要包含SESSION登陆成功,清空微信密码 } }
public static string AccountClaimActPageList(int aid, int cardid, int AccountId, int comid) { int totalcount = 0; var aaid = 0; var ret = ""; try { if (cardid != 0) { //查询优惠券 MemberActivityData Activitydata = new MemberActivityData(); Member_Activity Activitymodel = Activitydata.GetMemberActivityById(aid); if (Activitymodel != null) { if (Activitymodel.Runstate == false) { return(JsonConvert.SerializeObject(new { type = 1, msg = "活动已结束" })); } var today = DateTime.Now; if (Activitymodel.Actstar < today && Activitymodel.Actend.AddDays(1) > today) { } else { return(JsonConvert.SerializeObject(new { type = 1, msg = "活动已结束" })); } } //每个活动只能领取一次,防止重复领取, var listact = Activitydata.AccountActInfo(aid, AccountId, comid, out totalcount); if (listact == null) { //领取活动 aaid = Activitydata.AccountClaimActPageList(aid, cardid, comid); if (aaid != 0) { if (Activitymodel != null) { if (Activitymodel.Acttype == 4)//只有积分优惠券才会领取时充入积分 { MemberIntegralData intdate = new MemberIntegralData(); Member_Integral Intinfo = new Member_Integral() { Id = AccountId, Comid = comid, Acttype = "add_integral", //操作类型,增加积分 Money = Activitymodel.Money, //交易金额 Admin = "领取积分优惠券", Ip = "", Ptype = 1, Oid = 0, Remark = "", OrderId = 0, OrderName = Activitymodel.Atitle }; var InsertIntegral = intdate.InsertOrUpdate(Intinfo); //优惠券确认使用 Member_Activity actinfo = null; string phone = ""; string name = ""; decimal idcard = 0; decimal aggcardcode = 0; MemberCardData carddata = new MemberCardData(); var confirm = carddata.EconfirmCard(aaid, aid, cardid, comid, out actinfo, out phone, out name, out idcard, out aggcardcode); B2bCrmData prodata = new B2bCrmData(); var list = prodata.Readuser(AccountId, comid); //微信消息模板 if (list.Weixin != "") { new Weixin_tmplmsgManage().WxTmplMsg_CrmIntegralReward(list.Com_id, list.Weixin, "您好," + AccountId + " 积分已经打入您的账户", list.Idcard.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "活动赠送", Intinfo.Money.ToString(), list.Integral.ToString(), "如有疑问,请致电客服。"); } } } } ret = "OK"; } else { ret = "已领取活动"; } return(JsonConvert.SerializeObject(new { type = 100, msg = ret })); } else { return(JsonConvert.SerializeObject(new { type = 1, msg = "Unlogin" })); } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { type = 1, msg = ex.Message })); throw; } }
////导入项目列表,不用后删除或者隐藏 //protected void Button2_Click(object sender, EventArgs e) //{ // if (FileUpload1.HasFile) // { // byte[] fileBytes = FileUpload1.FileBytes; // if (ExcelRender.HasData(new MemoryStream(fileBytes))) // { // Stream excelFileStream = new MemoryStream(fileBytes); // int sheetIndex = 0; // int headerRowIndex = 0; // using (excelFileStream) // { // using (IWorkbook workbook = new HSSFWorkbook(excelFileStream)) // { // using (ISheet sheet = workbook.GetSheetAt(sheetIndex)) // { // StringBuilder builder = new StringBuilder(); // IRow headerRow = sheet.GetRow(headerRowIndex); // int cellCount = headerRow.LastCellNum;//LastCellNum = PhysicalNumberOfCells // int rowCount = sheet.LastRowNum;//LastRowNum = PhysicalNumberOfRows - 1 // for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++) // { // IRow row = sheet.GetRow(i); // if (row != null) // { // string name = GetCellValue(row.GetCell(0));//项目名称 // //判断项目中是否有同名的项目,有的话不在录入 // object o = ExcelSqlHelper.ExecuteScalar("select count(1) from b2b_com_project where projectname='" + name + "'"); // int c = o == null ? 0 : int.Parse(o.ToString()); // if (c > 0) // { // } // else // { // B2b_com_project model = new B2b_com_project // { // Id = 0, // Projectname = name, // Projectimg = 0, // Province = "", // City = "", // Industryid = 0, // Briefintroduce = "", // Address = "", // Mobile = "", // Coordinate = "", // Serviceintroduce = "", // Onlinestate = "0", // Comid = 106, // Createuserid = UserHelper.CurrentUser().Id, // Createtime = DateTime.Now // }; // int d = new B2b_com_projectData().EditProject(model); // } // } // if (i == rowCount) // { // Literal1.Text = "导入完成"; // } // } // } // } // } // } // } //} #endregion //上传文件方法 private bool Upload(System.Web.UI.WebControls.FileUpload myFileUpload, out int imlogid) { bool flag = false; //是否允许上载 bool fileAllow = false; //设定允许上载的扩展文件名类型 string[] allowExtensions = { ".xls" }; //取得网站根目录路径 string path = HttpContext.Current.Request.MapPath("~/upload_outMemberCardcode/"); if (myFileUpload.HasFile) { string fileExtension = System.IO.Path.GetExtension(myFileUpload.FileName).ToLower(); for (int i = 0; i < allowExtensions.Length; i++) { if (fileExtension == allowExtensions[i]) { fileAllow = true; } } if (fileAllow) { try { //string filename=DateTime.Now.ToString("HHmmssfff")+ myFileUpload.FileName; //string filePath = path + filename; ////存储文件到文件夹 //myFileUpload.SaveAs(filePath); HttpPostedFile file = myFileUpload.PostedFile; byte[] data = new byte[file.ContentLength]; file.InputStream.Read(data, 0, file.ContentLength); string filename = DateTime.Now.ToString("HHmmssfff") + "-" + myFileUpload.FileName; string filePath = path + filename; string relativepath = "/upload_outMemberCardcode/" + filename; FileStream fs = new FileStream(filePath, FileMode.CreateNew); fs.Write(data, 0, data.Length); fs.Close(); Literal1.Text = "文件导入成功"; flag = true; imlogid = new MemberCardData().Insoutcardcodeimlog(myFileUpload.FileName, relativepath, imtor, comid, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); } catch (Exception ex) { Literal1.Text += ex.Message; flag = false; imlogid = 0; } } else { Literal1.Text = "不允许上载:" + myFileUpload.PostedFile.FileName + ",只能上传xls的文件,请检查!"; flag = false; imlogid = 0; } } else { Literal1.Text = "请选择要导入的excel文件!"; flag = false; imlogid = 0; } return(flag); }
/// <summary> /// 上传文件并导入到数据库 /// </summary> protected void Button1_Click(object sender, EventArgs e) { initJavascript(); //comid = int.Parse(ddlcompany.SelectedValue.ToString()); string dd = "";//页面提示内容 //根据公司得到会员录入的次数 int MaxImportNum = new ExcelImportLogData().GetMaxImportNum(comid); if (FileUpload1.HasFile) { byte[] fileBytes = FileUpload1.FileBytes; if (ExcelRender.HasData(new MemoryStream(fileBytes))) { Stream excelFileStream = new MemoryStream(fileBytes); int sheetIndex = 0; int headerRowIndex = 0; int rowAffected = 0; //录入正确的条数 int rowerr = 0; //录入错误的条数 using (excelFileStream) { using (IWorkbook workbook = new HSSFWorkbook(excelFileStream)) { using (ISheet sheet = workbook.GetSheetAt(sheetIndex)) { StringBuilder builder = new StringBuilder(); IRow headerRow = sheet.GetRow(headerRowIndex); int cellCount = headerRow.LastCellNum; //LastCellNum = PhysicalNumberOfCells int rowCount = sheet.LastRowNum; //LastRowNum = PhysicalNumberOfRows - 1 if (rowCount > 1000) { dd += "<strong>每次导入限制1000条数据</strong>"; } else { for (int i = (sheet.FirstRowNum + 1); i <= rowCount; i++) { IRow row = sheet.GetRow(i); if (row != null) { int whetherwxfocus = 0; //微信关注状态标注为1(未关注) int whetheractivate = 0; //用户激活状态标注为0(未激活) string name = GetCellValue(row.GetCell(0)); //姓名 string phone = GetCellValue(row.GetCell(1)); //手机号 string email = GetCellValue(row.GetCell(2)); //email string weixin = GetCellValue(row.GetCell(3)); //微信号 if (weixin != "") { whetherwxfocus = 1; whetheractivate = 1; } string country = "中国"; //国家,都为“中国” string province = GetCellValue(row.GetCell(4)).ConvertTo <string>(""); //城市 string city = GetCellValue(row.GetCell(5)).ConvertTo <string>(""); //区县 string address = GetCellValue(row.GetCell(6)).ConvertTo <string>(""); //地址 string agegroup = GetCellValue(row.GetCell(7)).ConvertTo <string>(""); //年龄段 string crmlevel = GetCellValue(row.GetCell(8)).ConvertTo <string>("A"); //会员级别 decimal imprest = GetCellValue(row.GetCell(9)).ConvertTo <decimal>(0); //预付款 decimal integral = GetCellValue(row.GetCell(10)).ConvertTo <decimal>(0); //积分 int importstate = 1; //录入状态默认1:成功;0:出错 string ErrReason = ""; //录入错误原因 bool ishascrmphone = false; bool ishascrmweixin = false; if (phone != "") { ishascrmphone = new B2bCrmData().IsHasCrmPhone(comid, phone);//判断当前公司会员是否已经绑定当前手机 if (ishascrmphone == true) { ErrReason = "当前公司已有会员绑定过手机" + phone; } } if (weixin != "") { ishascrmweixin = new B2bCrmData().IsHasCrmWeiXin(comid, weixin);//判断当前公司会员是否已经绑定当前微信 if (ishascrmweixin == true) { ErrReason = "当前公司已有会员绑定过微信" + weixin; } } if (ishascrmphone == false && ishascrmweixin == false) { if (phone == "" && weixin == "") { ErrReason = "导入会员的手机,微信必须至少有其中一项"; //会员通过excel录入日志 importstate = 0; int importnum = MaxImportNum + 1; string importtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int insertlog = new ExcelImportLogData().InsExcelImportLog(importstate, 0, comid, "0", name, phone, weixin, whetherwxfocus, whetheractivate, importtime, importnum, email, ErrReason); rowerr++; } else { //创建卡号并插入活动 string cardcode = MemberCardData.CreateECard(2, comid); //插入会员表 int insb2bcrm = new B2bCrmData().ExcelInsB2bCrm(comid, cardcode, name, phone, weixin, whetherwxfocus, whetheractivate, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), email, imprest, integral, country, province, city, address, agegroup, crmlevel); int jifen_temp = 0; //插入关注赠送优惠券 var InputMoney = MemberCardData.AutoInputMoeny(insb2bcrm, 4, comid, out jifen_temp); //会员通过excel录入日志 int importnum = MaxImportNum + 1; string importtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int insertlog = new ExcelImportLogData().InsExcelImportLog(importstate, insb2bcrm, comid, cardcode, name, phone, weixin, whetherwxfocus, whetheractivate, importtime, importnum, email, ErrReason); rowAffected++; } } else { //会员通过excel录入日志 importstate = 0; int importnum = MaxImportNum + 1; string importtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); int insertlog = new ExcelImportLogData().InsExcelImportLog(importstate, 0, comid, "0", name, phone, weixin, whetherwxfocus, whetheractivate, importtime, importnum, email, ErrReason); rowerr++; } } } } } } } UnloadJavascript(); dd += "<strong>成功导入数据共:" + rowAffected.ToString() + "条;</strong>"; if (rowerr > 0) { dd += "<strong>错误导入数据共:" + rowerr.ToString() + "条;</strong>"; } Literal1.Text = dd; } else { UnloadJavascript(); Literal1.Text = "没有数据可用于导入"; } fileBytes = null; } BindGrid(comid, MaxImportNum + 1); }
public string CreateECard(int cardtype, int comid) { string insertsqltxt = ""; //卡号插入SQL string cardcode = ""; //卡号 int Face = 1; //活动面向对象 Face=3网站 Face=4微信 //从公司自己导入的卡号中获取卡号,如果没有的话则创建 cardcode = new MemberCardData().GetUnusedOutCardcode(comid); if (cardcode == "") { int RandomCode = 0; int Firstcard = 0; int Scountcard = Int16.Parse(DateTime.Now.ToString("yyMM")); if (cardtype == 1) { Firstcard = 2002; Face = 3; } else { Firstcard = 2001; Face = 4; } //获得随机码 RandomCode = MemberCardData.GetRandomCode(); //使用随机码时,标记为已使用防止重复码 insertsqltxt = "update RandomCode set state = 1 where code = " + RandomCode; var cmda = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); cmda.ExecuteNonQuery(); //插入卡库Member_Card cardcode = Firstcard.ToString() + Scountcard.ToString() + RandomCode; } else { //把得到的外部导入会员卡号标注为已使用,防止重复 insertsqltxt = "update Out_MemberCardCode set isused = 1 where outcardcode = '" + cardcode + "'"; var cmda = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); cmda.ExecuteNonQuery(); } insertsqltxt = "insert Member_Card (com_id,crid,cardcode,openstate)values(" + comid + ",0," + cardcode + ",1);select @@identity;"; var cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); string cardid = cmd.ExecuteScalar().ToString(); //直接插入活动指定活动3=网站活动,4=微信活动 insertsqltxt = "insert into Member_Card_Activity (CardID,ACTID ) select " + cardid + ",id from Member_Activity where com_id=" + comid + " and FaceObjects=" + Face; cmd = this.sqlHelper.PrepareTextSqlCommand(insertsqltxt); cmd.ExecuteNonQuery(); DateTime today = DateTime.Now; //当时微信注册或网站注册的 积分活动,自动已赠送,活动变成已使用 string updatesqltxt = "update member_card_activity set actnum=0,usestate=2,usesubdate='" + today + "' where cardid=" + cardid + " and actid in (select id from Member_Activity where acttype=4 and faceobjects in (4,3))"; cmd = this.sqlHelper.PrepareTextSqlCommand(updatesqltxt); cmd.ExecuteNonQuery(); return(cardcode); }
public string GetEnteredNumberByChannelId(string id) { int EnterCardNum = new MemberCardData().GetEnteredNumberByChannelId(int.Parse(id)); return(EnterCardNum.ToString()); }