using System; using System.Collections.Generic; using System.Web; using System.Text; using System.Data; using System.Data.SqlClient; using System.IO; using System.Net; using System.Web.SessionState; using System.Text.RegularExpressions; using System.Globalization; using System.Configuration; using Newtonsoft.Json; using System.Web.Script.Serialization; using System.Drawing; using System.Security.Cryptography; using Mtxfw.Utility; using Mtxfw.VipSite.api; using ThoughtWorks.QRCode.Codec; using ThoughtWorks.QRCode.Codec.Data; using ThoughtWorks.QRCode.Codec.Util; namespace Mtxfw.VipSite { /// /// Ajax 处理页面 /// public class xapiajax : IHttpHandler, IRequiresSessionState { DAL.user_info daoUser = new DAL.user_info(); Utility.Config config = new Utility.Config(""); DAL.user_Results daoResults = new DAL.user_Results(); DAL.user_Results_jl2 daojl2 = new DAL.user_Results_jl2(); DAL.user_Results_jl daojl = new DAL.user_Results_jl(); DAL.P_Category daoCategory = new DAL.P_Category(); DAL.P_Product daoProduct = new DAL.P_Product(); DAL.P_Guige daoGuige = new DAL.P_Guige(); DAL.order_info daoorder = new DAL.order_info(); Mtxfw.DAL.order_product_info daoorderproduct = new Mtxfw.DAL.order_product_info(); DAL.user_Goods daoGoods = new DAL.user_Goods(); DAL.province daoprovince = new DAL.province(); DAL.city daocity = new DAL.city(); DAL.county daocounty = new DAL.county(); DAL.Article daoArt = new DAL.Article(); DAL.user_proxy daoproxy = new DAL.user_proxy(); public int gtype = 0; DAL.user_live daolive = new DAL.user_live(); DAL.user_jjfp daojjfp = new DAL.user_jjfp(); DAL.qiandao daoqiandao = new DAL.qiandao(); DAL.duihuanma daodhm = new DAL.duihuanma(); DAL.user_Goods_lb daolb = new DAL.user_Goods_lb(); DAL.user_zzjf daozzjf = new DAL.user_zzjf(); DAL.user_zzjf_log daozzjflog = new DAL.user_zzjf_log(); DAL.business_info daobusiness = new DAL.business_info(); DAL.freighttemplate daoftem = new DAL.freighttemplate(); DAL.freighttemplate_freight daofreight = new DAL.freighttemplate_freight(); DAL.freighttemplate_free daofree = new DAL.freighttemplate_free(); public void ProcessRequest(HttpContext context) { String strData = ""; try { if (context.Request.QueryString.Count > 0) { foreach (var key in context.Request.QueryString.Keys) { strData += "&" + key + "=" + context.Request.QueryString[key.ToString()].ToString(); } } if (context.Request.Form.Count > 0) { foreach (var key in context.Request.Form.Keys) { strData += "&" + key + ":" + context.Request.Form[key.ToString()].ToString(); } } } catch (Exception err) { Model.User_Errlog mo = new Model.User_Errlog(); mo.DLID = 0; mo.ErrType = "xapiajax0"; mo.addtime = DateTime.Now; mo.ErrBody = strData; mo.ErrBody2 = err.ToString(); new DAL.User_Errlog().Add(mo); } string data = "{\"status\":0}"; try { string hostname = context.Request.Url.Host; //context.Response.ContentType = "text/plain"; //context.Response.ContentType = "application/json"; //context.Response.Cache.SetCacheability(HttpCacheability.NoCache); /*using (var reader = new System.IO.StreamReader(context.Request.InputStream)) { String xmlData = reader.ReadToEnd(); if (!string.IsNullOrEmpty(xmlData)) { Mtxfw.Utility.Common.WriteHtml("/weixin/action.txt", context.Request["action"] + "|" + xmlData); } }*/ //Mtxfw.Utility.Common.WriteHtml("/weixin/action.txt", context.Request["action"]); bool ifb = true; if (!String.IsNullOrEmpty(context.Request["userId"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["userId"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["LoginId"])) { if (context.Request["LoginId"].ToString().Length != 36) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["t"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["t"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["yqm"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["yqm"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["id"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["id"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["viewId"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["viewId"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["tguid"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["tguid"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["poid"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["poid"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["ptgroup"])) { if (!System.Text.RegularExpressions.Regex.IsMatch(context.Request["ptgroup"].ToString(), @"^-?\d+$")) { ifb = false; } } if (!String.IsNullOrEmpty(context.Request["CartId"])) { if (context.Request["CartId"].ToString().Length != 36) { ifb = false; } } /*Model.User_Errlog mo = new Model.User_Errlog(); mo.DLID = 0; mo.ErrType = Mtxfw.Utility.Common.GetIP; mo.addtime = DateTime.Now; mo.ErrBody = strData; mo.ErrBody2 = (context.Request["action"] != null? context.Request["action"].ToString() : "") + strhttp; new DAL.User_Errlog().Add(mo);*/ if (ifb) { //方式 switch (context.Request["action"]) { case "sendphonecode": data = sendphonecode(context); break; case "sendphonecode0": data = sendphonecode0(context); break; case "sendphonecode1": data = sendphonecode1(context); break; case "sendphonecode2": data = sendphonecode2(context); break; case "getregisterdata": data = getregisterdata(context); break; case "register": data = register(context); break; case "checkphone": data = checkphone(context); break; case "checkyqm": data = checkyqm(context); break; case "login": data = login(context); break; case "onLogin": data = onLogin(context); break; case "getopenid": data = getopenid(context); break; case "updateWxUserInfo": data = updateWxUserInfo(context); break; case "updateWxPhone": data = updateWxPhone(context); break; case "updatetgid": data = updatetgid(context); break; case "logout": data = logout(context); break; case "updateonline": data = updateonline(context); break; case "forgetPassword": data = forgetPassword(context); break; case "uploadtempImage": data = uploadtempImage(context); break; case "uploadImage": data = uploadImage(context); break; case "uploadFile": data = uploadFile(context); break; case "getuserinfo": data = getuserinfo(context); break; case "updateUserInfo2": data = updateUserInfo2(context); break; case "updateBankInfo": data = updateBankInfo(context); break; case "updatealipay": data = updatealipay(context); break; case "updateweixinpay": data = updateweixinpay(context); break; case "getwxphone": data = getwxphone(context); break; case "bindphone": data = bindphone(context); break; case "unbindphone": data = unbindphone(context); break; case "getbusinessinfo": data = getbusinessinfo(context); break; case "updatebusinessinfo": data = updatebusinessinfo(context); break; case "appupdatebusiness": data = appupdatebusiness(context); break; case "getbusinessinfo0": data = getbusinessinfo0(context); break; case "updatebusinessinfo0": data = updatebusinessinfo0(context); break; case "getsysmsglist": data = getsysmsglist(context); break; case "getnewslist": data = getnewslist(context); break; case "getarticlelist": data = getarticlelist(context); break; case "getvideolist": data = getvideolist(context); break; case "kvideo": data = kvideo(context); break; case "getftsclist": data = getftsclist(context); break; case "getjkzslist": data = getjkzslist(context); break; case "getxsxtlist": data = getxsxtlist(context); break; case "getnewdetail": data = getnewdetail(context); break; case "sendmsg": data = sendmsg(context); break; case "getchatlist": data = getchatlist(context); break; case "delchat": data = delchat(context); break; case "getvipdata": data = getvipdata(context); break; case "gmvip": data = gmvip(context); break; case "getdhmdata": data = getdhmdata(context); break; case "dhvip": data = dhvip(context); break; case "SetAutoHongBao": data = SetAutoHongBao(context); break; case "ononekey": data = ononekey(context); break; case "updateonekey": data = updateonekey(context); break; case "getcoupondata": data = getcoupondata(context); break; case "gmcoupon": data = gmcoupon(context); break; case "getbilllist": data = getbilllist(context); break; case "getzzjfdata": data = getzzjfdata(context); break; case "getzzjf_log": data = getzzjf_log(context); break; case "getqwzzjf_log": data = getqwzzjf_log(context); break; case "qymczzjf": data = qymczzjf(context); break; case "getmyincome": data = getmyincome(context); break; case "getjianjinlist": data = getjianjinlist(context); break; case "getjianjinlist0": data = getjianjinlist0(context); break; case "getbilltj": data = getbilltj(context); break; case "getBusinessdata": data = getBusinessdata(context); break; case "getbusinessview": data = getbusinessview(context); break; case "getindexdata": data = getindexdata(context); break; case "getshopdata": data = getshopdata(context); break; case "getothershopdata": data = getothershopdata(context); break; case "getothershopdata0": data = getothershopdata0(context); break; case "getmydata": data = getmydata(context); break; case "getPaypushdata": data = getPaypushdata(context); break; case "getPaypushdata0": data = getPaypushdata0(context); break; case "getmybusinessdata": data = getmybusinessdata(context); break; case "getmybusiness_smlog": data = getmybusiness_smlog(context); break; case "updatePaypush": data = updatePaypush(context); break; case "getmybusinessdata0": data = getmybusinessdata0(context); break; case "getmyproducts": data = getmyproducts(context); break; case "getqiandao": data = getqiandao(context); break; case "qiandao": data = qiandao(context); break; case "getmytgm": data = getmytgm(context); break; case "appdeclaration": data = appdeclaration(context); break; case "kttgy": data = kttgy(context); break; case "getkttgylist": data = getkttgylist(context); break; case "getordersinfo": data = getordersinfo(context); break; case "product_post": data = product_post(context); break; case "getproductsinfo": data = getproductsinfo(context); break; case "addfavorite": data = addfavorite(context); break; case "getmyfavorite": data = getmyfavorite(context); break; case "delfavorite": data = delfavorite(context); break; case "chongzhi": data = chongzhi(context); break; case "getshopcategory": data = getshopcategory(context); break; case "getwxshoplist": data = getwxshoplist(context); break; case "getshopsearch": data = getshopsearch(context); break; case "getshopview": data = getshopview(context); break; case "addcart": data = addcart(context); break; case "getshopcart": data = getshopcart(context); break; case "updatecart": data = updatecart(context); break; case "updateshopcart": data = updateshopcart(context); break; case "delshopcart": data = delshopcart(context); break; case "getshopcart2": data = getshopcart2(context); break; case "qygm": data = qygm(context); break; case "getyunfei": data = getyunfei(context); break; case "getpaydata": data = getpaydata(context); break; case "getIFPayed": data = getIFPayed(context); break; case "zhuanzhang": data = zhuanzhang(context); break; case "zhuanhuan": data = zhuanhuan(context); break; case "GetUserName2": data = GetUserName2(context); break; case "tixian": data = tixian(context); break; case "getzhuanzhanglist": data = getzhuanzhanglist(context); break; case "getzhuanhuanlist": data = getzhuanhuanlist(context); break; case "getgmviplist": data = getgmviplist(context); break; case "getgmcouponlist": data = getgmcouponlist(context); break; case "getchongzhilist": data = getchongzhilist(context); break; case "gettixianlist": data = gettixianlist(context); break; case "getguquanzhlist": data = getguquanzhlist(context); break; case "getmy_Recast": data = getmy_Recast(context); break; case "gethongbao": data = gethongbao(context); break; case "LQHongBao": data = LQHongBao(context); break; case "IFZJLQHongBao": data = IFZJLQHongBao(context); break; case "gethongbaodetails": data = gethongbaodetails(context); break; case "getmydhm": data = getmydhm(context); break; case "getmyfriendlist": data = getmyfriendlist(context); break; case "getmessagelist": data = getmessagelist(context); break; case "setToRead": data = setToRead(context); break; case "sendmessage": data = sendmessage(context); break; case "getorderslist": data = getorderslist(context); break; case "payorder": data = payorder(context); break; case "qyshorder": data = qyshorder(context); break; case "kdchaxun": data = kdchaxun(context); break; case "getAddress": data = getAddress(context); break; case "getZTAddress": data = getZTAddress(context); break; case "setDefaultAddress": data = setDefaultAddress(context); break; case "addweixinaddress": data = addweixinaddress(context); break; case "deleteAddress": data = deleteAddress(context); break; case "addAddress": data = addAddress(context); break; case "updateAddress": data = updateAddress(context); break; case "DeleteOrder": data = DeleteOrder(context); break; case "CancelOrder": data = CancelOrder(context); break; case "CancelOrderPay": data = CancelOrderPay(context); break; case "editpwd": data = editpwd(context); break; case "editpwd2": data = editpwd2(context); break; case "getServerMsg": data = getServerMsg(context); break; case "getxieyi": data = getxieyi(context); break; case "getmynetmap": data = getmynetmap(context); break; case "getmynetmap2": data = getmynetmap2(context); break; case "getyjpm": data = getyjpm(context); break; case "checkcode": data = checkcode(context); break; case "checkpwd2": data = checkpwd2(context); break; } if (context.Request["action"].ToString() == "getothershopdata") { Mtxfw.Utility.Common.WriteHtml("/weixin/apiajax.txt", data); } } Utility.Common.WriteJson(context, data); } catch (Exception err) { Logger.Singleton.Error(err.Message); if (strData.Length > 8000) { strData = strData.Substring(0, 8000); } Model.User_Errlog mo = new Model.User_Errlog(); mo.DLID = 0; mo.ErrType = "xapiajax"; mo.addtime = DateTime.Now; mo.ErrBody = strData; mo.ErrBody2 = err.ToString(); new DAL.User_Errlog().Add(mo); } } #region //发送手机验证码----------------------------------------------------------------------------------------- /// /// 发送手机验证码 /// protected string sendphonecode(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString().Trim()); } if (!String.IsNullOrEmpty(context.Request["phone"]) && !String.IsNullOrEmpty(context.Request["yzcodeid"]) && !String.IsNullOrEmpty(context.Request["code"])) { string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString()).Trim(); string yzcodeid = HttpUtility.UrlDecode(context.Request["yzcodeid"].ToString()); string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); bool b = true; if (config.FHEnable8 == "1") { b = false; data = "{\"status\":0,\"msg\":\"暂时不能发送短信!\"}"; } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect cell phone number format!" : "手机号码格式填写不正确!") + "\"}"; } } if (b) { if (yzcodeid.Length != 36) { b = false; data = "{\"status\":0,\"msg\":\"验证参数错误!\"}"; } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(code, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"图形验证码填写不正确!\"}"; } } if (b) { if (new DAL.user_code().GetCount("utype=0 and YZID='" + yzcodeid + "' and YZM='" + code + "'") > 0) { if (new DAL.user_code().GetCount("utype=0 and YZID='" + yzcodeid + "' and YZM='" + code + "' And DateDiff(mi,addtime,getdate())>3") > 0) { b = false; data = "{\"status\":0,\"msg\":\"图形验证码已失效!\"}"; } } else { b = false; data = "{\"status\":0,\"msg\":\"图形验证码错误!\"}"; } } if (b) { if (!new DAL.user_info().IsExists(phone,gtype)) { if (new DAL.user_YZMs().GetCount("utype=0 And phone='" + phone + "' And DateDiff(mi,addtime,getdate())<2") == 0) { string strIp = Mtxfw.Utility.Common.GetIP; if (new DAL.user_YZMs().GetCount("utype=0 And ip='" + strIp + "' And DateDiff(dy,addtime,getdate())=0") < 100) { if (new DAL.user_YZMs().GetCount("utype=0 And phone='" + phone + "' And DateDiff(dy,addtime,getdate())=0") < 30) { string strYZM = new CheckCode().RandNum(4); string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码30分钟内有效,请及时验证!【太极拼】"; try { Model.user_YZMs mymodel = new Model.user_YZMs(); mymodel.YZID = Guid.NewGuid().ToString(); mymodel.phone = phone; mymodel.YZM = strYZM; mymodel.ip = strIp; mymodel.AddTime = DateTime.Now; mymodel.utype = 0; new DAL.user_YZMs().Add(mymodel); Mtxfw.Utility.Common.sendsms(phone, "2537210", strYZM, config); //Mtxfw.Utility.Common.sendsms(phone, strconent); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Send success!" : "发送成功!") + "\",\"yzid\":\"" + mymodel.YZID + "\"}"; } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/sendphonecode.txt", err.ToString()); data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Error in sending verification code!" : "发送验证码出现错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Too frequent operation 2!" : "操作太频繁2!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Too frequent operation 2!" : "操作太频繁1!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Too frequent operation!" : "操作太频繁!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"此手机号码已经注册过!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数为空!") + "\"}"; } return data; } /// /// 发送手机验证码 /// protected string sendphonecode0(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString().Trim()); } if (!String.IsNullOrEmpty(context.Request["username"]) && !String.IsNullOrEmpty(context.Request["phone"])) { string username = HttpUtility.UrlDecode(context.Request["username"].ToString()); string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString()); bool b = true; if (config.FHEnable8 == "1") { b = false; data = "{\"status\":0,\"msg\":\"暂时不能发送短信!\"}"; } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect cell phone number format!" : "手机号码格式填写不正确!") + "\"}"; } } if (b) { Mtxfw.Model.user_info umodel = new DAL.user_info().GetModel(username, phone, gtype); if (umodel != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = umodel.PhoneTime.AddMinutes(2); if (dt1 > dt2) { bool bt = false; if (umodel.PhoneTime != null) { if (umodel.PhoneTime.ToString() != "") { dt2 = umodel.PhoneTime.AddDays(1); if (dt1 < dt2) { bt = true; } } } if (umodel.PhoneCount < 30 || (umodel.PhoneCount >= 30 && !bt)) { string strYZM = new CheckCode().RandNum(4); new DAL.user_info().UpdatePhoneTime(strYZM, DateTime.Now, umodel.Id); string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码30分钟内有效,请及时验证!【太极拼】";//【视通国际】 if (e == 1) { strconent = "Hello! Your phone verification code is " + strYZM + ". This verification code is valid in 30 minutes. Please verify it in time!【STTVC】"; } try { Mtxfw.Utility.Common.sendsms(umodel.Phone, "2537210", strYZM, config); //Mtxfw.Utility.Common.sendsms(umodel.Phone, strconent); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Send success!" : "发送成功!") + "\"}"; } catch { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Error sending verification code!" : "发送验证码出现错误!") + "\"}"; } } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You have sent more than 30 times, please try again tomorrow!" : "您已经发送超过30次了,请明天再试吧!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Please do it again in 2 minutes!" : "请您在2分钟后再操作!") + "\"}"; } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "This cell phone number does not exist!" : "此手机号码不存在!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数为空!") + "\"}"; } return data; } /// /// 发送手机验证码 /// protected string sendphonecode1(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString().Trim()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = context.Request["LoginId"].ToString(); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { bool b = true; if (config.FHEnable8 == "1") { b = false; data = "{\"status\":0,\"msg\":\"暂时不能发送短信!\"}"; } if (b) { if (umodel.LoginId2 == LoginId) { DateTime dt1 = DateTime.Now; DateTime dt2 = umodel.PhoneTime.AddMinutes(2); if (dt1 > dt2) { bool bt = false; if (umodel.PhoneTime != null) { if (umodel.PhoneTime.ToString() != "") { dt2 = umodel.PhoneTime.AddDays(1); if (dt1 < dt2) { bt = true; } } } if (umodel.PhoneCount < 30 || (umodel.PhoneCount >= 30 && !bt)) { string strYZM = new CheckCode().RandNum(4); new DAL.user_info().UpdatePhoneTime(strYZM, DateTime.Now, umodel.Id); string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码30分钟内有效,请及时验证!【太极拼】";//【视通国际】 if (e == 1) { strconent = "Hello! Your phone verification code is " + strYZM + ". This verification code is valid in 30 minutes. Please verify it in time!【STTVC】"; } try { Mtxfw.Utility.Common.sendsms(umodel.Phone, "2537210", strYZM, config); //Mtxfw.Utility.Common.sendsms(umodel.Phone, strconent); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Send success!" : "发送成功!") + "\"}"; } catch { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Error sending verification code!" : "发送验证码出现错误!") + "\"}"; } } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You have sent more than 30 times, please try again tomorrow!" : "您已经发送超过30次了,请明天再试吧!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Please do it again in 2 minutes!" : "请您在2分钟后再操作!") + "\"}"; return data; } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Wrong parameter!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数为空!") + "\"}"; } return data; } /// /// 发送手机验证码 /// protected string sendphonecode2(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString().Trim()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = context.Request["LoginId"].ToString(); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { bool b = true; if (config.FHEnable8 == "1") { b = false; data = "{\"status\":0,\"msg\":\"暂时不能发送短信!\"}"; } if (b) { if (umodel.LoginId2 == LoginId) { if (!String.IsNullOrEmpty(context.Request["phone"])) { string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString()).Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect cell phone number format!" : "手机号码格式填写不正确!") + "\"}"; } if (b) { DateTime dt1 = DateTime.Now; DateTime dt2 = umodel.PhoneTime.AddMinutes(2); if (dt1 > dt2) { bool bt = false; if (umodel.PhoneTime != null) { if (umodel.PhoneTime.ToString() != "") { dt2 = umodel.PhoneTime.AddDays(1); if (dt1 < dt2) { bt = true; } } } if (umodel.PhoneCount < 30 || (umodel.PhoneCount >= 30 && !bt)) { string strYZM = new CheckCode().RandNum(4); new DAL.user_info().UpdatePhoneTime(strYZM, DateTime.Now, umodel.Id); string strconent = "您好!您的手机验证码为" + strYZM + ",此验证码30分钟内有效,请及时验证!【太极拼】";//【视通国际】 if (e == 1) { strconent = "Hello! Your phone verification code is " + strYZM + ". This verification code is valid in 30 minutes. Please verify it in time!【STTVC】"; } try { Mtxfw.Utility.Common.sendsms(phone, "2537210", strYZM, config); //Mtxfw.Utility.Common.sendsms(phone, strconent); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Send success!" : "发送成功!") + "\"}"; } catch { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Error sending verification code!" : "发送验证码出现错误!") + "\"}"; } } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You have sent more than 30 times, please try again tomorrow!" : "您已经发送超过30次了,请明天再试吧!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Please do it again in 2 minutes!" : "请您在2分钟后再操作!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Cell phone number can not be empty!" : "手机号码不能为空!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Wrong parameter!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数为空!") + "\"}"; } return data; } #endregion #region 获取注册数据 /// /// 获取注册数据 /// /// protected string getregisterdata(HttpContext context) { string data = "{\"status\":0}"; string strrealname = ""; bool b = true; if (!String.IsNullOrEmpty(context.Request["yqm"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["yqm"].ToString(), @"^-?\d+$")) { int yqm = Convert.ToInt32(context.Request["yqm"]); int UserId = Mtxfw.Utility.Security.decrypt(yqm); SqlDataReader dr = daoUser.GetUserName(gtype, UserId); if (dr.Read()) { if (dr.HasRows) { strrealname = dr["realname"].ToString(); if (strrealname == "") { strrealname = dr["ncname"].ToString(); } if (strrealname == "") { strrealname = dr["username"].ToString(); } } else { b = false; data = "{\"status\":0,\"msg\":\"邀请码不存在!\"}"; } } dr.Close(); } } if (b) { if (!String.IsNullOrEmpty(context.Request["yzid"])) { string yzid = HttpUtility.UrlDecode(context.Request["yzid"].ToString()); new DAL.user_code().Delete(yzid); } string strNum = Mtxfw.Utility.Common.RandNum(4); string strIP = ""; Model.user_code mymodel = new Model.user_code(); mymodel.YZID = Guid.NewGuid().ToString(); mymodel.YZM = strNum; mymodel.ip = strIP; mymodel.AddTime = DateTime.Now; mymodel.utype = 0; new DAL.user_code().Add(mymodel); string yzcode = Mtxfw.Utility.Security.EncryptString(strNum).Replace("+", "_"); data = "{\"status\":1,\"name\":\"" + strrealname + "\",\"yzid\":\"" + mymodel.YZID + "\",\"yzcode\":\"" + yzcode + "\",\"FHEnable4\":\"" + config.FHEnable4 + "\"}"; } return data; } #endregion #region //注册会员----------------------------------------------------------------------------------------- /// /// 注册会员 /// protected string register(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString().Trim()); } if (!String.IsNullOrEmpty(context.Request["utype"]) && !String.IsNullOrEmpty(context.Request["yqm"]) && !String.IsNullOrEmpty(context.Request["realname"]) && !String.IsNullOrEmpty(context.Request["phone"]))// && !String.IsNullOrEmpty(context.Request["code"]) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["yqm"].ToString(), @"^-?\d+$")) { int utype = Convert.ToInt32(context.Request["utype"].ToString()); string invoicebody = "", strgoods = ""; int invoice = 0; string realname = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["realname"].ToString())); string phone = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["phone"].ToString())); string pwd = "", pwd0 = ""; string yqm = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["yqm"].ToString())); string CompanyName = ""; string CompanyNumber = ""; string CompanyCert = ""; string CompanyPic = ""; string CompanyProvince = ""; string CompanyCity = ""; string CompanyCounty = ""; string Companyaddress = ""; string Companylatitude = ""; string Companylongitude = ""; bool b = true; if (!String.IsNullOrEmpty(context.Request["pwd"])) { pwd = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["pwd"].ToString())); } else { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect cell phone number format!" : "登录密码不能为空!") + "\"}"; } if (!String.IsNullOrEmpty(context.Request["pwd0"])) { pwd0 = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["pwd0"].ToString())); } else { pwd0 = pwd; } int ifydl = 0; if (!String.IsNullOrEmpty(context.Request["ifydl"])) { ifydl = Convert.ToInt32(context.Request["ifydl"].ToString()); } string password = pwd; string password2 = pwd0; string sfz = "", UserPic = ""; string Province = ""; string City = "", County = ""; string strmailingaddress = ""; string bankaddress = ""; DateTime dt = DateTime.Now; if (!System.Text.RegularExpressions.Regex.IsMatch(realname, @"^[\u4e00-\u9fa5a-zA-Z]+$")) { b = false; data = "{\"status\":0,\"msg\":\"真实姓名填写不正确,只能输入中文和字母!\"}"; } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") || phone.Length != 11) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect cell phone number format!" : "手机号码格式填写不正确!") + "\"}"; } } if (b) { if (new DAL.user_info().IsExists(phone, gtype)) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The mobile phone number is occupied by other users!" : "手机号码被其它用户占用!") + "\"}"; } } if (config.FHEnable4 == "0") { if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (b) { if (new DAL.user_YZMs().GetCount("utype=0 And phone='" + phone + "' And YZM='" + code + "'") == 0) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is incorrect!" : "手机验证码不正确!") + "\"}"; } else { if (new DAL.user_YZMs().GetCount("utype=0 And phone='" + phone + "' And YZM='" + code + "' And DateDiff(mi,addtime,getdate())<30") == 0) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code has failed!" : "手机验证码已经失效!") + "\"}"; } } } } } else { if (!String.IsNullOrEmpty(context.Request.Form["code"]) && !String.IsNullOrEmpty(context.Request["yzcodeid"])) { string code = HttpUtility.UrlDecode(context.Request.Form["code"].ToString()); string yzcodeid = HttpUtility.UrlDecode(context.Request["yzcodeid"].ToString()); if (b) { if (yzcodeid.Length != 36) { b = false; data = "{\"status\":0,\"msg\":\"验证参数错误!\"}"; } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(code, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"图形验证码填写不正确!\"}"; } } if (b) { if (new DAL.user_code().GetCount("utype=0 and YZID='" + yzcodeid + "' and YZM='" + code + "'") > 0) { if (new DAL.user_code().GetCount("utype=0 and YZID='" + yzcodeid + "' and YZM='" + code + "' And DateDiff(mi,addtime,getdate())>3") > 0) { b = false; data = "{\"status\":0,\"msg\":\"图形验证码已失效!\"}"; } else { new DAL.user_code().Delete(yzcodeid); } } else { b = false; data = "{\"status\":0,\"msg\":\"图形验证码错误!\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"图形验证码不能为空!\"}"; } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(password, @"^[A-Za-z0-9_]+$") || password.Length < 6 || password.Length > 16) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The password is not entered correctly. The password is composed of 6-16 digits, letters and underlines!" : "登录密码输入不正确,密码由6-16位数字、字母、下划线组成!") + "\"}"; } } if (b) { if (password2 != "") { if (!System.Text.RegularExpressions.Regex.IsMatch(password2, @"^[A-Za-z0-9_]+$") || password2.Length < 6 || password2.Length > 16) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The password is not entered correctly. The password is composed of 6-16 digits, letters and underlines!" : "安全密码输入不正确,密码由6-16位数字、字母、下划线组成!") + "\"}"; } } } int SuperiorsID = 0, uLevel0 = 0, ContactID = 0, uLevel1 = 0, uLevel5 = 0, YContactID = 0; string ContactIDS = "", SuperiorsIDS = "", strContactID = ""; string strDLRememberID = ""; if (b) { if (yqm != "") { YContactID = Mtxfw.Utility.Security.decrypt(Convert.ToInt32(yqm)); } else { YContactID = 0; } Model.user_info umodel = daoUser.GetModel(YContactID); if (umodel != null) { strContactID = umodel.UserName; ContactID = umodel.Id; SuperiorsID = umodel.Id; ContactIDS = umodel.ContactIDS; SuperiorsIDS = umodel.ContactIDS; uLevel1 = umodel.uLevel1; uLevel0 = umodel.uLevel1; } else { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The invitation code does not exist!" : "邀请码不存在!") + "\"}"; } } if (b) { if (utype > 0) { if (!String.IsNullOrEmpty(context.Request["CompanyName"]) && !String.IsNullOrEmpty(context.Request["CompanyNumber"]) && !String.IsNullOrEmpty(context.Request["CompanyCert"]) && !String.IsNullOrEmpty(context.Request["CompanyPic"]) && !String.IsNullOrEmpty(context.Request["CompanyProvince"]) && !String.IsNullOrEmpty(context.Request["CompanyCity"]) && !String.IsNullOrEmpty(context.Request["Companyaddress"]) && !String.IsNullOrEmpty(context.Request["Companylatitude"]) && !String.IsNullOrEmpty(context.Request["Companylongitude"])) { CompanyName = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyName"].ToString())); CompanyNumber = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyNumber"].ToString())); CompanyCert = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyCert"].ToString())); CompanyPic = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyPic"].ToString())); CompanyProvince = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyProvince"].ToString())); CompanyCity = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyCity"].ToString())); if (!String.IsNullOrEmpty(context.Request["CompanyCounty"])) { CompanyCounty = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyCounty"].ToString())); } Companyaddress = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Companyaddress"].ToString())); Companylatitude = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Companylatitude"].ToString())); Companylongitude = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Companylongitude"].ToString())); UserPic = CompanyPic; } else { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The invitation code does not exist2!" : "参数为空2!") + "\"}"; } } } if (b) { Double umoney20 = 0; Double umoney21 = umoney20; string openid = "", session_key = ""; if (!String.IsNullOrEmpty(context.Request["lcode"])) { string lcode = HttpUtility.UrlDecode(context.Request["lcode"].ToString()); WXcode2Session ac = getcode2Session(lcode, config.webXAppID, config.webXAppSecret); openid = ac.openid; session_key = ac.session_key; } string strMemberCard = "hz" + (daoUser.GetMaxMemberCard(gtype) + 1).ToString(); Mtxfw.Model.user_info model = new Mtxfw.Model.user_info(); model.MemberCard = strMemberCard; model.UserName = phone; model.Password = Mtxfw.Utility.Security.EncryptString(password); model.Password2 = Mtxfw.Utility.Security.EncryptString(password2); model.RealName = realname; model.NCName = ""; model.UserPic = ""; model.Sex = ""; model.SFZ = sfz; model.CSDate = ""; model.Mobile = ""; model.Phone = phone; model.Email = ""; model.Province = Province; model.City = City; model.County = County; model.MailingAddress = strmailingaddress; model.PostalCode = bankaddress; model.QQ = ""; model.CompanyName = CompanyName; model.CompanyNumber = CompanyNumber; model.CompanyCert = CompanyCert; model.CompanyTel = ""; model.CompanyPic = CompanyPic; model.CompanyProvince = CompanyProvince; model.CompanyCity = CompanyCity; model.CompanyCounty = CompanyCounty; model.Companyaddress = Companyaddress; model.Companylatitude = (Companylatitude != "" ? Convert.ToDecimal(Companylatitude) : 0); model.Companylongitude = (Companylongitude != "" ? Convert.ToDecimal(Companylongitude) : 0); model.Companycontent = ""; model.ProductName = strgoods; model.UserState = "正常";//(hytype == 2 ? "未审核" : "正常") model.RegTime = DateTime.Now; model.RegTime2 = DateTime.Now; /*SqlDataReader Dr = daoUser.GetUserId(Text_RememberID.Text); if (Dr.Read()) { RememberID = int.Parse(Dr["Id"].ToString()); RememberIDS = Dr["RememberIDS"].ToString(); } Dr.Close();*/ model.RememberID = 0; model.RememberIDS = ""; model.SuperiorsID = SuperiorsID; if (SuperiorsIDS == "") { model.SuperiorsIDS = "," + SuperiorsID.ToString() + ","; } else { model.SuperiorsIDS = SuperiorsIDS + SuperiorsID.ToString() + ","; } model.ContactID = ContactID; if (ContactIDS == "") { model.ContactIDS = "," + ContactID.ToString() + ","; } else { model.ContactIDS = ContactIDS + ContactID.ToString() + ","; } int DLRememberID = 0; string DLRememberIDS = ""; SqlDataReader Dr = daoUser.GetUserId(gtype, strDLRememberID); if (Dr.Read()) { DLRememberID = int.Parse(Dr["Id"].ToString()); DLRememberIDS = Dr["DLRememberIDS"].ToString(); } Dr.Close(); model.DLRememberID = DLRememberID; if (DLRememberIDS == "") { model.DLRememberIDS = "," + DLRememberID.ToString() + ","; } else { model.DLRememberIDS = DLRememberIDS + DLRememberID.ToString() + ","; } model.SJRememberID = 0; model.SJRememberIDS = ""; model.umoney20 = umoney20; model.umoney21 = umoney21; model.uLevel = 0; model.uLevel0 = (uLevel0 + 1); model.uLevel1 = (uLevel1 + 1); model.uLevel3 = 0; model.uLevel5 = uLevel5; model.utype = utype.ToString(); model.uutype = "0"; model.openid = ""; model.openid0 = ""; model.openid1 = ""; model.opentype = 0; model.opentype2 = invoice; model.session_key = ""; model.unionid = ""; model.refresh_token = ""; model.refresh_token_time = ""; model.IFUpUserName = 0; model.gtype = gtype; model.IP = Mtxfw.Utility.Common.GetIP; model.Id = daoUser.Add(model); daoUser.UpdateuLevel("IFPhone", 1, model.Id); daojjfp.UpdateBcount("count1", 1, 0, 0); string strdata = ""; if (ifydl == 0) { Mtxfw.Model.user_info umodel = daoUser.GetModel(model.Id); if (umodel != null) { string LoginId = Guid.NewGuid().ToString(); Model.User_OnLine lmodel = new Model.User_OnLine(); lmodel.SessionId = LoginId; lmodel.MemberId = umodel.Id; lmodel.DLID = 1; lmodel.ZDLID = 0; lmodel.GDID = 0; lmodel.FGSID = 0; lmodel.InTime = dt; lmodel.IsOnline = 1; lmodel.IP = Mtxfw.Utility.Common.GetIP; lmodel.MAC = ""; lmodel.UserType = 0; new DAL.User_OnLine().Add(lmodel); umodel.LoginId = LoginId; daoUser.UpdateLogins(lmodel.IP, LoginId, umodel.Id, 1); daoUser.UpdatePassword("session_key", session_key, umodel.Id); //umodel.openid = openid; strdata = ",\"userId\":\"" + umodel.Id + "\",\"LoginId\":\"" + umodel.LoginId + "\""; strdata += "," + returndata(umodel); } } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = 0; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "小程序注册会员,用户名:" + model.UserName + ",姓名:" + model.RealName + ",推荐人:" + strContactID; logmodel.UType = 1; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Registration is successful!" : "注册成功!") + "\"" + strdata + "}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Wrong parameter!" : "参数为空!") + "\"}"; } return data; } #endregion #region 判断手机号是否存在(前台注册) /// /// 判断手机号是否存在(前台注册) /// /// protected string checkphone(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["t"]) && !String.IsNullOrEmpty(context.Request["phone"])) { int t = Convert.ToInt32(context.Request["t"]); String phone = HttpUtility.UrlDecode(context.Request["phone"]); bool b = true; if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$")) { b = false; data = "{\"status\":0,\"msg\":\"手机号码格式填写不正确!\"}"; } if (b) { if (t == 0) { if (daoUser.IsExists2(phone, 0, gtype)) { data = "{\"status\":0,\"msg\":\"手机号码已经被注册!\"}"; } else { data = "{\"status\":1,\"msg\":\"手机号码可以注册!\"}"; } } else if (t == 1) { if (daoUser.IsExists2(phone, 0, gtype)) { string strrealname = ""; SqlDataReader dr = daoUser.GetUserId(gtype, phone); if (dr.Read()) { if (dr.HasRows) { strrealname = dr["realname"].ToString(); } } dr.Close(); data = "{\"status\":0,\"name\":\"" + strrealname + "\"}"; } else { data = "{\"status\":1,\"msg\":\"对方账号不存在!\"}"; } } } } else { data = "{\"status\":0,\"msg\":\"手机号不能为空!\"}"; } return data; } #endregion #region 判断邀请码是否存在(前台注册) /// /// 判断邀请码是否存在(前台注册) /// /// protected string checkyqm(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["yqm"])) { int yqm = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["yqm"])); int UserId = Mtxfw.Utility.Security.decrypt(yqm); bool b = true; string strrealname = ""; SqlDataReader dr = daoUser.GetUserName(gtype, UserId); if (dr.Read()) { if (dr.HasRows) { strrealname = dr["realname"].ToString(); } else { b = false; data = "{\"status\":0,\"msg\":\"邀请码不存在!\"}"; } } dr.Close(); if (b) { data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"手机号不能为空!\"}"; } return data; } #endregion #region //会员登录----------------------------------------------------------------------------------------- /// /// 会员登录 /// protected string login(HttpContext context) { string data = "{\"status\":0}"; int plat = 1, IFupdate = 0; string version = ""; if (!String.IsNullOrEmpty(context.Request["plat"])) { plat = Convert.ToInt32(context.Request["plat"].ToString()); } if (!String.IsNullOrEmpty(context.Request["version"])) { version = context.Request["version"].ToString().Trim(); } int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(context.Request["e"].ToString().Trim()); } } bool b = true; DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (version != "" && (plat == 0 || plat == 1 || plat == 2)) { string[] aversion = config.webQQ.Split(','); if (aversion.Length == 3) { if (aversion[plat] != "" && aversion[plat] != version) { IFupdate = 1; } } } if (b) { if (IFupdate == 1) { b = false; data = "{\"status\":0,\"msg\":\"有新的版本,您必须更新才能登录\",\"updatemsg\":\"" + config.webWeiXin + "\"}"; } } if (b) { if (config.CloseEnable == "1") { b = false; data = "{\"status\":0,\"msg\":\"" + config.CloseMsg + "\"}"; } } if (b) { string username = "", password = ""; string strdata = "\"CloseEnable\":\"" + config.CloseEnable + "\",\"CloseMsg\":\"" + config.CloseMsg + "\""; int t = 1; if (!String.IsNullOrEmpty(context.Request["t"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["t"].ToString(), @"^-?\d+$")) { t = Convert.ToInt32(context.Request["t"].ToString().Trim()); } } if (!String.IsNullOrEmpty(context.Request["username"]) && !String.IsNullOrEmpty(context.Request["password"])) { username = HttpUtility.UrlDecode(context.Request["username"].ToString()); password = HttpUtility.UrlDecode(context.Request["password"].ToString()); } else { b = false; if (e == 1) { data = "{\"status\":0,\"msg\":\"The user name or password can not be empty!\"}"; } else { if (t == 0) { data = "{\"status\":0,\"msg\":\"手机号码和验证码不能为空!\"}"; } else { data = "{\"status\":0,\"msg\":\"手机号码和登录密码不能为空!\"}"; } } } if (b) { if (username.Length > 20) { b = false; if (e == 1) { data = "{\"status\":0,\"msg\":\"The password is not entered correctly. The password is composed of 6-16 digits, letters and underscores!\"}"; } else { data = "{\"status\":0,\"msg\":\"手机号输入不正确!\"}"; } } } if (b) { if (t == 1) { if (!System.Text.RegularExpressions.Regex.IsMatch(password, @"^[A-Za-z0-9_]+$") || password.Length < 6 || password.Length > 16) { b = false; if (e == 1) { data = "{\"status\":0,\"msg\":\"The password is not entered correctly. The password is composed of 6-16 digits, letters and underscores!\"}"; } else { data = "{\"status\":0,\"msg\":\"密码输入不正确,密码由6-16位数字、字母、下划线组成!\"}"; } } } } if (b) { string openid = "", session_key = ""; if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); try { WXcode2Session ac = getcode2Session(code, config.webXAppID, config.webXAppSecret); openid = ac.openid; session_key = ac.session_key; } catch(Exception err) { Model.User_Errlog mo = new Model.User_Errlog(); mo.DLID = 0; mo.ErrType = "getcode2Sessionerr"; mo.addtime = DateTime.Now; mo.ErrBody = err.ToString(); mo.ErrBody2 = err.Message; new DAL.User_Errlog().Add(mo); } } if (t == 1) { string TXEnable = config.JJBTXEnable; if (TXEnable == "0") { DayOfWeek day = dt.DayOfWeek; string dayString = day.ToString().ToLower(); string HSJEnable = Mtxfw.Utility.Common.cweek(config.HSJEnable); if (config.HSJEnable.IndexOf(dayString) == -1) { TXEnable = "1"; } } int MemberId = 0; int IFStores = 0; int IFUpUserName = 0; int uutype = 0; string MemberCard = ""; string MemberJS = ""; string NCName = ""; string RealName = ""; string Phone = ""; string RealName2 = ""; string SFZ = ""; string Phone2 = ""; string PostalCode = ""; string ProductName = ""; string avatar = ""; string BBSConent = ""; string CompanyCert = ""; string gender = ""; string birthday = ""; int ContactID = 0; int IFBecomeBusiness = 0; Double umoney = 0.00; Double umoney20 = 0.00; Double umoney15 = 0.00; Double umoney22 = 0.00; Double umoney26 = 0.00; Double umoney28 = 0.00; Double umoney29 = 0.00; Double umoney30 = 0.00; Double umoney33 = 0.00; Double umoney39 = 0.00; int MemberuLevel = 0; int MemberuLevel2 = 0; int MemberuLevel3 = 0; int MemberuLevel4 = 0; int MemberuLevel8 = 0; int MemberuLevel14 = 0; int MemberuLevel16 = 0; int MemberuLevel20 = 0; int IFEditBank = 0; int IFPhone = 0; int ProductShipped = 0; if (daoUser.IsLoginWeb(gtype, username, Mtxfw.Utility.Security.EncryptString(password), ref MemberCard, ref MemberId, ref ContactID, ref IFStores, ref RealName, ref RealName2, ref Phone, ref Phone2, ref SFZ, ref BBSConent, ref CompanyCert, ref NCName, ref avatar, ref gender, ref birthday, ref IFUpUserName, ref IFBecomeBusiness, ref uutype, ref MemberJS, ref MemberuLevel, ref MemberuLevel2, ref MemberuLevel3, ref MemberuLevel4, ref MemberuLevel8, ref MemberuLevel14, ref MemberuLevel16, ref MemberuLevel20, ref ProductShipped, ref IFEditBank, ref IFPhone, ref umoney, ref umoney15, ref umoney20, ref umoney22, ref umoney26, ref umoney28, ref umoney29, ref umoney30, ref umoney33, ref umoney39)) { if (IFStores == 0) { if (IFBecomeBusiness == 0) { if (MemberuLevel8 == 0) { string latitude = "", longitude = ""; string IP = (MemberId == 8714 ? "223.104.162.201" : Mtxfw.Utility.Common.GetIP); string Country = ""; try { Mtxfw.Utility.IPScanner IPScanner = new Mtxfw.Utility.IPScanner(); IPScanner.IP = IP; IPScanner.DataPath = context.Server.MapPath("/App_Data/qqwry.dat"); IPScanner.IPLocation(); if (IPScanner.Country != null) { Country = IPScanner.Country; if (Country == "中国") { latitude = "39.915085"; longitude = "116.3683244"; } else { string stra = Country.Substring(0, 2); string provinceid = "", center = ""; DataSet ds = new DAL.province().GetList1("provinceid,center", "provincename like '%" + stra + "%'"); if (ds.Tables[0].Rows.Count > 0) { provinceid = ds.Tables[0].Rows[0]["provinceid"].ToString(); center = ds.Tables[0].Rows[0]["center"].ToString(); } ds.Clear(); if (provinceid != "") { DataSet ds0 = new DAL.city().GetList1("cityid,center", "provinceid='" + provinceid + "' and cityname like '%" + Country + "%'"); if (ds0.Tables[0].Rows.Count > 0) { center = ds0.Tables[0].Rows[0]["center"].ToString(); } ds0.Clear(); } if (center != "") { string[] acenter = center.Split(','); latitude = acenter[1]; longitude = acenter[0]; } } } if (MemberId == 8714) { Country = "浙江省温州市"; } } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/IPLocationerr0.txt", err.ToString()); } string LoginId = Guid.NewGuid().ToString(); Model.User_OnLine model = new Model.User_OnLine(); model.SessionId = LoginId; model.MemberId = MemberId; model.DLID = 1; model.ZDLID = 0; model.GDID = 0; model.FGSID = 0; model.InTime = dt; model.IsOnline = 1; model.IP = IP; model.MAC = Country; model.UserType = 0; new DAL.User_OnLine().Add(model); daoUser.UpdateLogins(model.IP, LoginId, MemberId, 1); if (openid != "") { daoUser.UpdatePassword("xopenid0", openid, MemberId); daoUser.UpdatePassword("session_key0", session_key, MemberId); } context.Session["MemberId"] = MemberId; context.Session["MemberName"] = username; context.Session["MemberNCName"] = NCName; context.Session["MemberIFStores"] = IFStores; context.Session["MemberuLevel"] = MemberuLevel; context.Session["gtype"] = gtype; strdata += ",\"userId\":\"" + MemberId + "\",\"LoginId\":\"" + LoginId + "\""; Mtxfw.Model.user_info umodel = daoUser.GetModel(MemberId); if (openid != "") { umodel.openid = openid; } strdata += "," + returndata(umodel); data = "{\"status\":1,\"latitude\":\"" + latitude + "\",\"longitude\":\"" + longitude + "\",\"msg\":\"" + (e == 1 ? "Entering the system..." : "登录成功!") + "\"," + strdata + "}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Your account can not be logged in!" : "您的账户已被封号!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Your account can not be logged in!" : "您的账户不能登录!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect user name or password!" : "您的账号不能在此登录!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect user name or password!" : "账号或密码错误!") + "\"}"; } else { Mtxfw.Model.user_info umodel = daoUser.GetModelbyPhone(username, gtype); if (umodel != null) { if (umodel.PhoneNumber.ToLower() != password) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } if (b) { DateTime dt1 = DateTime.Now; DateTime dt2 = umodel.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } if (b) { if (umodel.IFStores == 0) { if (umodel.IFBecomeBusiness == 0) { if (umodel.uLevel8 == 0) { string IP = (umodel.Id == 8714 ? "223.104.162.201" : Mtxfw.Utility.Common.GetIP); string Country = ""; try { Mtxfw.Utility.IPScanner IPScanner = new Mtxfw.Utility.IPScanner(); IPScanner.IP = IP; IPScanner.DataPath = context.Server.MapPath("/App_Data/qqwry.dat"); IPScanner.IPLocation(); if (IPScanner.Country != null) { Country = IPScanner.Country; } if (umodel.Id == 8714) { Country = "浙江省温州市"; } } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/IPLocationerr0.txt", err.ToString()); } string LoginId = Guid.NewGuid().ToString(); Model.User_OnLine model = new Model.User_OnLine(); model.SessionId = LoginId; model.MemberId = umodel.Id; model.DLID = 1; model.ZDLID = 0; model.GDID = 0; model.FGSID = 0; model.InTime = dt; model.IsOnline = 1; model.IP = IP; model.MAC = Country; model.UserType = 0; new DAL.User_OnLine().Add(model); umodel.LoginId = LoginId; daoUser.UpdateLogins(model.IP, LoginId, umodel.Id, 1); daoUser.UpdatePassword("session_key0", session_key, umodel.Id); umodel.openid = openid; strdata = ",\"userId\":\"" + umodel.Id + "\",\"LoginId\":\"" + umodel.LoginId + "\""; strdata += "," + returndata(umodel); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Entering the system..." : "登录成功!") + "\"" + strdata + "}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Your account can not be logged in!" : "您的账户已被封号!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Your account can not be logged in!" : "您的账户不能登录!") + "\"}"; } else data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect user name or password!" : "您的账号不能在此登录!") + "\"}"; } } } } } return data; } #endregion #region //微信一键登录----------------------------------------------------------------------------------------- /// /// 微信一键登录 /// protected string onLogin(HttpContext context) { string data = "{\"status\":0}"; bool b = true; string code = ""; if (!String.IsNullOrEmpty(context.Request["code"])) { code = HttpUtility.UrlDecode(context.Request["code"].ToString()); } else { b = false; data = "{\"status\":0,\"msg\":\"code不能为空!\"}"; } if (b) { string LoginId = ""; int userId = 0; string userinfo = ""; string TXEnable = config.JJBTXEnable; if (TXEnable == "0") { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); DayOfWeek day = dt.DayOfWeek; string dayString = day.ToString().ToLower(); string HSJEnable = Mtxfw.Utility.Common.cweek(config.HSJEnable); if (config.HSJEnable.IndexOf(dayString) == -1) { TXEnable = "1"; } } try { WXcode2Session ac = getcode2Session(code, config.webXAppID, config.webXAppSecret); if (daoUser.GetCount("openid='" + ac.openid + "'") > 0) { Mtxfw.Model.user_info umodel = daoUser.GetModelbyopenid(ac.openid, gtype); if (umodel != null) { LoginId = umodel.LoginId2; if (umodel.LoginId2 == "") { LoginId = Guid.NewGuid().ToString(); Model.User_OnLine omodel = new Model.User_OnLine(); omodel.SessionId = LoginId; omodel.MemberId = umodel.Id; omodel.DLID = 1; omodel.ZDLID = 0; omodel.GDID = 0; omodel.FGSID = 0; omodel.InTime = DateTime.Now; omodel.IsOnline = 1; omodel.IP = Mtxfw.Utility.Common.GetIP; omodel.MAC = ""; omodel.UserType = 0; new DAL.User_OnLine().Add(omodel); daoUser.UpdateLogins(omodel.IP, LoginId, umodel.Id, 1); } userId = umodel.Id; umodel.session_key0 = ac.session_key; daoUser.Update(umodel); if (!String.IsNullOrEmpty(context.Request["tguid"])) { string tguid = HttpUtility.UrlDecode(context.Request["tguid"].ToString()).Replace("id=", ""); int ContactID = Mtxfw.Utility.Security.decrypt(Convert.ToInt32(tguid)); if (umodel.ContactID == 68 && umodel.Id != 68 && ContactID != umodel.ContactID) { //Utility.Common.WriteHtml("/weixin/ContactID1.txt", tguid + "|" + ContactID); string ContactIDS = ""; int uLevel1 = 0; SqlDataReader dr = daoUser.GetUserName(gtype, ContactID); if (dr.HasRows) { if (dr.Read()) { ContactIDS = dr["ContactIDS"].ToString(); uLevel1 = Convert.ToInt32(dr["uLevel1"]); } } dr.Close(); umodel.ContactID = ContactID; if (ContactIDS == "") { umodel.ContactIDS = "," + ContactID.ToString() + ","; } else { umodel.ContactIDS = ContactIDS + ContactID.ToString() + ","; } daoUser.UpdateTJR(umodel.ContactID, umodel.ContactIDS, umodel.Id); daoUser.UpdateJDR(umodel.ContactID, umodel.ContactIDS, umodel.Id); umodel.uLevel0 = uLevel1; umodel.uLevel1 = uLevel1; daoUser.UpdateuLevel("uLevel1", uLevel1, umodel.Id); } } userinfo = "," + returndata(umodel); } } else { int ContactID = 0, uLevel0 = 1; string ContactIDS = "", strContactID = ""; if (!String.IsNullOrEmpty(context.Request["tguid"])) { string tguid = HttpUtility.UrlDecode(context.Request["tguid"].ToString()).Replace("id=", ""); ContactID = Mtxfw.Utility.Security.decrypt(Convert.ToInt32(tguid)); SqlDataReader dr = daoUser.GetUserName(gtype, ContactID); if (dr.HasRows) { if (dr.Read()) { ContactIDS = dr["SuperiorsIDS"].ToString(); strContactID = dr["UserName"].ToString(); uLevel0 = Convert.ToInt32(dr["uLevel0"]); } } dr.Close(); //Utility.Common.WriteHtml("/weixin/apiajax1.txt", tguid + "|" + ContactID + "|" + ContactIDS); } string strMemberCard = (daoUser.GetMaxMemberCard(gtype) + 1).ToString(); Mtxfw.Model.user_info model = new Mtxfw.Model.user_info(); model.MemberCard = "zh" + strMemberCard; string strUserName = Mtxfw.Utility.Common.RandNum(6).ToString().ToLower(); if (daoUser.IsExists(strUserName, gtype)) { strUserName = "zh" + strMemberCard; } model.UserName = strUserName; model.Password = Mtxfw.Utility.Security.EncryptString("111111"); model.Password2 = Mtxfw.Utility.Security.EncryptString("111111"); model.RealName = ""; model.NCName = ""; model.UserPic = ""; model.Sex = ""; model.SFZ = ""; model.Mobile = ""; model.Phone = ""; model.Email = ""; model.Province = ""; model.City = ""; model.County = ""; model.MailingAddress = ""; model.PostalCode = ""; model.QQ = ""; model.CompanyName = ""; model.CompanyNumber = ""; model.CompanyCert = ""; model.CompanyPic = ""; model.CompanyProvince = ""; model.CompanyCity = ""; model.CompanyCounty = ""; model.Companyaddress = ""; model.Companylatitude = 0; model.Companylongitude = 0; model.Companycontent = ""; model.ProductName = ""; model.UserState = "正常"; model.RegTime = DateTime.Now; model.RegTime2 = DateTime.Now; model.RememberID = 0; model.RememberIDS = ""; model.ContactID = ContactID; if (ContactIDS == "") { model.ContactIDS = "," + ContactID.ToString() + ","; } else { model.ContactIDS = ContactIDS + ContactID.ToString() + ","; } model.SuperiorsID = model.ContactID; model.SuperiorsIDS = model.ContactIDS; model.DLRememberID = 0; model.DLRememberIDS = ""; model.SJRememberID = 0; model.SJRememberIDS = ""; model.uLevel0 = uLevel0 + 1; model.uLevel1 = model.uLevel0; model.uLevel3 = 0; int uLevel5 = 0; model.uLevel5 = uLevel5; model.utype = "0"; model.uutype = "0"; model.openid = ac.openid; model.opentype = 4; model.opentype2 = 4; model.session_key = ac.session_key; model.unionid = ""; model.refresh_token = ""; model.refresh_token_time = DateTime.Now.ToString(); model.IFUpUserName = 1; model.gtype = gtype; model.Id = daoUser.Add(model); LoginId = Guid.NewGuid().ToString(); userId = model.Id; Model.User_OnLine omodel = new Model.User_OnLine(); omodel.SessionId = LoginId; omodel.MemberId = model.Id; omodel.DLID = 1; omodel.ZDLID = 0; omodel.GDID = 0; omodel.FGSID = 0; omodel.InTime = DateTime.Now; omodel.IsOnline = 1; omodel.IP = Mtxfw.Utility.Common.GetIP; omodel.MAC = ""; omodel.UserType = 0; new DAL.User_OnLine().Add(omodel); daoUser.UpdateLogins(omodel.IP, LoginId, model.Id, 1); Mtxfw.Model.user_info umodel = daoUser.GetModel(model.Id); userinfo = "," + returndata(umodel); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = 0; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "微信小程序注册会员,用户名:" + model.UserName + ",姓名:" + model.RealName + ",推荐人:" + strContactID; logmodel.UType = 1; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); } data = "{\"status\":1,\"msg\":\"登录成功!\",\"userId\":\"" + userId + "\",\"LoginId\":\"" + LoginId + "\"" + userinfo + "}"; } catch (Exception err) { b = false; Mtxfw.Utility.Common.WriteHtml("/weixin/code.txt", err.ToString()); //data = "{\"status\":0,\"msg\":\"code错误!\"}"; } } //Mtxfw.Utility.Common.WriteHtml("/weixin/apiajax0.txt", data); return data; } public object Fromcode2Session(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public WXcode2Session getcode2Session(string code, string appID, string appSecret) { WXcode2Session ac = null; string str = Mtxfw.Utility.Common.getPage2("https://api.weixin.qq.com/sns/jscode2session?appid=" + appID + "&secret=" + appSecret + "&js_code=" + code + "&grant_type=authorization_code", "", "utf-8"); /*Model.User_Errlog mo = new Model.User_Errlog(); mo.DLID = 0; mo.ErrType = "getcode2Session"; mo.addtime = DateTime.Now; mo.ErrBody = "appid=" + appID + "&secret=" + appSecret + "&js_code=" + code; mo.ErrBody2 = str; new DAL.User_Errlog().Add(mo);*/ //Mtxfw.Utility.Common.WriteHtml("/weixin/str.txt", str); if (str.IndexOf("openid") != -1) { ac = (WXcode2Session)Fromcode2Session(str); } return ac; } #endregion #region //获取openid----------------------------------------------------------------------------------------- /// /// 获取openid /// protected string getopenid(HttpContext context) { string data = "{\"status\":0}"; bool b = true; string code = ""; if (!String.IsNullOrEmpty(context.Request["code"])) { code = HttpUtility.UrlDecode(context.Request["code"].ToString()); } else { b = false; data = "{\"status\":0,\"msg\":\"code不能为空!\"}"; } if (b) { WXcode2Session ac = getcode2Session(code, config.webXAppID, config.webXAppSecret); if (ac != null) { b = false; data = "{\"status\":1,\"openid\":\"" + ac.openid + "\"}"; } else { b = false; data = "{\"status\":0,\"msg\":\"获取openid错误!\"}"; } } return data; } #endregion #region //更新微信会员信息----------------------------------------------------------------------------------------- /// /// 更新微信会员信息 /// protected string updateWxUserInfo(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string ncname = ""; if (!String.IsNullOrEmpty(context.Request["ncname"])) { ncname = HttpUtility.UrlDecode(context.Request["ncname"].ToString()); } string avatar = ""; if (!String.IsNullOrEmpty(context.Request["avatar"])) { avatar = HttpUtility.UrlDecode(context.Request["avatar"].ToString()); } string gender = ""; if (!String.IsNullOrEmpty(context.Request["gender"])) { gender = HttpUtility.UrlDecode(context.Request["gender"].ToString()); } string province = ""; if (!String.IsNullOrEmpty(context.Request["province"])) { province = HttpUtility.UrlDecode(context.Request["province"].ToString()); } string city = "", county = ""; if (!String.IsNullOrEmpty(context.Request["city"])) { city = HttpUtility.UrlDecode(context.Request["city"].ToString()); } if (!String.IsNullOrEmpty(context.Request["county"])) { county = HttpUtility.UrlDecode(context.Request["county"].ToString()); } bool b = true; if (b) { if (ncname == "" && avatar == "" && gender == "" && province == "" && city == "" && county == "") { b = false; data = "{\"status\":0,\"msg\":\"缺少参数!\"}"; } } if (b) { if (ncname == "微信用户") { Mtxfw.Utility.Common.WriteHtml("/weixin/avatar.txt", avatar); b = false; data = "{\"status\":0,\"msg\":\"获取失败!\"}"; } } if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { var filepath = "/Files/grimage/" + model.Id + "/"; //创建保存位置 if (!Directory.Exists(context.Server.MapPath(filepath))) { Directory.CreateDirectory(context.Server.MapPath(filepath)); } //写入文件 string filename = filepath + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg"; if (saveUserPic(filename, avatar, context)) { avatar = filename; } else { avatar = ""; } if (model.NCName != ncname && ncname != "") { model.NCName = ncname; new Mtxfw.DAL.user_info().UpdatePassword("EWMPic", "", model.Id); } if (model.UserPic != avatar && avatar != "") { model.UserPic = avatar; new Mtxfw.DAL.user_info().UpdatePassword("EWMPic", "", model.Id); } if (model.Sex == "" && gender != "") { model.Sex = gender; } if (model.Province == "" && province != "") { model.Province = province; } if (model.City == "" && city != "") { model.City = city; } if (model.County == "" && county != "") { model.County = county; } daoUser.Update(model); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = (model.Id == 10154 ? "119.39.248.32" : Mtxfw.Utility.Common.GetIP); logmodel.Body = "更新微信资料"; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"授权成功!\",\"ncname\":\"" + model.NCName + "\",\"avatar\":\"" + (model.UserPic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(model.UserPic, "100x100", "cut") : "") + "\"," + returndata(model) + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } protected bool saveUserPic(string filename, string UserPic, HttpContext context) { string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" }; //文件允许格式 int fileSize = 3000; //文件大小限制,单位kb WebClient wc = new WebClient(); HttpWebResponse res; bool b = true; if (UserPic.Length > 7) { //格式验证 int temp = UserPic.LastIndexOf('.'); string currentType = UserPic.Substring(temp).ToLower(); res = (HttpWebResponse)WebRequest.Create(UserPic).GetResponse(); //大小验证 if (res.ContentLength > fileSize * 1024) { b = false; } //死链验证 if (res.StatusCode != HttpStatusCode.OK) { b = false; } //检查mime类型 if (res.ContentType.IndexOf("image") == -1) { b = false; } res.Close(); if (b) { wc.DownloadFile(UserPic, context.Server.MapPath(filename)); } } else { b = false; } return b; } #endregion #region //更新微信手机号码----------------------------------------------------------------------------------------- /// /// 更新微信手机号码 /// protected string updateWxPhone(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["encryptedData"]) && !String.IsNullOrEmpty(context.Request["iv"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string encryptedData = HttpUtility.UrlDecode(context.Request["encryptedData"].ToString()); string iv = HttpUtility.UrlDecode(context.Request["iv"].ToString()); bool b = true; if (b) { Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string session_key = umodel.session_key0; string Phone = getPhoneNumber(encryptedData, iv, session_key); if (Phone != "") { if (!System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") && !System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[00886]+[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[00886]+[-]+[09]+\d{8}")) { data = "{\"status\":0,\"msg\":\"获取手机号码错误!\"}"; } else { umodel.Phone = Phone; umodel.IFPhone = 1; daoUser.Update(umodel); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "更新微信手机号码"; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"授权成功!\",\"Phone\":\"" + Phone + "\"," + returndata(umodel) + "}"; } } else { //Mtxfw.Utility.Common.WriteHtml("/weixin/updateWxPhone.txt", encryptedData + "|" + iv + "|" + session_key + "|" + Phone); data = "{\"status\":0,\"msg\":\"服务器解密错误,请重新登录再试!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } /// /// AES解密:从小程序中 getPhoneNumber 返回值中,解析手机号码 /// /// 包括敏感数据在内的完整用户信息的加密数据,详细见加密数据解密算法 /// 加密算法的初始向量 /// /// 手机号码 private string getPhoneNumber(string encryptedData, string IV, string Session_key) { try { IV = IV.Replace(" ", "+"); Session_key = Session_key.Replace(" ", "+"); encryptedData = encryptedData.Replace(" ", "+"); byte[] encryData = Convert.FromBase64String(encryptedData); // strToToHexByte(text); RijndaelManaged rijndaelCipher = new RijndaelManaged(); rijndaelCipher.Key = Convert.FromBase64String(Session_key); // Encoding.UTF8.GetBytes(AesKey); rijndaelCipher.IV = Convert.FromBase64String(IV);// Encoding.UTF8.GetBytes(AesIV); rijndaelCipher.Mode = CipherMode.CBC; rijndaelCipher.Padding = PaddingMode.PKCS7; ICryptoTransform transform = rijndaelCipher.CreateDecryptor(); byte[] plainText = transform.TransformFinalBlock(encryData, 0, encryData.Length); string result = Encoding.Default.GetString(plainText); JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(result).phoneNumber; } catch (Exception ex) { //MessageBox.Show(ex.Message); return ""; } } #endregion #region //更新推广会员ID----------------------------------------------------------------------------------------- /// /// 更新推广会员ID /// protected string updatetgid(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["tguid"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string tguid = HttpUtility.UrlDecode(context.Request["tguid"].ToString()); bool b = true; if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { int ContactID = Mtxfw.Utility.Security.decrypt(Convert.ToInt32(tguid)); if (model.ContactID == 0 && ContactID != model.ContactID) { string ContactIDS = ""; int uLevel1 = 0; SqlDataReader dr = daoUser.GetUserName(gtype, ContactID); if (dr.HasRows) { if (dr.Read()) { ContactIDS = dr["ContactIDS"].ToString(); uLevel1 = Convert.ToInt32(dr["uLevel1"]); } } dr.Close(); model.ContactID = ContactID; if (ContactIDS == "") { model.ContactIDS = "," + ContactID.ToString() + ","; } else { model.ContactIDS = ContactIDS + ContactID.ToString() + ","; } daoUser.UpdateTJR(model.ContactID, model.ContactIDS, model.Id); daoUser.UpdateuLevel("uLevel1", uLevel1, model.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "更新推广会员ID"; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"更新成功!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //会员退出----------------------------------------------------------------------------------------- /// /// 会员退出 /// protected string logout(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); new DAL.user_info().UpdateLogoutTime(userId, LoginId, 1); DateTime MemberDLSJ = DateTime.Now; if (context.Session["MemberDLSJ"] != null) { MemberDLSJ = Convert.ToDateTime(context.Session["MemberDLSJ"].ToString()); } new DAL.User_OnLine().Update(gtype, LoginId, userId, MemberDLSJ); data = "{\"status\":1,\"msg\":\"退出成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //更新会员登录状态----------------------------------------------------------------------------------------- /// /// 更新会员登录状态 /// protected string updateonline(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); new DAL.User_OnLine().Update0(gtype, LoginId, userId); if (new DAL.user_info().GetCount("id=" + userId + " And LoginId2='" + LoginId + "'") == 0) { data = "{\"status\":1,\"msg\":\"已登录!\"}"; } else { data = "{\"status\":2,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } # endregion #region //忘记密码----------------------------------------------------------------------------------------- /// /// 忘记密码 /// protected string forgetPassword(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString().Trim()); } if (!String.IsNullOrEmpty(context.Request["phone"]) && !String.IsNullOrEmpty(context.Request["code"]) && !String.IsNullOrEmpty(context.Request["password"])) { string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString()); string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); string username = ""; string password = HttpUtility.UrlDecode(context.Request["password"].ToString()); if (!String.IsNullOrEmpty(context.Request["username"])) { username = HttpUtility.UrlDecode(context.Request["username"].ToString()); } bool b = true; if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$")) { b = false; data = "{\"status\":0,\"msg\":\"手机号码格式填写不正确!" + (e == 1 ? "Your account can not be logged in!" : "您的账户不能登录!") + "\"}"; } if (b) { Mtxfw.Model.user_info umodel = null; if (username != "") { umodel = new DAL.user_info().GetModel(username, phone, gtype); } else { umodel = new DAL.user_info().GetModelbyPhone(phone, gtype); } if (umodel != null) { if (umodel.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is incorrect!" : "手机验证码不正确!") + "\"}"; } if (b) { DateTime dt1 = DateTime.Now; DateTime dt2 = umodel.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code has failed!" : "手机验证码已经失效!") + "\"}"; } } if (b) { umodel.Password = Mtxfw.Utility.Security.EncryptString(password); umodel.Password2 = umodel.Password; new DAL.user_info().UpdatePassword("password", umodel.Password, umodel.Id); new DAL.user_info().UpdatePassword("password2", umodel.Password2, umodel.Id); daoUser.UpdatePhoneTime3("", umodel.Id); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Reset password is successful!" : "重置密码成功!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect input of mobile phone number!" : "手机号输入不正确!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //上传图片----------------------------------------------------------------------------------------- /// /// 上传图片 /// protected string uploadImage(HttpContext context) { string data = "{\"status\":0}"; if (context.Request.Files["image"] != null && !String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string strContentType = context.Request.Files["image"].ContentType.ToLower(); int intContentLength = context.Request.Files["image"].ContentLength; if (Mtxfw.Utility.Common.hasType(config.webUpType.Split(','), strContentType)) { if (intContentLength <= 102400 * 100) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string FileName, FileType, Folders; Folders = config.webUpPath; Folders = "/Files/grimage/" + model.Id + "/"; //创建保存位置 if (!Directory.Exists(context.Server.MapPath(Folders))) { Directory.CreateDirectory(context.Server.MapPath(Folders)); } FileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString(); FileType = context.Request.Files["image"].FileName.Substring(context.Request.Files["image"].FileName.LastIndexOf(".")).ToLower(); string strFilePath = Folders + FileName + FileType; try { /*Stream sin = context.Request.Files["image"].InputStream; //生产图片 显示 try { byte[] bytes = new byte[sin.Length]; sin.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的开始 sin.Seek(0, SeekOrigin.Begin); } catch { } //生产图片 保存 System.Drawing.Image img = System.Drawing.Bitmap.FromStream(sin); Bitmap bmp = new Bitmap(img); MemoryStream bmpStream = new MemoryStream(); bmp.Save(bmpStream, System.Drawing.Imaging.ImageFormat.Jpeg); FileStream fs = new FileStream(context.Server.MapPath(strFilePath), FileMode.Create); bmpStream.WriteTo(fs); bmpStream.Close(); fs.Close(); bmpStream.Dispose(); fs.Dispose();*/ context.Request.Files["image"].SaveAs(context.Server.MapPath(strFilePath)); string UploadFiles = ""; if (context.Session["UploadFileIng"] != null) { UploadFiles = context.Session["UploadFileIng"].ToString(); if (UploadFiles != "") { UploadFiles += "," + strFilePath; } else { UploadFiles = strFilePath; } } else { UploadFiles = strFilePath; } context.Session["UploadFileIng"] = UploadFiles; data = "{\"status\":1,\"msg\":\"上传成功!\",\"url\":\"" + config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strFilePath, "100x100", "cut") + "\",\"pic\":\"" + strFilePath + "\"}"; } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/uploadImageerr.txt", err.ToString()); data = "{\"status\":0,\"msg\":\"上传失败!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"只能上传小于10M的图片!\"}"; } } else { data = "{\"status\":0,\"msg\":\"只能上传图片" + strContentType + "!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } private Stream GetPostedFileSteam(HttpContext context) { if (context.Request.Browser.Browser == "IE" && context.Request.Files != null && context.Request.Files.Count > 0) { var postedFile = context.Request.Files[0]; return postedFile.InputStream; } else { return context.Request.InputStream; } } /// /// 字节流转换成图片 /// /// 要转换的字节流 /// 转换得到的Image对象 public static Image BytToImg(byte[] byt) { MemoryStream ms = new MemoryStream(byt); Image img = Image.FromStream(ms); return img; } public byte[] StreamToBytes(Stream stream) { byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的开始 stream.Seek(0, SeekOrigin.Begin); return bytes; } /*private System.Drawing.Imaging.ImageFormat GetImageFormat() { switch (FileUpload_Image.PostedFile.ContentType) { case "image/bmp": return System.Drawing.Imaging.ImageFormat.Bmp; case "image/gif": return System.Drawing.Imaging.ImageFormat.Gif; case "image/pjpeg": case "image/jpeg": return System.Drawing.Imaging.ImageFormat.Jpeg; case "image/tiff": return System.Drawing.Imaging.ImageFormat.Tiff; case "image/x-png": return System.Drawing.Imaging.ImageFormat.Png; default: return null; } }*/ #endregion #region //上传临时图片----------------------------------------------------------------------------------------- /// /// 上传临时图片 /// protected string uploadtempImage(HttpContext context) { string data = "{\"status\":0}"; if (context.Request.Files["image"] != null) { string strContentType = context.Request.Files["image"].ContentType.ToLower(); int intContentLength = context.Request.Files["image"].ContentLength; if (Mtxfw.Utility.Common.hasType(config.webUpType.Split(','), strContentType)) { if (intContentLength <= 102400 * 100) { string FileName, FileType, Folders; Folders = config.webUpPath; Folders = "/Files/grimage/temimage/"; //创建保存位置 if (!Directory.Exists(context.Server.MapPath(Folders))) { Directory.CreateDirectory(context.Server.MapPath(Folders)); } FileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString(); FileType = context.Request.Files["image"].FileName.Substring(context.Request.Files["image"].FileName.LastIndexOf(".")).ToLower(); string strFilePath = Folders + FileName + FileType; try { context.Request.Files["image"].SaveAs(context.Server.MapPath(strFilePath)); string UploadFiles = ""; if (context.Session["uploadtempImage"] != null) { UploadFiles = context.Session["uploadtempImage"].ToString(); if (UploadFiles != "") { UploadFiles += "," + strFilePath; } else { UploadFiles = strFilePath; } } else { UploadFiles = strFilePath; } context.Session["uploadtempImage"] = UploadFiles; data = "{\"status\":1,\"msg\":\"上传成功!\",\"url\":\"" + config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strFilePath, "100x100", "cut") + "\",\"pic\":\"" + strFilePath + "\"}"; } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/uploadtempImage.txt", err.ToString()); data = "{\"status\":0,\"msg\":\"上传失败!\"}"; } } else { data = "{\"status\":0,\"msg\":\"只能上传小于10M的图片!\"}"; } } else { data = "{\"status\":0,\"msg\":\"只能上传图片" + strContentType + "!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //上传文件----------------------------------------------------------------------------------------- /// /// 上传文件 /// protected string uploadFile(HttpContext context) { string data = "{\"status\":0}"; if (context.Request.Files["image"] != null && !String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string FileName, FileType, Folders; Folders = config.webUpPath; Folders = "/Files/grimage/" + model.Id + "/"; //创建保存位置 if (!Directory.Exists(context.Server.MapPath(Folders))) { Directory.CreateDirectory(context.Server.MapPath(Folders)); } FileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString(); FileType = context.Request.Files["image"].FileName.Substring(context.Request.Files["image"].FileName.LastIndexOf(".")).ToLower(); string strFilePath = Folders + FileName + FileType; try { context.Request.Files["image"].SaveAs(context.Server.MapPath(strFilePath)); if (!Mtxfw.Utility.Common.IsAllowedExtension(context.Server.MapPath(strFilePath))) { File.Delete(context.Server.MapPath(strFilePath)); data = "{\"status\":0,\"msg\":\"上传格式不正确!\",\"url\":\"" + strFilePath + "\"}"; } else { string UploadFiles = ""; if (context.Session["UploadFileIng"] != null) { UploadFiles = context.Session["UploadFileIng"].ToString(); if (UploadFiles != "") { UploadFiles += "," + strFilePath; } else { UploadFiles = strFilePath; } } else { UploadFiles = strFilePath; } context.Session["UploadFileIng"] = UploadFiles; data = "{\"status\":1,\"msg\":\"上传成功!\",\"url\":\"" + strFilePath + "\"}"; } } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/uploadImageerr.txt", err.ToString()); data = "{\"status\":0,\"msg\":\"上传失败!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } //} //else //{ //data = "{\"status\":0,\"msg\":\"只能上传小于2M的图片!\"}"; // } /*} else { data = "{\"status\":0,\"msg\":\"只能上传图片" + strContentType + "!\"}"; }*/ } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取会员信息----------------------------------------------------------------------------------------- /// /// 获取会员信息 /// protected string getuserinfo(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { int infoId = 0; if (!String.IsNullOrEmpty(context.Request["infoId"])) { infoId = Convert.ToInt32(context.Request["infoId"]); } if (infoId > 0) { data = "{\"status\":0,\"msg\":\"不能查看会员详情!\"}"; /*Mtxfw.Model.user_info model2 = daoUser.GetModel(infoId); if (model2 != null) { if (model2.SuperiorsIDS.IndexOf("," + model.Id + ",") != -1 || model2.ContactIDS.IndexOf("," + model.Id + ",") != -1) { data = "{\"status\":1,\"msg\":\"获取成功!\",\"user\":{\"avatar\":\"" + (model2.UserPic == "" ? "" : Mtxfw.Utility.Common.GetCoverPic(model2.UserPic, "100x100", "cut")) + "\",\"username\":\"" + model2.UserName + "\",\"realname\":\"" + model2.RealName + "\",\"ncname\":\"" + model2.NCName + "\",\"phone\":\"" + model2.Phone + "\",\"sfz\":\"" + model2.SFZ + "\",\"bankname\":\"" + model2.RealName2 + "\",\"bankcard\":\"" + model2.Phone2 + "\",\"bankaddress\":\"" + model2.MTZNLConent + "\",\"alipay\":\"" + model2.BBSConent + "\",\"weixin\":\"" + model2.CompanyCert + "\",\"gender\":\"" + model2.Sex + "\",\"birthday\":\"" + model2.CSDate + "\",\"Province\":\"" + model2.Province + "\",\"City\":\"" + model2.City + "\",\"County\":\"" + model2.County + "\"}}"; } else { data = "{\"status\":0,\"msg\":\"不是你的所属会员不能查看!\"}"; } }*/ } else { string Province = model.Province; string City = model.City; string County = model.County; string address = model.MailingAddress; if (model.utype != "0") { Province = model.CompanyProvince; City = model.CompanyCity; County = model.CompanyCounty; address = model.Companyaddress; } data = "{\"status\":1,\"msg\":\"获取成功!\",\"user\":{\"utype\":\"" + model.utype + "\",\"avatar\":\"" + (model.UserPic == "" ? "" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(model.UserPic, "100x100", "cut")) + "\",\"yavatar\":\"" + model.UserPic + "\",\"username\":\"" + model.UserName + "\",\"realname\":\"" + model.RealName + "\",\"ncname\":\"" + model.NCName + "\",\"address\":\"" + address + "\",\"phone\":\"" + model.Phone + "\",\"sfz\":\"" + model.SFZ + "\",\"accountname\":\"" + model.ProductName + "\",\"bankname\":\"" + model.RealName2 + "\",\"bankcard\":\"" + model.Phone2 + "\",\"bankaddress\":\"" + model.PostalCode + "\",\"AliAccount\":\"" + model.AliAccount + "\",\"AliName\":\"" + model.AliName + "\",\"aliimage\":\"" + (model.aliimage == "" ? "" : Mtxfw.Utility.Common.cmaximage(model.aliimage)) + "\",\"weixinimage\":\"" + (model.weixinimage == "" ? "" : Mtxfw.Utility.Common.cmaximage(model.weixinimage)) + "\",\"yaliimage\":\"" + model.aliimage + "\",\"yweixinimage\":\"" + model.weixinimage + "\",\"CompanyName\":\"" + model.CompanyName + "\",\"CompanyNumber\":\"" + model.CompanyNumber + "\",\"CompanyCert\":\"\",\"CompanyPic\":\"\",\"yCompanyCert\":\"\",\"yCompanyPic\":\"\",\"Province\":\"" + Province + "\",\"City\":\"" + City + "\",\"County\":\"" + County + "\",\"latitude\":\"" + model.latitude + "\",\"longitude\":\"" + model.longitude + "\"},\"webbank\":\"" + config.webbank + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //更新微信小程序信息2----------------------------------------------------------------------------------------- /// /// 更新微信小程序信息2 /// protected string updateUserInfo2(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } // && !String.IsNullOrEmpty(context.Request["Province"]) && !String.IsNullOrEmpty(context.Request["City"]) if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["contact"]) && !String.IsNullOrEmpty(context.Request["Province"]) && !String.IsNullOrEmpty(context.Request["City"]) && !String.IsNullOrEmpty(context.Request["County"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string contact = HttpUtility.UrlDecode(context.Request["contact"].ToString()); string ncname = ""; if (!String.IsNullOrEmpty(context.Request["ncname"])) { ncname = HttpUtility.UrlDecode(context.Request["ncname"].ToString()); } string sfz = "", UserPic = ""; if (!String.IsNullOrEmpty(context.Request["sfz"])) { sfz = HttpUtility.UrlDecode(context.Request["sfz"].ToString()); } if (!String.IsNullOrEmpty(context.Request["UserPic"])) { UserPic = HttpUtility.UrlDecode(context.Request["UserPic"].ToString()); } string Province = HttpUtility.UrlDecode(context.Request["Province"].ToString()); string City = "", County = ""; if (!String.IsNullOrEmpty(context.Request["City"])) { City = HttpUtility.UrlDecode(context.Request["City"].ToString()); } if (!String.IsNullOrEmpty(context.Request["County"])) { County = HttpUtility.UrlDecode(context.Request["County"].ToString()); } string address = ""; if (!String.IsNullOrEmpty(context.Request["address"])) { address = HttpUtility.UrlDecode(context.Request["address"].ToString()); } bool b = true; if (b) { if (contact.Length >= 10) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Provinces must choose!" : "姓名填写太长!") + "\"}"; } } /*bool ifb = true; DateTime dt1 = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (config.webXaccess_token != "" && config.webXaccess_token_time != "") { DateTime dt2 = Convert.ToDateTime(Convert.ToDateTime(config.webXaccess_token_time).AddMinutes(100).ToString("yyyy-MM-dd HH:mm:ss")); if (dt1 > dt2) { ifb = false; } } else { ifb = false; } if (!ifb) { Mtxfw.Utility.WXaccess_token ac = Mtxfw.Utility.Common.getxaccess_token(config.webXAppID, config.webXAppSecret); config.webXaccess_token = ac.access_token; config.webXaccess_token_time = dt1.ToString("yyyy-MM-dd HH:mm:ss"); config.Save(); } if (b) { string strresult = Mtxfw.Utility.Common.GetResponseData("{\"content\":\"" + contact + "\"}", "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + config.webXaccess_token, "utf-8"); if (strresult.IndexOf("errcode") != -1) { Mtxfw.Utility.Common.WriteHtml("/weixin/msg_sec_check.txt", strresult); msg_sec_check msg = (msg_sec_check)Frommsg_sec_check(strresult); if (msg.errcode != "0") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Provinces must choose!" : "姓名填写可能潜在风险!") + "\"}"; } } } if (b) { if (ncname != "") { string strresult = Mtxfw.Utility.Common.GetResponseData("{\"content\":\"" + ncname + "\"}", "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + config.webXaccess_token, "utf-8"); if (strresult.IndexOf("errcode") != -1) { msg_sec_check msg = (msg_sec_check)Frommsg_sec_check(strresult); if (msg.errcode != "0") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Provinces must choose!" : "昵称填写可能潜在风险!") + "\"}"; } } } } if (b) { if (sfz != "") { string strresult = Mtxfw.Utility.Common.GetResponseData("{\"content\":\"" + sfz + "\"}", "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + config.webXaccess_token, "utf-8"); if (strresult.IndexOf("errcode") != -1) { msg_sec_check msg = (msg_sec_check)Frommsg_sec_check(strresult); if (msg.errcode != "0") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Provinces must choose!" : "身份证填写可能潜在风险!") + "\"}"; } } } } if (b) { if (address != "") { string strresult = Mtxfw.Utility.Common.GetResponseData("{\"content\":\"" + address + "\"}", "https://api.weixin.qq.com/wxa/msg_sec_check?access_token=" + config.webXaccess_token, "utf-8"); if (strresult.IndexOf("errcode") != -1) { msg_sec_check msg = (msg_sec_check)Frommsg_sec_check(strresult); if (msg.errcode != "0") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Provinces must choose!" : "地址填写可能潜在风险!") + "\"}"; } } } }*/ if (b) { if (Province == "" || Province == "-1") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Provinces must choose!" : "省份必须选择!") + "\"}"; } } if (b) { if (City == "" || City == "-1") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Cities must choose!" : "城市必须选择!") + "\"}"; } } /*if (b) { // && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[-]+[09]+\d{8}") if (!System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Cities must choose!" : "手机号码格式填写不正确!") + "\"}"; } }*/ if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string CompanyName = ""; string CompanyNumber = ""; string CompanyCert = ""; string CompanyPic = ""; string CompanyProvince = ""; string CompanyCity = ""; string CompanyCounty = ""; string Companyaddress = ""; string Companylatitude = ""; string Companylongitude = ""; if (Convert.ToInt32(model.utype) > 0) { if (!String.IsNullOrEmpty(context.Request["CompanyName"]) && !String.IsNullOrEmpty(context.Request["CompanyNumber"]) && !String.IsNullOrEmpty(context.Request["CompanyCert"]) && !String.IsNullOrEmpty(context.Request["CompanyPic"]) && !String.IsNullOrEmpty(context.Request["Companylatitude"]) && !String.IsNullOrEmpty(context.Request["Companylongitude"])) { CompanyName = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyName"].ToString())); CompanyNumber = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyNumber"].ToString())); CompanyCert = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyCert"].ToString())); CompanyPic = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CompanyPic"].ToString())); CompanyProvince = Province; CompanyCity = City; CompanyCounty = County; Companyaddress = address; Companylatitude = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Companylatitude"].ToString())); Companylongitude = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Companylongitude"].ToString())); UserPic = CompanyPic; } else { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The invitation code does not exist2!" : "参数为空2!") + "\"}"; } } if (b) { string editbody = ""; if (model.RealName != contact) { editbody += " 原姓名" + model.RealName + "改为" + contact; } if (model.NCName != ncname) { editbody += " 原昵称" + model.NCName + "改为" + ncname; } model.RealName = contact; model.NCName = ncname; model.SFZ = sfz; model.UserPic = (UserPic != "" ? (UserPic.IndexOf("http") != -1 ? UserPic : config.webUrl + UserPic) : ""); if (Convert.ToInt32(model.utype) > 0) { model.CompanyName = CompanyName; model.CompanyNumber = CompanyNumber; model.CompanyCert = CompanyCert; model.CompanyPic = CompanyPic; model.CompanyProvince = CompanyProvince; model.CompanyCity = CompanyCity; model.CompanyCounty = CompanyCounty; model.Companyaddress = Companyaddress; model.Companylatitude = (Companylatitude != "" ? Convert.ToDecimal(Companylatitude) : 0); model.Companylongitude = (Companylongitude != "" ? Convert.ToDecimal(Companylongitude) : 0); } else { model.Province = Province; model.City = City; model.County = County; model.MailingAddress = address; } daoUser.Update(model); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = (model.Id == 10154 ? "119.39.248.32" : Mtxfw.Utility.Common.GetIP); logmodel.Body = "修改会员资料" + editbody; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); if (context.Session["uploadtempImage"] != null) { string[] stra = context.Session["uploadtempImage"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { bool ifdel = false; if (CompanyCert != "") { if (CompanyCert.IndexOf(str.Trim()) != -1) { ifdel = true; } } if (CompanyPic != "") { if (CompanyPic.IndexOf(str.Trim()) != -1) { ifdel = true; } } if (UserPic != "") { if (UserPic.IndexOf(str.Trim()) != -1) { ifdel = true; } } if (!ifdel) { if (System.IO.File.Exists(context.Server.MapPath(str.Trim()))) { System.IO.File.Delete(context.Server.MapPath(str.Trim())); } } } } context.Session.Remove("UploadFileIng"); } data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Update success!" : "更新成功!") + "\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } public object Frommsg_sec_check(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } #endregion #region //获取微信手机号码----------------------------------------------------------------------------------------- /// /// 获取微信手机号码 /// protected string getwxphone(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["encryptedData"]) && !String.IsNullOrEmpty(context.Request["iv"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string encryptedData = HttpUtility.UrlDecode(context.Request["encryptedData"].ToString()); string iv = HttpUtility.UrlDecode(context.Request["iv"].ToString()); bool b = true; if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string Phone = getPhoneNumber(encryptedData, iv, model.session_key0); if (Phone != "") { if (!System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") && !System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[00886]+[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(Phone, @"^[00886]+[-]+[09]+\d{8}")) { data = "{\"status\":0,\"msg\":\"获取手机号码错误!\"}"; } else { data = "{\"status\":1,\"msg\":\"授权成功!\",\"Phone\":\"" + Phone + "\"}"; } } else { //Mtxfw.Utility.Common.WriteHtml("/weixin/getwxphone.txt", encryptedData + "|" + iv + "|" + model.session_key0 + "|" + Phone); data = "{\"status\":0,\"msg\":\"服务器解密错误,请重新登录再试!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //绑定手机号码----------------------------------------------------------------------------------------- /// /// 绑定手机号码 /// protected string bindphone(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["phone"]) && !String.IsNullOrEmpty(context.Request["code"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string phone = HttpUtility.UrlDecode(context.Request["phone"].ToString()).Trim(); string code = HttpUtility.UrlDecode(context.Request["code"].ToString()).Trim(); bool b = true; if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(phone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Incorrect cell phone number format!" : "手机号码格式填写不正确!") + "\"}"; } } if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (b) { if (daoUser.GetCount("gtype=" + gtype + " and IFStores=0 And UserName='" + phone + "' And id<>" + model.Id) > 0) { b = false; data = "{\"status\":0,\"msg\":\"手机号码已存在\"}"; } } if (b) { if (model.Phone != "") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Mobile phone number has been bound!" : "手机号码已绑定过!") + "\"}"; } } if (b) { if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is incorrect!" : "手机验证码不正确!") + "\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is invalid!" : "手机验证码已经失效!") + "\"}"; } } } } if (b) { model.Phone = phone; model.IFPhone = 1; model.UserName = phone; daoUser.Update(model); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "绑定手机号码" + phone; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); daoUser.UpdatePhoneTime3("", model.Id); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Update success!" : "绑定成功!") + "\",\"IFDL\":0," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //解绑手机号码----------------------------------------------------------------------------------------- /// /// 解绑手机号码 /// protected string unbindphone(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["code"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string code = HttpUtility.UrlDecode(context.Request["code"].ToString()).Trim(); bool b = true; if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (b) { if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is incorrect!" : "手机验证码不正确!") + "\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is invalid!" : "手机验证码已经失效!") + "\"}"; } } } } if (b) { if (model.Phone == "") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Mobile phone number not bound!" : "手机号码未绑定!") + "\"}"; } } if (b) { model.Phone = ""; model.IFPhone = 0; daoUser.Update(model); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "解绑手机号码"; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); daoUser.UpdatePhoneTime3("", model.Id); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Unbundling success!" : "解绑成功!") + "\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //更新银行资料----------------------------------------------------------------------------------------- /// /// 更新银行资料 /// protected string updateBankInfo(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["AccountName"]) && !String.IsNullOrEmpty(context.Request["BankName"]) && !String.IsNullOrEmpty(context.Request["BankCard"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string AccountName = HttpUtility.UrlDecode(context.Request["AccountName"].ToString()); string BankName = HttpUtility.UrlDecode(context.Request["BankName"].ToString()); string BankCard = HttpUtility.UrlDecode(context.Request["BankCard"].ToString()); string BankDepos = ""; if (!String.IsNullOrEmpty(context.Request["BankDepos"])) { BankDepos = HttpUtility.UrlDecode(context.Request["BankDepos"].ToString()); } bool b = true; if (b) { if (AccountName == "") { b = false; data = "{\"status\":0,\"msg\":\"开户姓名不能为空!\"}"; } else { if (!System.Text.RegularExpressions.Regex.IsMatch(AccountName, @"^[\u4e00-\u9fa5a-zA-Z]+$")) { b = false; data = "{\"status\":0,\"msg\":\"开户姓名填写不正确,只能输入中文和字母!\"}"; } } } if (b) { if (BankName == "") { b = false; data = "{\"status\":0,\"msg\":\"银行名称必须选择!\"}"; } else { if (!System.Text.RegularExpressions.Regex.IsMatch(BankName, @"^[\u4e00-\u9fa5a-zA-Z0-9]+$")) { b = false; data = "{\"status\":0,\"msg\":\"银行名称填写不正确,只能输入中文和字母或数字!\"}"; } } } if (b) { if (BankCard == "") { b = false; data = "{\"status\":0,\"msg\":\"银行卡号不能为空!\"}"; } else { if (!System.Text.RegularExpressions.Regex.IsMatch(BankCard, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"银行卡号填写不正确,只能输入数字!\"}"; } } } if (b) { if (BankDepos == "") { b = false; data = "{\"status\":0,\"msg\":\"银行开户行地址不能为空!\"}"; } else { if (BankDepos.Length > 100) { b = false; data = "{\"status\":0,\"msg\":\"银行开户行地址太长!\"}"; } } } if (b) { if (String.IsNullOrEmpty(context.Request["code"]) && String.IsNullOrEmpty(context.Request["pwd"])) { b = false; data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } } if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } } if (b) { if (daoResults.GetCount("utype=1 And MemberId=" + model.Id + " and IFDelete=0 And UserId=0 and seef=0 And DateDiff(hour,addtime,getdate())<48") > 0) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,提现后在48小时内不能修改银行资料!\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["pwd"])) { string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } } if (b) { string editbody = ""; if (model.ProductName != AccountName) { editbody += " 原开户姓名" + model.ProductName + "改为" + AccountName; } if (model.RealName2 != BankName) { editbody += " 原银行名称" + model.RealName2 + "改为" + BankName; } if (model.Phone2 != BankCard) { editbody += " 原银行卡号" + model.Phone2 + "改为" + BankCard; } if (model.PostalCode != BankDepos) { editbody += " 原开户行" + model.PostalCode + "改为" + BankDepos; } model.ProductName = AccountName; model.RealName2 = BankName; model.Phone2 = BankCard; model.PostalCode = BankDepos; daoUser.Update(model); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = (model.Id == 10154 ? "119.39.248.32" : Mtxfw.Utility.Common.GetIP); logmodel.Body = "修改银行资料" + editbody; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); daoUser.UpdatePhoneTime3("", model.Id); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Update success!" : "更新成功!") + "\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //更新支付宝信息----------------------------------------------------------------------------------------- /// /// 更新支付宝信息 /// protected string updatealipay(HttpContext context) { string data = "{\"status\":0}";// && !String.IsNullOrEmpty(context.Request["Province"]) if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string AliAccount = ""; string AliName = ""; string aliimage = ""; if (!String.IsNullOrEmpty(context.Request["AliAccount"]) && !String.IsNullOrEmpty(context.Request["AliName"])) { AliAccount = HttpUtility.UrlDecode(context.Request["AliAccount"].ToString()); AliName = HttpUtility.UrlDecode(context.Request["AliName"].ToString()); } if (!String.IsNullOrEmpty(context.Request["aliimage"])) { aliimage = HttpUtility.UrlDecode(context.Request["aliimage"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (b) { if (String.IsNullOrEmpty(context.Request["code"]) && String.IsNullOrEmpty(context.Request["pwd"])) { b = false; data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } } if (b) { if ((AliAccount == "" || AliName == "") && aliimage == "") { b = false; data = "{\"status\":0,\"msg\":\"支付宝账号或支付宝收款码不能为空!\"}"; } } if (b) { if ((AliAccount != "" || AliName != "")) { if (!Regex.IsMatch(AliAccount, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") && !System.Text.RegularExpressions.Regex.IsMatch(AliAccount, @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$")) { b = false; data = "{\"status\":0,\"msg\":\"支付宝账号必须是手机号或邮箱!\"}"; } } } if (b) { if (daoResults.GetCount("utype=1 And MemberId=" + model.Id + " and IFDelete=0 And UserId=1 and seef=0 And DateDiff(hour,addtime,getdate())<48") > 0) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,提现后在48小时内不能修改支付宝资料!\"}"; } } if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } } if (b) { if (!String.IsNullOrEmpty(context.Request["pwd"])) { string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } } if (b) { model.AliAccount = AliAccount; model.AliName = AliName; if (aliimage != "") { if (model.aliimage != "") { try { File.Delete(context.Server.MapPath(model.aliimage)); } catch (Exception err) { } } model.aliimage = aliimage; } new Mtxfw.DAL.user_info().Update(model); daoUser.UpdatePassword("uploadimage", "", model.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = (model.Id == 8714 ? "223.104.162.201" : Mtxfw.Utility.Common.GetIP); logmodel.Body = "修改支付宝资料"; logmodel.UType = 2; logmodel.gtype = model.gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"更新成功!\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //更新微信收款码信息----------------------------------------------------------------------------------------- /// /// 更新微信收款码信息 /// protected string updateweixinpay(HttpContext context) { string data = "{\"status\":0}";// && !String.IsNullOrEmpty(context.Request["Province"]) if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["weixinimage"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string weixinimage = HttpUtility.UrlDecode(context.Request["weixinimage"].ToString()); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (b) { if (String.IsNullOrEmpty(context.Request["code"]) && String.IsNullOrEmpty(context.Request["pwd"])) { b = false; data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } } if (b) { if (weixinimage == "") { b = false; data = "{\"status\":0,\"msg\":\"微信收款码不能为空!\"}"; } } if (b) { if (daoResults.GetCount("utype=1 And MemberId=" + model.Id + " and IFDelete=0 And UserId=2 and seef=0 And DateDiff(hour,addtime,getdate())<48") > 0) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,提现后在48小时内不能修改微信收款码!\"}"; } } if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } } if (b) { if (!String.IsNullOrEmpty(context.Request["pwd"])) { string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } } if (b) { if (weixinimage != "") { if (model.weixinimage != "") { try { File.Delete(context.Server.MapPath(model.weixinimage)); } catch (Exception err) { } } model.weixinimage = weixinimage; } new Mtxfw.DAL.user_info().Update(model); daoUser.UpdatePassword("uploadimage", "", model.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = (model.Id == 8714 ? "223.104.162.201" : Mtxfw.Utility.Common.GetIP); logmodel.Body = "修改微信收款码信息"; logmodel.UType = 2; logmodel.gtype = model.gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"更新成功!\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取线下门店信息----------------------------------------------------------------------------------------- /// /// 获取线下门店信息 /// protected string getbusinessinfo(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string ClsID = "", name = "", xydm = "", phone = "", dgzh = "", frname = "", fridcard = "", province = "", city = "", county = "", address = "", xcoo = "", ycoo = "", range = "", bank = "", bankcard = "", bankname = "", khname = "", bankkhh="", image = "", image0 = "", image1 = "", image2 = "", image3 = "", minimage = "", minimage0 = "", minimage1 = "", minimage2 = "", minimage3 = ""; int ifedit = (config.TJTPEnable == "1" ? 1 : 0), ifeditbank = 0; int IFFill = 0; string Agentrading = ""; Mtxfw.Model.business_info bmodel = daobusiness.GetModelByUserId(0, model.Id); if (bmodel != null) { ClsID = bmodel.ClsID.ToString(); name = bmodel.CompanyName; xydm = bmodel.Industry; phone = bmodel.ContactPhone; dgzh = bmodel.ClsnName2; frname = bmodel.frname; fridcard = bmodel.fridcard; province = bmodel.Province; city = bmodel.City; county = bmodel.County; IFFill = bmodel.IFFill; Agentrading = bmodel.Agentrading; address = bmodel.Companyaddress; xcoo = bmodel.xcoo; ycoo = bmodel.ycoo; range = bmodel.BusinessRange; bank = bmodel.InternetSite; bankcard = bmodel.Busroutes; bankname = bmodel.Introduction; khname = bmodel.ContactPeople; bankkhh = bmodel.Introduction; image = (bmodel.picture != "" ? bmodel.picture.Split('|')[0] : ""); image0 = (bmodel.Businesslicense != "" ? bmodel.Businesslicense.Split('|')[0] : ""); image1 = (bmodel.TaxRegistration != "" ? bmodel.TaxRegistration.Split('|')[0] : ""); image2 = (bmodel.Introduction2 != "" ? bmodel.Introduction2.Split('|')[0] : ""); image3 = (bmodel.Introduction3 != "" ? bmodel.Introduction3.Split('|')[0] : ""); } minimage = Mtxfw.Utility.Common.cminimage(image); minimage0 = Mtxfw.Utility.Common.cminimage(image0); minimage1 = Mtxfw.Utility.Common.cminimage(image1); minimage2 = Mtxfw.Utility.Common.cminimage(image2); minimage3 = Mtxfw.Utility.Common.cminimage(image3); string strdata = ",\"clslist\":["; DataSet ds = daolb.GetList("gtype=" + gtype + " and utype=1 Order By LBLinkID"); int clsindex = 0; int index = 0; string clsname = ""; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string id = Dr["id"].ToString(); string lbname = Dr["LBName"].ToString(); strdata += "{\"id\":" + id + ",\"name\":\"" + lbname + "\"},"; if (id == ClsID) { clsindex = index; clsname = lbname; } index += 1; } ds.Clear(); if (strdata != "") { if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } strdata += "]"; string showtitle = "", showbody = ""; ds = daoArt.GetList1("id,title,Content", "gtype=" + gtype + " and id=226606 Order by AddTime desc"); if (ds.Tables[0].Rows.Count > 0) { showtitle = ds.Tables[0].Rows[0]["title"].ToString(); showbody = ds.Tables[0].Rows[0]["Content"].ToString(); } ds.Clear(); data = "{\"status\":1,\"msg\":\"获取成功!\",\"ylmoney\":\"" + config.webMoney74 + "\",\"ylmoney0\":\"" + config.webMoney75 + "\",\"sjylmoney\":\"" + model.umoney42.ToString() + "\",\"webbank\":\"" + config.webbank + "\",\"showtitle\":\"" + showtitle + "\",\"showbody\":\"" + Mtxfw.Utility.Common.ReplaceString(showbody) + "\"" + strdata + ",\"clsindex\":\"" + clsindex + "\",\"clsname\":\"" + clsname + "\",\"name\":\"" + name + "\",\"xydm\":\"" + xydm + "\",\"phone\":\"" + phone + "\",\"dgzh\":\"" + dgzh + "\",\"frname\":\"" + frname + "\",\"fridcard\":\"" + fridcard + "\",\"province\":\"" + province + "\",\"city\":\"" + city + "\",\"county\":\"" + county + "\",\"IFFill\":\"" + IFFill + "\",\"Agentrading\":\"" + Agentrading + "\",\"address\":\"" + address + "\",\"xcoo\":\"" + xcoo + "\",\"ycoo\":\"" + ycoo + "\",\"range\":\"" + range + "\",\"bank\":\"" + bank + "\",\"bankcard\":\"" + bankcard + "\",\"bankname\":\"" + bankname + "\",\"khname\":\"" + khname + "\",\"bankkhh\":\"" + bankkhh + "\",\"image\":\"" + image + "\",\"image0\":\"" + image0 + "\",\"image1\":\"" + image1 + "\",\"image2\":\"" + image2 + "\",\"image3\":\"" + image3 + "\",\"minimage\":\"" + minimage + "\",\"minimage0\":\"" + minimage0 + "\",\"minimage1\":\"" + minimage1 + "\",\"minimage2\":\"" + minimage2 + "\",\"minimage3\":\"" + minimage3 + "\",\"ifedit\":\"" + ifedit + "\",\"ifeditbank\":\"" + ifeditbank + "\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //更新线下门店信息----------------------------------------------------------------------------------------- /// /// 更新线下门店信息 /// protected string updatebusinessinfo(HttpContext context) { string data = "{\"status\":0}";// && !String.IsNullOrEmpty(context.Request["Province"]) if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["clsid"]) && !String.IsNullOrEmpty(context.Request["name"]) && !String.IsNullOrEmpty(context.Request["tel"]) && !String.IsNullOrEmpty(context.Request["number"]) && !String.IsNullOrEmpty(context.Request["image0"]) && !String.IsNullOrEmpty(context.Request["image1"]) && !String.IsNullOrEmpty(context.Request["image2"]) && !String.IsNullOrEmpty(context.Request["image3"]) && !String.IsNullOrEmpty(context.Request["image4"]) && context.Request["image5"] != null && context.Request["image6"] != null && !String.IsNullOrEmpty(context.Request["province"]) && !String.IsNullOrEmpty(context.Request["city"]) && !String.IsNullOrEmpty(context.Request["address"]) && !String.IsNullOrEmpty(context.Request["longitude"]) && !String.IsNullOrEmpty(context.Request["latitude"]) && !String.IsNullOrEmpty(context.Request["money"]) && !String.IsNullOrEmpty(context.Request["accountname"]) && !String.IsNullOrEmpty(context.Request["bankname"]) && !String.IsNullOrEmpty(context.Request["bankcard"]) && !String.IsNullOrEmpty(context.Request["bankaddress"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()).Trim(); int clsid = Convert.ToInt32(context.Request["clsid"].ToString()); string stryl = HttpUtility.UrlDecode(context.Request["money"].ToString()).Trim(); Double ylmoney = 0.0000; string clsname = ""; if (clsid > 0) { clsname = daolb.Getzd("lbname", "id=" + clsid).ToString(); } string dgzh = ""; if (!String.IsNullOrEmpty(context.Request["dgzh"])) { dgzh = context.Request["dgzh"].ToString(); } string frname = ""; if (!String.IsNullOrEmpty(context.Request["frname"])) { frname = context.Request["frname"].ToString(); } string fridcard = ""; if (!String.IsNullOrEmpty(context.Request["fridcard"])) { fridcard = context.Request["fridcard"].ToString(); } string email = ""; if (!String.IsNullOrEmpty(context.Request["email"])) { email = context.Request["email"].ToString(); } string name = HttpUtility.UrlDecode(context.Request["name"].ToString()).Trim(); string tel = HttpUtility.UrlDecode(context.Request["tel"].ToString()).Trim(); string number = HttpUtility.UrlDecode(context.Request["number"].ToString()).Trim(); string image0 = HttpUtility.UrlDecode(context.Request["image0"].ToString()).Trim(); string image1 = HttpUtility.UrlDecode(context.Request["image1"].ToString()).Trim(); string image2 = HttpUtility.UrlDecode(context.Request["image2"].ToString()).Trim(); string image3 = HttpUtility.UrlDecode(context.Request["image3"].ToString()).Trim(); string image4 = HttpUtility.UrlDecode(context.Request["image4"].ToString()).Trim(); string image5 = HttpUtility.UrlDecode(context.Request["image5"].ToString()).Trim(); string image6 = HttpUtility.UrlDecode(context.Request["image6"].ToString()).Trim(); string image7 = ""; if (!String.IsNullOrEmpty(context.Request["image7"])) { image7 = HttpUtility.UrlDecode(context.Request["image7"].ToString()).Trim(); } string province = HttpUtility.UrlDecode(context.Request["province"].ToString()).Trim(); string city = HttpUtility.UrlDecode(context.Request["city"].ToString()).Trim(); string county = ""; if (!String.IsNullOrEmpty(context.Request["county"])) { county = HttpUtility.UrlDecode(context.Request["county"].ToString()).Trim(); } int IFFill = 0; if (!String.IsNullOrEmpty(context.Request["IFFill"])) { IFFill = Convert.ToInt32(context.Request["IFFill"].ToString()); } string Agentrading = ""; if (!String.IsNullOrEmpty(context.Request["Agentrading"])) { Agentrading = HttpUtility.UrlDecode(context.Request["Agentrading"].ToString()).Trim(); } string address = HttpUtility.UrlDecode(context.Request["address"].ToString()).Trim(); string longitude = HttpUtility.UrlDecode(context.Request["longitude"].ToString()).Trim(); string latitude = HttpUtility.UrlDecode(context.Request["latitude"].ToString()).Trim(); string fwbody = ""; if (!String.IsNullOrEmpty(context.Request["fwbody"])) { fwbody = HttpUtility.UrlDecode(context.Request["fwbody"].ToString()).Trim(); } string accountname = HttpUtility.UrlDecode(context.Request["accountname"].ToString()).Trim(); string bankname = HttpUtility.UrlDecode(context.Request["bankname"].ToString()).Trim(); string bankcard = HttpUtility.UrlDecode(context.Request["bankcard"].ToString()).Trim(); string bankaddress = HttpUtility.UrlDecode(context.Request["bankaddress"].ToString()).Trim(); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (config.JJBZRDHBEnable == "1") { b = false; data = "{\"status\":0,\"msg\":\"本地生活暂时关闭!\"}"; } if (b) { if (model.uLevel16 == 1) { b = false; data = "{\"status\":0,\"msg\":\"线下门店申请正在审核中!\"}"; } } if (b) { if (model.uLevel16 == 2) { b = false; data = "{\"status\":0,\"msg\":\"线下门店申请已通过!\"}"; } } if (b) { if (model.uLevel34 == 0) { b = false; data = "{\"status\":0,\"msg\":\"你的账号还没有激活门店不能申请门店!\"}"; } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(stryl, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(stryl, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"门店让利格式有误"+ stryl + "!\"}"; } else { ylmoney = Convert.ToDouble(Convert.ToDouble(stryl).ToString("f4")); if (ylmoney < Convert.ToDouble(Convert.ToDouble(config.webMoney74).ToString("f4")) || ylmoney > Convert.ToDouble(Convert.ToDouble(config.webMoney75).ToString("f4"))) { b = false; data = "{\"status\":0,\"msg\":\"门店让利范围"+ config.webMoney74 +"至" + config.webMoney75 + "!\"}"; } } } if (b) { Mtxfw.Model.business_info bmodel = new Mtxfw.Model.business_info(); bmodel.CompanyName = name; bmodel.ClsID = clsid; bmodel.ClsnName = clsname; bmodel.frname = frname; bmodel.fridcard = fridcard; bmodel.email = email; bmodel.ClsID2 = 0; bmodel.ClsnName2 = dgzh; bmodel.Province = province; bmodel.City = city; bmodel.County = county; bmodel.IFFill = IFFill; bmodel.Agentrading = Agentrading; bmodel.Industry = number; bmodel.Introduction2 = (image3.IndexOf("http") == -1 ? config.webUrl : "") + image3;//身份证正面 bmodel.Introduction3 = (image4.IndexOf("http") == -1 ? config.webUrl : "") + image4;//身份证背面 bmodel.picture = (image0.IndexOf("http") == -1 ? config.webUrl : "") + image0; bmodel.BusinessRange = fwbody;//服务内容 bmodel.Businesslicense = (image1.IndexOf("http") == -1 ? config.webUrl : "") + image1;//营业执照 bmodel.TaxRegistration = (image2.IndexOf("http") == -1 ? config.webUrl : "") + image2;//门头照片 bmodel.Companyaddress = address; bmodel.InternetSite = bankname;//银行名称 bmodel.Busroutes = bankcard;//银行卡号 bmodel.Introduction = bankaddress;//银行开户行 bmodel.ContactPeople = accountname;//银行开户人 bmodel.ContactPhone = tel;//联系电话 bmodel.ApplyTime = DateTime.Now; bmodel.CompanyId = "0";//0银花优选1普民慧2普惠生活 bmodel.Discount = (image7.IndexOf("http") == -1 ? config.webUrl : "") + image7; bmodel.xcoo = latitude; bmodel.ycoo = longitude; bmodel.utype = "0"; bmodel.gtype = gtype; bmodel.seef = 0; bmodel.ApplyState = ""; bmodel.UserId = model.Id; daobusiness.Add(bmodel); daoUser.UpdateuLevel("uLevel16", 1, model.Id); model.uLevel16 = 1; daoUser.UpdateMoney2("umoney42", ylmoney, model.Id); model.umoney42 = ylmoney; daoUser.UpdateMoney2("umoney50", ylmoney, model.Id); model.umoney50 = ylmoney; daoUser.UpdateMoney2("umoney51", ylmoney, model.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "银花优选微信申请线下门店"; logmodel.UType = 2; logmodel.gtype = model.gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"提交成功!\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //申请修改门店资料----------------------------------------------------------------------------------------- /// /// 申请修改门店资料 /// protected string appupdatebusiness(HttpContext context) { string data = "{\"status\":0}";// && !String.IsNullOrEmpty(context.Request["Province"]) if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["clsid"]) && !String.IsNullOrEmpty(context.Request["name"]) && !String.IsNullOrEmpty(context.Request["tel"]) && !String.IsNullOrEmpty(context.Request["number"]) && !String.IsNullOrEmpty(context.Request["image0"]) && !String.IsNullOrEmpty(context.Request["image1"]) && !String.IsNullOrEmpty(context.Request["image2"]) && !String.IsNullOrEmpty(context.Request["image3"]) && !String.IsNullOrEmpty(context.Request["image4"]) && !String.IsNullOrEmpty(context.Request["province"]) && !String.IsNullOrEmpty(context.Request["city"]) && !String.IsNullOrEmpty(context.Request["address"]) && !String.IsNullOrEmpty(context.Request["longitude"]) && !String.IsNullOrEmpty(context.Request["latitude"]) && !String.IsNullOrEmpty(context.Request["money"]) && !String.IsNullOrEmpty(context.Request["accountname"]) && !String.IsNullOrEmpty(context.Request["bankname"]) && !String.IsNullOrEmpty(context.Request["bankcard"]) && !String.IsNullOrEmpty(context.Request["bankaddress"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()).Trim(); int clsid = Convert.ToInt32(context.Request["clsid"].ToString()); string stryl = HttpUtility.UrlDecode(context.Request["money"].ToString()).Trim(); Double ylmoney = 0.0000; string clsname = ""; if (clsid > 0) { clsname = daolb.Getzd("lbname", "id=" + clsid).ToString(); } string dgzh = ""; if (!String.IsNullOrEmpty(context.Request["dgzh"])) { dgzh = context.Request["dgzh"].ToString(); } string frname = ""; if (!String.IsNullOrEmpty(context.Request["frname"])) { frname = context.Request["frname"].ToString(); } string fridcard = ""; if (!String.IsNullOrEmpty(context.Request["fridcard"])) { fridcard = context.Request["fridcard"].ToString(); } string name = HttpUtility.UrlDecode(context.Request["name"].ToString()).Trim(); string tel = HttpUtility.UrlDecode(context.Request["tel"].ToString()).Trim(); string number = HttpUtility.UrlDecode(context.Request["number"].ToString()).Trim(); string image0 = HttpUtility.UrlDecode(context.Request["image0"].ToString()).Trim(); string image1 = HttpUtility.UrlDecode(context.Request["image1"].ToString()).Trim(); string image2 = HttpUtility.UrlDecode(context.Request["image2"].ToString()).Trim(); string image3 = HttpUtility.UrlDecode(context.Request["image3"].ToString()).Trim(); string image4 = HttpUtility.UrlDecode(context.Request["image4"].ToString()).Trim(); string province = HttpUtility.UrlDecode(context.Request["province"].ToString()).Trim(); string city = HttpUtility.UrlDecode(context.Request["city"].ToString()).Trim(); string county = ""; if (!String.IsNullOrEmpty(context.Request["county"])) { county = HttpUtility.UrlDecode(context.Request["county"].ToString()).Trim(); } int IFFill = 0; if (!String.IsNullOrEmpty(context.Request["IFFill"])) { IFFill = Convert.ToInt32(context.Request["IFFill"].ToString()); } string Agentrading = ""; if (!String.IsNullOrEmpty(context.Request["Agentrading"])) { Agentrading = HttpUtility.UrlDecode(context.Request["Agentrading"].ToString()).Trim(); } string address = HttpUtility.UrlDecode(context.Request["address"].ToString()).Trim(); string longitude = HttpUtility.UrlDecode(context.Request["longitude"].ToString()).Trim(); string latitude = HttpUtility.UrlDecode(context.Request["latitude"].ToString()).Trim(); string fwbody = ""; if (!String.IsNullOrEmpty(context.Request["fwbody"])) { fwbody = HttpUtility.UrlDecode(context.Request["fwbody"].ToString()).Trim(); } string accountname = HttpUtility.UrlDecode(context.Request["accountname"].ToString()).Trim(); string bankname = HttpUtility.UrlDecode(context.Request["bankname"].ToString()).Trim(); string bankcard = HttpUtility.UrlDecode(context.Request["bankcard"].ToString()).Trim(); string bankaddress = HttpUtility.UrlDecode(context.Request["bankaddress"].ToString()).Trim(); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (b) { if (config.TJTPEnable == "0") { b = false; data = "{\"status\":0,\"msg\":\"暂时不能修改门店资料!\"}"; } } if (b) { if (model.uLevel16 == 0) { b = false; data = "{\"status\":0,\"msg\":\"未申请线下门店!\"}"; } } if (b) { if (model.uLevel16 == 1) { b = false; data = "{\"status\":0,\"msg\":\"门店未审核!\"}"; } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(stryl, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(stryl, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"门店让利格式有误"+ stryl + "!\"}"; } else { ylmoney = Convert.ToDouble(Convert.ToDouble(stryl).ToString("f4")); if (ylmoney < Convert.ToDouble(Convert.ToDouble(config.webMoney74).ToString("f4")) || ylmoney > Convert.ToDouble(Convert.ToDouble(config.webMoney75).ToString("f4"))) { b = false; data = "{\"status\":0,\"msg\":\"门店让利范围"+ config.webMoney74 +"至" + config.webMoney75 + "!\"}"; } } } if (b) { Mtxfw.Model.business_info busmodel = daobusiness.GetModelByUserId(0, model.Id); if (busmodel != null) { Mtxfw.Model.business_info bmodel = daobusiness.GetModelByUserId(3, model.Id); if (bmodel != null) { if (bmodel.seef == 0) { b = false; data = "{\"status\":0,\"msg\":\"上次申请修改未审核!\"}"; } } if (b) { bmodel = new Model.business_info(); bmodel.CompanyName = name; bmodel.ClsID = clsid; bmodel.ClsnName = clsname; bmodel.frname = frname; bmodel.fridcard = fridcard; bmodel.email = ylmoney.ToString(); bmodel.ClsID2 = 0; bmodel.ClsnName2 = dgzh; bmodel.Province = province; bmodel.City = city; bmodel.County = county; bmodel.IFFill = IFFill; bmodel.Agentrading = Agentrading; bmodel.Industry = number; bmodel.Introduction2 = (image3.IndexOf("http") == -1 ? config.webUrl : "") + image3;//身份证正面 bmodel.Introduction3 = (image4.IndexOf("http") == -1 ? config.webUrl : "") + image4;//身份证背面 bmodel.picture = (image0.IndexOf("http") == -1 ? config.webUrl : "") + image0; bmodel.BusinessRange = fwbody;//服务内容 bmodel.Businesslicense = (image1.IndexOf("http") == -1 ? config.webUrl : "") + image1;//营业执照 bmodel.TaxRegistration = (image2.IndexOf("http") == -1 ? config.webUrl : "") + image2;//门头照片 bmodel.Companyaddress = address; bmodel.InternetSite = bankname;//银行名称 bmodel.Busroutes = bankcard;//银行卡号 bmodel.Introduction = bankaddress;//银行开户行 bmodel.ContactPeople = accountname;//银行开户人 bmodel.ContactPhone = tel;//联系电话 bmodel.ApplyTime = DateTime.Now; bmodel.CompanyId = "0";//0银花优选1普民慧2普惠生活 bmodel.Discount = ""; bmodel.xcoo = latitude; bmodel.ycoo = longitude; bmodel.utype = "3"; bmodel.gtype = gtype; bmodel.seef = 0; bmodel.ApplyState = ""; bmodel.UserId = model.Id; daobusiness.Add(bmodel); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "银花优选微信申请修改门店资料"; logmodel.UType = 2; logmodel.gtype = model.gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"提交成功!\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误0!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取线上门店信息----------------------------------------------------------------------------------------- /// /// 获取线上门店信息 /// protected string getbusinessinfo0(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ",\"clslist\":["; DataSet ds = daoCategory.GetList("gtype=" + gtype + " and ttype=8 Order By C_LinkID"); foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string id = Dr["C_ID"].ToString(); string name = Dr["C_NAME"].ToString(); strdata += "{\"id\":" + id + ",\"name\":\"" + name + "\"},"; } ds.Clear(); if (strdata != "") { if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } strdata += "]"; data = "{\"status\":1,\"msg\":\"获取成功!\"" + strdata + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //更新线上门店信息----------------------------------------------------------------------------------------- /// /// 更新线上门店信息 /// protected string updatebusinessinfo0(HttpContext context) { string data = "{\"status\":0}";// && !String.IsNullOrEmpty(context.Request["Province"]) if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["clsid"]) && !String.IsNullOrEmpty(context.Request["name"]) && !String.IsNullOrEmpty(context.Request["tel"]) && !String.IsNullOrEmpty(context.Request["number"]) && !String.IsNullOrEmpty(context.Request["image0"]) && !String.IsNullOrEmpty(context.Request["image1"]) && !String.IsNullOrEmpty(context.Request["image2"]) && !String.IsNullOrEmpty(context.Request["image3"]) && !String.IsNullOrEmpty(context.Request["image4"]) && !String.IsNullOrEmpty(context.Request["province"]) && !String.IsNullOrEmpty(context.Request["city"]) && !String.IsNullOrEmpty(context.Request["address"]) && !String.IsNullOrEmpty(context.Request["longitude"]) && !String.IsNullOrEmpty(context.Request["latitude"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()).Trim(); int clsid = Convert.ToInt32(context.Request["clsid"].ToString()); string clsname = ""; if (clsid > 0) { clsname = daoCategory.Getzd("C_NAME", "C_ID=" + clsid).ToString(); } string name = HttpUtility.UrlDecode(context.Request["name"].ToString()).Trim(); string tel = HttpUtility.UrlDecode(context.Request["tel"].ToString()).Trim(); string number = HttpUtility.UrlDecode(context.Request["number"].ToString()).Trim(); string image0 = HttpUtility.UrlDecode(context.Request["image0"].ToString()).Trim(); string image1 = HttpUtility.UrlDecode(context.Request["image1"].ToString()).Trim(); string image2 = HttpUtility.UrlDecode(context.Request["image2"].ToString()).Trim(); string image3 = HttpUtility.UrlDecode(context.Request["image3"].ToString()).Trim(); string image4 = HttpUtility.UrlDecode(context.Request["image4"].ToString()).Trim(); string image7 = ""; if (!String.IsNullOrEmpty(context.Request["image7"])) { image7 = HttpUtility.UrlDecode(context.Request["image7"].ToString()).Trim(); } string province = HttpUtility.UrlDecode(context.Request["province"].ToString()).Trim(); string city = HttpUtility.UrlDecode(context.Request["city"].ToString()).Trim(); string county = ""; if (!String.IsNullOrEmpty(context.Request["county"])) { county = HttpUtility.UrlDecode(context.Request["county"].ToString()).Trim(); } string address = HttpUtility.UrlDecode(context.Request["address"].ToString()).Trim(); string longitude = HttpUtility.UrlDecode(context.Request["longitude"].ToString()).Trim(); string latitude = HttpUtility.UrlDecode(context.Request["latitude"].ToString()).Trim(); string fwbody = ""; if (!String.IsNullOrEmpty(context.Request["fwbody"])) { fwbody = HttpUtility.UrlDecode(context.Request["fwbody"].ToString()).Trim(); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (b) { if (model.uLevel30 == 1) { b = false; data = "{\"status\":0,\"msg\":\"线上门店申请正在审核中!\"}"; } } if (b) { if (model.uLevel30 == 2) { b = false; data = "{\"status\":0,\"msg\":\"线上门店申请已通过!\"}"; } } if (b) { Mtxfw.Model.business_info bmodel = new Mtxfw.Model.business_info(); bmodel.CompanyName = name; bmodel.ClsID = clsid; bmodel.ClsnName = clsname; bmodel.ClsID2 = 0; bmodel.ClsnName2 = ""; bmodel.frname = ""; bmodel.fridcard = ""; bmodel.email = ""; bmodel.Province = province; bmodel.City = city; bmodel.County = county; bmodel.Industry = number; bmodel.Introduction2 = (image3.IndexOf("http") == -1 ? config.webUrl : "") + image3;//身份证正面 bmodel.Introduction3 = (image4.IndexOf("http") == -1 ? config.webUrl : "") + image4;//身份证背面 bmodel.picture = (image0.IndexOf("http") == -1 ? config.webUrl : "") + image0; bmodel.BusinessRange = fwbody;//服务内容 bmodel.Businesslicense = (image1.IndexOf("http") == -1 ? config.webUrl : "") + image1;//营业执照 bmodel.TaxRegistration = (image2.IndexOf("http") == -1 ? config.webUrl : "") + image2;//生产许可证 bmodel.Companyaddress = address; bmodel.InternetSite = ""; bmodel.Busroutes = ""; bmodel.Introduction = ""; bmodel.ContactPeople = model.RealName;//联系人 bmodel.ContactPhone = tel;//联系电话 bmodel.ApplyTime = DateTime.Now; bmodel.CompanyId = "0"; bmodel.Discount = image7; bmodel.xcoo = latitude; bmodel.ycoo = longitude; bmodel.utype = "2"; bmodel.gtype = gtype; bmodel.seef = 0; bmodel.ApplyState = ""; bmodel.UserId = model.Id; daobusiness.Add(bmodel); daoUser.UpdateuLevel("uLevel30", 1, model.Id); model.uLevel30 = 1; Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "申请线上门店"; logmodel.UType = 2; logmodel.gtype = model.gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"提交成功!\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取消息列表----------------------------------------------------------------------------------------- /// /// 获取消息列表 /// protected string getsysmsglist(HttpContext context) { string data = "{\"status\":0}"; string strdata = ""; string strsql = "parentid=30"; string strsql2 = "b.parentid=30"; string groupby = " group by wtype"; string strOrder = "wtype asc"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); strsql += " And (receiverid=" + userId + " Or receiverid=0)"; strsql2 += " And (b.receiverid=" + userId + " Or b.receiverid=0)"; } else { strsql += " And receiverid=0"; strsql2 += " And b.receiverid=0"; } int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } strsql2 += " And b.wtype=tbl2.wtype and DateDiff(day,b.addtime,getdate())<=30"; string Ids2 = ""; if (!String.IsNullOrEmpty(context.Request["Ids2"])) { Ids2 = HttpUtility.UrlDecode(context.Request["Ids2"].ToString()); strsql2 += " And charindex(','+Convert(varchar(50),b.id)+',','" + Ids2 + "')=0"; } Int32 Recount = 0; DataSet ds = daoArt.GetDataSet(groupby, strOrder, "id,ACount,wtype", "max(id) as id,wtype,(select count(b.id) from Article b where " + strsql2 + ") as ACount", strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int ACount = Convert.ToInt32(Dr["ACount"]); Mtxfw.Model.Article amodel = daoArt.GetModel(id); if (amodel != null) { string title = amodel.Title; string content = amodel.Content; string link = amodel.Paths; string img = amodel.Author; string addtime = amodel.AddTime.ToString(); if (img != "") { if (img.IndexOf("image/news-ico.png") == -1) { Mtxfw.Utility.Common.GetCoverPic(img.Split('|')[0], "40x40", "cut"); } } strdata += "{\"id\":\"" + id + "\",\"ACount\":\"" + ACount + "\",\"title\":\"" + title + "\",\"img\":\"" + img + "\",\"link\":\"" + link + "\",\"content\":\"" + content.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"createTime\":\"" + addtime + "\"}"; strdata += ","; i += 1; } } } ds.Clear(); if (strdata != "") { strdata = strdata.Substring(0, strdata.Length - 1); } data = "{\"status\":1,\"data\":[" + strdata + "]}"; return data; } #endregion #region //获取资讯中心列表----------------------------------------------------------------------------------------- /// /// 获取资讯中心列表 /// protected string getnewslist(HttpContext context) { string data = "{\"status\":0}"; bool ifre = true; if (!String.IsNullOrEmpty(context.Request["ReDataMM"])) { if (context.Request["ReDataMM"].ToString() != config.ReDataMM) { ifre = false; } } if (ifre) { if (!String.IsNullOrEmpty(context.Request["t"]) && ifre) { int t = 0; if (context.Request["t"].ToString() != "[object CustomEvent]") { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["t"].ToString(), @"^-?\d+$")) { t = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["t"].ToString())); } } int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["e"].ToString())); } } string strdata = ""; string strsql = "gtype=0 and parentid=17"; if (t == 2) { strsql += " And CategoryId='2'"; } else if (t == 1) { strsql += " And CategoryId='1'"; } else { strsql += " And CategoryId='0'"; } if (e == 1) { strsql += " And KeyWords<>''"; } string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["Start"].ToString(), @"^-?\d+$")) { Start = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Start"].ToString()))); } } Int32 Recount = 0; DataSet ds = daoArt.GetDataSet(groupby, strOrder, "id,hasRead,title,KeyWords,content,content2,Author,addtime", "", strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int hasRead = Convert.ToInt32(Dr["hasRead"]); string title = Dr["title"].ToString(); string content = Dr["content"].ToString(); if (e == 1) { title = Dr["KeyWords"].ToString(); content = Dr["content2"].ToString(); } string addtime = Dr["addtime"].ToString(); string addtime2 = Dr["addtime"].ToString(); TimeSpan ts1, ts2, ts; ts1 = new TimeSpan(Convert.ToDateTime(addtime).Ticks); ts2 = new TimeSpan(DateTime.Now.Ticks); ts = ts1.Subtract(ts2).Duration(); Int64 sjc = (ts.Days * 24 * 3600 + ts.Hours * 3600 + ts.Minutes * 60 + ts.Seconds); if (ts.Days > 0) { addtime = Convert.ToDateTime(addtime).ToString("yyyy-MM-dd"); } else { if (ts.Hours > 0) { addtime = ts.Hours + "小时前"; } else { if (ts.Minutes > 0) { addtime = ts.Minutes + "分钟前"; } else { addtime = ts.Seconds + "秒前"; } } } string pic = Dr["Author"].ToString(); strdata += "{\"id\":\"" + id + "\",\"title\":\"" + title + "\",\"pic\":\"" + (pic.IndexOf("http") != -1 ? pic: config.webUrl + Mtxfw.Utility.Common.GetCoverPic(pic.Split('|')[0], "720x360", "cut")) + "\",\"content\":\"" + Mtxfw.Utility.Common.CnCutString(Mtxfw.Utility.Common.CIntro(content), 60, "...") + "\",\"createTime\":\"" + addtime + "\",\"createTime2\":\"" + Convert.ToDateTime(addtime2).ToString("MM-dd") + "\""; strdata += "}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } } return data; } #endregion #region //获取优选专题列表----------------------------------------------------------------------------------------- /// /// 获取优选专题列表 /// protected string getarticlelist(HttpContext context) { string data = "{\"status\":0}"; int t = 0; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["e"].ToString())); } } string strdata = ""; string strsql = "gtype=" + gtype + " and parentid=17 And Seef=1"; if (e == 1) { strsql += " And KeyWords<>''"; } string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Start"].ToString()))); } Int32 Recount = 0; DataSet ds = daoArt.GetDataSet(groupby, strOrder, "id,hasRead,title,KeyWords,content,content2,Author,addtime", "", strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int hasRead = Convert.ToInt32(Dr["hasRead"]); string title = Dr["title"].ToString(); string content = Dr["content"].ToString(); if (e == 1) { title = Dr["KeyWords"].ToString(); content = Dr["content2"].ToString(); } string addtime = Dr["addtime"].ToString(); string addtime2 = Dr["addtime"].ToString(); TimeSpan ts1, ts2, ts; ts1 = new TimeSpan(Convert.ToDateTime(addtime).Ticks); ts2 = new TimeSpan(DateTime.Now.Ticks); ts = ts1.Subtract(ts2).Duration(); Int64 sjc = (ts.Days * 24 * 3600 + ts.Hours * 3600 + ts.Minutes * 60 + ts.Seconds); if (ts.Days > 0) { addtime = Convert.ToDateTime(addtime).ToString("yyyy-MM-dd"); } else { if (ts.Hours > 0) { addtime = ts.Hours + "小时前"; } else { if (ts.Minutes > 0) { addtime = ts.Minutes + "分钟前"; } else { addtime = ts.Seconds + "秒前"; } } } string pic = Dr["Author"].ToString(); strdata += "{\"id\":\"" + id + "\",\"title\":\"" + title + "\",\"pic\":\"" + (pic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(pic.Split('|')[0], "720x360", "cut") : "") + "\",\"content\":\"" + Mtxfw.Utility.Common.CnCutString(Mtxfw.Utility.Common.CIntro(content), 60, "...") + "\",\"createTime\":\"" + addtime + "\",\"createTime2\":\"" + Convert.ToDateTime(addtime2).ToString("MM-dd") + "\""; strdata += "}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; return data; } #endregion #region //获取观看视频列表----------------------------------------------------------------------------------------- /// /// 获取观看视频列表 /// protected string getvideolist(HttpContext context) { string data = "{\"status\":0}"; int videoid = 0; if (!String.IsNullOrEmpty(context.Request["videoid"])) { if (context.Request["videoid"].ToString() != "[object CustomEvent]") { videoid = Convert.ToInt32(context.Request["videoid"].ToString()); } } string strdata = ""; string strsql = "gtype=" + gtype + " and parentid=29 And Seef=0"; if (videoid > 0) { DataSet dss = daoArt.GetList1("id,wtype,wtype2,title,Paths,Author,addtime", "id=" + videoid); strsql += " And id<>" + videoid; if (dss.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Drr in dss.Tables[0].Rows) { int id = Convert.ToInt32(Drr["id"]); int wtype = Convert.ToInt32(Drr["wtype"]); int wtype2 = Convert.ToInt32(Drr["wtype2"]); string title = Drr["title"].ToString(); string Paths = Drr["Paths"].ToString(); string addtime = Drr["addtime"].ToString(); TimeSpan ts1, ts2, ts; ts1 = new TimeSpan(Convert.ToDateTime(addtime).Ticks); ts2 = new TimeSpan(DateTime.Now.Ticks); ts = ts1.Subtract(ts2).Duration(); Int64 sjc = (ts.Days * 24 * 3600 + ts.Hours * 3600 + ts.Minutes * 60 + ts.Seconds); if (ts.Days > 0) { addtime = Convert.ToDateTime(addtime).ToString("yyyy-MM-dd"); } else { if (ts.Hours > 0) { addtime = ts.Hours + "小时前"; } else { if (ts.Minutes > 0) { addtime = ts.Minutes + "分钟前"; } else { addtime = ts.Seconds + "秒前"; } } } string pic = Drr["Author"].ToString(); strdata += "{\"id\":\"" + id + "\",\"orders\":\"" + wtype + "\",\"orders2\":\"" + wtype2 + "\",\"title\":\"" + title + "\",\"video\":\"" + Mtxfw.Utility.Common.cfileurl(Paths) + "\",\"pic\":\"" + (pic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(pic.Split('|')[0], "460x720", "cut") : "") + "\",\"createTime\":\"" + addtime + "\",\"dianzan\":0"; strdata += "},"; i += 1; } } dss.Clear(); } string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daoArt.GetDataSet(groupby, strOrder, "id,wtype,wtype2,title,Paths,Author,addtime", "", strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int wtype = Convert.ToInt32(Dr["wtype"]); int wtype2 = Convert.ToInt32(Dr["wtype2"]); string title = Dr["title"].ToString(); string Paths = Dr["Paths"].ToString(); string addtime = Dr["addtime"].ToString(); TimeSpan ts1, ts2, ts; ts1 = new TimeSpan(Convert.ToDateTime(addtime).Ticks); ts2 = new TimeSpan(DateTime.Now.Ticks); ts = ts1.Subtract(ts2).Duration(); Int64 sjc = (ts.Days * 24 * 3600 + ts.Hours * 3600 + ts.Minutes * 60 + ts.Seconds); if (ts.Days > 0) { addtime = Convert.ToDateTime(addtime).ToString("yyyy-MM-dd"); } else { if (ts.Hours > 0) { addtime = ts.Hours + "小时前"; } else { if (ts.Minutes > 0) { addtime = ts.Minutes + "分钟前"; } else { addtime = ts.Seconds + "秒前"; } } } string pic = Dr["Author"].ToString(); strdata += "{\"id\":\"" + id + "\",\"orders\":\"" + wtype + "\",\"orders2\":\"" + wtype2 + "\",\"title\":\"" + title + "\",\"video\":\"" + Mtxfw.Utility.Common.cfileurl(Paths) + "\",\"pic\":\"" + (pic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(pic.Split('|')[0], "460x720", "cut") : "") + "\",\"createTime\":\"" + addtime + "\",\"dianzan\":0"; strdata += "}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); int userId = 0, tguid = 0; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { tguid = Mtxfw.Utility.Security.encrypt(umodel.Id); } } } data = "{\"status\":1,\"seconds\":\"" + config.webMoney16 + "\",\"tguid\":\"" + tguid + "\",\"data\":[" + strdata + "]}"; return data; } #endregion #region //点赞或观看视频----------------------------------------------------------------------------------------- /// /// 点赞或观看视频 /// protected string kvideo(HttpContext context) { string data = "{\"status\":0}"; int videoid = 0; if (!String.IsNullOrEmpty(context.Request["t"]) && !String.IsNullOrEmpty(context.Request["videoid"])) { int t = Convert.ToInt32(context.Request["t"].ToString()); videoid = Convert.ToInt32(context.Request["videoid"].ToString()); Mtxfw.Model.Article model = daoArt.GetModel(videoid); if (model != null) { if (t == 1) { daoArt.UpdateuSel0("wtype2", 1, model.id); model.wtype2 += 1; } else { daoArt.UpdateuSel0("wtype", 1, model.id); model.wtype += 1; } data = "{\"status\":1,\"orders\":\"" + model.wtype + "\",\"orders2\":\"" + model.wtype2 + "\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } return data; } #endregion #region //获取发图素材列表----------------------------------------------------------------------------------------- /// /// 获取发图素材列表 /// protected string getftsclist(HttpContext context) { string data = "{\"status\":0}"; string strdata = ""; string strsql = "gtype=0"; strsql += " and parentid=9"; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.Article().GetDataSet(groupby, strOrder, "id,hasRead,title,Content2,Author,Paths,addtime", "", strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int hasRead = Convert.ToInt32(Dr["hasRead"]); string title = Dr["title"].ToString(); string addtime = Dr["addtime"].ToString(); string pic = Dr["Author"].ToString(); if (pic.IndexOf("http") == -1) { pic = Mtxfw.Utility.Common.GetCoverPic(pic.Split('|')[0], "220x220", "cut"); } else { pic = pic + "?imageView2/2/w/220/h/220/q/100"; } strdata += "{\"id\":\"" + id + "\",\"title\":\"" + title + "\",\"pic\":\"" + pic + "\",\"createTime\":\"" + addtime + "\""; strdata += "}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; return data; } #endregion #region //获取健康知识列表----------------------------------------------------------------------------------------- /// /// 获取健康知识列表 /// protected string getjkzslist(HttpContext context) { string data = "{\"status\":0}"; string strdata = ""; string strsql = "gtype=0"; strsql += " and parentid=8"; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.Article().GetDataSet(groupby, strOrder, "id,hasRead,title,Content2,Author,Paths,addtime", "", strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int hasRead = Convert.ToInt32(Dr["hasRead"]); string title = Dr["title"].ToString(); string addtime = Dr["addtime"].ToString(); string pic = Dr["Author"].ToString(); if (pic.IndexOf("http") == -1) { pic = Mtxfw.Utility.Common.GetCoverPic(pic.Split('|')[0], "220x220", "cut"); } else { pic = pic + "?imageView2/2/w/220/h/220/q/100"; } strdata += "{\"id\":\"" + id + "\",\"title\":\"" + title + "\",\"pic\":\"" + pic + "\",\"createTime\":\"" + addtime + "\""; strdata += "}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; return data; } #endregion #region //获取商学院数据----------------------------------------------------------------------------------------- /// /// 获取商学院数据 /// protected string getxsxtlist(HttpContext context) { string data = "{\"status\":0}"; string strdata = "\"xsxtlb\":["; DataSet ds = new Mtxfw.DAL.user_Goods_lb().GetList("gtype=" + gtype + " and utype=0 Order By LBLinkID"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int LBid = Convert.ToInt32(Dr["id"]); string LBName = Dr["LBName"].ToString(); string strsql = "gtype=0 and parentid=19 And Seef=0"; strsql += " And CategoryId='" + LBid + "'"; DataSet dss = new Mtxfw.DAL.Article().GetList1("top 6 id,hasRead,title,Content2,Author,Paths,addtime", "" + strsql + " order By LinkID desc"); if (dss.Tables[0].Rows.Count > 0) { strdata += "{\"id\":\"" + LBid + "\",\"LBName\":\"" + LBName + "\""; strdata += ",\"data\":["; int i2 = 0; foreach (System.Data.DataRow Drr in dss.Tables[0].Rows) { int id = Convert.ToInt32(Drr["id"]); int hasRead = Convert.ToInt32(Drr["hasRead"]); string title = Drr["title"].ToString(); string content = Drr["Content2"].ToString(); string addtime = Drr["addtime"].ToString(); string pic = Drr["Author"].ToString().Split('|')[0]; string video = Drr["Paths"].ToString(); if (pic != "") { pic = Mtxfw.Utility.Common.cminimage0(pic); } strdata += "{\"id\":\"" + id + "\",\"title\":\"" + title + "\",\"pic\":\"" + pic + "\",\"video\":\"" + video + "\",\"content\":\"" + Mtxfw.Utility.Common.CnCutString(Mtxfw.Utility.Common.CIntro(content), 60, "...") + "\",\"createTime\":\"" + addtime + "\""; strdata += "}"; if (i2 != dss.Tables[0].Rows.Count - 1) { strdata += ","; } i2 += 1; } strdata += "]"; strdata += "},"; i += 1; } dss.Clear(); } } ds.Clear(); if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; string strtp = ""; ds = new Mtxfw.DAL.user_Goods().GetList1("top 1 id,GoodsName,GoodsPic,addtime", "gtype=" + gtype + " and utype=6 Order By addtime Desc"); if (ds.Tables[0].Rows.Count > 0) { string GoodsPic = ds.Tables[0].Rows[0]["GoodsPic"].ToString(); if (GoodsPic != "") { strtp = (GoodsPic.IndexOf("http") != -1 ? GoodsPic : Mtxfw.Utility.Common.GetCoverPic(GoodsPic, "720x360", "cut")); } } ds.Clear(); data = "{\"status\":1,\"strtp\":\"" + strtp + "\"," + strdata + "}"; return data; } #endregion #region //获取新闻公告详情----------------------------------------------------------------------------------------- /// /// 获取新闻公告详情 /// protected string getnewdetail(HttpContext context) { string data = "{\"status\":0}"; bool ifre = true; if (!String.IsNullOrEmpty(context.Request["ReDataMM"])) { if (context.Request["ReDataMM"].ToString() != config.ReDataMM) { ifre = false; } } if (ifre) { if (!String.IsNullOrEmpty(context.Request["id"]) && ifre) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["id"].ToString(), @"^-?\d+$")) { int id = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["id"].ToString())); int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } Mtxfw.Model.Article model = daoArt.GetModel(id); if (model != null) { string title = model.Title; string video = model.Paths; string content = model.Content; if (video != "") { video = new Admin_Member_livefile().cvideo(video); } if (e == 1) { title = model.KeyWords; content = model.Content2; } data = "{\"status\":1,\"title\":\"" + title + "\",\"type\":\"" + model.ParentID + "\",\"ltype\":\"" + model.ltype + "\",\"video\":\"" + video + "\",\"content\":\"" + Mtxfw.Utility.Common.ReplaceString(content) + "\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } } return data; } #endregion #region //发送聊天信息----------------------------------------------------------------------------------------- /// /// 发送聊天信息 /// protected string sendmsg(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); bool b = true; int ttype = 0, t = 0; if (!String.IsNullOrEmpty(context.Request["ttype"])) { ttype = Convert.ToInt32(context.Request["ttype"].ToString()); } else { b = false; data = "{\"status\":0,\"msg\":\"参数不能为空0!\"}"; } if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } else { b = false; data = "{\"status\":0,\"msg\":\"参数不能为空1!\"}"; } string body = ""; if (!String.IsNullOrEmpty(context.Request["body"])) { body = HttpUtility.UrlDecode(context.Request["body"].ToString()); } else { b = false; data = "{\"status\":0,\"msg\":\"参数不能为空2!\"}"; } int receiverid = 0; if (!String.IsNullOrEmpty(context.Request["receiverid"])) { receiverid = Convert.ToInt32(context.Request["receiverid"].ToString()); } if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { //string realname = (model.Sex == "男" ? "Mr." : "Miss.") + (model.RealName == "" ? "" : model.RealName.Substring(0, 1)); int m = 0; if (t == 1 || t == 3) { try { m = Mtxfw.Utility.Common.GetDurationByShellClass(context.Server.MapPath(body)); } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/ShellClass.txt", err.ToString()); } } Mtxfw.Model.Article Amodel = new Mtxfw.Model.Article(); Amodel.senderid = model.Id; Amodel.receiverid = receiverid; Amodel.Title = (ttype == 0 ? "客服信息" : ttype == 1 ? "私聊信息" : "群聊信息"); Amodel.ParentID = 21; Amodel.CategoryId = t.ToString();//t=0 文本信息 1语音信息 2图片信息 3视频信息 4位置 Amodel.AddTime = DateTime.Now; Amodel.Author = ""; Amodel.Content = body; Amodel.Paths = ""; Amodel.Content2 = ""; Amodel.Paths2 = ""; Amodel.KeyWords = ""; Amodel.media_id = ""; Amodel.thumb_media_id = ""; Amodel.wtype = ttype;//ttype=0 客服信息 1私聊信息 2群聊信息 Amodel.wtype2 = m;//语音或视频多少秒 Amodel.LinkID = 0; Amodel.Seef = 0; Amodel.gtype = model.gtype; int artid = new DAL.Article().Add(Amodel); Mtxfw.Model.user_info umodel = daoUser.GetModel(Amodel.receiverid); if (umodel != null) { Mtxfw.Model.Article amodel = new Mtxfw.Model.Article(); amodel.senderid = model.Id; amodel.receiverid = umodel.Id; amodel.Title = "客服信息"; amodel.ParentID = 30; amodel.CategoryId = artid.ToString(); amodel.AddTime = DateTime.Now; amodel.Author = "../image/chat-ico.png"; amodel.Content = (t == 1 ? "语音信息" : (t == 2 ? "图片信息" : (t == 3 ? "视频信息" : (t == 4 ? "位置" : body)))); amodel.Paths = "kf.html"; amodel.Content2 = ""; amodel.Paths2 = ""; amodel.KeyWords = ""; amodel.media_id = ""; amodel.thumb_media_id = ""; amodel.wtype = 9; amodel.wtype2 = 0; amodel.LinkID = 1; amodel.Seef = 0; amodel.gtype = gtype; daoArt.Add(amodel); } data = "{\"status\":1,\"msg\":\"提交成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取聊天列表----------------------------------------------------------------------------------------- /// /// 获取聊天列表 /// protected string getchatlist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["ttype"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int ttype = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["ttype"].ToString())); int receiverid = 0; if (!String.IsNullOrEmpty(context.Request["receiverid"])) { receiverid = Convert.ToInt32(context.Request["receiverid"].ToString()); } int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime asc,id asc"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("gtype=" + gtype + " and ParentID=21 and wtype=" + ttype + ""); sb.Append(" And ((senderid=" + umodel.Id + " And receiverid=" + receiverid + " And LinkID=0) Or (senderid=" + receiverid + " And receiverid=" + umodel.Id + " And seef=0))"); String SJ = context.Request["startsj"]; if (!String.IsNullOrEmpty(SJ)) { sb.Append("and addtime 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int CategoryId = Convert.ToInt32(Dr["CategoryId"]); int seconds = Convert.ToInt32(Dr["wtype2"]); int userid = Convert.ToInt32(Dr["senderid"]); int areceiverid = Convert.ToInt32(Dr["receiverid"]); int hasRead = Convert.ToInt32(Dr["hasRead"]); string content = Dr["content"].ToString(); string addtime = Dr["addtime"].ToString(); string aRealName = Dr["RealName"].ToString(); string UserPic = Dr["UserPic"].ToString().Trim(); if (CategoryId == 0) { Mtxfw.Utility.emojiconsConfig econfig = new Mtxfw.Utility.emojiconsConfig(); string pattern2 = @"\[(.*?)\]"; Regex R2 = new Regex(pattern2); Match M2 = R2.Match(content); while (M2.Success) { string group = M2.Groups[1].ToString(); string gdata = econfig.getData("[" + group + "]"); if (group != "" && gdata != "") { content = content.Replace("[" + group + "]", ""); } M2 = M2.NextMatch(); } } string minpic = ""; if (CategoryId == 2) { string FileType = content.Substring(content.LastIndexOf(".")).ToLower(); if (FileType != ".gif") { minpic = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(content, "220x220", "cut"); } else { minpic = config.webUrl + content; } content = config.webUrl + content; } strdata += "{\"id\":\"" + id + "\",\"userid\":\"" + userid + "\",\"name\":\"" + aRealName + "\",\"avatar\":\"" + (userid == 0 ? "../../images/kfserver.png" : (UserPic == "" ? "" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(UserPic, "40x40", "cut"))) + "\",\"CategoryId\":\"" + CategoryId + "\",\"content\":\"" + (CategoryId == 0 ? content.Replace("\n", "").Replace("\r", "") : content) + "\",\"addtime\":\"" + addtime + "\",\"seconds\":\"" + seconds + "\",\"minpic\":\"" + minpic + "\",\"isplayed\":\"" + hasRead + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //删除聊天信息----------------------------------------------------------------------------------------- /// /// 删除聊天信息 /// protected string delchat(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["delids"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string delids = context.Request["delids"].ToString(); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string[] adelids = delids.Split(','); foreach (string str in adelids) { if (str != "") { Mtxfw.Model.Article Amodel = daoArt.GetModel(Convert.ToInt32(str)); if (Amodel.senderid == model.Id || Amodel.receiverid == model.Id) { if (Amodel.receiverid == model.Id) { daoArt.UpdateuSel("Seef", 1, Amodel.id); daoArt.Delete("gtype=" + gtype + " and ParentID=30 And wtype=7 And receiverid=" + model.Id + " And CategoryId='" + Amodel.id + "'"); } else { daoArt.UpdateuSel("LinkID", 1, Amodel.id); } } } } data = "{\"status\":1,\"msg\":\"删除成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取VIP数据----------------------------------------------------------------------------------------- /// /// 获取VIP数据 /// protected string getvipdata(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string strdata = ""; DataSet ds = daoGoods.GetList1("id,GoodsName,GoodsPrices,GoodsPrices0,GoodsPrices1", "gtype=" + gtype + " and utype=0 Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string GoodsName = Dr["GoodsName"].ToString(); string GoodsPrices = Convert.ToDouble(Dr["GoodsPrices"]).ToString("0.####"); string GoodsPrices0 = Convert.ToDouble(Dr["GoodsPrices0"]).ToString("0.####"); string GoodsPrices1 = (Convert.ToDouble(Dr["GoodsPrices0"]) / Convert.ToDouble(Dr["GoodsPrices1"])).ToString("0.####"); strdata += "{\"id\":\"" + id + "\",\"title\":\"" + GoodsName + "\",\"price0\":\"" + GoodsPrices + "\",\"price\":\"" + GoodsPrices0 + "\",\"price1\":\"" + GoodsPrices1 + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); string msg = "您暂时还没有开通VIP!"; int vipqx = umodel.uLevel4; int IFAuto = 0; if (umodel.uLevel4 == 1) { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); DateTime dt0 = Convert.ToDateTime(umodel.RegTime1.ToString("yyyy-MM-dd HH:mm:ss")); if (dt > dt0) { msg = "您的VIP权限已过期!"; vipqx = 2; } else { msg = "VIP有效期至" + umodel.RegTime1.ToString("yyyy-MM-dd HH:mm") + ""; IFAuto = umodel.uLevel20; } } data = "{\"status\":1,\"vipqx\":\"" + vipqx + "\",\"msg\":\"" + msg + "\",\"IFAuto\":" + IFAuto + ",\"IFYGM\":" + umodel.uLevel14 + ",\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } return data; } #endregion #region //购买VIP----------------------------------------------------------------------------------------- /// /// 购买VIP /// protected string gmvip(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["LoginId"].ToString())); int id = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["id"].ToString()))); bool b = true; int zftype = 0; if (!String.IsNullOrEmpty(context.Request["zftype"])) { zftype = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["zftype"].ToString()))); } if (b) { Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Mtxfw.Model.user_Goods gmodel = daoGoods.GetModel(id); if (gmodel != null) { if (zftype == 2) { if (Convert.ToDouble(gmodel.GoodsPrices0.ToString("f2")) > Convert.ToDouble((umodel.umoney - umodel.umoney17).ToString("f2"))) { b = false; data = "{\"status\":0,\"msg\":\"余额不足!\"}"; } } if (b) { string openid = umodel.openid; if (!String.IsNullOrEmpty(context.Request["openid"])) { openid = HttpUtility.UrlDecode(context.Request["openid"].ToString()); } DateTime dt = DateTime.Now; string PayID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo); string body = "购买VIP套餐" + gmodel.GoodsName; Int64 ResultId = 0; string timestamp = ""; string nonceStr = ""; string package = ""; string paySign = ""; Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = gmodel.GoodsPrices; ModelResults.b1 = gmodel.GoodsPrices0; ModelResults.b2 = gmodel.GoodsPrices1; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = 0; ModelResults.conent = body; ModelResults.Totalmoney = gmodel.GoodsPrices0; ModelResults.MemberId = umodel.Id; ModelResults.UserId = 3; ModelResults.ListNumber = ""; ModelResults.Managers = gmodel.GoodsName; ModelResults.Seef = 0; ModelResults.utype = "4"; ModelResults.addtime = dt; ModelResults.gtype = gtype; ResultId = daoResults.Add(ModelResults); Int64 ResultId0 = 0; if (zftype == 2) { Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -gmodel.GoodsPrices0; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney - umodel.umoney17 - gmodel.GoodsPrices0); mjl2.addtime = dt; mjl2.BZContent = body; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 1; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; new Mtxfw.DAL.user_Results_jl2().Add(mjl2); //减少买家余额 new Mtxfw.DAL.user_info().UpdateMoney("umoney17", gmodel.GoodsPrices0, umodel.Id); daoResults.UpdateSeef(1, dt, ResultId); DateTime regtime1 = DateTime.Now.AddDays(gmodel.GoodsPrices1); if (umodel.uLevel4 == 1) { regtime1 = umodel.RegTime1.AddDays(gmodel.GoodsPrices1); } daoUser.UpdateuLevel("uLevel4", 1, umodel.Id); daoUser.UpdatePassword("regtime1", regtime1.ToString(), umodel.Id); daoUser.UpdateuLevel("uLevel20", 1, umodel.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = body; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); } else { Double JFZSubTotal = Convert.ToDouble(gmodel.GoodsPrices0.ToString("f2")); ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = JFZSubTotal; ModelResults.b1 = 0; ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = 1; ModelResults.conent = body; ModelResults.Totalmoney = JFZSubTotal; ModelResults.MemberId = umodel.Id; ModelResults.UserId = 3; ModelResults.ListNumber = PayID; ModelResults.Managers = "5"; ModelResults.Seef = 0; ModelResults.utype = "2"; ModelResults.addtime = dt; ModelResults.gtype = gtype; ResultId0 = daoResults.Add(ModelResults); daoResults.UpdateOrderIds(ResultId.ToString(), ResultId0); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = body + "去付款"; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); Mtxfw.Utility.Interface_WxPay.Get_RequestHtml0(config, context, openid, PayID, Convert.ToDecimal(JFZSubTotal), ref timestamp, ref nonceStr, ref package, ref paySign, body, "card_store"); //Mtxfw.Utility.Common.WriteHtml("/weixin/reResult.txt", timestamp + "|" + nonceStr + "|" + package + "|" + paySign); } data = "{\"status\":1,\"msg\":\"付款成功!\",\"ResultId\":\"" + ResultId0 + "\",\"timeStamp\":\"" + timestamp + "\",\"noncestr\":\"" + nonceStr + "\",\"package\":\"" + package + "\",\"paySign\":\"" + paySign + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取兑换码兑换VIP数据----------------------------------------------------------------------------------------- /// /// 获取兑换码兑换VIP数据 /// protected string getdhmdata(HttpContext context) { string data = "{\"status\":0}"; Mtxfw.Model.Article model = daoArt.GetModel(340); if (model != null) { string title = model.Title; string content = model.Content; data = "{\"status\":1,\"title\":\"" + title + "\",\"content\":\"" + content + "\"}"; } return data; } #endregion #region //兑换码兑换VIP----------------------------------------------------------------------------------------- /// /// 兑换码兑换VIP /// protected string dhvip(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["dhm"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); string dhm = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["dhm"].ToString())); bool b = true; if (b) { Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Mtxfw.Model.duihuanma dhmmodel = daodhm.GetModel(umodel.Id, dhm); if (dhmmodel != null) { if (dhmmodel.seef == 1) { b = false; data = "{\"status\":0,\"msg\":\"兑换码已使用,不可重复使用!\"}"; } if (b) { DateTime regtime1 = DateTime.Now.AddDays(dhmmodel.yxq); if (umodel.uLevel4 == 1) { regtime1 = umodel.RegTime1.AddDays(dhmmodel.yxq); } daoUser.UpdateuLevel("uLevel4", 1, umodel.Id); daoUser.UpdatePassword("regtime1", regtime1.ToString(), umodel.Id); daodhm.UpdateSeef("seef", 1, dhmmodel.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "兑换码兑换VIP"; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"兑换成功!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //启用\停用自动领取红包----------------------------------------------------------------------------------------- /// /// 启用\停用自动领取红包 /// protected string SetAutoHongBao(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["IFAuto"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["LoginId"].ToString())); int IFAuto = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["IFAuto"].ToString())); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["t"].ToString())); } bool b = true; if (IFAuto != 0 && IFAuto != 1) { b = false; data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } if (b) { Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { if (umodel.uLevel4 == 1) { if (IFAuto == 1) { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); DateTime dt0 = Convert.ToDateTime(umodel.RegTime1.ToString("yyyy-MM-dd HH:mm:ss")); if (dt > dt0) { b = false; data = "{\"status\":0,\"msg\":\"您的VIP权限已过期!\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"您还没有购买VIP套餐!\"}"; } if (umodel.uLevel23 == 1) { b = false; data = "{\"status\":0,\"msg\":\"请稍候,请不要重复点击!\"}"; } if (b) { if (t == 0) { daoUser.UpdateuLevel("uLevel23", 1, umodel.Id); daoUser.UpdateuLevel("uLevel20", IFAuto, umodel.Id); if (IFAuto == 1) { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string strsql = " and addtime>DateAdd(hour,-" + config.webMoney20 + ",'" + dt + "')"; DataSet ds = daoResults.GetList1("id,UserId,Totalmoney", "gtype=" + gtype + " and utype=8 And IFDelete=0 and seef=0 and MemberId=" + umodel.Id + strsql + " order by addtime"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int64 dID = Int64.Parse(Dr["id"].ToString()); Int32 UserId = Int32.Parse(Dr["UserId"].ToString()); Double umoney4 = Convert.ToDouble(Convert.ToDouble(Dr["Totalmoney"].ToString()).ToString("f2")); Double umoney41 = Convert.ToDouble(umodel.umoney41.ToString("f2")); Double SXumoney = 0.00; string selmoney = "umoney4", selmoney34 = "umoney34"; if (UserId == 1) { selmoney = "umoney5"; selmoney34 = "umoney35"; } daoResults.UpdateSeef(1, DateTime.Now, dID); if (UserId == 0) { if (umoney41 > 0.00) { Double Bzumoney = umoney4; if (Bzumoney > umoney41) { SXumoney = Convert.ToDouble((Bzumoney - umoney41).ToString("f2")); umoney4 = Convert.ToDouble(umoney41.ToString("f2")); } } } if (umoney4 > 0.00) { if (UserId == 0) { daoUser.UpdateMoney("umoney41", -umoney4, umodel.Id); } daoUser.UpdateMoney(selmoney34, umoney4, umodel.Id); daoUser.UpdateMoney2(selmoney, umoney4, umodel.Id); //Mtxfw.DAL.MemberStatistics.Statistics(DateTime.Now, umodel.Id, 0, 0, UserId, 0, (UserId == 0 ? 1 : 0), "来源"+ (UserId == 1?"团购":"新零售") + "红包奖励", gtype); } } } ds.Clear(); } daoUser.UpdateuLevel("uLevel23", 0, umodel.Id); } else { daoUser.UpdateuLevel("uLevel21", IFAuto, umodel.Id); } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = (t == 0 ? "启用" : "停用") + "自动领取红包"; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"操作成功!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //一键团购或一键领取红包----------------------------------------------------------------------------------------- /// /// 一键团购或一键领取红包 /// protected string ononekey(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["LoginId"].ToString())); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["t"].ToString())); } int t0 = 0; if (!String.IsNullOrEmpty(context.Request["t0"])) { t0 = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["t0"].ToString())); } int id = 0; if (!String.IsNullOrEmpty(context.Request["id"])) { id = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["id"].ToString())); } bool b = true; if (b) { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string mindt = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { if (t == 0) { if (umodel.uLevel23 == 1) { b = false; data = "{\"status\":0,\"msg\":\"请稍候,请不要重复点击!\"}"; } } if (b) { if (umodel.uLevel4 == 1) { DateTime dt0 = Convert.ToDateTime(umodel.RegTime1.ToString("yyyy-MM-dd HH:mm:ss")); if (dt > dt0) { b = false; data = "{\"status\":0,\"msg\":\"您的VIP权限已过期!\"}"; } } else { b = false; data = "{\"status\":0,\"msg\":\"您还没有购买VIP套餐!\"}"; } } if (t == 1) { if (b) { if (umodel.uLevel14 == 0) { b = false; data = "{\"status\":0,\"msg\":\"必须先购买新零售商品才能参与团购\"}"; } } if (b) { if (Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd ") + config.webMoney42) || Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd ") + config.webMoney41)) { b = false; data = "{\"status\":0,\"msg\":\"每天团购时间:" + config.webMoney42 + "至" + config.webMoney41 + "\"}"; } } if (b) { if (config.FHEnable3 == "1") { if (umodel.uLevel5 == 0) { b = false; data = "{\"status\":0,\"msg\":\"暂时不能团购\"}"; } } } } if (b) { if (t == 0) { daoUser.UpdateuLevel("uLevel23", 1, umodel.Id); string strsql = " and UserId=0"; if (t0 == 1) { strsql = " and UserId=1"; } strsql += " and addtime>DateAdd(hour,-" + config.webMoney20 + ",'" + dt + "')"; int ccount = 0; DataSet ds = daoResults.GetList1("id,Totalmoney,UserId", "gtype=" + gtype + " and utype=8 And IFDelete=0 and MemberId=" + umodel.Id + " and seef=0" + strsql + " order by addtime"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int64 dID = Int64.Parse(Dr["id"].ToString()); Int32 UserId = Int32.Parse(Dr["UserId"].ToString()); Double umoney4 = Convert.ToDouble(Convert.ToDouble(Dr["Totalmoney"].ToString()).ToString("f2")); Double umoney41 = Convert.ToDouble(umodel.umoney41.ToString("f2")); Double SXumoney = 0.00; string selmoney = "umoney4", selmoney34 = "umoney34"; if (UserId == 1) { selmoney = "umoney5"; selmoney34 = "umoney35"; } daoResults.UpdateSeef(1, DateTime.Now, dID); if (UserId == 0) { if (umoney41 > 0.00) { Double Bzumoney = umoney4; if (Bzumoney > umoney41) { SXumoney = Convert.ToDouble((Bzumoney - umoney41).ToString("f2")); umoney4 = Convert.ToDouble(umoney41.ToString("f2")); } } } if (umoney4 > 0.00) { if (UserId == 0) { daoUser.UpdateMoney("umoney41", -umoney4, umodel.Id); } daoUser.UpdateMoney(selmoney34, umoney4, umodel.Id); daoUser.UpdateMoney2(selmoney, umoney4, umodel.Id); //Mtxfw.DAL.MemberStatistics.Statistics(DateTime.Now, umodel.Id, 0, 0, UserId, 0, (UserId == 0 ? 1 : 0), "来源" + (UserId == 1 ? "团购" : "新零售") + "红包奖励", gtype); ccount += 1; } } } ds.Clear(); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "一键领取" + (t0 == 1 ? "团购" : "新零售") + "红包"; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); daoUser.UpdateuLevel("uLevel23", 0, umodel.Id); data = "{\"status\":1,\"msg\":\"成功领取" + ccount + "个红包!\"}"; } else { int ccount = 0; int yjptcount = umodel.uLevel24; if (yjptcount == 0) { int yptcount = umodel.uLevel25; int kptcount = (Convert.ToInt32(config.webMoney3) - yptcount); if (kptcount > 0) { Double ZTotalprice = 0.00; int pid = 0; string strzd = daoProduct.Getzd("p_id", "gtype=" + gtype + " and utype='6' And P_State=N'已处理' And IFDelete=0 and P_Id=" + id).ToString(); if (strzd != "") { pid = Convert.ToInt32(strzd); } string guigeid = new DAL.P_Guige().Getzd("G_ID", "G_PID=" + pid).ToString(); if (guigeid != "") { daoProduct.UpdateJiangLi(pid, kptcount); Double Totalprice = 0.00; string colors = ""; Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guigeid)); if (gmodel != null) { if (gmodel.G_Color != "") { colors = gmodel.G_Color.Split(',')[0]; } Totalprice = gmodel.G_JG; } ZTotalprice = Convert.ToDouble((Totalprice * 2).ToString("f2")); if (ZTotalprice <= Convert.ToDouble(umodel.umoney30.ToString("f2"))) { daoUser.UpdateuLevel("uLevel24", pid, umodel.Id); daoUser.UpdateuLevel0("uLevel25", 1, umodel.Id); Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -ZTotalprice; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney30 - ZTotalprice); mjl2.addtime = dt; mjl2.BZContent = "购买商品,总金额:" + ZTotalprice; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 2; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; new Mtxfw.DAL.user_Results_jl2().Add(mjl2); //减少买家余额 daoUser.UpdateMoney("umoney30", -ZTotalprice, umodel.Id); int UserID = umodel.Id, uLevel19 = umodel.uLevel19; Model.User_Errlog mo = new Model.User_Errlog(); mo.DLID = 0; mo.ErrType = "kptcount"; mo.addtime = DateTime.Now; mo.ErrBody = kptcount.ToString(); mo.ErrBody2 = UserID.ToString(); new DAL.User_Errlog().Add(mo); DataSet dss; string OID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo); Model.order_info Modelorder = new Model.order_info(); Modelorder.pid = pid; Modelorder.poid = 0; Modelorder.pcount = 0; Modelorder.ypcount = 0; Modelorder.addressid = 0; Modelorder.orderid = OID; Modelorder.Contactname = ""; Modelorder.Contacttel = ""; Modelorder.Province = ""; Modelorder.City = ""; Modelorder.County = ""; Modelorder.Address = ""; Modelorder.Zipcode = ""; Modelorder.Guests = ""; Modelorder.Totalprice = Totalprice; Modelorder.Totalprice0 = 0; Modelorder.Totalprice1 = 0; Modelorder.Totalprice2 = 0; Modelorder.Totalprice3 = 0; Modelorder.Totalprice4 = 0; Modelorder.Totalprice5 = 0; Modelorder.Totalnum = 1; Modelorder.O_Submit = "1"; Modelorder.O_yhj = ""; Modelorder.UserID = UserID; Modelorder.MemberId = 0; Modelorder.selcolor = ""; Modelorder.guige = ""; Modelorder.utype = "1"; Modelorder.ttype = 6; Modelorder.ptype = 1; Modelorder.ptgroup = 0; Modelorder.ifxnhy = 0; Modelorder.ypznum = uLevel19; Modelorder.ifxhpt = 1; Modelorder.peitype = 0; Modelorder.gtype = gtype; int poid = new Mtxfw.DAL.order_info().Add(Modelorder); daoorder.Updateifbhzshy(1, poid); Model.order_product_info opmodel = new Model.order_product_info(); opmodel.pid = pid; opmodel.orderid = poid; opmodel.selcolor = colors; opmodel.guige = guigeid; opmodel.DJprice = Totalprice; opmodel.Totalprice = Totalprice; opmodel.Totalnum = 1; opmodel.UserID = UserID; opmodel.SubmitTime = dt; opmodel.utype = "0"; opmodel.gtype = gtype; new DAL.order_product_info().Add(opmodel); daoorder.UpdateqyState(0, "4", dt, poid); ccount += 1; int pdrs = 4; for (int j = 0; j < pdrs; j++) { OID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo) + j; int aUserID = 0; int auLevel19 = 0; dss = daoUser.GetList1("top 1 id,uLevel19", "gtype=" + gtype + " and UserState='正常' And IFStores=0 And uLevel18=1 and (select count(b.id) from order_info b where b.gtype=" + gtype + " and b.ttype=6 and b.IFDelete=0 and b.ptype=1 and b.ifxnhy=1 And b.poid=" + poid + " and b.userid=a.id)=0 order by uLevel19 asc,id asc"); if (dss.Tables[0].Rows.Count > 0) { aUserID = Convert.ToInt32(dss.Tables[0].Rows[0]["id"]); auLevel19 = Convert.ToInt32(dss.Tables[0].Rows[0]["uLevel19"]); } dss.Clear(); if (UserID > 0) { Model.order_info Modelorder0 = new Model.order_info(); Modelorder0.pid = pid; Modelorder0.poid = poid; Modelorder0.pcount = Modelorder.pcount; Modelorder0.ypcount = 0; Modelorder0.addressid = 0; Modelorder0.orderid = OID; Modelorder0.Contactname = ""; Modelorder0.Contacttel = ""; Modelorder0.Province = ""; Modelorder0.City = ""; Modelorder0.County = ""; Modelorder0.Address = ""; Modelorder0.Zipcode = ""; Modelorder0.Guests = ""; Modelorder0.Totalprice = Totalprice; Modelorder0.Totalprice0 = 0; Modelorder0.Totalprice1 = 0; Modelorder0.Totalprice2 = 0; Modelorder0.Totalprice3 = 0; Modelorder0.Totalprice4 = 0; Modelorder0.Totalprice5 = 0; Modelorder0.Totalnum = 1; Modelorder0.O_Submit = "1"; Modelorder0.O_yhj = ""; Modelorder0.UserID = aUserID; Modelorder0.MemberId = 0; Modelorder0.selcolor = ""; Modelorder0.guige = ""; Modelorder0.utype = "0"; Modelorder0.ttype = 6; Modelorder0.ptype = 1; Modelorder0.ptgroup = 0; Modelorder0.ifxnhy = 1; Modelorder0.ypznum = auLevel19; Modelorder.ifxhpt = 0; Modelorder0.peitype = 0; Modelorder0.gtype = gtype; int OrderID0 = new Mtxfw.DAL.order_info().Add(Modelorder0); Model.order_product_info opmodel0 = new Model.order_product_info(); opmodel.pid = pid; opmodel.orderid = OrderID0; opmodel.selcolor = colors; opmodel.guige = guigeid; opmodel.DJprice = Totalprice; opmodel.Totalprice = Totalprice; opmodel.Totalnum = 1; opmodel.UserID = aUserID; opmodel.SubmitTime = dt; opmodel.utype = "0"; opmodel.gtype = gtype; new DAL.order_product_info().Add(opmodel); daoorder.UpdateqyState(0, "4", dt, OrderID0); daoorder.Updateypcount(1, poid); } } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "一键团购"; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"已拼" + ccount + "单!\"}"; } else { data = "{\"status\":0,\"msg\":\"团购券余额不足" + ZTotalprice.ToString() + "!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您今日团购次数已达,请明天再来!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您今日已一键团购过,请明天再来!\"}"; } } } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //更新一键团购----------------------------------------------------------------------------------------- /// /// 更新一键团购 /// protected string updateonekey(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["LoginId"].ToString())); DateTime dt = DateTime.Now; } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取团购卷数据----------------------------------------------------------------------------------------- /// /// 获取团购卷数据 /// protected string getcoupondata(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string strdata = ",\"mydatas\":["; DataSet ds; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = daoResults.GetDataSet(groupby, strOrder, "id,b0,b1,Seef,Managers,addtime", "", "(MemberId=" + umodel.Id + ") and utype=5 And IFDelete=0", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int seef = Convert.ToInt32(Dr["Seef"]); string b0 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b1 = Convert.ToDouble(Dr["b1"]).ToString(); string name = Dr["Managers"].ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"name\":\"" + name + "\",\"b0\":\"" + b0 + "\",\"b1\":\"" + b1 + "\",\"seef\":\"" + seef + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; if (Start == 0) { strdata += ",\"data\":["; ds = daoGoods.GetList1("id,GoodsName,GoodsPrices", "gtype=" + gtype + " and utype=1 Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string GoodsName = Dr["GoodsName"].ToString(); string GoodsPrices = Convert.ToDouble(Dr["GoodsPrices"]).ToString("f2"); strdata += "{\"id\":\"" + id + "\",\"title\":\"" + GoodsName + "\",\"price\":\"" + GoodsPrices + "\",\"num\":\"0\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); strdata += "]"; } data = "{\"status\":1,\"IFYGM\":" + umodel.uLevel14 + "" + strdata + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //购买团购卷----------------------------------------------------------------------------------------- /// /// 购买团购卷 /// protected string gmcoupon(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["coupons"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); string coupons = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["coupons"].ToString())); bool b = true; int zftype = 0; if (!String.IsNullOrEmpty(context.Request["zftype"])) { zftype = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["zftype"].ToString()))); } if (b) { Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Double zPrices = 0.00; string strname = "团购卷"; string[] acoupons = coupons.Split('|'); for (int i = 0; i < acoupons.Length; i++) { if (acoupons[i] != "") { string[] stra = acoupons[i].Split(','); if (stra.Length == 2) { Mtxfw.Model.user_Goods gmodel = daoGoods.GetModel(Convert.ToInt32(stra[0])); if (gmodel != null) { if (gmodel.utype == 1) { if (Convert.ToInt32(stra[1]) == 1) { zPrices += (gmodel.GoodsPrices * Convert.ToInt32(stra[1])); } else { b = false; data = "{\"status\":0,\"msg\":\"数量只能选1个!\"}"; break; } } else { b = false; data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; break; } } else { b = false; data = "{\"status\":0,\"msg\":\"参数错误1!\"}"; break; } } else { b = false; data = "{\"status\":0,\"msg\":\"参数错误!\"}"; break; } } } zPrices = Convert.ToDouble(zPrices.ToString("f2")); if (zftype == 2) { if (zPrices > Convert.ToDouble((umodel.umoney - umodel.umoney17).ToString("f2"))) { b = false; data = "{\"status\":0,\"msg\":\"余额不足!\"}"; } } if (b) { string openid = umodel.openid; if (!String.IsNullOrEmpty(context.Request["openid"])) { openid = HttpUtility.UrlDecode(context.Request["openid"].ToString()); } DateTime dt = DateTime.Now; string PayID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo); Mtxfw.Model.user_Results ModelResults; string body = "购买" + strname; string ResultIdS = ""; string timestamp = ""; string nonceStr = ""; string package = ""; string paySign = ""; for (int i = 0; i < acoupons.Length; i++) { if (acoupons[i] != "") { string[] stra = acoupons[i].Split(','); Mtxfw.Model.user_Goods gmodel = daoGoods.GetModel(Convert.ToInt32(stra[0])); if (gmodel != null) { ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = gmodel.GoodsPrices; ModelResults.b1 = Convert.ToInt32(stra[1]); ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = 0; ModelResults.conent = body; ModelResults.Totalmoney = gmodel.GoodsPrices; ModelResults.MemberId = umodel.Id; ModelResults.UserId = 0; ModelResults.ListNumber = ""; ModelResults.Managers = gmodel.GoodsName; ModelResults.Seef = 0; ModelResults.utype = "5"; ModelResults.addtime = dt; ModelResults.gtype = gtype; Int64 ResultId = daoResults.Add(ModelResults); if (ResultIdS != "") { ResultIdS += ResultId + ","; } else { ResultIdS += ResultId.ToString(); } } } } Int64 ResultId0 = 0; if (zftype == 2) { string[] aResultIdS = ResultIdS.Split(','); for (int i = 0; i < aResultIdS.Length; i++) { if (aResultIdS[i] != "") { daoResults.UpdateSeef(1, dt, Convert.ToInt64(aResultIdS[i])); } } Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -zPrices; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney - umodel.umoney17 - zPrices); mjl2.addtime = dt; mjl2.BZContent = body; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 1; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; new Mtxfw.DAL.user_Results_jl2().Add(mjl2); //减少买家余额 new Mtxfw.DAL.user_info().UpdateMoney("umoney17", zPrices, umodel.Id); mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = zPrices; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney30 + zPrices); mjl2.addtime = dt; mjl2.BZContent = body; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 2; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; new Mtxfw.DAL.user_Results_jl2().Add(mjl2); //减少买家余额 new Mtxfw.DAL.user_info().UpdateMoney("umoney30", zPrices, umodel.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "使用余额购买团购卷成功"; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); } else { Double JFZSubTotal = Convert.ToDouble(zPrices.ToString("f2")); ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = JFZSubTotal; ModelResults.b1 = 0; ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = 2; ModelResults.conent = body; ModelResults.Totalmoney = JFZSubTotal; ModelResults.MemberId = umodel.Id; ModelResults.UserId = 3; ModelResults.ListNumber = PayID; ModelResults.Managers = "5"; ModelResults.Seef = 0; ModelResults.utype = "2"; ModelResults.addtime = dt; ModelResults.gtype = gtype; ResultId0 = daoResults.Add(ModelResults); daoResults.UpdateOrderIds(ResultIdS, ResultId0); Mtxfw.Utility.Interface_WxPay.Get_RequestHtml0(config, context, openid, PayID, Convert.ToDecimal(JFZSubTotal), ref timestamp, ref nonceStr, ref package, ref paySign, body, "card_store"); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "购买团购卷去付款"; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); //Mtxfw.Utility.Common.WriteHtml("/weixin/reResult.txt", timestamp + "|" + nonceStr + "|" + package + "|" + paySign); } data = "{\"status\":1,\"msg\":\"付款成功!\",\"ResultId\":\"" + ResultId0 + "\",\"timeStamp\":\"" + timestamp + "\",\"noncestr\":\"" + nonceStr + "\",\"package\":\"" + package + "\",\"paySign\":\"" + paySign + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取奖金详情----------------------------------------------------------------------------------------- /// /// 获取奖金详情 /// protected string getjianjinlist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["t"].ToString()))); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { DateTime dt = DateTime.Now; string strdata = ",\"categorys\":["; string[] bonuscategory = config.webbonuscategory.Split('|'); foreach (string category in bonuscategory) { if (category != "") { strdata += "{\"title\":\"" + category + "\"},"; } } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; strdata += ",\"data\":["; System.Text.StringBuilder sb = new System.Text.StringBuilder(); string groupby = "group by CONVERT(varchar(10),addtime,120)"; string strOrder = "CONVERT(varchar(10),addtime,120) desc"; sb.Append("MemberId=" + model.Id + " and utype=0 And IFDelete=0"); if (t == 1) { sb.Append(" and b1>0"); } if (t == 2) { sb.Append(" and b2>0"); } if (t == 3) { sb.Append(" and b3>0"); } if (t == 4) { sb.Append(" and b5>0"); } if (t == 5) { sb.Append(" and seef=0"); } if (t == 6) { sb.Append(" and b11>0"); } String SJ = context.Request["SJ"]; String SJ2 = context.Request["SJ2"]; if (!String.IsNullOrEmpty(SJ) && !String.IsNullOrEmpty(SJ2)) { sb.Append("and (addtime between '" + SJ + " 00:00:00' and '" + SJ2 + " 23:59:59') "); } int Start = 0; int Limit = 20; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daoResults.GetDataSet(groupby, strOrder, "id,b0,b1,b2,b3,b4,b5,b6,b7,b8,b11,b12,b13,b14,Totalmoney,maxseef,minseef,addtime", "max(id) as id,sum(b0) as b0,sum(b1) as b1,sum(b2) as b2,sum(b3) as b3,sum(b4) as b4,sum(b5) as b5,sum(b6) as b6,sum(b7) as b7,sum(b8) as b8,sum(b11) as b11,sum(b12) as b12,sum(b13) as b13,sum(b14) as b14,sum(Totalmoney) as Totalmoney,max(Seef) as maxseef,min(Seef) as minseef,CONVERT(varchar(10),addtime,120) as addtime", sb.ToString(), Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { string id = Dr["id"].ToString(); string b1 = Convert.ToDouble(Dr["b1"]).ToString("f2"); string b2 = Convert.ToDouble(Dr["b2"]).ToString("f2"); string b3 = Convert.ToDouble(Dr["b3"]).ToString("f2"); string b4 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b5 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b6 = Convert.ToDouble(Dr["b6"]).ToString("f2"); string b7 = Convert.ToDouble(Dr["b7"]).ToString("f2"); string b8 = Convert.ToDouble(Dr["b8"]).ToString("f2"); string b11 = Convert.ToDouble(Dr["b11"]).ToString("f2"); string b12 = Convert.ToDouble(Dr["b12"]).ToString("f2"); string b13 = Convert.ToDouble(Dr["b13"]).ToString("f2"); string b14 = Convert.ToDouble(Dr["b14"]).ToString("f2"); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string addtime = Dr["addtime"].ToString(); int maxseef = Convert.ToInt32(Dr["maxseef"]); int minseef = Convert.ToInt32(Dr["minseef"]); string strseef = ((maxseef == 0 && minseef == 0) ? "未结算" : (minseef == 0 ? "未结完" : "已结算")); strdata += "{\"id\":\"" + id + "\",\"b1\":\"" + b1 + "\",\"b2\":\"" + b2 + "\",\"b3\":\"" + b3 + "\",\"b4\":\"" + b4 + "\",\"b5\":\"" + b5 + "\",\"b6\":\"" + b6 + "\",\"b7\":\"" + b7 + "\",\"b8\":\"" + b8 + "\",\"b11\":\"" + b11 + "\",\"b12\":\"" + b12 + "\",\"b13\":\"" + b13 + "\",\"b14\":\"" + b14 + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + strseef + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; data = "{\"status\":1,\"yjye\":\"" + model.umoney.ToString("f2") + "\"" + strdata + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } /// /// 获取奖金详情0 /// protected string getjianjinlist0(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ",\"categorys\":["; string[] bonuscategory = config.webbonuscategory.Split('|'); foreach (string category in bonuscategory) { if (category != "") { strdata += "{\"title\":\"" + category + "\"},"; } } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; strdata += ",\"data\":["; System.Text.StringBuilder sb = new System.Text.StringBuilder(); String addtime = context.Request["addtime"]; if (!String.IsNullOrEmpty(addtime)) { sb.Append(" and DateDiff(day,addtime,'" + addtime + "')=0"); } if (t == 1) { sb.Append(" and b1>0"); } if (t == 2) { sb.Append(" and b2>0"); } if (t == 3) { sb.Append(" and b3>0"); } if (t == 4) { sb.Append(" and b5>0"); } if (t == 5) { sb.Append(" and seef=0"); } if (t == 6) { sb.Append(" and b11>0"); } string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 20; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daoResults.GetDataSet(groupby, strOrder, "id,b0,b1,b2,b3,b4,b5,b6,b7,b8,b11,b12,b13,b14,Totalmoney,seef,Sended,addtime,conent,(Select UserName From user_info b Where b.Id=UserId) as UserName2", "", "MemberId=" + model.Id + " and utype=0 And IFDelete=0" + sb.ToString(), Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { string id = Dr["id"].ToString(); string b1 = Convert.ToDouble(Dr["b1"]).ToString("f2"); string b2 = Convert.ToDouble(Dr["b2"]).ToString("f2"); string b3 = Convert.ToDouble(Dr["b3"]).ToString("f2"); string b4 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b5 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b6 = Convert.ToDouble(Dr["b6"]).ToString("f2"); string b7 = Convert.ToDouble(Dr["b7"]).ToString("f2"); string b8 = Convert.ToDouble(Dr["b8"]).ToString("f2"); string b11 = Convert.ToDouble(Dr["b11"]).ToString("f2"); string b12 = Convert.ToDouble(Dr["b12"]).ToString("f2"); string b13 = Convert.ToDouble(Dr["b13"]).ToString("f2"); string b14 = Convert.ToDouble(Dr["b14"]).ToString("f2"); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string straddtime = Convert.ToDateTime(Dr["addtime"]).ToString("HH:mm:ss"); int seef = Convert.ToInt32(Dr["seef"]); int Sended = Convert.ToInt32(Dr["Sended"]); string UserName2 = Dr["UserName2"].ToString(); string conent = Dr["conent"].ToString(); if (conent.IndexOf("奖励") != -1) { conent = conent.Substring(0, conent.IndexOf("奖励")+2); } if (conent.IndexOf("加权分红") != -1) { conent = conent.Substring(0, conent.IndexOf("加权分红") + 4); } string strseef = (seef == 0 ? "未结算" : "已结算"); strdata += "{\"id\":\"" + id + "\",\"b1\":\"" + b1 + "\",\"b2\":\"" + b2 + "\",\"b3\":\"" + b3 + "\",\"b4\":\"" + b4 + "\",\"b5\":\"" + b5 + "\",\"b6\":\"" + b6 + "\",\"b7\":\"" + b7 + "\",\"b8\":\"" + b8 + "\",\"b11\":\"" + b11 + "\",\"b12\":\"" + b12 + "\",\"b13\":\"" + b13 + "\",\"b14\":\"" + b14 + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"addtime\":\"" + straddtime + "\",\"seef\":\"" + strseef + "\",\"conent\":\"" + conent + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; data = "{\"status\":1" + strdata + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取账户统计列表----------------------------------------------------------------------------------------- /// /// 获取账户统计列表 /// protected string getbilltj(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["t"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); if (t == 0 || t == 1 || t == 2 || t == 3 || t == 4 || t == 5 || t == 6 || t == 10) { Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string strdata = ""; string groupby = "group by CONVERT(varchar(10),addtime,120)"; string strOrder = "CONVERT(varchar(10),addtime,120) desc"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("IFDelete=0 and utype=" + t + " And MemberId=" + umodel.Id + ""); String SJ = context.Request["SJ"]; String SJ2 = context.Request["SJ2"]; if (!String.IsNullOrEmpty(SJ) && !String.IsNullOrEmpty(SJ2)) { sb.Append("and (addtime between '" + SJ + " 00:00:00' and '" + SJ2 + " 23:59:59') "); } int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daojl2.GetDataSet(groupby, strOrder, "id,Addmoney,addtime,seef", "max(id) as id,sum(Addmoney) as Addmoney,max(Seef) as seef,CONVERT(varchar(10),addtime,120) as addtime", sb.ToString(), Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int seef = Convert.ToInt32(Dr["seef"]); string Addmoney = Convert.ToDouble(Dr["Addmoney"]).ToString("f2"); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"Addmoney\":\"" + Addmoney + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + "已结算" + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); string zAddmoney = "0"; string b1 = daojl2.Getzd("sum(Addmoney)", sb.ToString()).ToString(); if (b1 != "") { zAddmoney = Convert.ToDouble(b1).ToString("f2"); } data = "{\"status\":1,\"zAddmoney\":\"" + zAddmoney + "\",\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取账户明细列表----------------------------------------------------------------------------------------- /// /// 获取账户明细列表 /// protected string getbilllist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); int t = 1; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["t"].ToString()))); } if (t >= 0 || t < 35) { Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc,id desc"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("IFDelete=0 and utype=" + t + " And MemberId=" + umodel.Id + ""); if (!String.IsNullOrEmpty(context.Request["ttype"])) { string ttype = HttpUtility.UrlDecode(context.Request["ttype"].ToString()); sb.Append(" and Convert(VarChar(100),BZContent) Like '%" + ttype + "%'"); } String SJ = context.Request["SJ"]; String SJ2 = context.Request["SJ2"]; if (!String.IsNullOrEmpty(SJ) && !String.IsNullOrEmpty(SJ2)) { if (SJ != "undefined" && SJ2 != "undefined") { sb.Append(" and (addtime between '" + SJ + " 00:00:00' and '" + SJ2 + " 23:59:59') "); } } int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daojl2.GetDataSet(groupby, strOrder, "id,Addmoney,Cutmoney,Totalmoney,PayID,OrdersIDs,BZContent,addtime,OrdersID,seef,utype2", "", sb.ToString(), Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string Addmoney = Convert.ToDouble(Dr["Addmoney"]).ToString("0.####"); string Cutmoney = Convert.ToDouble(Dr["Cutmoney"]).ToString("0.####"); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("0.####"); string PayID = Dr["PayID"].ToString(); string OrdersIDs = Dr["OrdersIDs"].ToString(); string BZContent = Dr["BZContent"].ToString(); string addtime = Dr["addtime"].ToString(); int OrdersID = Convert.ToInt32(Dr["OrdersID"]); int seef = Convert.ToInt32(Dr["seef"]); int utype2 = Convert.ToInt32(Dr["utype2"]); if (BZContent.IndexOf("奖励") != -1) { BZContent = BZContent.Substring(0, BZContent.IndexOf("奖励") + 2); } if (BZContent.IndexOf("加权分红") != -1) { BZContent = BZContent.Substring(0, BZContent.IndexOf("加权分红") + 4); } strdata += "{\"id\":\"" + id + "\",\"Addmoney\":\"" + Addmoney + "\",\"Cutmoney\":\"" + Cutmoney + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"PayID\":\"" + PayID + "\",\"OrdersIDs\":\"" + OrdersIDs + "\",\"BZContent\":\"" + BZContent.Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\",\"OrdersID\":\"" + OrdersID + "\",\"seef\":\"" + seef + "\",\"utype2\":\"" + utype2 + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); string strdqye = "0"; if (t == 0) { strdqye = (umodel.umoney - umodel.umoney17).ToString("f2"); } if (t == 1) { strdqye = umodel.umoney.ToString("f2"); } if (t == 2) { strdqye = umodel.umoney18.ToString("f2"); } if (t == 9) { strdqye = umodel.umoney38.ToString("f2"); } if (t == 10) { strdqye = umodel.umoney39.ToString("f2"); } data = "{\"status\":1,\"dqye\":\"" + strdqye + "\",\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取增值积分数据----------------------------------------------------------------------------------------- /// /// 获取增值积分数据 /// protected string getzzjfdata(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc,id desc"; int Start = 0; int Limit = 50; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daozzjflog.GetDataSet(groupby, strOrder, "id,zzjg,addtime", "", "gtype=" + gtype + " and IFDelete=0", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string zzjg = Convert.ToDouble(Convert.ToDouble(Dr["zzjg"]).ToString("0.########")).ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"zzjg\":\"" + zzjg + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); Double fxjg = 0, szjg = 0, jrjg = 0, ygsy = 0, zsy = model.umoney28, zzjfye = model.umoney37; if (Start == 0) { jrjg = daozzjf.GetZZJG(gtype); string strjg = daozzjflog.Getzd("zzjg", "gtype=" + gtype + " and IFDelete=0 order by addtime asc").ToString(); if (strjg != "") { fxjg = Convert.ToDouble(strjg); } strjg = daozzjflog.Getzd("max(zzjg)", "gtype=" + gtype + " and IFDelete=0 and DateDiff(day,addtime,getdate())=1").ToString(); if (strjg != "") { szjg = Convert.ToDouble(strjg); } ygsy = (model.umoney27); } data = "{\"status\":1,\"fxjg\":\"" + fxjg.ToString() + "\",\"szjg\":\"" + szjg.ToString() + "\",\"jrjg\":\"" + jrjg.ToString() + "\",\"ygsy\":\"" + ygsy.ToString("0.####") + "\",\"zsy\":\"" + zsy.ToString("0.####") + "\",\"zzjfye\":\"" + zzjfye.ToString("0.####") + "\",\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取增值记录----------------------------------------------------------------------------------------- /// /// 获取增值记录 /// protected string getzzjf_log(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["t"].ToString()))); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc,id desc"; string sql = ""; if(t == 1) { sql = " and Addmoney>0"; } else if (t == 2) { sql = " and Addmoney<0"; } int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Double jrjg = daozzjf.GetZZJG(gtype); Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.user_Results_jl2().GetDataSet(groupby, strOrder, "id,Addmoney,Cutmoney,Totalmoney,addtime,seef,BZContent", "", "gtype=" + gtype + " and utype=9 And IFDelete=0 and MemberId=" + model.Id + " and seef=0" + sql, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string sl = Convert.ToDouble(Dr["Addmoney"]).ToString(); string jg = Convert.ToDouble(Dr["Cutmoney"]).ToString(); string jz = Convert.ToDouble((Convert.ToDouble(Dr["Addmoney"]) * jrjg).ToString("0.####")).ToString(); string addtime = Dr["addtime"].ToString(); int seef = Convert.ToInt32(Dr["seef"]); string content = Dr["BZContent"].ToString(); strdata += "{\"id\":\"" + id + "\",\"sl\":\"" + sl + "\",\"jg\":\"" + jg + "\",\"jz\":\"" + jz + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\",\"content\":\"" + content + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); daoUser.UpdatePassword("Companyaddress", jrjg.ToString(), model.Id); data = "{\"status\":1,\"jrjg\":\"" + jrjg.ToString() + "\",\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取全网增值记录----------------------------------------------------------------------------------------- /// /// 获取全网增值记录 /// protected string getqwzzjf_log(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc,id desc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.user_Results_jl2().GetDataSet(groupby, strOrder, "id,Addmoney,Cutmoney,Totalmoney,addtime", "", "gtype=" + gtype + " and utype=9 And IFDelete=0", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string sl = Convert.ToDouble(Dr["Addmoney"]).ToString(); string jg = Convert.ToDouble(Dr["Cutmoney"]).ToString(); string jz = Convert.ToDouble((Convert.ToDouble(Dr["Addmoney"]) * daozzjf.GetZZJG(gtype)).ToString("0.####")).ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"sl\":\"" + sl + "\",\"jg\":\"" + jg + "\",\"jz\":\"" + jz + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //卖出增值积分----------------------------------------------------------------------------------------- /// /// 卖出增值积分 /// protected string qymczzjf(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"]) && !String.IsNullOrEmpty(context.Request["pwd"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int64 id = Convert.ToInt64(context.Request["id"].ToString()); string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Mtxfw.Model.user_Results_jl2 rmodel = daojl2.GetModel(id); if (rmodel != null) { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); bool b = true; b = false; data = "{\"status\":0,\"msg\":\"暂时不能卖出!\"}"; if (b) { if (rmodel.Seef == 1) { b = false; data = "{\"status\":0,\"msg\":\"此记录已卖出过!\"}"; } } if (b) { if (rmodel.IFDelete == 1) { b = false; data = "{\"status\":0,\"msg\":\"此记录已删除!\"}"; } } if (b) { if (rmodel.utype != 9) { b = false; data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } if (b) { if (umodel.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } if (b) { daojl2.UpdateSeef("seef", 1, "seeftime", dt, rmodel.Id); Double jg = daozzjf.GetZZJG(gtype); Double money = Convert.ToDouble(Convert.ToDouble((rmodel.Addmoney * jg).ToString("0.####")).ToString("f4")); if (money > 0.00) { Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = money; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney37 + money); mjl2.addtime = DateTime.Now; mjl2.BZContent = "卖出增值积分"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 19; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); umodel.umoney37 += money; daoUser.UpdateMoney("umoney37", money, umodel.Id); daoUser.UpdateMoney("umoney27", -rmodel.Totalmoney, umodel.Id); daoUser.UpdateMoney("umoney22", rmodel.Addmoney, umodel.Id); } data = "{\"status\":1,\"msg\":\"卖出成功\"," + returndata(umodel) + "}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误0\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取我的收益明细----------------------------------------------------------------------------------------- /// /// 获取我的收益明细 /// protected string getmyincome(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["t"].ToString()))); } Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string strdata = ""; string groupby = "group by CONVERT(varchar(10),addtime,120)"; string strOrder = "CONVERT(varchar(10),addtime,120) desc"; string fieidlist = "b0,Totalmoney,addtime"; string fieidlist0 = "sum(b0) as b0,sum(Totalmoney) as Totalmoney,CONVERT(varchar(10),addtime,120) as addtime"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("utype=0 And IFDelete=0 and MemberId=" + umodel.Id + ""); if (t == 1 || t == 2 || t == 3 || t == 4 || t == 5) { groupby = ""; strOrder = "addtime desc,id desc"; fieidlist = "id,b0,Totalmoney,addtime,conent"; fieidlist0 = ""; if (t == 1) { DateTime dt = DateTime.Now; string mindt = dt.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = dt.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; sb.Append(" and addtime>='" + mindt + "' and addtime<'" + maxdt + "'"); } else if (t == 2) { DateTime dt = DateTime.Now; string mindt = dt.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = dt.ToString("yyyy-MM-dd") + " 00:00:00"; sb.Append(" and addtime>='" + mindt + "' and addtime<'" + maxdt + "'"); } else if (t == 4) { sb.Append(" and hasRead=2"); } else if (t == 5) { sb.Append(" and hasRead=2 and Sended=1"); } else { String addtime = context.Request["addtime"]; if (!String.IsNullOrEmpty(addtime)) { DateTime dt = Convert.ToDateTime(addtime); string mindt = dt.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = dt.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; sb.Append(" and addtime>='" + mindt + "' and addtime<'" + maxdt + "'"); } } } String SJ = context.Request["SJ"]; String SJ2 = context.Request["SJ2"]; if (!String.IsNullOrEmpty(SJ) && !String.IsNullOrEmpty(SJ2)) { if (SJ != "undefined" && SJ2 != "undefined") { sb.Append(" and (addtime between '" + SJ + " 00:00:00' and '" + SJ2 + " 23:59:59') "); } } int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daoResults.GetDataSet(groupby, strOrder, fieidlist, fieidlist0, sb.ToString(), Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { string b0 = Convert.ToDouble(Dr["b0"]).ToString("0.####"); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("0.####"); string addtime = Convert.ToDateTime(Dr["addtime"]).ToString("yyyy-MM-dd"); string conent = ""; string id = addtime; if (t == 1 || t == 2 || t == 3 || t == 4 || t == 5) { id = Dr["id"].ToString(); addtime = Convert.ToDateTime(Dr["addtime"]).ToString("HH:mm:ss"); if (t == 4|| t == 5) { addtime = Convert.ToDateTime(Dr["addtime"]).ToString("yyyy-MM-dd HH:mm:ss"); } conent = Dr["conent"].ToString(); } strdata += "{\"id\":\"" + id + "\",\"b0\":\"" + b0 + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"addtime\":\"" + addtime + "\",\"conent\":\"" + conent.Replace("\"", "\\\"") + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); string zsymoney = "0.00", jrsymoney = "0.00", zrsymoney = "0.00", bysymoney = "0.00", sysymoney = "0.00"; Double SYCount0 = 0.00, SYCount1 = 0.00, SYCount2 = 0.00, SYCount3 = 0.00, SYCount4 = 0.00, SYCount5 = 0.00, SYCount6 = 0.00, SYCount7 = 0.00; if (Start == 0) { /*string strzd = daoResults.Getzd("sum(Totalmoney)", sb.ToString()).ToString(); if (strzd != "") { zsymoney = Convert.ToDouble(strzd).ToString("f2"); }*/ /*strzd = daoResults.Getzd("sum(Totalmoney)", "utype=0 And IFDelete=0 and MemberId=" + umodel.Id + " and DateDiff(day,addtime,getdate())=0").ToString(); if (strzd != "") { jrsymoney = Convert.ToDouble(strzd).ToString("f2"); } strzd = daoResults.Getzd("sum(Totalmoney)", "utype=0 And IFDelete=0 and MemberId=" + umodel.Id + " and DateDiff(day,addtime,getdate())=1").ToString(); if (strzd != "") { zrsymoney = Convert.ToDouble(strzd).ToString("f2"); } strzd = daoResults.Getzd("sum(Totalmoney)", "utype=0 And IFDelete=0 and MemberId=" + umodel.Id + " and DateDiff(month,addtime,getdate())=0").ToString(); if (strzd != "") { bysymoney = Convert.ToDouble(strzd).ToString("f2"); } strzd = daoResults.Getzd("sum(Totalmoney)", "utype=0 And IFDelete=0 and MemberId=" + umodel.Id + " and DateDiff(month,addtime,getdate())=1").ToString(); if (strzd != "") { sysymoney = Convert.ToDouble(strzd).ToString("f2"); }*/ } data = "{\"status\":1,\"zsymoney\":\"" + zsymoney + "\",\"jrsymoney\":\"" + jrsymoney + "\",\"zrsymoney\":\"" + zrsymoney + "\",\"bysymoney\":\"" + bysymoney + "\",\"sysymoney\":\"" + sysymoney + "\",\"SYCount0\":\"" + SYCount0.ToString("f2") + "\",\"SYCount1\":\"" + SYCount1.ToString("f2") + "\",\"SYCount2\":\"" + SYCount2.ToString("f2") + "\",\"SYCount3\":\"" + SYCount3.ToString("f2") + "\",\"SYCount4\":\"" + SYCount5.ToString("f2") + "\",\"SYCount5\":\"" + SYCount5.ToString("f2") + "\",\"SYCount6\":\"" + SYCount6.ToString("f2") + "\",\"SYCount7\":\"" + SYCount7.ToString("f2") + "\",\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取联盟门店数据----------------------------------------------------------------------------------------- /// /// 获取联盟门店数据 /// protected string getBusinessdata(HttpContext context) { string data = "{\"status\":0}"; int userId = 0; bool ifb = true; string userinfo = "", province = "", city = "", county = "", strAddress = ""; bool dsj = false; string strsql = ""; string latitude = "0"; string longitude = "0"; if (!String.IsNullOrEmpty(context.Request["latitude"]) && !String.IsNullOrEmpty(context.Request["longitude"])) { latitude = context.Request["latitude"].ToString(); longitude = context.Request["longitude"].ToString(); } if (!String.IsNullOrEmpty(context.Request["selcityid"])) { string selcityid = context.Request["selcityid"].ToString(); if (!String.IsNullOrEmpty(context.Request["selcountyid"])) { string selcountyid = context.Request["selcountyid"].ToString(); strsql += " And (city='" + selcityid + "' and county='" + selcountyid + "')"; } else { strsql += " And city='" + selcityid + "'"; } } else { /* if (!String.IsNullOrEmpty(context.Request["latitude"]) && !String.IsNullOrEmpty(context.Request["longitude"])) { latitude = context.Request["latitude"].ToString(); longitude = context.Request["longitude"].ToString(); string Address = Mtxfw.Utility.Common.GetAddress(longitude, latitude); if (Address != "") { string stra = Address.Substring(0, 2); string strzd = new DAL.province().Getzd("provinceid", "provincename like '%" + stra + "%'").ToString(); if (strzd != "") { province = strzd; } if (province != "") { if (Address.IndexOf("市") != -1) { strzd = new DAL.city().Getzd("cityid", "provinceid='" + province + "' and charindex(cityname,'" + Address + "')>0").ToString(); if (strzd != "") { city = strzd;// + (province!=""? " and provinceid = '"+ province + "'" : "") } if (city != "") { strzd = new DAL.county().Getzd("countyid", "cityid='" + city + "' and charindex(countyname,'" + Address + "')>0").ToString(); if (strzd != "") { county = strzd; } } else { DataSet ds = new DAL.county().GetList("charindex(countyname,'" + Address + "')>0"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string cityid = Dr["cityid"].ToString(); string countyid = Dr["countyid"].ToString(); if (new DAL.city().GetCount("provinceid='" + province + "' and cityid='" + cityid + "'") > 0) { county = countyid; city = cityid; } } } ds.Clear(); dsj = true; } //Mtxfw.Utility.Common.WriteHtml("/weixin/getindexdata0.txt", province + "|" + city + "|" + county + "|" + Address); } else { DataSet ds = new DAL.city().GetList("provinceid='" + province + "'"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string cityid = Dr["cityid"].ToString(); strzd = new DAL.county().Getzd("countyid", "cityid='" + cityid + "' and charindex(countyname,'" + Address + "')>0").ToString(); if (strzd != "") { county = strzd; city = cityid; } } } ds.Clear(); //Mtxfw.Utility.Common.WriteHtml("/weixin/getindexdata1.txt", province + "|" + city + "|" + county + "|" + Address); } } else { DataSet ds = new DAL.city().GetList("charindex(cityname,'" + Address + "')>0"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string cityid = Dr["cityid"].ToString(); string provinceid = Dr["provinceid"].ToString(); province = provinceid; city = cityid; } } ds.Clear(); strzd = new DAL.county().Getzd("countyid", "cityid='" + city + "' and charindex(countyname,'" + Address + "')>0").ToString(); if (strzd != "") { county = strzd; } //Mtxfw.Utility.Common.WriteHtml("/weixin/getindexdata2.txt", province + "|" + city + "|" + county + "|" + Address); } } strAddress = Address; if (strAddress != "") { if (dsj) { if (strAddress.IndexOf("市") != -1) { strAddress = strAddress.Substring((strAddress.IndexOf("市") + 1), strAddress.Length - (strAddress.IndexOf("市") + 1)); } } else { if (strAddress.IndexOf("县") != -1) { strAddress = strAddress.Substring((strAddress.IndexOf("县") + 1), strAddress.Length - (strAddress.IndexOf("县") + 1)); } if (strAddress.IndexOf("区") != -1) { strAddress = strAddress.Substring((strAddress.IndexOf("区") + 1), strAddress.Length - (strAddress.IndexOf("区") + 1)); } } } }*/ } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { userinfo = ",\"iflogin\":1," + returndata(umodel); } else { userinfo = ",\"iflogin\":0}"; } } else { userinfo = ",\"iflogin\":2"; } } if (ifb) { int Start = 0; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); strsql += " And ClsID=" + t + ""; } if (!String.IsNullOrEmpty(context.Request["keyword"])) { string keyword = HttpUtility.UrlDecode(context.Request["keyword"].ToString()); strsql += " And CompanyName like '%" + keyword + "%'"; } string strdata = ""; if (Start == 0) { strdata += "\"pic\":["; DataSet ds; /*DataSet ds = daoGoods.GetList1("id,GoodsName,GoodsPic,GoodsUrl", "gtype=" + gtype + " and utype=11 Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string GoodsName = Dr["GoodsName"].ToString(); string GoodsUrl = Dr["GoodsUrl"].ToString(); string GoodsPic = Dr["GoodsPic"].ToString(); if (GoodsPic != "") { if (GoodsPic.IndexOf("http") == -1) { GoodsPic = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(GoodsPic, "220x220", "cut"); } else { GoodsPic = (GoodsPic + ""); } } strdata += "{\"id\":\"" + id + "\",\"img\":\"" + GoodsPic + "\",\"label\":\"" + GoodsName + "\",\"url\":\"" + GoodsUrl + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear();*/ strdata += "]"; strdata += ",\"lbs\":["; ds = daolb.GetList1("id,LBName,LBBody", "utype=1 Order By LBLinkID asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string name = Dr["LBName"].ToString(); string pic = Dr["LBBody"].ToString().Split(',')[0]; if (pic != "") { if (pic.IndexOf("http") == -1) { pic = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(pic, "220x220", "cut"); } else { pic = (pic + ""); } } if (daobusiness.GetCount("utype='0' and seef=1 and ClsID=" + id) > 0) { if (i % 8 == 0) { strdata += "{\"datas\":["; } strdata += "{\"id\":\"" + id + "\",\"img\":\"" + pic + "\",\"name\":\"" + name + "\"},"; if ((i > 1 && ((i + 1) % 8 == 0)) || i == ds.Tables[0].Rows.Count - 1) { if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]},"; } i += 1; } } if (strdata.Substring(strdata.Length - 3, 3) != "]},") { if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); strdata += "]"; } if (strdata != "") { strdata += ","; } strdata += "\"Businesslist\":[";// And P_M_P>0 string groupby = ""; string strOrder = "dbo.GetDistance(" + latitude + "," + longitude + ",xcoo,ycoo) asc"; int Limit = 12; Int32 Recount = 0;// System.Data.DataSet Ds_ = daobusiness.GetDataSet(groupby, strOrder, "id,UserId,CompanyName,picture,Companyaddress,ycoo,xcoo,dbo.GetDistance(" + latitude + "," + longitude + ",xcoo,ycoo) as distance", "", "utype='0' and (seef=1 or seef0=1) and showpic=0" + strsql + "", Start, Limit, out Recount); if (Ds_.Tables[1].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow drv in Ds_.Tables[1].Rows) { string id = drv["id"].ToString(); string UserId = drv["UserId"].ToString(); string name = drv["CompanyName"].ToString(); string images = drv["picture"].ToString().Split('|')[0].Split(',')[0]; if (images != "") { images = Mtxfw.Utility.Common.cminimage(images); } string address = drv["Companyaddress"].ToString(); string lon = drv["xcoo"].ToString(); string lat = drv["ycoo"].ToString(); string strdistance = drv["distance"].ToString(); Double distance = 0.00; if (strdistance != "") { distance = Convert.ToDouble(Convert.ToDouble(strdistance).ToString("f4")); } if (distance < 0.0000) { distance = -distance; } if (distance > 1000.0000) { strdistance = (distance / 1000).ToString().Split('.')[0] + "km"; } else { strdistance = distance.ToString("f0") + "m"; } strdata += "{\"_id\":\"" + id + "\",\"showpic\":\"0\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(name) + "\",\"address\":\"" + Mtxfw.Utility.Common.ReplaceString(address) + "\",\"distance\":\"" + strdistance + "\",\"lon\":\"" + lon + "\",\"lat\":\"" + lat + "\",\"image\":\"" + images + "\""; strdata += ",\"products\":["; /*DataSet Ds_Product0 = daoProduct.GetList1("top 3 P_ID,P_NAME,P_images", "gtype=" + gtype + " And IFDelete=0 And P_qgproduct=1 And P_State=N'已处理' And P_UserID=" + UserId + " And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 order by P_IFTop Desc,P_HITED Desc"); if (Ds_Product0.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow drv2 in Ds_Product0.Tables[0].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = ""; string P_VIP_P = ""; string P_VIP_P0 = ""; string P_VIP_P3 = ""; DataSet ds0 = new DAL.P_Guige().GetList1("min(G_JG) as G_JG,min(G_JG0) as G_JG0,min(G_JG2) as G_JG2,min(G_JG3) as G_JG3,min(G_JF) as G_JF", "G_PID=" + P_ID + " And G_KC>0"); if (ds0.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_Market_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG0"]).ToString("f2"); P_VIP_P3 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG3"]).ToString(); } ds0.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; if (P_images != "") { if (P_images.IndexOf("http") == -1) { P_images = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut"); } else { P_images = (P_images + ""); } } string x = "220x220"; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje3\":\"" + P_VIP_P3 + "\",\"image\":\"" + P_images + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_Product0.Clear();*/ strdata += "]"; strdata += "}"; strdata += ","; j += 1; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_.Clear(); strdata += "]"; strdata += (userinfo + ",\"province\":\"" + province + "\",\"city\":\"" + city + "\",\"county\":\"" + county + "\",\"Address\":\"" + strAddress + "\""); data = "{\"status\":1," + strdata + "}"; } return data; } #endregion #region //获取联盟门店详情----------------------------------------------------------------------------------------- /// /// 获取联盟门店详情 /// protected string getbusinessview(HttpContext context) { string data = "{"; int userId = 0; string latitude = "0"; string longitude = "0"; if (!String.IsNullOrEmpty(context.Request["latitude"]) && !String.IsNullOrEmpty(context.Request["longitude"])) { latitude = context.Request["latitude"].ToString(); longitude = context.Request["longitude"].ToString(); } bool ifb = true; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { data += "\"status\":1,\"iflogin\":1"; } else { data += "\"status\":0,\"iflogin\":0"; } } else { data += "\"status\":0,\"iflogin\":2"; } } if (ifb) { int Start = 0; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } if (!String.IsNullOrEmpty(context.Request["viewId"])) { int viewId = Convert.ToInt32(context.Request["viewId"]); Model.business_info bmodel = daobusiness.GetModel(viewId); if (bmodel != null) { if (data == "{") { data = "{\"status\":1,\"iflogin\":3"; } data += ",\"pic\":["; string[] pics = bmodel.picture.Split('|'); string showpic = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(pics[0].Split(',')[0], "150x150", "cut"); foreach (string str in pics) { if (str != "") { string[] stra = str.Split(','); if (stra[0] != "") { stra[0] = Mtxfw.Utility.Common.cmaximage(stra[0]); } data += "{\"img\":\"" + stra[0] + "\",\"label\":\"\"}"; data += ","; } } if (data.Substring(data.Length - 1, 1) == ",") { data = data.Substring(0, data.Length - 1); } data += "]"; string strdistance = ""; Double distance = Mtxfw.Utility.Common.GetDistance(Convert.ToDouble(latitude), Convert.ToDouble(longitude), Convert.ToDouble(bmodel.xcoo), Convert.ToDouble(bmodel.ycoo)); distance = Convert.ToDouble(distance.ToString("f4")); if (distance < 0.0000) { distance = -distance; } if (distance > 1000.0000) { strdistance = (distance / 1000).ToString().Split('.')[0] + "km"; } else { strdistance = distance.ToString("f0") + "m"; } data += ",\"_id\":\"" + bmodel.Id + "\",\"showpic\":\"" + bmodel.showpic + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(bmodel.CompanyName) + "\",\"address\":\"" + Mtxfw.Utility.Common.ReplaceString(bmodel.Companyaddress) + "\",\"fwbody\":\"" + Mtxfw.Utility.Common.ReplaceString(bmodel.BusinessRange) + "\",\"distance\":\"" + strdistance + "\",\"lon\":\"" + bmodel.xcoo + "\",\"lat\":\"" + bmodel.ycoo + "\""; data += ",\"productlist\":["; if (bmodel.utype == "0") { string groupby = ""; string strOrder = "P_IFTop Desc,P_HITED Desc"; int Limit = 12; Int32 Recount = 0;// System.Data.DataSet Ds_ = daoProduct.GetDataSet(groupby, strOrder, "P_ID,P_NAME,P_images", "", "gtype=" + gtype + " and utype0=1 And IFDelete=0 And P_qgproduct=1 And P_State=N'已处理' And P_UserID=" + bmodel.UserId + " And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0", Start, Limit, out Recount); if (Ds_.Tables[1].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow drv in Ds_.Tables[1].Rows) { string P_ID = drv["P_ID"].ToString(); string P_NAME = drv["P_NAME"].ToString(); string P_Market_P = ""; string P_VIP_P = ""; string P_VIP_P0 = ""; string P_VIP_P3 = ""; DataSet ds0 = new DAL.P_Guige().GetList1("min(G_JG) as G_JG,min(G_JG0) as G_JG0,min(G_JG2) as G_JG2,min(G_JG3) as G_JG3,min(G_JF) as G_JF", "G_PID=" + P_ID + " And G_KC>0"); if (ds0.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_Market_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG0"]).ToString("f2"); P_VIP_P3 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG3"]).ToString(); } ds0.Clear(); string P_images = drv["P_images"].ToString().Split('|')[0].Split(',')[0]; if (P_images != "") { if (P_images.IndexOf("http") == -1) { P_images = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut"); } else { P_images = (P_images + ""); } } string x = "220x220"; data += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje3\":\"" + P_VIP_P3 + "\",\"image\":\"" + P_images + "\"},"; } } Ds_.Clear(); if (data.Substring(data.Length - 1, 1) == ",") { data = data.Substring(0, data.Length - 1); } } data += "]"; } } } data += "}"; return data; } #endregion #region //获取首页数据----------------------------------------------------------------------------------------- /// /// 获取首页数据 /// protected string getindexdata(HttpContext context) { string data = "{\"status\":0}"; int userId = 0, IFYGM = 0; string userinfo = ""; string strsql2 = "a.parentid=30 and a.hasRead=0"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { IFYGM = umodel.uLevel14; strsql2 += " And ((a.receiverid=" + userId + ") Or a.receiverid=0)"; userinfo = ",\"iflogin\":1," + returndata(umodel); } else { strsql2 += " And a.receiverid=0"; userinfo = ",\"iflogin\":2"; } } else { strsql2 += " And a.receiverid=0"; userinfo = ",\"iflogin\":2"; } } else { strsql2 += " And a.receiverid=0"; userinfo = ",\"iflogin\":0"; } int Start = 0; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } string strdata = ""; int msgCount = 0; if (Start == 0) { msgCount = daoArt.GetCount(strsql2); } strdata += "\"msgCount\":" + msgCount; DataSet ds; strdata += ",\"news\":["; if (Start == 0) { ds = daoArt.GetList1("id,title,Content", "gtype=0 and ParentID=17 and seef=1 Order by AddTime desc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { strdata += "{\"id\":\"" + Dr["id"].ToString() + "\",\"title\":\"" + Dr["title"].ToString() + "\",\"content\":\"" + Mtxfw.Utility.Common.ReplaceString(Dr["Content"].ToString()) + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); } strdata += "]"; string showtitle = "", showbody = ""; if (Start == 0) { ds = daoArt.GetList1("id,title,KeyWords,Content", "gtype=0 and ParentID=17 and wtype2=1 Order by AddTime desc"); if (ds.Tables[0].Rows.Count > 0) { showtitle = ds.Tables[0].Rows[0]["title"].ToString(); showbody = ds.Tables[0].Rows[0]["Content"].ToString(); } ds.Clear(); } strdata += ",\"showtitle\":\"" + showtitle + "\",\"showbody\":\"" + Mtxfw.Utility.Common.ReplaceString(showbody) + "\""; strdata += ",\"pic\":["; if (Start == 0) { ds = daoGoods.GetList1("id,GoodsName,GoodsPic,GoodsUrl", "gtype=0 and utype=4 Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string GoodsName = Dr["GoodsName"].ToString(); string GoodsUrl = Dr["GoodsUrl"].ToString(); string GoodsPic = Dr["GoodsPic"].ToString(); if (GoodsPic != "") { if (GoodsPic.IndexOf("http") == -1) { GoodsPic = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(GoodsPic, "720x360", "cut"); } else { GoodsPic = (GoodsPic + ""); } } strdata += "{\"img\":\"" + GoodsPic + "\",\"label\":\"" + GoodsName + "\",\"url\":\"" + GoodsUrl + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); } strdata += "]"; strdata += ",\"pic1\":["; if (Start == 0) { strdata += "{\"id\":\"0\",\"img\":\"\",\"label\":\"全部分类\""; strdata += "},"; System.Data.DataSet Ds_Productlb = new DAL.P_Category().GetList("", "gtype=" + gtype + " and ttype=0 And C_Layer=1 And IfShow=0 Order By C_LinkID Asc"); if (Ds_Productlb.Tables[0].Rows.Count > 0) { for (int i = 0; i < (Ds_Productlb.Tables[0].Rows.Count); i++) { string C_ID = ""; string C_NAME = ""; string C_images = ""; C_ID = Ds_Productlb.Tables[0].Rows[i]["C_ID"].ToString(); C_NAME = Ds_Productlb.Tables[0].Rows[i]["C_NAME"].ToString(); C_images = Ds_Productlb.Tables[0].Rows[i]["C_images"].ToString(); if (C_images != "") { if (C_images.IndexOf("http") == -1) { C_images = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(C_images, "380x380", "cut"); } else { C_images = (C_images + "?imageView2/2/w/220/h/220/q/75"); } } //int pcount = new DAL.P_Product().GetCount("gtype=" + gtype + " and utype=" + t + " And P_State=N'已处理' And IFDelete=0 and P_CATEGORYs like '," + C_ID + ",%' And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0"); //if (pcount > 0) //{ strdata += "{\"id\":\"" + C_ID + "\",\"img\":\"" + C_images + "\",\"label\":\"" + C_NAME + "\""; strdata += "},"; //} } } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } strdata += "]"; strdata += ",\"products\":["; DataSet Ds_Product0; if (Start == 0) { Ds_Product0 = daoProduct.GetList1("P_ID,P_NAME,P_images", "gtype=" + gtype + " And utype=2 And P_State=N'已处理' And IFDelete=0 And ((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)>0) order by P_IFTop Desc,P_HITED Desc"); if (Ds_Product0.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow drv2 in Ds_Product0.Tables[0].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = ""; string P_VIP_P = ""; string P_VIP_P0 = ""; string P_VIP_P1 = ""; string P_VIP_JF = ""; DataSet gds = new Mtxfw.DAL.P_Guige().GetList1("G_JG,G_JG0,G_JG1,G_JG2,G_JF", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 Order by G_JG asc"); if (gds.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG0"]).ToString("0.####"); P_VIP_P1 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG1"]).ToString("0.####"); P_Market_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_JF = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JF"]).ToString("0.####"); } gds.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string x = "440x440"; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje1\":\"" + P_VIP_P1 + "\",\"hyjf\":\"" + P_VIP_JF + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, x, "cut")) + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_Product0.Clear(); } strdata += "]"; strdata += ",\"products0\":["; if (Start == 0) { Ds_Product0 = daoProduct.GetList1("P_ID,P_NAME,P_images", "gtype=" + gtype + " And utype=14 And P_State=N'已处理' And IFDelete=0 and P_COMMENDF=1 And ((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)>0) order by P_IFTop Desc,P_HITED Desc"); if (Ds_Product0.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow drv2 in Ds_Product0.Tables[0].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = ""; string P_VIP_P = ""; string P_VIP_P0 = ""; string P_VIP_P1 = ""; string P_VIP_JF = ""; DataSet gds = new Mtxfw.DAL.P_Guige().GetList1("G_JG,G_JG0,G_JG1,G_JG2,G_JF", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 Order by G_JG asc"); if (gds.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG0"]).ToString("0.####"); P_VIP_P1 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG1"]).ToString("0.####"); P_Market_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_JF = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JF"]).ToString("0.####"); } gds.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string x = "440x320"; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje1\":\"" + P_VIP_P1 + "\",\"hyjf\":\"" + P_VIP_JF + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, x, "cut")) + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_Product0.Clear(); } strdata += "]"; strdata += ",\"products1\":["; string groupby = ""; string strOrder = "P_IFTop Desc,P_HITED Desc"; int categoryid = 0; if (!String.IsNullOrEmpty(context.Request["categoryid"])) { categoryid = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["categoryid"].ToString())); } int Limit = 12; Int32 Recount = 0;// System.Data.DataSet Ds_Product = new DAL.P_Product().GetDataSet(groupby, strOrder, "P_ID,P_NAME,P_images,P_CATEGORYs", "", "gtype=" + gtype + " And utype=0 and P_State=N'已处理' And IFDelete=0" + (categoryid > 0 ? " and (P_CATEGORY=" + categoryid + " Or P_CATEGORYs like '%," + categoryid + ",%')" : "") + " And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0", Start, Limit, out Recount); if (Ds_Product.Tables[1].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[1].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = "0.00"; string P_VIP_P = "0.00"; string P_VIP_P0 = "0.00"; string P_VIP_P1 = "0.00"; string P_VIP_P3 = "0.00"; string P_VIP_P4 = "0.00"; DataSet ds0 = new DAL.P_Guige().GetList1(" top 1 G_JG,G_JG0,G_JG1,G_JG2,G_JG3,G_JG4", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 order by G_JG asc"); if (ds0.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG0"]).ToString("0.####"); P_VIP_P1 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG1"]).ToString("0.####"); P_Market_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_P3 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG3"]).ToString("0.####"); P_VIP_P4 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG4"]).ToString("0.####"); } ds0.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string P_CATEGORYs = drv2["P_CATEGORYs"].ToString(); strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje1\":\"" + P_VIP_P1 + "\",\"hyje3\":\"" + P_VIP_P3 + "\",\"hyje4\":\"" + P_VIP_P4 + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut")) + "\"}"; strdata += ","; j += 1; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_Product.Clear(); strdata += "]"; strdata += userinfo; data = "{\"status\":1,\"IFCS\":1," + strdata + "}"; return data; } #endregion #region //获取商城首页数据----------------------------------------------------------------------------------------- /// /// 获取商城首页数据 /// protected string getshopdata(HttpContext context) { string data = "{\"status\":0}"; int IFYGM = 0; string userinfo = "", province = "", city = "", county = "", strAddress = ""; bool ifre = true; if (!String.IsNullOrEmpty(context.Request["ReDataMM"])) { if (context.Request["ReDataMM"].ToString() != config.ReDataMM) { ifre = false; } } if (ifre) { int Start = 0; if (!String.IsNullOrEmpty(context.Request["Start"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["Start"].ToString(), @"^-?\d+$")) { Start = Convert.ToInt32(context.Request["Start"].ToString()); } string strsql = ""; int nav = 0; if (!String.IsNullOrEmpty(context.Request["nav"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["nav"].ToString(), @"^-?\d+$")) { nav = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["nav"].ToString())); } } if (nav == 0) { strsql += " And P_CATEGORYs like '%,139,%'"; } else if (nav == 1) { strsql += " And P_CATEGORYs like '%,140,%'"; } else if (nav == 2) { strsql += " And P_CATEGORYs like '%,141,%'"; } else if (nav == 3) { strsql += " And P_CATEGORYs like '%,142,%'"; } string strdata = ""; int IFAuto = 0, ywccount = 0, ypzcount = 0, P_ID0 = 0; int userId = 0; string mindt = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["userId"].ToString(), @"^-?\d+$")) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { if (umodel.uLevel4 == 1) { DateTime dt0 = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); DateTime dt1 = Convert.ToDateTime(umodel.RegTime1.ToString("yyyy-MM-dd HH:mm:ss")); if (dt0 < dt1) { IFAuto = 1; if (umodel.uLevel24 > 0) { P_ID0 = umodel.uLevel24; IFAuto = 2; ywccount = umodel.uLevel26; if (ywccount > 0) { ypzcount = 1; //daoorder.GetCount1("ttype=6 and ptype=1 and IFDelete=0 and ifxhpt=1 and UserId=" + userId + " and O_Payed='5' and O_Shipped='1' And O_Payed_Date>='" + mindt + "' and O_Payed_Date<'" + maxdt + "'"); } } } } userinfo = ",\"iflogin\":1," + returndata(umodel); } else { userinfo = ",\"iflogin\":0}"; } } else { userinfo = ",\"iflogin\":2"; } } } string groupby = ""; string strOrder = "P_IFTop Desc,P_UserID Desc,P_HITED Desc"; int Limit = 20; Int32 Recount = 0; DateTime dt = DateTime.Now; strdata += "\"Products2\":["; DataSet Ds_Product0 = daoProduct.GetDataSet(groupby, strOrder, "P_ID,P_NAME,P_images,P_JiangLi", "", "gtype=" + gtype + " and utype='6' And P_State=N'已处理' And IFDelete=0 " + strsql + " And (((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)>0) Or ((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)=0 And P_Inventory>0))", Start, Limit, out Recount); int dtcount = Recount; if (Ds_Product0.Tables[1].Rows.Count > 0) { foreach (System.Data.DataRow drv2 in Ds_Product0.Tables[1].Rows) { int P_ID = Convert.ToInt32(drv2["P_ID"].ToString()); string P_NAME = drv2["P_NAME"].ToString(); string P_JiangLi = drv2["P_JiangLi"].ToString(); string P_Market_P = ""; string P_M_P = ""; string P_VIP_P = ""; string G_JG = "G_JG"; string strzd = new DAL.P_Guige().Getzd("min(" + G_JG + ")", "ttype=0 And G_PID=" + P_ID + " And G_KC>0").ToString(); if (strzd != "") { P_VIP_P = Convert.ToDouble(strzd).ToString("f2"); } strzd = new DAL.P_Guige().Getzd("min(G_JG2)", "ttype=0 And G_PID=" + P_ID + " And G_KC>0").ToString(); if (strzd != "") { P_Market_P = Convert.ToDouble(strzd).ToString("f2"); } int IFAutoed = 0; if (IFAuto > 0 && userId > 0) { if (P_ID0 == P_ID) { IFAutoed = 1; } } string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string x = "220x220"; strdata += "{\"_id\":\"" + P_ID + "\",\"IFAutoed\":\"" + IFAutoed + "\",\"ywccount\":\"" + ywccount + "\",\"ypzcount\":\"" + ypzcount + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"xjje\":\"" + P_M_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"YPTNum\":\"" + P_JiangLi + "\",\"image\":\"" + config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, x, "cut") + "\""; strdata += ",\"spell_list\":["; /*if (userId > 0) { DataSet ds = daoorder.GetZHList(" top 20 a.id,a.UserID,a.PCount,a.yPCount,a.O_SubmitDate,b.NCName,b.RealName,b.UserPic", "User_Info", "a.ttype=6 and a.ptype=1 and a.IFDelete=0 and a.ifxnhy=1 and a.pid=" + P_ID + " and a.poid=0 and a.O_Payed='4' and a.ypcount<" + config.webMoney1 + " and b.id=a.UserID Order by a.ypcount desc");// and a.PCount> if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int64 id = Int64.Parse(Dr["id"].ToString()); int MemberId = int.Parse(Dr["UserID"].ToString()); string NCName = Dr["NCName"].ToString(); string RealName = Mtxfw.Utility.Common.CName(Dr["RealName"].ToString()); string UserPic = Dr["UserPic"].ToString(); int PCount = int.Parse(Dr["PCount"].ToString()); int yPCount = int.Parse(Dr["yPCount"].ToString()); string SJC = ""; UserPic = (UserPic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(UserPic, "100x100", "cut") : ""); strdata += "{\"id\":\"" + id + "\",\"MemberId\":\"" + MemberId + "\",\"NCName\":\"" + RealName + "\",\"UserPic\":\"" + UserPic + "\",\"PCount\":\"" + (PCount - yPCount) + "\",\"SJC\":\"" + SJC + "\",\"times\":\"\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); }*/ strdata += "]},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_Product0.Clear(); strdata += "]"; if (Start == 0) { strdata += ",\"pic\":["; DataSet ds = daoGoods.GetList1("id,GoodsName,GoodsPic,GoodsUrl", "gtype=0 and utype=5 Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string GoodsName = Dr["GoodsName"].ToString(); string GoodsUrl = Dr["GoodsUrl"].ToString(); string GoodsPic = Dr["GoodsPic"].ToString(); strdata += "{\"img\":\"" + (GoodsPic.IndexOf("http") != -1 ? GoodsPic + "?imageView2/2/w/720/h/460/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(GoodsPic, "720x460", "cut")) + "\",\"label\":\"" + GoodsName + "\",\"url\":\"" + GoodsUrl + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); strdata += "]"; strdata += ",\"pic1\":["; System.Data.DataSet Ds_Productlb = new DAL.P_Category().GetList1("C_ID,C_NAME,C_images", "gtype=" + gtype + " and ttype=6 And C_Layer=1 And IfShow=0 Order By C_LinkID Asc"); if (Ds_Productlb.Tables[0].Rows.Count > 0) { for (int i = 0; i < (Ds_Productlb.Tables[0].Rows.Count); i++) { string C_ID = ""; string C_NAME = ""; string C_images = ""; C_ID = Ds_Productlb.Tables[0].Rows[i]["C_ID"].ToString(); C_NAME = Ds_Productlb.Tables[0].Rows[i]["C_NAME"].ToString(); C_images = Ds_Productlb.Tables[0].Rows[i]["C_images"].ToString(); if (C_images != "") { C_images = config.webUrl + config.webUpPath + C_images; } strdata += "{\"id\":\"" + C_ID + "\",\"img\":\"" + C_images + "\",\"label\":\"" + C_NAME + "\""; strdata += "},"; } } Ds_Productlb.Clear(); if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; strdata += ",\"products\":["; DataSet Ds_Product = daoProduct.GetList1("P_ID,P_NAME,P_images", "gtype=" + gtype + " And utype=5 And P_State=N'已处理' And IFDelete=0 " + strsql + " And (((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)>0) Or ((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)=0 And P_Inventory>0)) order by " + strOrder); if (Ds_Product.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = ""; string P_M_P = ""; string P_VIP_P = ""; string G_JG = "G_JG"; string strzd = new DAL.P_Guige().Getzd("min(" + G_JG + ")", "ttype=0 And G_PID=" + P_ID + " And G_KC>0").ToString(); if (strzd != "") { P_VIP_P = Convert.ToDouble(strzd).ToString("f2"); } strzd = new DAL.P_Guige().Getzd("min(G_JG2)", "ttype=0 And G_PID=" + P_ID + " And G_KC>0").ToString(); if (strzd != "") { P_Market_P = Convert.ToDouble(strzd).ToString("f2"); } string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string x = "220x220"; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"xjje\":\"" + P_M_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, x, "cut")) + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_Product.Clear(); strdata += "]"; strdata += (userinfo + ",\"IFAuto\":\"" + IFAuto + "\",\"IFYGM\":" + IFYGM + ",\"dlMemberId\":\"0\",\"province\":\"" + province + "\",\"city\":\"" + city + "\",\"county\":\"" + county + "\",\"Address\":\"" + strAddress + "\",\"servermsg\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.ServerMsg)) + "\",\"webname\":\"" + config.webName + "\""); } data = "{\"status\":1," + strdata + "}"; } } return data; } #endregion #region //获取其它商城数据----------------------------------------------------------------------------------------- /// /// 获取其它商城数据 /// protected string getothershopdata(HttpContext context) { string data = "{\"status\":0}"; bool ifb = true; int userId = 0, uLevel = 0; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["userId"].ToString(), @"^-?\d+$")) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { uLevel = umodel.uLevel; } else { ifb = false; } } else { ifb = false; } } else { ifb = false; } } if (ifb) { int t = 8; if (!String.IsNullOrEmpty(context.Request["t"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["t"].ToString(), @"^-?\d+$")) { t = Convert.ToInt32(context.Request["t"]); } } int pt = 4; if (t == 1) { pt = 4; } if (t == 2) { pt = 4; } if (t == 5) { pt = 4; } if (t == 6) { pt = 8; } if (t == 7) { pt = 9; } if (t == 8) { pt = 6; } if (t == 9) { pt = 7; } string strdata = "\"pic\":["; DataSet ds = daoGoods.GetList1("id,GoodsName,GoodsPic,GoodsUrl", "gtype=0 and utype=" + pt + " Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string GoodsName = Dr["GoodsName"].ToString(); string GoodsUrl = Dr["GoodsUrl"].ToString(); string GoodsPic = Dr["GoodsPic"].ToString(); strdata += "{\"img\":\"" + (GoodsPic.IndexOf("http") != -1 ? GoodsPic + "?imageView2/2/w/720/h/460/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(GoodsPic, "720x460", "cut")) + "\",\"label\":\"" + GoodsName + "\",\"url\":\"" + GoodsUrl + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); strdata += "]"; string strsql = ""; string strdata0 = "\"productlbs\":["; strdata += ",\"productlb\":["; if (t == 1) { System.Data.DataSet Ds_Product = new DAL.P_Product().GetList(" top 1", "gtype=" + gtype + " and utype=" + t + " And P_State=N'已处理' " + strsql + " And IFDelete=0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 Order By P_IFTop Desc,P_HITED Desc"); if (Ds_Product.Tables[0].Rows.Count > 0) { strdata += "{\"_id\":\"0\",\"name\":\"商品列表\",\"productlist\":[";// And P_M_P>0 int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = ""; string P_VIP_P = ""; string P_VIP_P0 = ""; string P_VIP_P1 = ""; string P_VIP_JF = ""; DataSet gds = new Mtxfw.DAL.P_Guige().GetList1("G_JG,G_JG0,G_JG1,G_JG2,G_JF", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 Order by G_JG asc"); if (gds.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG0"]).ToString("f2"); P_VIP_P1 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG1"]).ToString("f2"); P_Market_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_JF = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JF"]).ToString("0.####"); } gds.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje1\":\"" + P_VIP_P1 + "\",\"hyjf\":\"" + P_VIP_JF + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut")) + "\"}"; strdata += ","; j += 1; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]},"; } Ds_Product.Clear(); } else { System.Data.DataSet Ds_Productlb = new DAL.P_Category().GetList("", "gtype=" + gtype + " and ttype=" + t + " And C_Layer=1 And IfShow=0 Order By C_LinkID Asc"); //System.Data.DataSet Ds_Productlb = new DAL.P_Category().GetList("", "gtype=" + gtype + " and ttype=" + t + " And c_id=197 Order By C_LinkID Asc"); if (Ds_Productlb.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow drv in Ds_Productlb.Tables[0].Rows) { string C_ID = drv["C_ID"].ToString(); string C_NAME = drv["C_NAME"].ToString(); string C_images = Ds_Productlb.Tables[0].Rows[i]["C_images"].ToString(); if (C_images != "") { if (C_images.IndexOf("http") == -1) { C_images = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(C_images, "380x380", "cut"); } else { C_images = (C_images + "?imageView2/2/w/220/h/220/q/75"); } } //System.Data.DataSet Ds_Product = new DAL.P_Product().GetList(" top 2 ", "gtype=" + gtype + " and utype=" + t + " And IFDelete=0 " + strsql + " and P_CATEGORYs like '," + C_ID + ",%' And (Select count(c.G_ID) From P_Guige c where c.G_PID=a.P_ID And G_KC>0)>0 Order By P_IFTop Desc,P_HITED Desc"); System.Data.DataSet Ds_Product = new DAL.P_Product().GetList(" top 2 ", "gtype=" + gtype + " and utype=" + t + " And P_State=N'已处理' And IFDelete=0 " + strsql + " and P_CATEGORYs like '," + C_ID + ",%' And (Select count(c.G_ID) From P_Guige c where c.G_PID=a.P_ID And G_KC>0)>0 Order By P_IFTop Desc,P_HITED Desc"); if (Ds_Product.Tables[0].Rows.Count > 0) { if (i % 8 == 0) { strdata0 += "{\"datas\":["; } strdata += "{\"_id\":\"" + C_ID + "\",\"name\":\"" + C_NAME + "\",\"productlist\":[";// And P_M_P>0 int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = ""; string P_VIP_P = ""; string P_VIP_P0 = ""; string P_VIP_P1 = ""; string P_VIP_P6 = ""; string P_VIP_JF = ""; DataSet gds = new Mtxfw.DAL.P_Guige().GetList1("G_JG,G_JG0,G_JG1,G_JG2,G_JG6,G_JF", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 Order by G_JG asc"); if (gds.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG0"]).ToString("f2"); P_VIP_P1 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG1"]).ToString("f2"); P_Market_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_P6 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG6"]).ToString("0.####"); P_VIP_JF = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JF"]).ToString("0.####"); } gds.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje1\":\"" + P_VIP_P1 + "\",\"zzjf\":\"" + P_VIP_P6 + "\",\"hyjf\":\"" + P_VIP_JF + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut")) + "\"}"; strdata += ","; j += 1; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]},"; strdata0 += "{\"id\":\"" + C_ID + "\",\"img\":\"" + C_images + "\",\"label\":\"" + C_NAME + "\""; strdata0 += "},"; if ((i > 1 && ((i + 1) % 8 == 0)) || i == Ds_Productlb.Tables[0].Rows.Count - 1) { if (strdata0.Substring(strdata0.Length - 1, 1) == ",") { strdata0 = strdata0.Substring(0, strdata0.Length - 1); } strdata0 += "]},"; } i += 1; } Ds_Product.Clear(); } if (strdata0 != "\"productlbs\":[") { if (strdata0.Substring(strdata0.Length - 3, 3) != "]},") { if (strdata0.Substring(strdata0.Length - 1, 1) == ",") { strdata0 = strdata0.Substring(0, strdata0.Length - 1); } strdata0 += "]},"; } } } Ds_Productlb.Clear(); } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; if (strdata0.Substring(strdata0.Length - 1, 1) == ",") { strdata0 = strdata0.Substring(0, strdata0.Length - 1); } strdata0 += "]"; data = "{\"status\":1," + strdata + "," + strdata0 + "}"; } return data; } #endregion #region //获取其它商城数据0----------------------------------------------------------------------------------------- /// /// 获取其它商城数据0 /// protected string getothershopdata0(HttpContext context) { string data = "{\"status\":0}"; string userdata = ""; bool ifb = true; int userId = 0, uLevel = 0; Double umoney21 = 0.00; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId == LoginId) { uLevel = umodel.uLevel; umoney21 = Convert.ToDouble(umodel.umoney21.ToString("f2")); userdata = "," + returndata(umodel); } } } if (ifb) { int t = 0, pt = 4; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"]); } int t0 = 0; if (!String.IsNullOrEmpty(context.Request["t0"])) { t0 = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t0"].ToString())); } if (t == 0) { pt = 4; } if (t == 1) { pt = 3; } if (t == 2) { pt = 4; } if (t == 3) { pt = 4; } if (t == 5) { pt = 4; } if (t == 6) { pt = 4; } if (t == 7) { pt = 4; } if (t == 8) { pt = 5; } if (t == 9) { pt = 5; } if (t == 10) { pt = 4; } if (t == 11) { pt = 4; } string strdata = "\"pic\":["; /*if (t != 2) { DataSet ds = daoGoods.GetList1("id,GoodsName,GoodsPic,GoodsUrl", "gtype=0 and utype=" + pt + " Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = Convert.ToInt32(Dr["id"]); string GoodsName = Dr["GoodsName"].ToString(); string GoodsUrl = Dr["GoodsUrl"].ToString(); string GoodsPic = Dr["GoodsPic"].ToString(); if (GoodsPic != "") { if (GoodsPic.IndexOf("http") == -1) { GoodsPic = config.webUrl + Mtxfw.Utility.Common.GetCoverPic(GoodsPic, "720x360", "cut"); } else { GoodsPic = (GoodsPic + ""); } } strdata += "{\"img\":\"" + GoodsPic + "\",\"label\":\"" + GoodsName + "\",\"url\":\"" + GoodsUrl + "\"}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); }*/ strdata += "]"; strdata += ",\"productlist\":[";// And P_M_P>0 string groupby = ""; string strOrder = "P_IFTop Desc,P_HITED Desc"; int Start = 0; int Limit = 12; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } string sql = " and utype=" + t; Int32 Recount = 0;// System.Data.DataSet Ds_Product = new DAL.P_Product().GetDataSet(groupby, strOrder, "P_ID,P_NAME,P_images,P_CATEGORYs", "", "gtype=" + gtype + " and P_State=N'已处理' And IFDelete=0" + sql + " And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0", Start, Limit, out Recount); if (Ds_Product.Tables[1].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[1].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = "0.00"; string P_VIP_P = "0.00"; string P_VIP_P0 = "0.00"; string P_VIP_P1 = "0.00"; string P_VIP_P3 = "0.00"; string P_VIP_P4 = "0.00"; DataSet ds0 = new DAL.P_Guige().GetList1(" top 1 G_JG,G_JG0,G_JG1,G_JG2,G_JG3,G_JG4", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 order by G_JG asc"); if (ds0.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG0"]).ToString("0.####"); P_VIP_P1 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG1"]).ToString("0.####"); P_Market_P = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_P3 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG3"]).ToString("0.####"); P_VIP_P4 = Convert.ToDouble(ds0.Tables[0].Rows[0]["G_JG4"]).ToString("0.####"); } ds0.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string P_CATEGORYs = drv2["P_CATEGORYs"].ToString(); int type = 0;//开屏广告视频 if (P_CATEGORYs.IndexOf(",140,") != -1) { type = 1;//释放广告积分广告视频 } if (P_CATEGORYs.IndexOf(",141,") != -1) { type = 2;//释放贡献值广告视频 } if (P_CATEGORYs.IndexOf(",142,") != -1) { type = 3;//赚贡献值广告视频 } if (P_CATEGORYs.IndexOf(",245,") != -1) { type = 4;//短视频广告 } strdata += "{\"_id\":\"" + P_ID + "\",\"type\":\"" + type + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyje0\":\"" + P_VIP_P0 + "\",\"hyje1\":\"" + P_VIP_P1 + "\",\"hyje3\":\"" + P_VIP_P3 + "\",\"hyje4\":\"" + P_VIP_P4 + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut")) + "\"}"; strdata += ","; j += 1; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } Ds_Product.Clear(); strdata += "]"; int ifytfg = 0; Double maxmoney = 0.00; if (Start == 0) { if (daobusiness.GetCount("utype=1 and UserId=" + userId + "") > 0) { ifytfg = 1; } if (t == 15) { maxmoney = Convert.ToDouble(config.webMoney13); } } data = "{\"status\":1,\"ifytfg\":" + ifytfg + ",\"maxmoney\":\"" + maxmoney.ToString() + "\"," + strdata + userdata + "}"; } return data; } #endregion #region //获取我的数据----------------------------------------------------------------------------------------- /// /// 获取我的数据 /// protected string getmydata(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { data = "{\"status\":1,\"CloseEnable\":\"" + config.CloseEnable + "\",\"CloseMsg\":\"" + Mtxfw.Utility.Common.ReplaceString(config.CloseMsg) + "\"," + returndata(umodel) + "}"; } else { data = "{\"status\":0,\"CloseEnable\":\"" + config.CloseEnable + "\",\"CloseMsg\":\"" + Mtxfw.Utility.Common.ReplaceString(config.CloseMsg) + "\",\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"CloseEnable\":\"" + config.CloseEnable + "\",\"CloseMsg\":\"" + Mtxfw.Utility.Common.ReplaceString(config.CloseMsg) + "\",\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"CloseEnable\":\"" + config.CloseEnable + "\",\"CloseMsg\":\"" + Mtxfw.Utility.Common.ReplaceString(config.CloseMsg) + "\",\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取门店收款推送数据----------------------------------------------------------------------------------------- /// /// 获取门店收款推送数据 /// protected string getPaypushdata(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { if (umodel.uLevel36 == 1) { string strdata = "", strdata0 = ""; if (umodel.uLevel37 == 1) { daoUser.UpdateuLevel("uLevel37", 0, umodel.Id); DataSet ds = daojl2.GetList1("id,OrdersID,Totalmoney", "gtype=0 and utype=23 and IFDelete=0 and MemberId=" + umodel.Id + " and seef=0 And addTime>DateAdd(mi,-2,getdate()) Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int64 rid = Convert.ToInt64(Dr["Id"].ToString()); Int32 zftype = Convert.ToInt32(Dr["OrdersID"].ToString()); Double money = Convert.ToDouble(Dr["Totalmoney"].ToString()); string strq = "银花优选" + (zftype == 2 ? "微信收款" : zftype == 1 ? "支付宝收款" : "积分兑付") + "" + money + "元"; daojl2.UpdateSeef(1, rid); strdata += "{\"video\":\"http://211.149.175.190:29998/tts.mp3?v=F-zh-CN-Xiaoxiao&txt=" + HttpUtility.UrlEncode(strq) + "\"}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); } else if (umodel.uLevel38 == 1) { /* DataSet ds = daoResults.GetList1("id,b0,b17", "gtype=0 and utype=9 and IFDelete=0 and MemberId=" + umodel.Id + " and seef=0 And addTime>DateAdd(hour,-1,getdate()) Order By addtime asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int64 rid = Convert.ToInt64(Dr["Id"].ToString()); Int32 zftype = Convert.ToInt32(Dr["b17"].ToString().Split('.')[0]); Double money = Convert.ToDouble(Dr["b0"].ToString()); string strq = "银花优选" + (zftype == 2 ? "微信收款" : zftype == 1 ? "支付宝收款" : "积分兑付") + "" + money + "元"; daojl2.UpdateSeef(1, rid); strdata0 += "{\"id\":" + rid + ",\"video\":\"http://211.149.175.190:29998/tts.mp3?v=F-zh-CN-Xiaoxiao&txt=" + HttpUtility.UrlEncode(strq) + "\"}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata0 += ","; } i += 1; } } ds.Clear();*/ } data = "{\"status\":1,\"data\":[" + strdata + "],\"data0\":[" + strdata0 + "]}"; } else { data = "{\"status\":0,\"msg\":\"没有数据\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取门店收款推送数据0----------------------------------------------------------------------------------------- /// /// 获取门店收款推送数据0 /// protected string getPaypushdata0(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { if (umodel.uLevel36 == 1) { string ids = ""; if (!String.IsNullOrEmpty(context.Request["ids"])) { ids = HttpUtility.UrlDecode(context.Request["ids"].ToString()); } string strdata = ""; DataSet ds = daojl.GetList1("id,SHFX,conent", "gtype=0 and utype=0 and MemberId=" + umodel.Id + " and Count1=0 and Count2=1 And addTime>DateAdd(mi,-5,getdate()) Order By addtime asc");// And addTime>DateAdd(mi,-10,getdate()) if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int64 rid = Convert.ToInt64(Dr["Id"].ToString()); Int32 zftype = Convert.ToInt32(Dr["SHFX"].ToString()); string mp3 = Dr["conent"].ToString(); daojl.Updatemoney("Count1",1, rid); strdata += "{\"id\":\"" + rid + "\",\"zftype\":\"" + zftype + "\",\"mp3\":\"" + mp3 + "\"}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"没有数据\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取我的联盟门店数据--------------------------------------------------------------------------------- /// /// 获取我的联盟门店数据 /// protected string getmybusinessdata(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string ewmpic = umodel.thumb_media_id; string sjname = daobusiness.Getzd("companyname", "utype=0 and UserId=" + umodel.Id).ToString(); string sjylmoney = umodel.umoney42.ToString(); string smzemoney = umodel.umoney43.ToString(); string zsymoney = umodel.umoney28.ToString(); string jrmoney = daojl2.Getzd("sum(Totalmoney)", "gtype=" + gtype + " and utype=23 and MemberId=" + umodel.Id + " And IFDelete=0 And DateDiff(day,addtime,getdate())=0").ToString(); if (jrmoney == "") { jrmoney = "0"; } string zrmoney = daojl2.Getzd("sum(Totalmoney)", "gtype=" + gtype + " and utype=23 and MemberId=" + umodel.Id + " And IFDelete=0 And DateDiff(day,addtime,getdate())=1").ToString(); if (zrmoney == "") { zrmoney = "0"; } string strurl = config.webUrl; if (ewmpic == "") { var filepath = "/Files/grimage/" + umodel.Id + "/"; string filename = filepath + "sjewm.jpg"; if (!File.Exists(context.Server.MapPath(filepath))) { Directory.CreateDirectory(context.Server.MapPath(filepath)); } Bitmap bt; string enCodeString = strurl + "/mobile/smpay/?sjid=" + umodel.Id; QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(); //设置尺寸 qrCodeEncoder.QRCodeScale = 8; bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8); bt.Save(context.Server.MapPath(filename)); ewmpic = config.webUrl + filename; daoUser.UpdatePassword("thumb_media_id", ewmpic, umodel.Id); } data = "{\"status\":1,\"ewmpic\":\"" + (ewmpic != "" ? (ewmpic.IndexOf("https://") != -1 ? ewmpic : config.webUrl + ewmpic + "?t=2") : "") + "\",\"sjname\":\"" + sjname + "\",\"jrmoney\":\"" + Convert.ToDouble(jrmoney).ToString() + "\",\"zrmoney\":\"" + Convert.ToDouble(zrmoney).ToString() + "\",\"sjylmoney\":\"" + sjylmoney + "\",\"smzemoney\":\"" + smzemoney + "\",\"zsymoney\":\"" + zsymoney + "\",\"ifcs\":\"1\"," + returndata(umodel) + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取扫码记录----------------------------------------------------------------------------------------- /// /// 获取扫码记录 /// protected string getmybusiness_smlog(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } int t0 = 0; if (!String.IsNullOrEmpty(context.Request["t0"])) { t0 = Convert.ToInt32(context.Request["t0"].ToString()); } int MemberId = 0; if (!String.IsNullOrEmpty(context.Request["MemberId"])) { MemberId = Convert.ToInt32(context.Request["MemberId"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc,id desc"; string sql = " and MemberId=" + model.Id + ""; if (t0 == 1) { sql = " and MemberId=" + MemberId + ""; } else if (t0 == 2) { sql = " and TGYID=" + MemberId + ""; } if (t == 1) { sql += " And DateDiff(day,addtime,getdate())=0"; } else if (t == 2) { sql += " And DateDiff(day,addtime,getdate())=1"; } else { String SJ = context.Request["SJ"]; String SJ2 = context.Request["SJ2"]; if (!String.IsNullOrEmpty(SJ) && !String.IsNullOrEmpty(SJ2)) { if (SJ != "undefined" && SJ2 != "undefined") { sql += " and (addtime between '" + SJ + " 00:00:00' and '" + SJ2 + " 23:59:59') "; } } } int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daojl2.GetDataSet(groupby, strOrder, "id,Addmoney,Cutmoney,Totalmoney,addtime", "", "gtype=" + gtype + " and utype=23 And IFDelete=0" + sql, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string ylje = Convert.ToDouble(Dr["Addmoney"]).ToString(); string zjf = Convert.ToDouble(Dr["Cutmoney"]).ToString(); string zje = Convert.ToDouble(Dr["Totalmoney"]).ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"zje\":\"" + zje + "\",\"ylje\":\"" + ylje + "\",\"zjf\":\"" + zjf + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); string zsymoney = "0"; if (Start == 0) { //Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxMemberId.txt", "gtype=" + gtype + " and utype=23 And IFDelete=0" + sql); string strzd = daojl2.Getzd("sum(Totalmoney)", "gtype=" + gtype + " and utype=23 And IFDelete=0" + sql).ToString(); if (strzd != "") { zsymoney = Convert.ToDouble(strzd).ToString("f2"); } } data = "{\"status\":1,\"zsymoney\":\"" + zsymoney + "\",\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //开启或关闭收款推送----------------------------------------------------------------------------------------- /// /// 开启或关闭收款推送 /// protected string updatePaypush(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (t == 1) { if (model.uLevel36 == 1) { b = true; data = "{\"status\":0,\"msg\":\"状态不正确\"}"; } } else { if (model.uLevel36 == 0) { b = true; data = "{\"status\":0,\"msg\":\"状态不正确\"}"; } } if (b) { if (t != 0 && t != 1) { b = true; data = "{\"status\":0,\"msg\":\"状态不正确0\"}"; } } if (b) { daoUser.UpdateuLevel("uLevel36", t, model.Id); model.uLevel36 = t; data = "{\"status\":1,\"msg\":\"设置成功\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取我的事业部数据--------------------------------------------------------------------------------- /// /// 获取我的事业部数据 /// protected string getmybusinessdata0(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { int productcount = daoProduct.GetCount("gtype=" + gtype + " and IFDelete=0 and P_UserID=" + umodel.Id + " And P_State=N'已处理'"); int productcount0 = daoProduct.GetCount("gtype=" + gtype + " and IFDelete=0 and P_UserID=" + umodel.Id + " And P_State=N'未处理'"); int productcount1 = 0;// daoProduct.GetCount("gtype=" + gtype + " and IFDelete=0 and ttype=1 And P_ID in(select b.G_PID from P_fwzx b where b.MemberId=" + umodel.Id + ")"); int fhordercount0 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 and MemberId=" + umodel.Id + " and peitype=0 And O_Payed=1"); int fhordercount1 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 and MemberId=" + umodel.Id + " and peitype=0 And O_Payed=2"); int fhordercount2 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 and MemberId=" + umodel.Id + " and peitype=0 And O_Payed=3"); int kdordercount0 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 And UserId in(Select b.id from user_info b where b.IFStores=0 And (b.id=" + umodel.Id + " or b.ContactIDS like '%," + umodel.Id + ",%')) And O_Payed=1"); int kdordercount1 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 And UserId in(Select b.id from user_info b where b.IFStores=0 And (b.id=" + umodel.Id + " or b.ContactIDS like '%," + umodel.Id + ",%')) And O_Payed=2"); int kdordercount2 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 And UserId in(Select b.id from user_info b where b.IFStores=0 And (b.id=" + umodel.Id + " or b.ContactIDS like '%," + umodel.Id + ",%')) And O_Payed=3"); int ztordercount0 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 and ZTMemberId=" + umodel.Id + " And O_Payed=1"); int ztordercount1 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 and ZTMemberId=" + umodel.Id + " And O_Payed=2"); int ztordercount2 = daoorder.GetCount("gtype=" + gtype + " and IFDelete=0 and ZTMemberId=" + umodel.Id + " And O_Payed=3"); string zh = "", mm = "", mm0 = ""; DataSet ds = daoUser.GetList1("UserName,password,password2", "IFStores=1 and ShippingID=" + umodel.Id); if (ds.Tables[0].Rows.Count > 0) { zh = ds.Tables[0].Rows[0]["UserName"].ToString(); mm = Mtxfw.Utility.Security.DecryptString(ds.Tables[0].Rows[0]["password"].ToString()); mm0 = Mtxfw.Utility.Security.DecryptString(ds.Tables[0].Rows[0]["password2"].ToString()); } ds.Clear(); data = "{\"status\":1,\"zh\":\"" + zh + "\",\"mm\":\"" + mm + "\",\"mm0\":\"" + mm0 + "\",\"productcount\":\"" + productcount + "\",\"productcount0\":\"" + productcount0 + "\",\"productcount1\":\"" + productcount1 + "\",\"fhordercount0\":\"" + fhordercount0 + "\",\"fhordercount1\":\"" + fhordercount1 + "\",\"fhordercount2\":\"" + fhordercount2 + "\",\"kdordercount0\":\"" + kdordercount0 + "\",\"kdordercount1\":\"" + kdordercount1 + "\",\"kdordercount2\":\"" + kdordercount2 + "\",\"ztordercount0\":\"" + ztordercount0 + "\",\"ztordercount1\":\"" + ztordercount1 + "\",\"ztordercount2\":\"" + ztordercount2 + "\"," + returndata(umodel) + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取我的商品数据----------------------------------------------------------------------------------------- /// /// 获取我的商品数据 /// protected string getmyproducts(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["t"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = Convert.ToInt32(context.Request["t"].ToString()); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strsql = " And P_UserID=" + model.Id; if (t == 3) { strsql = " and ttype=1 And P_ID in(select b.G_PID from P_fwzx b where b.MemberId=" + model.Id + ")"; } else { if (t == 1) { strsql += " And P_State=N'已处理'"; } else if (t == 2) { strsql += " And P_State=N'未处理'"; } } string strdata = ""; strdata += "\"data\":["; string groupby = ""; string strOrder = "P_ADDATE Desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.P_Product().GetDataSet(groupby, strOrder, "P_ID,P_NAME,P_images", "", "gtype=" + gtype + " And IFDelete=0" + strsql + "", Start, Limit, out Recount); if (ds.Tables[1].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow drv2 in ds.Tables[1].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_VIP_P = ""; string strzd = new Mtxfw.DAL.P_Guige().Getzd("min(G_JG)", "G_PID=" + P_ID + "").ToString(); if (strzd != "") { P_VIP_P = Convert.ToDouble(strzd).ToString("f2"); } string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + P_NAME + "\",\"hyje\":\"" + P_VIP_P + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut")) + "\"}"; strdata += ","; j += 1; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); strdata += "]"; data = "{\"status\":1," + strdata + "}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取我的推广码----------------------------------------------------------------------------------------- /// /// 获取我的推广码 /// protected string getmytgm(HttpContext context) { string data = "{\"status\":0}"; int userId = 0; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string NCName = (umodel.NCName == "" ? umodel.RealName : umodel.NCName); string UserPic = umodel.UserPic; string QRcode = umodel.EWMPic2; string yqm = Mtxfw.Utility.Security.encrypt(umodel.Id).ToString(); if (QRcode == "") { bool ifb = true; DateTime dt1 = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); if (config.webXaccess_token != "" && config.webXaccess_token_time != "") { DateTime dt2 = Convert.ToDateTime(Convert.ToDateTime(config.webXaccess_token_time).AddMinutes(100).ToString("yyyy-MM-dd HH:mm:ss")); if (dt1 > dt2) { ifb = false; } } else { ifb = false; } if (!ifb) { Mtxfw.Utility.WXaccess_token ac = Mtxfw.Utility.Common.getxaccess_token(config.webXAppID, config.webXAppSecret); config.webXaccess_token = ac.access_token; config.webXaccess_token_time = dt1.ToString("yyyy-MM-dd HH:mm:ss"); config.Save(); } //string URL = "https://api.weixin.qq.com/wxa/getwxacode?access_token=" + config.webXaccess_token; //string json = "{\"path\":\"pages/index/index?tguid=" + Mtxfw.Utility.Security.encrypt(umodel.Id) + "\"}"; string URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + config.webXaccess_token; string json = "{\"scene\":\"" + Mtxfw.Utility.Security.encrypt(umodel.Id) + "\",\"page\":\"pages/index/index\"}"; byte[] bytes = Mtxfw.Utility.Common.GetResponsebyte(json, URL); string str = System.Text.Encoding.Default.GetString(bytes); //Mtxfw.Utility.Common.WriteHtml("/weixin/errcode.txt", str); if (str.IndexOf("errcode") != -1) { Mtxfw.Utility.WXaccess_token ac = Mtxfw.Utility.Common.getxaccess_token(config.webXAppID, config.webXAppSecret); config.webXaccess_token = ac.access_token; config.webXaccess_token_time = dt1.ToString("yyyy-MM-dd HH:mm:ss"); config.Save(); URL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + ac.access_token; bytes = Mtxfw.Utility.Common.GetResponsebyte(json, URL); str = BitConverter.ToString(bytes); //Mtxfw.Utility.Common.WriteHtml("/weixin/errcode0.txt", str); } /*var filepath = "/Files/grimage/" + umodel.Id + "/"; //创建保存位置 if (!Directory.Exists(context.Server.MapPath(filepath))) { Directory.CreateDirectory(context.Server.MapPath(filepath)); } string filename = filepath + "ewm.jpg"; //写入文件 System.IO.File.WriteAllBytes(context.Server.MapPath(filename), bytes); string ewmpic = "data:image/png;base64," + Mtxfw.Utility.Common.ImageToBase64(context.Server.MapPath(filename));*/ string ewmpic = "data:image/png;base64," + Convert.ToBase64String(bytes); new Mtxfw.DAL.user_info().UpdatePassword("EWMPic2", ewmpic, umodel.Id); umodel.EWMPic2 = ewmpic; } //Mtxfw.Utility.Common.WriteHtml("/weixin/EWMPic.txt", umodel.EWMPic2); data = "{\"status\":1,\"QRcode\":\"" + umodel.EWMPic2 + "\",\"minQRcode\":\"" + umodel.EWMPic2 + "\",\"yqm\":\"" + yqm + "\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //申请代理----------------------------------------------------------------------------------------- /// /// 申请代理 /// protected string appdeclaration(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["Province"]) && !String.IsNullOrEmpty(context.Request["City"]) && !String.IsNullOrEmpty(context.Request["County"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string Province = HttpUtility.UrlDecode(context.Request["Province"].ToString()); string City = HttpUtility.UrlDecode(context.Request["City"].ToString()); string County = HttpUtility.UrlDecode(context.Request["County"].ToString()); string AAddress = ""; if (!String.IsNullOrEmpty(context.Request["AAddress"])) { AAddress = HttpUtility.UrlDecode(context.Request["AAddress"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; Mtxfw.Model.user_proxy pm = daoproxy.GetModel(gtype, 1, model.Id); if (pm == null) { Mtxfw.Model.user_proxy pmodel = new Model.user_proxy(); pmodel.MemberId = model.Id; pmodel.AgenLevel = 0; pmodel.AgenCost = 0; pmodel.Agenprovince = Province; pmodel.Agencity = City; pmodel.Agencounty = County; pmodel.AAddress = AAddress; pmodel.IFJS = 0; pmodel.TType = 1; pmodel.gtype = gtype; pmodel.latitude = 0; pmodel.longitude = 0; pmodel.TType = 1; daoproxy.Add(pmodel); model.uLevel2 = 1; daoUser.UpdateuLevel("uLevel2", 1, model.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "申请成为代理,区域:" + new DAL.province().GetProvince(Province) + new DAL.city().GetCity(City) + new DAL.county().GetCounty(County); logmodel.UType = 2; logmodel.gtype = model.gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"提交申请成功,请耐心等待审核!\","+ returndata(model) + "}"; } else { data = "{\"status\":0,\"msg\":\"您已申请过代理!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //开通推广员----------------------------------------------------------------------------------------- /// /// 开通推广员 /// protected string kttgy(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["username"]) && !String.IsNullOrEmpty(context.Request["pwd"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string username = HttpUtility.UrlDecode(context.Request["username"].ToString()); string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } string title = "推广名额"; Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; int UserId = 0, uLevel16 = 0, uLevel33 = 0, uLevel34 = 0; SqlDataReader Dr = new Mtxfw.DAL.user_info().GetUserId(gtype, username); if (Dr.HasRows) { if (Dr.Read()) { UserId = Convert.ToInt32(Dr["Id"].ToString()); uLevel16 = Convert.ToInt32(Dr["uLevel16"].ToString()); uLevel33 = Convert.ToInt32(Dr["uLevel33"].ToString()); uLevel34 = Convert.ToInt32(Dr["uLevel34"].ToString()); } } Dr.Close(); if (UserId == 0) { if (b) { b = false; data = "{\"status\":0,\"msg\":\"账户不存在!\"}"; } } if (b) { if (t == 1) { if (uLevel16 == 1) { b = false; data = "{\"status\":0,\"msg\":\"" + username + "已申请过门店!\"}"; } else if (uLevel16 == 2) { b = false; data = "{\"status\":0,\"msg\":\"" + username + "已是门店!\"}"; } if (b) { if (uLevel34 == 1) { b = false; data = "{\"status\":0,\"msg\":\"" + username + "已激活过!\"}"; } } if (b) { if (model.uLevel33 < 2) { b = false; data = "{\"status\":0,\"msg\":\"您不是推广员不能激活门店!\"}"; } } } else { if (uLevel33 == 1) { b = false; data = "{\"status\":0,\"msg\":\"" + username + "已申请过推广员!\"}"; } if (uLevel33 == 2) { b = false; data = "{\"status\":0,\"msg\":\"" + username + "已是推广员!\"}"; } if (b) { if (model.uLevel25 < 2) { b = false; data = "{\"status\":0,\"msg\":\"您不是代理不能开通推广员!\"}"; } } } } Double money = 1.00; if (b) { if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } Double ktCurrency = 0.00; if (t == 0) { ktCurrency = Convert.ToDouble(Convert.ToDouble(model.umoney15.ToString("0.####")).ToString("f4")); if (b) { if (money > ktCurrency) { b = false; data = "{\"status\":0,\"msg\":\"您的" + title + "不足!\"}"; } } } if (b) { Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = money; ModelResults.b1 = 0; ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = t; ModelResults.conent = (t == 1 ? "激活门店" : "开通推广员"); ModelResults.Totalmoney = money; ModelResults.MemberId = model.Id; ModelResults.UserId = UserId; ModelResults.ListNumber = ""; ModelResults.Managers = ""; ModelResults.Seef = -1; ModelResults.utype = "13"; DateTime dt = DateTime.Now; ModelResults.addtime = dt; ModelResults.gtype = gtype; daoResults.Add(ModelResults); if (t == 0) { int utype = 22; daoUser.UpdateMoney("umoney15", -money, model.Id); model.umoney15 -= money; Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = UserId; mjl2.Addmoney = -money; mjl2.Cutmoney = 0; mjl2.Totalmoney = ktCurrency - money; mjl2.addtime = DateTime.Now; mjl2.BZContent = (t == 1 ? "激活门店" : "开通推广员"); mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = utype; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); } if (t == 1) { daoUser.UpdateuLevel("uLevel34", 1, UserId); daoUser.UpdateuLevel0("uLevel35", 1, model.Id); daoUser.UpdateuLevel("ActivateBusID", model.Id, UserId); } else { daoUser.UpdateuLevel("uLevel33", 2, UserId); daoUser.UpdateuLevel("DLRememberID", model.Id, UserId); } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = dt; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = (t == 1 ? "激活门店:" : "开通推广员:") + username; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"" + (t == 1 ? "激活" : "开通") + "成功!\"," + returndata(model) + "}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //开通推广员记录----------------------------------------------------------------------------------------- /// /// 开通推广员记录 /// protected string getkttgylist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; DataSet ds; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = new Mtxfw.DAL.user_Results().GetDataSet(groupby, strOrder, "id,b1,Totalmoney,conent,addtime,UserId,(Select UserName From user_info b Where b.Id=UserId) as UserName,(Select RealName From user_info b Where b.Id=UserId) as RealName,(Select "+(t ==1? "umoney43" : "umoney45") +" From user_info b Where b.Id=UserId) as umoney43", "", "gtype=" + gtype + " and MemberId=" + model.Id + " and utype=13 And IFDelete=0 and b18=" + t, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { Int64 id = Convert.ToInt64(Dr["id"]); string UserName = Dr["UserName"].ToString(); string RealName = Dr["RealName"].ToString(); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string addtime = Dr["addtime"].ToString(); int UserId = Convert.ToInt32(Dr["UserId"]); string smzemoney = Dr["umoney43"].ToString(); string sjname = ""; if (t == 1) { Mtxfw.Model.business_info bmodel = daobusiness.GetModelByUserId(0, UserId); if (bmodel != null) { sjname = bmodel.CompanyName; } } else { sjname = RealName; } if (smzemoney == "") { smzemoney = "0"; } string jrmoney = daojl2.Getzd("sum(Totalmoney)", "gtype=" + gtype + " and utype=23 and " + (t == 1 ? "MemberId" : "TGYID") + "=" + UserId + " And IFDelete=0 And DateDiff(day,addtime,getdate())=0").ToString(); if (jrmoney == "") { jrmoney = "0"; } string zrmoney = daojl2.Getzd("sum(Totalmoney)", "gtype=" + gtype + " and utype=23 and " + (t == 1 ? "MemberId" : "TGYID") + "=" + UserId + " And IFDelete=0 And DateDiff(day,addtime,getdate())=1").ToString(); if (zrmoney == "") { zrmoney = "0"; } strdata += "{\"id\":\"" + id + "\",\"UserId\":\"" + UserId + "\",\"UserName\":\"" + UserName + "\",\"sjname\":\"" + sjname + "\",\"money\":\"" + Totalmoney + "\",\"jrmoney\":\"" + Convert.ToDouble(jrmoney).ToString() + "\",\"zrmoney\":\"" + Convert.ToDouble(zrmoney).ToString() + "\",\"smzemoney\":\"" + Convert.ToDouble(smzemoney).ToString() + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取签到----------------------------------------------------------------------------------------- /// /// 获取签到 /// protected string getqiandao(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); if (userId > 0) { Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { int IFqiandao = 0; int qiandaonum = 0; DateTime lastdt = DateTime.Now; DataSet ds = daoqiandao.getqiandao(gtype, umodel.Id); if (ds.Tables[0].Rows.Count > 0) { IFqiandao = Convert.ToInt32(ds.Tables[0].Rows[0]["IFqiandao"].ToString()); qiandaonum = Convert.ToInt32(ds.Tables[0].Rows[0]["qiandaonum"].ToString()); if (ds.Tables[0].Rows[0]["lastdt"].ToString() != "") { lastdt = Convert.ToDateTime(ds.Tables[0].Rows[0]["lastdt"].ToString()); } if (qiandaonum >= (Convert.ToInt32(config.webMoney64))) { if (qiandaonum % Convert.ToInt32(config.webMoney64) == 0 && lastdt.ToString("yyyy-MM-dd")==DateTime.Now.ToString("yyyy-MM-dd")) { lastdt = lastdt.AddDays(-(Convert.ToInt32(config.webMoney64) - 1)); qiandaonum = Convert.ToInt32(config.webMoney64); } else { int cutnum = Convert.ToInt32((qiandaonum / Convert.ToInt32(config.webMoney64)).ToString().Split('.')[0]); qiandaonum -= (Convert.ToInt32(config.webMoney64) * cutnum); Mtxfw.Utility.Common.WriteHtml("/weixin/qiandaonum0.txt", qiandaonum + "|" + cutnum); if (qiandaonum == 0) { lastdt = DateTime.Now; } else { lastdt = lastdt.AddDays(-(qiandaonum - 1)); } } } else { if (qiandaonum == 0) { lastdt = DateTime.Now; } else { lastdt = lastdt.AddDays(-(qiandaonum - 1)); } } } ds.Clear(); Mtxfw.Utility.Common.WriteHtml("/weixin/qiandaonum.txt", lastdt.ToString()); string qiandaodays = ""; for (int i = 0; i < Convert.ToInt32(config.webMoney64); i++) { DateTime dt = lastdt; if (i > 0) { dt = lastdt.AddDays(i); } int IFqd = daoqiandao.GetCount("gtype=" + gtype + " and Q_MemberId=" + umodel.Id + " and DATEDIFF(day ,Q_SJ,'" + dt + "')=0"); Double QDJF = Convert.ToDouble(Convert.ToDouble(config.webMoney56).ToString("f2")); if (i > 0) { QDJF = Convert.ToDouble((Convert.ToDouble(config.webMoney56) + i * Convert.ToDouble(config.webMoney55)).ToString("f2")); } qiandaodays += "{\"IFqd\":" + IFqd + ",\"dt\":\"" + (dt.ToString("YYYY-MM-dd") == DateTime.Now.ToString("YYYY-MM-dd") ? "今日" : dt.ToString("MM月dd日")) + "\",\"QDJF\":\"" + QDJF + "\"}"; if (i < Convert.ToInt32(config.webMoney64)-1) { qiandaodays += ","; } } data = "{\"status\":1,\"IFqiandao\":\"" + IFqiandao + "\",\"qiandaonum\":\"" + qiandaonum + "\",\"qiandaodays\":[" + qiandaodays + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"登录参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //签到----------------------------------------------------------------------------------------- /// /// 签到 /// protected string qiandao(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); if (userId > 0) { Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { int IFqd = daoqiandao.GetCount("gtype=" + gtype + " and Q_MemberId=" + umodel.Id + " and DATEDIFF(day ,Q_SJ,getdate())=0"); if (IFqd == 0) { int qiandaonum = 0; DataSet ds = new DAL.qiandao().getqiandao(gtype, umodel.Id); if (ds.Tables[0].Rows.Count > 0) { qiandaonum = (Convert.ToInt32(ds.Tables[0].Rows[0]["qiandaonum"].ToString())); if (qiandaonum >= Convert.ToInt32(config.webMoney64)) { int cutnum = Convert.ToInt32((qiandaonum / Convert.ToInt32(config.webMoney64)).ToString().Split('.')[0]); qiandaonum -= (Convert.ToInt32(config.webMoney64) * cutnum); } } ds.Clear(); Double QDJF = Convert.ToDouble(Convert.ToDouble(config.webMoney56).ToString("f2")); if (qiandaonum > 0) { QDJF = Convert.ToDouble((Convert.ToDouble(config.webMoney56) + (qiandaonum * Convert.ToDouble(config.webMoney55))).ToString("f2")); } if (QDJF > 0.00) { Model.qiandao qmodel = new Model.qiandao(); qmodel.Q_MemberId = umodel.Id; qmodel.Q_Intro = ""; qmodel.Q_Num = 0; qmodel.gtype = gtype; daoqiandao.Add(qmodel); Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = QDJF; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney31 + QDJF); mjl2.addtime = DateTime.Now; mjl2.BZContent = "签到赠送"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 3; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); daoUser.UpdateMoney("umoney31", QDJF, umodel.Id); } data = "{\"status\":1,\"msg\":\"签到成功\"}"; } else { data = "{\"status\":0,\"msg\":\"今日已签到\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"登录参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region 添加商品 //添加商品 protected string product_post(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { if (umodel.uLevel15 == 1) { if (!String.IsNullOrEmpty(context.Request["title"]) && !String.IsNullOrEmpty(context.Request["guiges"]) && !String.IsNullOrEmpty(context.Request["photos"]) && !String.IsNullOrEmpty(context.Request["bianhao"])) { string title = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["title"].ToString())); string photos = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["photos"].ToString())); string bianhao = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["bianhao"].ToString())); string strguiges = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["guiges"].ToString())); string info = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["info"].ToString())); int id = 0; if (!String.IsNullOrEmpty(context.Request["id"])) { id = Convert.ToInt32(context.Request["id"]); } int ttype = 0; if (!String.IsNullOrEmpty(context.Request["ttype"])) { ttype = Convert.ToInt32(context.Request["ttype"]); } int p1 = 0; if (!String.IsNullOrEmpty(context.Request["p1"])) { p1 = Convert.ToInt32(context.Request["p1"]); } int p2 = 0; if (!String.IsNullOrEmpty(context.Request["p2"])) { p2 = Convert.ToInt32(context.Request["p2"]); } string date = ""; if (!String.IsNullOrEmpty(context.Request["date"])) { date = HttpUtility.UrlDecode(context.Request["date"].ToString()); } string date0 = ""; if (!String.IsNullOrEmpty(context.Request["date0"])) { date0 = HttpUtility.UrlDecode(context.Request["date0"].ToString()); } string time0 = ""; if (!String.IsNullOrEmpty(context.Request["time0"])) { time0 = HttpUtility.UrlDecode(context.Request["time0"].ToString()); } string time1 = ""; if (!String.IsNullOrEmpty(context.Request["time1"])) { time1 = HttpUtility.UrlDecode(context.Request["time1"].ToString()); } string video = ""; if (!String.IsNullOrEmpty(context.Request["video"])) { video = HttpUtility.UrlDecode(context.Request["video"].ToString()); } bool b = true; if (b) { Regex R1 = new Regex(@"<([\S\s\n\t]*?)>"); Match M1 = R1.Match(title); if (M1.Success) { b = false; data = "{\"status\":0,\"msg\":\"商品名称不能包含HTML代码\"}"; } } if (b) { Regex R1 = new Regex(@"<([\S\s\n\t]*?)>"); Match M1 = R1.Match(bianhao); if (M1.Success) { b = false; data = "{\"status\":0,\"msg\":\"商品编号不能包含HTML代码\"}"; } } if (b) { if (id == 0) { if (daoProduct.GetCount("P_UserID=" + umodel.Id + " And P_bianhao='" + bianhao + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"商品编号不能重复\"}"; } } else { if (daoProduct.GetCount("P_UserID=" + umodel.Id + " And P_bianhao='" + bianhao + "' and P_id<>" + id) > 0) { b = false; data = "{\"status\":0,\"msg\":\"商品编号不能重复\"}"; } } } List aguiges = guigesJson(strguiges); if (b) { if (aguiges.Count == 0) { b = false; data = "{\"status\":0,\"msg\":\"规格未填写\"}"; } } if (ttype == 7 || ttype == 8) { if (date != "每天") { string[] strdate = date.Split('至'); if (Convert.ToDateTime(strdate[0] + " 00:00:00").CompareTo(Convert.ToDateTime(strdate[1] + " 00:00:00"))>0) { b = false; data = "{\"status\":0,\"msg\":\"开始日期不能大于结束日期\"}"; } if (Convert.ToDateTime(strdate[0] + " " + time0 ).CompareTo(Convert.ToDateTime(strdate[0] + " " + time1))>=0) { b = false; data = "{\"status\":0,\"msg\":\"结束时间必须大于开始时间\"}"; } } else { DateTime dt = DateTime.Now; if (Convert.ToDateTime(dt.ToLongDateString() + " " + time0).CompareTo(Convert.ToDateTime(dt.ToLongDateString() + " " + time1))>=0) { b = false; data = "{\"status\":0,\"msg\":\"结束时间必须大于开始时间\"}"; } } } if (b) { string times = ""; if (ttype == 7 || ttype == 8) { times = (date + "," + time0 + "," + time1); } if (id > 0) { Mtxfw.Model.P_Product model = daoProduct.GetModel(id); if (model != null) { model.P_NAME = title; model.P_NAME2 = video; model.P_CATEGORY = p1; string P_CATEGORYs = "," + p1 + ","; if (p2 > 0) { P_CATEGORYs += p2 + ","; } model.P_CATEGORYs = P_CATEGORYs; model.P_DESCRIPTION = info; model.P_images = photos; model.P_bianhao = bianhao; model.P_EDESCRIPTION = times; model.P_ENAME = date0; model.P_State = "未处理"; model.utype = ttype.ToString(); model.P_EDESCRIPTION = times; model.P_ENAME = date0; model.utype = ttype.ToString(); daoProduct.Update(model); for (int i = 0; i < aguiges.Count; i++) { string colors = ""; for (int j = 0; j < aguiges[i].colors.Count; j++) { if (colors != "") { colors += ("," + aguiges[i].colors[j].color + "|" + aguiges[i].colors[j].kc); } else { colors = (aguiges[i].colors[j].color + "|" + aguiges[i].colors[j].kc); } } string images = ""; for (int j = 0; j < aguiges[i].images.Count; j++) { if (images != "") { images += ("|" + aguiges[i].images[j].pic + "," + aguiges[i].images[j].color); } else { images = (aguiges[i].images[j].pic + "," + aguiges[i].images[j].color); } } //Mtxfw.Utility.Common.WriteHtml("/weixin/aguiges.txt", aguiges[i].id + "|" + aguiges[i].gg); if (Convert.ToInt32(aguiges[i].id) > 0) { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(aguiges[i].id)); if (gmodel != null) { gmodel.G_Name = aguiges[i].gg; gmodel.G_JG = Convert.ToDouble(aguiges[i].jg); gmodel.G_JG0 = Convert.ToDouble(aguiges[i].jg0); gmodel.G_JG1 = Convert.ToDouble(aguiges[i].jg1); gmodel.G_JG2 = Convert.ToDouble(aguiges[i].jg2); gmodel.G_JG4 = Convert.ToDouble(aguiges[i].jg4); //gmodel.G_JF = Convert.ToDouble(jf); gmodel.G_ZL = Convert.ToDouble(aguiges[i].zl); gmodel.G_KC = Convert.ToInt32(aguiges[i].kc); gmodel.G_Color = colors; gmodel.G_Images = images; new DAL.P_Guige().Update(gmodel); } } else { if (new DAL.P_Guige().GetCount("MemberId=" + umodel.Id + " And G_PID='" + model.P_ID + "' And G_Name='" + aguiges[i].gg + "'") == 0) { Mtxfw.Model.P_Guige gmodel = new Model.P_Guige(); gmodel.G_PID = model.P_ID; gmodel.G_Name = aguiges[i].gg; gmodel.G_JG = Convert.ToDouble(aguiges[i].jg); gmodel.G_JG0 = Convert.ToDouble(aguiges[i].jg0); gmodel.G_JG1 = Convert.ToDouble(aguiges[i].jg1); gmodel.G_JG2 = Convert.ToDouble(aguiges[i].jg2); gmodel.G_JG3 = 0; gmodel.G_JG4 = Convert.ToDouble(aguiges[i].jg4); gmodel.G_JF = 0; gmodel.G_ZL = Convert.ToDouble(aguiges[i].zl); gmodel.G_KC = Convert.ToInt32(aguiges[i].kc); gmodel.G_Color = colors; gmodel.G_Images = images; gmodel.ttype = 0; gmodel.MemberId = umodel.Id; int returnid = new DAL.P_Guige().Add(gmodel); } } } if (context.Session["UploadFileIng"] != null) { string[] stra = context.Session["UploadFileIng"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { bool ifguiimage = true; for (int i = 0; i < aguiges.Count; i++) { for (int j = 0; j < aguiges[i].images.Count; j++) { if (aguiges[i].images[j].pic != "" && aguiges[i].images[j].pic == str.Trim()) { ifguiimage = false; } } } if (ifguiimage && model.P_images.IndexOf(str.Trim()) == -1 && model.P_DESCRIPTION.IndexOf(str.Trim()) == -1) { if (System.IO.File.Exists(context.Server.MapPath(str.Trim()))) { System.IO.File.Delete(context.Server.MapPath(str.Trim())); } } } } context.Session.Remove("UploadFileIng"); } System.Collections.IDictionaryEnumerator CacheEnum = context.Cache.GetEnumerator(); while (CacheEnum.MoveNext()) { context.Cache.Remove(CacheEnum.Key.ToString()); } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "编辑产品,标题:" + title; logmodel.UType = 1; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"编辑成功\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { Mtxfw.Model.P_Product model = new Mtxfw.Model.P_Product(); model.P_NAME = title; model.P_ENAME = ""; model.P_NAME2 = video; model.P_UserID = umodel.Id; model.P_State = "未处理"; model.P_CATEGORY = p1; string P_CATEGORYs = "," + p1 + ","; if (p2 > 0) { P_CATEGORYs += p2 + ","; } model.P_CATEGORYs = P_CATEGORYs; context.Session["P_CATEGORY1"] = p1; context.Session["P_CATEGORY2"] = p2; model.P_Market_P = 0; model.P_VIP_P = 0; model.P_VIP_P1 = 0; model.P_VIP_P2 = 0; model.P_M_P = 0; model.P_CB_P = 0; model.P_YH_P = 0; model.P_Inventory = 0; model.P_M_Web = ""; model.P_DESCRIPTION = info; model.P_COMMENDF = false; model.P_Orders = 0; model.P_ADDATE = DateTime.Now; model.P_HITED = 0; model.utype = ttype.ToString(); model.Province = umodel.CompanyProvince; model.City = umodel.CompanyCity; model.County = umodel.CompanyCounty; model.P_JiangLi = 0; model.P_JiangLi2 = 0; model.P_JiangLi3 = 0; model.P_yanse = ""; model.P_images = photos; model.P_DESCRIPTION1 = ""; model.P_DESCRIPTION2 = ""; model.P_EDESCRIPTION = times; model.P_ENAME = date0; model.P_bianhao = bianhao; int returnid = daoProduct.Add(model); string strzd = daoProduct.Getzd("max(P_HITED)", "utype='0'").ToString(); if (strzd != "") { daoProduct.Update(returnid, "P_HITED", (Convert.ToInt32(strzd) + 1).ToString()); } for (int i = 0; i < aguiges.Count; i++) { string colors = ""; for (int j = 0; j < aguiges[i].colors.Count; j++) { if (colors != "") { colors += ("," + aguiges[i].colors[j].color + "|" + aguiges[i].colors[j].kc); } else { colors = (aguiges[i].colors[j].color + "|" + aguiges[i].colors[j].kc); } } string images = ""; for (int j = 0; j < aguiges[i].images.Count; j++) { if (images != "") { images += ("|" + aguiges[i].images[j].pic + "," + aguiges[i].images[j].color); } else { images = (aguiges[i].images[j].pic + "," + aguiges[i].images[j].color); } } if (Convert.ToInt32(aguiges[i].id) > 0) { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(aguiges[i].id)); if (gmodel != null) { gmodel.G_Name = aguiges[i].gg; gmodel.G_JG = Convert.ToDouble(aguiges[i].jg); gmodel.G_JG0 = Convert.ToDouble(aguiges[i].jg0); gmodel.G_JG1 = Convert.ToDouble(aguiges[i].jg1); gmodel.G_JG2 = Convert.ToDouble(aguiges[i].jg2); gmodel.G_JG4 = Convert.ToDouble(aguiges[i].jg4); //gmodel.G_JF = Convert.ToDouble(jf); gmodel.G_ZL = Convert.ToDouble(aguiges[i].zl); gmodel.G_KC = Convert.ToInt32(aguiges[i].kc); gmodel.G_Color = colors; gmodel.G_Images = images; new DAL.P_Guige().Update(gmodel); } } else { if (new DAL.P_Guige().GetCount("MemberId=" + umodel.Id + " And G_PID='" + returnid + "' And G_Name='" + aguiges[i].gg + "'") == 0) { Mtxfw.Model.P_Guige gmodel = new Model.P_Guige(); gmodel.G_PID = returnid; gmodel.G_Name = aguiges[i].gg; gmodel.G_JG = Convert.ToDouble(aguiges[i].jg); gmodel.G_JG0 = Convert.ToDouble(aguiges[i].jg0); gmodel.G_JG1 = Convert.ToDouble(aguiges[i].jg1); gmodel.G_JG2 = Convert.ToDouble(aguiges[i].jg2); gmodel.G_JG3 = 0; gmodel.G_JF = 0; gmodel.G_ZL = Convert.ToDouble(aguiges[i].zl); gmodel.G_KC = Convert.ToInt32(aguiges[i].kc); gmodel.G_Color = colors; gmodel.G_Images = images; gmodel.ttype = 0; gmodel.MemberId = umodel.Id; new DAL.P_Guige().Add(gmodel); } } } daoCategory.Update2(model.P_CATEGORY, 1); if (context.Session["UploadFileIng"] != null) { string[] stra = context.Session["UploadFileIng"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { bool ifguiimage = true; for (int i = 0; i < aguiges.Count; i++) { for (int j = 0; j < aguiges[i].images.Count; j++) { if (aguiges[i].images[j].pic != "" && aguiges[i].images[j].pic == str.Trim()) { ifguiimage = false; } } } if (ifguiimage && model.P_images.IndexOf(str.Trim()) == -1 && model.P_DESCRIPTION.IndexOf(str.Trim()) == -1) { if (System.IO.File.Exists(context.Server.MapPath(str.Trim()))) { System.IO.File.Delete(context.Server.MapPath(str.Trim())); } } } } context.Session.Remove("UploadFileIng"); } System.Collections.IDictionaryEnumerator CacheEnum = context.Cache.GetEnumerator(); while (CacheEnum.MoveNext()) { context.Cache.Remove(CacheEnum.Key.ToString()); } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "添加商品,商品名称:" + title; logmodel.UType = 1; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"添加成功\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } } else { data = "{\"status\":0,\"msg\":\"未审核不能发布\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } public List guigesJson(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize>(json); } #endregion #region 获取商品详情 //获取商品详情 protected string getproductsinfo(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (!String.IsNullOrEmpty(context.Request["aid"])) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); int aid = Convert.ToInt32(context.Request["aid"].ToString()); Mtxfw.Model.P_Product pmodel = daoProduct.GetModel(aid); if (pmodel != null) { string strdata = ",\"guige\":["; int kc = pmodel.P_Inventory; Decimal zzl = Convert.ToDecimal(pmodel.P_YH_P.ToString("f2")); DataSet ds = new DAL.P_Guige().GetList("ttype=0 And G_KC>0 And G_PID=" + pmodel.P_ID); if (ds.Tables[0].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int G_ID = int.Parse(Dr["G_ID"].ToString()); string G_Name = Dr["G_Name"].ToString(); string G_Color = Dr["G_Color"].ToString(); string G_Images = Dr["G_Images"].ToString(); Decimal G_JG = Decimal.Parse(Dr["G_JG"].ToString()); Decimal G_JG0 = Decimal.Parse(Dr["G_JG0"].ToString()); Decimal G_JG1 = Decimal.Parse(Dr["G_JG1"].ToString()); Decimal G_JG2 = Decimal.Parse(Dr["G_JG2"].ToString()); Decimal G_JG4 = Decimal.Parse(Dr["G_JG4"].ToString()); Decimal G_JF = Decimal.Parse(Dr["G_JF"].ToString()); Decimal G_ZL = Decimal.Parse(Dr["G_ZL"].ToString()); int G_KC = int.Parse(Dr["G_KC"].ToString()); string[] acolors = G_Color.Split(','); string colors = "["; for (int k = 0; k < acolors.Length; k++) { if (acolors[k] != "") { var acolor = acolors[k].Split('|'); colors += "{\"color\":\"" + acolor[0] + "\",\"kc\":\"" + acolor[1] + "\"},"; } } if (colors.Substring(colors.Length - 1, 1) == ",") { colors = colors.Substring(0, colors.Length - 1); } colors += "]"; string[] aimages = G_Images.Split('|'); string images = "["; for (int k = 0; k < aimages.Length; k++) { if (aimages[k] != "") { var aimage = aimages[k].Split(','); images += "{\"url\":\"" + (aimage[0] != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(aimage[0], "40x40", config.webImgMode) : "") + "\",\"pic\":\"" + aimage[0] + "\",\"color\":\"" + aimage[1] + "\",\"cindex\":-1},"; } } if (images.Substring(images.Length - 1, 1) == ",") { images = images.Substring(0, images.Length - 1); } images += "]"; if (j == 0) { kc = G_KC; zzl = Convert.ToDecimal(Convert.ToDecimal(Dr["G_ZL"].ToString()).ToString("f2")); } strdata += "{\"id\":\"" + G_ID + "\",\"gg\":\"" + G_Name + "\",\"jg\":\"" + G_JG.ToString("f2") + "\",\"jg0\":\"" + G_JG0.ToString("f2") + "\",\"jg1\":\"" + G_JG1.ToString("f2") + "\",\"jg2\":\"" + G_JG2.ToString("f2") + "\",\"jg4\":\"" + G_JG4.ToString("f2") + "\",\"jf\":\"" + G_JF.ToString() + "\",\"zl\":\"" + G_ZL.ToString("f0") + "\",\"kc\":\"" + G_KC.ToString() + "\",\"colors\":" + colors + ",\"images\":" + images + "},"; j += 1; } } if (strdata != "") { if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } strdata += "]"; string[] apics = pmodel.P_images.Split('|'); strdata += ",\"images\":["; for (int k = 0; k < apics.Length; k++) { if (apics[k] != "") { if (k > 0) { var apic = apics[k].Split(','); strdata += "{\"url\":\"" + (apic[0] != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(apic[0], "40x40", config.webImgMode) : "") + "\",\"pic\":\"" + apic[0] + "\"},"; } } } if (strdata != "") { if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } strdata += "]"; string p1 = "", p2 = ""; string[] ACATEGORYs = pmodel.P_CATEGORYs.Split(','); if (ACATEGORYs.Length > 1) { p1 = ACATEGORYs[1]; } if (ACATEGORYs.Length > 2) { p2 = ACATEGORYs[2]; } strdata += ",\"times\":["; if (pmodel.utype == "7" || pmodel.utype == "8") { if (pmodel.P_EDESCRIPTION != "") { string[] astr = pmodel.P_EDESCRIPTION.Split('|'); int i = 0; foreach (string str in astr) { if (str != "") { string[] astr1 = str.Split(','); if (astr1.Length == 3) { strdata += "{\"date\":\"" + astr1[0] + "\",\"time0\":\"" + astr1[1] + "\",\"time1\":\"" + astr1[2] + "\"},"; } i += 1; } } } } if (strdata != "") { if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } strdata += "]"; strdata += ",\"date0\":\"" + pmodel.P_ENAME + "\""; data = "{\"status\":1,\"ttype\":\"" + pmodel.utype + "\",\"h_p1\":\"" + p1 + "\",\"h_p2\":\"" + p2 + "\",\"h_title\":\"" + Mtxfw.Utility.Common.ReplaceString(pmodel.P_NAME) + "\",\"gmnum\":\"" + pmodel.P_JiangLi + "\",\"h_bianhao\":\"" + pmodel.P_bianhao + "\",\"h_pic\":\"" + pmodel.P_images + "\",\"h_video\":\"" + pmodel.P_NAME2 + "\",\"h_info\":\"" + Mtxfw.Utility.Common.ReplaceString(pmodel.P_DESCRIPTION) + "\"" + strdata + "}"; } else { data = "{\"status\":0,\"msg\":'参数错误!'}"; } } else { data = "{\"status\":0,\"msg\":'参数为空!'}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取商品分类数据----------------------------------------------------------------------------------------- /// /// 获取商品分类数据 /// protected string getshopcategory(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { if (context.Request["CartId"].ToString().Length == 36) { CartId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CartId"].ToString())); } } int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["e"].ToString(), @"^-?\d+$")) { e = Convert.ToInt32(context.Request["e"].ToString()); } } string strsql = ""; int categoryid = 0; if (!String.IsNullOrEmpty(context.Request["categoryid"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["categoryid"].ToString(), @"^-?\d+$")) { categoryid = Convert.ToInt32(context.Request["categoryid"].ToString()); } } int categoryid0 = 0; if (!String.IsNullOrEmpty(context.Request["categoryid0"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["categoryid0"].ToString(), @"^-?\d+$")) { categoryid0 = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["categoryid0"].ToString()))); } } if (categoryid0 > 0) { strsql = " and (P_CATEGORY=" + categoryid0 + " Or P_CATEGORYs like '%," + categoryid0 + ",%')"; } else { if (categoryid > 0) { strsql = " and (P_CATEGORY=" + categoryid + " Or P_CATEGORYs like '%," + categoryid + ",%')"; } } string strdata = ""; strdata += "\"productlist\":["; string groupby = ""; string strOrder = "P_HITED Desc"; int Start = 0; int Limit = 20; if (!String.IsNullOrEmpty(context.Request["Start"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["Start"].ToString(), @"^-?\d+$")) { Start = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Start"].ToString()))); } } Int32 Recount = 0; System.Data.DataSet Ds_Product = new Mtxfw.DAL.P_Product().GetDataSet(groupby, strOrder, "P_ID,P_NAME,P_Market_P,P_VIP_P,P_images,utype", "", "gtype=" + gtype + " And P_State=N'已处理' And IFDelete=0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And c.G_KC>0)>0" + strsql, Start, Limit, out Recount); if (Ds_Product.Tables[1].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[1].Rows) { string P_ID = drv2["P_ID"].ToString(); string utype = drv2["utype"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_Market_P = Convert.ToDouble(drv2["P_Market_P"]).ToString("f2"); string P_VIP_P = Convert.ToDouble(drv2["P_VIP_P"]).ToString("f2"); string sql = "min(G_JG)"; if (utype == "5") { sql = "min(G_JG2)"; } string strzd = new Mtxfw.DAL.P_Guige().Getzd("" + sql + "", "ttype=0 And G_PID=" + P_ID + "").ToString(); if (strzd != "") { P_VIP_P = Convert.ToDouble(strzd).ToString("f2"); } strzd = new Mtxfw.DAL.P_Guige().Getzd("min(G_JG2)", "ttype=0 And G_PID=" + P_ID + "").ToString(); if (strzd != "") { P_Market_P = Convert.ToDouble(strzd).ToString("f2"); } string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + P_NAME + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, "220x220", "cut")) + "\"}"; if (j != Ds_Product.Tables[1].Rows.Count - 1) { strdata += ","; } j += 1; } } Ds_Product.Clear(); strdata += "]"; int navindex = 0; if (Start == 0) { strdata += ",\"productlb\":["; System.Data.DataSet Ds_Productlb = new DAL.P_Category().GetList("", "gtype=" + gtype + " and ttype=0 And C_Layer=1 And IfShow=0 Order By C_LinkID Asc"); if (Ds_Productlb.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow drv in Ds_Productlb.Tables[0].Rows) { string C_ID = drv["C_ID"].ToString(); string C_NAME = drv["C_NAME"].ToString(); string C_images = drv["C_images"].ToString(); if (categoryid.ToString() == C_ID) { navindex = i; } strdata += "{\"header\":\"" + C_NAME + "\",\"image\":\"" + (C_images != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(C_images, "300x300", config.webImgMode) : "") + "\""; strdata += ",\"productlb\":["; System.Data.DataSet Ds_Productlb2 = new DAL.P_Category().GetList("", "gtype=" + gtype + " and ttype=0 And C_PARENTID=" + C_ID + " And IfShow=0 Order By C_LinkID Asc"); if (Ds_Productlb2.Tables[0].Rows.Count > 0) { int i2 = 0; foreach (System.Data.DataRow drv2 in Ds_Productlb2.Tables[0].Rows) { string C_ID2 = drv2["C_ID"].ToString(); string C_NAME2 = drv2["C_NAME"].ToString(); string C_images2 = drv2["C_images"].ToString(); strdata += "{\"header\":\"" + C_NAME2 + "\",\"image\":\"" + (C_images2 != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(C_images2, "300x300", config.webImgMode) : "") + "\",\"id\":\"" + C_ID2 + "\"}"; if (i2 != Ds_Productlb2.Tables[0].Rows.Count - 1) { strdata += ","; } i2 += 1; } } Ds_Productlb2.Clear(); strdata += "]"; strdata += ",\"id\":\"" + C_ID + "\""; strdata += "}"; if (i != Ds_Productlb.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } Ds_Productlb.Clear(); strdata += "]"; } int cartcount = 0; if (CartId != "") { string strzd = new DAL.user_cart().Getzd("sum(ProductNum)", "gtype=" + gtype + " and ttype=0 And CartId='" + CartId + "'").ToString(); if (strzd != "") { cartcount = Convert.ToInt32(strzd); } } data = "{\"status\":1," + strdata + ",\"cartcount\":\"" + cartcount + "\",\"navindex\":\"" + navindex + "\"}"; return data; } #endregion #region //获取微信分类商品列表----------------------------------------------------------------------------------------- /// /// 获取微信分类商品列表 /// protected string getwxshoplist(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { if (context.Request["CartId"].ToString().Length == 36) { CartId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CartId"].ToString())); } } int categoryid = 0; if (!String.IsNullOrEmpty(context.Request["categoryid"])) { categoryid = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["categoryid"].ToString()))); } int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["e"].ToString())); } int userId = 0, uLevel = 0; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { uLevel = umodel.uLevel; } } } int cid = categoryid; string strsql = ""; if (!String.IsNullOrEmpty(context.Request["selcityid"])) { string selcityid = Mtxfw.Utility.Tools.SafeSQL(context.Request["selcityid"].ToString()); if (!String.IsNullOrEmpty(context.Request["selcountyid"])) { string selcountyid = Mtxfw.Utility.Tools.SafeSQL(context.Request["selcountyid"].ToString()); DataSet pds = daoproxy.GetList1("MemberId", "gtype=" + gtype + " and TType=1 and Agencity='" + selcityid + "' and Agencounty='" + selcountyid + "'"); if (pds.Tables[0].Rows.Count > 0) { strsql += " And (P_UserID=0 Or (P_city='" + selcityid + "' and P_county='" + selcountyid + "'))"; } else { strsql += " And P_UserID=0"; } pds.Clear(); } else { DataSet pds = daoproxy.GetList1("MemberId", "gtype=" + gtype + " and TType=1 and Agencity='" + selcityid + "'"); if (pds.Tables[0].Rows.Count > 0) { strsql += " And (P_UserID=0 Or P_city='" + selcityid + "')"; } else { strsql += " And P_UserID=0"; } pds.Clear(); } } else { if (!String.IsNullOrEmpty(context.Request["dlMemberId"])) { int dlMemberId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["dlMemberId"].ToString())); strsql += " And (P_UserID=0 Or P_UserID=" + dlMemberId + ")"; } } string strCartId = CartId; string sql = strsql; if (e == 1) { sql += " and P_NAME2<>''"; } if (!String.IsNullOrEmpty(context.Request["keyword"])) { string key = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["keyword"].ToString()).Trim()); string GetCategoryIDs = daoCategory.GetCategoryIDs(0, key); string sql0 = ""; if (GetCategoryIDs != "") { string[] aCategoryIDs = GetCategoryIDs.Split(','); foreach (string CategoryID in aCategoryIDs) { sql0 += " or P_CATEGORYs like '%," + CategoryID + ",%'"; } } sql += " and (P_NAME like '%" + key + "%' Or P_bianhao like '%" + key + "%'"+ sql0 + ")"; } else { sql += " and (P_CATEGORY=" + cid + " Or P_CATEGORYs like '%," + cid + ",%')"; } string strdata = ""; strdata += "\"productlist\":["; string groupby = ""; string strOrder = "P_IFTop Desc,P_UserID Desc,P_HITED Desc"; int Start = 0; int Limit = 12; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Start"].ToString()))); } Int32 Recount = 0;// System.Data.DataSet Ds_Product = new DAL.P_Product().GetDataSet(groupby, strOrder, "P_ID,P_NAME,P_NAME2,P_CATEGORYs,P_Market_P,P_VIP_P,P_M_P,P_images", "", "gtype=" + gtype + " and P_State=N'已处理' And IFDelete=0" + sql + " And (((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)>0) Or ((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)=0 And P_Inventory>0))", Start, Limit, out Recount); if (Ds_Product.Tables[1].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[1].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_NAME2 = drv2["P_NAME2"].ToString(); string P_CATEGORYs = drv2["P_CATEGORYs"].ToString(); if (e == 1) { P_NAME = P_NAME2; } string P_Market_P = ""; string P_VIP_P = ""; string P_VIP_P0 = ""; string P_VIP_P1 = ""; string P_VIP_JF = ""; DataSet gds = new Mtxfw.DAL.P_Guige().GetList1("G_JG,G_JG0,G_JG1,G_JG2,G_JF", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 Order by G_JG asc"); if (gds.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_VIP_P0 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG0"]).ToString("0.####"); P_VIP_P1 = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG1"]).ToString("0.####"); P_Market_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); P_VIP_JF = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JF"]).ToString("0.####"); } gds.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string x = "220x220"; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"hyjf\":\"" + P_VIP_JF + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, x, "cut")) + "\"}"; if (j != Ds_Product.Tables[1].Rows.Count - 1) { strdata += ","; } j += 1; } } Ds_Product.Clear(); strdata += "]"; data = "{\"status\":1," + strdata + ",\"Recount\":\"" + Recount + "\"}"; return data; } #endregion #region //获取搜索商品列表----------------------------------------------------------------------------------------- /// /// 获取搜索商品列表 /// protected string getshopsearch(HttpContext context) { string data = "{\"status\":0}"; string CartId = "", strkey = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { if (context.Request["CartId"].ToString().Length == 36) { CartId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CartId"].ToString())); } } if (!String.IsNullOrEmpty(context.Request["key"])) { strkey = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["key"].ToString())); } int userId = 0, uLevel = 0; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { uLevel = umodel.uLevel; } } } string sql = " and P_NAME like '%" + strkey + "%'"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["e"].ToString())); } if (e == 1) { sql = " and P_NAME2 like '%" + strkey + "%'"; } string strdata = ""; strdata += "\"productlist\":["; System.Data.DataSet Ds_Product = new DAL.P_Product().GetList(" top 20 ", "gtype=" + gtype + " and utype='0' And P_State=N'已处理' And IFDelete=0" + sql + " And (((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID And G_KC>0)>0 And (Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)>0) Or ((Select count(c.G_ID) From P_Guige c where c.G_PID=P_ID)=0 And P_Inventory>0)) Order By P_IFTop Desc,P_UserID Desc,P_HITED Desc"); int productcount = Ds_Product.Tables[0].Rows.Count; if (productcount > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string P_ID = drv2["P_ID"].ToString(); string P_NAME = drv2["P_NAME"].ToString(); string P_NAME2 = drv2["P_NAME2"].ToString(); string P_CATEGORYs = drv2["P_CATEGORYs"].ToString(); if (e == 1) { P_NAME = P_NAME2; } string P_Market_P = Convert.ToDouble(drv2["P_Market_P"]).ToString("f2"); string P_VIP_P = Convert.ToDouble(drv2["P_VIP_P"]).ToString("f2"); DataSet gds = new Mtxfw.DAL.P_Guige().GetList1("G_JG,G_JG0,G_JG1,G_JG2,G_JF", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 Order by G_JG asc"); if (gds.Tables[0].Rows.Count > 0) { P_VIP_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG"]).ToString("f2"); P_Market_P = Convert.ToDouble(gds.Tables[0].Rows[0]["G_JG2"]).ToString("f2"); } gds.Clear(); string P_images = drv2["P_images"].ToString().Split('|')[0].Split(',')[0]; string x = "220x220"; strdata += "{\"_id\":\"" + P_ID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(P_NAME) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"image\":\"" + (P_images.IndexOf("http") != -1 ? P_images + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, x, "cut")) + "\"}"; if (j != Ds_Product.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } } Ds_Product.Clear(); strdata += "]"; data = "{\"status\":1," + strdata + ",\"productcount\":\"" + productcount + "\"}"; return data; } #endregion #region //获取商品详情----------------------------------------------------------------------------------------- /// /// 获取商品详情 /// protected string getshopview(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { if (context.Request["CartId"].ToString().Length == 36) { CartId = HttpUtility.UrlDecode(context.Request["CartId"].ToString()); } } bool ifre = true; if (!String.IsNullOrEmpty(context.Request["ReDataMM"])) { if (context.Request["ReDataMM"].ToString() != config.ReDataMM) { ifre = false; } } if (ifre) { int userId = 0, uLevel = 0, tguid = 0; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["userId"].ToString(), @"^-?\d+$")) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { uLevel = umodel.uLevel; tguid = Mtxfw.Utility.Security.encrypt(umodel.Id); } } } } if (!String.IsNullOrEmpty(context.Request["viewId"]) && ifre) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["viewId"].ToString(), @"^-?\d+$")) { int viewId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["viewId"].ToString())); Mtxfw.Model.P_Product model = new Mtxfw.DAL.P_Product().GetModel(viewId); if (model != null) { if (model.IFDelete == 1) { data = "{\"status\":0,\"msg\":\"商品已删除\"}"; } else if (model.P_State == "未处理") { data = "{\"status\":0,\"msg\":\"商品已下架\"}"; } else { string strdata = ""; int ttype = Convert.ToInt32(model.utype); string sharepic = ""; string[] pics = model.P_images.Split('|'); strdata += "\"pic\":["; string showpic = (pics[0].Split(',')[0].IndexOf("http") != -1 ? pics[0].Split(',')[0] : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(pics[0].Split(',')[0], "150x150", "cut")); int j = 0; foreach (string str in pics) { if (str != "") { string[] stra = str.Split(','); strdata += "{\"img\":\"" + (stra[0].IndexOf("http") != -1 ? stra[0] + "?imageView2/2/w/720/h/460/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(stra[0], "720x720", "cut")) + "\",\"minimg\":\"" + (stra[0].IndexOf("http") != -1 ? stra[0] + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(stra[0], "150x150", "cut")) + "\",\"label\":\"\",\"yanse\":\"" + (stra.Length > 1 ? stra[1] : "") + "\"}"; if (j != pics.Length - 2) { strdata += ","; } if (j == 0) { sharepic = (stra[0].IndexOf("http") != -1 ? stra[0] + "?imageView2/2/w/220/h/220/q/75" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(stra[0], "150x150", "cut")); } j += 1; } } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; strdata += ",\"yanse\":["; j = 0; string[] yanses = model.P_yanse.Split(','); foreach (string str in yanses) { if (str != "") { strdata += "{\"yanse\":\"" + str + "\"}"; if (j != yanses.Length - 2) { strdata += ","; } } j += 1; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; strdata += ",\"guige\":["; int kc = model.P_Inventory; Double hyprice = 0.00, hyprice0 = 0.00, hyprice1 = 0.00, scprice = 0.00, xfjfje = 0.00; Double minprice = 0.00, maxprice = 0.00; Double zzl = 0.00; DataSet ds = new DAL.P_Guige().GetList("ttype=0 And G_PID=" + model.P_ID); if (ds.Tables[0].Rows.Count > 0) { j = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int G_ID = int.Parse(Dr["G_ID"].ToString()); string G_Name = Dr["G_Name"].ToString(); string G_Color = Dr["G_Color"].ToString(); string G_Images = Dr["G_Images"].ToString(); Double G_JG = Double.Parse(Dr["G_JG"].ToString()); Double G_JG0 = Double.Parse(Dr["G_JG0"].ToString()); Double G_JG1 = Double.Parse(Dr["G_JG1"].ToString()); Double G_JG2 = Double.Parse(Dr["G_JG2"].ToString()); Double G_JF = Double.Parse(Dr["G_JF"].ToString()); int G_KC = int.Parse(Dr["G_KC"].ToString()); if (minprice == 0.00) { minprice = G_JG; hyprice = G_JG; hyprice0 = G_JG0; hyprice1 = G_JG1; scprice = G_JG2; xfjfje = G_JF; } else { if (G_JG < minprice) { minprice = G_JG; hyprice = G_JG; hyprice0 = G_JG0; hyprice1 = G_JG1; scprice = G_JG2; xfjfje = G_JF; } } if (maxprice == 0.00) { maxprice = G_JG; } else { if (G_JG > maxprice) { maxprice = G_JG; } } if (j == 0) { kc = G_KC; zzl = Convert.ToDouble(Convert.ToDouble(Dr["G_ZL"].ToString()).ToString("f2")); } string[] acolors = G_Color.Split(','); string colors = "["; for (int k = 0; k < acolors.Length; k++) { if (acolors[k] != "") { var acolor = acolors[k].Split('|'); colors += "{\"color\":\"" + acolor[0] + "\",\"kc\":\"" + acolor[1] + "\"},"; } } if (colors.Substring(colors.Length - 1, 1) == ",") { colors = colors.Substring(0, colors.Length - 1); } colors += "]"; strdata += "{\"id\":\"" + G_ID + "\",\"gg\":\"" + G_Name + "\",\"jg\":\"" + G_JG.ToString("f2") + "\",\"jg0\":\"" + G_JG0.ToString() + "\",\"jg1\":\"" + G_JG1.ToString() + "\",\"jg2\":\"" + G_JG2.ToString("f2") + "\",\"jf\":\"" + G_JF.ToString() + "\",\"kc\":\"" + G_KC + "\",\"colors\":" + colors + ",\"images\":\"" + G_Images + "\",\"selectedcolor\":\"\",\"selectednum\":\"1\"}"; if (j != ds.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } } else { scprice = model.P_Market_P; hyprice = model.P_VIP_P; minprice = model.P_VIP_P; maxprice = model.P_VIP_P; } ds.Clear(); if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; int cartcount = 0; if (CartId.Length == 36) { string strzd = new Mtxfw.DAL.user_cart().Getzd("sum(ProductNum)", "CartId='" + CartId + "'").ToString(); if (strzd != "") { cartcount = Convert.ToInt32(strzd); } } Double yunfei = 0.00; if (zzl > 0.00) { if (zzl > 1.00) { int zzzl = Convert.ToInt32(zzl.ToString().Split('.')[0]); yunfei = (Convert.ToDouble(config.webYHMoney) + Convert.ToDouble(config.webYHMoney2) * (zzzl - 1)); } else { yunfei = Convert.ToDouble(config.webYHMoney); } } int IFQG = 0; string video = model.P_NAME2; Double YHMoney = 0.00; string aBody = model.P_DESCRIPTION; ds = daoArt.GetList1("top 1 content", "id=344"); if (ds.Tables[0].Rows.Count > 0) { aBody += ds.Tables[0].Rows[0]["content"].ToString(); } ds.Clear(); string ptgztitle = "", ptgzbody = ""; ds = daoArt.GetList1("top 1 title,content", "id=343"); if (ds.Tables[0].Rows.Count > 0) { ptgztitle = ds.Tables[0].Rows[0]["title"].ToString(); ptgzbody = ds.Tables[0].Rows[0]["content"].ToString(); } ds.Clear(); string ptgztitle0 = "", ptgzbody0 = ""; ds = daoArt.GetList1("top 1 title,content", "id=347"); if (ds.Tables[0].Rows.Count > 0) { ptgztitle0 = ds.Tables[0].Rows[0]["title"].ToString(); ptgzbody0 = ds.Tables[0].Rows[0]["content"].ToString(); } ds.Clear(); strdata += ",\"_id\":" + model.P_ID + ",\"ttype\":" + ttype + ",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(model.P_NAME) + "\",\"video\":\"" + video + "\",\"showpic\":\"" + showpic + "\",\"bianhao\":\"" + model.P_bianhao + "\",\"zl\":\"" + model.P_YH_P.ToString("f2") + "\",\"yunfei\":\"" + yunfei.ToString("f2") + "\",\"scje\":\"" + scprice.ToString("f2") + "\",\"hyje\":\"" + hyprice.ToString("f2") + "\",\"hyje0\":\"" + hyprice0.ToString() + "\",\"hyje1\":\"" + hyprice1.ToString() + "\",\"xfjfje\":\"" + xfjfje.ToString("f2") + "\",\"minprice\":\"" + minprice.ToString("f2") + "\",\"maxprice\":\"" + maxprice.ToString("f2") + "\",\"kc\":" + kc + ",\"body\":\"" + Mtxfw.Utility.Common.ReplaceString(aBody) + "\",\"ptgztitle\":\"" + Mtxfw.Utility.Common.ReplaceString(ptgztitle) + "\",\"ptgzbody\":\"" + Mtxfw.Utility.Common.ReplaceString(ptgzbody) + "\",\"ptgztitle0\":\"" + Mtxfw.Utility.Common.ReplaceString(ptgztitle0) + "\",\"ptgzbody0\":\"" + Mtxfw.Utility.Common.ReplaceString(ptgzbody0) + "\",\"sharetitle\":\"" + model.P_DESCRIPTION1 + "\",\"sharecontent\":\"" + model.P_DESCRIPTION2 + "\",\"sharepic\":\"" + sharepic + "\",\"images\":\"" + model.P_images + "\",\"IFQG\":\"" + IFQG + "\",\"YPTNum\":\"" + model.P_JiangLi + "\""; strdata += ",\"yunfeis\":["; ds = new DAL.province().GetList("id>0 Order by ProvinceID"); if (ds.Tables[0].Rows.Count > 0) { j = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int ProvinceID = int.Parse(Dr["ProvinceID"].ToString()); Double YFMoney = Double.Parse(Dr["YFmoney"].ToString()); Double YFMoney2 = Double.Parse(Dr["YFmoney2"].ToString()); yunfei = 0.00; if (zzl > 1.00) { int zzzl = Convert.ToInt32(zzl.ToString().Split('.')[0]); yunfei = (Convert.ToDouble(YFMoney) + Convert.ToDouble(YFMoney2) * (zzzl - 1)); } else { yunfei = Convert.ToDouble(YFMoney); } if (j == 0) { YHMoney = yunfei; } strdata += "{\"ProvinceID\":\"" + ProvinceID + "\",\"yunfei\":\"" + yunfei + "\"}"; if (j != ds.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } } ds.Clear(); strdata += "]"; DateTime dt = DateTime.Now; Int64 IFPD = 0; string yqpdname = ""; int pdid = 0, poid = 0; if (!String.IsNullOrEmpty(context.Request["tguid"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["tguid"].ToString(), @"^-?\d+$")) { pdid = Mtxfw.Utility.Security.decrypt(Convert.ToInt32(context.Request["tguid"].ToString())); } } if (!String.IsNullOrEmpty(context.Request["poid"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["poid"].ToString(), @"^-?\d+$")) { poid = Convert.ToInt32(context.Request["poid"].ToString()); } } strdata += ",\"spell_list\":["; if (model.utype == "6") { //,a.PCount,a.yPCount ds = daoorder.GetZHList(" top 20 a.id,a.UserID,b.NCName,b.RealName,b.UserPic", "User_Info", "a.ttype=6 and a.IFDelete=0 and a.poid=0 and a.ptype=1 and a.ifxnhy=1 and a.pid=" + model.P_ID + " and a.O_Payed='4' and a.ypcount<" + config.webMoney1 + " and b.id=a.UserID Order by a.ypcount desc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int32 id = Int32.Parse(Dr["id"].ToString()); int MemberId = int.Parse(Dr["UserID"].ToString()); string NCName = Dr["NCName"].ToString(); string RealName = Mtxfw.Utility.Common.CName(Dr["RealName"].ToString()); string UserPic = Dr["UserPic"].ToString(); //int PCount = int.Parse(Dr["PCount"].ToString()); //int yPCount = int.Parse(Dr["yPCount"].ToString()); /*DateTime addtime = Convert.ToDateTime(Dr["O_SubmitDate"].ToString()).AddMinutes(Convert.ToInt32(config.webMoney34)); if (dt.CompareTo(addtime) > 0) { addtime = Convert.ToDateTime(dt.ToString("yyyy-MM-dd") + " 00:00:00").AddMinutes(Convert.ToInt32(config.webMoney34)); }*/ if (poid > 0) { if (poid == id) { IFPD = id; yqpdname = (NCName == "" ? RealName : NCName); } } else { if (MemberId == pdid) { IFPD = id; yqpdname = (NCName == "" ? RealName : NCName); } } string SJC = ""; /*TimeSpan ts1, ts2, ts; if (dt.CompareTo(addtime) < 0) { ts1 = new TimeSpan(addtime.Ticks); ts2 = new TimeSpan(dt.Ticks); ts = ts1.Subtract(ts2).Duration(); SJC = (ts.Days * 24 * 3600 + ts.Hours * 3600 + ts.Minutes * 60 + ts.Seconds).ToString(); }*/ UserPic = (UserPic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(UserPic, "100x100", "cut") : ""); strdata += "{\"id\":\"" + id + "\",\"MemberId\":\"" + MemberId + "\",\"NCName\":\"" + RealName + "\",\"UserPic\":\"" + UserPic + "\",\"PCount\":\"1\",\"SJC\":\"" + SJC + "\",\"times\":\"\"},"; j += 1; } } ds.Clear(); if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } strdata += "]"; int IFfavorite = 0; if (userId > 0) { IFfavorite = new Mtxfw.DAL.user_favorite().GetCount("ttype=0 and ProductID=" + viewId + " And MemberId=" + userId); } string times = ""; string stime = ""; bool ifqg = true; data = "{\"status\":1,\"tguid\":\"" + tguid + "\",\"IFPD\":" + IFPD + ",\"yqpdname\":\"" + yqpdname + "\",\"cartcount\":\"" + cartcount + "\",\"IFfavorite\":\"" + IFfavorite + "\",\"MYMoney\":\"" + config.webMoney59 + "\",\"YHMoney\":\"" + YHMoney.ToString("f2") + "\",\"times\":\"" + times + "\",\"ifqg\":\"" + ifqg + "\",\"yjptnum\":\"0\"," + strdata + "}"; } } } } } return data; } #endregion #region //添加商品到购物车----------------------------------------------------------------------------------------- /// /// 添加商品到购物车 /// protected string addcart(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { if (context.Request["CartId"].ToString().Length == 36) { CartId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CartId"].ToString())); } } string guiges = ""; if (!String.IsNullOrEmpty(context.Request["guiges"])) { guiges = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["guiges"].ToString())); } int at = 0; if (!String.IsNullOrEmpty(context.Request["at"])) { //Mtxfw.Utility.Common.WriteHtml("/weixin/addcartt.txt", context.Request["at"].ToString().Trim()); at = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["at"].ToString().Trim())); } if (!String.IsNullOrEmpty(context.Request["viewId"])) { int viewId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["viewId"].ToString()))); Mtxfw.Model.P_Product model = new Mtxfw.DAL.P_Product().GetModel(viewId); if (model != null) { if (CartId == "" || CartId == "null") { CartId = Guid.NewGuid().ToString(); } string ptitle = Mtxfw.Utility.Common.GetOrderType(Convert.ToInt32(model.utype)); bool b = true; int znum = 0; string[] aguige = null; if (b) { if (model.IFDelete == 1 || model.P_State == "未处理") { b = false; data = "{\"status\":0,\"msg\":\"此商品已下架,不能添加\"}"; } } if (b) { if (guiges != "") { aguige = guiges.Split(','); foreach (string strg in aguige) { string[] ag = strg.Split('|'); string guigeid = ag[0]; string selcolor = ag[1]; int num = Convert.ToInt32(ag[2]); znum += num; int prodkc = 0; Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guigeid)); if (gmodel != null) { prodkc = gmodel.G_KC; string[] acolors = gmodel.G_Color.Split(','); for (int j = 0; j < acolors.Length; j++) { if (acolors[j] != "") { var ac = acolors[j].Split('|'); if (ac[0] == selcolor) { if (ac.Length > 1) { if (ac[1] != "") { prodkc = Convert.ToInt32(ac[1]); } } } } } if (b) { if (num > prodkc) { b = false; data = "{\"status\":0,\"msg\":\"" + gmodel.G_Name + "库存不足\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"规格选择错误\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"规格必须选择\"}"; } } if (b) { if (model.utype == "6" && at==1) { if (aguige.Length > 1) { b = false; data = "{\"status\":0,\"msg\":\"" + ptitle + "最多只能选一种规格\"}"; } } } if (b) { if (model.utype == "11") { if (znum > 10) { b = false; data = "{\"status\":0,\"msg\":\"每次最多只能购买10单\"}"; } } } /*if (b) { if (model.utype == "7" || model.utype == "8") { if (znum > 1) { b = false; data = "{\"status\":0,\"msg\":\"" + ptitle + "最多只能选一件\"}"; } } }*/ if (b) { int userId = 0, uLevel = 0, uLevel5 = 0, uLevel14 = 0, uLevel24 = 0, uLevel25 = 0; string openid = ""; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { uLevel = umodel.uLevel; uLevel5 = umodel.uLevel5; uLevel14 = umodel.uLevel14; uLevel24 = umodel.uLevel24; uLevel25 = umodel.uLevel25; openid = umodel.openid; } else { if (model.utype == "6") { b = false; data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"登录有误,请重新登录\"}"; } } int poid = 0; DateTime dt = DateTime.Now; if (b) { if (model.utype == "1") { if (aguige.Length > 1) { b = false; data = "{\"status\":0,\"msg\":\"" + ptitle + "最多只能选一种规格\"}"; } } } string mindt = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; if (b) { if (model.utype != "0") { DataSet ds2 = new Mtxfw.DAL.user_cart().GetList1("ID", "gtype=" + gtype + " and CartId='" + CartId + "'"); if (ds2.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds2.Tables[0].Rows) { int ProductID = Convert.ToInt32(Dr["ID"]); new Mtxfw.DAL.user_cart().Delete(ProductID); } } ds2.Clear(); } if (model.utype == "6" && at == 1) { if (b) { if (Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) < Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd ") + config.webMoney42) || Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd ") + config.webMoney41)) { b = false; data = "{\"status\":0,\"msg\":\"每天团购时间:" + config.webMoney42 + "至" + config.webMoney41 + "\"}"; } } if (!String.IsNullOrEmpty(context.Request["poid"])) { poid = Convert.ToInt32(context.Request["poid"]); } if (poid == 0) { string strpoid = daoorder.Getzd("id", "ttype=6 and ptype=1 and IFDelete=0 and poid=0 and ifxnhy=0 and O_Payed='4' and pid=" + model.P_ID + " and ypcount<" + config.webMoney1 + "").ToString(); if (strpoid != "") { poid = Convert.ToInt32(strpoid); } } if (poid > 0) { if (b) { if (daoorder.GetCount("ttype=6 and ptype=1 and IFDelete=0 and id=" + poid + " and pid=" + model.P_ID) == 0) { b = false; data = "{\"status\":0,\"msg\":\"拼单参数有误\"}"; } } if (b) { if (daoorder.GetCount("ttype=6 and ptype=1 and IFDelete=0 and (id=" + poid + " or poid=" + poid + ") and UserId=" + userId) > 0) { b = false; data = "{\"status\":0,\"msg\":\"同一团购只能拼一次\"}"; } } if (b) { if (daoorder.GetCount("ttype=6 and ptype=1 and IFDelete=0 and poid=" + poid + " and UserId=" + userId) > 0) { b = false; data = "{\"status\":0,\"msg\":\"不能和自己拼单\"}"; } } } if (b) { int yptcount = uLevel24; if (yptcount > 0) { b = false; data = "{\"status\":0,\"msg\":\"您今日已一键团购过,不能再参与团购\"}"; } } if (b) { if (uLevel25 >= Convert.ToInt32(config.webMoney3)) { b = false; data = "{\"status\":0,\"msg\":\"今日团购已达上限\"}"; } } if (b) { if (config.FHEnable3 == "1") { if (uLevel5 == 0) { b = false; data = "{\"status\":0,\"msg\":\"暂时不能团购\"}"; } } } } } if (b) { DataSet ds2 = new Mtxfw.DAL.user_cart().GetList1("ID", "gtype=" + gtype + " and CartId='" + CartId + "' And (Select b.utype From P_Product b Where b.P_ID=a.ProductID)<>" + model.utype); if (ds2.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds2.Tables[0].Rows) { int ProductID = Convert.ToInt32(Dr["ID"]); new Mtxfw.DAL.user_cart().Delete(ProductID); } } ds2.Clear(); ds2 = new Mtxfw.DAL.user_cart().GetList1("ID", "gtype=" + gtype + " and CartId='" + CartId + "' And (Select b.P_UserID From P_Product b Where b.P_ID=a.ProductID)<>" + model.P_UserID); if (ds2.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds2.Tables[0].Rows) { int ProductID = Convert.ToInt32(Dr["ID"]); new Mtxfw.DAL.user_cart().Delete(ProductID); } } ds2.Clear(); ds2 = new Mtxfw.DAL.user_cart().GetList1("ID", "gtype=" + gtype + " and CartId='" + CartId + "' and ttype<>" + at); if (ds2.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds2.Tables[0].Rows) { int ProductID = Convert.ToInt32(Dr["ID"]); new Mtxfw.DAL.user_cart().Delete(ProductID); } } ds2.Clear(); foreach (string strg in aguige) { string[] ag = strg.Split('|'); string guigeid = ag[0]; string selcolor = ag[1]; int num = Convert.ToInt32(ag[2]); if (new Mtxfw.DAL.user_cart().GetCount("gtype=" + gtype + " and CartId='" + CartId + "' And ProductID=" + viewId + " And selcolor='" + selcolor + "' And guige='" + guigeid + "'") == 0) { Model.user_cart cmodel = new Model.user_cart(); cmodel.ProductID = model.P_ID; cmodel.ProductNum = num; cmodel.selcolor = selcolor; cmodel.guige = guigeid; cmodel.CartId = CartId; cmodel.ttype = at; cmodel.gtype = gtype; cmodel.poid = poid; new Mtxfw.DAL.user_cart().Add(cmodel); } else { new Mtxfw.DAL.user_cart().UpdateProductNum(num, model.P_ID, selcolor, guigeid, CartId); } } int cartcount = 0; if (CartId != "") { string strzd = new Mtxfw.DAL.user_cart().Getzd("sum(ProductNum)", "gtype=" + gtype + " and CartId='" + CartId + "'").ToString(); if (strzd != "") { cartcount = Convert.ToInt32(strzd); } } data = "{\"status\":1,\"msg\":\"添加成功\",\"cartcount\":\"" + cartcount + "\",\"CartId\":\"" + CartId + "\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数有误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //添加收藏----------------------------------------------------------------------------------------- /// /// 添加收藏 /// protected string addfavorite(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["viewId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int32 viewId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["viewId"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Mtxfw.Model.P_Product pmodel = new Mtxfw.DAL.P_Product().GetModel(viewId); if (pmodel != null) { if (pmodel.IFDelete == 0) { if (new Mtxfw.DAL.user_favorite().GetCount("gtype=" + gtype + " and ttype=0 and ProductID=" + pmodel.P_ID + " And MemberId=" + umodel.Id) == 0) { Mtxfw.Model.user_favorite fmodel = new Model.user_favorite(); fmodel.ProductID = pmodel.P_ID; fmodel.MemberId = umodel.Id; fmodel.ttype = 0; fmodel.gtype = gtype; new Mtxfw.DAL.user_favorite().Add(fmodel); new Mtxfw.DAL.P_Product().Update(pmodel.P_ID, "P_SCOrders", "1"); data = "{\"status\":1,\"msg\":\"收藏成功\"}"; } else { data = "{\"status\":0,\"msg\":\"商品已被收藏过\"}"; } } else { data = "{\"status\":0,\"msg\":\"商品已被删除\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数有误\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取我的收藏----------------------------------------------------------------------------------------- /// /// 获取我的收藏 /// protected string getmyfavorite(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string strdata = "\"data\":["; string groupby = ""; string strOrder = "addTime Desc"; int Start = 0; int Limit = 20; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(context.Request["Start"].ToString()); } string strSQL = " and MemberId=" + userId + ""; Int32 Recount = 0; DataSet ds = new DAL.user_favorite().GetDataSet(groupby, strOrder, "id,ProductID,(select b.P_NAME from P_Product b where b.P_ID=tbl.ProductID) as name,(select b.P_images from P_Product b where b.P_ID=tbl.ProductID) as image", "", "gtype=" + gtype + " and ttype=0" + strSQL, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int ProductID = Convert.ToInt32(Dr["ProductID"]); string name = Dr["name"].ToString(); string image = Dr["image"].ToString().Split('|')[0].Split(',')[0]; string P_Market_P = "0.00"; string P_VIP_P = "0.00"; string strzd = new DAL.P_Guige().Getzd("min(G_JG)", "ttype=0 And G_PID=" + ProductID + " And G_KC>0").ToString(); if (strzd != "") { P_VIP_P = Convert.ToDouble(strzd).ToString("f2"); } strzd = new DAL.P_Guige().Getzd("min(G_JG2)", "ttype=0 And G_PID=" + ProductID + " And G_KC>0").ToString(); if (strzd != "") { P_Market_P = Convert.ToDouble(strzd).ToString("f2"); } strdata += "{\"id\":\"" + id + "\",\"ProductID\":\"" + ProductID + "\",\"name\":\"" + Mtxfw.Utility.Common.ReplaceString(name) + "\",\"scje\":\"" + P_Market_P + "\",\"hyje\":\"" + P_VIP_P + "\",\"image\":\"" + config.webUrl + Mtxfw.Utility.Common.GetCoverPic(image, "220x220", "cut") + "\"}"; strdata += ","; i += 1; } } ds.Clear(); if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; data = "{\"status\":1," + strdata + "}"; } else { data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } return data; } #endregion #region //删除收藏----------------------------------------------------------------------------------------- /// /// 删除收藏 /// protected string delfavorite(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int32 id = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["id"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { if (new Mtxfw.DAL.user_favorite().GetCount("MemberId=" + userId + " and id=" + id) > 0) { new Mtxfw.DAL.user_favorite().Delete(id); data = "{\"status\":1,\"msg\":\"删除成功\"}"; } else { data = "{\"status\":0,\"msg\":\"权限不足\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取购物车商品列表----------------------------------------------------------------------------------------- /// /// 获取购物车商品列表 /// protected string getshopcart(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { if (context.Request["CartId"].ToString().Length == 36) { CartId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["CartId"].ToString())); } } int userId = 0, uLevel = 0; bool ifb = true; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { if (System.Text.RegularExpressions.Regex.IsMatch(context.Request["userId"].ToString(), @"^-?\d+$")) { userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { uLevel = umodel.uLevel; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; ifb = false; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; ifb = false; } } else { ifb = false; } } if (ifb) { string strdata = ""; int ttype = 0; Double ZSubTotal = 0.00; strdata += "\"productlist\":["; System.Data.DataSet Ds_Product = new Mtxfw.DAL.user_cart().GetList(" top 20 (Select P_Name From P_Product b Where b.P_ID=a.ProductID) as prodName,(Select P_images From P_Product b Where b.P_ID=a.ProductID) as prodimg,(Select utype From P_Product b Where b.P_ID=a.ProductID) as utype,", "gtype=" + gtype + " and CartId='" + CartId + "' Order By addtime Desc"); int productcount = Ds_Product.Tables[0].Rows.Count; if (productcount > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string strid = drv2["id"].ToString(); string prodid = drv2["ProductID"].ToString(); string prodName = drv2["prodName"].ToString(); string selcolor = HttpUtility.UrlDecode(drv2["selcolor"].ToString()); string prodimg = drv2["prodimg"].ToString(); string[] aprodimg = prodimg.Split('|'); string prodPrice = "0.00"; string prodPrice2 = "0.00"; if (drv2["utype"].ToString() != "") { ttype = Convert.ToInt32(drv2["utype"].ToString()); } int prodkc = 0; string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodPrice = Convert.ToDouble(gmodel.G_JG).ToString("f2").Replace(",", ""); prodPrice2 = Convert.ToDouble(gmodel.G_JF).ToString(); prodName += " " + gmodel.G_Name; prodkc = gmodel.G_KC; if (gmodel.G_Color != "") { string[] acolors = gmodel.G_Color.Split(','); foreach (string color in acolors) { if (color != "") { string[] acolor = color.Split('|'); if (acolor[0] == selcolor) { if (acolor.Length > 1) { if (acolor[1] != "") { prodkc = Convert.ToInt32(acolor[1]); } } } } } } } } string prodNum = "0"; if (drv2["ProductNum"].ToString() != "") { prodNum = drv2["ProductNum"].ToString(); } string TotalNum = prodkc.ToString(); string SubTotal = (Convert.ToInt32(prodNum) * Convert.ToDouble(prodPrice)).ToString("f2").Replace(",", ""); ZSubTotal += Convert.ToDouble(SubTotal); string strimg = ""; if (selcolor != "") { foreach (string img in aprodimg) { if (img.IndexOf(selcolor) != -1) { strimg = img.Split(',')[0]; } } if (strimg == "") { strimg = prodimg.Split('|')[0].Split(',')[0]; } } else { strimg = prodimg.Split('|')[0].Split(',')[0]; } strdata += "{\"id\":\"" + strid + "\",\"prodid\":\"" + prodid + "\",\"prodName\":\"" + Mtxfw.Utility.Common.ReplaceString(prodName) + "\",\"selcolor\":\"" + selcolor + "\",\"guige\":\"" + guige + "\",\"prodimg\":\"" + (strimg.IndexOf("http") != -1 ? strimg : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strimg, "80x80", "cut")) + "\",\"prodNum\":\"" + prodNum + "\",\"TotalNum\":\"" + TotalNum + "\",\"prodPrice\":\"" + prodPrice + "\",\"prodPrice2\":\"" + prodPrice2 + "\",\"SubTotal\":\"" + SubTotal + "\"}"; if (j != Ds_Product.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } } Ds_Product.Clear(); strdata += "]"; data = "{\"status\":1," + strdata + ",\"ttype\":\"" + ttype + "\",\"ZSubTotal\":\"" + ZSubTotal.ToString("f2").Replace(",", "") + "\"}"; } return data; } #endregion #region //更新购物车----------------------------------------------------------------------------------------- /// /// 更新购物车 /// protected string updatecart(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { CartId = HttpUtility.UrlDecode(context.Request["CartId"].ToString()); } string guige = ""; if (!String.IsNullOrEmpty(context.Request["guige"])) { guige = context.Request["guige"].ToString(); } if (!String.IsNullOrEmpty(context.Request["viewId"]) && !String.IsNullOrEmpty(context.Request["num"])) { int viewId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["viewId"].ToString())); int num = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["num"].ToString())); string selcolor = ""; if (!String.IsNullOrEmpty(context.Request["selcolor"])) { selcolor = HttpUtility.UrlDecode(context.Request["selcolor"].ToString()); } Mtxfw.Model.P_Product model = new Mtxfw.DAL.P_Product().GetModel(viewId); if (model != null) { int prodkc = model.P_Inventory; if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodkc = gmodel.G_KC; string[] acolors = gmodel.G_Color.Split(','); for (int j = 0; j < acolors.Length; j++) { if (acolors[j] != "") { var ac = acolors[j].Split('|'); if (ac[0] == selcolor) { if (ac.Length > 1) { if (ac[1] != "") { prodkc = Convert.ToInt32(ac[1]); } } } } } } } if ((prodkc - num) >= 0) { new Mtxfw.DAL.user_cart().UpdateProductNum2(num, viewId, selcolor, guige, CartId); new Mtxfw.DAL.user_cart().Delete(); int cartcount = 0; if (CartId != "") { string strzd = new Mtxfw.DAL.user_cart().Getzd("sum(ProductNum)", "CartId='" + CartId + "'").ToString(); if (strzd != "") { cartcount = Convert.ToInt32(strzd); } } data = "{\"status\":1,\"msg\":\"更新成功\",\"cartcount\":\"" + cartcount + "\"}"; } else { data = "{\"status\":0,\"msg\":\"库存不足\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //更新购物车记录----------------------------------------------------------------------------------------- /// /// 更新购物车记录 /// protected string updateshopcart(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { CartId = HttpUtility.UrlDecode(context.Request["CartId"].ToString()); } if (!String.IsNullOrEmpty(context.Request["id"]) && !String.IsNullOrEmpty(context.Request["num"])) { int id = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["id"].ToString())); int num = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["num"].ToString())); int ttype = 0; string strdata = ""; Double ZSubTotal = 0.00; Mtxfw.Model.user_cart model = new Mtxfw.DAL.user_cart().GetModel(id); if (model != null) { if (model.CartId == CartId) { new DAL.user_cart().UpdateProductNum(num, id); strdata += "\"productlist\":["; System.Data.DataSet Ds_Product = new Mtxfw.DAL.user_cart().GetList(" top 20 (Select P_Name From P_Product b Where b.P_ID=a.ProductID) as prodName,(Select P_images From P_Product b Where b.P_ID=a.ProductID) as prodimg,(Select utype From P_Product b Where b.P_ID=a.ProductID) as utype,", "CartId='" + CartId + "' Order By addtime Desc"); int productcount = Ds_Product.Tables[0].Rows.Count; if (productcount > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string strid = drv2["id"].ToString(); string prodid = drv2["ProductID"].ToString(); string prodName = drv2["prodName"].ToString(); string selcolor = HttpUtility.UrlDecode(drv2["selcolor"].ToString()); ttype = Convert.ToInt32(drv2["utype"].ToString()); string prodimg = drv2["prodimg"].ToString(); string[] aprodimg = prodimg.Split('|'); string prodPrice = "0.00"; string prodPrice2 = "0.00"; int prodkc = 0; string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodPrice = Convert.ToDouble(gmodel.G_JG).ToString("f2").Replace(",", ""); if (ttype == 5) { prodPrice = "0.00"; } prodPrice2 = Convert.ToDouble(gmodel.G_JF).ToString(); prodName += " " + gmodel.G_Name; prodkc = gmodel.G_KC; if (gmodel.G_Color != "") { string[] acolors = gmodel.G_Color.Split(','); foreach (string color in acolors) { if (color != "") { string[] acolor = color.Split('|'); if (acolor[0] == selcolor) { if (acolor.Length > 1) { if (acolor[1] != "") { prodkc = Convert.ToInt32(acolor[1]); } } } } } } } } string prodNum = "0"; if (drv2["ProductNum"].ToString() != "") { prodNum = drv2["ProductNum"].ToString(); } string TotalNum = prodkc.ToString(); string SubTotal = (Convert.ToInt32(prodNum) * Convert.ToDouble(prodPrice)).ToString("f2").Replace(",", ""); ZSubTotal += Convert.ToDouble(SubTotal); string strimg = ""; if (selcolor != "") { foreach (string img in aprodimg) { if (img.IndexOf(selcolor) != -1) { strimg = img.Split(',')[0]; } } if (strimg == "") { strimg = prodimg.Split('|')[0].Split(',')[0]; } } else { strimg = prodimg.Split('|')[0].Split(',')[0]; } string imgUrl = strimg; //config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strimg, "80x80", "cut"); strdata += "{\"id\":\"" + strid + "\",\"prodid\":\"" + prodid + "\",\"prodName\":\"" + prodName + "\",\"selcolor\":\"" + selcolor + "\",\"guige\":\"" + guige + "\",\"prodimg\":\"" + imgUrl + "\",\"prodNum\":\"" + prodNum + "\",\"TotalNum\":\"" + TotalNum + "\",\"prodPrice\":\"" + prodPrice + "\",\"prodPrice2\":\"" + prodPrice2 + "\",\"SubTotal\":\"" + SubTotal + "\"}"; if (j != Ds_Product.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } } Ds_Product.Clear(); strdata += "]"; data = "{\"status\":1,\"msg\":\"删除成功\"," + strdata + ",\"ttype\":\"" + ttype + "\",\"ZSubTotal\":\"" + ZSubTotal.ToString("f2").Replace(",", "") + "\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误0\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //删除购物车记录----------------------------------------------------------------------------------------- /// /// 删除购物车记录 /// protected string delshopcart(HttpContext context) { string data = "{\"status\":0}"; string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { CartId = HttpUtility.UrlDecode(context.Request["CartId"].ToString()); } if (!String.IsNullOrEmpty(context.Request["id"])) { int id = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["id"].ToString())); int ttype = 0; string strdata = ""; Double ZSubTotal = 0.00; Mtxfw.Model.user_cart model = new Mtxfw.DAL.user_cart().GetModel(id); if (model != null) { if (model.CartId == CartId) { new DAL.user_cart().Delete(id); strdata += "\"productlist\":["; System.Data.DataSet Ds_Product = new Mtxfw.DAL.user_cart().GetList(" top 20 (Select P_Name From P_Product b Where b.P_ID=a.ProductID) as prodName,(Select P_images From P_Product b Where b.P_ID=a.ProductID) as prodimg,(Select utype From P_Product b Where b.P_ID=a.ProductID) as utype,", "CartId='" + CartId + "' Order By addtime Desc"); int productcount = Ds_Product.Tables[0].Rows.Count; if (productcount > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string strid = drv2["id"].ToString(); string prodid = drv2["ProductID"].ToString(); string prodName = drv2["prodName"].ToString(); string selcolor = HttpUtility.UrlDecode(drv2["selcolor"].ToString()); ttype = Convert.ToInt32(drv2["utype"].ToString()); string prodimg = drv2["prodimg"].ToString(); string[] aprodimg = prodimg.Split('|'); string prodPrice = "0.00"; string prodPrice2 = "0.00"; int prodkc = 0; string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodPrice = Convert.ToDouble(gmodel.G_JG).ToString("f2").Replace(",", ""); if (ttype == 5) { prodPrice = "0.00"; } prodPrice2 = Convert.ToDouble(gmodel.G_JF).ToString(); prodName += " " + gmodel.G_Name; prodkc = gmodel.G_KC; if (gmodel.G_Color != "") { string[] acolors = gmodel.G_Color.Split(','); foreach (string color in acolors) { if (color != "") { string[] acolor = color.Split('|'); if (acolor[0] == selcolor) { if (acolor.Length > 1) { if (acolor[1] != "") { prodkc = Convert.ToInt32(acolor[1]); } } } } } } } } string prodNum = "0"; if (drv2["ProductNum"].ToString() != "") { prodNum = drv2["ProductNum"].ToString(); } string TotalNum = prodkc.ToString(); string SubTotal = (Convert.ToInt32(prodNum) * Convert.ToDouble(prodPrice)).ToString("f2").Replace(",", ""); ZSubTotal += Convert.ToDouble(SubTotal); string strimg = ""; if (selcolor != "") { foreach (string img in aprodimg) { if (img.IndexOf(selcolor) != -1) { strimg = img.Split(',')[0]; } } if (strimg == "") { strimg = prodimg.Split('|')[0].Split(',')[0]; } } else { strimg = prodimg.Split('|')[0].Split(',')[0]; } strdata += "{\"id\":\"" + strid + "\",\"prodid\":\"" + prodid + "\",\"prodName\":\"" + prodName + "\",\"selcolor\":\"" + selcolor + "\",\"guige\":\"" + guige + "\",\"prodimg\":\"" + config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strimg, "80x80", "cut") + "\",\"prodNum\":\"" + prodNum + "\",\"TotalNum\":\"" + TotalNum + "\",\"prodPrice\":\"" + prodPrice + "\",\"prodPrice2\":\"" + prodPrice2 + "\",\"SubTotal\":\"" + SubTotal + "\"}"; if (j != Ds_Product.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } } Ds_Product.Clear(); strdata += "]"; data = "{\"status\":1,\"msg\":\"删除成功\"," + strdata + ",\"ttype\":\"" + ttype + "\",\"ZSubTotal\":\"" + ZSubTotal.ToString("f2").Replace(",", "") + "\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误0\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取购买结算商品列表----------------------------------------------------------------------------------------- /// /// 获取购买结算商品列表 /// protected string getshopcart2(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["LoginId"].ToString())); Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { CartId = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["CartId"].ToString())); } Decimal latitude = 0; if (!String.IsNullOrEmpty(context.Request["latitude"])) { latitude = Convert.ToDecimal(Mtxfw.Utility.Tools.SafeSQL(context.Request["latitude"].ToString())); } Decimal longitude = 0; if (!String.IsNullOrEmpty(context.Request["longitude"])) { longitude = Convert.ToDecimal(Mtxfw.Utility.Tools.SafeSQL(context.Request["longitude"].ToString())); } int ttype = 0, ptype = 0, peitype = 0, peitype0 = 0; string strdata = ""; Double ZSubTotal = 0.00, ZSubTotal2 = 0.00; Double zzl = 0.00, yunfei = 0.00; int P_UserID = 0, poid = 0, zprodNum = 0, ycount0 = 0; strdata += "\"productlist\":["; System.Data.DataSet Ds_Product = new Mtxfw.DAL.user_cart().GetList(" top 20 (Select P_Name From P_Product b Where b.P_ID=a.ProductID) as prodName,(Select P_images From P_Product b Where b.P_ID=a.ProductID) as prodimg,(Select P_CATEGORYs From P_Product b Where b.P_ID=a.ProductID) as P_CATEGORYs,(Select P_UserID From P_Product b Where b.P_ID=a.ProductID) as P_UserID,(Select utype From P_Product b Where b.P_ID=a.ProductID) as utype,(Select P_peitype From P_Product b Where b.P_ID=a.ProductID) as P_peitype,(Select P_peitype0 From P_Product b Where b.P_ID=a.ProductID) as P_peitype0,", "gtype=" + gtype + " and CartId='" + CartId + "' Order By addtime Desc"); int productcount = Ds_Product.Tables[0].Rows.Count; if (productcount > 0) { int j = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string strid = drv2["id"].ToString(); int addtype = Convert.ToInt32(drv2["ttype"].ToString()); P_UserID = Convert.ToInt32(drv2["P_UserID"].ToString()); string prodid = drv2["ProductID"].ToString(); string P_CATEGORYs = drv2["P_CATEGORYs"].ToString(); string prodName = drv2["prodName"].ToString(); poid = Convert.ToInt32(drv2["poid"].ToString()); if (drv2["utype"].ToString() != "") { ttype = Convert.ToInt32(drv2["utype"].ToString()); } string selcolor = HttpUtility.UrlDecode(drv2["selcolor"].ToString()); string prodimg = drv2["prodimg"].ToString(); string[] aprodimg = prodimg.Split('|'); string prodPrice = "0.00"; string prodPrice2 = "0.00"; int prodkc = 0; Double zl = 0.00; peitype = Convert.ToInt32(drv2["P_peitype"].ToString()); peitype0 = Convert.ToInt32(drv2["P_peitype0"].ToString()); if (ttype == 2) { if (P_CATEGORYs.IndexOf(",146,") != -1) { ptype = 1; } else if (P_CATEGORYs.IndexOf(",147,") != -1) { ptype = 2; } else if (P_CATEGORYs.IndexOf(",148,") != -1) { ptype = 3; } else if (P_CATEGORYs.IndexOf(",149,") != -1) { ptype = 4; } else if (P_CATEGORYs.IndexOf(",150,") != -1) { ptype = 5; } ycount0 = daoorder.GetCount("ttype=2 and IFDelete=0 and ptype=" + ptype + " and UserId=" + umodel.Id + " and O_Payed>0"); } string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodPrice = Convert.ToDouble(gmodel.G_JG).ToString("f2").Replace(",", ""); if (ycount0 > 0) { prodPrice = Convert.ToDouble(gmodel.G_JG2).ToString("f2").Replace(",", ""); } prodPrice2 = Convert.ToDouble(gmodel.G_JF).ToString("f2").Replace(",", ""); prodkc = gmodel.G_KC; zl = gmodel.G_ZL; prodName += " " + gmodel.G_Name; } } string prodNum = "0"; if (drv2["ProductNum"].ToString() != "") { prodNum = drv2["ProductNum"].ToString(); zprodNum += Convert.ToInt32(prodNum); } string TotalNum = prodkc.ToString(); string SubTotal = (Convert.ToInt32(prodNum) * Convert.ToDouble(prodPrice)).ToString("f2").Replace(",", ""); zzl += (Convert.ToInt32(prodNum) * zl); ZSubTotal += Convert.ToDouble(SubTotal); string strimg = ""; if (selcolor != "") { foreach (string img in aprodimg) { if (img.IndexOf(selcolor) != -1) { strimg = img.Split(',')[0]; } } if (strimg == "") { strimg = prodimg.Split('|')[0].Split(',')[0]; } } else { strimg = prodimg.Split('|')[0].Split(',')[0]; } strdata += "{\"_id\":\"" + strid + "\",\"prodid\":\"" + prodid + "\",\"prodName\":\"" + Mtxfw.Utility.Common.ReplaceString(prodName) + "\",\"selcolor\":\"" + selcolor + "\",\"guige\":\"" + guige + "\",\"prodimg\":\"" + (strimg.IndexOf("http") != -1 ? strimg : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strimg, "80x80", "cut")) + "\",\"prodNum\":\"" + prodNum + "\",\"TotalNum\":\"" + TotalNum + "\",\"prodPrice\":\"" + prodPrice + "\",\"prodPrice2\":\"" + prodPrice2 + "\",\"SubTotal\":\"" + SubTotal + "\"}"; if (j != Ds_Product.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } zzl = Convert.ToDouble(zzl.ToString("f2")); ZSubTotal = Convert.ToDouble(ZSubTotal.ToString("f2")); if (zzl > 0.00) { if (zzl > 1.00) { int zzzl = Convert.ToInt32(zzl.ToString().Split('.')[0]); yunfei = (Convert.ToDouble(config.webYHMoney) + Convert.ToDouble(config.webYHMoney2) * (zzzl - 1)); } else { yunfei = Convert.ToDouble(config.webYHMoney); } } yunfei = Convert.ToDouble(yunfei.ToString("f2")); } Ds_Product.Clear(); strdata += "]"; strdata += ",\"address\":["; string yProvince = ""; DataSet ds = new Mtxfw.DAL.user_address().GetList1("top 1 id,Contactname,Contacttel,Address,IFIndex,Province,City,County,IFFill,Tradingarea,Zipcode", "gtype=" + gtype + " and UserID=" + umodel.Id + " Order By IFIndex Desc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string _id = Dr["id"].ToString(); string contact = Dr["Contactname"].ToString(); string tel = Dr["Contacttel"].ToString(); string detail = Dr["Address"].ToString(); string Province = Dr["Province"].ToString(); string City = Dr["City"].ToString(); string County = Dr["County"].ToString(); string IFFill = Dr["IFFill"].ToString(); string Tradingarea = Dr["Tradingarea"].ToString(); string IFIndex = Dr["IFIndex"].ToString(); if (IFIndex == "1") { yProvince = Province; } string area = new DAL.province().GetProvince(Province) + new DAL.city().GetCity(City) + new DAL.county().GetCounty(County); strdata += "{\"addressId\":\"" + _id + "\",\"contact\":\"" + contact + "\",\"tel\":\"" + tel + "\",\"Province\":\"" + Province + "\",\"City\":\"" + City + "\",\"County\":\"" + County + "\",\"IFFill\":\"" + IFFill + "\",\"Tradingarea\":\"" + Tradingarea + "\",\"area\":\"" + area + "\",\"detail\":\"" + detail + "\",\"IFIndex\":\"" + IFIndex + "\"}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } strdata += "]"; strdata += ",\"yunfeis\":["; ds = new DAL.province().GetList("id>0 Order by ProvinceID"); if (ds.Tables[0].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string strProvince = Dr["ProvinceID"].ToString(); Double YFMoney = Double.Parse(Dr["YFmoney"].ToString()); Double YFMoney2 = Double.Parse(Dr["YFmoney2"].ToString()); Double yunfei2 = 0.00; if (ttype == 0) { if (zzl > 0.00) { if (zzl > 1.00 && YFMoney > 0.00) { int zzzl = Convert.ToInt32(zzl.ToString().Split('.')[0]); yunfei2 = (Convert.ToDouble(YFMoney) + Convert.ToDouble(YFMoney2) * (zzzl - 1)); } else { yunfei2 = Convert.ToDouble(YFMoney); } if (yProvince == strProvince) { yunfei = Convert.ToDouble(yunfei2.ToString("f2")); } } } strdata += "{\"ProvinceID\":\"" + strProvince + "\",\"yunfei\":\"" + yunfei2 + "\"}"; if (j != ds.Tables[0].Rows.Count - 1) { strdata += ","; } j += 1; } } ds.Clear(); strdata += "]"; strdata += ",\"addresss\":["; string strsql0 = " and UserId=" + P_UserID; /*string strorder0 = "Order by dbo.GetDistance(" + latitude + "," + longitude + ",xcoo,ycoo) asc"; ds = daobusiness.GetList("top 10 dbo.GetDistance(" + latitude + "," + longitude + ",xcoo,ycoo) as distance,", "utype='0'" + strsql0 + strorder0); if (ds.Tables[0].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string id = Dr["id"].ToString(); string name = Dr["CompanyName"].ToString(); string tel = Dr["ContactPhone"].ToString(); string sprovince = Dr["Province"].ToString(); string scity = Dr["City"].ToString(); string scounty = Dr["County"].ToString(); string address = Dr["Companyaddress"].ToString(); string strprovince = new DAL.province().GetProvince(sprovince); string strcity = new DAL.city().GetCity(scity); string strcounty = new DAL.county().GetCounty(scounty); string sarea = strprovince + (strprovince != strcity ? strcity : "") + strcounty; Double distance = Convert.ToDouble(Convert.ToDouble(Dr["distance"]).ToString("f4")); string strdistance = ""; if (distance < 0.0000) { distance = -distance; } if (distance > 1000.0000) { strdistance = (distance / 1000).ToString().Split('.')[0] + "km"; } else { strdistance = distance.ToString("f0") + "m"; } strdata += "{\"addressId\":\"" + id + "\",\"type\":1,\"contact\":\"" + name + "\",\"tel\":\"" + tel + "\",\"province\":\"" + sprovince + "\",\"city\":\"" + scity + "\",\"county\":\"" + scounty + "\",\"IFFill\":\"" + IFFill + "\",\"Tradingarea\":\"" + Tradingarea + "\",\"address\":\"" + address + "\",\"distance\":\"" + strdistance + "\"},"; j += 1; } } ds.Clear();*/ //,dbo.GetDistance(" + latitude + "," + longitude + ",latitude,longitude) as distance ds = daoproxy.GetList1(" top 1 id,AName,ATel,Agenprovince,Agencity,Agencounty,IFFill,Agentrading,AAddress,dbo.GetDistance(" + latitude + "," + longitude + ",latitude,longitude) as distance", "gtype=" + gtype + " and TType=0 and id=729 and seef=1 order by dbo.GetDistance(" + latitude + "," + longitude + ",latitude,longitude) asc"); if (ds.Tables[0].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string id = Dr["id"].ToString(); string name = Dr["AName"].ToString(); string tel = Dr["ATel"].ToString(); string sprovince = Dr["Agenprovince"].ToString(); string scity = Dr["Agencity"].ToString(); string scounty = Dr["Agencounty"].ToString(); string IFFill = Dr["IFFill"].ToString(); string Agentrading = Dr["Agentrading"].ToString(); string address = Dr["AAddress"].ToString(); string sarea = new DAL.province().GetProvince(sprovince); sarea += new DAL.city().GetCity(scity); sarea += new DAL.county().GetCounty(scounty); sarea += (IFFill == "1" ? Agentrading : new Mtxfw.DAL.tradingarea().Gettradingarea(scity, scounty, Agentrading)); string strdistance = ""; Double distance = Convert.ToDouble(Convert.ToDouble(Dr["distance"]).ToString("f4")); if (distance < 0.0000) { distance = -distance; } if (distance > 1000.0000) { strdistance = (distance / 1000).ToString().Split('.')[0] + "km"; } else { strdistance = distance.ToString("f0") + "m"; } strdata += "{\"addressId\":\"" + id + "\",\"type\":0,\"contact\":\"" + Mtxfw.Utility.Common.ReplaceString(name) + "\",\"tel\":\"" + Mtxfw.Utility.Common.ReplaceString(tel) + "\",\"province\":\"" + sprovince + "\",\"city\":\"" + scity + "\",\"county\":\"" + scounty + "\",\"area\":\"" + sarea + "\",\"IFFill\":\"" + IFFill + "\",\"Tradingarea\":\"" + Mtxfw.Utility.Common.ReplaceString(Agentrading) + "\",\"address\":\"" + Mtxfw.Utility.Common.ReplaceString(address) + "\",\"distance\":\"" + strdistance + "\"},"; j += 1; } } ds.Clear(); /*if (config.webMoney63 != "") { string[] astr = config.webMoney63.Split('|'); int i = 0; foreach (string str in astr) { if (str != "") { string[] astr1 = str.Split(','); string sarea = ""; string sprovince = ""; if (astr1.Length > 2) { sprovince = astr1[2]; sarea = new DAL.province().GetProvince(sprovince); } string scity = ""; if (astr1.Length > 3) { scity = astr1[3]; sarea += new DAL.city().GetCity(scity); } string scounty = ""; if (astr1.Length > 4) { scounty = astr1[4]; sarea += new DAL.county().GetCounty(scounty); } string saddress = ""; if (astr1.Length > 5) { saddress = astr1[5]; } strdata += "{\"addressId\":\"" + i + "\",\"contact\":\"" + astr1[0] + "\",\"tel\":\"" + astr1[1] + "\",\"address\":\"" + sarea + saddress + "\"},"; i += 1; } } }*/ if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } strdata += "]"; int ifkjpay = 0; strdata += ",\"kjpaybanks\":["; /*if (umodel.uLevel21 == 1) { ifkjpay = 1; ds = daobank.GetList1("top 10 id,bank_name,bank_card_no", "issigned=1 and MemberId=" + umodel.Id); if (ds.Tables[0].Rows.Count > 0) { int j = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string id = Dr["id"].ToString(); string bank_name = Dr["bank_name"].ToString(); string bank_card_no = Dr["bank_card_no"].ToString(); strdata += "{\"value\":\"" + id + "\",\"key\":\"[" + bank_name + "]" + Mtxfw.Utility.Common.CCark(bank_card_no) + "\"},"; j += 1; } } ds.Clear(); if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } }*/ strdata += "]"; data = "{\"status\":1," + strdata + ",\"openid\":\"" + umodel.openid + "\",\"ttype\":\"" + ttype + "\",\"peitype\":\"" + peitype + "\",\"peitype0\":\"" + peitype0 + "\",\"poid\":\"" + poid + "\",\"ZSubTotal\":\"" + ZSubTotal.ToString("f2").Replace(",", "") + "\",\"ZSubTotal2\":\"" + ZSubTotal2.ToString("f2").Replace(",", "") + "\",\"yunfei\":\"" + yunfei.ToString("f2").Replace(",", "") + "\",\"xjjye\":\"" + (umodel.umoney - umodel.umoney17).ToString("f2") + "\",\"xfjfye\":\"" + (umodel.umoney28).ToString("f2") + "\",\"xfbye\":\"" + (umodel.umoney29).ToString("f2") + "\",\"jfye\":\"" + (umodel.umoney30).ToString("f2") + "\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取购买结算运费----------------------------------------------------------------------------------------- /// /// 获取购买结算运费 /// protected string getyunfei(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["province"]) && !String.IsNullOrEmpty(context.Request["city"]) && !String.IsNullOrEmpty(context.Request["county"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string province = context.Request["province"].ToString(); string city = context.Request["city"].ToString(); string county = context.Request["county"].ToString(); string CartId = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { CartId = HttpUtility.UrlDecode(context.Request["CartId"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { Double yunfei = 0.00; System.Data.DataSet Ds_Product = new Mtxfw.DAL.user_cart().GetList(" top 20 (Select P_M_P From P_Product b Where b.P_ID=a.ProductID) as P_M_P,", "gtype=" + gtype + " and CartId='" + CartId + "' Order By addtime Desc"); int productcount = Ds_Product.Tables[0].Rows.Count; if (productcount > 0) { int i = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string strid = drv2["id"].ToString(); int ProductNum = Convert.ToInt32(drv2["ProductNum"].ToString()); int yunfeiid = Convert.ToInt32(drv2["P_M_P"].ToString()); if (yunfeiid > 0) { Mtxfw.Model.freighttemplate fmodel = daoftem.GetModel(yunfeiid); if (fmodel != null) { if (fmodel.ttype == 0) { Double zl = 0.00; string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { zl = gmodel.G_ZL; } } DataSet ds = daofreight.GetList("fid=" + fmodel.Id + " order by ifallregions desc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = int.Parse(Dr["id"].ToString()); int ifallregions = int.Parse(Dr["ifallregions"].ToString()); string regions = Dr["regions"].ToString(); Double firstweight = Convert.ToDouble(Convert.ToDouble(Dr["firstweight"].ToString()).ToString("f4")); Double firstfreight = Convert.ToDouble(Convert.ToDouble(Dr["firstfreight"].ToString()).ToString("f4")); Double contweight = Convert.ToDouble(Convert.ToDouble(Dr["contweight"].ToString()).ToString("f4")); Double contfreight = Convert.ToDouble(Convert.ToDouble(Dr["contfreight"].ToString()).ToString("f4")); bool ifa = false; if (ifallregions == 0) { if (regions != "") { returnProvincedata redata = (returnProvincedata)FromProvincedataJson("{\"Province\":" + regions + "}"); for (int j = 0; j < redata.Province.Count; j++) { if (redata.Province[j].ProvinceID == province) { for (int j0 = 0; j0 < redata.Province[j].City.Count; j0++) { if (redata.Province[j].City[j0].CityID == city) { for (int j1 = 0; j1 < redata.Province[j].City[j0].County.Count; j1++) { if (redata.Province[j].City[j0].County[j1].CountyID == county) { ifa = true; } } } } } } } } else { ifa = true; } if (ifa) { if (fmodel.tcharge == 0) { Double firstnum = Convert.ToDouble(Convert.ToDouble(ProductNum).ToString("f4")); if (firstnum >= firstweight) { Double yfmoney = firstfreight; Double contnum = Convert.ToDouble((firstnum - firstweight).ToString("f4")); if (contnum > contweight) { int num = 0; if (contweight > 0.0000) { num = Convert.ToInt32((contnum / contweight).ToString().Split('.')[0]); } yfmoney += (num * contfreight); } yunfei = Convert.ToDouble(yfmoney.ToString("f4")); } } else if (fmodel.tcharge == 1 && zl > 0.0000) { Double firstnum = Convert.ToDouble(Convert.ToDouble(ProductNum * zl).ToString("f4")); if (firstnum >= firstweight) { Double yfmoney = firstfreight; Double contnum = Convert.ToDouble((firstnum - firstweight).ToString("f4")); if (contnum > contweight) { int num = 0; if (contweight > 0.0000) { num = Convert.ToInt32((contnum / contweight).ToString().Split('.')[0]); } yfmoney += (num * contfreight); } yunfei = Convert.ToDouble(yfmoney.ToString("f4")); } } } if (yunfei > 0.0000) { break; } } } ds.Clear(); if (fmodel.iffreeshipping == 1) { ds = daofree.GetList("fid=" + fmodel.Id + " order by id asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = int.Parse(Dr["id"].ToString()); int ifallregions = int.Parse(Dr["ifallregions"].ToString()); string regions = Dr["regions"].ToString(); Double firstweight = Convert.ToDouble(Convert.ToDouble(Dr["firstweight"].ToString()).ToString("f4")); Double firstfreight = Convert.ToDouble(Convert.ToDouble(Dr["firstfreight"].ToString()).ToString("f4")); Double contweight = Convert.ToDouble(Convert.ToDouble(Dr["contweight"].ToString()).ToString("f4")); Double contfreight = Convert.ToDouble(Convert.ToDouble(Dr["contfreight"].ToString()).ToString("f4")); bool ifa = false; if (regions != "") { returnProvincedata redata = (returnProvincedata)FromProvincedataJson("{\"Province\":" + regions + "}"); for (int j = 0; j < redata.Province.Count; j++) { if (redata.Province[j].ProvinceID == province) { for (int j0 = 0; j0 < redata.Province[j].City.Count; j0++) { if (redata.Province[j].City[j0].CityID == city) { for (int j1 = 0; j1 < redata.Province[j].City[j0].County.Count; j1++) { if (redata.Province[j].City[j0].County[j1].CountyID == county) { ifa = true; } } } } } } } if (ifa) { yunfei = 0.00; } } } ds.Clear(); } } } } i += 1; } } Ds_Product.Clear(); data = "{\"status\":1,\"yunfei\":\"" + yunfei.ToString() + "\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //确认购买----------------------------------------------------------------------------------------- /// /// 确认购买 /// protected string qygm(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["userId"].ToString())); string LoginId = HttpUtility.UrlDecode(Mtxfw.Utility.Tools.SafeSQL(context.Request["LoginId"].ToString())); bool b = true; int addressId = 0; int peitype = 0; if (!String.IsNullOrEmpty(context.Request["peitype"])) { peitype = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["peitype"].ToString()))); } int zftype = 0; if (!String.IsNullOrEmpty(context.Request["zftype"])) { zftype = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["zftype"].ToString()))); } string Guests = ""; if (!String.IsNullOrEmpty(context.Request["Guests"])) { Guests = Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["Guests"].ToString())); } int liveid = 0; if (!String.IsNullOrEmpty(context.Request["liveid"])) { liveid = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(context.Request["liveid"].ToString())); } string pwd = ""; if (!String.IsNullOrEmpty(context.Request["pwd"])) { pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); } string openid = ""; if (!String.IsNullOrEmpty(context.Request["openid"])) { openid = HttpUtility.UrlDecode(context.Request["openid"].ToString()); } int poid = 0; int agentid = 0, agenttype = 0, ZTUserID = 0; string contact = ""; string tel = ""; string province = ""; string city = ""; string county = ""; int IFFill = 0; string Tradingarea = ""; string address = ""; string province0 = ""; string city0 = ""; string county0 = ""; int IFFill0 = 0; string Tradingarea0 = ""; string mindt = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; if (!String.IsNullOrEmpty(context.Request["province"])) { province0 = HttpUtility.UrlDecode(context.Request["province"].ToString()); } if (!String.IsNullOrEmpty(context.Request["city"])) { city0 = HttpUtility.UrlDecode(context.Request["city"].ToString()); } if (!String.IsNullOrEmpty(context.Request["county"])) { county0 = HttpUtility.UrlDecode(context.Request["county"].ToString()); } if (!String.IsNullOrEmpty(context.Request["IFFill"])) { IFFill0 = Convert.ToInt32(context.Request["IFFill"].ToString()); } if (!String.IsNullOrEmpty(context.Request["Tradingarea"])) { Tradingarea0 = HttpUtility.UrlDecode(context.Request["Tradingarea"].ToString()); } if (b) { if (peitype == 0) { if (!String.IsNullOrEmpty(context.Request["addressId"])) { addressId = Convert.ToInt32(Mtxfw.Utility.Tools.SafeSQL(HttpUtility.UrlDecode(context.Request["addressId"].ToString()))); Model.user_address amodel = new DAL.user_address().GetModel(addressId); if (amodel != null) { if (amodel.UserID != userId) { b = false; data = "{\"status\":0,\"msg\":\"地址错误2!\"}"; } else { if (!System.Text.RegularExpressions.Regex.IsMatch(amodel.Contactname, @"[\u4e00-\u9fa5]")) { b = false; data = "{\"status\":0,\"msg\":\"收货人姓名填写不正确,只能输入中文!\"}"; } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(amodel.Contacttel, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") && !System.Text.RegularExpressions.Regex.IsMatch(amodel.Contacttel, @"^[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(amodel.Contacttel, @"^[00886]+[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(amodel.Contacttel, @"^[00886]+[-]+[09]+\d{8}")) { b = false; data = "{\"status\":0,\"msg\":\"手机号码格式填写不正确!\"}"; } } contact = amodel.Contactname; tel = amodel.Contacttel; address = amodel.Address; province = amodel.Province; city = amodel.City; county = amodel.County; IFFill = amodel.IFFill; Tradingarea = amodel.Tradingarea; string strprovince = new DAL.province().GetProvince(province); if (b) { if (strprovince != "") { address = address.Replace(strprovince, ""); } } string strcity = new DAL.city().GetCity(city); if (strcity != "") { address = address.Replace(strcity, ""); } string strcounty = new DAL.county().GetCounty(county); if (strcounty != "") { address = address.Replace(strcounty, ""); } if (b) { if (strprovince.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"配送地址省份选择有误!\"}"; } } if (b) { if (strcity.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"配送地址城市选择有误!\"}"; } } if (b) { if (county.Trim() != "") { if (strcounty.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"配送地址区县选择有误!\"}"; } } } if (b) { if (address.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"配送地址不能为空!\"}"; } } } } else { b = false; data = "{\"status\":0,\"msg\":\"配送地址错误!\"}"; } } else { b = false; data = "{\"status\":0,\"msg\":\"配送地址ID不能为空!\"}"; } } else { if (!String.IsNullOrEmpty(context.Request["agentid"])) { agentid = Convert.ToInt32(context.Request["agentid"].ToString()); if (!String.IsNullOrEmpty(context.Request["agenttype"])) { agenttype = Convert.ToInt32(context.Request["agenttype"].ToString()); } agentid = Convert.ToInt32(context.Request["agentid"].ToString()); if (agenttype == 0) { Mtxfw.Model.user_proxy pmodel = daoproxy.GetModel(agentid); if (pmodel != null) { ZTUserID = pmodel.MemberId; province = pmodel.Agenprovince; city = pmodel.Agencity; county = pmodel.Agencounty; IFFill = pmodel.IFFill; Tradingarea = pmodel.Agentrading; string strprovince = new DAL.province().GetProvince(province); if (b) { if (strprovince != "") { address = address.Replace(strprovince, ""); } } if (b) { if (strprovince.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"自提地址省份选择有误!\"}"; } } string strcity = new DAL.city().GetCity(city); if (strcity != "") { address = address.Replace(strcity, ""); } if (b) { if (strcity.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"自提地址城市选择有误!\"}"; } } string strcounty = new DAL.county().GetCounty(county); if (strcounty != "") { address = address.Replace(strcounty, ""); } if (b) { if (strcounty.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"自提地址区县选择有误!\"}"; } } if (b) { address = strprovince + strcity + strcounty + pmodel.AAddress; } } else { b = false; data = "{\"status\":0,\"msg\":\"取货地址选择错误1!\"}"; } } else { Mtxfw.Model.business_info bumodel = daobusiness.GetModel(agentid); if (bumodel != null) { ZTUserID = bumodel.UserId; province = bumodel.Province; city = bumodel.City; county = bumodel.County; string strprovince = new DAL.province().GetProvince(province); if (b) { if (strprovince != "") { address = address.Replace(strprovince, ""); } } if (b) { if (strprovince.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"自提地址省份选择有误!\"}"; } } string strcity = new DAL.city().GetCity(city); if (strcity != "") { address = address.Replace(strcity, ""); } if (b) { if (strcity.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"自提地址城市选择有误!\"}"; } } string strcounty = new DAL.county().GetCounty(county); if (strcounty != "") { address = address.Replace(strcounty, ""); } if (b) { if (strcounty.Trim() == "") { b = false; data = "{\"status\":0,\"msg\":\"自提地址区县选择有误!\"}"; } } if (b) { address = strprovince + strcity + strcounty + bumodel.Companyaddress; } } else { b = false; data = "{\"status\":0,\"msg\":\"取货地址选择错误0!\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["name"])) { contact = HttpUtility.UrlDecode(context.Request["name"].ToString()); } else { b = false; data = "{\"status\":0,\"msg\":\"取货人不能为空!\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["tel"])) { tel = HttpUtility.UrlDecode(context.Request["tel"].ToString()); if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[-]+[09]+\d{8}")) { b = false; data = "{\"status\":0,\"msg\":\"手机号格式填写不正确!\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"手机号不能为空!\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"取货地址选择错误!\"}"; } } } int bankid = 0; string bankname = "", bankphone = "", sign_no = ""; string strzftitle = "余额支付"; if (zftype == 1) { // strzftitle = "兑换积分+现金"; // b = false; // data = "{\"status\":0,\"msg\":\"暂时不能使用积分支付!\"}"; strzftitle = "兑换券抵扣"; //启用兑换券支付(实际就是积分支付,对应user_info --> umoney30 字段) } else if (zftype == 2) { strzftitle = "微信支付"; //b = false; //data = "{\"status\":0,\"msg\":\"微信支付暂时不能支付!\"}"; if (openid == "") { b = false; data = "{\"status\":0,\"msg\":\"openid为空请重新登录!\"}"; } } else if (zftype == 3) { strzftitle = "支付宝"; b = false; data = "{\"status\":0,\"msg\":\"支付宝暂时未开通!\"}"; } else if (zftype == 4) { strzftitle = "赠送"; b = false; data = "{\"status\":0,\"msg\":\"赠送暂时未开通!\"}"; } else if (zftype == 5) { strzftitle = "流量积分"; b = false; data = "{\"status\":0,\"msg\":\"暂时不能使用积分支付!\"}"; } else if (zftype == 6) { strzftitle = "佣金支付"; b = false; data = "{\"status\":0,\"msg\":\"暂时不能使用积分支付!\"}"; } else if (zftype == 7) { strzftitle = "KSD支付"; b = false; data = "{\"status\":0,\"msg\":\"赠送暂时未开通!\"}"; } else { strzftitle = "余额支付"; } if (b) { Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Double ZSubTotal = 0.00; Double ZSubTotal0 = 0.00; Double ZSubTotal1 = 0.00; Double ZSubTotal2 = 0.00; Double ZSubTotal3 = 0.00; Double ZSubTotal4 = 0.00; Double JFZSubTotal = 0.00; Double XJZSubTotal = 0.00; Double PayZSubTotal = 0.00; int Totalnum = 0, zkgmnum = 0; Double zzl = 0.00, zyunfei = 0.00; string CartId = "", strProductName = ""; if (!String.IsNullOrEmpty(context.Request["CartId"])) { CartId = HttpUtility.UrlDecode(context.Request["CartId"].ToString()); } int P_UserID = 0, prodid = 0, IFDS = 0, ycount0 = 0; //,(Select P_M_P From P_Product b Where b.P_ID=a.ProductID) as prodPrice2 System.Data.DataSet Ds_Product = new Mtxfw.DAL.user_cart().GetList(" top 100 (Select utype From P_Product b Where b.P_ID=a.ProductID) as utype,(Select utype0 From P_Product b Where b.P_ID=a.ProductID) as utype0,(Select IFDelete From P_Product b Where b.P_ID=a.ProductID) as IFDelete,(Select P_State From P_Product b Where b.P_ID=a.ProductID) as P_State,(Select P_NAME From P_Product b Where b.P_ID=a.ProductID) as P_NAME,(Select P_CATEGORYs From P_Product b Where b.P_ID=a.ProductID) as P_CATEGORYs,(Select P_M_P From P_Product b Where b.P_ID=a.ProductID) as P_M_P,(Select P_UserID From P_Product b Where b.P_ID=a.ProductID) as P_UserID,", "CartId='" + CartId + "' Order By addtime Desc"); int productcount = Ds_Product.Tables[0].Rows.Count; if (productcount > 0) { int j = 0; int utype = -1, utype0 = 0, ptype = 0; string UserIDs = "", strkcname = "", P_CATEGORYs = ""; bool bb = true, bbbb = true, bbbbb = true; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string strid = drv2["id"].ToString(); P_UserID = Convert.ToInt32(drv2["P_UserID"].ToString()); P_CATEGORYs = drv2["P_CATEGORYs"].ToString(); if (UserIDs != "") { if (UserIDs.IndexOf("," + P_UserID + ",") == -1) { UserIDs += (P_UserID + ","); } } else { UserIDs += ("," + P_UserID + ","); } poid = Convert.ToInt32(drv2["poid"].ToString()); int butype = Convert.ToInt32(drv2["utype"].ToString()); utype0 = Convert.ToInt32(drv2["utype0"].ToString()); int yunfeiid = Convert.ToInt32(drv2["P_M_P"].ToString().Split('.')[0]); if (utype != -1) { if (utype != butype) { bbbbb = false; } else { utype = butype; } } else { utype = butype; } if (utype == 2) { if (P_CATEGORYs.IndexOf(",146,") != -1) { ptype = 1; } else if (P_CATEGORYs.IndexOf(",147,") != -1) { ptype = 2; } else if (P_CATEGORYs.IndexOf(",148,") != -1) { ptype = 3; } else if (P_CATEGORYs.IndexOf(",149,") != -1) { ptype = 4; } else if (P_CATEGORYs.IndexOf(",150,") != -1) { ptype = 5; } ycount0 = daoorder.GetCount("ttype=2 and IFDelete=0 and ptype=" + ptype + " and UserId=" + umodel.Id + " and O_Payed>0"); } prodid = Convert.ToInt32(drv2["ProductID"].ToString()); string ProductName = drv2["P_NAME"].ToString() + " "; string selcolor = HttpUtility.UrlDecode(drv2["selcolor"].ToString()); string IFDelete = drv2["IFDelete"].ToString(); string P_State = drv2["P_State"].ToString(); Double prodPrice = 0.00; Double prodPrice0 = 0.00; Double prodPrice1 = 0.00; Double prodPrice2 = 0.00; Double prodPrice3 = 0.00; Double prodPrice4 = 0.00; Double jfprodPrice = 0.00; if (selcolor != "") { ProductName += selcolor + " "; } int prodkc = 0; Double zl = 0.00; string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodPrice = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG).ToString("f2")); jfprodPrice = Convert.ToDouble(Convert.ToDouble(gmodel.G_JF).ToString("f2")); prodPrice0 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG0).ToString("f2")); prodPrice1 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG1).ToString("f2")); prodPrice2 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG2).ToString("f2")); prodPrice3 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG3).ToString("f2")); prodPrice4 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG4).ToString("f2")); zkgmnum = Convert.ToInt32(gmodel.G_JG4.ToString().Split('.')[0]); if (utype == 2) { if (ycount0 > 0) { prodPrice = prodPrice2; } } prodkc = gmodel.G_KC; zl = gmodel.G_ZL; string[] acolors = gmodel.G_Color.Split(','); for (int k = 0; k < acolors.Length; k++) { if (acolors[k] != "") { var ac = acolors[k].Split('|'); if (ac[0] == selcolor) { if (ac.Length > 1) { if (ac[1] != "") { prodkc = Convert.ToInt32(ac[1]); } } } } } } } strProductName += ProductName; int prodNum = 0; if (drv2["ProductNum"].ToString() != "") { prodNum = Convert.ToInt32(drv2["ProductNum"]); } Totalnum += prodNum; ZSubTotal += (prodNum * prodPrice); JFZSubTotal += (prodNum * jfprodPrice); ZSubTotal0 += (prodNum * prodPrice0); if (utype == 5) { ZSubTotal1 = prodPrice1; } else { ZSubTotal1 += (prodNum * prodPrice1); } ZSubTotal2 += (prodNum * prodPrice2); ZSubTotal3 += (prodNum * prodPrice3); ZSubTotal4 += (prodNum * prodPrice4); if (prodkc - Convert.ToInt32(prodNum) < 0) { bb = false; strkcname += ProductName + " "; } if (IFDelete == "1" || P_State != "已处理") { bbbb = false; } j += 1; Double yunfei = 0.00; if ((peitype == 0 && utype != 1)) { //Mtxfw.Utility.Common.WriteHtml("/weixin/qygmapiajax.txt", yunfeiid.ToString()); if (yunfeiid > 0) { Mtxfw.Model.freighttemplate fmodel = daoftem.GetModel(yunfeiid); if (fmodel != null) { if (fmodel.ttype == 0) { DataSet ds = daofreight.GetList("fid=" + fmodel.Id + " order by ifallregions desc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = int.Parse(Dr["id"].ToString()); int ifallregions = int.Parse(Dr["ifallregions"].ToString()); string regions = Dr["regions"].ToString(); Double firstweight = Convert.ToDouble(Convert.ToDouble(Dr["firstweight"].ToString()).ToString("f4")); Double firstfreight = Convert.ToDouble(Convert.ToDouble(Dr["firstfreight"].ToString()).ToString("f4")); Double contweight = Convert.ToDouble(Convert.ToDouble(Dr["contweight"].ToString()).ToString("f4")); Double contfreight = Convert.ToDouble(Convert.ToDouble(Dr["contfreight"].ToString()).ToString("f4")); bool ifa = false; if (ifallregions == 0) { if (regions != "") { returnProvincedata redata = (returnProvincedata)FromProvincedataJson("{\"Province\":" + regions + "}"); for (int jj = 0; jj < redata.Province.Count; jj++) { if (redata.Province[jj].ProvinceID == province) { for (int j0 = 0; j0 < redata.Province[jj].City.Count; j0++) { if (redata.Province[jj].City[j0].CityID == city) { for (int j1 = 0; j1 < redata.Province[jj].City[j0].County.Count; j1++) { if (redata.Province[jj].City[j0].County[j1].CountyID == county) { ifa = true; } } } } } } } } else { ifa = true; } if (ifa) { if (fmodel.tcharge == 0) { Double firstnum = Convert.ToDouble(Convert.ToDouble(prodNum).ToString("f4")); if (firstnum >= firstweight) { Double yfmoney = firstfreight; Double contnum = Convert.ToDouble((firstnum - firstweight).ToString("f4")); if (contnum > contweight) { int num = 0; if (contweight > 0.0000) { num = Convert.ToInt32((contnum / contweight).ToString().Split('.')[0]); } yfmoney += (num * contfreight); } yunfei = Convert.ToDouble(yfmoney.ToString("f2")); } } else if (fmodel.tcharge == 1 && zl > 0.0000) { Double firstnum = Convert.ToDouble(Convert.ToDouble(prodNum * zl).ToString("f4")); if (firstnum >= firstweight) { Double yfmoney = firstfreight; Double contnum = Convert.ToDouble((firstnum - firstweight).ToString("f4")); if (contnum > contweight) { int num = 0; if (contweight > 0.0000) { num = Convert.ToInt32((contnum / contweight).ToString().Split('.')[0]); } yfmoney += (num * contfreight); } yunfei = Convert.ToDouble(yfmoney.ToString("f2")); } } } if (yunfei > 0.0000) { break; } } } ds.Clear(); if (fmodel.iffreeshipping == 1) { ds = daofree.GetList("fid=" + fmodel.Id + " order by id asc"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id = int.Parse(Dr["id"].ToString()); int ifallregions = int.Parse(Dr["ifallregions"].ToString()); string regions = Dr["regions"].ToString(); Double firstweight = Convert.ToDouble(Convert.ToDouble(Dr["firstweight"].ToString()).ToString("f4")); Double firstfreight = Convert.ToDouble(Convert.ToDouble(Dr["firstfreight"].ToString()).ToString("f4")); Double contweight = Convert.ToDouble(Convert.ToDouble(Dr["contweight"].ToString()).ToString("f4")); Double contfreight = Convert.ToDouble(Convert.ToDouble(Dr["contfreight"].ToString()).ToString("f4")); bool ifa = false; if (regions != "") { returnProvincedata redata = (returnProvincedata)FromProvincedataJson("{\"Province\":" + regions + "}"); for (int jj = 0; jj < redata.Province.Count; jj++) { if (redata.Province[jj].ProvinceID == province) { for (int j0 = 0; j0 < redata.Province[jj].City.Count; j0++) { if (redata.Province[jj].City[j0].CityID == city) { for (int j1 = 0; j1 < redata.Province[jj].City[j0].County.Count; j1++) { if (redata.Province[jj].City[j0].County[j1].CountyID == county) { ifa = true; } } } } } } } if (ifa) { yunfei = 0.00; } } } ds.Clear(); } } } zyunfei += yunfei; } } } zyunfei = Convert.ToDouble(zyunfei.ToString("f2")); if (utype == 0 || utype == 12 || utype == 14) { XJZSubTotal = (ZSubTotal - JFZSubTotal + zyunfei); } else { XJZSubTotal = (ZSubTotal + zyunfei); } ZSubTotal = Convert.ToDouble(ZSubTotal.ToString("f2")); JFZSubTotal = Convert.ToDouble(JFZSubTotal.ToString("f2")); ZSubTotal0 = Convert.ToDouble(ZSubTotal0.ToString("f2")); ZSubTotal1 = Convert.ToDouble(ZSubTotal1.ToString("f2")); ZSubTotal2 = Convert.ToDouble(ZSubTotal2.ToString("f2")); ZSubTotal3 = Convert.ToDouble(ZSubTotal3.ToString("f2")); ZSubTotal4 = Convert.ToDouble(ZSubTotal4.ToString("f2")); if (zftype == 2 || zftype == 3) { PayZSubTotal = XJZSubTotal; } else { PayZSubTotal = 0.00; } DateTime dt = DateTime.Now; if (b) { if (!bb) { b = false; data = "{\"status\":0,\"msg\":\"" + strkcname + "库存不足!\"}"; } } if (b) { if (!bbbb) { b = false; data = "{\"status\":0,\"msg\":\"此购物车包含已下架商品请重新选择!\"}"; } } if (b) { if (!bbbbb) { b = false; data = "{\"status\":0,\"msg\":\"此购物车包含不同商城商品请重新选择!\"}"; } } Mtxfw.Model.order_info OrderModel = null; if (b) { if (utype == 10) { if (Totalnum > 1) { b = false; data = "{\"status\":0,\"msg\":\"每人限购一单\"}"; } int ycount = daoorder.GetCount("ttype=10 and IFDelete=0 and UserId=" + umodel.Id + " and O_Payed>0");// if (ycount > 0) { b = false; data = "{\"status\":0,\"msg\":\"每人限购一单\"}"; } } } /*if (b) { if (utype == 6) { if (umodel.uLevel14 > 0) { if (Totalnum > 1) { b = false; data = "{\"status\":0,\"msg\":\"最多只能选一件\"}"; } if (b) { if (daoorder.GetCount("ttype=6 and IFDelete=0 and userId=" + umodel.Id + " and DateDiff(week,addtime,getdate())=0") >= Convert.ToInt32(config.webMoney14)) { b = false; data = "{\"status\":0,\"msg\":\"每个账号每周限购" + config.webMoney14 + "单\"}"; } } if (b) { if (daoorder.GetCount("ttype=6 and IFDelete=0 and userId=" + umodel.Id + "") >= Convert.ToInt32(config.webMoney18)) { b = false; data = "{\"status\":0,\"msg\":\"已超出可购买周数\"}"; } } } else { if (daoorder.GetCount("ttype=6 and IFDelete=0 and userId=" + umodel.Id + "") > Convert.ToInt32(config.webMoney48)) { b = false; data = "{\"status\":0,\"msg\":\"未激活会员只能购买"+ config.webMoney48 + "单\"}"; } } } }*/ if (b) { if (Totalnum < 1) { b = false; data = "{\"status\":0,\"msg\":\"数量不能少于1\"}"; } } if (b) { if (utype == 1) { int ygmnum = 0; string strnum = daoorder.Getzd("sum(Totalnum)", "ttype=1 and IFDelete=0 and UserId=" + umodel.Id + " and pid=" + prodid + " and O_Payed=1 and O_Shipped=0 and Totalprice0>Totalprice10").ToString();// if (strnum != "") { ygmnum = Convert.ToInt32(strnum); } if ((Totalnum + ygmnum) > zkgmnum) { b = false; data = "{\"status\":0,\"msg\":\"每人最多只能购买" + zkgmnum + "件\"}"; } } } if (b) { if (utype == 10) { if (Totalnum > 1) { b = false; data = "{\"status\":0,\"msg\":\"每人限购一单\"}"; } int ycount = daoorder.GetCount("ttype=10 and IFDelete=0 and UserId=" + umodel.Id + " and O_Payed>0");// if (ycount > 0) { b = false; data = "{\"status\":0,\"msg\":\"每人限购一单\"}"; } } } if (b) { if (utype == 11) { if (Totalnum > 10) { b = false; data = "{\"status\":0,\"msg\":\"每次最多只能购买10单\"}"; } } } if (b) { if (utype == 13 || utype == 14 || utype == 15) { if (Tradingarea == "") { b = false; data = "{\"status\":0,\"msg\":\"地址中的街道/乡镇不能为空\"}"; } } if (utype == 15) { if (province0 == "") { b = false; data = "{\"status\":0,\"msg\":\"服务商区域未选择\"}"; } if (b) { if (city0 == "") { b = false; data = "{\"status\":0,\"msg\":\"服务商区域未选择0\"}"; } } if (b) { if (county0 == "") { b = false; data = "{\"status\":0,\"msg\":\"服务商区域未选择1\"}"; } } if (b) { if (Tradingarea0 == "") { b = false; data = "{\"status\":0,\"msg\":\"服务商区域未选择1\"}"; } } if (b) { if (daoproxy.GetCount("TType=1 And AgenLevel=2 And Agenprovince='" + province0 + "' And Agencity='" + city0 + "' And Agencounty='" + county0 + "' and Agentrading='" + Tradingarea0 + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"所选区域已经有镇街服务商!\"}"; } } if (b) { if (ZSubTotal < Convert.ToDouble(Convert.ToDouble(config.webMoney13).ToString("f2"))) { b = false; data = "{\"status\":0,\"msg\":\"镇街服务商的消费金额必须" + config.webMoney13 + "以上\"}"; } } } } if (b) { if (utype == 0 || utype == 12 || utype == 14) { if (JFZSubTotal > 0.00) { if (Convert.ToDouble(Convert.ToDouble((umodel.umoney31).ToString("0.####")).ToString("f2")) < JFZSubTotal) { b = false; data = "{\"status\":0,\"msg\":\"您的补贴券不足" + JFZSubTotal.ToString() + "!\"}"; } } } } if (b) { if (zftype == 0) { if (Convert.ToDouble(Convert.ToDouble((umodel.umoney - umodel.umoney17).ToString("0.####")).ToString("f2")) < XJZSubTotal) { b = false; data = "{\"status\":0,\"msg\":\"您的" + strzftitle.Replace("支付", "") + "不足" + XJZSubTotal.ToString() + "!\"}"; } } else if (zftype == 1) { if (Convert.ToDouble(Convert.ToDouble(umodel.umoney30.ToString("0.####")).ToString("f2")) < Convert.ToDouble((XJZSubTotal).ToString("f2"))) { //PayZSubTotal = Convert.ToDouble((XJZSubTotal - umodel.umoney30).ToString("f2")); b = false; data = "{\"status\":0,\"msg\":\"您的兑换券余额不足" + XJZSubTotal.ToString() + "!\"}"; } // if (b) // { // if (utype != 3) // { // b = false; // data = "{\"status\":0,\"msg\":\"生态区才能使用兑换积分!\"}"; // } // } } else if (zftype == 5) { if (Convert.ToDouble(Convert.ToDouble(umodel.umoney29.ToString("0.####")).ToString("f2")) < Convert.ToDouble(XJZSubTotal.ToString("f2"))) { b = false; data = "{\"status\":0,\"msg\":\"您的" + strzftitle.Replace("支付", "") + "不足" + XJZSubTotal.ToString() + "!\"}"; } if (b) { if (utype != 1) { b = false; data = "{\"status\":0,\"msg\":\"支付方式选择错误1!\"}"; } } } else if (zftype == 6) { if (Convert.ToDouble(Convert.ToDouble(umodel.umoney32.ToString("0.####")).ToString("f2")) < Convert.ToDouble(XJZSubTotal.ToString("f2"))) { b = false; data = "{\"status\":0,\"msg\":\"您的" + strzftitle.Replace("支付", "") + "不足" + XJZSubTotal.ToString() + "!\"}"; } } else if (zftype == 7) { } } if (b) { if (zftype != 0 && zftype != 1 && zftype != 2 && zftype != 3 && zftype != 5 && zftype != 6 && zftype != 7) { b = false; data = "{\"status\":0,\"msg\":\"支付方式选择错误!\"}"; } } if (zftype == 0 || zftype == 1 || zftype == 4 || zftype == 5 || zftype == 6 || zftype == 7) { if (b) { if (pwd != "") { if (b) { if (umodel.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"安全密码不能为空\"}"; } } } Model.user_Results_jl2 mjl2; Int64 ResultId = 0; int IFSendSms = 0; string PayID = dt.ToString("yyMMddHHmmss", DateTimeFormatInfo.InvariantInfo) + umodel.Id; string SendSmsErr = ""; string timestamp = ""; string nonceStr = ""; string package = ""; string paySign = ""; string signType = "MD5"; string OrderIDs = ""; string[] AUserIDs = UserIDs.Split(','); if (b) { foreach (string UserID in AUserIDs) { if (UserID != "") { Double Totalprice = 0.00; Double JFTotalprice = 0.00; Double Totalprice0 = 0.00; Double Totalprice1 = 0.00; Double Totalprice2 = 0.00; Double Totalprice3 = 0.00; Double Totalprice4 = 0.00; Double Totalprice5 = 0.00; Double Totalprice6 = 0.00; Totalnum = 0; zzl = 0; foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { string strid = drv2["id"].ToString(); P_UserID = Convert.ToInt32(drv2["P_UserID"].ToString()); if (P_UserID.ToString() == UserID) { string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); Double jfprodPrice = 0.00, prodPrice = 0.00, prodPrice0 = 0.00, prodPrice1 = 0.00, prodPrice2 = 0.00, prodPrice3 = 0.00, prodPrice4 = 0.00, prodPrice5 = 0.00, prodPrice6 = 0.00, zl = 0.00; if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodPrice = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG).ToString("f2")); jfprodPrice = Convert.ToDouble(Convert.ToDouble(gmodel.G_JF).ToString("f2")); prodPrice0 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG0).ToString("f2")); prodPrice1 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG1).ToString("f2")); prodPrice2 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG2).ToString("f2")); prodPrice3 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG3).ToString("f2")); prodPrice4 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG4).ToString("f2")); prodPrice5 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG5).ToString("f2")); prodPrice6 = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG6).ToString("f2")); zl = gmodel.G_ZL; } } int prodNum = 0; if (drv2["ProductNum"].ToString() != "") { prodNum = Convert.ToInt32(drv2["ProductNum"]); } zzl += (prodNum * zl); Totalprice += (prodNum * prodPrice); Totalprice0 += (prodNum * prodPrice0); if (utype == 0 || utype == 12 || utype == 14) { JFTotalprice += (prodNum * jfprodPrice); } if (utype == 1) { Totalprice1 = prodPrice1; Totalprice3 = prodPrice3; Totalprice4 = prodPrice4; } else if (utype == 5) { Totalprice1 = prodPrice1; Totalprice3 = prodPrice3; Totalprice4 = prodPrice4; } else { Totalprice1 += (prodNum * prodPrice1); Totalprice3 += (prodNum * prodPrice3); Totalprice4 += (prodNum * prodPrice4); Totalprice5 += (prodNum * prodPrice5); Totalprice6 += (prodNum * prodPrice6); } Totalprice2 += (prodNum * prodPrice2); Totalnum += Convert.ToInt32(prodNum); } } Totalprice = Convert.ToDouble(Totalprice.ToString("f2")); JFTotalprice = Convert.ToDouble(JFTotalprice.ToString("f2")); Totalprice0 = Convert.ToDouble(Totalprice0.ToString("f2")); Totalprice1 = Convert.ToDouble(Totalprice1.ToString("f2")); Totalprice2 = Convert.ToDouble(Totalprice2.ToString("f2")); Totalprice3 = Convert.ToDouble(Totalprice3.ToString("f2")); Totalprice4 = Convert.ToDouble(Totalprice4.ToString("f2")); Totalprice5 = Convert.ToDouble(Totalprice5.ToString("f2")); Totalprice6 = Convert.ToDouble(Totalprice6.ToString("f2")); if ((peitype == 0 && utype != 1)) { if (zzl > 0.00) { if (zzl > 1.00) { int zzzl = Convert.ToInt32(zzl.ToString().Split('.')[0]); zyunfei = (Convert.ToDouble(config.webYHMoney) + Convert.ToDouble(config.webYHMoney2) * (zzzl - 1)); } else { zyunfei = Convert.ToDouble(config.webYHMoney); } if (!String.IsNullOrEmpty(province)) { Mtxfw.Model.province pmodel = new DAL.province().GetModel(province); if (pmodel != null) { if (zzl > 1.00 && Convert.ToDouble(pmodel.YFMoney.ToString("f2")) > 0.00) { int zzzl = Convert.ToInt32(zzl.ToString().Split('.')[0]); zyunfei = (Convert.ToDouble(pmodel.YFMoney) * Totalnum + Convert.ToDouble(pmodel.YFMoney2) * (zzzl - 1 * Totalnum)); } else { zyunfei = Convert.ToDouble(pmodel.YFMoney) * Totalnum; } } } } } Model.order_info Modelorder = new Model.order_info(); Modelorder.pid = prodid; Modelorder.poid = (utype == 6 ? poid : 0); Modelorder.pcount = 0; Modelorder.ypcount = 1; Modelorder.addressid = (peitype == 1 ? agentid : 0); Modelorder.orderid = PayID; Modelorder.Contactname = contact; Modelorder.Contacttel = tel; Modelorder.Province = province; Modelorder.City = city; Modelorder.County = county; Modelorder.IFFill = IFFill; Modelorder.Tradingarea = Tradingarea; Modelorder.Address = address; Modelorder.Zipcode = ""; Modelorder.Guests = Guests; Modelorder.Totalprice = Totalprice;//流量积分 Modelorder.JFTotalprice = JFTotalprice;//使用积分 Modelorder.Totalprice0 = Totalprice0;//总产出 Modelorder.Totalprice1 = zyunfei; Modelorder.Totalprice2 = Totalprice1;//产出周期//赠送流量包级别 Modelorder.Totalprice3 = Totalprice2;//活力值 Modelorder.Totalprice4 = Totalprice3;//有效期//成本 Modelorder.Totalprice5 = Totalprice4; //最大持有量//管理费 Modelorder.Totalprice6 = Totalprice5;//税金 Modelorder.Totalprice7 = Totalprice6;//增值积分 Modelorder.Totalprice8 = Totalprice1;//剩余产出天数 Modelorder.Totalprice9 = Totalprice3;//剩余有效天数 Modelorder.Totalprice10 = 0;//已释放数量 Modelorder.Totalnum = Totalnum; Modelorder.O_Submit = "1"; Modelorder.O_yhj = ""; Modelorder.UserID = umodel.Id; Modelorder.MemberId = P_UserID; Modelorder.ZTMemberId = ZTUserID; Modelorder.selcolor = ""; Modelorder.guige = ""; Modelorder.utype = zftype.ToString(); Modelorder.ttype = CommonFunctions.GetOrderType(Ds_Product); //utype; Modelorder.ttype0 = utype0; Modelorder.ptype = ptype; Modelorder.ptgroup = 0; Modelorder.ifxnhy = 0; Modelorder.ypznum = 0; Modelorder.ifxhpt = 1;//0银花优选订单1银花优选订单 Modelorder.peitype = peitype; Modelorder.gtype = gtype; int OrderID = daoorder.Add(Modelorder); daoorder.Updateopenid(openid, OrderID); string Address0 = province0 + "|" + city0 + "|" + county0 + "|" + IFFill0 + "|" + Tradingarea0; daoorder.UpdateAddress0(Address0, OrderID); Modelorder.Id = OrderID; if (OrderIDs != "") { OrderIDs += ("," + OrderID); } else { OrderIDs = OrderID.ToString(); } foreach (System.Data.DataRow drv2 in Ds_Product.Tables[0].Rows) { long strid = Convert.ToInt64(drv2["id"]); prodid = Convert.ToInt32(drv2["ProductID"]); string selcolor = HttpUtility.UrlDecode(drv2["selcolor"].ToString()); Double prodPrice = 0.00; int prodNum = Convert.ToInt32(drv2["ProductNum"]); string guige = HttpUtility.UrlDecode(drv2["guige"].ToString()); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { prodPrice = Convert.ToDouble(Convert.ToDouble(gmodel.G_JG).ToString("f2")); int ZKC = 0; bool IFKC = true; string strcolors = gmodel.G_Color; string[] acolors = gmodel.G_Color.Split(','); for (int jj = 0; jj < acolors.Length; jj++) { if (acolors[jj] != "") { var ac = acolors[jj].Split('|'); if (ac.Length > 1) { if (ac[1] != "") { int intNum = Convert.ToInt32(ac[1]); if (ac[0] == selcolor) { intNum = (intNum - Convert.ToInt32(prodNum)); if (intNum < 0) { intNum = 0; } strcolors = strcolors.Replace(ac[0] + "|" + ac[1], ac[0] + "|" + intNum); } ZKC += intNum; IFKC = false; } } } } gmodel.G_Color = strcolors; if (IFKC) { gmodel.G_KC = gmodel.G_KC - Convert.ToInt32(prodNum); } else { gmodel.G_KC = ZKC; } new DAL.P_Guige().Update(gmodel); } } Model.order_product_info opmodel = new Model.order_product_info(); opmodel.pid = prodid; opmodel.orderid = OrderID; opmodel.selcolor = HttpUtility.UrlDecode(selcolor); opmodel.guige = HttpUtility.UrlDecode(guige); opmodel.DJprice = prodPrice; opmodel.Totalprice = prodPrice * prodNum; opmodel.Totalnum = prodNum; opmodel.UserID = umodel.Id; opmodel.SubmitTime = dt; opmodel.utype = "0"; opmodel.gtype = gtype; new DAL.order_product_info().Add(opmodel); new Mtxfw.DAL.user_cart().Delete(strid); } } } if (umodel.RealName == "" && contact != "") { daoUser.UpdatePassword("RealName", contact, umodel.Id); } if (zftype == 0 || (zftype == 1 && PayZSubTotal == 0.00) || zftype == 5 || zftype == 6 || zftype == 7) { if (utype == 0 || utype == 12 || utype == 14) { if (JFZSubTotal > 0.00) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -JFZSubTotal; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney47 - JFZSubTotal); mjl2.addtime = dt; mjl2.BZContent = "购买商品"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 26; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); //减少买家余额 daoUser.UpdateMoney("umoney47", -JFZSubTotal, umodel.Id); } } if (zftype == 0) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -XJZSubTotal; mjl2.Cutmoney = 0; mjl2.Totalmoney = ((umodel.umoney - umodel.umoney17) - XJZSubTotal); mjl2.addtime = dt; mjl2.BZContent = "购买商品"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 1; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); daoUser.UpdateMoney("umoney17", XJZSubTotal, umodel.Id); umodel.umoney17 += XJZSubTotal; } else if (zftype == 1) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -XJZSubTotal; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney30 - XJZSubTotal); mjl2.addtime = dt; mjl2.BZContent = "用户使用兑换券抵扣商品"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 3; // 兑换券记录 utype=3 mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); //减少买家余额 daoUser.UpdateMoney("umoney30", -XJZSubTotal, umodel.Id); umodel.umoney30 -= XJZSubTotal; } else if (zftype == 5) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -XJZSubTotal; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney29 - XJZSubTotal); mjl2.addtime = dt; mjl2.BZContent = "购买商品"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 6; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); //减少买家余额 daoUser.UpdateMoney("umoney29", -XJZSubTotal, umodel.Id); umodel.umoney29 -= XJZSubTotal; } else if (zftype == 6) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -XJZSubTotal; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel.umoney32 - XJZSubTotal); mjl2.addtime = dt; mjl2.BZContent = "购买商品"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 4; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); //减少买家余额 daoUser.UpdateMoney("umoney32", -XJZSubTotal, umodel.Id); umodel.umoney32 -= XJZSubTotal; } else if (zftype == 7) { } string[] AOrderIDs = OrderIDs.Split(','); for (int i = 0; i < AOrderIDs.Length; i++) { OrderModel = daoorder.GetModel(int.Parse(AOrderIDs[i])); if (OrderModel != null) { Double money = Convert.ToDouble((OrderModel.Totalprice - OrderModel.Totalprice1).ToString("f2"));//结算金额 if (utype == 0) { money = Convert.ToDouble((money - OrderModel.JFTotalprice).ToString("f2"));//结算金额 } Double money0 = Convert.ToDouble(OrderModel.Totalprice0.ToString("f2"));//首单推荐奖励 Double money1 = Convert.ToDouble(OrderModel.Totalprice2.ToString("f2"));//复购推荐奖励 Double money2 = Convert.ToDouble(OrderModel.Totalprice3.ToString("f2"));//赠送广告券/成本 Double money3 = Convert.ToDouble(OrderModel.Totalprice4.ToString("f2"));//赠送补贴券 Double money4 = Convert.ToDouble(OrderModel.Totalprice5.ToString("f2"));// Double money5 = Convert.ToDouble(OrderModel.Totalprice6.ToString("f2"));// Double money6 = Convert.ToDouble(OrderModel.Totalprice7.ToString("f2"));// Double money7 = Convert.ToDouble(OrderModel.Totalprice8.ToString("f2"));// Double money8 = Convert.ToDouble(OrderModel.Totalprice9.ToString("f2"));// if (utype == 0) { DAL.MemberStatistics.UpdteYJ(config, umodel, money, money0, money2, money3, gtype, dt, OrderModel.ttype, OrderModel.ptype, peitype, OrderModel.orderid, OrderModel.Id, OrderModel.Province, OrderModel.City, OrderModel.County, OrderModel.Tradingarea); } else if (utype == 2) { if (ycount0 > 0) { money0 = money1; } DAL.MemberStatistics.UpdteYJ(config, umodel, money, money0, money2, money3, gtype, dt, OrderModel.ttype, OrderModel.ptype, peitype, OrderModel.orderid, OrderModel.Id, OrderModel.Province, OrderModel.City, OrderModel.County, OrderModel.Tradingarea); } if (utype == 14) { if ((peitype == 1 ? OrderModel.ZTMemberId : OrderModel.MemberId) > 0) { Mtxfw.Model.user_info umodel0 = new Mtxfw.DAL.user_info().GetModel((peitype == 1 ? OrderModel.ZTMemberId : OrderModel.MemberId)); if (umodel0 != null) { if (money3 > 0.00) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = umodel0.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = money3; mjl2.Cutmoney = 0; mjl2.Totalmoney = (umodel0.umoney40 + money3); mjl2.addtime = dt; mjl2.BZContent = umodel.RealName + "购买商品,成本"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 16; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); umodel0.umoney40 += money3; umodel0.umoney40 = Convert.ToDouble(umodel0.umoney40.ToString("f2")); daoUser.UpdateMoney("umoney40", money3, umodel0.Id); } } } } daoorder.UpdateqyState(0, "1", dt, OrderModel.Id); daoProduct.UpdateJiangLi(OrderModel.pid, 1); if (peitype == 1) { //string orderhxm = dt.ToString("yyMMddHHmmss", DateTimeFormatInfo.InvariantInfo) + OrderModel.Id; //daoorder.Updateorderhxm(orderhxm, OrderModel.Id); //daoorder.UpdateqyState(0, "2", dt, OrderModel.Id); //daoorder.Updateyundanhao("", "auto", "", OrderModel.Id); } } } if (umodel.Province == "" && umodel.City == "" && umodel.County == "") { daoUser.UpdatePassword("Province", province, umodel.Id); umodel.Province = province; daoUser.UpdatePassword("City", city, umodel.Id); umodel.City = city; daoUser.UpdatePassword("County", county, umodel.Id); umodel.County = county; if (umodel.RealName == "") { umodel.RealName = contact; daoUser.UpdatePassword("RealName", contact, umodel.Id); } } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = dt; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "银花优选" + "微信小程序购买商品" + ZSubTotal + "元成功,支付方式:" + strzftitle; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); } else { strProductName = strProductName.Replace("%", "度").Replace(" ", ""); if (strProductName.Length > 120) { strProductName = strProductName.Substring(0, 120) + "..."; } Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = PayZSubTotal; ModelResults.b1 = 0; ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 1;//0官方支付1汇付支付 ModelResults.b17 = 2; ModelResults.b18 = 0; ModelResults.conent = "购买商品" + strProductName; ModelResults.Totalmoney = PayZSubTotal; ModelResults.MemberId = umodel.Id; ModelResults.UserId = 3; ModelResults.ListNumber = PayID; ModelResults.Managers = "5"; ModelResults.Seef = 0; ModelResults.utype = "2"; ModelResults.addtime = dt; ModelResults.gtype = gtype; ResultId = daoResults.Add(ModelResults); daoResults.UpdateOrderIds(OrderIDs.ToString(), ResultId); string body = "购买商品" + strProductName; /*string p0_Version = "2.1"; string p1_MerchantNo = config.hjpay_ID; string p2_OrderNo = PayID; string p3_Amount = PayZSubTotal.ToString("f2"); string p4_Cur = "1"; string p5_ProductName = body; //string p6_ProductDesc = ""; //string p7_Mp = ""; //string p8_ReturnUrl = ""; string p9_NotifyUrl = config.webUrl + "/pay/receive_notify.aspx"; string q1_FrpCode = "WEIXIN_XCX"; //string q2_MerchantBankCode = ""; //string q3_SubMerchantNo = ""; //string q4_IsShowPic = ""; string q5_OpenId = openid; //string q6_AuthCode = ""; string q7_AppId = config.webXAppID; //string q8_TerminalNo = ""; string qa_TradeMerchantNo = "777112000720172"; //string qk_DisablePayModel = ""; string strsign = p0_Version + p1_MerchantNo + p2_OrderNo + p3_Amount + p4_Cur + p5_ProductName + p9_NotifyUrl + q1_FrpCode + q5_OpenId + q7_AppId + qa_TradeMerchantNo; string hmac = Mtxfw.Utility.Interface_WxPay.GetMD5(strsign + config.hjpay_Secret).ToUpper(); string url = "https://www.joinpay.com/trade/uniPayApi.action"; byte[] postBye; string postdata = "p0_Version=" + p0_Version + "&p1_MerchantNo=" + p1_MerchantNo + "&p2_OrderNo=" + p2_OrderNo + "&p3_Amount=" + p3_Amount + "&p4_Cur=" + p4_Cur + "&p5_ProductName=" + p5_ProductName + "&p9_NotifyUrl=" + p9_NotifyUrl + "&q1_FrpCode=" + q1_FrpCode + "&q5_OpenId=" + q5_OpenId + "&q7_AppId=" + q7_AppId + "&qa_TradeMerchantNo=" + qa_TradeMerchantNo + "&hmac=" + hmac; postBye = Encoding.UTF8.GetBytes(postdata); Mtxfw.Utility.ReturnValue retValue = Mtxfw.Utility.StreamReaderUtils.StreamReader(url, postBye, Encoding.UTF8, true, false, false, ""); if (!retValue.HasError) { hjpay_returns hjpay = (hjpay_returns)Fromhjpay_returnsJson(retValue.Message); if (hjpay.ra_Code == "100") { hjpay_rc_Result hjrc_Result = (hjpay_rc_Result)Fromhjpay_rc_Result(hjpay.rc_Result); timestamp = hjrc_Result.timeStamp; nonceStr = hjrc_Result.nonceStr; package = hjrc_Result.package; paySign = hjrc_Result.paySign; signType = hjrc_Result.signType; } else { Mtxfw.Utility.Common.WriteHtml("/weixin/hmac.txt", strsign + "|" + postdata + "|" + retValue.Message); } }*/ string sys_id = config.hfpaysys_id; string product_id = config.hfpayproduct_id; string req_date = dt.ToString("yyyyMMdd"); string req_seq_id = PayID; string huifu_id = config.hfpayMerchantID; string goods_desc = body; string trade_type = "T_MINIAPP";//T_JSAPI: 微信公众号 T_MINIAPP: 微信小程序 A_JSAPI: 支付宝 A_NATIVE: 支付宝正扫 U_NATIVE: 银联正扫 U_JSAPI: 银联JS D_NATIVE: 数字人民币正扫 T_H5:微信直连H5支付 T_APP:微信APP支付 T_NATIVE:微信正扫 string wx_data = "{\\\"sub_appid\\\":\\\"" + config.webXAppID + "\\\",\\\"sub_openid\\\":\\\"" + openid + "\\\"}"; string trans_amt = PayZSubTotal.ToString("f2"); string time_expire = dt.AddMinutes(10).ToString("yyyyMMddHHmmss"); string notify_url = config.webUrl + "/pay/hfpay_notify_url.aspx"; SortedDictionary pay_dic = new SortedDictionary(); pay_dic.Add("req_date", req_date); pay_dic.Add("req_seq_id", req_seq_id); pay_dic.Add("huifu_id", huifu_id); pay_dic.Add("goods_desc", goods_desc); pay_dic.Add("trade_type", trade_type); pay_dic.Add("wx_data", wx_data); pay_dic.Add("trans_amt", trans_amt); pay_dic.Add("time_expire", time_expire); pay_dic.Add("notify_url", notify_url); string get_PaySign = Mtxfw.Utility.Interface_WxPay.BuildRequest0(pay_dic, config.hfpayPrivateKey); string strq = "{"; strq += "\"sys_id\":\"" + sys_id + "\","; strq += "\"product_id\":\"" + product_id + "\","; strq += "\"data\":{"; strq += "\"req_date\":\"" + req_date + "\","; strq += "\"req_seq_id\":\"" + req_seq_id + "\","; strq += "\"huifu_id\":\"" + huifu_id + "\","; strq += "\"goods_desc\":\"" + goods_desc + "\","; strq += "\"trade_type\":\"" + trade_type + "\","; strq += "\"wx_data\":\"" + wx_data + "\","; strq += "\"trans_amt\":\"" + trans_amt + "\","; strq += "\"time_expire\":\"" + time_expire + "\","; strq += "\"notify_url\":\"" + notify_url + "\""; strq += "}"; strq += ",\"sign\":\"" + get_PaySign + "\""; strq += "}"; string strResult = Mtxfw.Utility.Common.getPage2("https://api.huifu.com/v2/trade/payment/jspay", "", "utf-8", true, true, strq); Mtxfw.Utility.Common.WriteHtml("/weixin/xapiajaxstrResult.txt", strResult); huifuresult hr = (huifuresult)FromhuifuresultJson(strResult); if (hr.data.resp_code == "00000100") { huifuresult2 hr0 = (huifuresult2)Fromhuifuresult2Json(strResult); string pay_info = hr0.data.pay_info; hjpay_rc_Result hjrc_Result = (hjpay_rc_Result)Fromhjpay_rc_Result(pay_info); timestamp = hjrc_Result.timeStamp; nonceStr = hjrc_Result.nonceStr; package = hjrc_Result.package; paySign = hjrc_Result.paySign; signType = hjrc_Result.signType; //data = "{\"status\":1,\"msg\":\"正在支付中...\",\"timeStamp\":\"" + hjrc_Result.timeStamp + "\",\"noncestr\":\"" + hjrc_Result.nonceStr + "\",\"package\":\"" + hjrc_Result.package + "\",\"paySign\":\"" + hjrc_Result.paySign + "\",\"signType\":\"" + hjrc_Result.signType + "\"}"; } else { b = false; data = "{\"status\":0,\"msg\":\"" + hr.data.resp_desc + "\"}"; } //Mtxfw.Utility.Interface_WxPay.Get_RequestHtml0(config, context, openid, PayID, Convert.ToDecimal(JFZSubTotal), ref timestamp, ref nonceStr, ref package, ref paySign, body, "card_store"); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = dt; logmodel.IP = (umodel.Id == 10154 ? "119.39.248.32" : Mtxfw.Utility.Common.GetIP); logmodel.Body = "银花优选" + "微信小程序购买商品" + ZSubTotal + "元去付款,支付方式:" + strzftitle; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); Model.User_Errlog mo = new Model.User_Errlog(); mo.DLID = 0; mo.ErrType = "银花优选微信小程序购买商品"; mo.addtime = DateTime.Now; mo.ErrBody = umodel.Id + "|" + umodel.UserName; mo.ErrBody2 = openid + "|" + timestamp + "|" + nonceStr + "|" + package + "|" + paySign; new DAL.User_Errlog().Add(mo); //Mtxfw.Utility.Common.WriteHtml("/weixin/reResult.txt", ); } if (b) { string strdata = ""; umodel = daoUser.GetModel(userId); strdata = returndata(umodel); data = "{\"status\":1,\"msg\":\"" + (zftype == 2 ? "正在支付中" : "下单成功") + "\",\"PayID\":\"" + PayID + "\",\"IFSendSms\":\"" + IFSendSms + "\",\"SendSmsErr\":\"" + SendSmsErr + "\",\"bankphone\":\"" + bankphone + "\",\"ResultId\":\"" + ResultId + "\",\"timeStamp\":\"" + timestamp + "\",\"noncestr\":\"" + nonceStr + "\",\"package\":\"" + package + "\",\"paySign\":\"" + paySign + "\",\"signType\":\"" + signType + "\"," + strdata + "}"; } } } else { data = "{\"status\":0,\"msg\":\"请不要重复点击!\"}"; } Ds_Product.Clear(); } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } //Mtxfw.Utility.Common.WriteHtml("/weixin/data.txt", data); return data; } #endregion #region //获取支付信息----------------------------------------------------------------------------------------- /// /// 获取支付信息 /// protected string getpaydata(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["id"]) && !String.IsNullOrEmpty(context.Request["code"])) { Int64 ResultId = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["id"].ToString())); string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); WXcode2Session ac = getcode2Session(code, config.webXAppID, config.webXAppSecret); if (ac != null) { string openid = ac.openid; Mtxfw.Model.user_Results rmodel = daoResults.GetModel(ResultId); if (rmodel != null) { if (rmodel.utype == "2") { if (rmodel.IFDelete == 0) { if (rmodel.Seef == 0) { string[] OrderIds = rmodel.OrderIds.Split(','); foreach (string orderid in OrderIds) { if (orderid != "") { daoorder.Updateopenid(openid, Convert.ToInt32(orderid)); } } DateTime dt = DateTime.Now; /*string p0_Version = "2.1"; string p1_MerchantNo = config.hjpay_ID; string p2_OrderNo = rmodel.ListNumber; string p3_Amount = rmodel.b0.ToString("f2"); string p4_Cur = "1"; string p5_ProductName = rmodel.conent; //string p6_ProductDesc = ""; //string p7_Mp = ""; //string p8_ReturnUrl = ""; string p9_NotifyUrl = config.webUrl + "/pay/receive_notify.aspx"; string q1_FrpCode = "WEIXIN_XCX"; //string q2_MerchantBankCode = ""; //string q3_SubMerchantNo = ""; //string q4_IsShowPic = ""; string q5_OpenId = openid; //string q6_AuthCode = ""; string q7_AppId = config.webXAppID; //string q8_TerminalNo = ""; string qa_TradeMerchantNo = "777112000720172"; //string qk_DisablePayModel = ""; string strsign = p0_Version + p1_MerchantNo + p2_OrderNo + p3_Amount + p4_Cur + p5_ProductName + p9_NotifyUrl + q1_FrpCode + q5_OpenId + q7_AppId + qa_TradeMerchantNo; string hmac = Mtxfw.Utility.Interface_WxPay.GetMD5(strsign + config.hjpay_Secret).ToUpper(); string url = "https://www.joinpay.com/trade/uniPayApi.action"; byte[] postBye; string postdata = "p0_Version=" + p0_Version + "&p1_MerchantNo=" + p1_MerchantNo + "&p2_OrderNo=" + p2_OrderNo + "&p3_Amount=" + p3_Amount + "&p4_Cur=" + p4_Cur + "&p5_ProductName=" + p5_ProductName + "&p9_NotifyUrl=" + p9_NotifyUrl + "&q1_FrpCode=" + q1_FrpCode + "&q5_OpenId=" + q5_OpenId + "&q7_AppId=" + q7_AppId + "&qa_TradeMerchantNo=" + qa_TradeMerchantNo + "&hmac=" + hmac; postBye = Encoding.UTF8.GetBytes(postdata); Mtxfw.Utility.ReturnValue retValue = Mtxfw.Utility.StreamReaderUtils.StreamReader(url, postBye, Encoding.UTF8, true, false, false, ""); if (!retValue.HasError) { hjpay_returns hjpay = (hjpay_returns)Fromhjpay_returnsJson(retValue.Message); if (hjpay.ra_Code == "100") { hjpay_rc_Result hjrc_Result = (hjpay_rc_Result)Fromhjpay_rc_Result(hjpay.rc_Result); string timestamp = hjrc_Result.timeStamp; string nonceStr = hjrc_Result.nonceStr; string package = hjrc_Result.package; string paySign = hjrc_Result.paySign; string signType = hjrc_Result.signType; data = "{\"status\":1,\"msg\":\"正在支付中...\",\"timeStamp\":\"" + timestamp + "\",\"noncestr\":\"" + nonceStr + "\",\"package\":\"" + package + "\",\"paySign\":\"" + paySign + "\",\"signType\":\"" + signType + "\"}"; } else { Mtxfw.Utility.Common.WriteHtml("/weixin/xpayerr.txt", strsign + "|" + postdata + "|" + retValue.Message); data = "{\"status\":0,\"msg\":\"" + hjpay.rb_CodeMsg + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"支付失败\"}"; }*/ string sys_id = config.hfpaysys_id; string product_id = config.hfpayproduct_id; string req_date = dt.ToString("yyyyMMdd"); string req_seq_id = rmodel.ListNumber; string huifu_id = config.hfpayMerchantID; string goods_desc = rmodel.conent; string trade_type = "T_MINIAPP";//T_JSAPI: 微信公众号 T_MINIAPP: 微信小程序 A_JSAPI: 支付宝 A_NATIVE: 支付宝正扫 U_NATIVE: 银联正扫 U_JSAPI: 银联JS D_NATIVE: 数字人民币正扫 T_H5:微信直连H5支付 T_APP:微信APP支付 T_NATIVE:微信正扫 string wx_data = "{\\\"sub_appid\\\":\\\"" + config.webXAppID + "\\\",\\\"sub_openid\\\":\\\"" + openid + "\\\"}"; string trans_amt = rmodel.b0.ToString("f2"); string time_expire = dt.AddMinutes(10).ToString("yyyyMMddHHmmss"); string notify_url = config.webUrl + "/pay/hfpay_notify_url.aspx"; SortedDictionary pay_dic = new SortedDictionary(); pay_dic.Add("req_date", req_date); pay_dic.Add("req_seq_id", req_seq_id); pay_dic.Add("huifu_id", huifu_id); pay_dic.Add("goods_desc", goods_desc); pay_dic.Add("trade_type", trade_type); pay_dic.Add("wx_data", wx_data); pay_dic.Add("trans_amt", trans_amt); pay_dic.Add("time_expire", time_expire); pay_dic.Add("notify_url", notify_url); string get_PaySign = Mtxfw.Utility.Interface_WxPay.BuildRequest0(pay_dic, config.hfpayPrivateKey); string strq = "{"; strq += "\"sys_id\":\"" + sys_id + "\","; strq += "\"product_id\":\"" + product_id + "\","; strq += "\"data\":{"; strq += "\"req_date\":\"" + req_date + "\","; strq += "\"req_seq_id\":\"" + req_seq_id + "\","; strq += "\"huifu_id\":\"" + huifu_id + "\","; strq += "\"goods_desc\":\"" + goods_desc + "\","; strq += "\"trade_type\":\"" + trade_type + "\","; strq += "\"wx_data\":\"" + wx_data + "\","; strq += "\"trans_amt\":\"" + trans_amt + "\","; strq += "\"time_expire\":\"" + time_expire + "\","; strq += "\"notify_url\":\"" + notify_url + "\""; strq += "}"; strq += ",\"sign\":\"" + get_PaySign + "\""; strq += "}"; string strResult = Mtxfw.Utility.Common.getPage2("https://api.huifu.com/v2/trade/payment/jspay", "", "utf-8", true, true, strq); Mtxfw.Utility.Common.WriteHtml("/weixin/xapiajaxstrResult0.txt", strResult); huifuresult hr = (huifuresult)FromhuifuresultJson(strResult); if (hr.data.resp_code == "00000100") { huifuresult2 hr0 = (huifuresult2)Fromhuifuresult2Json(strResult); string pay_info = hr0.data.pay_info; hjpay_rc_Result hjrc_Result = (hjpay_rc_Result)Fromhjpay_rc_Result(pay_info); data = "{\"status\":1,\"msg\":\"正在支付中...\",\"timeStamp\":\"" + hjrc_Result.timeStamp + "\",\"noncestr\":\"" + hjrc_Result.nonceStr + "\",\"package\":\"" + hjrc_Result.package + "\",\"paySign\":\"" + hjrc_Result.paySign + "\",\"signType\":\"" + hjrc_Result.signType + "\"}"; } else { data = "{\"status\":0,\"msg\":\"" + hr.data.resp_desc + "\"}"; } /*string timestamp = "", nonceStr = "", package = "", paySign = ""; Mtxfw.Utility.Interface_WxPay.Get_RequestHtml0(config, context, openid, rmodel.ListNumber, Convert.ToDecimal(rmodel.b0), ref timestamp, ref nonceStr, ref package, ref paySign, rmodel.conent, "card_store"); data = "{\"status\":1,\"msg\":\"正在支付中...\",\"timeStamp\":\"" + timestamp + "\",\"noncestr\":\"" + nonceStr + "\",\"package\":\"" + package + "\",\"paySign\":\"" + paySign + "\",\"signType\":\"MD5\"}";*/ } else { data = "{\"status\":0,\"msg\":\"此订单已支付!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误1!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误0!\"}"; } } else { data = "{\"status\":0,\"msg\":\"获取openid错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取支付签名----------------------------------------------------------------------------------------- /// /// 获取支付签名 /// protected string car_pay_sign(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["prepayid"]) && !String.IsNullOrEmpty(context.Request["package"]) && !String.IsNullOrEmpty(context.Request["noncestr"]) && !String.IsNullOrEmpty(context.Request["ResultId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string prepayid = HttpUtility.UrlDecode(context.Request["prepayid"].ToString()); string package = HttpUtility.UrlDecode(context.Request["package"].ToString()); string noncestr = HttpUtility.UrlDecode(context.Request["noncestr"].ToString()); Int64 ResultId = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["ResultId"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { //Mtxfw.Utility.Common.WriteHtml("/weixin/ResultId.txt", ResultId.ToString()); if (umodel.LoginId2 == LoginId) { Mtxfw.Model.user_Results rmodel = daoResults.GetModel(ResultId); if (rmodel != null) { SortedDictionary pay_dic = new SortedDictionary(); string appid = config.weixinAPP_ID; string mch_id = config.webPARTNER; string PARTNER_KEY = config.webPARTNER_KEY; string timestamp = Mtxfw.Utility.Interface_WxPay.getTimestamp(); pay_dic.Add("appid", appid); pay_dic.Add("partnerid", mch_id); pay_dic.Add("prepayid", prepayid); pay_dic.Add("package", package); pay_dic.Add("noncestr", noncestr); pay_dic.Add("timestamp", timestamp); context.Session["timestamp"] = timestamp; string get_PaySign = Mtxfw.Utility.Interface_WxPay.BuildRequest(pay_dic, PARTNER_KEY); //Mtxfw.Utility.Common.WriteHtml("/weixin/car_pay_sign.txt", get_PaySign); data = "{\"status\":1,\"msg\":\"请稍候!\",\"partnerid\":\"" + mch_id + "\",\"noncestr\":\"" + noncestr + "\",\"timestamp\":\"" + timestamp + "\",\"sign\":\"" + get_PaySign + "\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取订单是否已支付----------------------------------------------------------------------------------------- /// /// 获取订单是否已支付 /// protected string getIFPayed(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["ResultId"])) { Int64 ResultId = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["ResultId"].ToString())); if (daoResults.GetCount("seef=1 And id=" + ResultId) > 0) { data = "{\"status\":1,\"msg\":\"支付成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region 判断邀请人账号是否存在(前台注册) /// /// 判断邀请人账号是否存在(前台注册) /// /// protected string GetUserName2(HttpContext context) { string data = "{\"status\":0}"; String UserName = HttpUtility.UrlDecode(context.Request["name"]); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"]); } int uLevel5 = 0; if (!String.IsNullOrEmpty(context.Request["uLevel5"])) { uLevel5 = Convert.ToInt32(context.Request["uLevel5"]); } if (t == 2) { if (daoUser.IsExists2(UserName, 0, gtype)) { string strrealname = ""; int uLevel3 = 0, uLevel6 = 0, SuperiorsID = 0; SqlDataReader dr = daoUser.GetUserId(gtype, UserName); if (dr.Read()) { if (dr.HasRows) { SuperiorsID = int.Parse(dr["id"].ToString()); uLevel3 = int.Parse(dr["uLevel3"].ToString()); uLevel6 = int.Parse(dr["uLevel6"].ToString()); strrealname = dr["realname"].ToString(); } } dr.Close(); if (daoUser.GetCount("SuperiorsID=" + SuperiorsID) > 3) { data = "{\"status\":0,\"msg\":\"接点人已满人!\"}"; } else { if (uLevel5 == 0) { if (daoUser.GetCount("SuperiorsID=" + SuperiorsID + " And uLevel5=0") > 0) { data = "{\"status\":0,\"msg\":\"A区已有人!\"}"; } else { data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } } else { if (uLevel5 == 1) { if (daoUser.GetCount("SuperiorsID=" + SuperiorsID + " And uLevel5=0 And UserState='正常'") == 0) { data = "{\"status\":0,\"msg\":\"A区未审核或未注册!\"}"; } else { if (daoUser.GetCount("SuperiorsID=" + SuperiorsID + " And uLevel5=1") > 0) { data = "{\"status\":0,\"msg\":\"B区已有人!\"}"; } else { data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } } } else if (uLevel5 == 2) { if (daoUser.GetCount("SuperiorsID=" + SuperiorsID + " And uLevel5=1 And UserState='正常'") == 0) { data = "{\"status\":0,\"msg\":\"B区未审核或未注册!\"}"; } else { if (daoUser.GetCount("SuperiorsID=" + SuperiorsID + " And uLevel5=2") > 0) { data = "{\"status\":0,\"msg\":\"C区已有人!\"}"; } else { data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } } } } } } else { data = "{\"status\":0,\"msg\":\"对方账户不存在!\"}"; } } else if (t == 3) { if (daoUser.IsExists2(UserName, 0, gtype)) { string strrealname = ""; SqlDataReader dr = daoUser.GetUserId(gtype, UserName); if (dr.Read()) { if (dr.HasRows) { strrealname = dr["realname"].ToString(); } } dr.Close(); data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } else { data = "{\"status\":0,\"msg\":\"对方账户不存在!\"}"; } } else if (t == 4) { if (daoUser.IsExists2(UserName, 1, gtype)) { string strrealname = ""; SqlDataReader dr = daoUser.GetUserId(gtype, UserName); if (dr.Read()) { if (dr.HasRows) { strrealname = dr["realname"].ToString(); } } dr.Close(); data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } else { data = "{\"status\":0,\"msg\":\"服务中心账户不存在!\"}"; } } else if (t == 5) { if (daoUser.IsExists2(UserName, 0, gtype)) { string strrealname = ""; SqlDataReader dr = daoUser.GetUserId(gtype, UserName); if (dr.Read()) { if (dr.HasRows) { strrealname = dr["realname"].ToString(); } } dr.Close(); data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } else { data = "{\"status\":0,\"msg\":\"推荐人账户不存在!\"}"; } } else if (t == 10) { if (daoUser.IsExists2(UserName, 0, gtype)) { string strrealname = ""; string uutype = ""; SqlDataReader dr = daoUser.GetUserId(gtype, UserName); if (dr.Read()) { if (dr.HasRows) { uutype = dr["uutype"].ToString(); strrealname = dr["realname"].ToString(); } } dr.Close(); if (uutype != "0") { data = "{\"status\":0,\"msg\":\"接点人账户填写错误!\"}"; } else { data = "{\"status\":1,\"name\":\"" + strrealname + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"合伙人账户不存在!\"}"; } } else { if (daoUser.IsExists2(UserName, t, gtype)) { data = "{\"status\":0,\"msg\":\"账号已存在!\"}"; } else { data = "{\"status\":1,\"msg\":\"账号可以注册!\"}"; } } return data; } #endregion #region //转账----------------------------------------------------------------------------------------- /// /// 转账 /// protected string zhuanzhang(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["UserName"]) && !String.IsNullOrEmpty(context.Request["je"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string UserName = HttpUtility.UrlDecode(context.Request["UserName"].ToString()); string je = HttpUtility.UrlDecode(context.Request["je"].ToString()); string desc = "互转"; if (!String.IsNullOrEmpty(context.Request["desc"])) { desc = HttpUtility.UrlDecode(context.Request["desc"].ToString()); } int zztype = 0; if (!String.IsNullOrEmpty(context.Request["zztype"])) { zztype = Convert.ToInt32(context.Request["zztype"].ToString()); } string strtitle = "激活码", ZZEnable = ""; bool b = true; if (zztype == 1) { strtitle = "余额"; ZZEnable = config.JJBZZEnable; } else if (zztype == 4) { strtitle = "佣金"; ZZEnable = config.DZBZZEnable; } else if (zztype == 5) { strtitle = "KSD"; ZZEnable = config.JJBZRDHBEnable; } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { Double ktCurrency = 0.00, ktCurrency2 = 0.00; int UserId = 0; string ContactIDS = ""; string registrationId = ""; SqlDataReader Dr = new Mtxfw.DAL.user_info().GetUserId(gtype, UserName); if (Dr.HasRows) { if (Dr.Read()) { UserId = int.Parse(Dr["Id"].ToString()); ContactIDS = Dr["ContactIDS"].ToString(); registrationId = Dr["registrationId"].ToString(); if (zztype == 5) { ktCurrency2 = (Convert.ToDouble(Dr["umoney34"])); } else if (zztype == 4) { ktCurrency2 = (Convert.ToDouble(Dr["umoney32"])); } else if (zztype == 1) { ktCurrency2 = (Convert.ToDouble(Dr["umoney"]) - Convert.ToDouble(Dr["umoney17"])); } else if (zztype == 0) { ktCurrency2 = (Convert.ToDouble(Dr["umoney16"])); } } } Dr.Close(); ktCurrency2 = Convert.ToDouble(Convert.ToDouble(ktCurrency2.ToString("0.####")).ToString("f4")); if (b) { if (zztype == 0) { if (ktCurrency2 > 0.00) { b = false; data = "{\"status\":0,\"msg\":\"对方已有激活码,不需要再转!\"}"; } } } if (b) { if (config.FHEnable == "0") { if (model.uLevel18 != 2) { b = false; data = "{\"status\":0,\"msg\":\"请先实名认证!\"}"; } } } if (b) { if (String.IsNullOrEmpty(context.Request["code"]) && String.IsNullOrEmpty(context.Request["pwd"])) { b = false; data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } } if (b) { if (zztype > 0) { if (ZZEnable == "1" && model.uLevel47==0) { b = false; data = "{\"status\":0,\"msg\":\"互转通道暂时关闭!\"}"; } } } if (UserId == 0) { if (b) { b = false; data = "{\"status\":0,\"msg\":\"对方账户不存在!\"}"; } } if (b) { if (UserId == model.Id) { b = false; data = "{\"status\":0,\"msg\":\"对方账户不能是自己!\"}"; } } if (b) { if (model.uLevel8 == 1) { b = false; data = "{\"status\":0,\"msg\":\"您的账户已被封号不能转账!\"}"; } } if (b) { if (model.uLevel10 == 1) { b = false; data = "{\"status\":0,\"msg\":\"您的账户暂时不能转账!\"}"; } } /*if (b) { if (model.ContactIDS.IndexOf("," + UserId + ",") == -1 && ContactIDS.IndexOf("," + model.Id + ",") == -1) { b = false; data = "{\"status\":0,\"msg\":\"只能上下转账!\"}"; } }*/ if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(je, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"转账数量必须为整数!\"}"; } } Double money = 0.00; if (b) { money = Convert.ToDouble(Convert.ToDouble(je).ToString("f2")); if (Convert.ToInt32(je) < 1 || Convert.ToInt32(je) % 1 != 0) { b = false; data = "{\"status\":0,\"msg\":\"转账数量必须为1的倍数!\"}"; } } if (b) { if (money <= 0.00) { b = false; data = "{\"status\":0,\"msg\":\"转账数量不能小于0!\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["pwd"])) { string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } else { if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } } } } if (zztype == 5) { ktCurrency = (model.umoney34); } else if (zztype == 4) { ktCurrency = (model.umoney32); } else if (zztype == 1) { ktCurrency = (model.umoney - model.umoney17); } else if (zztype == 0) { ktCurrency = (model.umoney16); } //Double ktCurrency1 = Convert.ToDouble(model.umoney31.ToString("f2")); ktCurrency = Convert.ToDouble(Convert.ToDouble(ktCurrency.ToString("0.####")).ToString("f4")); if (b) { if (money > ktCurrency) { b = false; data = "{\"status\":0,\"msg\":\"您的" + strtitle + "可用余额不足!\"}"; } } /*if (zztype == 0) { if (b) { if (gxzmoney > ktCurrency1) { b = false; data = "{\"status\":0,\"msg\":\"您的贡献值余额不足!\"}"; } } }*/ if (b) { Double zzsxf = 0.00; Double b0 = 0; /*if (zztype == 0) { zzsxf = Mtxfw.Utility.Common.GetSXF(model.uLevel, config); zzsxf = Convert.ToDouble(zzsxf.ToString("f2")); if (zzsxf < 0.00) { zzsxf = 0.00; } b0 = (money * zzsxf / 100); }*/ Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = b0; ModelResults.b1 = (money - b0); ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = zztype; ModelResults.conent = desc; ModelResults.Totalmoney = money; ModelResults.MemberId = model.Id; ModelResults.UserId = UserId; ModelResults.ListNumber = ""; ModelResults.Managers = ""; ModelResults.Seef = -1; ModelResults.utype = "11"; DateTime dt = DateTime.Now; ModelResults.addtime = dt; ModelResults.gtype = gtype; daoResults.Add(ModelResults); int utype = 1; if (zztype == 5) { utype = 14; daoUser.UpdateMoney("umoney34", (money - b0), UserId); daoUser.UpdateMoney("umoney34", -money, model.Id); model.umoney34 -= money; } else if (zztype == 4) { utype = 4; daoUser.UpdateMoney("umoney32", (money - b0), UserId); daoUser.UpdateMoney("umoney32", -money, model.Id); model.umoney32 -= money; } else if (zztype == 1) { utype = 1; daoUser.UpdateMoney("umoney17", -(money - b0), UserId); daoUser.UpdateMoney("umoney17", money, model.Id); model.umoney17 += money; } else if (zztype == 0) { utype = 21; daoUser.UpdateMoney("umoney16", (money - b0), UserId); daoUser.UpdateMoney("umoney16", -money, model.Id); model.umoney16 -= money; daoUser.UpdateuLevel("DLRememberID", model.Id, UserId); } Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = UserId; mjl2.Addmoney = -money; mjl2.Cutmoney = 0; mjl2.Totalmoney = ktCurrency - money; mjl2.addtime = DateTime.Now; mjl2.BZContent = "您给" + UserName + "转账" + ((desc != "转账" && desc != "互转") ? " " + desc : ""); mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = utype; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = UserId; mjl2.MemberId2 = model.Id; mjl2.Addmoney = (money - b0); mjl2.Cutmoney = 0; mjl2.Totalmoney = ktCurrency2 + (money - b0); mjl2.addtime = DateTime.Now; mjl2.BZContent = model.UserName + "给您转账" + (desc != "转账" ? " " + desc : ""); mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = utype; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = dt; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = strtitle + " 转账,转出账户:" + model.UserName + ",转入账户:" + UserName + ",转账金额:" + money; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); Mtxfw.Model.Article amodel = new Mtxfw.Model.Article(); amodel.senderid = 0; amodel.receiverid = UserId; amodel.Title = "转账消息"; amodel.ParentID = 30; amodel.CategoryId = "0"; amodel.AddTime = DateTime.Now; amodel.Author = "../image/zhuanzhang-ico.png"; amodel.Content = model.UserName + "给您转账" + money; amodel.Paths = "zhuanzhang_log.html"; amodel.Content2 = ""; amodel.Paths2 = ""; amodel.KeyWords = ""; amodel.media_id = ""; amodel.thumb_media_id = ""; amodel.wtype = 1; amodel.wtype2 = 0; amodel.LinkID = 1; amodel.Seef = 0; amodel.gtype = gtype; string dataid = daoArt.Add(amodel).ToString(); if (registrationId != "") { List RegistrationIDList = new List(); RegistrationIDList.Add(registrationId); string title = amodel.Title; string strMsg = amodel.Content; bool is_production = true; string strLog = ""; new Jiguang.JPush.JPushV3().SendPushV2(RegistrationIDList, title, dataid, strMsg, is_production, out strLog); } if (!String.IsNullOrEmpty(context.Request["code"])) { daoUser.UpdatePhoneTime3("", model.Id); } data = "{\"status\":1,\"msg\":\"转账成功!\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //兑换----------------------------------------------------------------------------------------- /// /// 兑换 /// protected string zhuanhuan(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["je"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string je = HttpUtility.UrlDecode(context.Request["je"].ToString()); string desc = "划转"; if (!String.IsNullOrEmpty(context.Request["desc"])) { desc = HttpUtility.UrlDecode(context.Request["desc"].ToString()); } int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { Double ktCurrency = 0.00, ktCurrency2 = 0.00; string strtitle = "余额划转兑换积分", strtit = "余额"; string ZHFHEnable = ""; bool b = true; if (t == 1) { strtitle = "兑换积分划转流量积分"; strtit = "兑换积分"; ZHFHEnable = config.FHEnable2; if (model.uLevel26 == 0) { b = false; data = "{\"status\":0,\"msg\":\"创客会员才能把兑换积分划转流量积分!\"}"; } } else if (t == 2) { strtitle = "流量积分划转KSD"; strtit = "流量积分"; ZHFHEnable = config.FHEnable3; } else if (t == 3) { strtitle = "KSD划转流量积分"; strtit = "KSD"; ZHFHEnable = config.FHEnable6; } else { b = false; data = "{\"status\":0,\"msg\":\"余额划转兑换积分暂时不能划转!\"}"; } if (b) { if (config.FHEnable == "0") { if (model.uLevel18 != 2) { b = false; data = "{\"status\":0,\"msg\":\"请先实名认证!\"}"; } } } if (b) { if (String.IsNullOrEmpty(context.Request["code"]) && String.IsNullOrEmpty(context.Request["pwd"])) { b = false; data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } } if (b) { if (ZHFHEnable == "1") { b = false; data = "{\"status\":0,\"msg\":\"" + strtitle + "通道暂时关闭!\"}"; } } if (b) { if (model.uLevel8 == 1) { b = false; data = "{\"status\":0,\"msg\":\"您的账户已被封号不能划转!\"}"; } } if (b) { if (t == 1 || t == 3) { if (model.uLevel31 == 1) { b = false; data = "{\"status\":0,\"msg\":\"您的账户暂时不能兑换流量积分!\"}"; } } else if (t == 2) { if (model.uLevel32 == 1) { b = false; data = "{\"status\":0,\"msg\":\"您的账户暂时不能兑换KSD!\"}"; } } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(je, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"划转数量必须为整数!\"}"; } } Double money = 0.00; if (b) { money = Convert.ToDouble(Convert.ToDouble(je).ToString("f2")); } if (b) { if (money <= 0.00) { b = false; data = "{\"status\":0,\"msg\":\"划转数量不能小于0!\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["pwd"])) { string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } else { if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } } } } ktCurrency = (model.umoney - model.umoney17); ktCurrency2 = model.umoney30; if (t == 1) { ktCurrency = model.umoney30; ktCurrency2 = model.umoney29; } if (t == 2) { ktCurrency = model.umoney29; ktCurrency2 = model.umoney34; } else if (t == 3) { ktCurrency = model.umoney34; ktCurrency2 = model.umoney29; } ktCurrency = Convert.ToDouble(Convert.ToDouble(ktCurrency.ToString("0.####")).ToString("f4")); ktCurrency2 = Convert.ToDouble(Convert.ToDouble(ktCurrency2.ToString("0.####")).ToString("f4")); if (b) { if (money > ktCurrency) { b = false; data = "{\"status\":0,\"msg\":\"您的" + strtit + "不足" + money + "!\"}"; } } /*if (t == 0) { if (b) { if (gxzmoney > ktCurrency1) { b = false; data = "{\"status\":0,\"msg\":\"您的贡献值余额不足!\"}"; } } }*/ if (b) { Double zhsxf = 0.00; if (t == 2) { //zhsxf = Mtxfw.Utility.Common.GetSXF(model.uLevel, config); zhsxf = Convert.ToDouble(zhsxf.ToString("f2")); if (zhsxf < 0.00) { zhsxf = 0.00; } } Double b1 = (zhsxf / 100 * money); Double b2 = (money - b1); if (t == 1) { Double jyjg = daojjfp.GetJYJG(); b2 = ((money - b1) / jyjg); } DateTime dt = DateTime.Now; string orderid = "dh" + dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo); Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = money; ModelResults.b1 = b1; ModelResults.b2 = b2; ModelResults.b3 = Convert.ToDouble(config.webMoney79); ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = 0; ModelResults.conent = desc; ModelResults.Totalmoney = money; ModelResults.MemberId = model.Id; ModelResults.UserId = t; ModelResults.ListNumber = orderid; ModelResults.Managers = ""; ModelResults.Seef = 0; ModelResults.utype = "3"; ModelResults.addtime = dt; ModelResults.gtype = gtype; Int64 ResultID = daoResults.Add(ModelResults); int utype = 2; if (t == 3) { utype = 14; daoUser.UpdateMoney("umoney34", -money, model.Id); model.umoney34 -= money; daoUser.UpdateMoney("umoney29", b2, model.Id); model.umoney29 += b2; } else if (t == 2) { utype = 6; daoUser.UpdateMoney("umoney29", -money, model.Id); model.umoney29 -= money; daoUser.UpdateMoney("umoney34", b2, model.Id); model.umoney34 += b2; } else if (t == 1) { utype = 2; daoUser.UpdateMoney("umoney30", -money, model.Id); model.umoney30 -= money; daoUser.UpdateMoney("umoney29", b2, model.Id); model.umoney29 += b2; } else { utype = 1; daoUser.UpdateMoney("umoney17", money, model.Id); model.umoney17 += money; daoUser.UpdateMoney("umoney30", b2, model.Id); model.umoney30 += b2; } Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -money; mjl2.Cutmoney = 0; mjl2.Totalmoney = ktCurrency - money; mjl2.addtime = dt; mjl2.BZContent = strtitle; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = utype; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); /*if (t == 0) { if (gxzmoney > 0.00) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -gxzmoney; mjl2.Cutmoney = 0; mjl2.Totalmoney = ktCurrency1 - gxzmoney; mjl2.addtime = DateTime.Now; mjl2.BZContent = strtitle; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 3; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); daoUser.UpdateMoney("umoney31", -gxzmoney, model.Id); } }*/ utype = 2; if (t == 3) { utype = 6; } else if (t == 2) { utype = 14; } else if (t == 1) { utype = 6; } mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = model.Id; mjl2.Addmoney = b2; mjl2.Cutmoney = 0; mjl2.Totalmoney = ktCurrency2 + b2; mjl2.addtime = dt; mjl2.BZContent = strtitle; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = utype; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = dt; mjl2.gtype = gtype; daojl2.Add(mjl2); if (t == 2) { if (Convert.ToDouble(b1.ToString("f2")) > 0.00) { daojjfp.Updatecount("count1", b1, gtype, 0); } } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = dt; logmodel.IP = (model.Id == 8714 ? "223.104.162.201" : Mtxfw.Utility.Common.GetIP); logmodel.Body = strtitle + " ,数量:" + money; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"划转成功!\",\"ResultID\":\"" + ResultID + "\"," + returndata(model) + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //充值----------------------------------------------------------------------------------------- /// /// 充值 /// protected string chongzhi(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(context.Request["e"].ToString()); } } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["je"]) && context.Request["desc"] != null) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int zztype = 0; if (!String.IsNullOrEmpty(context.Request["zztype"])) { zztype = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["zztype"].ToString())); } string je = HttpUtility.UrlDecode(context.Request["je"].ToString()); bool b = true; string zhanghao = ""; if (!String.IsNullOrEmpty(context.Request["zhanghao"])) { zhanghao = context.Request["zhanghao"].ToString().Trim(); } string desc = HttpUtility.UrlDecode(context.Request["desc"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (b) { if (config.JJBZZEnable == "1") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Recharge switch has been closed!" : "充值开关已关闭!") + "\"}"; } } if (b) { if (zztype < 0 || zztype > 6) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The charging mode is incorrect!" : "充值方式不正确!") + "\"}"; } } int acount = daoResults.GetCount("MemberId=" + model.Id + " and utype=2 And Seef=0 And IFDelete=0 And UserId<>5"); if (acount > 4) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Only 5 unaudited records can be submitted at most!" : "最多只能提交5次未审核记录!") + "\"}"; } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(je, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The amount of recharge must be an integer!" : "充值金额必须为整数!") + "\"}"; } } Double money = 0.00; if (b) { money = Convert.ToDouble(Convert.ToDouble(je).ToString("f2")); if (Convert.ToInt32(je) < Convert.ToDouble(Convert.ToDouble(config.webMoney1).ToString("f2")) || Convert.ToInt32(je) % Convert.ToInt32(config.webMoney2) != 0) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The amount of recharge must be greater than or equal to " + config.webMoney1 + " and must be a multiple of " + config.webMoney1 + "!" : "充值金额必须大于或等于" + config.webMoney1 + "且必须为" + config.webMoney2 + "的倍数!") + "\"}"; } } if (b) { if (money <= 0.00) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The amount of recharge can not be less than 0!" : "充值金额不能小于0!") + "\"}"; } } if (b) { if (zhanghao == "") { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "After the bank card number, the four must not be empty!" : "银行卡号后四位不能为空!") + "\"}"; } else { if (!System.Text.RegularExpressions.Regex.IsMatch(zhanghao, @"^-?\d+$") || zhanghao.Length != 4) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "After the bank card number, the four digit can only be 4 digits!" : "银行卡号后四位只能是4位数字!") + "\"}"; } } } if (b) { DateTime dt = DateTime.Now; string PayID = dt.ToString("yyyyMMddhhmmssffff", DateTimeFormatInfo.InvariantInfo); Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = money; ModelResults.b1 = 0; ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = 0; ModelResults.conent = desc; ModelResults.Totalmoney = money; ModelResults.MemberId = model.Id; ModelResults.UserId = zztype; ModelResults.ListNumber = PayID; ModelResults.Managers = zhanghao; ModelResults.Seef = 0; ModelResults.utype = "2"; ModelResults.addtime = dt; ModelResults.gtype = gtype; daoResults.Add(ModelResults); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = dt; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "充值金额:" + money; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Save success!" : "保存成功!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //提现----------------------------------------------------------------------------------------- /// /// 提现 /// protected string tixian(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(context.Request["e"].ToString()); } } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["je"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string je = HttpUtility.UrlDecode(context.Request["je"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } int paytype = 0; if (!String.IsNullOrEmpty(context.Request["paytype"])) { paytype = Convert.ToInt32(context.Request["paytype"].ToString()); } string strtitle = "佣金"; if (t == 1) { strtitle = "KSD"; } else if (t == 2) { strtitle = "解冻货款"; } else if (t == 3) { strtitle = "货款扣税"; } else if (t == 4) { strtitle = "增值积分"; } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); bool b = true; if (t == 0) { if (b) { if (paytype == 2) { if (config.CQEnable.IndexOf("2") == -1) { b = false; data = "{\"status\":0,\"msg\":\"暂时不能提现到微信!\"}"; } } else if (paytype == 1) { if (config.CQEnable.IndexOf("1") == -1) { b = false; data = "{\"status\":0,\"msg\":\"暂时不能提现到支付宝!\"}"; } } else { if (config.CQEnable.IndexOf("0") == -1) { b = false; data = "{\"status\":0,\"msg\":\"暂时不能提现到银行卡!\"}"; } } } } else { b = false; data = "{\"status\":0,\"msg\":\"暂时不能提现" + strtitle + "!\"}"; } if (b) { if (config.FHEnable == "0") { if (model.uLevel18 != 2) { b = false; data = "{\"status\":0,\"msg\":\"请先实名认证!\"}"; } } } if (b) { if (String.IsNullOrEmpty(context.Request["code"]) && String.IsNullOrEmpty(context.Request["pwd"])) { b = false; data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } } if (b) { if (paytype > 3 || paytype < 0) { b = false; data = "{\"status\":0,\"msg\":\"参数选择错误!\"}"; } } if (b) { if (config.JJBTXEnable == "1") { b = false; data = "{\"status\":0,\"msg\":\"暂时不能提现!\"}"; } else { DayOfWeek day = dt.DayOfWeek; string dayString = day.ToString().ToLower(); string HSJEnable = Mtxfw.Utility.Common.cweek(config.HSJEnable); if (config.HSJEnable.IndexOf(dayString) == -1) { b = false; data = "{\"status\":0,\"msg\":\"暂时不能提现!\"}"; } else { DateTime mintime = Convert.ToDateTime(Convert.ToDateTime(dt.ToShortDateString() + " " + config.UpdaeSJ1 + ":00").ToString("yyyy-MM-dd HH:mm:ss")); DateTime maxtime = Convert.ToDateTime(Convert.ToDateTime(dt.ToShortDateString() + " " + config.UpdaeSJ2 + ":59").ToString("yyyy-MM-dd HH:mm:ss")); if (dt < mintime || dt > maxtime) { b = false; data = "{\"status\":0,\"msg\":\"提现时间为:" + HSJEnable + config.UpdaeSJ1 + "至" + config.UpdaeSJ2 + "!\"}"; } } } } if (b) { if (model.uLevel8 == 1) { b = false; data = "{\"status\":0,\"msg\":\"您的账户已被封号不能提现!\"}"; } } if (paytype == 0) { if (b) { if (model.Phone2 == "" || model.RealName2 == "") { b = false; data = "{\"status\":0,\"msg\":\"您的银行资料未完善不能提现!\"}"; } } } else if (paytype == 1) { if (b) { if ((model.AliAccount == "" || model.AliName == "") || model.aliimage == "") { b = false; data = "{\"status\":0,\"msg\":\"您的支付宝未完善不能提现!\"}"; } } } else if (paytype == 2) { if (b) { if (model.weixinimage == "") { b = false; data = "{\"status\":0,\"msg\":\"您的微信支付未完善不能提现!\"}"; } } } else if (paytype == 3) { if (b) { if (model.qbaddress == "") { b = false; data = "{\"status\":0,\"msg\":\"您的钱包地址未完善不能提现!\"}"; } } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(je, @"^-?\d+$")) { b = false; data = "{\"status\":0,\"msg\":\"提现金额必须为整数!\"}"; } } Double ktCurrency = model.umoney32; Double ktCurrency0 = model.umoney36; if (t == 1) { ktCurrency = model.umoney34; } else if (t == 2) { ktCurrency = model.umoney41; } else if (t == 3) { ktCurrency = model.umoney39; } else if (t == 4) { ktCurrency = model.umoney37; } ktCurrency = Convert.ToDouble(Convert.ToDouble(ktCurrency.ToString("0.####")).ToString("f4")); ktCurrency0 = Convert.ToDouble(Convert.ToDouble(ktCurrency0.ToString("0.####")).ToString("f4")); int money = 0; if (b) { money = Convert.ToInt32(je); if (t == 1) { if (money < Convert.ToInt32(config.webMoney115) || money % Convert.ToInt32(config.webMoney116) != 0) { b = false; data = "{\"status\":0,\"msg\":\"提现范围为:" + config.webMoney115 + "个起且必须为" + config.webMoney116 + "的倍数!\"}"; } } else { if (money < Convert.ToInt32(config.webMoney52) || money > Convert.ToInt32(config.webMoney53) || money % Convert.ToInt32(config.webMoney54) != 0) { b = false; data = "{\"status\":0,\"msg\":\"提现范围为:" + config.webMoney52 + " 元 至 " + config.webMoney53 + "元 且必须为" + config.webMoney54 + "的倍数!\"}"; } } } if (b) { if (!String.IsNullOrEmpty(context.Request["pwd"])) { string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}"; } } } else { if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } } } } if (b) { if (Convert.ToDouble(money.ToString("f2")) > ktCurrency) { b = false; data = "{\"status\":0,\"msg\":\"您的" + strtitle + "可提现余额不足!\"}"; } } if (t == 4) { if (b) { if (Convert.ToDouble(money.ToString("f2")) > ktCurrency0) { b = false; data = "{\"status\":0,\"msg\":\"您的广告值不足!\"}"; } } } if (b) { string Country = ""; try { Mtxfw.Utility.IPScanner IPScanner = new Mtxfw.Utility.IPScanner(); IPScanner.IP = model.IP; IPScanner.DataPath = context.Server.MapPath("/App_Data/qqwry.dat"); IPScanner.IPLocation(); Country = IPScanner.Country; if (model.Id == 8714) { Country = "浙江省温州市"; } } catch (Exception err) { Mtxfw.Utility.Common.WriteHtml("/weixin/IPLocationerr.txt", err.ToString()); } Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); Double SS = 0.00; if (t == 2) { SS = Convert.ToDouble((money * Convert.ToDouble(config.webMoney118) / 100).ToString("f2")); } else if (t == 0) { if (config.HFHEnable == "0") { SS = Convert.ToDouble((money * Convert.ToDouble(config.webMoney50) / 100 + Convert.ToDouble(config.webMoney51)).ToString("f2")); } else if (config.HFHEnable == "1") { SS = Convert.ToDouble(Convert.ToDouble(config.webMoney50).ToString("f2")); } else { SS = Convert.ToDouble((money * Convert.ToDouble(config.webMoney51) / 100).ToString("f2")); } } string PayID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo) + model.Id; ModelResults.b0 = money - SS; ModelResults.b1 = SS; ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 0; ModelResults.b17 = 0; ModelResults.b18 = t; ModelResults.conent = "申请提现"; ModelResults.Totalmoney = money; ModelResults.MemberId = model.Id; ModelResults.UserId = paytype; ModelResults.ListNumber = PayID; ModelResults.Managers = Country; ModelResults.Seef = 0; ModelResults.utype = "1"; ModelResults.gtype = gtype; ModelResults.addtime = dt; Int64 ResultsId = daoResults.Add(ModelResults); string strsel = "umoney32"; int utype = 4; if (t == 1) { strsel = "umoney34"; utype = 14; model.umoney34 -= money; } else if (t == 2) { strsel = "umoney41"; utype = 17; model.umoney41 -= money; } else if (t == 3) { strsel = "umoney39"; utype = 15; model.umoney39 -= money; } else if (t == 4) { strsel = "umoney37"; utype = 19; model.umoney37 -= money; } else { model.umoney32 -= money; } daoUser.UpdateMoney(strsel, -money, model.Id); Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -money; mjl2.Cutmoney = 0; mjl2.Totalmoney = (ktCurrency - money); mjl2.addtime = DateTime.Now; mjl2.BZContent = "申请提现"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = utype; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); if (t == 2) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = SS; mjl2.Cutmoney = 0; mjl2.Totalmoney = (model.umoney39 + SS); mjl2.addtime = DateTime.Now; mjl2.BZContent = "申请提现扣税"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 15; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); model.umoney39 += SS; daoUser.UpdateMoney("umoney39", SS, model.Id); } else if (t == 4) { mjl2 = new Model.user_Results_jl2(); mjl2.MemberId = model.Id; mjl2.MemberId2 = 0; mjl2.Addmoney = -money; mjl2.Cutmoney = 0; mjl2.Totalmoney = (model.umoney36 - money); mjl2.addtime = DateTime.Now; mjl2.BZContent = "增值积分提现扣除"; mjl2.PayID = ""; mjl2.OrdersIDs = ""; mjl2.OrdersID = 0; mjl2.utype = 18; mjl2.utype2 = 0; mjl2.Seef = -1; mjl2.seeftime = DateTime.Now; mjl2.gtype = gtype; daojl2.Add(mjl2); model.umoney36 -= money; daoUser.UpdateMoney("umoney36", -money, model.Id); } bool ifauto = true, ifyz = false; string strerr = ""; if (ifauto) { if (config.webMoney59 != "") { string strconent = "您好!有会员提货,请及时处理!【银花优选】"; try { Mtxfw.Utility.Common.sendsms(config.webMoney59, "1510662", null, config); //Mtxfw.Utility.Common.sendsms(config.webMoney59, strconent); } catch { } } } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = dt; logmodel.IP = (model.Id == 8714 ? "223.104.162.201" : Mtxfw.Utility.Common.GetIP); logmodel.Body = strtitle + "提现到" + (paytype == 2 ? "微信" : (paytype == 1 ? "支付宝" : "银行账号")) + ",提现数量:" + money.ToString("f2") + (!ifauto ? (ifyz ? " 成功" : " 失败 " + strerr) : ""); logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); if (!String.IsNullOrEmpty(context.Request["code"])) { daoUser.UpdatePhoneTime3("", model.Id); } if (!ifauto) { if (ifyz) { data = "{\"status\":1,\"msg\":\"提交成功!\"," + returndata(model) + "}"; } } else { data = "{\"status\":1,\"msg\":\"提交成功!\"," + returndata(model) + "}"; } } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //获取转账记录----------------------------------------------------------------------------------------- /// /// 获取转账记录 /// protected string getzhuanzhanglist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["t"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; DataSet ds; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = new Mtxfw.DAL.user_Results().GetDataSet(groupby, strOrder, "id,b1,Totalmoney,conent,addtime,(Select UserName From user_info b Where b.Id=UserId) as UserName", "", "gtype=" + gtype + " and MemberId=" + model.Id + " and utype=11 And IFDelete=0 and b18=" + t, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string UserName = Dr["UserName"].ToString(); string b1 = Convert.ToDouble(Dr["b1"]).ToString("f2"); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string conent = Dr["conent"].ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"UserName\":\"" + UserName + "\",\"b1\":\"" + b1 + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"conent\":\"" + conent.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取提现记录----------------------------------------------------------------------------------------- /// /// 获取提现记录 /// protected string gettixianlist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int32 t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.user_Results().GetDataSet(groupby, strOrder, "id,Totalmoney,b0,b1,conent,addtime,seef", "", "gtype=" + gtype + " and MemberId=" + model.Id + " and utype=1 And IFDelete=0 and b18=" + t, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string b0 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b1 = Convert.ToDouble(Dr["b1"]).ToString("f2"); string conent = Dr["conent"].ToString(); string addtime = Dr["addtime"].ToString(); string seef = Dr["seef"].ToString(); strdata += "{\"id\":\"" + id + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"b0\":\"" + b0 + "\",\"b1\":\"" + b1 + "\",\"conent\":\"" + conent.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取兌換记录----------------------------------------------------------------------------------------- /// /// 获取兌換记录 /// protected string getzhuanhuanlist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; DataSet ds; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 50; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = new Mtxfw.DAL.user_Results().GetDataSet(groupby, strOrder, "id,b0,b2,Totalmoney,conent,addtime,seef", "", "gtype=" + gtype + " and MemberId=" + model.Id + " and utype=3 And IFDelete=0 And UserId=" + t, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string b0 = Convert.ToDouble(Dr["b0"]).ToString(); string b2 = Convert.ToDouble(Dr["b2"]).ToString(); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string conent = Dr["conent"].ToString(); string addtime = Dr["addtime"].ToString(); int seef = Convert.ToInt32(Dr["seef"]); strdata += "{\"id\":\"" + id + "\",\"seef\":\"" + seef + "\",\"b0\":\"" + b0 + "\",\"b2\":\"" + b2 + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"conent\":\"" + conent.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取购买VIP记录----------------------------------------------------------------------------------------- /// /// 获取购买VIP记录 /// protected string getgmviplist(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(context.Request["e"].ToString()); } } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int userId = 0; if (context.Request["userId"].ToString() != "[object CustomEvent]") { userId = Convert.ToInt32(context.Request["userId"].ToString()); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; DataSet ds; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = daoResults.GetDataSet(groupby, strOrder, "id,b0,b1,b2,b3,b4,b5,Seef,addtime", "", "(MemberId=" + model.Id + ") and utype=4 And IFDelete=0", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int seef = Convert.ToInt32(Dr["Seef"]); string b0 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b1 = Convert.ToDouble(Dr["b1"]).ToString("f2"); string b2 = Convert.ToDouble(Dr["b2"]).ToString("f2"); string b3 = Convert.ToDouble(Dr["b3"]).ToString("f2"); string b4 = Convert.ToDouble(Dr["b4"]).ToString("f2"); string b5 = Convert.ToDouble(Dr["b5"]).ToString("f2"); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"b0\":\"" + b0 + "\",\"b1\":\"" + b1 + "\",\"b2\":\"" + b2 + "\",\"b3\":\"" + b3 + "\",\"b4\":\"" + b4 + "\",\"b5\":\"" + b5 + "\",\"seef\":\"" + seef + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //获取购买团购卷记录----------------------------------------------------------------------------------------- /// /// 获取购买团购卷记录 /// protected string getgmcouponlist(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(context.Request["e"].ToString()); } } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int userId = 0; if (context.Request["userId"].ToString() != "[object CustomEvent]") { userId = Convert.ToInt32(context.Request["userId"].ToString()); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; DataSet ds; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = daoResults.GetDataSet(groupby, strOrder, "id,b0,b1,Seef,Managers,addtime", "", "(MemberId=" + model.Id + ") and utype=5 And IFDelete=0", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int seef = Convert.ToInt32(Dr["Seef"]); string b0 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b1 = Convert.ToDouble(Dr["b1"]).ToString(); string name = Dr["Managers"].ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"name\":\"" + name + "\",\"b0\":\"" + b0 + "\",\"b1\":\"" + b1 + "\",\"seef\":\"" + seef + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //获取我的红包 ----------------------------------------------------------------------------------------- /// /// 获取我的红包 /// protected string gethongbao(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"]); } int t0 = 0; if (!String.IsNullOrEmpty(context.Request["t0"])) { t0 = Convert.ToInt32(context.Request["t0"]); } Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } string Sql = "gtype=" + gtype + " and MemberId=" + umodel.Id + " and utype=8 And IFDelete=0"; if (t == 1) { Sql += " And UserId=1"; } else { Sql += " And UserId=0"; } if (t0 == 1) { Sql += " And seef=0"; } Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.user_Results().GetDataSet(groupby, strOrder, "id,Totalmoney,conent,addtime,seef,UserId", "", Sql, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string conent = Dr["conent"].ToString(); string addtime = Dr["addtime"].ToString(); int seef = Convert.ToInt32(Dr["seef"].ToString()); int UserId = Convert.ToInt32(Dr["UserId"].ToString()); if (seef == 0) { int yxqday = Convert.ToInt32(config.webMoney20); if (Convert.ToDateTime(addtime).AddHours(yxqday) < DateTime.Now) { seef = -1; } } strdata += "{\"id\":\"" + id + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"conent\":\"" + conent.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); int IFAuto = 0; if (umodel.uLevel4 == 1) { DateTime dt0 = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); DateTime dt1 = Convert.ToDateTime(umodel.RegTime1.ToString("yyyy-MM-dd HH:mm:ss")); if (dt0 < dt1) { IFAuto = 1; } } data = "{\"status\":1,\"IFAuto\":\"" + IFAuto + "\",\"datas\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //判断是否可直接领取红包----------------------------------------------------------------------------------------- /// /// 判断是否可直接领取红包 /// protected string IFZJLQHongBao(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int64 id = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["id"].ToString())); Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { int vipqx = umodel.uLevel4; if (umodel.uLevel4 == 1) { DateTime dt0 = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); DateTime dt1 = Convert.ToDateTime(umodel.RegTime1.ToString("yyyy-MM-dd HH:mm:ss")); if (dt0 > dt1) { vipqx = 2; } } bool b = true; int LQType = 0; if (vipqx == 1 && umodel.uLevel20 == 1) { LQType = 1; } Mtxfw.Model.user_Results rmodel = daoResults.GetModel(id); if (rmodel != null) { if (rmodel.IFDelete == 0) { if (rmodel.MemberId == umodel.Id) { int seef = rmodel.Seef; if (seef == 0) { int yxqday = Convert.ToInt32(config.webMoney20); if (Convert.ToDateTime(rmodel.addtime).AddHours(yxqday) < DateTime.Now) { seef = -1; } } if (seef == 0) { /*if (rmodel.UserId == 0) { if (DateTime.Now.Year == rmodel.addtime.Year && DateTime.Now.Month == rmodel.addtime.Month && DateTime.Now.Day <= rmodel.addtime.Day) { b = false; data = "{\"status\":0,\"msg\":\"此红包明天才能领取\"}"; } }*/ if (LQType == 1) { if (b) { Double umoney4 = Convert.ToDouble(rmodel.Totalmoney.ToString("f2")); Double umoney41 = Convert.ToDouble(umodel.umoney41.ToString("f2")); string selmoney = "umoney4", selmoney34 = "umoney34"; if (rmodel.UserId == 1) { selmoney = "umoney5"; selmoney34 = "umoney35"; } Double SXumoney = 0.00; if (rmodel.UserId == 0) { if (umoney41 <= 0.00) { b = false; data = "{\"status\":0,\"msg\":\"最多只能领取" + config.webMoney25 + "元\"}"; } Double Bzumoney = umoney4; if (Bzumoney > umoney41) { SXumoney = Convert.ToDouble((Bzumoney - umoney41).ToString("f2")); umoney4 = Convert.ToDouble(umoney41.ToString("f2")); } } if (b) { if (umoney4 > 0.00) { daoUser.UpdateMoney(selmoney34, umoney4, umodel.Id); daoUser.UpdateMoney(selmoney, umoney4, umodel.Id); if (rmodel.UserId == 0) { daoUser.UpdateMoney("umoney41", -umoney4, umodel.Id); } //Mtxfw.DAL.MemberStatistics.Statistics(DateTime.Now, umodel.Id, 0, 0, rmodel.UserId, 0, (rmodel.UserId == 0 ? 1 : 0), "来源"+ (rmodel.UserId == 1 ? "团购" : "新零售") + "红包奖励", gtype); } rmodel.seeftime = DateTime.Now; daoResults.UpdateSeef(1, rmodel.seeftime, rmodel.Id); } } } if (b) { data = "{\"status\":1,\"id\":\"" + id + "\",\"msg\":\"可以领取\"}"; } } else { b = false; if (seef == 1) { data = "{\"status\":0,\"msg\":\"红包已领取\"}"; } else { data = "{\"status\":0,\"msg\":\"红包已过期\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"权限不足\"}"; } } else { b = false; data = "{\"status\":0,\"msg\":\"红包已被删除\"}"; } } else { b = false; data = "{\"status\":0,\"msg\":\"参数有误\"}"; } if (b) { data = "{\"status\":1,\"LQType\":" + LQType + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //领取红包----------------------------------------------------------------------------------------- /// /// 领取红包 /// protected string LQHongBao(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int64 id = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["id"].ToString())); Model.user_Results_jl2 mjl2; Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Mtxfw.Model.user_Results rmodel = daoResults.GetModel(id); if (rmodel != null) { if (rmodel.IFDelete == 0) { if (rmodel.MemberId == umodel.Id) { int seef = rmodel.Seef; if (seef == 0) { /*if (rmodel.UserId == 0) { int yxqday = Convert.ToInt32(config.webMoney20); if (Convert.ToDateTime(Convert.ToDateTime(rmodel.addtime).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00").AddHours(yxqday) < DateTime.Now) { seef = -1; } } else {*/ int yxqday = Convert.ToInt32(config.webMoney20); if (Convert.ToDateTime(rmodel.addtime).AddHours(yxqday) < DateTime.Now) { seef = -1; } //} } if (seef == 0) { Double umoney4 = Convert.ToDouble(rmodel.Totalmoney.ToString("f2")); Double umoney41 = Convert.ToDouble(umodel.umoney41.ToString("f2")); string selmoney = "umoney4", selmoney34 = "umoney34"; if (rmodel.UserId == 1) { selmoney = "umoney5"; selmoney34 = "umoney35"; } Double SXumoney = 0.00; bool b = true; /*if (rmodel.UserId == 0) { if (DateTime.Now.Year == rmodel.addtime.Year && DateTime.Now.Month == rmodel.addtime.Month && DateTime.Now.Day <= rmodel.addtime.Day) { b = false; data = "{\"status\":0,\"msg\":\"此红包明天才能领取\"}"; } }*/ if (b) { if (rmodel.UserId == 0) { if (umoney41 <= 0.00) { b = false; data = "{\"status\":0,\"msg\":\"最多只能领取" + config.webMoney25 + "元\"}"; } Double Bzumoney = umoney4; if (Bzumoney > umoney41) { SXumoney = Convert.ToDouble((Bzumoney - umoney41).ToString("f2")); umoney4 = Convert.ToDouble(umoney41.ToString("f2")); } } } if (b) { if (umoney4 > 0.00) { daoUser.UpdateMoney(selmoney34, umoney4, umodel.Id); daoUser.UpdateMoney(selmoney, umoney4, umodel.Id); if (rmodel.UserId == 0) { daoUser.UpdateMoney("umoney41", -umoney4, umodel.Id); } //Mtxfw.DAL.MemberStatistics.Statistics(DateTime.Now, umodel.Id, 0, 0, rmodel.UserId, 0, (rmodel.UserId == 0 ? 1 : 0), "来源" + (rmodel.UserId == 1 ? "团购" : "新零售") + "红包奖励", gtype); } rmodel.seeftime = DateTime.Now; daoResults.UpdateSeef(1, rmodel.seeftime, rmodel.Id); data = "{\"status\":1,\"id\":\"" + id + "\",\"msg\":\"领取成功\"}"; } } else { if (seef == 1) { data = "{\"status\":0,\"msg\":\"红包已领取\"}"; } else { data = "{\"status\":0,\"msg\":\"红包已过期\"}"; } } } else { data = "{\"status\":0,\"msg\":\"权限不足\"}"; } } else { data = "{\"status\":0,\"msg\":\"红包已被删除\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数有误\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //查看红包详情----------------------------------------------------------------------------------------- /// /// 查看红包详情 /// protected string gethongbaodetails(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int64 id = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["id"].ToString())); Model.user_Results_jl2 mjl2; Mtxfw.Model.user_info umodel = daoUser.GetModel(userId); if (umodel != null) { if (umodel.LoginId2 == LoginId) { Mtxfw.Model.user_Results rmodel = daoResults.GetModel(id); if (rmodel != null) { if (rmodel.IFDelete == 0) { if (rmodel.MemberId == umodel.Id) { int seef = rmodel.Seef; if (seef == 0) { /*if (rmodel.UserId == 0) { int yxqday = Convert.ToInt32(config.webMoney20); if (Convert.ToDateTime(Convert.ToDateTime(rmodel.addtime).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00").AddHours(yxqday) < DateTime.Now) { seef = -1; } } else {*/ int yxqday = Convert.ToInt32(config.webMoney20); if (Convert.ToDateTime(rmodel.addtime).AddHours(yxqday) < DateTime.Now) { seef = -1; } //} } if (seef != 0) { string strdata = "\"datas\":["; DataSet ds = daoResults.GetList1("top 20 id,Totalmoney,addtime,seef,(Select Phone From user_info b Where b.Id=a.MemberId) as Phone", "gtype=" + gtype + " and utype=8 And IFDelete=0 and UserId="+ rmodel.UserId + " and seef=1 And DateDiff(day,addtime,getdate())<3 order by Totalmoney desc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id0 = Convert.ToInt32(Dr["id"]); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string Phone = Dr["Phone"].ToString(); string addtime = Dr["addtime"].ToString(); int seef0 = Convert.ToInt32(Dr["seef"].ToString()); strdata += "{\"id\":\"" + id0 + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"Phone\":\"" + Mtxfw.Utility.Common.cphone(Phone) + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef0 + "\"}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; data = "{\"status\":1,\"id\":\"" + id + "\",\"NCName\":\"" + (umodel.NCName == "" ? umodel.RealName : umodel.NCName) + "\",\"Totalmoney\":\"" + rmodel.Totalmoney.ToString("f2") + "\",\"conent\":\"" + rmodel.conent.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"seeftime\":\"" + rmodel.seeftime + "\",\"seef\":\"" + seef + "\","+ strdata + "}"; } else { data = "{\"status\":0,\"msg\":\"红包未领取\"}"; } } else { data = "{\"status\":0,\"msg\":\"权限不足\"}"; } } else { data = "{\"status\":0,\"msg\":\"红包已被删除\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数有误\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取我的兑换码 ----------------------------------------------------------------------------------------- /// /// 获取我的兑换码 /// protected string getmydhm(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"]); } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } string Sql = "gtype=" + gtype + " and MemberId=" + model.Id + ""; Int32 Recount = 0; DataSet ds = daodhm.GetDataSet(groupby, strOrder, "id,dhm,yxq,addtime,seef", "", Sql, Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string dhm = Dr["dhm"].ToString(); int yxq = Convert.ToInt32(Dr["yxq"]); string addtime = Dr["addtime"].ToString(); int seef = Convert.ToInt32(Dr["seef"].ToString()); strdata += "{\"id\":\"" + id + "\",\"dhm\":\"" + dhm + "\",\"yxq\":\"" + yxq + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"datas\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取充值记录----------------------------------------------------------------------------------------- /// /// 获取充值记录 /// protected string getchongzhilist(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { if (context.Request["e"].ToString() != "[object CustomEvent]") { e = Convert.ToInt32(context.Request["e"].ToString()); } } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = 0; if (context.Request["userId"].ToString() != "[object CustomEvent]") { userId = Convert.ToInt32(context.Request["userId"].ToString()); } string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { DataSet ds = daoResults.GetList1("Id", "utype=2 and seef=0 and Managers='5' And IFDelete=0 and DateDiff(day,addtime,getdate())>0"); if (ds.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { Int64 Id = Convert.ToInt64(Dr["Id"].ToString()); daoResults.UpdateIFDelete(1, DateTime.Now.ToString(), Id); } } ds.Clear(); string strdata = ""; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = daoResults.GetDataSet(groupby, strOrder, "id,Totalmoney,conent,UserId,Managers,addtime,seef", "", "MemberId=" + model.Id + " and utype=2 And IFDelete=0 And (Managers<>'5' Or (Managers='5' And Seef=1))", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int UserId = Convert.ToInt32(Dr["UserId"]); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string conent = Dr["conent"].ToString(); string addtime = Dr["addtime"].ToString(); string seef = Dr["seef"].ToString(); string Managers = Dr["Managers"].ToString(); string paytype = Mtxfw.Utility.Common.GetChongZhiType(UserId) + (Managers == "" ? "" : ":银行卡后4位" + Managers); strdata += "{\"id\":\"" + id + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"paytype\":\"" + paytype + "\",\"conent\":\"" + conent.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); string strdata2 = ""; if (Start == 0) { string strsql2 = "parentid=30"; strsql2 += " And receiverid=" + userId; strsql2 += " And wtype=2 and DateDiff(day,addtime,getdate())<=30"; string Ids2 = ""; if (!String.IsNullOrEmpty(context.Request["Ids2"])) { Ids2 = HttpUtility.UrlDecode(context.Request["Ids2"].ToString()); strsql2 += " And charindex(','+Convert(varchar(50),id)+',','" + Ids2 + "')=0"; } DataSet dss = daoArt.GetList1("id", strsql2 + " Order by AddTime desc"); if (dss.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Drr in dss.Tables[0].Rows) { int id = Convert.ToInt32(Drr["id"]); strdata2 += "{\"id\":\"" + id + "\"}"; if (i != dss.Tables[0].Rows.Count - 1) { strdata2 += ","; } i += 1; } } dss.Clear(); } data = "{\"status\":1,\"data\":[" + strdata + "],\"data2\":[" + strdata2 + "]}"; } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //获取股权购买记录----------------------------------------------------------------------------------------- /// /// 获取股权购买记录 /// protected string getguquanzhlist(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = new DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; DataSet ds; string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; ds = new DAL.user_Results().GetDataSet(groupby, strOrder, "id,b0,b1,Totalmoney,conent,addtime", "", "MemberId=" + model.Id + " and utype=7 And IFDelete=0", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string b0 = Convert.ToDouble(Dr["b0"]).ToString("f2"); string b1 = Convert.ToDouble(Dr["b1"]).ToString("f2"); string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2"); string conent = Dr["conent"].ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"id\":\"" + id + "\",\"b0\":\"" + b0 + "\",\"b1\":\"" + b1 + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"conent\":\"" + conent.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //获取复投界面----------------------------------------------------------------------------------------- /// /// 获取复投界面 /// protected string getmy_Recast(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata2 = ""; string strsql2 = "parentid=30"; strsql2 += " And receiverid=" + userId; strsql2 += " And wtype=5 and DateDiff(day,addtime,getdate())<=30"; string Ids2 = ""; if (!String.IsNullOrEmpty(context.Request["Ids2"])) { Ids2 = HttpUtility.UrlDecode(context.Request["Ids2"].ToString()); strsql2 += " And charindex(','+Convert(varchar(50),id)+',','" + Ids2 + "')=0"; } DataSet dss = daoArt.GetList1("id", strsql2 + " Order by AddTime desc"); if (dss.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Drr in dss.Tables[0].Rows) { int id = Convert.ToInt32(Drr["id"]); strdata2 += "{\"id\":\"" + id + "\"}"; if (i != dss.Tables[0].Rows.Count - 1) { strdata2 += ","; } i += 1; } } dss.Clear(); data = "{\"status\":1,\"data2\":[" + strdata2 + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取我的好友----------------------------------------------------------------------------------------- /// /// 获取我的好友 /// protected string getmyfriendlist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); } int Start = 0; if (t == 0) { string groupby = ""; string strOrder = "addtime desc"; string strsql = " and SJID=" + model.Id + ""; int Limit = 50; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = new Mtxfw.DAL.User_openids().GetDataSet(groupby, strOrder, "id,ttype,(Select b.realname From user_info b Where b.Id=MemberId) as RealName,(Select b.UserPic From user_info b Where b.Id=MemberId) as UserPic,(Select b.uLevel From user_info b Where b.Id=MemberId) as uLevel,(Select b.uLevel15 From user_info b Where b.Id=MemberId) as uLevel15,addtime", "", "gtype=" + gtype + "" + strsql, Start, Limit, out Recount);// And uLevel5=" + t int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); string RealName = Dr["RealName"].ToString(); string UserPic = Dr["UserPic"].ToString(); string regtime = Convert.ToDateTime(Dr["addtime"]).ToString("yyyy-MM-dd HH:mm:ss"); string struLevel = ""; if (Dr["uLevel"].ToString() != "") { struLevel = Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(Dr["uLevel"].ToString())); } int uLevel15 = 0; if (Dr["uLevel"].ToString() != "") { uLevel15 = Convert.ToInt32(Dr["uLevel15"]); } strdata += "{\"id\":\"" + id + "\",\"RealName\":\"" + RealName + "\",\"uLevel\":\"" + struLevel + "\",\"zt\":\"" + (uLevel15 == 1 ? "已团购" : "未团购") + "\",\"UserPic\":\"" + (UserPic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(UserPic, "40x40", "cut") : "") + "\",\"regtime\":\"" + regtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } } else { string groupby = ""; string strOrder = "addtime desc"; string strsql = "gtype=" + gtype + " and SJId=" + model.Id + ""; string strfill = "id,MemberId"; if (t == 1) { strOrder = "regtime desc"; strsql = "gtype=" + gtype + " and IFStores=0 And UserState='正常' and uLevel17=0 And ContactID=" + model.Id + ""; strfill = "id,UserName,RealName,NCName,Phone,UserPic,ContactIDS,regtime,tjcount,temcount,uLevel,uLevel48,umoney18,umoney19"; } int Limit = 50; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds; if (t == 1) { ds = new Mtxfw.DAL.user_info().GetDataSet(groupby, strOrder, strfill, "", "" + strsql, Start, Limit, out Recount); } else { ds = new Mtxfw.DAL.User_openids().GetDataSet(groupby, strOrder, strfill, "", "" + strsql, Start, Limit, out Recount); } int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int MemberId = id; string UserName = "",RealName="",NCName="",Phone="",UserPic="",ContactIDS="",regtime="",zyj0="",struLevel=""; int tjcount0 = 0; int temcount0 = 0; Double zcount0 = 0.00; Double maxzcount0 = 0.00; Double minzcount0 = 0.00; int IFqiandao = 0; int uLevel48 = 0; if (t == 1) { UserName = Dr["UserName"].ToString(); RealName = Dr["RealName"].ToString(); NCName = Dr["NCName"].ToString(); if (NCName != "") { RealName = NCName; } Phone = Dr["Phone"].ToString(); UserPic = Dr["UserPic"].ToString(); ContactIDS = Dr["ContactIDS"].ToString(); regtime = Convert.ToDateTime(Dr["regtime"]).ToString("yyyy-MM-dd HH:mm:ss"); zyj0 = Convert.ToDouble(Dr["umoney18"]).ToString(); struLevel = Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(Dr["uLevel"])); uLevel48 = Convert.ToInt32(Dr["uLevel48"]); } else { MemberId = Convert.ToInt32(Dr["MemberId"]); Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(MemberId); if (umodel != null) { UserName = umodel.UserName; RealName = umodel.RealName; NCName = umodel.NCName; if (NCName != "") { RealName = NCName; } Phone = umodel.Phone; UserPic = umodel.UserPic; ContactIDS = umodel.ContactIDS; regtime = umodel.RegTime.ToString("yyyy-MM-dd HH:mm:ss"); zyj0 = umodel.umoney18.ToString(); struLevel = Mtxfw.Utility.Common.GetuLevelname(umodel.uLevel); uLevel48 = umodel.uLevel48; } } tjcount0 = daoUser.GetCount("gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel14=1 and ContactID=" + MemberId + ""); temcount0 = daoUser.GetCount("gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel14=1 and ContactIDS like '" + ContactIDS + id + "%'"); DataSet qdds = daoqiandao.getqiandao(gtype, MemberId); if (qdds.Tables[0].Rows.Count > 0) { IFqiandao = Convert.ToInt32(qdds.Tables[0].Rows[0]["IFqiandao"].ToString()); } qdds.Clear(); DataSet dss0 = daoUser.GetList1("id,umoney19", "gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel17=0 and ContactID=" + MemberId + ""); if (dss0.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Drr0 in dss0.Tables[0].Rows) { int aid = Convert.ToInt32(Drr0["id"]); Double umoney19 = Convert.ToDouble(Convert.ToDouble(Drr0["umoney19"].ToString()).ToString("f2")); zcount0 += umoney19; if (maxzcount0 == 0.00) { maxzcount0 = umoney19; } else { if (maxzcount0 < umoney19) { maxzcount0 = umoney19; } } } } dss0.Clear(); minzcount0 = (zcount0 - maxzcount0); strdata += "{\"id\":\"" + id + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"uLevel\":\"" + struLevel + "\",\"zt\":\"" + (uLevel48 > 0 ? "已消费" : "未消费") + "\",\"zt0\":\"" + (IFqiandao > 0 ? "已签到" : "未签到") + "\",\"Phone\":\"" + Phone + "\",\"UserPic\":\"" + (UserPic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(UserPic, "40x40", "cut") : "") + "\",\"regtime\":\"" + regtime + "\",\"zcount\":\"" + zcount0.ToString() + "\",\"maxzcount\":\"" + maxzcount0.ToString() + "\",\"minzcount\":\"" + minzcount0.ToString() + "\",\"tjcount\":\"" + tjcount0 + "\",\"temcount\":\"" + temcount0 + "\",\"zyj\":\"" + zyj0 + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } } Double zcount = 0.00; Double maxzcount = 0.00; Double minzcount = 0.00; int tjcount = 0, temcount = 0; int atemcount = 0; //if (Start == 0) //{ if (t == 1) { DataSet dss = daoUser.GetList1("id,umoney19", "gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel17=0 and ContactID=" + model.Id + ""); if (dss.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow Drr in dss.Tables[0].Rows) { int aid = Convert.ToInt32(Drr["id"]); Double umoney19 = Convert.ToDouble(Convert.ToDouble(Drr["umoney19"].ToString()).ToString("f2")); zcount += umoney19; if (maxzcount == 0.00) { maxzcount = umoney19; } else { if (maxzcount < umoney19) { maxzcount = umoney19; } } } } dss.Clear(); minzcount = (zcount - maxzcount); tjcount = daoUser.GetCount("gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel14=1 and ContactID=" + model.Id + ""); temcount = daoUser.GetCount("gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel14=1 and ContactIDS like '" + model.ContactIDS + model.Id + "%'"); } else { string mindt = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"; string maxdt = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00"; tjcount = new Mtxfw.DAL.User_openids().GetCount("gtype=" + gtype + " and SJId=" + model.Id + " and addtime>='" + mindt + "' and addtime<'" + maxdt + "'"); mindt = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00:00"; maxdt = DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00"; temcount = new Mtxfw.DAL.User_openids().GetCount("gtype=" + gtype + " and SJId=" + model.Id + " and addtime>='" + mindt + "' and addtime<'" + maxdt + "'"); atemcount = new Mtxfw.DAL.User_openids().GetCount("gtype=" + gtype + " and SJId=" + model.Id + ""); } //} string zyj = model.umoney18.ToString(); data = "{\"status\":1,\"data\":[" + strdata + "],\"zcount\":\"" + zcount.ToString() + "\",\"maxzcount\":\"" + maxzcount.ToString() + "\",\"minzcount\":\"" + minzcount.ToString() + "\",\"tjcount\":\"" + tjcount + "\",\"temcount\":\"" + temcount + "\",\"atemcount\":\"" + atemcount + "\",\"zyj\":\"" + zyj + "\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取信息列表----------------------------------------------------------------------------------------- /// /// 获取信息列表 /// protected string getmessagelist(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["t"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string strsql = " receiverid=" + userId + ""; if (t == 1) { strsql = " senderid=" + userId + ""; } string groupby = ""; string strOrder = "addtime desc"; int Start = 0; int Limit = 10; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daoArt.GetDataSet(groupby, strOrder, "id,hasRead,title,content,addtime", "", "parentid=20 and " + strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { int id = Convert.ToInt32(Dr["id"]); int hasRead = Convert.ToInt32(Dr["hasRead"]); string title = Dr["title"].ToString(); string content = Dr["content"].ToString(); string addtime = Dr["addtime"].ToString(); strdata += "{\"hasRead\":\"" + (hasRead == 1 ? "false" : "true") + "\",\"id\":\"" + id + "\",\"title\":\"" + title + "\",\"content\":\"" + content.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"createTime\":\"" + addtime + "\"}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //设置已读----------------------------------------------------------------------------------------- /// /// 设置已读 /// protected string setToRead(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["messageId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int messageId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["messageId"].ToString())); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { daoArt.UpdateuSel("hasRead", 1, 20, userId, messageId); data = "{\"status\":1,\"data\":\"设置成功\"}"; } } } return data; } #endregion #region //发送信息----------------------------------------------------------------------------------------- /// /// 发送信息 /// protected string sendmessage(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["title"]) && context.Request["desc"] != null) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string UserName = ""; if (!String.IsNullOrEmpty(context.Request["UserName"])) { UserName = HttpUtility.UrlDecode(context.Request["UserName"].ToString()); } string title = HttpUtility.UrlDecode(context.Request["title"].ToString()); string desc = HttpUtility.UrlDecode(context.Request["desc"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; int UserId = 0; string ContactIDS = ""; if (UserName != "") { SqlDataReader Dr = daoUser.GetUserId(gtype, UserName); if (Dr.HasRows) { if (Dr.Read()) { UserId = int.Parse(Dr["Id"].ToString()); ContactIDS = Dr["ContactIDS"].ToString(); } } Dr.Close(); if (UserId == 0) { if (b) { b = false; data = "{\"status\":0,\"msg\":\"接收账户不存在!\"}"; } } if (b) { if (UserId == model.Id) { b = false; data = "{\"status\":0,\"msg\":\"接收账户不能是自己!\"}"; } } } if (b) { Mtxfw.Model.Article Amodel = new Mtxfw.Model.Article(); Amodel.senderid = model.Id; Amodel.receiverid = UserId; Amodel.Title = title; Amodel.ParentID = 20; Amodel.CategoryId = "0"; Amodel.AddTime = DateTime.Now; Amodel.Author = ""; Amodel.Content = desc; Amodel.Paths = ""; Amodel.Content2 = ""; Amodel.Paths2 = ""; Amodel.KeyWords = ""; Amodel.media_id = ""; Amodel.thumb_media_id = ""; Amodel.wtype = 0; Amodel.wtype2 = 0; Amodel.LinkID = 0; Amodel.Seef = 0; Amodel.gtype = gtype; new DAL.Article().Add(Amodel); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "发送信息给" + UserName + ",信息标题:" + title + ",信息内容:" + desc; logmodel.UType = 1; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"保存成功!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数不能为空!\"}"; } return data; } #endregion #region //获取订单列表----------------------------------------------------------------------------------------- /// /// 获取订单列表 /// protected string getorderslist(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["t0"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); } int t0 = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t0"].ToString())); Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string strsql = " and UserID=" + model.Id + ""; string strfill = ""; if (t > 0) { if (t == 3)//自提订单 { strsql = " and ZTMemberId=" + model.Id + " And O_Payed<>0"; strfill = ",(select UserName from user_info c where c.ID=UserID) as UserName"; } else if (t == 2)//快递订单 { strsql = " And UserId in(Select b.id from user_info b where b.IFStores=0 And (b.id=" + model.Id + " or b.ContactIDS like '%," + model.Id + ",%')) And O_Payed<>0"; strfill = ",(select UserName from user_info c where c.ID=UserID) as UserName"; } else if (t == 1)//发货订单 { strsql = " and MemberId=" + model.Id + " and peitype=0 And O_Payed<>0"; strfill = ",(select UserName from user_info c where c.ID=UserID) as UserName"; } } if (t0 != 10) { strsql += " And O_Payed=" + t0; } string groupby = ""; string strOrder = "O_SubmitDate desc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = new DAL.order_info().GetDataSet(groupby, strOrder, "ttype,ptype,peitype,id,pid,poid,orderid,Totalnum,pcount,ypcount,ypznum,ifxhpt,ifpd,ifbhzshy,Totalprice,O_Payed,O_Payed_Date,O_Shipped,O_Shipped_Date,O_received,O_received_Date,O_SubmitDate,Contactname,Contacttel,Province,City,County,Address,kdcompay,yundanhao,Guests,wlremarks, refundstatus, refund_channel, user_received_account, success_time,O_Seef, O_ReturnReason" + strfill, "", "ttype IN(0,1) and IFDelete=0" + strsql + "", Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { string utype = Dr["ttype"].ToString(); int ptype = Convert.ToInt32(Dr["ptype"].ToString()); string O_Id = Dr["id"].ToString(); int O_pid = Convert.ToInt32(Dr["pid"].ToString()); int poid = Convert.ToInt32(Dr["poid"].ToString()); int peitype = Convert.ToInt32(Dr["peitype"].ToString()); string orderid = Dr["orderid"].ToString(); int Totalnum = Convert.ToInt32(Dr["Totalnum"].ToString()); Double Totalprice = Convert.ToDouble(Convert.ToDouble(Dr["Totalprice"]).ToString("f2")); string O_Payed = Dr["O_Payed"].ToString(); string O_Payed_Date = Dr["O_Payed_Date"].ToString(); string O_Shipped = Dr["O_Shipped"].ToString(); string O_Shipped_Date = Dr["O_Shipped_Date"].ToString(); string O_received = Dr["O_received"].ToString(); string O_received_Date = Dr["O_received_Date"].ToString(); string O_SubmitDate = Dr["O_SubmitDate"].ToString(); string Contactname = Dr["Contactname"].ToString(); string Contacttel = Dr["Contacttel"].ToString(); string Province = Dr["Province"].ToString(); string City = Dr["City"].ToString(); string County = Dr["County"].ToString(); string kdcompay = Dr["kdcompay"].ToString(); string Address = Dr["Address"].ToString(); string yundanhao = Dr["yundanhao"].ToString(); string Guests = Dr["Guests"].ToString(); int refundstatus = Convert.ToInt32(Dr["refundstatus"].ToString()); string refund_channel = Dr["refund_channel"].ToString(); string user_received_account = Dr["user_received_account"].ToString(); string success_time = Dr["success_time"].ToString(); string wlremarks = Mtxfw.Utility.Common.ReplaceString(Dr["wlremarks"].ToString()); int O_Seef = Convert.ToInt32(Dr["O_Seef"].ToString()); string O_ReturnReason = Dr["O_ReturnReason"].ToString(); string[] strStatus = Mtxfw.Utility.Common.GetOrderStatus(utype, O_Id, orderid, ptype, peitype, O_SubmitDate, O_Payed, O_Payed_Date, O_Shipped, O_Shipped_Date, O_received, O_received_Date, kdcompay, yundanhao, Contacttel, wlremarks, refundstatus, refund_channel, user_received_account, success_time, O_Seef, Totalprice, O_ReturnReason, 0); strdata += "{\"O_Id\":\"" + O_Id + "\",\"Payed\":\"" + O_Payed + "\",\"orderid\":\"" + orderid + "\",\"Totalnum\":\"" + Totalnum + "\",\"Totalprice\":\"" + Totalprice + "\",\"SubmitDate\":\"" + O_SubmitDate + "\",\"Contactname\":\"" + Contactname + "\",\"Contacttel\":\"" + Contacttel + "\",\"Province\":\"" + Province + "\",\"City\":\"" + City + "\",\"County\":\"" + County + "\",\"Address\":\"" + Address + "\",\"kdgs\":\"" + kdcompay + "\",\"kdgsmc\":\"" + Mtxfw.Utility.Common.Getkdcompay(kdcompay) + "\",\"ydh\":\"" + yundanhao + "\",\"status0\":\"" + strStatus[0] + "\",\"status1\":\"" + strStatus[1] + "\",\"Guests\":\"" + Mtxfw.Utility.Common.ReplaceString(Guests) + "\",\"pics\":["; System.Data.DataSet Ds_op = new DAL.order_product_info().GetList("(Select utype from P_Product b where b.P_ID=a.pid) as cutype,(Select P_NAME from P_Product b where b.P_ID=a.pid) as prodName,(Select P_bianhao from P_Product b where b.P_ID=a.pid) as bianhao,(Select P_images from P_Product b where b.P_ID=a.pid) as prodimg,(Select selcolor from P_Product b where b.P_ID=a.pid) as cselcolor,", "orderid=" + O_Id + " And UserID=" + model.Id + " And IFDelete=0 Order By SubmitTime asc"); if (Ds_op.Tables[0].Rows.Count > 0) { for (int l = 0; l < Ds_op.Tables[0].Rows.Count; l++) { string prodimg2 = Ds_op.Tables[0].Rows[l]["prodimg"].ToString(); string[] aprodimg = prodimg2.Split('|'); string prodid2 = Ds_op.Tables[0].Rows[l]["pid"].ToString(); string prodName2 = Ds_op.Tables[0].Rows[l]["prodName"].ToString(); string bianhao = Ds_op.Tables[0].Rows[l]["bianhao"].ToString(); string selcolor2 = Ds_op.Tables[0].Rows[l]["cselcolor"].ToString(); string Totalnum2 = Ds_op.Tables[0].Rows[l]["Totalnum"].ToString(); string DJprice = Convert.ToDouble(Ds_op.Tables[0].Rows[l]["DJprice"]).ToString("f2"); string Totalprice2 = Convert.ToDouble(Ds_op.Tables[0].Rows[l]["Totalprice"]).ToString("f2"); string pid2 = Ds_op.Tables[0].Rows[l]["id"].ToString(); string cutype = Ds_op.Tables[0].Rows[l]["cutype"].ToString(); string strimg = ""; if (selcolor2 != "") { foreach (string img in aprodimg) { if (img.IndexOf(selcolor2) != -1) { strimg = img.Split(',')[0]; } } if (strimg == "") { strimg = prodimg2.Split('|')[0].Split(',')[0]; } } else { strimg = prodimg2.Split('|')[0].Split(',')[0]; } string guige2 = Ds_op.Tables[0].Rows[l]["guige"].ToString(); if (guige2 != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige2)); if (gmodel != null) { prodName2 += " " + gmodel.G_Name; } } prodName2 += " " + selcolor2; strdata += "{\"cutype\":\"" + cutype + "\",\"prodid\":\"" + prodid2 + "\",\"bianhao\":\"" + bianhao + "\",\"prodName\":\"" + Mtxfw.Utility.Common.ReplaceString(prodName2) + "\",\"prodimg\":\"" + (strimg.IndexOf("http") != -1 ? strimg : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strimg, "100x100", "cut")) + "\",\"num\":\"" + Totalnum2 + "\",\"DJprice\":\"" + DJprice + "\",\"price\":\"" + Totalprice2 + "\"}"; if (l != Ds_op.Tables[0].Rows.Count - 1) { strdata += ","; } } } Ds_op.Clear(); strdata += "]}"; if (i != ds.Tables[1].Rows.Count - 1) { strdata += ","; } i += 1; } } else { strdata = ""; } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取订单详情----------------------------------------------------------------------------------------- /// /// 获取订单详情 /// protected string getordersinfo(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["orderId"]) || !String.IsNullOrEmpty(context.Request["id"])) { int orderId = 0; if (!String.IsNullOrEmpty(context.Request["orderId"])) { orderId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["orderId"].ToString())); } int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["t"].ToString())); } string strid = ""; if (!String.IsNullOrEmpty(context.Request["id"])) { strid = HttpUtility.UrlDecode(context.Request["id"].ToString()); } string strdata = ""; string strsql = ""; strsql = (strid != "" ? "out_trade_no='" + strid + "'" : " And Id=" + orderId); string utype = ""; DataSet ds = new DAL.order_info().GetList1("ttype,ptype,peitype,id,pid,poid,orderid,Totalnum,pcount,ypcount,ypznum,ifxhpt,ifpd,ifbhzshy,Totalprice,O_Payed,O_Payed_Date,O_Shipped,O_Shipped_Date,O_received,O_received_Date,O_SubmitDate,Contactname,Contacttel,Address,Address0,Zipcode,kdcompay,yundanhao,guests,wlremarks,Province,City,County, refundstatus, refund_channel, user_received_account, success_time,O_Seef, O_ReturnReason", "IFDelete=0" + strsql + " Order By addtime Desc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { utype = Dr["ttype"].ToString(); int ptype = Convert.ToInt32(Dr["ptype"].ToString()); string O_Id = Dr["id"].ToString(); string orderid = Dr["orderid"].ToString(); int O_pid = Convert.ToInt32(Dr["pid"].ToString()); int poid = Convert.ToInt32(Dr["poid"].ToString()); int peitype = Convert.ToInt32(Dr["peitype"].ToString()); string Zipcode = Dr["Zipcode"].ToString(); int Totalnum = Convert.ToInt32(Dr["Totalnum"].ToString()); Double Totalprice = Convert.ToDouble(Convert.ToDouble(Dr["Totalprice"]).ToString("f2")); string O_SubmitDate = Dr["O_SubmitDate"].ToString(); string O_Payed = Dr["O_Payed"].ToString(); string O_Payed_Date = Dr["O_Payed_Date"].ToString(); string O_Shipped = Dr["O_Shipped"].ToString(); string O_Shipped_Date = Dr["O_Shipped_Date"].ToString(); string O_received = Dr["O_received"].ToString(); string O_received_Date = Dr["O_received_Date"].ToString(); string kdcompay = Dr["kdcompay"].ToString(); string yundanhao = Dr["yundanhao"].ToString(); string Contacttel = Dr["Contacttel"].ToString(); string guests = Dr["guests"].ToString(); string Address0 = Dr["Address0"].ToString(); string wlremarks = Mtxfw.Utility.Common.ReplaceString(Dr["wlremarks"].ToString()); int refundstatus = Convert.ToInt32(Dr["refundstatus"].ToString()); string refund_channel = Dr["refund_channel"].ToString(); string user_received_account = Dr["user_received_account"].ToString(); string success_time = Dr["success_time"].ToString(); int O_Seef = Convert.ToInt32(Dr["O_Seef"].ToString()); string O_ReturnReason = Dr["O_ReturnReason"].ToString(); string address = CommonFunctions.GetOrderAddress(Utils.StrToInt(O_Id,0),false); //(Dr["peitype"].ToString() == "0" ? "快递配送 " + Dr["Contactname"].ToString() + " " + Dr["Contacttel"].ToString() + " " + (Dr["Address0"].ToString() != "" ? Dr["Address0"].ToString() : new DAL.province().GetProvince(Dr["Province"].ToString()) + new DAL.city().GetCity(Dr["City"].ToString()) + new DAL.county().GetCounty(Dr["County"].ToString())) + Dr["Address"].ToString() : "上门自取 取货人:" + Dr["Contactname"].ToString() + " 手机号:" + Dr["Contacttel"].ToString() + " 取货地址:" + Dr["Address"].ToString()); string[] strStatus = Mtxfw.Utility.Common.GetOrderStatus(utype, O_Id, orderid, ptype, peitype, O_SubmitDate, O_Payed, O_Payed_Date, O_Shipped, O_Shipped_Date, O_received, O_received_Date, kdcompay, yundanhao, Contacttel, wlremarks, refundstatus, refund_channel, user_received_account, success_time, O_Seef, Totalprice, O_ReturnReason, 0); int minzsbfb = 0, maxzsbfb = 0, minthbfb = 0, maxthbfb = 0; string yjaddress = ""; if (utype == "1") { string[] astr = config.webMoney63.Split('|'); string[] astr1 = astr[0].Split(','); string sarea = ""; string sprovince = ""; if (astr1.Length > 2) { sprovince = astr1[2]; sarea = new DAL.province().GetProvince(sprovince); } string scity = ""; if (astr1.Length > 3) { scity = astr1[3]; sarea += new DAL.city().GetCity(scity); } string scounty = ""; if (astr1.Length > 4) { scounty = astr1[4]; sarea += new DAL.county().GetCounty(scounty); } string saddress = ""; if (astr1.Length > 5) { saddress = astr1[5]; } yjaddress = sarea + saddress + " " + astr1[0] + " " + astr1[1] + ""; if (O_received == "1") { yjaddress = ""; //address = Address0; } } if ((O_Payed == "2" || O_Payed == "3") && O_received == "0") { O_received = "1"; } strdata += "{\"utype\":\"" + utype + "\",\"ptype\":\"" + ptype + "\",\"O_Id\":\"" + O_Id + "\",\"Payed\":\"" + O_Payed + "\",\"received\":\"" + O_received + "\",\"orderid\":\"" + orderid + "\",\"phone\":\"" + Contacttel + "\",\"Totalnum\":\"" + Totalnum + "\",\"Totalprice\":\"" + Totalprice + "\",\"SubmitDate\":\"" + O_SubmitDate + "\",\"address\":\"" + address + "\",\"kdgs\":\"" + kdcompay + "\",\"kdgsmc\":\"" + Mtxfw.Utility.Common.Getkdcompay(kdcompay) + "\",\"ydh\":\"" + yundanhao + "\",\"status0\":\"" + strStatus[0] + "\",\"status1\":\"\",\"Guests\":\"" + Mtxfw.Utility.Common.ReplaceString(guests) + "\",\"yjaddress\":\"" + Mtxfw.Utility.Common.ReplaceString(yjaddress) + "\",\"pics\":["; System.Data.DataSet Ds_op = new DAL.order_product_info().GetList("(Select P_NAME from P_Product b where b.P_ID=a.pid) as prodName,(Select P_bianhao from P_Product b where b.P_ID=a.pid) as bianhao,(Select P_images from P_Product b where b.P_ID=a.pid) as prodimg,(Select selcolor from P_Product b where b.P_ID=a.pid) as cselcolor,", "orderid=" + O_Id + " And IFDelete=0 Order By SubmitTime asc"); if (Ds_op.Tables[0].Rows.Count > 0) { for (int l = 0; l < Ds_op.Tables[0].Rows.Count; l++) { string prodimg2 = Ds_op.Tables[0].Rows[l]["prodimg"].ToString(); string[] aprodimg = prodimg2.Split('|'); string prodid2 = Ds_op.Tables[0].Rows[l]["pid"].ToString(); string prodName2 = Ds_op.Tables[0].Rows[l]["prodName"].ToString(); string bianhao = Ds_op.Tables[0].Rows[l]["bianhao"].ToString(); string selcolor2 = Ds_op.Tables[0].Rows[l]["cselcolor"].ToString(); string Totalnum2 = Ds_op.Tables[0].Rows[l]["Totalnum"].ToString(); string DJprice = Convert.ToDouble(Ds_op.Tables[0].Rows[l]["DJprice"]).ToString("f2"); string Totalprice2 = Convert.ToDouble(Ds_op.Tables[0].Rows[l]["Totalprice"]).ToString("f2"); string pid2 = Ds_op.Tables[0].Rows[l]["id"].ToString(); string strimg = ""; if (selcolor2 != "") { foreach (string img in aprodimg) { if (img.IndexOf(selcolor2) != -1) { strimg = img.Split(',')[0]; } } if (strimg == "") { strimg = prodimg2.Split('|')[0].Split(',')[0]; } } else { strimg = prodimg2.Split('|')[0].Split(',')[0]; } string guige2 = Ds_op.Tables[0].Rows[l]["guige"].ToString(); if (guige2 != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige2)); if (gmodel != null) { prodName2 += " " + gmodel.G_Name; DJprice = gmodel.G_JG.ToString(); Totalprice2 = (gmodel.G_JG * Convert.ToDouble(Totalnum2)).ToString(); } } prodName2 += " " + selcolor2; strdata += "{\"cutype\":\"" + utype + "\",\"prodid\":\"" + prodid2 + "\",\"selcolor\":\"\",\"bianhao\":\"" + bianhao + "\",\"prodName\":\"" + Mtxfw.Utility.Common.ReplaceString(prodName2) + "\",\"prodimg\":\"" + (strimg.IndexOf("http") != -1 ? strimg : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strimg, "40x40", "cut")) + "\",\"num\":\"" + Totalnum2 + "\",\"price\":\"" + DJprice + "\"}"; if (l != Ds_op.Tables[0].Rows.Count - 1) { strdata += ","; } } } Ds_op.Clear(); strdata += "]}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } string strdata0 = ",\"addresss\":["; if (utype == "1") { if (config.webMoney63 != "") { string[] astr = config.webMoney63.Split('|'); int i = 0; foreach (string str in astr) { if (str != "") { string[] astr1 = str.Split(','); string sarea = ""; string sprovince = ""; if (astr1.Length > 2) { sprovince = astr1[2]; sarea = new DAL.province().GetProvince(sprovince); } string scity = ""; if (astr1.Length > 3) { scity = astr1[3]; sarea += new DAL.city().GetCity(scity); } string scounty = ""; if (astr1.Length > 4) { scounty = astr1[4]; sarea += new DAL.county().GetCounty(scounty); } string saddress = ""; if (astr1.Length > 5) { saddress = astr1[5]; } strdata0 += "{\"addressId\":\"" + i + "\",\"contact\":\"" + astr1[0] + "\",\"tel\":\"" + astr1[1] + "\",\"address\":\"" + sarea + saddress + "\"},"; i += 1; } } } if (strdata0.Substring(strdata0.Length - 1, 1) == ",") { strdata0 = strdata0.Substring(0, strdata0.Length - 1); } } strdata0 += "]"; strdata0 = ",\"shipments\":["; System.Data.DataSet Ds_sp = daojl2.GetList1("id,Addmoney,PayID,OrdersIDs,BZContent,addtime,seef", "gtype=" + gtype + " and utype=33 And IFDelete=0 and OrdersID=" + orderId + " Order By addtime desc"); if (Ds_sp.Tables[0].Rows.Count > 0) { for (int l = 0; l < Ds_sp.Tables[0].Rows.Count; l++) { string id = Ds_sp.Tables[0].Rows[l]["id"].ToString(); string num = Convert.ToDouble(Ds_sp.Tables[0].Rows[l]["Addmoney"]).ToString(); string kdcompay = Ds_sp.Tables[0].Rows[l]["PayID"].ToString(); string kdorderid = Ds_sp.Tables[0].Rows[l]["OrdersIDs"].ToString(); string content = Ds_sp.Tables[0].Rows[l]["BZContent"].ToString(); string addtime = Ds_sp.Tables[0].Rows[l]["addtime"].ToString(); string seef = Ds_sp.Tables[0].Rows[l]["seef"].ToString(); strdata0 += "{\"id\":\"" + id + "\",\"num\":\"" + num + "\",\"kdcompayid\":\"" + kdcompay + "\",\"kdcompay\":\"" + Mtxfw.Utility.Common.Getkdcompay(kdcompay) + "\",\"kdorderid\":\"" + kdorderid + "\",\"content\":\"" + content + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\"},"; } } Ds_sp.Clear(); if (strdata0.Substring(strdata0.Length - 1, 1) == ",") { strdata0 = strdata0.Substring(0, strdata0.Length - 1); } strdata0 += "]"; data = "{\"status\":1,\"data\":[" + strdata + "]" + strdata0 + "}"; } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //去付款----------------------------------------------------------------------------------------- /// /// 去付款 /// protected string payorder(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["orderid"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int orderid = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["orderid"].ToString())); bool b = true; int zftype = 0; if (!String.IsNullOrEmpty(context.Request["zftype"])) { zftype = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["zftype"].ToString())); } string openid = ""; if (!String.IsNullOrEmpty(context.Request["openid"])) { openid = HttpUtility.UrlDecode(context.Request["openid"].ToString()); } if (b) { Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { Mtxfw.Model.order_info ModelOrder = new Mtxfw.DAL.order_info().GetModel(orderid); if (ModelOrder != null) { if (ModelOrder.IFDelete == 0) { if (ModelOrder.O_Payed == "0" && ModelOrder.UserID == model.Id) { if (b) { string strProductName = ""; System.Data.DataSet Ds_op = daoorderproduct.GetList1("(Select P_NAME from P_Product b where b.P_ID=a.pid) as prodName", "orderid=" + ModelOrder.Id + " And IFDelete=0 Order By SubmitTime asc"); if (Ds_op.Tables[0].Rows.Count > 0) { for (int l = 0; l < Ds_op.Tables[0].Rows.Count; l++) { string prodName2 = Ds_op.Tables[0].Rows[l]["prodName"].ToString(); strProductName += prodName2 + " "; } } Mtxfw.Model.user_info umodel = daoUser.GetModel(ModelOrder.UserID); if (umodel != null) { DateTime dt = DateTime.Now; string PayID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo); string body = "购买商品" + strProductName; Int64 ResultId = 0; string timestamp = ""; string nonceStr = ""; string package = ""; string paySign = ""; string signType = ""; Double JFZSubTotal = Convert.ToDouble(ModelOrder.Totalprice.ToString("f2")); Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results(); ModelResults.b0 = JFZSubTotal; ModelResults.b1 = 0; ModelResults.b2 = 0; ModelResults.b3 = 0; ModelResults.b4 = 0; ModelResults.b5 = 0; ModelResults.b6 = 0; ModelResults.b7 = 0; ModelResults.b8 = 0; ModelResults.b9 = 0; ModelResults.b10 = 0; ModelResults.b11 = 0; ModelResults.b12 = 0; ModelResults.b13 = 0; ModelResults.b14 = 0; ModelResults.b15 = 0; ModelResults.b16 = 1;//0官方支付1汇付支付 ModelResults.b17 = (zftype == 1 ? 3 : 2); ModelResults.b18 = 0; ModelResults.conent = "购买商品" + strProductName; ModelResults.Totalmoney = JFZSubTotal; ModelResults.MemberId = umodel.Id; ModelResults.UserId = 3; ModelResults.ListNumber = PayID; ModelResults.Managers = "5"; ModelResults.Seef = 0; ModelResults.utype = "2"; ModelResults.addtime = dt; ModelResults.gtype = gtype; ResultId = daoResults.Add(ModelResults); daoResults.UpdateOrderIds(ModelOrder.Id.ToString(), ResultId); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = umodel.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "去付款" + ModelOrder.orderid; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); if (Convert.ToInt32(ModelOrder.utype) != (zftype == 1 ? 3 : 2)) { daoorder.Updatesel0("utype", (zftype == 1 ? 3 : 2), ModelOrder.Id); } string sys_id = config.hfpaysys_id; string product_id = config.hfpayproduct_id; string req_date = dt.ToString("yyyyMMdd"); string req_seq_id = PayID; string huifu_id = config.hfpayMerchantID; string goods_desc = body; string trade_type = "T_MINIAPP";//T_JSAPI: 微信公众号 T_MINIAPP: 微信小程序 A_JSAPI: 支付宝 A_NATIVE: 支付宝正扫 U_NATIVE: 银联正扫 U_JSAPI: 银联JS D_NATIVE: 数字人民币正扫 T_H5:微信直连H5支付 T_APP:微信APP支付 T_NATIVE:微信正扫 string wx_data = "{\\\"sub_appid\\\":\\\"" + config.webXAppID + "\\\",\\\"sub_openid\\\":\\\"" + openid + "\\\"}"; string trans_amt = JFZSubTotal.ToString("f2"); string time_expire = dt.AddMinutes(10).ToString("yyyyMMddHHmmss"); string notify_url = config.webUrl + "/pay/hfpay_notify_url.aspx"; SortedDictionary pay_dic = new SortedDictionary(); pay_dic.Add("req_date", req_date); pay_dic.Add("req_seq_id", req_seq_id); pay_dic.Add("huifu_id", huifu_id); pay_dic.Add("goods_desc", goods_desc); pay_dic.Add("trade_type", trade_type); pay_dic.Add("wx_data", wx_data); pay_dic.Add("trans_amt", trans_amt); pay_dic.Add("time_expire", time_expire); pay_dic.Add("notify_url", notify_url); string get_PaySign = Mtxfw.Utility.Interface_WxPay.BuildRequest0(pay_dic, config.hfpayPrivateKey); string strq = "{"; strq += "\"sys_id\":\"" + sys_id + "\","; strq += "\"product_id\":\"" + product_id + "\","; strq += "\"data\":{"; strq += "\"req_date\":\"" + req_date + "\","; strq += "\"req_seq_id\":\"" + req_seq_id + "\","; strq += "\"huifu_id\":\"" + huifu_id + "\","; strq += "\"goods_desc\":\"" + goods_desc + "\","; strq += "\"trade_type\":\"" + trade_type + "\","; strq += "\"wx_data\":\"" + wx_data + "\","; strq += "\"trans_amt\":\"" + trans_amt + "\","; strq += "\"time_expire\":\"" + time_expire + "\","; strq += "\"notify_url\":\"" + notify_url + "\""; strq += "}"; strq += ",\"sign\":\"" + get_PaySign + "\""; strq += "}"; string strResult = Mtxfw.Utility.Common.getPage2("https://api.huifu.com/v2/trade/payment/jspay", "", "utf-8", true, true, strq); Mtxfw.Utility.Common.WriteHtml("/weixin/xapiajaxstrResult.txt", strResult); huifuresult hr = (huifuresult)FromhuifuresultJson(strResult); if (hr.data.resp_code == "00000100") { huifuresult2 hr0 = (huifuresult2)Fromhuifuresult2Json(strResult); string pay_info = hr0.data.pay_info; hjpay_rc_Result hjrc_Result = (hjpay_rc_Result)Fromhjpay_rc_Result(pay_info); timestamp = hjrc_Result.timeStamp; nonceStr = hjrc_Result.nonceStr; package = hjrc_Result.package; paySign = hjrc_Result.paySign; signType = hjrc_Result.signType; //data = "{\"status\":1,\"msg\":\"正在支付中...\",\"timeStamp\":\"" + hjrc_Result.timeStamp + "\",\"noncestr\":\"" + hjrc_Result.nonceStr + "\",\"package\":\"" + hjrc_Result.package + "\",\"paySign\":\"" + hjrc_Result.paySign + "\",\"signType\":\"" + hjrc_Result.signType + "\"}"; } else { b = false; data = "{\"status\":0,\"msg\":\"" + hr.data.resp_desc + "\"}"; } //Mtxfw.Utility.Interface_WxPay.Get_RequestHtml0(config, context, umodel.openid, PayID, Convert.ToDecimal(JFZSubTotal), ref timestamp, ref nonceStr, ref package, ref paySign, body, "card_store"); //Mtxfw.Utility.Common.WriteHtml("/weixin/reResult.txt", timestamp + "|" + nonceStr + "|" + package + "|" + paySign); if (b) { data = "{\"status\":1,\"msg\":\"付款成功!\",\"ResultId\":\"" + ResultId + "\",\"timeStamp\":\"" + timestamp + "\",\"noncestr\":\"" + nonceStr + "\",\"package\":\"" + package + "\",\"paySign\":\"" + paySign + "\",\"signType\":\"" + signType + "\"}"; } } } } else { data = "{\"status\":0,\"msg\":\"参数错误4!\"}"; } } else { data = "{\"status\":0,\"msg\":\"订单已被删除!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //确认收货----------------------------------------------------------------------------------------- /// /// 确认收货 /// protected string qyshorder(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Int64 id = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["id"].ToString())); bool b = true; if (b) { Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { Mtxfw.Model.user_Results_jl2 jlModel = daojl2.GetModel(id); if (jlModel != null) { if (jlModel.IFDelete == 1) { b = false; data = "{\"status\":0,\"msg\":\"记录已删除!\"}"; } if (b) { if (jlModel.utype != 33) { b = false; data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } if (b) { if (jlModel.Seef == 1) { b = false; data = "{\"status\":0,\"msg\":\"此发货单已确认收货!\"}"; } } if (b) { if (jlModel.MemberId != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"无权限!\"}"; } } if(b){ DateTime dt = DateTime.Now; daojl2.UpdateSeef("seef", 1, "seeftime", dt, jlModel.Id); string orderid = ""; Mtxfw.Model.order_info oModel = daoorder.GetModel(jlModel.OrdersID); if (oModel != null) { orderid = oModel.orderid; if (oModel.O_Payed == "3") { int scount = daojl2.GetCount("gtype=" + gtype + " and utype=33 And IFDelete=0 and OrdersID=" + oModel.Id + " and seef=0"); if (scount == 0) { daoorder.UpdateqyState(0, "4", dt, oModel.Id); } } } Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = dt; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "小程序确认收货,单号:" + orderid; logmodel.UType = 1; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"操作成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"参数错误4!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //获取物流信息----------------------------------------------------------------------------------------- /// /// 获取物流信息 /// protected string kdchaxun(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["kdgs"]) && !String.IsNullOrEmpty(context.Request["ydh"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string kdgs = HttpUtility.UrlDecode(context.Request["kdgs"].ToString()); string ydh = HttpUtility.UrlDecode(context.Request["ydh"].ToString()); string mobile = ""; if (kdgs == "sf" && !String.IsNullOrEmpty(context.Request["mobile"])) { mobile = HttpUtility.UrlDecode(context.Request["mobile"].ToString()); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (b) { string strResult = ""; strResult = Mtxfw.Utility.Common.GetKDXX(ydh, kdgs, mobile); if (strResult.IndexOf("success") != -1) { kdchaxun kd = (kdchaxun)FromkdJson(strResult); if (kd.code == 200 && kd.success) { } else { b = false; data = "{\"success\":false,\"msg\":\"" + kd.msg + "\"}"; } if (b) { kdchaxun0 kd0 = (kdchaxun0)FromkdJson0(strResult); int status = 0; if (kd0.data.logisticsStatusDesc.IndexOf("已收件") != -1 || kd0.data.logisticsStatusDesc.IndexOf("已收寄") != -1) { status = 1; } if (kd0.data.logisticsStatusDesc.IndexOf("已到达") != -1 || kd0.data.logisticsStatusDesc.IndexOf("已发往") != -1 || kd0.data.logisticsStatusDesc.IndexOf("正发往") != -1 || kd0.data.logisticsStatusDesc.IndexOf("上一站") != -1 || kd0.data.logisticsStatusDesc.IndexOf("下一站") != -1 || kd0.data.logisticsStatusDesc.IndexOf("已进行") != -1 || kd0.data.logisticsStatusDesc.IndexOf("已在") != -1 || kd0.data.logisticsStatusDesc.IndexOf("运输中") != -1) { status = 2; } if (kd0.data.logisticsStatusDesc.IndexOf("派件") != -1 || kd0.data.logisticsStatusDesc.IndexOf("派送") != -1) { status = 3; } if (kd0.data.logisticsStatusDesc.IndexOf("签收") != -1 || kd0.data.logisticsStatusDesc.IndexOf("已暂存") != -1 || kd0.data.logisticsStatusDesc.IndexOf("已送达") != -1 || kd0.data.logisticsStatusDesc.IndexOf("代收") != -1) { status = 4; } int Count = kd0.data.logisticsTraceDetails.Count; StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); using (JsonWriter jw = new JsonTextWriter(sw)) { jw.WriteStartObject(); jw.WritePropertyName("success"); jw.WriteValue(true); DateTime dt1 = Mtxfw.Utility.Common.To13DateTime(kd0.data.logisticsTraceDetails[0].time); DateTime dt2 = Mtxfw.Utility.Common.To13DateTime(kd0.data.logisticsTraceDetails[Count - 1].time); TimeSpan t = dt2.Subtract(dt1); string times = ""; if (t.Days > 0) { times = t.Days + "天" + t.Hours + "小时"; } else { times = t.Hours + "小时"; } jw.WritePropertyName("times"); jw.WriteValue(times); jw.WritePropertyName("items"); jw.WriteStartArray(); string strtimes = ""; for (int i = 0; i < Count; i++) { string strremark = "[" + kd0.data.logisticsTraceDetails[i].areaName + "]" + kd0.data.logisticsTraceDetails[i].desc.Replace(" ", "").Trim(); string dt = Mtxfw.Utility.Common.To13DateTime(kd0.data.logisticsTraceDetails[i].time).ToString("yyyy-MM-dd", System.Globalization.DateTimeFormatInfo.InvariantInfo); string sj = Mtxfw.Utility.Common.To13DateTime(kd0.data.logisticsTraceDetails[i].time).ToString("HH:mm", System.Globalization.DateTimeFormatInfo.InvariantInfo); if (strtimes != "" && strtimes != dt) { jw.WriteEndArray(); jw.WriteEndObject(); } if (strtimes == "" || strtimes != dt) { jw.WriteStartObject(); jw.WritePropertyName("ddate"); jw.WriteValue(dt); jw.WritePropertyName("lists"); jw.WriteStartArray(); jw.WriteStartObject(); jw.WritePropertyName("datetime"); jw.WriteValue(sj); jw.WritePropertyName("remark"); jw.WriteValue(strremark); jw.WriteEndObject(); } else { jw.WriteStartObject(); jw.WritePropertyName("datetime"); jw.WriteValue(sj); jw.WritePropertyName("remark"); jw.WriteValue(strremark); jw.WriteEndObject(); } strtimes = dt; } if (Count > 0) { jw.WriteEndArray(); jw.WriteEndObject(); } jw.WriteEndArray(); jw.WritePropertyName("status");//状态 jw.WriteValue(status); jw.WriteEndObject(); } data = sw.ToString(); } } else { data = "{\"success\":false,\"msg\":\"超时,未能成功获取内容\"}"; } } } else { data = "{\"success\":false,\"msg\":\"您未登录\"}"; } } else { data = "{\"success\":false,\"msg\":\"参数错误\"}"; } } else { data = "{\"success\":false,\"msg\":\"参数为空\"}"; } return data; } public object FromkdJson(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object FromkdJson0(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } #endregion #region //获取地址列表----------------------------------------------------------------------------------------- /// /// 获取地址列表 /// protected string getAddress(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; DataSet ds = new DAL.user_address().GetList1("id,Contactname,Contacttel,Address,IFIndex,Province,City,County,Zipcode", "UserID=" + model.Id + " Order By IFIndex Desc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { string _id = Dr["id"].ToString(); string contact = Dr["Contactname"].ToString(); string tel = Dr["Contacttel"].ToString(); string detail = Dr["Address"].ToString(); string Province = Dr["Province"].ToString(); string City = Dr["City"].ToString(); string County = Dr["County"].ToString(); string IFIndex = Dr["IFIndex"].ToString(); string area = new DAL.province().GetProvince(Province)+ new DAL.city().GetCity(City) + new DAL.county().GetCounty(County); strdata += "{\"addressId\":\"" + _id + "\",\"contact\":\"" + contact + "\",\"tel\":\"" + tel + "\",\"Province\":\"" + Province + "\",\"City\":\"" + City + "\",\"County\":\"" + County + "\",\"area\":\"" + area + "\",\"detail\":\"" + detail + "\",\"IFIndex\":\"" + IFIndex + "\"}"; if (i != ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取自提地址列表----------------------------------------------------------------------------------------- /// /// 获取自提地址列表 /// protected string getZTAddress(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Decimal latitude = 0; if (!String.IsNullOrEmpty(context.Request["latitude"])) { latitude = Convert.ToDecimal(context.Request["latitude"].ToString()); } Decimal longitude = 0; if (!String.IsNullOrEmpty(context.Request["longitude"])) { longitude = Convert.ToDecimal(context.Request["longitude"].ToString()); } string keyword = ""; if (!String.IsNullOrEmpty(context.Request["keyword"])) { keyword = HttpUtility.UrlDecode(context.Request["keyword"].ToString()); } String province = context.Request["province"]; String city = context.Request["city"]; String county = context.Request["county"]; System.Text.StringBuilder sb = new System.Text.StringBuilder(); if (!String.IsNullOrEmpty(province)) { if (province!="-1") { sb.Append(" and Agenprovince='" + province + "'"); } } if (!String.IsNullOrEmpty(city)) { if (city != "-1") { sb.Append(" and Agencity='" + city + "'"); } } if (!String.IsNullOrEmpty(county)) { if (county != "-1") { sb.Append(" and Agencounty='" + county + "'"); } } Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string strdata = ""; string groupby = ""; string strOrder = "dbo.GetDistance(" + latitude + "," + longitude + ",latitude,longitude) asc"; int Start = 0; int Limit = 30; if (!String.IsNullOrEmpty(context.Request["Start"])) { Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString())); } Int32 Recount = 0; DataSet ds = daoproxy.GetDataSet(groupby, strOrder, "id,AName,ATel,Agenprovince,Agencity,Agencounty,IFFill,Agentrading,AAddress,dbo.GetDistance(" + latitude + "," + longitude + ",latitude,longitude) as distance", "", "gtype=" + gtype + " and TType=0 and seef=1" +sb.ToString()+ (keyword!=""?" and (AName like '%"+keyword+"%' or ATel like '%"+keyword+"%')":""), Start, Limit, out Recount); int dtcount = Recount; if (ds.Tables[1].Rows.Count > 0) { foreach (System.Data.DataRow Dr in ds.Tables[1].Rows) { string id = Dr["id"].ToString(); string name = Dr["AName"].ToString(); string tel = Dr["ATel"].ToString(); string sprovince = Dr["Agenprovince"].ToString(); string scity = Dr["Agencity"].ToString(); string scounty = Dr["Agencounty"].ToString(); string IFFill = Dr["IFFill"].ToString(); string Agentrading = Dr["Agentrading"].ToString(); string address = Dr["AAddress"].ToString(); string sarea = new DAL.province().GetProvince(sprovince); sarea += new DAL.city().GetCity(scity); sarea += new DAL.county().GetCounty(scounty); sarea += (IFFill == "1" ? Agentrading : new Mtxfw.DAL.tradingarea().Gettradingarea(scity, scounty, Agentrading)); string strdistance = ""; Double distance = Convert.ToDouble(Convert.ToDouble(Dr["distance"]).ToString("f4")); if (distance < 0.0000) { distance = -distance; } if (distance > 1000.0000) { strdistance = (distance / 1000).ToString().Split('.')[0] + "km"; } else { strdistance = distance.ToString("f0") + "m"; } strdata += "{\"addressId\":\"" + id + "\",\"type\":0,\"contact\":\"" + Mtxfw.Utility.Common.ReplaceString(name) + "\",\"tel\":\"" + Mtxfw.Utility.Common.ReplaceString(tel) + "\",\"province\":\"" + sprovince + "\",\"city\":\"" + scity + "\",\"county\":\"" + scounty + "\",\"area\":\"" + sarea + "\",\"IFFill\":\"" + IFFill + "\",\"Tradingarea\":\"" + Mtxfw.Utility.Common.ReplaceString(Agentrading) + "\",\"address\":\"" + Mtxfw.Utility.Common.ReplaceString(address) + "\",\"distance\":\"" + strdistance + "\"},"; } if (strdata.Substring(strdata.Length - 1, 1) == ",") { strdata = strdata.Substring(0, strdata.Length - 1); } } ds.Clear(); data = "{\"status\":1,\"data\":[" + strdata + "]}"; } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //设置默认地址----------------------------------------------------------------------------------------- /// /// 设置默认地址 /// protected string setDefaultAddress(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["addressId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int addressId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["addressId"].ToString())); int t = 0; if (!String.IsNullOrEmpty(context.Request["t"])) { t = Convert.ToInt32(context.Request["t"].ToString()); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (t == 0) { new DAL.user_address().UpdateIFIndex(addressId, userId); } else { new DAL.user_address().UpdateIFIndex0(addressId, userId); } data = "{\"status\":1,\"msg\":\"设置成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //添加微信地址----------------------------------------------------------------------------------------- /// /// 添加微信地址 /// protected string addweixinaddress(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["contact"]) && !String.IsNullOrEmpty(context.Request["tel"]) && !String.IsNullOrEmpty(context.Request["detail"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string contact = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["contact"].ToString())); string tel = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["tel"].ToString())); bool b = true; string provinceName = ""; string Province = ""; string cityName = "", County = ""; string City = "", countyName = ""; if (b) { if (contact.Length >= 10) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Provinces must choose!" : "姓名填写太长!") + "\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["provinceName"])) { provinceName = HttpUtility.UrlDecode(context.Request["provinceName"].ToString()); provinceName = provinceName.Substring(0, 2); Province = new DAL.province().GetProvinceID(provinceName); } else { b = false; data = "{\"status\":0,\"msg\":\"省份未选择!\"}"; } } if (b) { if (Province == "") { b = false; data = "{\"status\":0,\"msg\":\"省份选择错误!\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["cityName"])) { cityName = HttpUtility.UrlDecode(context.Request["cityName"].ToString()); City = new DAL.city().GetCityID(cityName); } else { if (new DAL.city().GetCount("ProvinceID='" + Province + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"城市未选择!\"}"; } } } if (b) { if (!String.IsNullOrEmpty(context.Request["countyName"])) { countyName = HttpUtility.UrlDecode(context.Request["countyName"].ToString()); County = new DAL.county().GetCountyID(countyName); } else { if (new DAL.county().GetCount("CityID='" + City + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"县区未选择!\"}"; } } } int IFIndex = 1; if (!String.IsNullOrEmpty(context.Request["IFIndex"])) { IFIndex = Convert.ToInt32(context.Request["IFIndex"].ToString()); } string detail = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["detail"].ToString())); if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (new DAL.user_address().GetCount("UserID=" + model.Id) < 5) { if (IFIndex == 1) { new DAL.user_address().UpdateIFIndex(userId); } Model.user_address amodel = new Model.user_address(); amodel.Contactname = contact; amodel.Contacttel = tel; amodel.Province = Province; amodel.City = City; amodel.County = County; amodel.Address = detail; amodel.Zipcode = ""; amodel.Guests = ""; amodel.IFIndex = IFIndex; amodel.UserID = model.Id; amodel.gtype = gtype; int addressId = new DAL.user_address().Add(amodel); if (model.RealName == "") { model.RealName = contact; daoUser.Update(model); } data = "{\"status\":1,\"msg\":\"添加成功!\",\"addressId\":\"" + addressId + "\"}"; } else { data = "{\"status\":1,\"msg\":\"最多只能添加5个地址!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //删除地址----------------------------------------------------------------------------------------- /// /// 删除地址 /// protected string deleteAddress(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["addressId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int addressId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["addressId"].ToString())); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { new DAL.user_address().Delete(addressId, userId); data = "{\"status\":1,\"msg\":\"删除成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //添加地址----------------------------------------------------------------------------------------- /// /// 添加地址 /// protected string addAddress(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["contact"]) && !String.IsNullOrEmpty(context.Request["tel"]) && !String.IsNullOrEmpty(context.Request["Province"]) && !String.IsNullOrEmpty(context.Request["detail"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string contact = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["contact"].ToString())); string tel = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["tel"].ToString())); bool b = true; string Province = HttpUtility.UrlDecode(context.Request["Province"].ToString()); string City = "", County = ""; if (!String.IsNullOrEmpty(context.Request["City"])) { City = HttpUtility.UrlDecode(context.Request["City"].ToString()); if (City != "") { City = City.Replace("null", ""); } } if (b) { if (!String.IsNullOrEmpty(contact)) { if (!System.Text.RegularExpressions.Regex.IsMatch(contact, @"^[\u4e00-\u9fa5a-zA-Z]+$")) { b = false; data = "{\"status\":0,\"msg\":\"联系人姓名填写不正确,只能输入中文或字母!\"}"; } } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[-]+[09]+\d{8}")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Cities must choose!" : "手机号码格式填写不正确!") + "\"}"; } } if (b) { if (City == "") { if (new Mtxfw.DAL.city().GetCount("ProvinceID='" + Province + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"城市未选择!\"}"; } } } if (!String.IsNullOrEmpty(context.Request["County"])) { County = HttpUtility.UrlDecode(context.Request["County"].ToString()); if (County != "") { County = County.Replace("null", ""); } } if (b) { if (County == "") { if (b) { if (new Mtxfw.DAL.county().GetCount("CityID='" + City + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"县区未选择!\"}"; } } } } int IFIndex = 1; if (!String.IsNullOrEmpty(context.Request["IFIndex"])) { IFIndex = Convert.ToInt32(context.Request["IFIndex"].ToString()); } string detail = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["detail"].ToString())); if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { if (new DAL.user_address().GetCount("UserID=" + model.Id) < 5) { if (IFIndex == 1) { new DAL.user_address().UpdateIFIndex(userId); } Model.user_address amodel = new Model.user_address(); amodel.Contactname = contact; amodel.Contacttel = tel; amodel.Province = Province; amodel.City = City; amodel.County = County; amodel.Tradingarea = ""; amodel.Address = detail; amodel.Zipcode = ""; amodel.Guests = ""; amodel.IFIndex = IFIndex; amodel.UserID = model.Id; amodel.gtype = gtype; int addressId = new DAL.user_address().Add(amodel); if (model.RealName == "") { model.RealName = contact; daoUser.Update(model); } data = "{\"status\":1,\"msg\":\"添加成功!\",\"addressId\":\"" + addressId + "\"}"; } else { data = "{\"status\":1,\"msg\":\"最多只能添加5个地址!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //修改地址----------------------------------------------------------------------------------------- /// /// 修改地址 /// protected string updateAddress(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["addressId"]) && !String.IsNullOrEmpty(context.Request["contact"]) && !String.IsNullOrEmpty(context.Request["tel"]) && !String.IsNullOrEmpty(context.Request["Province"]) && !String.IsNullOrEmpty(context.Request["detail"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int addressId = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["addressId"].ToString())); string contact = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["contact"].ToString())); string tel = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["tel"].ToString())); bool b = true; string Province = HttpUtility.UrlDecode(context.Request["Province"].ToString()); string City = "", County = ""; if (b) { if (!String.IsNullOrEmpty(contact)) { if (!System.Text.RegularExpressions.Regex.IsMatch(contact, @"^[\u4e00-\u9fa5a-zA-Z]+$")) { b = false; data = "{\"status\":0,\"msg\":\"联系人姓名填写不正确,只能输入中文或字母!\"}"; } } } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[09]+\d{8}") && !System.Text.RegularExpressions.Regex.IsMatch(tel, @"^[00886]+[-]+[09]+\d{8}")) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Cities must choose!" : "手机号码格式填写不正确!") + "\"}"; } } if (b) { if (City == "") { if (new Mtxfw.DAL.city().GetCount("ProvinceID='" + Province + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"城市未选择!\"}"; } } } if (!String.IsNullOrEmpty(context.Request["County"])) { County = HttpUtility.UrlDecode(context.Request["County"].ToString()); if (County != "") { County = County.Replace("null", ""); } } if (b) { if (County == "") { if (b) { if (new Mtxfw.DAL.county().GetCount("CityID='" + City + "'") > 0) { b = false; data = "{\"status\":0,\"msg\":\"县区未选择!\"}"; } } } } int IFIndex = 1; if (!String.IsNullOrEmpty(context.Request["IFIndex"])) { IFIndex = Convert.ToInt32(context.Request["IFIndex"].ToString()); } string detail = Mtxfw.Utility.Common.CIntro0(HttpUtility.UrlDecode(context.Request["detail"].ToString())); if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { Model.user_address amodel = new DAL.user_address().GetModel(addressId); if (amodel != null) { if (IFIndex == 1) { new DAL.user_address().UpdateIFIndex(addressId, userId); } amodel.Contactname = contact; amodel.Contacttel = tel; amodel.Province = Province; amodel.City = City; amodel.County = County; amodel.Address = detail; amodel.IFIndex = IFIndex; new DAL.user_address().Update(amodel); data = "{\"status\":1,\"msg\":\"修改成功!\"}"; } else { data = "{\"status\":0,\"msg\":\"修改失败!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //取消订单----------------------------------------------------------------------------------------- /// /// 取消订单 /// protected string CancelOrder(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["orderid"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int orderid = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["orderid"].ToString())); bool b = true; if (b) { Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { Mtxfw.DAL.order_info baoorder = new Mtxfw.DAL.order_info(); Mtxfw.DAL.user_info daouser = new Mtxfw.DAL.user_info(); Mtxfw.DAL.user_Results daoResults = new Mtxfw.DAL.user_Results(); Mtxfw.Model.order_info ModelOrder = baoorder.GetModel(orderid); if (ModelOrder != null) { if (ModelOrder.UserID == model.Id) { string O_Payed = ""; O_Payed = ModelOrder.O_Payed; if (ModelOrder.IFDelete == 0) { if (O_Payed == "0") { System.Data.DataSet Ds_op = new Mtxfw.DAL.order_product_info().GetList1("Totalnum,guige,selcolor", "utype='0' And orderid=" + ModelOrder.Id + " And IFDelete=0 Order By SubmitTime asc"); if (Ds_op.Tables[0].Rows.Count > 0) { foreach (System.Data.DataRow drv2 in Ds_op.Tables[0].Rows) { string selcolor = drv2["selcolor"].ToString(); int prodNum = Convert.ToInt32(drv2["Totalnum"]); string guige = drv2["guige"].ToString(); if (guige != "") { Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige)); if (gmodel != null) { int ZKC = 0; bool IFKC = true; string strcolors = gmodel.G_Color; string[] acolors = gmodel.G_Color.Split(','); for (int jj = 0; jj < acolors.Length; jj++) { if (acolors[jj] != "") { var ac = acolors[jj].Split('|'); if (ac.Length > 1) { if (ac[1] != "") { int intNum = Convert.ToInt32(ac[1]); if (ac[0] == selcolor) { intNum = (intNum + Convert.ToInt32(prodNum)); strcolors = strcolors.Replace(ac[0] + "|" + ac[1], ac[0] + "|" + intNum); } ZKC += intNum; IFKC = false; } } } } gmodel.G_Color = strcolors; if (IFKC) { gmodel.G_KC = gmodel.G_KC + Convert.ToInt32(prodNum); } else { gmodel.G_KC = ZKC; } new DAL.P_Guige().Update(gmodel); } } } } Ds_op.Clear(); baoorder.UpdateqyState(0, "-1", DateTime.Now, ModelOrder.Id); daoorderproduct.UpdateIFDelete(1, DateTime.Now.ToString(), ModelOrder.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "取消订单" + ModelOrder.orderid; logmodel.UType = 0; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"订单取消成功!\"}"; } else { if (O_Payed == "-1") { data = "{\"status\":0,\"msg\":\"此订单已取消!\"}"; } else { data = "{\"status\":0,\"msg\":\"此订单不能取消!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"此订单已删除,不能取消!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"不是您的订单不能取消!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //用户取消订单支付----------------------------------------------------------------------------------------- /// /// 用户取消订单支付 /// protected string CancelOrderPay(HttpContext context) { string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["id"])) { Int64 ResultId = Convert.ToInt64(HttpUtility.UrlDecode(context.Request["id"].ToString())); Mtxfw.Model.user_Results rmodel = daoResults.GetModel(ResultId); if (rmodel != null) { if (rmodel.utype == "2") { if (rmodel.IFDelete == 0) { if (rmodel.Seef == 0) { /*string[] OrderIds = rmodel.OrderIds.Split(','); foreach (string orderid in OrderIds) { if (orderid != "") { daoorder.UpdateIFDelete(1, DateTime.Now.ToString(), Convert.ToInt32(orderid)); } }*/ daoResults.Updatemoney("b10", 1, "id=" + rmodel.Id); } else { data = "{\"status\":0,\"msg\":\"此订单已支付!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误1!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空!\"}"; } return data; } #endregion #region //删除订单----------------------------------------------------------------------------------------- /// /// 删除订单 /// protected string DeleteOrder(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["orderid"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int orderid = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["orderid"].ToString())); bool b = true; if (b) { Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { DAL.order_info baoorder = new DAL.order_info(); Mtxfw.Model.order_info ModelOrder = baoorder.GetModel(orderid); if (ModelOrder != null) { if (ModelOrder.UserID == model.Id) { string O_Payed = ""; O_Payed = ModelOrder.O_Payed; if (ModelOrder.IFDelete == 0) { if (O_Payed == "1" || O_Payed == "2" || O_Payed == "3") { bool IFDelete = true; DateTime dt1 = DateTime.Now; DateTime dt2 = ModelOrder.O_SubmitDate.AddHours(72); if (dt1 < dt2) { IFDelete = false; } if (ModelOrder.utype == "0") { IFDelete = false; } if (IFDelete) { Mtxfw.Model.user_info umodel = daoUser.GetModel(ModelOrder.UserID); if (umodel != null) { baoorder.UpdateIFDelete(1, DateTime.Now.ToString(), ModelOrder.Id); daoorderproduct.UpdateIFDelete(1, DateTime.Now.ToString(), ModelOrder.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "删除订单" + ModelOrder.orderid; logmodel.UType = 1; new DAL.User_CZ_log().Add(logmodel); } data = "{\"status\":1,\"msg\":\"删除成功!\"}"; } else { if (ModelOrder.utype == "3") { data = "{\"status\":0,\"msg\":\"下单在72个小时后仍是未发货状态才可以删除!\"}"; } else { data = "{\"status\":0,\"msg\":\"套餐订单不能删除!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"订单已发货不能删除!\"}"; } } else { data = "{\"status\":0,\"msg\":\"订单已删除,请不要重复操作!\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录!\"}"; } } else { data = "{\"status\":0,\"msg\":\"不是您的订单不能删除!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误3!\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误2!\"}"; } } } else { data = "{\"status\":0,\"msg\":\"参数错误!\"}"; } return data; } #endregion #region //修改登录密码----------------------------------------------------------------------------------------- /// /// 修改登录密码 /// protected string editpwd(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["newpwd"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string newpwd = HttpUtility.UrlDecode(context.Request["newpwd"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(newpwd, @"^[A-Za-z0-9_]+$") || newpwd.Length < 6 || newpwd.Length > 16) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The new password is not entered correctly. The password is composed of 6-16 digits, letters and underscores!" : "新密码输入不正确,密码由6-16位数字、字母、下划线组成!") + "\"}"; } } if (b) { if (model.IFPhone == 1) { if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } } else { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不能为空!\"}"; } } else { b = false; data = "{\"status\":0,\"msg\":\"未绑定手机号!\"}"; } } if (b) { daoUser.UpdatePassword("password", Mtxfw.Utility.Security.EncryptString(newpwd), model.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "修改登录密码"; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); daoUser.UpdatePhoneTime3("", model.Id); data = "{\"status\":1,\"msg\":\"" + (e == 1 ? "Amend the success!" : "修改成功!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //修改二级密码---------------------------------------------------------------------------------- /// /// 修改二级密码 /// protected string editpwd2(HttpContext context) { string data = "{\"status\":0}"; int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["newpwd"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); string newpwd = HttpUtility.UrlDecode(context.Request["newpwd"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; if (String.IsNullOrEmpty(context.Request["oldpwd"]) && String.IsNullOrEmpty(context.Request["code"])) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数为空!") + "\"}"; } if (b) { if (!System.Text.RegularExpressions.Regex.IsMatch(newpwd, @"^[A-Za-z0-9_]+$") || newpwd.Length < 6 || newpwd.Length > 16) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The new password is not entered correctly. The password is composed of 6-16 digits, letters and underscores!" : "新密码输入不正确,密码由6-16位数字、字母、下划线组成!") + "\"}"; } } if (b) { if (Mtxfw.Utility.Security.EncryptString(newpwd) == model.Password) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The two level password can not be the same as the first level cipher!" : "二级密码不能跟登录密码相同!") + "\"}"; } } if (b) { if (Mtxfw.Utility.Security.EncryptString(newpwd) == model.Password2) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The new password cannot be the same as the old one!" : "新密码不能跟旧密码相同!") + "\"}"; } } if (b) { if (!String.IsNullOrEmpty(context.Request["oldpwd"])) { string oldpwd = HttpUtility.UrlDecode(context.Request["oldpwd"].ToString()); if (model.Password != Mtxfw.Utility.Security.EncryptString(oldpwd)) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Old password is incorrect!" : "旧密码不正确!") + "\"}"; } } } if (b) { if (!String.IsNullOrEmpty(context.Request["code"])) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is incorrect!" : "手机验证码不正确!") + "\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "The phone verification code is invalid!" : "手机验证码已经失效!") + "\"}"; } } } } } if (b) { daoUser.UpdatePassword("password2", Mtxfw.Utility.Security.EncryptString(newpwd), model.Id); Model.User_CZ_log logmodel = new Model.User_CZ_log(); logmodel.MemberId = model.Id; logmodel.AddTime = DateTime.Now; logmodel.IP = Mtxfw.Utility.Common.GetIP; logmodel.Body = "修改二级密码"; logmodel.UType = 2; logmodel.gtype = gtype; new DAL.User_CZ_log().Add(logmodel); data = "{\"status\":1,\"msg\":\"修改成功!\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "You are not logged in!" : "您未登录!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter error!" : "参数错误!") + "\"}"; } } else { data = "{\"status\":0,\"msg\":\"" + (e == 1 ? "Parameter can not be empty!" : "参数不能为空!") + "\"}"; } return data; } #endregion #region //获取客服----------------------------------------------------------------------------------------- /// /// 获取客服 /// protected string getServerMsg(HttpContext context) { int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } string data = "{\"status\":0}"; data = "" + Mtxfw.Utility.Common.InputText(config.ServerMsg) + ""; return data; } #endregion #region //获取会员协议----------------------------------------------------------------------------------------- /// /// 获取会员协议 /// protected string getxieyi(HttpContext context) { int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } string data = "{\"status\":0}"; Mtxfw.Model.Article model = daoArt.GetModel(451); if (model != null) { string strdata = "\"lifemuseu\":["; DataSet ds = daoUser.GetList1("id,lifename,lifeaddress", "uutype='0' And UserState='正常' And IFStores=0 And uLevel3=2 Order By regtime asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id2 = Convert.ToInt32(Dr["id"]); string lifename = Dr["lifename"].ToString(); string lifeaddress = Dr["lifeaddress"].ToString(); strdata += "{\"id\":\"" + id2 + "\",\"lifename\":\"" + lifename + "\",\"lifeaddress\":\"" + lifeaddress + "\"}";// if (i < ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; data = "{\"status\":1,\"content\":\"" + model.Content.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\"", "\\\"") + "\",\"IFShowlifemuseu\":"+config.FHEnable5+"," + strdata + "}"; } return data; } #endregion #region //获取推荐图谱----------------------------------------------------------------------------------------- /// /// 获取推荐图谱 /// protected string getmynetmap(HttpContext context) { int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int id = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["id"].ToString())); string keyword = ""; if (!String.IsNullOrEmpty(context.Request["keyword"])) { keyword = context.Request["keyword"].ToString(); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; string strdata = ""; int ccount = 0, ccount2 = 0; int hyid = id; int dcid = model.Id; int sycid = 0; int uLevel1 = model.uLevel1; if (keyword != "" && id == 0) { DataSet dss = daoUser.GetList1("id,UserName,RealName,NCName,ContactID,ContactIDS,uLevel1,umoney19,UserState,regtime,(select count(*) from user_info b where b.ContactID=a.id and b.userstate='正常') as tjcount,(select count(*) from user_info b where b.ContactIDS like '%,' + convert(varchar(50),a.id) + ',%' and b.userstate='正常') as zcount", "uutype='0' And UserState='正常' And IFStores=0 And UserName='" + keyword + "' Order By regtime asc"); if (dss.Tables[0].Rows.Count > 0) { int id2 = Convert.ToInt32(dss.Tables[0].Rows[0]["id"]); sycid = Convert.ToInt32(dss.Tables[0].Rows[0]["ContactID"]); hyid = id2; string UserName = dss.Tables[0].Rows[0]["UserName"].ToString(); string RealName = dss.Tables[0].Rows[0]["RealName"].ToString(); string NCName = dss.Tables[0].Rows[0]["NCName"].ToString(); string umoney19 = Convert.ToDouble(dss.Tables[0].Rows[0]["umoney19"]).ToString("f2"); string UserState = dss.Tables[0].Rows[0]["UserState"].ToString(); string RegTime = dss.Tables[0].Rows[0]["RegTime"].ToString(); string tjcount = dss.Tables[0].Rows[0]["tjcount"].ToString(); string ContactIDS = dss.Tables[0].Rows[0]["ContactIDS"].ToString(); string zcount = dss.Tables[0].Rows[0]["zcount"].ToString(); uLevel1 = Convert.ToInt32(dss.Tables[0].Rows[0]["uLevel1"]); if (NCName == "") { NCName = RealName; } strdata += "\"topuser\":{\"id\":" + id2 + ",\"dcid\":" + dcid + ",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"NCName\":\"" + NCName + "\",\"ds\":0,\"ztsl\":" + tjcount + ",\"hyzs\":" + zcount + ",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"zcsj\":\"" + RegTime + "\"}"; if (ContactIDS != ",") { if (ContactIDS.IndexOf("," + model.Id + ",") == -1 && id2 != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中\"}"; } } else { if (id2 != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"账号不存在\"}"; } dss.Clear(); } else { if (id == 0) { hyid = userId; ccount = daoUser.GetCount("ContactID=" + model.Id + " and userstate='正常'"); ccount2 = daoUser.GetCount("ContactIDS Like '%," + model.Id + ",%' and userstate='正常'"); string NCName = model.NCName; if (NCName == "") { NCName = model.RealName; } strdata += "\"topuser\":{\"id\":" + model.Id + ",\"dcid\":" + dcid + ",\"UserName\":\"" + model.UserName + "\",\"RealName\":\"" + model.RealName + "\",\"NCName\":\"" + NCName + "\",\"ds\":0,\"ztsl\":" + ccount + ",\"hyzs\":" + ccount2 + ",\"zyj\":\"" + model.umoney19 + "\",\"zt\":\"" + model.UserState + "\",\"zcsj\":\"" + model.RegTime + "\"}"; } else { dcid = -1; Mtxfw.Model.user_info model2 = daoUser.GetModel(hyid); if (model2 != null) { sycid = model2.ContactID; ccount = daoUser.GetCount("ContactID=" + model2.Id + " and userstate='正常'"); ccount2 = daoUser.GetCount("ContactIDS Like '%," + model2.Id + ",%' and userstate='正常'"); string NCName = model2.NCName; if (NCName == "") { NCName = model2.RealName; } strdata += "\"topuser\":{\"id\":" + model2.Id + ",\"dcid\":" + dcid + ",\"UserName\":\"" + model2.UserName + "\",\"RealName\":\"" + model2.RealName + "\",\"NCName\":\"" + NCName + "\",\"ds\":" + (model2.uLevel1 - uLevel1) + ",\"ztsl\":" + ccount + ",\"hyzs\":" + ccount2 + ",\"zyj\":\"" + model2.umoney19.ToString("f2") + "\",\"zt\":\"" + model2.UserState + "\",\"zcsj\":\"" + model2.RegTime + "\"}"; if (model2.ContactIDS != ",") { if (model2.ContactIDS.IndexOf("," + model.Id + ",") == -1 && model2.Id != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中2\"}"; } } else { if (model2.Id != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中2\"}"; } } } } } if (b) { strdata += ",\"muser\":["; DataSet ds = daoUser.GetList1("id,UserName,RealName,NCName,umoney19,UserState,regtime,uLevel1,(select count(*) from user_info b where b.ContactID=a.id and b.userstate='正常') as tjcount,(select count(*) from user_info b where b.ContactIDS like '%,' + convert(varchar(50),a.id) + ',%' and b.userstate='正常') as zcount", "uutype='0' And UserState='正常' And IFStores=0 And ContactID=" + hyid + " Order By regtime asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id2 = Convert.ToInt32(Dr["id"]); string UserName = Dr["UserName"].ToString(); string RealName = Dr["RealName"].ToString(); string NCName = Dr["NCName"].ToString(); string umoney19 = Convert.ToDouble(Dr["umoney19"]).ToString("f2"); string UserState = Dr["UserState"].ToString(); string RegTime = Dr["RegTime"].ToString(); string tjcount = Dr["tjcount"].ToString(); string zcount = Dr["zcount"].ToString(); int suLevel1 = Convert.ToInt32(Dr["uLevel1"]) - uLevel1; if (NCName == "") { NCName = RealName; } strdata += "{\"id\":" + id2 + ",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"NCName\":\"" + NCName + "\",\"ds\":" + suLevel1 + ",\"ztsl\":" + tjcount + ",\"hyzs\":" + zcount + ",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"zcsj\":\"" + RegTime + "\"}"; if (i < ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; data = "{\"status\":1,\"sycid\":\"" + sycid + "\"," + strdata + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取接点图谱----------------------------------------------------------------------------------------- /// /// 获取接点图谱 /// protected string getmynetmap2(HttpContext context) { int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["id"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); int id = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["id"].ToString())); string keyword = ""; if (!String.IsNullOrEmpty(context.Request["keyword"])) { keyword = context.Request["keyword"].ToString(); } Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; string strdata = ""; int ccount = 0, ccount2 = 0; int hyid = id; int dcid = model.Id; int sycid = 0; int uLevel0 = model.uLevel0; if (keyword != "" && id == 0) { DataSet dss = daoUser.GetList1("id,UserName,RealName,SuperiorsID,SuperiorsIDS,uLevel0,umoney19,UserState,regtime,(select count(*) from user_info b where b.ContactID=a.id and b.userstate='正常') as tjcount,(select count(*) from user_info b where b.SuperiorsID=a.id and b.userstate='正常') as jdcount,(select count(*) from user_info b where b.SuperiorsIDS like '%,' + convert(varchar(50),a.id) + ',%' and b.userstate='正常') as zcount", "uutype='0' And UserState='正常' And IFStores=0 And UserName='" + keyword + "' Order By regtime asc"); if (dss.Tables[0].Rows.Count > 0) { int id2 = Convert.ToInt32(dss.Tables[0].Rows[0]["id"]); sycid = Convert.ToInt32(dss.Tables[0].Rows[0]["SuperiorsID"]); hyid = id2; string UserName = dss.Tables[0].Rows[0]["UserName"].ToString(); string RealName = dss.Tables[0].Rows[0]["RealName"].ToString(); string umoney19 = Convert.ToDouble(dss.Tables[0].Rows[0]["umoney19"]).ToString("f2"); string UserState = dss.Tables[0].Rows[0]["UserState"].ToString(); string RegTime = dss.Tables[0].Rows[0]["RegTime"].ToString(); string tjcount = dss.Tables[0].Rows[0]["tjcount"].ToString(); string jdcount = dss.Tables[0].Rows[0]["jdcount"].ToString(); string SuperiorsIDS = dss.Tables[0].Rows[0]["SuperiorsIDS"].ToString(); string zcount = dss.Tables[0].Rows[0]["zcount"].ToString(); uLevel0 = Convert.ToInt32(dss.Tables[0].Rows[0]["uLevel0"]); strdata += "\"topuser\":{\"id\":\"" + id2 + "\",\"dcid\":\"" + dcid + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"0\",\"ztsl\":\"" + tjcount + "\",\"jdcount\":\"" + jdcount + "\",\"hyzs\":\"" + zcount + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"zcsj\":\"" + RegTime + "\"}"; if (SuperiorsIDS != ",") { if (SuperiorsIDS.IndexOf("," + model.Id + ",") == -1 && id2 != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中\"}"; } } else { if (id2 != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中\"}"; } } } else { b = false; data = "{\"status\":0,\"msg\":\"账号不存在\"}"; } dss.Clear(); } else { if (id == 0) { hyid = userId; ccount = daoUser.GetCount("ContactID=" + model.Id + " and userstate='正常'"); ccount2 = daoUser.GetCount("SuperiorsIDS Like '%," + model.Id + ",%' and userstate='正常'"); strdata += "\"topuser\":{\"id\":\"" + model.Id + "\",\"dcid\":\"" + dcid + "\",\"UserName\":\"" + model.UserName + "\",\"RealName\":\"" + model.RealName + "\",\"ds\":\"0\",\"ztsl\":\"" + ccount + "\",\"hyzs\":\"" + ccount2 + "\",\"zyj\":\"" + model.umoney19 + "\",\"zt\":\"" + model.UserState + "\",\"zcsj\":\"" + model.RegTime + "\"}"; } else { dcid = -1; Mtxfw.Model.user_info model2 = daoUser.GetModel(hyid); if (model2 != null) { sycid = model2.SuperiorsID; ccount = daoUser.GetCount("ContactID=" + model2.Id + " and userstate='正常'"); ccount2 = daoUser.GetCount("SuperiorsIDS Like '%," + model2.Id + ",%' and userstate='正常'"); strdata += "\"topuser\":{\"id\":\"" + model2.Id + "\",\"dcid\":\"" + dcid + "\",\"UserName\":\"" + model2.UserName + "\",\"RealName\":\"" + model2.RealName + "\",\"ds\":\"" + (model2.uLevel0 - uLevel0) + "\",\"ztsl\":\"" + ccount + "\",\"hyzs\":\"" + ccount2 + "\",\"zyj\":\"" + model2.umoney19.ToString("f2") + "\",\"zt\":\"" + model2.UserState + "\",\"zcsj\":\"" + model2.RegTime + "\"}"; if (model2.SuperiorsIDS != ",") { if (model2.SuperiorsIDS.IndexOf("," + model.Id + ",") == -1 && model2.Id != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中2\"}"; } } else { if (model2.Id != model.Id) { b = false; data = "{\"status\":0,\"msg\":\"账号不存在您的网络图中2\"}"; } } } } } if (b) { strdata += ",\"muser\":["; DataSet ds = daoUser.GetList1("id,UserName,RealName,umoney19,UserState,regtime,uLevel0,(select count(*) from user_info b where b.ContactID=a.id and b.userstate='正常') as tjcount,(select count(*) from user_info b where b.SuperiorsID=a.id and b.userstate='正常') as jdcount,(select count(*) from user_info b where b.SuperiorsIDS like '%,' + convert(varchar(50),a.id) + ',%' and b.userstate='正常') as zcount", "uutype='0' And UserState='正常' And IFStores=0 And IFUpUserName=0 And SuperiorsID=" + hyid + " Order By regtime asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id2 = Convert.ToInt32(Dr["id"]); string UserName = Dr["UserName"].ToString(); string RealName = Dr["RealName"].ToString(); string umoney19 = Convert.ToDouble(Dr["umoney19"]).ToString("f2"); string UserState = Dr["UserState"].ToString(); string RegTime = Dr["RegTime"].ToString(); string tjcount = Dr["tjcount"].ToString(); string jdcount = Dr["jdcount"].ToString(); string zcount = Dr["zcount"].ToString(); int suLevel0 = Convert.ToInt32(Dr["uLevel0"]) - uLevel0; strdata += "{\"id\":\"" + id2 + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"" + suLevel0 + "\",\"ztsl\":\"" + tjcount + "\",\"jdcount\":\"" + jdcount + "\",\"hyzs\":\"" + zcount + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"zcsj\":\"" + RegTime + "\"}"; if (i < ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; data = "{\"status\":1,\"sycid\":\"" + sycid + "\"," + strdata + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //获取业绩排名----------------------------------------------------------------------------------------- /// /// 获取业绩排名 /// protected string getyjpm(HttpContext context) { int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { bool b = true; string strdata = ""; int pm = -1; if (b) { strdata += ",\"muser\":["; DataSet ds = daoUser.GetList1("top 10 id,UserName,RealName,NCName,UserPic,umoney19,UserState,regtime", "uutype='0' And UserState='正常' And IFStores=0 Order By umoney19 desc,regtime asc"); if (ds.Tables[0].Rows.Count > 0) { int i = 0; foreach (System.Data.DataRow Dr in ds.Tables[0].Rows) { int id2 = Convert.ToInt32(Dr["id"]); if(id2== model.Id) { pm = (i + 1); } string UserName = Dr["UserName"].ToString(); string RealName = Dr["RealName"].ToString(); string NCName = Dr["NCName"].ToString(); string UserPic = Dr["UserPic"].ToString(); string umoney19 = Convert.ToDouble(Dr["umoney19"]).ToString("f2"); string UserState = Dr["UserState"].ToString(); string RegTime = Dr["RegTime"].ToString(); if (NCName == "") { NCName = RealName; } strdata += "{\"id\":" + id2 + ",\"i\":" + i + ",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"NCName\":\"" + NCName + "\",\"UserPic\":\"" + (UserPic != "" ? config.webUrl + Mtxfw.Utility.Common.GetCoverPic(UserPic, "100x100", "cut") : "") + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"zcsj\":\"" + RegTime + "\"}"; if (i < ds.Tables[0].Rows.Count - 1) { strdata += ","; } i += 1; } } ds.Clear(); strdata += "]"; data = "{\"status\":1,\"pm\":"+ pm + ",\"pmzyj\":\"" + model.umoney19.ToString("f2") + "\"" + strdata + "}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //验证手机验证码是否正确----------------------------------------------------------------------------------------- /// /// 验证手机验证码是否正确 /// protected string checkcode(HttpContext context) { int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["code"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string code = HttpUtility.UrlDecode(context.Request["code"].ToString()); bool b = true; if (b) { if (model.PhoneNumber.ToLower() != code) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}"; } } if (b) { if (model.PhoneTime != null) { DateTime dt1 = DateTime.Now; DateTime dt2 = model.PhoneTime.AddMinutes(30); if (dt1 > dt2) { b = false; data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}"; } } } if (b) { data = "{\"status\":1,\"msg\":\"验证成功\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion #region //验证二级密码是否正确----------------------------------------------------------------------------------------- /// /// 验证二级密码是否正确 /// protected string checkpwd2(HttpContext context) { int e = 0; if (!String.IsNullOrEmpty(context.Request["e"])) { e = Convert.ToInt32(context.Request["e"].ToString()); } string data = "{\"status\":0}"; if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["pwd"])) { int userId = Convert.ToInt32(context.Request["userId"].ToString()); string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString()); Mtxfw.Model.user_info model = daoUser.GetModel(userId); if (model != null) { if (model.LoginId2 == LoginId) { string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString()); bool b = true; if (b) { if (model.Password == model.Password2) { b = false; data = "{\"status\":0,\"msg\":\"您的二级密码和登录密码相同,必须先修改才能查看!\"}"; } } if (b) { string password2 = Mtxfw.Utility.Security.DecryptString(model.Password2); if (password2 == "111111" || password2 == "222222" || password2 == "333333" || password2 == "444444" || password2 == "555555" || password2 == "666666" || password2 == "777777" || password2 == "888888" || password2 == "999999") { b = false; data = "{\"status\":0,\"msg\":\"您的二级密码太简单,必须先修改才能查看!\"}"; } } if (b) { if (model.Password != Mtxfw.Utility.Security.EncryptString(pwd)) { b = false; data = "{\"status\":0,\"msg\":\"二级密码不正确!\"}"; } } if (b) { data = "{\"status\":1,\"msg\":\"验证成功\"}"; } } else { data = "{\"status\":0,\"msg\":\"您未登录\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数错误\"}"; } } else { data = "{\"status\":0,\"msg\":\"参数为空\"}"; } return data; } #endregion protected string returndata(Mtxfw.Model.user_info umodel) { string strdata = ""; if (umodel != null) { DateTime dt = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string TXEnable = config.JJBTXEnable; if (TXEnable == "0") { DayOfWeek day = dt.DayOfWeek; string dayString = day.ToString().ToLower(); string HSJEnable = Mtxfw.Utility.Common.cweek(config.HSJEnable); if (config.HSJEnable.IndexOf(dayString) == -1) { TXEnable = "1"; } else { DateTime mintime = Convert.ToDateTime(Convert.ToDateTime(dt.ToShortDateString() + " " + config.UpdaeSJ1 + ":00").ToString("yyyy-MM-dd HH:mm:ss")); DateTime maxtime = Convert.ToDateTime(Convert.ToDateTime(dt.ToShortDateString() + " " + config.UpdaeSJ2 + ":59").ToString("yyyy-MM-dd HH:mm:ss")); if (dt < mintime || dt > maxtime) { TXEnable = "1"; } } } string ZZEnable = (umodel.uLevel47 == 1 ? "0" : config.JJBZZEnable); string ZZEnable0 = (umodel.uLevel47 == 1 ? "0" : config.DZBZZEnable); string ZZEnable1 = "1"; string ZCEnable = config.DZBZRDHBEnable; string ZHEnable = config.FHEnable2; string ZHEnable0 = config.FHEnable3; string ZHEnable1 = config.FHEnable6; string bdshEnable = config.JJBZRDHBEnable; string txzh = "开户姓名:" + umodel.ProductName + "
银行名称:" + umodel.RealName2 + "
银行卡号:" + umodel.Phone2 + "
开户行:" + umodel.PostalCode; int IFYGM = umodel.uLevel14; int uLevel = umodel.uLevel; string NCName = (umodel.NCName == "" ? umodel.RealName : umodel.NCName); string Phone = umodel.Phone; string UserPic = umodel.UserPic; string struLevel = Mtxfw.Utility.Common.GetuLevelname(umodel.uLevel); /*if (umodel.uLevel4 > 0) { struLevel += "-" + Mtxfw.Utility.Common.GetuLevel4name(umodel.uLevel4); }*/ string struLevel0 = ""; if (umodel.uLevel33 > 1) { struLevel0 = "推广员"; struLevel = "推广员"; } string struLevel1 = ""; string xjjye = Convert.ToDouble((umodel.umoney - umodel.umoney17).ToString("0.####")).ToString(); string tgmeye = umodel.umoney15.ToString("0.####"); string jhmye = umodel.umoney16.ToString("0.####"); string cfxfye = Convert.ToDouble((umodel.umoney22).ToString("0.####")).ToString(); string ggjfye = Convert.ToDouble((umodel.umoney29).ToString("0.####")).ToString(); string mfye = Convert.ToDouble((umodel.umoney30).ToString("0.####")).ToString(); string gxzye = Convert.ToDouble((umodel.umoney31).ToString("0.####")).ToString(); string xjye = Convert.ToDouble((umodel.umoney32).ToString("0.####")).ToString(); string hyzye = Convert.ToDouble((umodel.umoney33).ToString("0.####")).ToString(); string ksdye = Convert.ToDouble((umodel.umoney34).ToString("0.####")).ToString(); string lljye = Convert.ToDouble((umodel.umoney38).ToString("0.####")).ToString(); string ggzye = Convert.ToDouble((umodel.umoney36).ToString("0.####")).ToString(); string zzedze = Convert.ToDouble((umodel.umoney27).ToString("0.####")).ToString(); string zzedye = Convert.ToDouble((umodel.umoney28).ToString("0.####")).ToString(); string zzjfye = Convert.ToDouble((umodel.umoney37).ToString("0.####")).ToString(); string hkksye = Convert.ToDouble((umodel.umoney39).ToString("0.####")).ToString(); string hkdjye = Convert.ToDouble((umodel.umoney40).ToString("0.####")).ToString(); string hkjdye = Convert.ToDouble((umodel.umoney41).ToString("0.####")).ToString(); string btjye = Convert.ToDouble((umodel.umoney47).ToString("0.####")).ToString(); string btzye = Convert.ToDouble((umodel.umoney52).ToString("0.####")).ToString(); int iftx = 0; int IFEditBank = 0; if (umodel.RealName2 == "" || umodel.Phone2 == "") { IFEditBank = 1; } string yqm = Mtxfw.Utility.Security.encrypt(umodel.Id).ToString(); string zsymoney = umodel.umoney23.ToString("0.####"), jrsymoney = umodel.umoney24.ToString("0.####"), zrsymoney = umodel.umoney25.ToString("0.####"); Double zhsxf = 0.00; //zhsxf = Mtxfw.Utility.Common.GetSXF(umodel.uLevel, config); zhsxf = Convert.ToDouble(zhsxf.ToString("0.####")); if (zhsxf < 0.00) { zhsxf = 0.00; } int wgkcount = 0, ygkcount = umodel.uLevel20, wgkcount0 = 0, ygkcount0 = umodel.uLevel23; strdata = "\"userInfo\":{\"id\":\"" + umodel.Id + "\",\"openid\":\"" + umodel.openid + "\",\"yaoqingma\":\"" + Mtxfw.Utility.Security.encrypt(umodel.Id) + "\",\"IFYGM\":" + IFYGM + ",\"IFEditBank\":" + IFEditBank + ",\"IFPhone\":" + (Phone == "" ? 0 : 1) + ",\"yqm\":\"" + yqm + "\",\"uLevel\":\"" + struLevel + "\",\"uLevel0\":\"" + struLevel0 + "\",\"uLevel1\":\"" + struLevel1 + "\",\"uLevel2\":" + umodel.uLevel2 + ",\"sjuLevel\":" + umodel.uLevel16 + ",\"sjuLevel0\":" + umodel.uLevel30 + ",\"sjuLevel1\":" + umodel.uLevel39 + ",\"ifsmrz\":" + umodel.uLevel18 + ",\"dluLevel\":" + umodel.uLevel25 + ",\"tgyuLevel\":" + (umodel.uLevel33 > 1 ? 3 : umodel.uLevel33) + ",\"ifyjhsj\":" + umodel.uLevel34 + ",\"yjhsjnum\":" + umodel.uLevel35 + ",\"Paypush\":\"" + umodel.uLevel36 + "\",\"UserName\":\"" + umodel.UserName + "\",\"NCName\":\"" + NCName + "\",\"RealName\":\"" + umodel.RealName + "\",\"Phone\":\"" + Phone + "\",\"Email\":\"" + umodel.Email + "\",\"UserPic\":\"" + (UserPic != "" ? Mtxfw.Utility.Common.cminimage(UserPic) : "") + "\",\"Province\":\"" + umodel.Province + "\",\"City\":\"" + umodel.City + "\",\"County\":\"" + umodel.County + "\",\"ifywc\":" + umodel.uLevel19 + ",\"wgkcount\":" + wgkcount + ",\"ygkcount\":" + ygkcount + ",\"wgkcount0\":" + wgkcount0 + ",\"ygkcount0\":" + ygkcount0 + ",\"zsymoney\":\"" + zsymoney + "\",\"jrsymoney\":\"" + jrsymoney + "\",\"zrsymoney\":\"" + zrsymoney + "\",\"xjye\":\"" + xjye + "\",\"xjjye\":\"" + xjjye + "\",\"jhmye\":\"" + jhmye + "\",\"tgmeye\":\"" + tgmeye + "\",\"mfye\":\"" + mfye + "\",\"ggjfye\":\"" + ggjfye + "\",\"gxzye\":\"" + gxzye + "\",\"hyzye\":\"" + hyzye + "\",\"ksdye\":\"" + ksdye + "\",\"lljye\":\"" + lljye + "\",\"ggzye\":\"" + ggzye + "\",\"zzedze\":\"" + zzedze + "\",\"zzedye\":\"" + zzedye + "\",\"zzjfye\":\"" + zzjfye + "\",\"hkksye\":\"" + hkksye + "\",\"hkdjye\":\"" + hkdjye + "\",\"hkjdye\":\"" + hkjdye + "\",\"btjye\":\"" + btjye + "\",\"btzye\":\"" + btzye + "\",\"GGEnable\":\"" + config.FHEnable1 + "\",\"TXEnable\":\"" + TXEnable + "\",\"ZZEnable\":\"" + ZZEnable + "\",\"ZZEnable0\":\"" + ZZEnable0 + "\",\"ZZEnable1\":\"" + ZZEnable1 + "\",\"ZCEnable\":\"" + ZCEnable + "\",\"ZHEnable\":\"" + ZHEnable + "\",\"ZHEnable0\":\"" + ZHEnable0 + "\",\"ZHEnable1\":\"" + ZHEnable1 + "\",\"FHEnable\":\"" + config.FHEnable + "\",\"bdshEnable\":\"" + bdshEnable + "\",\"zhsxf\":\"" + zhsxf.ToString() + "\",\"ksdjg\":\"" + config.webMoney79 + "\",\"KHName\":\"" + umodel.ProductName + "\",\"BankName\":\"" + umodel.RealName2 + "\",\"BankCard\":\"" + umodel.Phone2 + "\",\"BankKHH\":\"" + umodel.PostalCode + "\",\"AliAccount\":\"" + umodel.AliAccount + "\",\"AliName\":\"" + umodel.AliName + "\",\"aliimage\":\"" + (umodel.aliimage == "" ? "" : Mtxfw.Utility.Common.cmaximage(umodel.aliimage)) + "\",\"weixinimage\":\"" + (umodel.weixinimage == "" ? "" : Mtxfw.Utility.Common.cmaximage(umodel.weixinimage)) + "\",\"qbaddress\":\"" + umodel.qbaddress + "\",\"ifshowzzjf\":\"1\",\"txtype\":\"" + config.HFHEnable + "\",\"txsxf\":\"" + config.webMoney50 + "\",\"txsxf0\":\"" + config.webMoney51 + "\",\"iftx\":\"" + iftx + "\",\"txtype\":\"" + config.CQEnable + "\",\"txmsg\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney64)) + "\",\"txmsg0\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney93)) + "\",\"zzmsg\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney94)) + "\",\"zzmsg0\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney95)) + "\",\"zzmsg1\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney96)) + "\",\"zzmsg2\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney97)) + "\",\"czmsg\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney152)) + "\",\"upmsg\":\"" + Mtxfw.Utility.Common.ReplaceString(Mtxfw.Utility.Common.InputText(config.webMoney102)) + "\",\"tpaddress\":\"" + config.webMoney47 + "\",\"aliimage0\":\"" + (config.webMoney55 == "" ? "" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(config.webMoney55, "1000x1000", config.webImgMode)) + "\",\"weixinimage0\":\"" + (config.webMoney56 == "" ? "" : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(config.webMoney56, "1000x1000", config.webImgMode)) + "\"}"; } return strdata; } public object FromProvincedataJson(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromhjpay_returnsJson(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromhjpay_returnsJson0(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromhjpay_rc_Result(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromkjpay_returns(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromkjpay_returns_SendSMSdata(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromkjpay_returns_SendSMSdata0(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromkjpay_Sign_returns(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromkjpay_returns_Signdata(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromkjpay_returns_Signdata0(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object FromhuifuresultJson(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromhuifuresult1Json(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public object Fromhuifuresult2Json(string json) { JavaScriptSerializer js = new JavaScriptSerializer(); return js.Deserialize(json); } public bool IsReusable { get { return false; } } } public class guiges { public String id { get; set; } public String gg { get; set; } public String jg { get; set; } public String jg0 { get; set; } public String jg1 { get; set; } public String jg2 { get; set; } public String jg4 { get; set; } public String jf { get; set; } public String zl { get; set; } public String kc { get; set; } public List colors { get; set; } public List images { get; set; } } public class tocolors { public String color { get; set; } public String kc { get; set; } } public class toimages { public String pic { get; set; } public String color { get; set; } } public class WXticket { public String ticket { get; set; } public String expire_seconds { get; set; } public String url { get; set; } } public class WXcode2Session { public String openid { get; set; } public String session_key { get; set; } } public class WXphoneNumber { public String phoneNumber { get; set; } } public class msg_sec_check { public String errcode { get; set; } } public class hjpay_returns { public String r2_OrderNo { get; set; } public Decimal r3_Amount { get; set; } public String ra_Code { get; set; } public String rb_CodeMsg { get; set; } public String rc_Result { get; set; } } public class hjpay_NATIVEreturns { public String r2_OrderNo { get; set; } public Decimal r3_Amount { get; set; } public String ra_Code { get; set; } public String rb_CodeMsg { get; set; } public String rc_Result { get; set; } public String rd_Pic { get; set; } } public class hjpay_rc_Result { public String appId { get; set; } public String timeStamp { get; set; } public String nonceStr { get; set; } public String package { get; set; } public String paySign { get; set; } public String signType { get; set; } } public class kjpay_returns { public String resp_code { get; set; } public String biz_code { get; set; } public String biz_msg { get; set; } public String data { get; set; } } public class kjpay_returns_SendSMSdata { public String mch_order_no { get; set; } public String order_status { get; set; } public String jp_order_no { get; set; } } public class kjpay_returns_SendSMSdata0 { public String mch_order_no { get; set; } public String order_status { get; set; } public String jp_order_no { get; set; } public String err_code { get; set; } public String err_msg { get; set; } } public class kjpay_Sign_returns { public String resp_code { get; set; } public String biz_code { get; set; } public String biz_msg { get; set; } public String data { get; set; } } public class kjpay_returns_Signdata { public String mch_order_no { get; set; } public String order_status { get; set; } public String jp_order_no { get; set; } public String sign_no { get; set; } public String bank_code { get; set; } } public class kjpay_returns_Signdata0 { public String mch_order_no { get; set; } public String order_status { get; set; } public String jp_order_no { get; set; } public String sign_no { get; set; } public String err_code { get; set; } public String err_msg { get; set; } } public class kjpay_returns_gzhdata { public String appId { get; set; } public String timeStamp { get; set; } public String nonceStr { get; set; } public String package { get; set; } public String signType { get; set; } public String paySign { get; set; } } }