(json);
}
#endregion
#region //获取地址列表-----------------------------------------------------------------------------------------
///
/// 获取地址列表
///
protected string getAddress(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.LoginId == LoginId)
{
string strdata = "";
DataSet ds = new Mtxfw.DAL.user_address().GetList1("id,Contactname,Contacttel,IFFill,Tradingarea,Address,IFIndex,Province,City,County,Zipcode", "gtype=" + gtype + " and 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 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 detail = Dr["Address"].ToString();
string IFIndex = Dr["IFIndex"].ToString();
strdata += "{\"addressId\":\"" + _id + "\",\"contact\":\"" + contact + "\",\"tel\":\"" + tel + "\",\"Province\":\"" + Province + "\",\"City\":\"" + City + "\",\"County\":\"" + County + "\",\"IFFill\":\"" + IFFill + "\",\"Tradingarea\":\"" + Tradingarea + "\",\"detail\":\"" + detail + "\",\"IFIndex\":\"" + IFIndex + "\"}";
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\":\"参数为空\"}";
}
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.LoginId == 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);// or MemberId in(Select id from user_info b where b.gtype=" + gtype + " and b.IFStores=0 and (b.UserName like '%" + keyword + "%' or b.realname like '%" + keyword + "%'))
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 + "\",\"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}";
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 = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
new DAL.user_address().UpdateIFIndex(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 deleteAddress(HttpContext context)
{
string data = "{\"status\":0}";
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 = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == 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}";
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 = HttpUtility.UrlDecode(context.Request["contact"].ToString()).Replace("'","").Replace("\"","");
string tel = HttpUtility.UrlDecode(context.Request["tel"].ToString());
bool b = true;
string Province = HttpUtility.UrlDecode(context.Request["Province"].ToString());
string City = "", County = "", Tradingarea = "";
if (!String.IsNullOrEmpty(context.Request["City"]))
{
City = HttpUtility.UrlDecode(context.Request["City"].ToString());
if (City != "")
{
City = City.Replace("null", "");
}
}
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", "");
}
}
int IFFill = 0;
if (!String.IsNullOrEmpty(context.Request["IFFill"]))
{
string strIFFill = context.Request["IFFill"].ToString();
if (System.Text.RegularExpressions.Regex.IsMatch(strIFFill, @"^-?\d+$"))
{
IFFill = Convert.ToInt32(strIFFill);
}
}
if (!String.IsNullOrEmpty(context.Request["Tradingarea"]))
{
Tradingarea = HttpUtility.UrlDecode(context.Request["Tradingarea"].ToString());
if (Tradingarea != "")
{
Tradingarea = Tradingarea.Replace("null", "");
}
}
if (County == "")
{
if (b)
{
if (new Mtxfw.DAL.county().GetCount("CityID='" + City + "'") > 0)
{
b = false;
data = "{\"status\":0,\"msg\":\"县区未选择!\"}";
}
}
}
string detail = HttpUtility.UrlDecode(context.Request["detail"].ToString()).Replace("'","").Replace("\"","");
if (b)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
if (new DAL.user_address().GetCount("UserID=" + model.Id) < 5)
{
Model.user_address amodel = new Model.user_address();
amodel.Contactname = contact;
amodel.Contacttel = tel;
amodel.Province = Province;
amodel.City = City;
amodel.County = County;
amodel.IFFill = IFFill;
amodel.Tradingarea = Tradingarea;
amodel.Address = detail;
amodel.Zipcode = "";
amodel.Guests = "";
amodel.IFIndex = 0;
amodel.UserID = model.Id;
amodel.gtype = gtype;
amodel.Id = new DAL.user_address().Add(amodel);
new DAL.user_address().UpdateIFIndex(amodel.Id, amodel.UserID);
data = "{\"status\":1,\"msg\":\"添加成功!\",\"addressId\":\"" + amodel.Id + "\"," + returndata(model) + "}";
}
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}";
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 = HttpUtility.UrlDecode(context.Request["contact"].ToString()).Replace("'","").Replace("\"","");
string tel = HttpUtility.UrlDecode(context.Request["tel"].ToString());
bool b = true;
string Province = HttpUtility.UrlDecode(context.Request["Province"].ToString());
string City = "", County = "", Tradingarea = "";
if (!String.IsNullOrEmpty(context.Request["City"]))
{
City = HttpUtility.UrlDecode(context.Request["City"].ToString());
if (City != "")
{
City = City.Replace("null", "");
}
}
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", "");
}
}
int IFFill = 0;
if (!String.IsNullOrEmpty(context.Request["IFFill"]))
{
string strIFFill = context.Request["IFFill"].ToString();
if (System.Text.RegularExpressions.Regex.IsMatch(strIFFill, @"^-?\d+$"))
{
IFFill = Convert.ToInt32(strIFFill);
}
}
if (!String.IsNullOrEmpty(context.Request["Tradingarea"]))
{
Tradingarea = HttpUtility.UrlDecode(context.Request["Tradingarea"].ToString());
if (Tradingarea != "")
{
Tradingarea = Tradingarea.Replace("null", "");
}
}
if (County == "")
{
if (b)
{
if (new Mtxfw.DAL.county().GetCount("CityID='" + City + "'") > 0)
{
b = false;
data = "{\"status\":0,\"msg\":\"县区未选择!\"}";
}
}
}
string detail = HttpUtility.UrlDecode(context.Request["detail"].ToString()).Replace("'","").Replace("\"","");
if (b)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
Model.user_address amodel = new DAL.user_address().GetModel(addressId);
if (amodel != null)
{
amodel.Contactname = contact;
amodel.Contacttel = tel;
amodel.Province = Province;
amodel.City = City;
amodel.County = County;
amodel.IFFill = IFFill;
amodel.Tradingarea = Tradingarea;
amodel.Address = detail;
new DAL.user_address().Update(amodel);
data = "{\"status\":1,\"msg\":\"修改成功!\"," + returndata(model) + "}";
}
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.LoginId == LoginId)
{
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 = daoorder.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();
daoorder.UpdateqyState(0, "-1", DateTime.Now, ModelOrder.Id);
daoorderproduct.UpdateIFDelete(1, DateTime.Now.ToString(), ModelOrder.Id);
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 editpwd(HttpContext context)
{
string data = "{\"status\":0}";
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 = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
bool b = true;
if (b)
{
if (String.IsNullOrEmpty(context.Request["oldpwd"]) && String.IsNullOrEmpty(context.Request["code"]))
{
b = false;
data = "{\"status\":0,\"msg\":\"参数不能为空0!\"}";
}
}
if (b)
{
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 (!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\":\"旧密码不正确!\"}";
}
}
}
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\":\"新密码输入不正确,密码由6-16位数字、字母、下划线组成!\"}";
}
}
if (b)
{
daoUser.UpdatePassword("password", Mtxfw.Utility.Security.EncryptString(newpwd), model.Id);
daoUser.UpdatePhoneTime3("", 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 = (ifweb==0?"app":"web") + "修改登录密码";
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\":\"参数错误2!\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空!\"}";
}
return data;
}
#endregion
#region //修改安全密码----------------------------------------------------------------------------------
///
/// 修改安全密码
///
protected string editpwd2(HttpContext context)
{
string data = "{\"status\":0}";
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 = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
bool b = true;
if (b)
{
if (String.IsNullOrEmpty(context.Request["oldpwd"]) && String.IsNullOrEmpty(context.Request["code"]))
{
b = false;
data = "{\"status\":0,\"msg\":\"参数不能为空0!\"}";
}
}
if (b)
{
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 (!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\":\"旧密码不正确!\"}";
}
}
}
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\":\"新密码输入不正确,密码由6-16位数字、字母、下划线组成!\"}";
}
}
if (b)
{
if (Mtxfw.Utility.Security.EncryptString(newpwd) == model.Password)
{
b = false;
data = "{\"status\":0,\"msg\":\"安全密码不能跟登录密码相同!\"}";
}
}
if (b)
{
if (Mtxfw.Utility.Security.EncryptString(newpwd) == model.Password2)
{
b = false;
data = "{\"status\":0,\"msg\":\"新密码不能跟旧密码相同!\"}";
}
}
if (b)
{
new Mtxfw.DAL.user_info().UpdatePassword("password2", Mtxfw.Utility.Security.EncryptString(newpwd), model.Id);
daoUser.UpdatePhoneTime3("", 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 = (ifweb==0?"app":"web") + "修改安全密码";
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\":\"参数错误2!\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误!\"}";
}
return data;
}
#endregion
#region //修改手机号码-----------------------------------------------------------------------------------------
///
/// 修改手机号码
///
protected string editphone(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["oldphone"]) && !String.IsNullOrEmpty(context.Request["usercode"]) && !String.IsNullOrEmpty(context.Request["usercode2"]) && !String.IsNullOrEmpty(context.Request["newphone"]) && !String.IsNullOrEmpty(context.Request["yzid"]))
{
int userId = Convert.ToInt32(context.Request["userId"].ToString());
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
string oldphone = HttpUtility.UrlDecode(context.Request["oldphone"].ToString());
string usercode = HttpUtility.UrlDecode(context.Request["usercode"].ToString());
string usercode2 = HttpUtility.UrlDecode(context.Request["usercode2"].ToString());
string newphone = HttpUtility.UrlDecode(context.Request["newphone"].ToString());
string yzid = HttpUtility.UrlDecode(context.Request["yzid"].ToString());
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
bool b = true;
if (!System.Text.RegularExpressions.Regex.IsMatch(newphone, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$"))
{
b = false;
data = "{\"status\":0,\"msg\":\"新手机号码格式填写不正确!\"}";
}
if (b)
{
if (model.Phone != newphone && daoUser.IsExistsmobile(newphone, gtype))
{
b = false;
data = "{\"status\":0,\"msg\":\"新手机号码被其它用户占用!\"}";
}
}
if (model.PhoneNumber.ToLower() != usercode)
{
b = false;
data = "{\"status\":0,\"msg\":\"旧手机验证码不正确!\"}";
}
if (b)
{
DateTime dt1 = DateTime.Now;
DateTime dt2 = model.PhoneTime.AddMinutes(30);
if (dt1 > dt2)
{
b = false;
data = "{\"status\":0,\"msg\":\"旧手机验证码已经失效!\"}";
}
}
if (b)
{
if (new DAL.user_YZMs().GetCount("gtype=" + gtype + " and utype=0 And YZID=\"" + yzid + "\" And phone=\"" + newphone + "\" And YZM=\"" + usercode2 + "\"") == 0)
{
b = false;
data = "{\"status\":0,\"msg\":\"新手机验证码输入不正确!\"}";
}
}
if (b)
{
new Mtxfw.DAL.user_info().UpdatePassword("phone", newphone, model.Id);
new Mtxfw.DAL.user_info().UpdatePhoneTime3("", model.Id);
new DAL.user_YZMs().Delete("gtype=" + gtype + " and utype=0 And YZID=\"" + yzid + "\" And phone=\"" + newphone + "\" And YZM=\"" + usercode2 + "\"");
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 = (ifweb==0?"app":"web") + "修改手机号";
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\":\"参数错误2!\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误!\"}";
}
return data;
}
#endregion
#region //发布新动态-----------------------------------------------------------------------------------------
///
/// 发布新动态
///
protected string adddongtai(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && context.Request["explain"] != null)
{
int userId = Convert.ToInt32(context.Request["userId"].ToString());
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
string explain = HttpUtility.UrlDecode(context.Request["explain"].ToString());
string images = "";
if (!String.IsNullOrEmpty(context.Request["image"]))
{
images = context.Request["image"].ToString();
}
int dtid = 0;
if (!String.IsNullOrEmpty(context.Request["dtid"]))
{
dtid = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["dtid"].ToString()));
}
bool b = true;
int wtype = 0;
if (dtid > 0)
{
explain = (explain == "" ? "转发动态" : explain);
Mtxfw.Model.Article amodel = new Mtxfw.DAL.Article().GetModel(dtid);
if (amodel != null)
{
if (amodel.CategoryId != "" && amodel.CategoryId != "0")
{
dtid = Convert.ToInt32(amodel.CategoryId);
}
wtype = amodel.wtype;
if (new DAL.Article().GetCount("ParentID=22 And senderid=" + userId + " And CategoryId='" + dtid + "'") > 0)
{
b = false;
data = "{\"status\":0,\"msg\":\"请不要频繁操作!\"}";
}
}
else
{
b = false;
data = "{\"status\":0,\"msg\":\"参数错误3!\"}";
}
}
if (b)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
Mtxfw.Model.Article Amodel = new Mtxfw.Model.Article();
Amodel.senderid = model.Id;
Amodel.receiverid = 0;
Amodel.Title = "新动态";
Amodel.ParentID = 22;
Amodel.CategoryId = dtid.ToString();
Amodel.AddTime = DateTime.Now;
Amodel.Author = "";
Amodel.Content = explain;
Amodel.Paths = "";
Amodel.Content2 = images;
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 = (ifweb==0?"app":"web") + "发布新动态,信息内容:" + explain;
logmodel.UType = 1;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
if (dtid > 0)
{
new DAL.Article().UpdateuSel("wtype", wtype + 1, dtid);
}
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 getdongtailist(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.LoginId == LoginId)
{
string strdata = "";
string strsql=" And hasRead=1";
if (t == 1)
{
strsql = " And categoryid='0' And senderid<>" + model.Id;
}
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,senderid,CategoryId,title,content,content2,addtime,wtype,wtype2,LinkID,(select UserName from user_info b where b.id=senderid) as UserName,(select NCName from user_info b where b.id=senderid) as NCName,(select UserPic from user_info b where b.id=senderid) as UserPic", "", "gtype=" + gtype + " And parentid=22 " + 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 senderid = Convert.ToInt32(Dr["senderid"]);
int hasRead = Convert.ToInt32(Dr["hasRead"]);
string title = Dr["title"].ToString();
string CategoryId = Dr["CategoryId"].ToString();
string content = Dr["content"].ToString();
string images = Dr["content2"].ToString();
string addtime = Dr["addtime"].ToString();
string wtype = Dr["wtype"].ToString();
string wtype2 = Dr["wtype2"].ToString();
string LinkID = Dr["LinkID"].ToString();
string UserName = Dr["UserName"].ToString();
string NCName = Dr["NCName"].ToString().Trim();
if (images != "")
{
content += "";
string[] aimages = images.Split('|');
foreach (string strimg in aimages)
{
if (strimg != "")
{
content += "
";
//Mtxfw.Utility.Common.WriteHtml("/weixin/webUrl.txt", config.webUrl + Mtxfw.Utility.Common.GetCoverPic(strimg, "100x100", "cut"));
}
}
content += "
";
}
if (NCName == "")
{
NCName = UserName;
}
if (CategoryId == "")
{
CategoryId = "0";
}
string content2 = "", addtime2 = "", UserPic2 = "", NCName2 = "";
if (CategoryId != "0")
{
Mtxfw.Model.Article amodel = new Mtxfw.DAL.Article().GetModel(Convert.ToInt32(CategoryId));
if (amodel != null)
{
content2 = amodel.Content;
if (amodel.Content2 != "")
{
content2 += "";
string[] aimages = amodel.Content2.Split('|');
foreach (string strimg in aimages)
{
if (strimg != "")
{
content2 += "
";
}
}
content += "
";
}
if (NCName == "")
{
NCName = UserName;
}
if (CategoryId == "")
{
CategoryId = "0";
}
string content2 = "", addtime2 = "", UserPic2 = "", NCName2 = "";
if (CategoryId != "0")
{
Mtxfw.Model.Article amodel = new Mtxfw.DAL.Article().GetModel(Convert.ToInt32(CategoryId));
if (amodel != null)
{
content2 = amodel.Content;
if (amodel.Content2 != "")
{
content2 += "";
string[] aimages = amodel.Content2.Split('|');
foreach (string strimg in aimages)
{
if (strimg != "")
{
content2 += "
";
}
}
content2 += "
";
}
addtime2 = amodel.AddTime.ToString();
Mtxfw.Model.user_info model2 = new Mtxfw.DAL.user_info().GetModel(amodel.senderid);
if (model2 != null)
{
UserPic2 = model2.UserPic;
NCName2 = model2.NCName;
if (NCName2 == "")
{
NCName2 = model2.UserName;
}
}
}
}
int IFGZ = 0;
if (new DAL.user_favorite().GetCount("gtype=" + gtype + " and ttype=3 And MemberId=" + model.Id + " And ProductID=" + senderid) > 0)
{
IFGZ = 1;
}
string UserPic = Dr["UserPic"].ToString().Trim();
strdata += "{\"hasRead\":\"" + (hasRead == 1 ? "false" : "true") + "\",\"id\":\"" + id + "\",\"CategoryId\":" + CategoryId + ",\"title\":\"" + title + "\",\"content\":\"" + content.Replace("\"", "\\\"") + "\",\"content2\":\"" + content2.Replace("\"", "\\\"") + "\",\"createTime\":\"" + addtime + "\",\"createTime2\":\"" + addtime2 + "\",\"zforders\":\"" + wtype + "\",\"dzorders\":\"" + wtype2 + "\",\"plorders\":\"" + LinkID + "\",\"userid\":" + senderid + ",\"IFGZ\":" + IFGZ + ",\"NCName\":\"" + NCName + "\",\"NCName2\":\"" + NCName2 + "\",\"avatar\":\"" + (UserPic == "" ? "" : Mtxfw.Utility.Common.GetCoverPic(UserPic, "40x40", "cut")) + "\",\"avatar2\":\"" + (UserPic2 == "" ? "" : Mtxfw.Utility.Common.GetCoverPic(UserPic2, "40x40", "cut")) + "\"}";
i += 1;
}
}
ds.Clear();
}
string groupby = "";
string strOrder = "addtime desc";
Int32 Recount = 0;
ds = new Mtxfw.DAL.Article().GetDataSet(groupby, strOrder, "id,hasRead,CategoryId,title,content,addtime,wtype,wtype2,LinkID,(select UserName from user_info b where b.id=senderid) as UserName,(select NCName from user_info b where b.id=senderid) as NCName,(select UserPic from user_info b where b.id=senderid) as UserPic", "", "gtype=" + gtype + " and parentid=23 And categoryid=" + dtid + "", Start, Limit, out 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 CategoryId = Dr["CategoryId"].ToString();
string content = Dr["content"].ToString();
string addtime = Dr["addtime"].ToString();
string wtype = Dr["wtype"].ToString();
string wtype2 = Dr["wtype2"].ToString();
string LinkID = Dr["LinkID"].ToString();
string UserName = Dr["UserName"].ToString();
string NCName = Dr["NCName"].ToString().Trim();
if (NCName == "")
{
NCName = UserName;
}
if (CategoryId == "")
{
CategoryId = "0";
}
string content2 = "";
if (CategoryId != "0")
{
Mtxfw.Model.Article amodel = new Mtxfw.DAL.Article().GetModel(Convert.ToInt32(CategoryId));
if (amodel != null)
{
content2 = amodel.Content;
}
}
string UserPic = Dr["UserPic"].ToString().Trim();
strdata2 += "{\"hasRead\":\"" + (hasRead == 1 ? "false" : "true") + "\",\"id\":\"" + id + "\",\"CategoryId\":" + CategoryId + ",\"title\":\"" + title + "\",\"content\":\"" + content.Replace("\"", "\\\"") + "\",\"content2\":\"" + content2.Replace("\"", "\\\"") + "\",\"createTime\":\"" + addtime + "\",\"zforders\":\"" + wtype + "\",\"dzorders\":\"" + wtype2 + "\",\"plorders\":\"" + LinkID + "\",\"NCName\":\"" + NCName + "\",\"avatar\":\"" + (UserPic == "" ? "" : Mtxfw.Utility.Common.GetCoverPic(UserPic, "40x40", "cut")) + "\"}";
if (i != ds.Tables[1].Rows.Count - 1)
{
strdata2 += ",";
}
i += 1;
}
}
ds.Clear();
data = "{\"status\":1,\"data\":" + strdata + ",\"pldata\":[" + strdata2 + "]}";
}
else
{
data = "{\"status\":0,\"msg\":\"您未登录\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //添加动态评论-----------------------------------------------------------------------------------------
///
/// 添加动态评论
///
protected string adddongtaipl(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && context.Request["explain"] != null && context.Request["dtid"] != null)
{
int userId = Convert.ToInt32(context.Request["userId"].ToString());
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
string explain = HttpUtility.UrlDecode(context.Request["explain"].ToString());
int dtid = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["dtid"].ToString()));
string images = "";
bool b = true;
int wtype = 0;
if (b)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
Mtxfw.Model.Article amodel = new Mtxfw.DAL.Article().GetModel(dtid);
if (amodel != null)
{
Mtxfw.Model.Article Amodel = new Mtxfw.Model.Article();
Amodel.senderid = model.Id;
Amodel.receiverid = 0;
Amodel.Title = "动态评论";
Amodel.ParentID = 23;
Amodel.CategoryId = dtid.ToString();
Amodel.AddTime = DateTime.Now;
Amodel.Author = "";
Amodel.Content = explain;
Amodel.Paths = "";
Amodel.Content2 = images;
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;
int returnid = 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 = (ifweb==0?"app":"web") + "动态评论,信息内容:" + explain;
logmodel.UType = 1;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
new DAL.Article().UpdateuSel("LinkID", amodel.LinkID + 1, dtid);
string NCName = model.NCName;
if (NCName == "")
{
NCName = model.UserName;
}
data = "{\"status\":1,\"msg\":\"保存成功!\",\"data\":{\"id\":" + returnid + ",\"content\":\"" + explain + "\",\"createTime\":\"" + DateTime.Now + "\",\"avatar\":\"" + (model.UserPic == "" ? "" : Mtxfw.Utility.Common.GetCoverPic(model.UserPic, "40x40", "cut")) + "\",\"NCName\":\"" + NCName + "\",\"dzorders\":\"0\"}}";
}
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 getmydongtailist(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.LoginId == 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.Article().GetDataSet(groupby, strOrder, "id,hasRead,senderid,CategoryId,title,content,content2,addtime,wtype,wtype2,LinkID,(select UserName from user_info b where b.id=senderid) as UserName,(select NCName from user_info b where b.id=senderid) as NCName,(select UserPic from user_info b where b.id=senderid) as UserPic", "", "gtype=" + gtype + " And parentid=22 And senderid=" + model.Id + "", Start, Limit, out Recount);
int dtcount = ds.Tables[1].Rows.Count;
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 senderid = Convert.ToInt32(Dr["senderid"]);
int hasRead = Convert.ToInt32(Dr["hasRead"]);
string title = Dr["title"].ToString();
string CategoryId = Dr["CategoryId"].ToString();
string content = Dr["content"].ToString();
string images = Dr["content2"].ToString();
string addtime = Dr["addtime"].ToString();
string wtype = Dr["wtype"].ToString();
string wtype2 = Dr["wtype2"].ToString();
string LinkID = Dr["LinkID"].ToString();
string UserName = Dr["UserName"].ToString();
string NCName = Dr["NCName"].ToString().Trim();
if (images != "")
{
content += "";
string[] aimages = images.Split('|');
foreach (string strimg in aimages)
{
if (strimg != "")
{
content += "
";
}
}
content += "
";
}
if (NCName == "")
{
NCName = UserName;
}
if (CategoryId == "")
{
CategoryId = "0";
}
string content2 = "", addtime2 = "", UserPic2 = "", NCName2 = "";
if (CategoryId != "0")
{
Mtxfw.Model.Article amodel = new Mtxfw.DAL.Article().GetModel(Convert.ToInt32(CategoryId));
if (amodel != null)
{
content2 = amodel.Content;
if (amodel.Content2 != "")
{
content2 += "";
string[] aimages = amodel.Content2.Split('|');
foreach (string strimg in aimages)
{
if (strimg != "")
{
content2 += "
0)
{
int i = 0;
foreach (System.Data.DataRow Dr in ds.Tables[1].Rows)
{
Int64 id = Convert.ToInt64(Dr["id"]);
int Seef = Convert.ToInt32(Dr["Seef"]);
string Addmoney = Convert.ToDouble(Dr["Addmoney"]).ToString("f2");
string Cutmoney = Convert.ToDouble(Dr["Cutmoney"]).ToString("f2");
string Totalmoney = Convert.ToDouble(Dr["Totalmoney"]).ToString("f2");
string BZContent = Dr["BZContent"].ToString();
string addtime = Dr["addtime"].ToString();
strdata += "{\"utype\":\"" + t + "\",\"id\":\"" + id + "\",\"IFUseed\":\"" + Seef + "\",\"Addmoney\":\"" + Addmoney + "\",\"Cutmoney\":\"" + Cutmoney + "\",\"Totalmoney\":\"" + Totalmoney + "\",\"BZContent\":\"" + BZContent.Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\"}";
if (i != ds.Tables[1].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
ds.Clear();
string zcze = "0.00";
Double umoney26 = model.umoney26;
umoney27 = model.umoney27;
if (t == 0)
{
zcze = model.umoney27.ToString("f2");
}
else if (t == 2)
{
zcze = (model.umoney28 - model.umoney29).ToString("f2");
}
else if (t == 3)
{
zcze = (model.umoney16).ToString("f2");
Double symoney = umoney27;
DataSet dss = new Mtxfw.DAL.user_Results_jl2().GetList1("Addmoney,OrdersIDs", "gtype=" + gtype + " and MemberId=" + model.Id + " and utype=3 and utype2=0 And IFDelete=0 And Seef=3 And Cutmoney>0 order by addtime asc");
if (dss.Tables[0].Rows.Count > 0)
{
foreach (System.Data.DataRow Drr in dss.Tables[0].Rows)
{
Double Addmoney = Convert.ToDouble(Drr["Addmoney"]);
Double Cutmoney = 0.00;
if (Drr["OrdersIDs"].ToString() != "")
{
Cutmoney = Convert.ToDouble(Convert.ToDouble(Drr["OrdersIDs"]).ToString("f2"));
}
umoney26 -= Cutmoney;
umoney27 -= Cutmoney;
zcze = (Convert.ToDouble(zcze) - Addmoney).ToString();
}
}
dss.Clear();
}
else if (t == 4)
{
zcze = (model.umoney36).ToString("f2");
}
else if (t == 6)
{
zcze = (model.umoney18).ToString("f2");
}
string syze = umoney26.ToString("f2");
string syzeed = umoney27.ToString("f2");
data = "{\"status\":1,\"data\":[" + strdata + "],\"data2\":[" + strdata2 + "],\"zcze\":\"" + zcze + "\",\"syze\":\"" + syze + "\",\"syzeed\":\"" + syzeed + "\",\"DZBZZEnable\":\"" + config.DZBZZEnable + "\",\"phone\":\"" + model.Phone + "\"}";
}
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 getjuancount(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.LoginId == LoginId)
{
int thjcount = new Mtxfw.DAL.user_Results_jl2().GetCount("gtype=" + gtype + " and MemberId=" + model.Id + " and utype=2");
int zcjcount = new Mtxfw.DAL.user_Results_jl2().GetCount("gtype=" + gtype + " and MemberId=" + model.Id + " and utype=3");
int xjjcount = new Mtxfw.DAL.user_Results_jl2().GetCount("gtype=" + gtype + " and MemberId=" + model.Id + " and utype=4");
int xfjcount = new Mtxfw.DAL.user_Results_jl2().GetCount("gtype=" + gtype + " and MemberId=" + model.Id + " and utype=5");
data = "{\"status\":1,\"thjcount\":" + thjcount + ",\"zcjcount\":" + zcjcount + ",\"xjjcount\":" + xjjcount + ",\"xfjcount\":" + xfjcount + "}";
}
}
}
return data;
}
#endregion
#region //获取客服-----------------------------------------------------------------------------------------
///
/// 获取客服
///
protected string getServerMsg(HttpContext context)
{
string data = "{\"status\":0}";
data = "" + Mtxfw.Utility.Common.InputText(config.ServerMsg) + "";
return data;
}
#endregion
#region //获取会员协议-----------------------------------------------------------------------------------------
///
/// 获取会员协议
///
protected string getxieyi(HttpContext context)
{
string data = "{\"status\":0}";
Mtxfw.Model.Article model = new Mtxfw.DAL.Article().GetModel(451);
if (model != null)
{
string strdata = "\"lifemuseu\":[";
DataSet ds = new Mtxfw.DAL.user_info().GetList1("id,AliAccount,lifeaddress", "gtype=" + gtype + " and 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 AliAccount = Dr["AliAccount"].ToString();
string lifeaddress = Dr["lifeaddress"].ToString();
strdata += "{\"id\":\"" + id2 + "\",\"AliAccount\":\"" + AliAccount + "\",\"lifeaddress\":\"" + lifeaddress + "\"}";
if (i < ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
ds.Clear();
strdata += "]";
data = "{\"status\":1,\"content\":\"" + Mtxfw.Utility.Common.ReplaceString(model.Content) + "\",\"IFShowlifemuseu\":" + config.FHEnable5 + "," + strdata + "}";
}
return data;
}
#endregion
#region //获取会员网络图谱-----------------------------------------------------------------------------------------
///
/// 获取会员网络图谱
///
protected string getmynetmap(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 keyword = "";
if (!String.IsNullOrEmpty(context.Request["keyword"]))
{
keyword = context.Request["keyword"].ToString();
}
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
bool b = true;
string strdata = "";
int ccount = 0, ccount2 = 0;
int sycid = 0, sycid1 = 0, hyid = model.Id;
int uLevel1 = model.uLevel1;
/*if (keyword != "")
{
DataSet dss = new Mtxfw.DAL.user_info().GetList1("id,UserName,RealName,SuperiorsID,SuperiorsIDS,DLRememberIDS,uLevel,uLevel1,uLevel14,umoney19,UserState,regtime", "gtype=" + gtype + " and uutype='0' And UserState='正常' And IFStores=0 and uLevel17=0 And UserName='" + keyword + "' Order By id asc");
if (dss.Tables[0].Rows.Count > 0)
{
int id2 = Convert.ToInt32(dss.Tables[0].Rows[0]["id"]);
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]["uLevel14"].ToString() == "1" ? "正常" : "未购买";
string RegTime = dss.Tables[0].Rows[0]["RegTime"].ToString();
string SuperiorsIDS = dss.Tables[0].Rows[0]["SuperiorsIDS"].ToString();
string DLRememberIDS = dss.Tables[0].Rows[0]["DLRememberIDS"].ToString();
string uLevel = Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(dss.Tables[0].Rows[0]["uLevel"]));
uLevel1 = Convert.ToInt32(dss.Tables[0].Rows[0]["uLevel1"]);
strdata += "\"topuser\":{\"id\":\"" + id2 + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"0\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"uLevel\":\"" + uLevel + "\",\"zcsj\":\"" + RegTime + "\"}";
if (SuperiorsIDS.IndexOf("," + model.Id + ",") == -1 && DLRememberIDS.IndexOf("," + model.Id + ",") == -1)
{
b = false;
data = "{\"status\":0,\"msg\":\"用户名不存在您的网络图中\"}";
}
}
else
{
b = false;
data = "{\"status\":0,\"msg\":\"用户名不存在\"}";
}
dss.Clear();
}
else
{
ccount = new Mtxfw.DAL.user_info().GetCount("SuperiorsID=" + model.Id + " and userstate='正常'");
ccount2 = new Mtxfw.DAL.user_info().GetCount("SuperiorsIDS Like '%," + model.Id + ",%' and userstate='正常'");
strdata += "\"topuser\":{\"id\":\"" + model.Id + "\",\"UserName\":\"" + model.UserName + "\",\"RealName\":\"" + model.RealName + "\",\"ds\":\"0\",\"ztsl\":\"" + ccount + "\",\"hyzs\":\"" + ccount2 + "\",\"zyj\":\"" + model.umoney19 + "\",\"zt\":\"" + (model.uLevel14 == 1 ? "正常" : "未购买") + "\",\"uLevel\":\"" + Mtxfw.Utility.Common.GetuLevelname(model.uLevel) + "\",\"zcsj\":\"" + model.RegTime + "\"}";
}
string strbusr1 = "[", strbusr2 = "[", strbusr3 = "[";
if (b)
{
strdata += ",\"muser\":[";
DataSet ds = new Mtxfw.DAL.user_info().GetList1("id,UserName,RealName,umoney19,UserState,regtime,uLevel,uLevel1,uLevel14", "gtype=" + gtype + " and uutype='0' And UserState='正常' And IFStores=0 and uLevel17=0 And SuperiorsID=" + hyid + " Order By id 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["uLevel14"].ToString()=="1"?"正常":"未购买";
string uLevel = Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(Dr["uLevel"]));
string RegTime = Dr["RegTime"].ToString();
int suLevel1 = Convert.ToInt32(Dr["uLevel1"]) - uLevel1;
strdata += "{\"id\":\"" + id2 + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"" + suLevel1 + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"uLevel\":\"" + uLevel + "\",\"zcsj\":\"" + RegTime + "\"}";
DataSet ds2 = new Mtxfw.DAL.user_info().GetList1("id,UserName,RealName,umoney19,UserState,regtime,uLevel,uLevel1,uLevel14,(select count(*) from user_info b where b.SuperiorsID=a.id and b.userstate='正常' and b.uLevel17=0) as tjcount", "uutype='0' And UserState='正常' And IFStores=0 and uLevel17=0 And ContactID=" + id2 + " Order By id asc");
if (ds2.Tables[0].Rows.Count > 0)
{
int i2 = 0;
foreach (System.Data.DataRow Dr2 in ds2.Tables[0].Rows)
{
int id3 = Convert.ToInt32(Dr2["id"]);
string UserName2 = Dr2["UserName"].ToString();
string RealName2 = Dr2["RealName"].ToString();
string umoney192 = Convert.ToDouble(Dr2["umoney19"]).ToString("f2");
string UserState2 = Dr2["uLevel14"].ToString() == "1" ? "正常" : "未购买";
string uLevel2 = Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(Dr2["uLevel"]));
string RegTime2 = Dr2["RegTime"].ToString();
int suLevel12 = Convert.ToInt32(Dr2["uLevel1"]) - uLevel1;
string tjcount = Dr2["tjcount"].ToString();
if (i == 0)
{
strbusr1 += "{\"id\":\"" + id3 + "\",\"UserName\":\"" + UserName2 + "\",\"RealName\":\"" + RealName2 + "\",\"ds\":\"" + suLevel12 + "\",\"ztsl\":\"" + tjcount + "\",\"zyj\":\"" + umoney192 + "\",\"zt\":\"" + UserState2 + "\",\"uLevel\":\"" + uLevel2 + "\",\"zcsj\":\"" + RegTime2 + "\"}";
if (i2 < ds2.Tables[0].Rows.Count - 1)
{
strbusr1 += ",";
}
}
else if (i == 1)
{
strbusr2 += "{\"id\":\"" + id3 + "\",\"UserName\":\"" + UserName2 + "\",\"RealName\":\"" + RealName2 + "\",\"ds\":\"" + suLevel12 + "\",\"ztsl\":\"" + tjcount + "\",\"zyj\":\"" + umoney192 + "\",\"zt\":\"" + UserState2 + "\",\"uLevel\":\"" + uLevel2 + "\",\"zcsj\":\"" + RegTime2 + "\"}";
if (i2 < ds2.Tables[0].Rows.Count - 1)
{
strbusr2 += ",";
}
}
else if (i == 2)
{
strbusr3 += "{\"id\":\"" + id3 + "\",\"UserName\":\"" + UserName2 + "\",\"RealName\":\"" + RealName2 + "\",\"ds\":\"" + suLevel12 + "\",\"ztsl\":\"" + tjcount + "\",\"zyj\":\"" + umoney192 + "\",\"zt\":\"" + UserState2 + "\",\"uLevel\":\"" + uLevel2 + "\",\"zcsj\":\"" + RegTime2 + "\"}";
if (i2 < ds2.Tables[0].Rows.Count - 1)
{
strbusr3 += ",";
}
}
i2 += 1;
}
}
ds2.Clear();
if (i < ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
ds.Clear();
strdata += "]";
strbusr1 += "]";
strbusr2 += "]";
strbusr3 += "]";
data = "{\"status\":1,\"sycid\":\"" + sycid + "\"," + strdata + ",\"busr1\":" + strbusr1 + ",\"busr2\":" + strbusr2 + ",\"busr3\":" + strbusr3 + "}";*/
if (keyword != "")
{
//,(select count(*) from user_info b where b.gtype=" + gtype + " and b.UserState='正常' And b.IFStores=0 and b.uLevel17=0 and (b.uLevel7=1 or b.uLevel14=1) and b.SuperiorsID=a.id) as tjcount,(select count(*) from user_info b where b.gtype=" + gtype + " and b.UserState='正常' And b.IFStores=0 and b.uLevel17=0 and (b.uLevel7=1 or b.uLevel14=1) and b.SuperiorsIDS Like '%' + a.SuperiorsIDS + Convert(VarChar(50),a.id) + ',') as temcount
DataSet dss = new Mtxfw.DAL.user_info().GetList1("id,UserName,RealName,SuperiorsID,SuperiorsIDS,ContactID,DLRememberIDS,uLevel,uLevel1,umoney19,UserState,regtime,tjcount,temcount", "gtype=" + gtype + " and uutype='0' And UserState='正常' And IFStores=0 and uLevel17=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"]);
sycid1 = 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 umoney19 = Convert.ToDouble(dss.Tables[0].Rows[0]["umoney19"]).ToString("f2");
string UserState = dss.Tables[0].Rows[0]["uLevel14"].ToString() == "1" ? "正常" : "未购买";
string RegTime = dss.Tables[0].Rows[0]["RegTime"].ToString();
string SuperiorsIDS = dss.Tables[0].Rows[0]["SuperiorsIDS"].ToString();
string DLRememberIDS = dss.Tables[0].Rows[0]["DLRememberIDS"].ToString();
string uLevel = (UserState == "未购买" ? "体验会员" : Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(dss.Tables[0].Rows[0]["uLevel"])));
string tjcount = dss.Tables[0].Rows[0]["tjcount"].ToString();
string temcount = dss.Tables[0].Rows[0]["temcount"].ToString();
strdata += "\"topuser\":{\"id\":\"" + id2 + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"0\",\"tjcount\":\"" + tjcount + "\",\"temcount\":\"" + temcount + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"uLevel\":\"" + uLevel + "\",\"zcsj\":\"" + RegTime + "\"}";
if (b)
{
if (SuperiorsIDS.IndexOf("," + model.Id + ",") == -1 && DLRememberIDS.IndexOf("," + model.Id + ",") == -1)
{
b = false;
data = "{\"status\":0,\"msg\":\"用户名不存在您的网络图中\"}";
}
}
}
else
{
b = false;
data = "{\"status\":0,\"msg\":\"用户名不存在\"}";
}
dss.Clear();
}
else
{
sycid = model.SuperiorsID;
sycid1 = model.ContactID;
int tjcount = model.tjcount;//new Mtxfw.DAL.user_info().GetCount("gtype=" + gtype + " and UserState='正常' And IFStores=0 and uLevel17=0 and (uLevel7=1 or uLevel14=1) and SuperiorsID=" + model.Id + "");
int temcount = model.temcount;//new Mtxfw.DAL.user_info().GetCount("gtype=" + gtype + " and UserState='正常' And IFStores=0 and uLevel17=0 and (uLevel7=1 or uLevel14=1) and SuperiorsIDS Like '%," + model.Id + ",%'");
strdata += "\"topuser\":{\"id\":\"" + model.Id + "\",\"UserName\":\"" + model.UserName + "\",\"RealName\":\"" + model.RealName + "\",\"ds\":\"0\",\"tjcount\":\"" + tjcount + "\",\"temcount\":\"" + temcount + "\",\"zyj\":\"" + model.umoney19 + "\",\"zt\":\"" + (model.uLevel14 == 1 ? "正常" : "未购买") + "\",\"uLevel\":\"" + (model.uLevel14 == 0 ? "体验会员" : Mtxfw.Utility.Common.GetuLevelname(model.uLevel)) + "\",\"zcsj\":\"" + model.RegTime + "\"}";
}
if (b)
{
strdata += ",\"muser\":[";
DataSet ds = new Mtxfw.DAL.user_info().GetList1("id,UserName,RealName,umoney19,UserState,regtime,uLevel,uLevel1,uLevel14,(select count(*) from user_info b where b.gtype=" + gtype + " and b.UserState='正常' And b.IFStores=0 and b.uLevel17=0 and b.SuperiorsID=a.id) as ztsl,tjcount,temcount", "gtype=" + gtype + " and uutype='0' And UserState='正常' And IFStores=0 and uLevel17=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();
if (UserName.Length == 11)
{
UserName = UserName.Substring(0, 3) + "****" + UserName.Substring(7, 4);
}
string RealName = Dr["RealName"].ToString();
string umoney19 = Convert.ToDouble(Dr["umoney19"]).ToString("f2");
string UserState = Dr["uLevel14"].ToString() == "1" ? "正常" : "未购买";
string uLevel = (UserState == "未购买" ? "体验会员" : Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(Dr["uLevel"])));
string RegTime = Dr["RegTime"].ToString();
string ztsl = Dr["ztsl"].ToString();
string tjcount = Dr["tjcount"].ToString();
string temcount = Dr["temcount"].ToString();
int suLevel1 = Convert.ToInt32(Dr["uLevel1"]) - uLevel1;
strdata += "{\"id\":\"" + id2 + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"" + suLevel1 + "\",\"ztsl\":\"" + ztsl + "\",\"tjcount\":\"" + tjcount + "\",\"temcount\":\"" + temcount + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"uLevel\":\"" + uLevel + "\",\"zcsj\":\"" + RegTime + "\"}";
if (i < ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
strdata += "]";
strdata += ",\"muser2\":[";
ds = new Mtxfw.DAL.user_info().GetList1("id,UserName,RealName,umoney19,UserState,regtime,uLevel,uLevel1,uLevel14,(select count(*) from user_info b where b.ContactID=a.id and b.userstate='正常' and (b.uLevel7=1 or b.uLevel14=1) and b.uLevel17=0) as ztsl,tjcount,temcount", "gtype=" + gtype + " and uutype='0' And UserState='正常' And IFStores=0 and (uLevel7=1 or uLevel14=1) and uLevel17=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();
if (UserName.Length == 11)
{
UserName = UserName.Substring(0, 3) + "****" + UserName.Substring(7, 4);
}
string RealName = Dr["RealName"].ToString();
string umoney19 = Convert.ToDouble(Dr["umoney19"]).ToString("f2");
string UserState = Dr["uLevel14"].ToString() == "1" ? "正常" : "未购买";
string uLevel = (UserState == "未购买" ? "体验会员" : Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(Dr["uLevel"])));
string RegTime = Dr["RegTime"].ToString();
string ztsl = Dr["ztsl"].ToString();
string tjcount = Dr["tjcount"].ToString();
string temcount = Dr["temcount"].ToString();
int suLevel1 = Convert.ToInt32(Dr["uLevel1"]) - uLevel1;
strdata += "{\"id\":\"" + id2 + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"" + suLevel1 + "\",\"ztsl\":\"" + ztsl + "\",\"tjcount\":\"" + tjcount + "\",\"temcount\":\"" + temcount + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"uLevel\":\"" + uLevel + "\",\"zcsj\":\"" + RegTime + "\"}";
if (i < ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
strdata += "]";
data = "{\"status\":1,\"sycid\":\"" + sycid + "\",\"sycid1\":\"" + sycid1 + "\"," + strdata + "}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"您未登录\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //获取会员网络图谱2-----------------------------------------------------------------------------------------
///
/// 获取会员网络图谱2
///
protected string getmynetmap2(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());
int id = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["id"].ToString()));
int t = 0;
if (!String.IsNullOrEmpty(context.Request["t"]))
{
t = Convert.ToInt32(context.Request["t"]);
}
string sql = "SuperiorsID";
if (t == 1)
{
sql = "ContactID";
}
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
bool b = true;
int sycid = 0;
string strdata = "";
if (b)
{
string strsql2 = "";
Mtxfw.Model.user_info model2 = new Mtxfw.DAL.user_info().GetModel(id);
if (model2 != null)
{
sycid = model2.SuperiorsID;
if (t == 1)
{
sycid = model2.ContactID;
strsql2 = " and (b.uLevel7=1 or b.uLevel14=1)";
}
int tjcount = model2.tjcount;//new Mtxfw.DAL.user_info().GetCount("gtype=" + gtype + " and UserState='正常' And IFStores=0 and uLevel17=0 and (uLevel7=1 or uLevel14=1) and SuperiorsID=" + model2.Id + "");
int temcount = model2.temcount;//new Mtxfw.DAL.user_info().GetCount("gtype=" + gtype + " and UserState='正常' And IFStores=0 and uLevel17=0 and (uLevel7=1 or uLevel14=1) and SuperiorsIDS Like '%," + model2.Id + ",%'");
string UserName = model2.UserName;
if (UserName.Length == 11)
{
UserName = UserName.Substring(0, 3) + "****" + UserName.Substring(7, 4);
}
strdata += "\"topuser\":{\"id\":\"" + model2.Id + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + model2.RealName + "\",\"ds\":\"0\",\"tjcount\":\"" + tjcount + "\",\"temcount\":\"" + temcount + "\",\"zyj\":\"" + model2.umoney19 + "\",\"zt\":\"" + (model2.uLevel14 == 1 ? "正常" : "未购买") + "\",\"uLevel\":\"" + (model2.uLevel14 == 0 ? "体验会员" : Mtxfw.Utility.Common.GetuLevelname(model2.uLevel)) + "\",\"zcsj\":\"" + model2.RegTime + "\"}";
}
strdata += ",\"muser\":[";
DataSet ds = new Mtxfw.DAL.user_info().GetList1("id,UserName,RealName,umoney19,UserState,regtime,uLevel,uLevel1,uLevel14,(select count(*) from user_info b where b.userstate='正常' And b.IFStores=0" + strsql2 + " and b.uLevel17=0 and b." + sql + "=a.id) as ztsl,tjcount,temcount", "gtype=" + gtype + " and uutype='0' And UserState='正常' And IFStores=0" + strsql2 + " and uLevel17=0 And " + sql + "=" + id + " 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();
if (UserName.Length == 11)
{
UserName = UserName.Substring(0, 3) + "****" + UserName.Substring(7, 4);
}
string RealName = Dr["RealName"].ToString();
string umoney19 = Convert.ToDouble(Dr["umoney19"]).ToString("f2");
string UserState = Dr["uLevel14"].ToString() == "1" ? "正常" : "未购买";
string RegTime = Dr["RegTime"].ToString();
string ztsl = Dr["ztsl"].ToString();
string uLevel = (UserState == "未购买" ? "体验会员" : Mtxfw.Utility.Common.GetuLevelname(Convert.ToInt32(Dr["uLevel"])));
int suLevel1 = Convert.ToInt32(Dr["uLevel1"]) - model.uLevel1;
string tjcount = Dr["tjcount"].ToString();
string temcount = Dr["temcount"].ToString();
strdata += "{\"id\":\"" + id2 + "\",\"UserName\":\"" + UserName + "\",\"RealName\":\"" + RealName + "\",\"ds\":\"" + suLevel1 + "\",\"ztsl\":\"" + ztsl + "\",\"tjcount\":\"" + tjcount + "\",\"temcount\":\"" + temcount + "\",\"zyj\":\"" + umoney19 + "\",\"zt\":\"" + UserState + "\",\"uLevel\":\"" + uLevel + "\",\"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 getnewyj(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.LoginId == LoginId)
{
string strdata = ",\"data\":[";
string strdata2 = "";
if (t == 1)
{
strdata = ",\"labels\":[";
strdata2 = ",\"data\":[";
}
string groupby = "group by DATEPART(week,addtime)";
string strOrder = "DATEPART(week,addtime) Desc";
int Start = 0;
int Limit = 6;
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, "Addmoney,addtime", "sum(Addmoney) as Addmoney,DATEPART(week,addtime) as addtime", "gtype=" + gtype + " and utype=3 And Convert(varchar(50),BZContent)='注册币' And IFDelete=0", Start, Limit, out Recount);
Double yjze = 0.00;
int dtcount = Recount;
if (ds.Tables[1].Rows.Count > 0)
{
int i = 0;
foreach (System.Data.DataRow Dr in ds.Tables[1].Rows)
{
string Addmoney = (Convert.ToDouble(Dr["Addmoney"]) * Convert.ToDouble(config.webMoney35) / 100).ToString("f2");
string addtime = (Dr["addtime"].ToString().ToString()!=""?(Convert.ToInt32(Dr["addtime"])-10).ToString():"0");
if (Convert.ToDouble(Addmoney) > yjze)
{
yjze = Convert.ToDouble(Addmoney);
}
if (t == 0)
{
strdata += "{\"xValue\":\"" + addtime + "周\",\"yValue\":\"" + Addmoney + "\"}";
}
else
{
strdata += "\"" + addtime + "周\"";
if (addtime == "14")
{
strdata2 += "" + (Convert.ToDouble(Addmoney)+400000).ToString() + "";
}
else if (addtime == "15")
{
strdata2 += "" + (Convert.ToDouble(Addmoney) + 400000).ToString() + "";
}
else
{
strdata2 += "" + Convert.ToDouble(Addmoney).ToString() + "";
}
}
if (i != ds.Tables[1].Rows.Count - 1)
{
strdata += ",";
if (t == 1)
{
strdata2 += ",";
}
}
i += 1;
}
}
ds.Clear();
strdata += "]";
if (t == 1)
{
strdata2 += "],\"scaleStepWidth\":\"100000\",\"yjze\":\"" + yjze / 100000 + "\"";
}
data = "{\"status\":1" + strdata + strdata2 + "}";
}
else
{
data = "{\"status\":0,\"msg\":\"您未登录\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //获取门店分类和地图标志-----------------------------------------------------------------------------------------
///
/// 获取门店分类和地图标志
///
protected string getbusiness_info(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["categoryid"]))
{
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 categoryid = Convert.ToInt32(context.Request["categoryid"].ToString());
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
string groupby = "";
string strOrder = "applytime Desc";
int Start = 0;
int Limit = 30;
if (t == 0)
{
Limit = 100000;
}
if (!String.IsNullOrEmpty(context.Request["Start"]))
{
Start = Convert.ToInt32(HttpUtility.UrlDecode(context.Request["Start"].ToString()));
}
string strdata = "";
int i = 0;
strdata = "\"businesscategory\":[";
Dictionary list = Mtxfw.Utility.Common.GetBusinessClass();
i = 0;
foreach (KeyValuePair kv in list)
{
strdata += "{\"kvalue\":\"" + kv.Value + "\",\"kkey\":\"" + kv.Key.ToString() + "\"}";
if (i != 12)
{
strdata += ",";
}
i += 1;
}
strdata += "],";
strdata += "\"data\":[";
Int32 Recount = 0;
DataSet ds = new Mtxfw.DAL.business_info().GetDataSet(groupby, strOrder, "id,companyname,ClsnName,businessrange,province,city,county,companyaddress,xcoo,ycoo,picture", "", "gtype=" + gtype + " and ApplyState=N'已处理' And xcoo<>'' And ycoo<>'' And picture<>''" + (categoryid == 0 ? "" : " And ClsID=" + categoryid), Start, Limit, out Recount);
int dtcount = Recount;
if (ds.Tables[1].Rows.Count > 0)
{
i = 0;
foreach (System.Data.DataRow Dr in ds.Tables[1].Rows)
{
string id = Dr["id"].ToString();
string companyname = Dr["companyname"].ToString();
string ClsnName = Dr["ClsnName"].ToString();
string businessrange = Dr["businessrange"].ToString();
string province = new DAL.province().GetProvince(Dr["province"].ToString());
string city = new DAL.city().GetCity(Dr["city"].ToString());
if (city != "")
{
city = city.Replace("市辖区", "");
}
string county = new DAL.county().GetCounty(Dr["county"].ToString());
if (county != "")
{
county = county.Replace("市辖区", "");
}
string address = Dr["companyaddress"].ToString();
if (address != "")
{
if (province != "")
{
address = address.Replace(province, "");
}
if (city != "")
{
address = address.Replace(city, "");
}
if (county != "")
{
address = address.Replace(county, "");
}
}
address = province + city + county + address;
string xcoo = Dr["xcoo"].ToString();
string ycoo = Dr["ycoo"].ToString();
/*if (xcoo.Length > 10)
{
ycoo = xcoo.Substring(0, 10);
}
if (ycoo.Length > 10)
{
ycoo = ycoo.Substring(0, 10);
}*/
string picture = Dr["picture"].ToString().Split('|')[0];
if (t == 0)
{
strdata += "{\"id\":" + id + ",\"longitude\":" + xcoo + ",\"latitude\":" + ycoo + ",\"bubble\":{\"title\":\"" + companyname + "\",\"subTitle\":\"\"}}";//,\"address\":\"" + address + "\",\"ClsnName\":\"" + ClsnName + "\"
}
else
{
strdata += "{\"id\":" + id + ",\"companyname\":\"" + companyname + "\",\"businessrange\":\"" + businessrange + "\",\"picture\":\"" + Mtxfw.Utility.Common.GetCoverPic(picture, "220x220", "cut") + "\"}";
}
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 get2wm(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());
if (t == 0 || t == 1)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
string strdata = "";
string strRandNum = t + new CheckCode().RandNum(12) + model.Id;
bool b = true;
if (t == 0)
{
string PayEWMPic = "";
PayEWMPic = CreateQrcode(strRandNum, model.Id, t, context);
if (!String.IsNullOrEmpty(context.Request["IFUpdate"]) && !String.IsNullOrEmpty(context.Request["paytype"]))
{
int IFUpdate = Convert.ToInt32(context.Request["IFUpdate"].ToString());
int paytype = Convert.ToInt32(context.Request["paytype"].ToString());
if (IFUpdate == 1)
{
new Mtxfw.DAL.user_info().UpdatePassword("PayType", paytype.ToString(), model.Id);
}
}
new Mtxfw.DAL.user_info().UpdatePassword("PayEWMPic1", strRandNum, model.Id);
strdata += "\"PayEWMPic\":\"" + PayEWMPic + "\",\"PayType\":\"" + model.PayType + "\",\"MemNum\":\"" + strRandNum + "\"";
}
else
{
if (!String.IsNullOrEmpty(context.Request["IFUpdate"]) && !String.IsNullOrEmpty(context.Request["je"]) && context.Request["content"] != null)
{
int IFUpdate = Convert.ToInt32(context.Request["IFUpdate"].ToString());
string strje = context.Request["je"].ToString();
if (!System.Text.RegularExpressions.Regex.IsMatch(strje, @"^-?\d+$"))
{
b = false;
data = "{\"status\":0,\"msg\":\"提现金额必须为整数!\"}";
}
if (b)
{
int je = Convert.ToInt32(strje);
string content = HttpUtility.UrlDecode(context.Request["content"].ToString());
if (IFUpdate == 1)
{
model.umoney38 = je;
model.PayReason = content;
new Mtxfw.DAL.user_info().UpdateMoney2("umoney38", je, model.Id);
new Mtxfw.DAL.user_info().UpdatePassword("PayReason", content, model.Id);
}
}
}
string PayEWMPic = "";
PayEWMPic = CreateQrcode(strRandNum, model.Id, t, context);
strdata += "\"PayEWMPic\":\"" + PayEWMPic + "\",\"PayReason\":\"" + model.PayReason + "\",\"PayMoney\":\"" + model.umoney38.ToString() + "\",\"MemNum\":\"" + strRandNum + "\"";
new Mtxfw.DAL.user_info().UpdatePassword("PayEWMPic2", strRandNum, model.Id);
}
data = "{\"status\":1," + strdata + "}";
}
else
{
data = "{\"status\":0,\"msg\":\"您未登录\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误2\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
private string CreateQrcode(string nr, int id, int t, HttpContext context)
{
Bitmap bt;
string enCodeString = nr;
QRCodeEncoder qrCodeEncoder = new QRCodeEncoder();
//设置尺寸
qrCodeEncoder.QRCodeScale = 8;
bt = qrCodeEncoder.Encode(enCodeString, Encoding.UTF8);
string filepath = "/Files/grimage/" + id + "/";
//创建保存位置
if (!Directory.Exists(context.Server.MapPath(filepath)))
{
Directory.CreateDirectory(context.Server.MapPath(filepath));
}
string path = filepath + "PayEWMPic1.jpg";
bt.Save(context.Server.MapPath(path));
if (t == 0)
{
string path2 = filepath + "PayEWMPic2.jpg";
Mtxfw.Utility.Code39 _Code39 = new Mtxfw.Utility.Code39();
_Code39.Height = 50;
_Code39.Magnify = 0;
_Code39.ViewFont = new Font("Arial", 14);
System.Drawing.Image _CodeImage = _Code39.GetCodeImage(nr, Mtxfw.Utility.Code39.Code39Model.Code39Normal, true, false);
_CodeImage.Save(context.Server.MapPath(path2), System.Drawing.Imaging.ImageFormat.Jpeg);
return path + "|" + path2;
}
else
{
return path;
}
}
#endregion
#region //验证手机验证码是否正确-----------------------------------------------------------------------------------------
///
/// 验证手机验证码是否正确
///
protected string checkcode(HttpContext context)
{
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 = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == 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)
{
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 = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
string pwd = HttpUtility.UrlDecode(context.Request["pwd"].ToString());
bool b = true;
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
#region //获取付款或收款记录-----------------------------------------------------------------------------------------
///
/// 获取付款或收款记录
///
protected string getpaylog(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)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == 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()));
}
string strsql = "gtype=" + gtype + " and utype='10' And IFDelete=0";
if (t == 1)
{
strsql += " And b1=0 And MemberId=" + model.Id + "";
}
else if (t == 2)
{
strsql += " And b1=1 And MemberId=" + model.Id + "";
}
else
{
strsql += " And (MemberId=" + model.Id + " or UserId=" + model.Id + ")";
}
Int32 Recount = 0;
DataSet ds = new Mtxfw.DAL.user_Results().GetDataSet(groupby, strOrder, "id,MemberId,UserId,b0,b1,ListNumber,Managers,conent,addtime,seef,(Select UserName From user_info b Where b.Id=MemberId) as MemberName,(Select realname From user_info b Where b.Id=MemberId) as realname,(Select UserName From user_info b Where b.Id=UserId) as MemberName2,(Select realname From user_info b Where b.Id=UserId) as realname2", "", 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 = Convert.ToInt32(Dr["MemberId"]);
int UserId = Convert.ToInt32(Dr["UserId"]);
string Addmoney = Convert.ToDouble(Dr["b0"]).ToString("f2");
string b1 = Convert.ToDouble(Dr["b1"]).ToString();
string PayID = Dr["ListNumber"].ToString();
string BZContent = Dr["conent"].ToString();
string addtime = Dr["addtime"].ToString();
int seef = Convert.ToInt32(Dr["seef"]);
string MemberName = Dr["MemberName"].ToString();
string MemberName2 = Dr["MemberName2"].ToString();
string realname = Dr["realname"].ToString();
string realname2 = Dr["realname2"].ToString();
string Managers = Dr["Managers"].ToString();
BZContent += "["+Managers+"]";
if (MemberId == model.Id)
{
if (b1 == "0")
{
Addmoney = "-" + Addmoney;
}
BZContent = "你向" + (realname2 != "" ? realname2.Substring(0, 1) : MemberName2.Substring(0, 2)) + "**" + BZContent;
}
else
{
if (b1 == "1")
{
Addmoney = "-" + Addmoney;
}
BZContent = (realname != "" ? realname.Substring(0, 1) : MemberName.Substring(0, 2)) + "**向你" + BZContent;
}
strdata += "{\"id\":\"" + id + "\",\"Addmoney\":\"" + Addmoney + "\",\"PayID\":\"" + PayID + "\",\"BZContent\":\"" + BZContent.Replace("\"", "\\\"") + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\"}";
if (i != ds.Tables[1].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
ds.Clear();
if (t == 0)
{
data = "{\"status\":1,\"phone\":\"" + model.Phone + "\",\"data\":[" + strdata + "]}";
}
else
{
data = "{\"status\":1,\"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 getpaydata(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["payid"]))
{
int userId = Convert.ToInt32(context.Request["userId"].ToString());
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
string payid = context.Request["payid"].ToString();
int t = Convert.ToInt32(payid.Substring(0,1));
int MemberId = Convert.ToInt32(payid.Substring(13, payid.Length-13));
if (t == 0 || t == 1)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
Mtxfw.Model.user_info model2 = new Mtxfw.DAL.user_info().GetModel(MemberId);
if (model2 != null)
{
string PayEWM = model2.PayEWMPic1;
if (t == 1)
{
PayEWM = model2.PayEWMPic2;
}
if (PayEWM == payid)
{
string strdata = "";
string strRandNum = t + new CheckCode().RandNum(12) + model.Id;
bool b = true;
if (t == 0)
{
strdata += "\"name\":\"" + (model2.RealName != "" ? model2.RealName.Substring(0,1) : model2.UserName.Substring(0, 2)) + "***\",\"PayType\":\"" + (model2.PayType=="1"?"奖金币":"注册币") + "\"";
}
else
{
strdata += "\"name\":\"" + (model2.RealName != "" ? model2.RealName.Substring(0, 1) : model2.UserName.Substring(0, 2)) + "***\",\"payje\":\"" + model2.umoney38.ToString() + "\",\"content\":\"" + model2.PayReason + "\",\"zcjye\":\"" + (model.umoney26 - model.umoney27).ToString("f2") + "\",\"xjjye\":\"" + (model.umoney - model.umoney17).ToString("f2") + "\"";
}
if (b)
{
if (t == 1)
{
data = "{\"status\":1,\"phone\":\"" + model.Phone + "\"," + strdata + "}";
}
else
{
data = "{\"status\":1," + strdata + "}";
}
}
}
else
{
Mtxfw.Utility.Common.WriteHtml("/weixin/PayEWM3.txt", PayEWM + "|" + payid);
data = "{\"status\":0,\"msg\":\"参数错误4\"}";
}
}
else
{
Mtxfw.Utility.Common.WriteHtml("/weixin/PayEWM2.txt", payid);
data = "{\"status\":0,\"msg\":\"参数错误3\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"您未登录\"}";
}
}
else
{
Mtxfw.Utility.Common.WriteHtml("/weixin/PayEWM1.txt", payid);
data = "{\"status\":0,\"msg\":\"参数错误2\"}";
}
}
else
{
Mtxfw.Utility.Common.WriteHtml("/weixin/PayEWM0.txt", payid);
data = "{\"status\":0,\"msg\":\"参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //保存付款或收款信息-----------------------------------------------------------------------------------------
///
/// 保存付款或收款信息
///
protected string savepay(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["userId"]) && !String.IsNullOrEmpty(context.Request["LoginId"]) && !String.IsNullOrEmpty(context.Request["payid"]))
{
int userId = Convert.ToInt32(context.Request["userId"].ToString());
string LoginId = HttpUtility.UrlDecode(context.Request["LoginId"].ToString());
string payid = context.Request["payid"].ToString();
int t = Convert.ToInt32(payid.Substring(0, 1));
int MemberId = Convert.ToInt32(payid.Substring(13, payid.Length - 13));
bool b = true;
Double je = 0.00;
if (!String.IsNullOrEmpty(context.Request["je"]))
{
string strje = context.Request["je"].ToString();
if (!System.Text.RegularExpressions.Regex.IsMatch(strje, @"^-?\d+$"))
{
b = false;
data = "{\"status\":0,\"msg\":\"付款金额必须为整数!\"}";
}
else
{
je = Convert.ToDouble(Convert.ToDouble(strje).ToString("f2"));
}
}
else
{
if (t == 0)
{
data = "{\"status\":0,\"msg\":\"付款金额不能为空!\"}";
}
}
string strcontent = "";
if (!String.IsNullOrEmpty(context.Request["content"]))
{
strcontent = HttpUtility.UrlDecode(context.Request["content"].ToString());
}
if (b)
{
if (t == 0 || t == 1)
{
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
Mtxfw.Model.user_info model2 = new Mtxfw.DAL.user_info().GetModel(MemberId);
if (model2 != null)
{
string PayEWM = model2.PayEWMPic1;
if (t == 1)
{
PayEWM = model2.PayEWMPic2;
}
if (PayEWM == payid)
{
if (model.Id != model2.Id)
{
if (t == 0)
{
Double umoney = Convert.ToDouble((model2.umoney26 - model2.umoney27).ToString("f2"));
Double umoney2 = Convert.ToDouble((model2.umoney26 - model2.umoney27).ToString("f2"));
if (model2.PayType == "1")
{
umoney = Convert.ToDouble((model.umoney - model.umoney17).ToString("f2"));
umoney2 = Convert.ToDouble((model2.umoney - model2.umoney17).ToString("f2"));
}
if (b)
{
if (je <= 0.00)
{
b = false;
data = "{\"status\":0,\"msg\":\"付款金额不能小于0!\"}";
}
}
if (b)
{
if (umoney < je)
{
b = false;
if (model2.PayType == "1")
{
data = "{\"status\":0,\"msg\":\"对方奖金币余额不足!\"}";
}
else
{
data = "{\"status\":0,\"msg\":\"对方注册币余额不足!\"}";
}
}
}
if (b)
{
Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results();
ModelResults.b0 = je;
ModelResults.b1 = t;
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 = (t == 0 ? "付款" : "收款") + (strcontent != "" ? " 收款理由:" + strcontent : "");
ModelResults.Totalmoney = je;
ModelResults.MemberId = model2.Id;
ModelResults.UserId = model.Id;
ModelResults.ListNumber = payid;
ModelResults.Managers = (model2.PayType == "1" ? "奖金币" : "注册币");
ModelResults.Seef = -1;
ModelResults.utype = "10";
ModelResults.gtype = gtype;
DateTime dt = DateTime.Now;
ModelResults.addtime = dt;
Int64 ResultID = new Mtxfw.DAL.user_Results().Add(ModelResults);
if (model2.PayType == "1")
{
new Mtxfw.DAL.user_info().UpdateMoney("umoney17", je, model2.Id);
new Mtxfw.DAL.user_info().UpdateMoney("umoney17", -je, model.Id);
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model2.Id;
mjl2.MemberId2 = model.Id;
mjl2.Addmoney = -je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney2 - je;
mjl2.addtime = DateTime.Now;
mjl2.BZContent = "你向" + (model.RealName != "" ? model.RealName.Substring(0, 1) : model.UserName.Substring(0, 2)) + "**付款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 1;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model.Id;
mjl2.MemberId2 = model2.Id;
mjl2.Addmoney = -je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney + je;
mjl2.addtime = DateTime.Now;
mjl2.BZContent = (model2.RealName != "" ? model2.RealName.Substring(0, 1) : model2.UserName.Substring(0, 2)) + "**向你付款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 1;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
}
else
{
new Mtxfw.DAL.user_info().UpdateMoney("umoney27", je, model2.Id);
new Mtxfw.DAL.user_info().UpdateMoney("umoney27", -je, model.Id);
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model2.Id;
mjl2.MemberId2 = model.Id;
mjl2.Addmoney = -je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney2 - je;
mjl2.addtime = dt;
mjl2.BZContent = "你向" + (model.RealName != "" ? model.RealName.Substring(0, 1) : model.UserName.Substring(0, 2)) + "**付款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 3;
mjl2.utype2 = 1;
mjl2.Seef = -1;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model.Id;
mjl2.MemberId2 = model2.Id;
mjl2.Addmoney = je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney + je;
mjl2.addtime = dt;
mjl2.BZContent = (model2.RealName != "" ? model2.RealName.Substring(0, 1) : model2.UserName.Substring(0, 2)) + "**向你付款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 3;
mjl2.utype2 = 1;
mjl2.Seef = -1;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
}
data = "{\"status\":1,\"msg\":\"保存成功\"}";
}
}
else
{
if (b)
{
if (String.IsNullOrEmpty(context.Request["code"]) && String.IsNullOrEmpty(context.Request["pwd"]))
{
b = false;
data = "{\"status\":0,\"msg\":\"参数为空!\"}";
}
}
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 (model.Password != Mtxfw.Utility.Security.EncryptString(pwd))
{
b = false;
data = "{\"status\":0,\"msg\":\"操作失败,安全密码不正确!\"}";
}
}
}
int paytype = 0;
if (!String.IsNullOrEmpty(context.Request["paytype"]))
{
paytype = Convert.ToInt32(context.Request["paytype"].ToString());
}
if (Convert.ToDouble(model2.umoney38.ToString("f2")) > 0.00)
{
je = Convert.ToDouble(model2.umoney38.ToString("f2"));
}
if (b)
{
if (je <= 0.00)
{
b = false;
data = "{\"status\":0,\"msg\":\"付款金额不能小于0!\"}";
}
}
Double umoney = Convert.ToDouble((model.umoney26 - model.umoney27).ToString("f2"));
Double umoney2 = Convert.ToDouble((model2.umoney26 - model2.umoney27).ToString("f2"));
if (paytype == 1)
{
umoney = Convert.ToDouble((model.umoney - model.umoney17).ToString("f2"));
umoney2 = Convert.ToDouble((model2.umoney - model2.umoney17).ToString("f2"));
}
if (b)
{
if (umoney < je)
{
b = false;
if (model2.PayType == "1")
{
data = "{\"status\":0,\"msg\":\"您的奖金币余额不足!\"}";
}
else
{
data = "{\"status\":0,\"msg\":\"您的注册币余额不足!\"}";
}
}
}
if (b)
{
Mtxfw.Model.user_Results ModelResults = new Mtxfw.Model.user_Results();
ModelResults.b0 = je;
ModelResults.b1 = t;
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 = (t == 0 ? "付款" : "收款") + (model.PayReason != "" ? " 收款理由:" + model.PayReason : "");
ModelResults.Totalmoney = je;
ModelResults.MemberId = model2.Id;
ModelResults.UserId = model.Id;
ModelResults.ListNumber = payid;
ModelResults.Managers = (paytype == 1 ? "奖金券" : "注册币");
ModelResults.Seef = -1;
ModelResults.utype = "10";
ModelResults.gtype = gtype;
DateTime dt = DateTime.Now;
ModelResults.addtime = dt;
Int64 ResultID = new Mtxfw.DAL.user_Results().Add(ModelResults);
if (model2.PayType == "1")
{
new Mtxfw.DAL.user_info().UpdateMoney("umoney17", -je, model2.Id);
new Mtxfw.DAL.user_info().UpdateMoney("umoney17", je, model.Id);
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model2.Id;
mjl2.MemberId2 = model.Id;
mjl2.Addmoney = je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney2 + je;
mjl2.addtime = DateTime.Now;
mjl2.BZContent = "你向" + (model.RealName != "" ? model.RealName.Substring(0, 1) : model.UserName.Substring(0, 2)) + "**收款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 1;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model.Id;
mjl2.MemberId2 = model2.Id;
mjl2.Addmoney = -je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney - je;
mjl2.addtime = DateTime.Now;
mjl2.BZContent = (model2.RealName != "" ? model2.RealName.Substring(0, 1) : model2.UserName.Substring(0, 2)) + "**向你收款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 1;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
}
else
{
new Mtxfw.DAL.user_info().UpdateMoney("umoney27", -je, model2.Id);
new Mtxfw.DAL.user_info().UpdateMoney("umoney27", je, model.Id);
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model2.Id;
mjl2.MemberId2 = model.Id;
mjl2.Addmoney = je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney2 + je;
mjl2.addtime = dt;
mjl2.BZContent = "你向" + (model.RealName != "" ? model.RealName.Substring(0, 1) : model.UserName.Substring(0, 2)) + "**收款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 3;
mjl2.utype2 = 1;
mjl2.Seef = -1;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = model.Id;
mjl2.MemberId2 = model2.Id;
mjl2.Addmoney = -je;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = umoney - je;
mjl2.addtime = dt;
mjl2.BZContent = (model2.RealName != "" ? model2.RealName.Substring(0, 1) : model2.UserName.Substring(0, 2)) + "**向你收款";
mjl2.PayID = payid;
mjl2.OrdersIDs = ResultID.ToString();
mjl2.OrdersID = 0;
mjl2.utype = 3;
mjl2.utype2 = 1;
mjl2.Seef = -1;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
new Mtxfw.DAL.user_Results_jl2().Add(mjl2);
}
data = "{\"status\":1,\"msg\":\"保存成功\"}";
}
}
}
else
{
data = "{\"status\":0,\"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\":\"参数错误\"}";
}
}
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.LoginId == 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.webMoney47)))
{
if (qiandaonum % Convert.ToInt32(config.webMoney47) == 0 && lastdt.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
{
lastdt = lastdt.AddDays(-(Convert.ToInt32(config.webMoney47) - 1));
qiandaonum = Convert.ToInt32(config.webMoney47);
}
else
{
int cutnum = Convert.ToInt32((qiandaonum / Convert.ToInt32(config.webMoney47)).ToString().Split('.')[0]);
qiandaonum -= (Convert.ToInt32(config.webMoney47) * 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.webMoney47); 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.webMoney47) - 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.LoginId == LoginId)
{
int IFqd = daoqiandao.GetCount("gtype=" + gtype + " and Q_MemberId=" + umodel.Id + " and DATEDIFF(day ,Q_SJ,getdate())=0");
if (IFqd == 0)
{
if (Convert.ToDouble(umodel.umoney52.ToString("f4")) > 0.0000)
{
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.webMoney47))
{
int cutnum = Convert.ToInt32((qiandaonum / Convert.ToInt32(config.webMoney47)).ToString().Split('.')[0]);
qiandaonum -= (Convert.ToInt32(config.webMoney47) * cutnum);
}
}
ds.Clear();
Double bfb = Convert.ToDouble(Convert.ToDouble(config.webMoney56).ToString("f4"));
if (qiandaonum > 0)
{
bfb = Convert.ToDouble((Convert.ToDouble(config.webMoney56) + (qiandaonum * Convert.ToDouble(config.webMoney55))).ToString("f4"));
}
Double QDJF = Convert.ToDouble((bfb / 100 * umodel.umoney52).ToString("f4"));
if (QDJF > 0.0000)
{
Model.qiandao qmodel = new Model.qiandao();
qmodel.Q_MemberId = umodel.Id;
qmodel.Q_Intro = "";
qmodel.Q_Num = 0;
qmodel.gtype = gtype;
daoqiandao.Add(qmodel);
if (Convert.ToDouble(umodel.umoney52.ToString("f4")) < QDJF)
{
QDJF = Convert.ToDouble(umodel.umoney52.ToString("f4"));
}
if (QDJF > 0.0000)
{
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.umoney32 + QDJF);
mjl2.addtime = DateTime.Now;
mjl2.BZContent = "签到";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 4;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
mjl2.gtype = gtype;
daojl2.Add(mjl2);
daoUser.UpdateMoney("umoney32", QDJF, umodel.Id);
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = umodel.Id;
mjl2.MemberId2 = 0;
mjl2.Addmoney = -QDJF;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = (umodel.umoney52 - QDJF);
mjl2.addtime = DateTime.Now;
mjl2.BZContent = "签到";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 28;
mjl2.utype2 = 0;
mjl2.Seef = -1;
mjl2.seeftime = DateTime.Now;
mjl2.gtype = gtype;
daojl2.Add(mjl2);
daoUser.UpdateMoney("umoney52", -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\":\"参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //获取扫码内容-----------------------------------------------------------------------------------------
///
/// 获取扫码内容
///
protected string getScanner(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["content"]))
{
string content = HttpUtility.UrlDecode(context.Request["content"].ToString());
Mtxfw.Utility.Common.WriteHtml("/weixin/getScanner.txt", content);
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //获取用户信息列表-----------------------------------------------------------------------------------------
///
/// 获取用户信息列表
///
protected string getusers(HttpContext context)
{
string data = "{\"status\":0}";
DateTime time = DateTime.Now;
if (!String.IsNullOrEmpty(context.Request["time"]))
{
time = Convert.ToDateTime(context.Request["time"].ToString());
}
string strdata = "";
string strsql = "gtype=" + gtype + " and UserState='正常' And IFStores=0 And QianBao<>'' And QBTime>Convert(DateTime,'" + time + "') order by QBTime asc";
DataSet ds = daoUser.GetList1("UserName,RealName,qbaddress,QBTime,umoney,umoney17,umoney22,(Select b.qbaddress From user_info b where b.gtype=" + gtype + " and b.UserState='正常' And b.IFStores=0 And b.id=a.ContactID) as QianBao0", strsql);
if (ds.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
string UserName = Dr["UserName"].ToString();
string RealName = Dr["RealName"].ToString();
string QianBao = Dr["qbaddress"].ToString();
string QBTime = Dr["QBTime"].ToString();
string QianBao0 = Dr["QianBao0"].ToString();
string umoney32 = (Convert.ToDouble(Dr["umoney"])- Convert.ToDouble(Dr["umoney17"])).ToString();
string umoney33 = Convert.ToDouble(Dr["umoney22"]).ToString();
strdata += "{\"qianbao\":\"" + QianBao + "\",\"time\":\"" + QBTime + "\",\"tjqianbao\":\"" + QianBao0 + "\",\"company\":\"银花优选\",\"userid\":\"" + UserName + "\",\"name\":\"" + RealName + "\",\"L1\":\"" + umoney32 + "\",\"L2\":\"" + umoney33 + "\"";
strdata += "}";
if (i != ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
ds.Clear();
data = "{\"status\":1,\"data\":[" + strdata + "]}";
return data;
}
#endregion
#region //获取订单信息列表-----------------------------------------------------------------------------------------
///
/// 获取订单信息列表
///
protected string getorders(HttpContext context)
{
string data = "{\"status\":0}";
int id = 1000000;
if (!String.IsNullOrEmpty(context.Request["id"]))
{
id = Convert.ToInt32(context.Request["id"].ToString());
}
string strdata = "";
string strsql = "gtype=" + gtype + " and IFDelete=0 And Totalprice10=1 And id>" + id + " order by id asc";
DataSet ds = daoorder.GetList1("id,ttype,poid,orderid,Totalprice,Totalprice2,Totalprice5,O_Payed_Date,(Select b.qbaddress From user_info b where b.gtype=" + gtype + " and b.UserState='正常' And b.IFStores=0 And b.id=a.UserID) as QianBao", strsql);
if (ds.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
string oid = Dr["id"].ToString();
string ttype = Dr["ttype"].ToString();
string orderid = Dr["orderid"].ToString();
string Totalprice = Convert.ToDouble(Dr["Totalprice"]).ToString();
string Totalprice2 = Convert.ToDouble(Dr["Totalprice2"]).ToString();
string Totalprice5 = Convert.ToDouble(Dr["Totalprice5"]).ToString();
string O_Payed_Date = Dr["O_Payed_Date"].ToString();
string QianBao = Dr["QianBao"].ToString();
strdata += "{\"id\":\"" + oid + "\",\"orderid\":\"" + orderid + "\",\"qianbao\":\"" + QianBao + "\",\"company\":\"银花优选\",\"totalprice\":\"" + Totalprice + "\",\"integral\":\"" + Totalprice5 + "\",\"time\":\"" + O_Payed_Date + "\"";
strdata += "}";
if (i != ds.Tables[0].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
ds.Clear();
data = "{\"status\":1,\"data\":[" + strdata + "]}";
return data;
}
#endregion
#region //获取任务包数据-----------------------------------------------------------------------------------------
///
///获取任务包数据
///
protected string getrwbdata(HttpContext context)
{
string data = "{\"status\":0}";
string strdata = "";
DataSet Ds_Product0 = daoProduct.GetList1("P_ID,P_NAME,P_images,P_DESCRIPTION", "gtype=" + gtype + " And utype=1 And P_State=N'已处理' And IFDelete=0 and P_ID<>1873 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_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 strdata0 = ",\"guige\":[";
string P_Market_P = "";
string P_VIP_P = "";
string P_VIP_P0 = "";
string P_VIP_P1 = "";
string P_VIP_P2 = "";
string P_VIP_P3 = "";
string P_VIP_P4 = "";
DataSet ds0 = new DAL.P_Guige().GetList1("G_ID,G_Name,G_JG,G_JG0,G_JG1,G_JG2,G_JG3,G_JG4,G_JF,G_KC", "ttype=0 And G_PID=" + P_ID + " And G_KC>0 order by G_JG asc");
if (ds0.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (System.Data.DataRow Dr in ds0.Tables[0].Rows)
{
int G_ID = int.Parse(Dr["G_ID"].ToString());
string G_Name = Dr["G_Name"].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_JG3 = Double.Parse(Dr["G_JG3"].ToString());
Double G_JG4 = Double.Parse(Dr["G_JG4"].ToString());
Double G_JF = Double.Parse(Dr["G_JF"].ToString());
int G_KC = int.Parse(Dr["G_KC"].ToString());
if (i == 0)
{
P_Market_P = G_JG2.ToString();
P_VIP_P = G_JG.ToString();
P_VIP_P0 = G_JG0.ToString();
P_VIP_P1 = G_JG1.ToString();
P_VIP_P2 = G_JG2.ToString();
P_VIP_P3 = G_JG3.ToString();
P_VIP_P4 = G_JG4.ToString();
}
i += 1;
strdata0 += "{\"id\":\"" + G_ID + "\",\"gg\":\"" + G_Name + "\",\"jg\":\"" + G_JG.ToString("f2") + "\",\"jg0\":\"" + G_JG0.ToString() + "\",\"jg1\":\"" + G_JG1.ToString() + "\",\"jg2\":\"" + G_JG2.ToString("f2") + "\",\"jg3\":\"" + G_JG3.ToString() + "\",\"jg4\":\"" + G_JG4.ToString() + "\",\"jf\":\"" + G_JF.ToString() + "\",\"kc\":\"" + G_KC + "\",\"selectedcolor\":\"\",\"selectednum\":\"0\",\"colors\":[],\"images\":[]}";
}
}
ds0.Clear();
strdata0 += "]";
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 + "\",\"hyje2\":\"" + P_VIP_P2 + "\",\"hyje3\":\"" + P_VIP_P3 + "\",\"hyje4\":\"" + P_VIP_P4 + "\",\"image\":\"" + (P_images.IndexOf("http")!=-1 ? P_images : config.webUrl + Mtxfw.Utility.Common.GetCoverPic(P_images, x, "cut")) + "\"" + strdata0 + "},";
}
if (strdata.Substring(strdata.Length - 1, 1) == ",")
{
strdata = strdata.Substring(0, strdata.Length - 1);
}
}
Ds_Product0.Clear();
data = "{\"status\":1,\"data\":[" + strdata + "]}";
return data;
}
#endregion
#region //获取任务包详情-----------------------------------------------------------------------------------------
///
///获取任务包详情
///
protected string getrwbdetails(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["rwbid"]) && !String.IsNullOrEmpty(context.Request["czuserid"]) && !String.IsNullOrEmpty(context.Request["timestamp"]) && !String.IsNullOrEmpty(context.Request["sign"]))
{
string czuserid = context.Request["czuserid"].ToString();
int rwbid = Convert.ToInt32(context.Request["rwbid"].ToString());
string timestamp = context.Request["timestamp"].ToString();
string sign = context.Request["sign"].ToString();
string strq = "&rwbid=" + rwbid + "&czuserid=" + czuserid + "×tamp=" + timestamp;
if (Mtxfw.Utility.AlipayMD5.Verify(strq, sign, config.AccessKeySecret, "utf-8"))
{
Mtxfw.Model.P_Product pmodel = new Mtxfw.DAL.P_Product().GetModel(rwbid);
if (pmodel != null)
{
int UserId = 0;
SqlDataReader Dr = new Mtxfw.DAL.user_info().GetUserId(gtype, czuserid);
if (Dr.HasRows)
{
if (Dr.Read())
{
UserId = int.Parse(Dr["Id"].ToString());
}
}
Dr.Close();
if (UserId > 0)
{
string hyje = "";
DataSet ds0 = new DAL.P_Guige().GetList1("top 1 G_ID,G_Name,G_JG,G_JG0,G_JG1,G_JG2,G_JG3,G_JG4,G_JF,G_KC", "ttype=0 And G_PID=" + pmodel.P_ID + " And G_KC>0 order by G_JG asc");
if (ds0.Tables[0].Rows.Count > 0)
{
int i = 0;
foreach (System.Data.DataRow Dr0 in ds0.Tables[0].Rows)
{
int G_ID = int.Parse(Dr0["G_ID"].ToString());
string G_Name = Dr0["G_Name"].ToString();
Double G_JG = Double.Parse(Dr0["G_JG"].ToString());
Double G_JG0 = Double.Parse(Dr0["G_JG0"].ToString());
Double G_JG1 = Double.Parse(Dr0["G_JG1"].ToString());
Double G_JG2 = Double.Parse(Dr0["G_JG2"].ToString());
Double G_JG3 = Double.Parse(Dr0["G_JG3"].ToString());
Double G_JG4 = Double.Parse(Dr0["G_JG4"].ToString());
Double G_JF = Double.Parse(Dr0["G_JF"].ToString());
int G_KC = int.Parse(Dr0["G_KC"].ToString());
if (i == 0)
{
hyje = G_JG.ToString();
}
i += 1;
}
}
ds0.Clear();
data = "{\"status\":1,\"UserId\":" + UserId + ",\"hyje\":\"" + hyje + "\"}";
}
else
{
data = "{\"status\":0,\"msg\":\"赠送账号不存在\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误\"}";
}
}
else
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "签名错误";
mo.addtime = DateTime.Now;
mo.ErrBody = strq;
mo.ErrBody2 = sign;
new DAL.User_Errlog().Add(mo);
data = "{\"status\":0,\"msg\":\"签名错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //接收线上赠送-----------------------------------------------------------------------------------------
///
/// 接收线上赠送
///
protected string acceptzengsong(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["rwbid"]) && !String.IsNullOrEmpty(context.Request["num"]) && !String.IsNullOrEmpty(context.Request["czuserid"]) && !String.IsNullOrEmpty(context.Request["username"]) && !String.IsNullOrEmpty(context.Request["timestamp"]) && !String.IsNullOrEmpty(context.Request["orderid"]) && !String.IsNullOrEmpty(context.Request["sign"]))
{
int rwbid = Convert.ToInt32(context.Request["rwbid"].ToString());
int num = Convert.ToInt32(context.Request["num"].ToString());
string czuserid = HttpUtility.UrlDecode(context.Request["czuserid"].ToString());
string username = HttpUtility.UrlDecode(context.Request["username"].ToString());
string timestamp = context.Request["timestamp"].ToString();
string orderid = context.Request["orderid"].ToString();
string sign = context.Request["sign"].ToString();
string strq = "&rwbid=" + rwbid + "&num=" + num + "&czuserid=" + czuserid + "&username=" + username + "×tamp=" + timestamp + "&orderid=" + orderid;
if (Mtxfw.Utility.AlipayMD5.Verify(strq, sign, config.AccessKeySecret, "utf-8"))
{
SqlDataReader dr = daoUser.GetUserId(gtype, czuserid);
if (dr.HasRows)
{
if (dr.Read())
{
DateTime dt = DateTime.Now;
int uid = int.Parse(dr["Id"].ToString());
int SJRememberID = int.Parse(dr["SJRememberID"].ToString());
Double umoney = (Convert.ToDouble(dr["umoney30"].ToString()));
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
string OID = orderid;
if (daoorder.GetCount("ttype=1 and utype='4' and IFDelete=0 and orderid='" + orderid +"'") == 0)
{
int prodid = 1873;
Model.P_Product pm = daoProduct.GetModel(prodid);
if (pm != null)
{
DataSet ds = daoGuige.GetList1("top 1 * ", "ttype=0 And G_PID=" + prodid);
if (ds.Tables[0].Rows.Count > 0)
{
int G_ID = int.Parse(ds.Tables[0].Rows[0]["G_ID"].ToString());
string G_Name = ds.Tables[0].Rows[0]["G_Name"].ToString();
Double G_JG = Double.Parse(ds.Tables[0].Rows[0]["G_JG"].ToString());
Double G_JG0 = Double.Parse(ds.Tables[0].Rows[0]["G_JG0"].ToString());
Double G_JG1 = Double.Parse(ds.Tables[0].Rows[0]["G_JG1"].ToString());
Double G_JG2 = Double.Parse(ds.Tables[0].Rows[0]["G_JG2"].ToString());
Double G_JG3 = Double.Parse(ds.Tables[0].Rows[0]["G_JG3"].ToString());
Double G_JG4 = Double.Parse(ds.Tables[0].Rows[0]["G_JG4"].ToString());
Double G_JF = Double.Parse(ds.Tables[0].Rows[0]["G_JF"].ToString());
Double G_ZL = Double.Parse(ds.Tables[0].Rows[0]["G_ZL"].ToString());
int G_KC = int.Parse(ds.Tables[0].Rows[0]["G_KC"].ToString());
Model.order_info Modelorder = new Model.order_info();
Modelorder.pid = prodid;
Modelorder.poid = 0;
Modelorder.addressid = 0;
Modelorder.orderid = OID;
Modelorder.Contactname = "";
Modelorder.Contacttel = "";
Modelorder.Province = "";
Modelorder.City = "";
Modelorder.County = "";
Modelorder.Address = "";
Modelorder.Zipcode = "";
Modelorder.Guests = username + "赠送";
Modelorder.Totalprice = (G_JG * num);
Modelorder.Totalprice0 = (G_JG0 * num);//总产出
Modelorder.Totalprice1 = 0;
Modelorder.Totalprice2 = G_JG1;//产出周期
Modelorder.Totalprice3 = (G_JG2 * num);//活力值
Modelorder.Totalprice4 = G_JG3;//有效期
Modelorder.Totalprice5 = G_JG4;//最大持有量
Modelorder.Totalprice6 = 0;
Modelorder.Totalprice7 = 0;
Modelorder.Totalprice8 = G_JG1;//剩余产出天数
Modelorder.Totalprice9 = G_JG3;//剩余有效天数
Modelorder.Totalprice10 = 0;//已产出数量
Modelorder.Totalnum = num;
Modelorder.O_Submit = "1";
Modelorder.O_yhj = "";
Modelorder.UserID = uid;
Modelorder.MemberId = 0;
Modelorder.selcolor = "";
Modelorder.guige = "";
Modelorder.utype = "4";
Modelorder.ttype = 1;
Modelorder.peitype = 0;
Modelorder.ptype = 0;
Modelorder.gtype = gtype;
Modelorder.Id = daoorder.Add(Modelorder);
daoorder.Updateptgroup(SJRememberID, Modelorder.Id);
daoorder.UpdateqyState(0, "1", dt, Modelorder.Id);
daoorder.UpdateqyState(2, "1", dt, Modelorder.Id);
Model.order_product_info opmodel = new Model.order_product_info();
opmodel.pid = prodid;
opmodel.orderid = Modelorder.Id;
opmodel.selcolor = "";
opmodel.guige = "3302";
opmodel.DJprice = G_JG;
opmodel.Totalprice = (G_JG* num);
opmodel.Totalnum = num;
opmodel.UserID = uid;
opmodel.SubmitTime = dt;
opmodel.utype = "0";
opmodel.gtype = gtype;
new DAL.order_product_info().Add(opmodel);
Mtxfw.Model.user_info umodel0 = daoUser.GetModel(uid);
if (umodel0 != null)
{
Double money = Convert.ToDouble(Modelorder.Totalprice.ToString("f2"));//流量积分
Double money0 = Convert.ToDouble(Modelorder.Totalprice0.ToString("f2"));//总产出//赠送贡献值
Double money2 = Convert.ToDouble(Modelorder.Totalprice3.ToString("f2"));//活力值
Double money1 = Convert.ToDouble(Modelorder.Totalprice2.ToString("f2"));//产出期//赠送流量包
Double money3 = Convert.ToDouble(Modelorder.Totalprice4.ToString("f2"));//有效期
Double money4 = Convert.ToDouble(Modelorder.Totalprice5.ToString("f2"));//最大持有数
}
}
data = "{\"status\":1,\"msg\":\"赠送成功\"}";
}
else
{
data = "{\"status\":0,\"msg\":\"任务包ID错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"订单号已存在\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"赠送账号不存在0\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"赠送账号不存在\"}";
}
dr.Close();
}
else
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "签名错误";
mo.addtime = DateTime.Now;
mo.ErrBody = strq;
mo.ErrBody2 = sign;
new DAL.User_Errlog().Add(mo);
data = "{\"status\":0,\"msg\":\"签名错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //接收Ms-----------------------------------------------------------------------------------------
///
/// 接收Ms
///
protected string acceptms(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["zcusername"]) && !String.IsNullOrEmpty(context.Request["zruserid"]) && !String.IsNullOrEmpty(context.Request["money"]) && !String.IsNullOrEmpty(context.Request["timestamp"]) && !String.IsNullOrEmpty(context.Request["sign"]))
{
string zcusername = context.Request["zcusername"].ToString();
string zruserid = context.Request["zruserid"].ToString();
string money = context.Request["money"].ToString();
string timestamp = context.Request["timestamp"].ToString();
string orderid = context.Request["orderid"].ToString();
string sign = context.Request["sign"].ToString();
string strq = "&zcusername=" + zcusername + "&zruserid=" + zruserid + "&money=" + money + "×tamp=" + timestamp + "&orderid=" + orderid;
if (Mtxfw.Utility.AlipayMD5.Verify(strq, sign, config.AccessKeySecret, "utf-8"))
{
SqlDataReader dr = daoUser.GetUserId(gtype, zruserid);
if (dr.HasRows)
{
if (dr.Read())
{
if (daojl2.GetCount("utype=14 and utype2=1 and IFDelete=0 and OrdersIDs='" + orderid + "'") == 0)
{
DateTime dt = DateTime.Now;
int id = int.Parse(dr["Id"].ToString());
Double umoney = (Convert.ToDouble(dr["umoney34"].ToString()));
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = id;
mjl2.MemberId2 = 0;
mjl2.Addmoney = Convert.ToDouble(money);
mjl2.Cutmoney = 0;
mjl2.Totalmoney = (umoney + Convert.ToDouble(money));
mjl2.addtime = dt;
mjl2.BZContent = Mtxfw.Utility.Common.cphone(zcusername) + "转入";
mjl2.PayID = zcusername;
mjl2.OrdersIDs = orderid;
mjl2.OrdersID = 0;
mjl2.utype = 14;
mjl2.utype2 = 1;
mjl2.Seef = 0;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
Int64 rid = daojl2.Add(mjl2);
daoUser.UpdateMoney("umoney34", Convert.ToDouble(money), id);
data = "{\"status\":1,\"msg\":\"接收成功\"}";
}
else
{
data = "{\"status\":0,\"msg\":\"订单号已存在\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"转账账号不存在0\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"转账账号不存在\"}";
}
dr.Close();
}
else
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "签名错误";
mo.addtime = DateTime.Now;
mo.ErrBody = strq;
mo.ErrBody2 = sign;
new DAL.User_Errlog().Add(mo);
data = "{\"status\":0,\"msg\":\"签名错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
public object FromJson2(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize(json);
}
public object Fromamap_ResultJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize(json);
}
#region //获取扫码支付数据-----------------------------------------------------------------------------------------
///
/// 获取扫码支付数据
///
protected string getsmpaydata(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["dltype"]) && !String.IsNullOrEmpty(context.Request["sjid"]) && context.Request["openid"] !=null)
{
string strdltype = context.Request["dltype"].ToString();
string strsjid = context.Request["sjid"].ToString();
string paycode = "";
if (!String.IsNullOrEmpty(context.Request["paycode"]))
{
paycode = context.Request["paycode"].ToString();
}
if (System.Text.RegularExpressions.Regex.IsMatch(strdltype, @"^-?\d+$") && System.Text.RegularExpressions.Regex.IsMatch(strsjid, @"^-?\d+$"))
{
int dltype = Convert.ToInt32(strdltype);
int sjid = Convert.ToInt32(strsjid);
string yopenid = context.Request["openid"].ToString();
string appKey = config.webappKey;
string nonceStr = Mtxfw.Utility.Common.CreatenNonce_str();
string timestamp = Mtxfw.Utility.Common.timeStamp();
string signature = "", userid = "";
int ifgetname = 0;
int ifydl = 0;
Double zzjfze = 0.00, zzjfye = 0.00, xfjye = 0.00;
if (yopenid != "")
{
Decimal zzjg = 0;
DataSet zzds = daozzjf.GetList("", "gtype=" + gtype + "");
if (zzds.Tables[0].Rows.Count > 0)
{
zzjg = Convert.ToDecimal(zzds.Tables[0].Rows[0]["zzjg"]);
}
zzds.Clear();
DataSet ds = daoUser.GetList1("id,IFStores,NCName,umoney28,umoney32,umoney37", "(IFStores=0 or IFStores=2) and " + (dltype == 3 ? "openid1" : dltype == 2 ? "openid0" : "openid") + "='" + yopenid + "'");
if (ds.Tables[0].Rows.Count > 0)
{
userid = Mtxfw.Utility.Security.encrypt(Convert.ToInt32(ds.Tables[0].Rows[0]["id"])).ToString();
int IFStores = Convert.ToInt32(ds.Tables[0].Rows[0]["IFStores"]);
string NCName = ds.Tables[0].Rows[0]["NCName"].ToString();
zzjfze = Convert.ToDouble(ds.Tables[0].Rows[0]["umoney28"]);
xfjye = Convert.ToDouble(ds.Tables[0].Rows[0]["umoney32"]);
zzjfye = Convert.ToDouble(zzjfze * Convert.ToDouble(zzjg));
//Mtxfw.Utility.Common.WriteHtml("/weixin/openid0.txt", openid);
if (IFStores == 0)
{
ifydl = 2;
}
else
{
ifydl = 1;
}
if (NCName == "")
{
ifgetname = 1;
}
}
ds.Clear();
}
string openid = "";
if (dltype == 2)
{
if (paycode != "")
{
string weixinresult = Mtxfw.Utility.Common.getPage2("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appKey + "&secret=" + config.webappSecret + "&code=" + paycode + "&grant_type=authorization_code", "", "utf-8", false, false, "");
Mtxfw.Utility.Common.WriteHtml("/weixin/weixinresult.txt", weixinresult);
if (weixinresult.IndexOf("openid") != -1)
{
WXaccess_token ac = null;
ac = (WXaccess_token)FromJson2(weixinresult);
openid = ac.openid;
}
}
string jsapi_ticket = Mtxfw.Utility.Common.getjsapi_ticket(context, appKey, config.webappSecret, config);
string string1 = "";
string tmpStr = Mtxfw.Utility.Common.GetSignature(jsapi_ticket, nonceStr, timestamp, config.webUrl + "/mobile/smpay", out string1);
signature = tmpStr;
Mtxfw.Utility.Common.WriteHtml("/weixin/weixin.txt", jsapi_ticket + "|" + tmpStr + "|" + string1);
}
else if (dltype == 1)
{
}
string sjname = daobusiness.Getzd("companyname", "utype=0 and UserId=" + sjid).ToString();
if (sjname == "")
{
sjname = config.webName;
}
data = "{\"status\":1,\"ifydl\":" + ifydl + ",\"ifgetname\":" + ifgetname + ",\"userid\":\"" + userid + "\",\"openid\":\"" + openid + "\",\"sjname\":\"" + sjname + "\",\"zzjfze\":\"" + zzjfze.ToString() + "\",\"zzjfye\":\"" + zzjfye.ToString("0.####") + "\",\"xfjye\":\"" + xfjye.ToString("0.####") + "\",\"nonceStr\":\"" + nonceStr + "\",\"timestamp\":\"" + timestamp + "\",\"appKey\":\"" + appKey + "\",\"signature\":\"" + signature + "\",\"aliAPP_ID\":\"" + config.aliwebAPP_ID + "\",\"ifbindphone\":\"" + config.FHEnable4 + "\",\"ifxfj\":\"" + config.JDTPEnable + "\"}";
}
else
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = Mtxfw.Utility.Common.GetIP;
mo.addtime = DateTime.Now;
mo.ErrBody = "getsmpaydataerr";
mo.ErrBody2 = strdltype + "|" + strsjid;
new DAL.User_Errlog().Add(mo);
data = "{\"status\":0,\"msg\":\"参数错误,请重新扫码\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //获取支付openid-----------------------------------------------------------------------------------------
///
/// 获取支付openid
///
protected string getopenid(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["dltype"]) && !String.IsNullOrEmpty(context.Request["sjid"]) && context.Request["dlcode"] != null)
{
int dltype = Convert.ToInt32(context.Request["dltype"].ToString());
int sjid = Convert.ToInt32(context.Request["sjid"].ToString());
string result = context.Request["dlcode"].ToString();
int ifpay = 0;
string appKey = config.webappKey;
string appSecret = config.webappSecret;
if (ifpay == 1)
{
appKey = config.webappKey0;
appSecret = config.webappSecret0;
}
string openid = "";
string weixinresult = "";
string code = "";
bool b = true;
int ContactID = 0, uLevel1 = 0;
string ContactIDS = "";
if (b)
{
SqlDataReader dr = daoUser.GetUserName(gtype, sjid);
if (dr.HasRows)
{
if (dr.Read())
{
ContactID = int.Parse(dr["Id"].ToString());
ContactIDS = dr["ContactIDS"].ToString();
uLevel1 = int.Parse(dr["uLevel1"].ToString());
}
}
if (ContactID == 0)
{
b = false;
data = "{\"status\":0,\"msg\":\"门店ID错误\"}";
}
}
if (b)
{
if (dltype == 2)
{
weixinresult = Mtxfw.Utility.Common.getPage2("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appKey + "&secret=" + appSecret + "&code=" + result + "&grant_type=authorization_code", "", "utf-8");
Mtxfw.Utility.Common.WriteHtml("/weixin/weixinresult0.txt", weixinresult + "|" + result);
if (weixinresult.IndexOf("openid") != -1)
{
Mtxfw.shop.WXaccess_token ac = null;
ac = (Mtxfw.shop.WXaccess_token)FromJson2(weixinresult);
openid = ac.openid;
}
else
{
b = false;
data = "{\"status\":0,\"msg\":\"登录微信失败\"}";
}
}
else
{
if (result.IndexOf("auth_code=") != -1)
{
string pattern = @"auth_code=(.*?)&scope=kuaijie";
Regex R = new Regex(pattern);
Match M = R.Match(result);
if (M.Success)
{
code = M.Groups[1].ToString();
}
}
else
{
code = result;
}
//Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxcode.txt", code);
Aop.Api.CertParams certParams = new Aop.Api.CertParams
{
AlipayPublicCertPath = context.Server.MapPath("/App_Data/alipaywebgyzs.crt"),
AppCertPath = context.Server.MapPath("/App_Data/alipaywebyygyzs.crt"),
RootCertPath = context.Server.MapPath("/App_Data/alipaywebgzs.crt")
};
// 创建DefaultAopClient对象并设置相关参数
Aop.Api.IAopClient client = new Aop.Api.DefaultAopClient("https://openapi.alipay.com/gateway.do", config.aliwebAPP_ID, config.aliAPP_PRIVATE_KEY, "json", "1.0", "RSA2", "utf-8", false, certParams);
// 构造AlipaySystemOauthTokenRequest对象并设置必要参数
Aop.Api.Request.AlipaySystemOauthTokenRequest request = new Aop.Api.Request.AlipaySystemOauthTokenRequest();
request.GrantType = "authorization_code";
request.Code = code;
try
{
// 调用SDK接口发送请求并获取结果
Aop.Api.Response.AlipaySystemOauthTokenResponse response = client.CertificateExecute(request);
Mtxfw.Utility.Common.WriteHtml("/weixin/AlipaySystemOauthTokenResponse0.txt", response.IsError + "|" + response.Msg + "|" + response.OpenId + "|" + response.Body);
if (!response.IsError){
openid = response.OpenId;
}
else
{
b = false;
data = "{\"status\":0,\"msg\":\"发生错误0\"}";
}
}
catch (Exception ex)
{
Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxMessage.txt", ex.Message);
b = false;
data = "{\"status\":0,\"msg\":\"发生错误\"}";
}
}
if (b)
{
data = "{\"status\":1,\"openid\":\"" + openid + "\"}";
}
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //绑定手机号-----------------------------------------------------------------------------------------
///
/// 绑定手机号
///
protected string bindphone(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["dltype"]) && !String.IsNullOrEmpty(context.Request["openid"]) && !String.IsNullOrEmpty(context.Request["phone"]) && !String.IsNullOrEmpty(context.Request["phonecode"]))
{
int dltype = Convert.ToInt32(context.Request["dltype"].ToString());
string openid = context.Request["openid"].ToString();
string phone = context.Request["phone"].ToString();
string phonecode = context.Request["phonecode"].ToString();
bool b = true;
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\":\"手机号码格式填写不正确!\"}";
}
}
if (b)
{
Mtxfw.Model.user_info umodel = daoUser.GetModelbyopenid(openid, dltype);
if (umodel != null)
{
if (umodel.IFStores == 2)
{
if (b)
{
if (daoUser.GetCount("IFStores=0 and Phone='" + phone + "' and " + (dltype == 3 ? "openid1" : dltype == 2 ? "openid0" : "openid") + "<>''") > 0)
{
b = false;
data = "{\"status\":0,\"msg\":\"此手机号已绑定别的设备!\"}";
}
}
if (b)
{
if (umodel.PhoneNumber.ToLower() != phonecode)
{
b = false;
data = "{\"status\":0,\"msg\":\"手机验证码不正确!\"}";
}
if (b)
{
if (umodel.PhoneTime != null)
{
DateTime dt1 = DateTime.Now;
DateTime dt2 = umodel.PhoneTime.AddMinutes(30);
if (dt1 > dt2)
{
b = false;
data = "{\"status\":0,\"msg\":\"手机验证码已经失效!\"}";
}
}
}
}
if (b)
{
Double umoney37 = 0.00;
int UserId = 0, ActivateBusID = 0;
DataSet ds = daoUser.GetList1("id,ActivateBusID,umoney37", "gtype=" + gtype + " and IFStores=0 And UserName='" + phone + "'");
if (ds.Tables[0].Rows.Count > 0)
{
UserId = Convert.ToInt32(ds.Tables[0].Rows[0]["id"]);
ActivateBusID = Convert.ToInt32(ds.Tables[0].Rows[0]["ActivateBusID"]);
umoney37 = Convert.ToDouble(ds.Tables[0].Rows[0]["umoney37"]);
}
ds.Clear();
if (UserId == 0)
{
string IP = Mtxfw.Utility.Common.GetIP;
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(config.webMoney114);
model.Password2 = Mtxfw.Utility.Security.EncryptString(config.webMoney119);
model.RealName = "";
model.CSDate = "";
model.NCName = umodel.NCName;
model.UserPic = umodel.UserPic;
model.Sex = "";
model.SFZ = "";
model.Mobile = "";
model.Phone = phone;
model.Email = "";
model.Province = "";
model.City = "";
model.County = "";
model.MailingAddress = "";
model.PostalCode = "";
model.QQ = "";
model.ProductName = "";
model.CompanyName = "";
model.CompanyTel = "";
model.CompanyNumber = "";
model.CompanyCert = "";
model.CompanyPic = "";
model.CompanyProvince = "";
model.CompanyCity = "";
model.CompanyCounty = "";
model.Companyaddress = "";
model.Companylatitude = 0;
model.Companylongitude = 0;
model.Companycontent = "";
model.UserState = "正常";
model.RegTime = DateTime.Now;
model.RegTime2 = DateTime.Now;
/*SqlDataReader Dr = daoUser.GetUserId(Text_RememberID.Text.Trim());
if (Dr.Read())
{
RememberID = int.Parse(Dr["Id"].ToString());
RememberIDS = Dr["RememberIDS"].ToString();
}
Dr.Close();*/
model.RememberID = umodel.RememberID;
model.RememberIDS = "";
model.SuperiorsID = 0;
model.SuperiorsIDS = "";
model.ContactID = umodel.ContactID;
model.ContactIDS = umodel.ContactIDS;
int DLRememberID = 0;
model.DLRememberID = DLRememberID;
model.DLRememberIDS = "";
/*foreach (KeyValuePair kv in Mtxfw.Utility.Common.GetTems())
{
if (model.ContactIDS.IndexOf("," + kv.Key.ToString() + ",") != -1)
{
SJRememberID = kv.Key;
break;
}
}*/
model.SJRememberID = 0;
model.SJRememberIDS = "";
model.umoney20 = umodel.umoney20;
model.umoney21 = umodel.umoney21;
model.uLevel = umodel.uLevel;
model.uLevel0 = umodel.uLevel0;
model.uLevel1 = umodel.uLevel1;
model.uLevel3 = umodel.uLevel3;
model.uLevel5 = umodel.uLevel5;
model.utype = "0";
model.uutype = "0";
model.openid = umodel.openid;
model.openid0 = umodel.openid0;
model.openid1 = umodel.openid1;
model.aopenid = umodel.aopenid;
model.aopenid0 = umodel.aopenid0;
model.aopenid1 = umodel.aopenid1;
model.opentype = 0;
model.opentype2 = 0;
model.session_key = "";
model.unionid = "";
model.refresh_token = "";
model.refresh_token_time = "";
model.IFUpUserName = 0;
model.IP = IP;
model.gtype = gtype;
model.Id = daoUser.Add(model);
daoUser.UpdateuLevel("ActivateBusID", umodel.ActivateBusID, model.Id);
daoUser.UpdatePassword("openid", umodel.aopenid, model.Id);
daoUser.UpdatePassword("openid0", umodel.aopenid0, model.Id);
daoUser.UpdatePassword("openid1", umodel.aopenid1, model.Id);
daoUser.UpdatePassword("aopenid", umodel.aopenid, model.Id);
daoUser.UpdatePassword("openid0", umodel.aopenid0, model.Id);
daoUser.UpdatePassword("openid1", umodel.aopenid1, model.Id);
daoUser.UpdateMoney("umoney27", umodel.umoney27, model.Id);
daoUser.UpdateMoney("umoney28", umodel.umoney28, model.Id);
daoUser.UpdateMoney("umoney37", umodel.umoney37, model.Id);
daoResults.UpdateMemberId(model.Id, "utype=0 and MemberId=" + umodel.Id);
daojl2.Updateutype2(0, "utype=9 and utype2=1 and MemberId=" + umodel.Id);
daojl2.UpdateMemberId(model.Id, "(utype=9 or utype=19) and MemberId=" + umodel.Id);
daoUser.Delete(umodel.Id);
}
else
{
daoUser.UpdateMoney("umoney27", umodel.umoney27, UserId);
daoUser.UpdateMoney("umoney28", umodel.umoney28, UserId);
if (Convert.ToDouble(umodel.umoney37.ToString("f4")) > 0.0000)
{
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = UserId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = umodel.umoney37;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = (umoney37 + umodel.umoney37);
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);
daoUser.UpdateMoney("umoney37", umodel.umoney37, UserId);
}
daoResults.UpdateMemberId(UserId, "utype=0 and MemberId=" + umodel.Id);
daojl2.Updateutype2(0, "utype=9 and utype2=1 and MemberId=" + umodel.Id);
daojl2.UpdateMemberId(UserId, "utype=9 and MemberId=" + umodel.Id);
if (ActivateBusID== 0)
{
daoUser.UpdateuLevel("ActivateBusID", umodel.ActivateBusID, UserId);
Model.User_CZ_log logmodel0 = new Model.User_CZ_log();
logmodel0.MemberId = umodel.ActivateBusID;
logmodel0.AddTime = DateTime.Now;
logmodel0.IP = Mtxfw.Utility.Common.GetIP;
logmodel0.Body = "银花优选" + umodel.UserName + "绑定手机号锁定会员:" + phone + "|" + UserId;
logmodel0.UType = 0;
logmodel0.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel0);
}
daoUser.UpdatePassword("" + (dltype == 3 ? "openid1" : dltype == 2 ? "openid0" : "openid"), openid, UserId);
daoUser.Delete(umodel.Id);
}
data = "{\"status\":1,\"msg\":\"绑定成功\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数openid错误0\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数openid错误\"}";
}
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //扫码支付-----------------------------------------------------------------------------------------
///
/// 扫码支付
///
protected string smpay(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["dltype"]) && !String.IsNullOrEmpty(context.Request["sjid"]) && context.Request["openid"] != null && !String.IsNullOrEmpty(context.Request["paytype"]) && !String.IsNullOrEmpty(context.Request["je"]))
{
int dltype = Convert.ToInt32(context.Request["dltype"].ToString());
int sjid = Convert.ToInt32(context.Request["sjid"].ToString());
string openid = context.Request["openid"].ToString();
int paytype = Convert.ToInt32(context.Request["paytype"].ToString());
string strje = context.Request["je"].ToString();
string openid0 = "";
if (!String.IsNullOrEmpty(context.Request["openid0"]))
{
openid0 = context.Request["openid0"].ToString();
}
int ifshowgzh = 0;
/*if (!String.IsNullOrEmpty(context.Request["ifshowgzh"]))
{
ifshowgzh = Convert.ToInt32(context.Request["ifshowgzh"].ToString());
}*/
Double money = 0.00;
bool b = true;
if (b)
{
if (!System.Text.RegularExpressions.Regex.IsMatch(strje, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(strje, @"^-?\d+$"))
{
b = false;
data = "{\"status\":0,\"msg\":\"支付金额格式错误!\"}";
}
else
{
money = Convert.ToDouble(Convert.ToDouble(strje).ToString("f2"));
if (money < Convert.ToDouble(Convert.ToDouble(config.webMoney77).ToString("f2")))
{
b = false;
data = "{\"status\":0,\"msg\":\"支付金额" + config.webMoney77 + "元起!\"}";
}
}
}
int UserId = 0;
Double yzzjfye = 0.00, zzjfye = 0.00, xfjye = 0.00;
Double yzzjfye0 = 0.00, zzjfye0 = 0.00, ylbfb = 0.00;
string phone = "";
int ifydl = 0;
Decimal zznum = 0, zzjg = 0, zzjf = 0;
int LockBusID = 0;//锁定门店ID
if (b)
{
string Password2 = "";
if (openid0 != "")
{
DataSet zzds = daozzjf.GetList("", "gtype=" + gtype + "");
if (zzds.Tables[0].Rows.Count > 0)
{
zznum = Convert.ToDecimal(zzds.Tables[0].Rows[0]["zznum"]);
zzjg = Convert.ToDecimal(zzds.Tables[0].Rows[0]["zzjg"]);
zzjf = Convert.ToDecimal(zzds.Tables[0].Rows[0]["zzjf"]);
}
zzds.Clear();
DataSet ds = daoUser.GetList1("id,IFStores,RememberID,Password2,phone,umoney28,umoney32,umoney42,umoney46", "(IFStores=0 or IFStores=2) and " + (dltype == 3 ? "openid1" : dltype == 2 ? "openid0" : "openid") + "='" + openid0 + "'");
if (ds.Tables[0].Rows.Count > 0)
{
UserId = Convert.ToInt32(ds.Tables[0].Rows[0]["Id"]);
int IFStores = Convert.ToInt32(ds.Tables[0].Rows[0]["IFStores"]);
LockBusID = Convert.ToInt32(ds.Tables[0].Rows[0]["RememberID"]);
Password2 = ds.Tables[0].Rows[0]["Password2"].ToString();
phone = ds.Tables[0].Rows[0]["phone"].ToString();
yzzjfye = Convert.ToDouble(ds.Tables[0].Rows[0]["umoney28"]);
zzjfye = Convert.ToDouble((yzzjfye * Convert.ToDouble(zzjg)).ToString("0.####"));
xfjye = Convert.ToDouble(ds.Tables[0].Rows[0]["umoney32"]);
yzzjfye0 = Convert.ToDouble(ds.Tables[0].Rows[0]["umoney46"]);
zzjfye0 = Convert.ToDouble((yzzjfye0 * Convert.ToDouble(zzjg)).ToString("0.####"));
if (IFStores == 0)
{
ifydl = 2;
}
else
{
ifydl = 1;
}
}
ds.Clear();
}
//Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxyopenid.txt", ifydl+"|"+openid0);
if (b)
{
if (ifydl == 0)
{
b = false;
data = "{\"status\":0,\"msg\":\"操作失败,openid错误!\"}";
}
}
if (b)
{
if (config.FHEnable3 == "1" && UserId != 87769)
{
b = false;
data = "{\"status\":0,\"msg\":\"暂时不能支付!\"}";
}
}
if (paytype == 0)
{
if (b)
{
if (Convert.ToDouble(money.ToString("f4")) > Convert.ToDouble(zzjfye.ToString("f4")))
{
b = false;
data = "{\"status\":0,\"msg\":\"您的增值积分余额不足!\"}";
}
}
if (b)
{
if (Convert.ToDouble(yzzjfye0.ToString("f4")) > 0.0000)
{
if (Convert.ToDouble(money.ToString("f4")) > Convert.ToDouble(zzjfye0.ToString("f4")))
{
b = false;
data = "{\"status\":0,\"msg\":\"您的可用增值积分不足!\"}";
}
}
}
if (b)
{
if (config.FHEnable4 == "0")
{
if (ifydl != 2)
{
b = false;
data = "{\"status\":0,\"msg\":\"操作失败,未绑定手机号!\"}";
}
}
}
if (b)
{
if (config.FHEnable6 == "1")
{
b = false;
data = "{\"status\":0,\"msg\":\"暂时不能使用增值积分支付!\"}";
}
}
}
else if (paytype == 2)
{
if (b)
{
if (Convert.ToDouble(money.ToString("f4")) > Convert.ToDouble(xfjye.ToString("f4")))
{
b = false;
data = "{\"status\":0,\"msg\":\"您的消费券余额不足!\"}";
}
}
if (b)
{
if (config.JDTPEnable == "1")
{
b = false;
data = "{\"status\":0,\"msg\":\"暂时不能用消费券兑付!\"}";
}
}
if (b)
{
if (config.FHEnable4 == "0")
{
if (ifydl != 2)
{
b = false;
data = "{\"status\":0,\"msg\":\"操作失败,未绑定手机号!\"}";
}
}
}
}
}
if (b)
{
Mtxfw.Model.user_info umodel = daoUser.GetModel(sjid);
if (umodel != null)
{
if (b)
{
if (umodel.uLevel16 < 2)
{
b = false;
data = "{\"status\":0,\"msg\":\"门店未审核!\"}";
}
}
if (b)
{
ylbfb = Convert.ToDouble(umodel.umoney42);
if (paytype == 0 || paytype == 2 || (paytype == 1 && (dltype == 1 && umodel.CompanyNumber != "") || (dltype == 2 && umodel.CompanyCert != "")))
{
DateTime dt = DateTime.Now;
string strq = "银花优选" + (dltype == 2 ? "微信收款" : dltype == 1 ? "支付宝收款" : "" + (paytype == 2 ? "消费券" : "积分") + "兑付") + "" + money.ToString() + "元";
Model.user_Results_jl mjl = new Model.user_Results_jl();
mjl.MemberId = umodel.Id;
mjl.MemberIds = "";
mjl.conent = "http://v.pmhapp.cn:29998/tts.mp3?v=F-zh-CN-Xiaoxiao&txt=" + strq;
mjl.Count1 = 0;
mjl.Count2 = (dltype == 0 ? 1 : 0);//0未支付1已支付
mjl.Count3 = 0;
mjl.Count4 = 0;
mjl.SHFX = dltype;
mjl.utype = 0;
mjl.addtime = dt;
mjl.gtype = gtype;
Int64 mjlid = daojl.Add(mjl);
Model.user_Results_jl2 mjl2;
Int64 ResultId = 0;
string appId = "", timeStamp = "", nonceStr = "", signType = "", paySign = "", rcResult = "";
int alipaying = 0;
string msg = "";
int wxsj = (dltype == 2 ? 0 : 1);
int bid = 0, apaytype = 0;
string province = "", city = "", county = "", Tradingarea = "", bankname = "", bankcard = "", bankaddress = "", accountname = "", huifu_uid = "", token_no0 = "";
DataSet sjds = daobusiness.GetList1("id,province,city,county,Agentrading,InternetSite,Busroutes,Introduction,ContactPeople,huifu_uid,token_no0,paytype", "utype=0 and UserId=" + umodel.Id);
if (sjds.Tables[0].Rows.Count > 0)
{
bid = Convert.ToInt32(sjds.Tables[0].Rows[0]["id"].ToString());
apaytype = Convert.ToInt32(sjds.Tables[0].Rows[0]["paytype"].ToString());
province = sjds.Tables[0].Rows[0]["province"].ToString();
city = sjds.Tables[0].Rows[0]["city"].ToString();
county = sjds.Tables[0].Rows[0]["county"].ToString();
Tradingarea = sjds.Tables[0].Rows[0]["Agentrading"].ToString();
bankname = sjds.Tables[0].Rows[0]["InternetSite"].ToString();
bankcard = sjds.Tables[0].Rows[0]["Busroutes"].ToString();
bankaddress = sjds.Tables[0].Rows[0]["Introduction"].ToString();
accountname = sjds.Tables[0].Rows[0]["ContactPeople"].ToString();
huifu_uid = sjds.Tables[0].Rows[0]["huifu_uid"].ToString();
token_no0 = sjds.Tables[0].Rows[0]["token_no0"].ToString();
}
sjds.Clear();
if (paytype == 0 || paytype == 2)
{
if (umodel.uLevel36 == 1)
{
if (umodel.uLevel37 == 0)
{
daoUser.UpdateuLevel("uLevel37", 1, umodel.Id);
}
}
Double zmoney = money;
Double paymoney = 0.00;
if (paytype == 2)
{
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = UserId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = -money;
mjl2.Cutmoney = Convert.ToDouble(zzjg);
mjl2.Totalmoney = (xfjye - money);
mjl2.addtime = dt;
mjl2.BZContent = "消费券兑付";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 4;
mjl2.utype2 = 0;
mjl2.Seef = 0;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
Int64 jl2id0 = daojl2.Add(mjl2);
daoUser.UpdateMoney("umoney32", -money, UserId);
}
else
{
paymoney = Convert.ToDouble((money / Convert.ToDouble(zzjg)).ToString("0.####"));
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = UserId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = -paymoney;
mjl2.Cutmoney = Convert.ToDouble(zzjg);
mjl2.Totalmoney = (yzzjfye - paymoney);
mjl2.addtime = dt;
mjl2.BZContent = "积分兑付";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 9;
mjl2.utype2 = 0;
mjl2.Seef = 0;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
Int64 jl2id0 = daojl2.Add(mjl2);
daoUser.UpdateMoney("umoney28", -paymoney, UserId);
if (Convert.ToDouble(yzzjfye0.ToString("f4")) > 0.0000)
{
mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = UserId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = -paymoney;
mjl2.Cutmoney = 0;
mjl2.Totalmoney = (yzzjfye0 - paymoney);
mjl2.addtime = dt;
mjl2.BZContent = "积分兑付";
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 24;
mjl2.utype2 = 0;
mjl2.Seef = 0;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
jl2id0 = daojl2.Add(mjl2);
daoUser.UpdateMoney("umoney46", -paymoney, UserId);
}
}
if (daoopenids.GetCount("ttype=" + (dltype == 2 ? 1 : 0) + " and openid='" + openid0 + "'") == 0)
{
Model.User_openids omodel = new Model.User_openids();
omodel.MemberId = UserId;
omodel.SJId = umodel.Id;
omodel.openid = openid;
omodel.addtime = DateTime.Now;
omodel.ttype = (dltype == 2 ? 1 : 0);
omodel.gtype = 0;
daoopenids.Add(omodel);
LockBusID = umodel.Id;
}
else
{
string strid = daoopenids.Getzd("SJId", "ttype=" + (dltype == 2 ? 1 : 0) + " and openid='" + openid0 + "'").ToString();
if (strid != "")
{
int LockBusID0 = Convert.ToInt32(strid);
if (LockBusID0 == 0)
{
if (LockBusID == 0)
{
daoUser.UpdateuLevel("LockBusID", umodel.Id, UserId);
LockBusID = umodel.Id;
Model.User_CZ_log logmodel0 = new Model.User_CZ_log();
logmodel0.MemberId = umodel.Id;
logmodel0.AddTime = DateTime.Now;
logmodel0.IP = Mtxfw.Utility.Common.GetIP;
logmodel0.Body = "银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付锁定会员:" + phone + "|" + UserId;
logmodel0.UType = 0;
logmodel0.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel0);
}
daoopenids.UpdateSJId(LockBusID, (dltype == 2 ? 1 : 0), openid);
}
else
{
LockBusID = LockBusID0;
}
}
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = UserId;
logmodel.AddTime = dt;
logmodel.IP = (umodel.Id == 10154 ? "119.39.248.32" : Mtxfw.Utility.Common.GetIP);
logmodel.Body = "银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
if (umodel.CompanyPic != "")
{
string t = Mtxfw.Utility.Common.timeStamp();
string tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyPic + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
string strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27905/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyPic;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyPic + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27904/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "积分兑付exec:29999";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyPic;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyPic + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27900/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "积分兑付exec1:27900";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyPic;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyPic + "|" + t + "|tts|银花优选积分兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27901/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27901";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyPic;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyPic + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27902/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27902";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyPic;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyPic + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27903/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27903";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyPic;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
}
}
}
}
}
}
}
if (umodel.CompanyProvince != "")
{
string t = Mtxfw.Utility.Common.timeStamp();
string tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyProvince + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
string strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27905/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyProvince;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyProvince + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27904/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec:29999";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyProvince;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyProvince + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27900/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27900";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyProvince;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyProvince + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27901/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27901";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyProvince;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyProvince + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27902/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27902";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyProvince;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyProvince + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27903/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27903";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyProvince;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
}
}
}
}
}
}
}
if (umodel.CompanyCity != "")
{
string t = Mtxfw.Utility.Common.timeStamp();
string tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyCity + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
string strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27905/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
Model.User_Errlog mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyCity;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyCity + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27904/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec:29999";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyCity;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyCity + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27900/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27900";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyCity;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyCity + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27901/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27901";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyCity;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyCity + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27902/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27902";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyCity;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
t = Mtxfw.Utility.Common.timeStamp();
tsign = Mtxfw.Utility.Interface_WxPay.GetMD5(t + "3596", "utf-8");
strq = "exec|" + umodel.CompanyCity + "|" + t + "|tts|银花优选" + (paytype == 2 ? "消费券" : "积分") + "兑付" + money.ToString() + "元";
strr = Mtxfw.Utility.Common.getPage2("http://v.pmhapp.cn:27903/exec?t=" + t + "&tsign=" + tsign, "", "utf-8", false, true, strq);
if (strr != "OK")
{
mo = new Model.User_Errlog();
mo.DLID = 0;
mo.ErrType = "" + (paytype == 2 ? "消费券" : "积分") + "兑付exec1:27903";
mo.addtime = DateTime.Now;
mo.ErrBody = umodel.CompanyCity;
mo.ErrBody2 = strr;
new DAL.User_Errlog().Add(mo);
}
}
}
}
}
}
}
}
else
{
Double JFZSubTotal = money;
string PayID = dt.ToString("yyMMddHHmmssffff", DateTimeFormatInfo.InvariantInfo);
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;//是否已发起订单确认0否1是
ModelResults.b16 = apaytype;//0汇聚支付1汇付支付
ModelResults.b17 = dltype;
ModelResults.b18 = 1;
ModelResults.conent = "扫码支付";
ModelResults.Totalmoney = JFZSubTotal;
ModelResults.MemberId = sjid;
ModelResults.UserId = UserId;
ModelResults.ListNumber = PayID;
ModelResults.Managers = mjlid.ToString();
ModelResults.Seef = 0;
ModelResults.utype = "9";
ModelResults.addtime = dt;
ModelResults.gtype = gtype;
ResultId = daoResults.Add(ModelResults);
daoResults.UpdateOrderIds(openid0, ResultId);
string body = "扫码支付";
if (apaytype == 0)
{
string p0_Version = "2.1";
string p1_MerchantNo = config.hjpay_ID;
string p2_OrderNo = PayID;
string p3_Amount = JFZSubTotal.ToString("f2");
string p4_Cur = "1";
string p5_ProductName = body;
//string p6_ProductDesc = "";
//string p7_Mp = "";
//string p8_ReturnUrl = config.webUrl + "/pay/receive_notify.aspx";
string p9_NotifyUrl = config.webUrl + "/pay/receive_notify.aspx";
string q1_FrpCode = (dltype == 2 ? (wxsj == 1 ? "WEIXIN_NATIVE" : "WEIXIN_GZH") : "ALIPAY_NATIVE");//(ifshowgzh == 1 ? "WEIXIN_GZH" :
//string q2_MerchantBankCode = "";
//string q3_SubMerchantNo = "";
string q4_IsShowPic = "1";
string q5_OpenId = openid;
//string q6_AuthCode = "";
string q7_AppId = config.webappKey;
string q8_TerminalNo = "";
string qa_TradeMerchantNo = (dltype == 2 ? (umodel.CompanyCert != "" ? umodel.CompanyCert : "777112000720172") : (umodel.CompanyNumber != "" ? umodel.CompanyNumber : "777112000720172"));
//string qk_DisablePayModel = "";
string strsign = p0_Version + p1_MerchantNo + p2_OrderNo + p3_Amount + p4_Cur + p5_ProductName + p9_NotifyUrl + q1_FrpCode + q4_IsShowPic;
if (dltype == 2 && (wxsj == 0))// || (wxsj == 1 && ifshowgzh == 1)
{
strsign += q5_OpenId + q7_AppId;
}
strsign += 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
+ "&q4_IsShowPic=" + q4_IsShowPic;
if (dltype == 2 && (wxsj == 0))// || (wxsj == 1 && ifshowgzh == 1)
{
postdata += "&q5_OpenId=" + q5_OpenId + "&q7_AppId=" + q7_AppId;
}
postdata += "&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, "");
//Mtxfw.Utility.Common.WriteHtml("/weixin/rcHasError.txt", retValue.ErrorCode+"|"+retValue.Message + "|" + strsign + "|" + postdata);
if (!retValue.HasError)
{
hjpay_NATIVEreturns hjpay = (hjpay_NATIVEreturns)Fromhjpay_NATIVEreturnsJson(retValue.Message);
//Mtxfw.Utility.Common.WriteHtml("/weixin/rcMessage.txt", retValue.Message);
if (hjpay.ra_Code == "100")
{
if (dltype == 2)
{
if (wxsj == 0)// || (wxsj == 1 && ifshowgzh == 1)
{
kjpay_returns_gzhdata hjpay0 = (kjpay_returns_gzhdata)Fromkjpay_returns_gzhdata(hjpay.rc_Result);
rcResult = hjpay0.package;
appId = hjpay0.appId;
timeStamp = hjpay0.timeStamp;
nonceStr = hjpay0.nonceStr;
signType = hjpay0.signType;
paySign = hjpay0.paySign;
}
else
{
rcResult = hjpay.rc_Result;
}
}
else
{
rcResult = hjpay.rc_Result;
Mtxfw.Utility.Common.WriteHtml("/weixin/rcResult.txt", rcResult);
}
}
else
{
Mtxfw.Utility.Common.WriteHtml("/weixin/hmac.txt", strsign + "|" + postdata + "|" + retValue.Message);
b = false;
data = "{\"status\":0,\"msg\":\"获取支付信息错误0\"}";
}
}
}
else
{
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 = (dltype == 1 ? umodel.CompanyNumber : umodel.CompanyCert);
string goods_desc = body;
string trade_type = (dltype == 2 ? "T_JSAPI" : "A_NATIVE");//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 = "";
if (dltype == 2)
{
wx_data = "{\\\"sub_appid\\\":\\\"" + config.webappKey + "\\\",\\\"sub_openid\\\":\\\"" + openid + "\\\"}";
}
string delay_acct_flag = "N";
string percentage_div = (100 - (ylbfb)).ToString("f2");
string acct_split_bunch = "{\\\"acct_infos\\\":[{\\\"huifu_id\\\":\\\"" + (dltype == 1 ? umodel.CompanyNumber : umodel.CompanyCert) + "\\\",\\\"percentage_div\\\":\\\"" + percentage_div + "\\\"},{\\\"huifu_id\\\":\\\"" + config.hfpayMerchantID + "\\\",\\\"percentage_div\\\":\\\"" + (ylbfb).ToString("f2") + "\\\"}],\\\"percentage_flag\\\":\\\"Y\\\",\\\"is_clean_split\\\":\\\"N\\\"}";
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);
if (wx_data != "")
{
pay_dic.Add("wx_data", wx_data);
}
pay_dic.Add("trans_amt", trans_amt);
pay_dic.Add("delay_acct_flag", delay_acct_flag);
pay_dic.Add("acct_split_bunch", acct_split_bunch);
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 strq0 = "{";
strq0 += "\"sys_id\":\"" + sys_id + "\",";
strq0 += "\"product_id\":\"" + product_id + "\",";
strq0 += "\"data\":{";
strq0 += "\"req_date\":\"" + req_date + "\",";
strq0 += "\"req_seq_id\":\"" + req_seq_id + "\",";
strq0 += "\"huifu_id\":\"" + huifu_id + "\",";
strq0 += "\"goods_desc\":\"" + goods_desc + "\",";
strq0 += "\"trade_type\":\"" + trade_type + "\",";
if (wx_data != "")
{
strq0 += "\"wx_data\":\"" + wx_data + "\",";
}
strq0 += "\"trans_amt\":\"" + trans_amt + "\",";
strq0 += "\"delay_acct_flag\":\"" + delay_acct_flag + "\",";
strq0 += "\"acct_split_bunch\":\"" + acct_split_bunch + "\",";
strq0 += "\"time_expire\":\"" + time_expire + "\",";
strq0 += "\"notify_url\":\"" + notify_url + "\"";
strq0 += "}";
strq0 += ",\"sign\":\"" + get_PaySign + "\"";
strq0 += "}";
string strResult = Mtxfw.Utility.Common.getPage2("https://api.huifu.com/v2/trade/payment/jspay", "", "utf-8", true, true, strq0);
Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxstrResult.txt", strResult);
huifuresult hr = (huifuresult)FromhuifuresultJson(strResult);
if (hr.data.resp_code == "00000100")
{
if (dltype == 2)
{
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);
rcResult = hjrc_Result.package;
appId = hjrc_Result.appId;
timeStamp = hjrc_Result.timeStamp;
nonceStr = hjrc_Result.nonceStr;
paySign = hjrc_Result.paySign;
signType = hjrc_Result.signType;
}
else
{
huifuresult1 hr0 = (huifuresult1)Fromhuifuresult1Json(strResult);
rcResult = hr0.data.qr_code;
}
}
else
{
msg = hr.data.resp_desc;
alipaying = 1;
Mtxfw.Utility.Common.WriteHtml("/weixin/apiajaxstrResulterr.txt", strResult + "|" + strq0);
}
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = UserId;
logmodel.AddTime = dt;
logmodel.IP = (umodel.Id == 10154 ? "119.39.248.32" : Mtxfw.Utility.Common.GetIP);
logmodel.Body = "银花优选线下扫码付款" + JFZSubTotal + "元去付款,支付方式:" + (dltype == 2 ? "微信支付" : "支付宝");
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
}
if (alipaying == 0)
{
if (b)
{
data = "{\"status\":1,\"ResultId\":" + ResultId + ",\"wxsj\":" + wxsj + ",\"appId\":\"" + appId + "\",\"timeStamp\":\"" + timeStamp + "\",\"nonceStr\":\"" + nonceStr + "\",\"signType\":\"" + signType + "\",\"paySign\":\"" + paySign + "\",\"rcResult\":\"" + rcResult + "\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"" + msg + "\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"门店未绑定商户号\"}";
}
}
}
else
{
data = "{\"status\":0,\"msg\":\"门店ID有错误\"}";
}
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
public object Fromhuifupayresult1Json(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 FromhuifubasicdataresultJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize(json);
}
public object FromhuifucardlistJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize>(json);
}
#endregion
#region //获取扫码积分记录-----------------------------------------------------------------------------------------
///
/// 获取扫码积分记录
///
protected string getsmjflog(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["dltype"]) && !String.IsNullOrEmpty(context.Request["openid"]))
{
int dltype = Convert.ToInt32(context.Request["dltype"].ToString());
string openid = context.Request["openid"].ToString();
Mtxfw.Model.user_info model = daoUser.GetModelbyopenid(openid, dltype);
if (model != null)
{
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,seef,BZContent", "", "gtype=" + gtype + " and utype=9 And IFDelete=0 and MemberId=" + model.Id + " and seef=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 addtime = Dr["addtime"].ToString();
int seef = Convert.ToInt32(Dr["seef"]);
string content = Dr["BZContent"].ToString();
strdata += "{\"id\":\"" + id + "\",\"sl\":\"" + sl + "\",\"jg\":\"" + jg + "\",\"addtime\":\"" + addtime + "\",\"seef\":\"" + seef + "\",\"content\":\"" + content + "\"}";
if (i != ds.Tables[1].Rows.Count - 1)
{
strdata += ",";
}
i += 1;
}
}
ds.Clear();
data = "{\"status\":1,\"data\":[" + strdata + "]}";
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误2\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //获取扫码红包数据-----------------------------------------------------------------------------------------
///
/// 获取扫码红包数据
///
protected string getsmhbdata(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["dltype"]) && context.Request["openid"] !=null)
{
string strdltype = context.Request["dltype"].ToString();
if (System.Text.RegularExpressions.Regex.IsMatch(strdltype, @"^-?\d+$"))
{
int dltype = Convert.ToInt32(strdltype);
string openid = context.Request["openid"].ToString();
int userid = 0;
if (openid != "")
{
DataSet ds = daoUser.GetList1("id", "(IFStores=0 or IFStores=2) and " + (dltype == 3 ? "openid1" : dltype == 2 ? "openid0" : "openid") + "='" + openid + "'");
if (ds.Tables[0].Rows.Count > 0)
{
userid = Convert.ToInt32(ds.Tables[0].Rows[0]["id"]);
}
ds.Clear();
}
Int64 rid = 0;
if (userid > 0)
{
string strzd = daojl2.Getzd("id", "utype=31 and IFDelete=0 and MemberId=" + userid + " and seef=0").ToString();
if (strzd != "")
{
rid = Convert.ToInt64(strzd);
}
}
if (rid > 0)
{
data = "{\"status\":1,\"rid\":\"" + rid + "\"}";
}
else
{
data = "{\"status\":0,\"msg\":\"获取失败\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误,请重新扫码\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //领取扫码红包-----------------------------------------------------------------------------------------
///
/// 领取扫码红包
///
protected string lqsmhb(HttpContext context)
{
string data = "{\"status\":0}";
if (!String.IsNullOrEmpty(context.Request["dltype"]) && !String.IsNullOrEmpty(context.Request["rid"]) && context.Request["openid"] !=null)
{
string strdltype = context.Request["dltype"].ToString();
string strrid=context.Request["rid"].ToString();
if (System.Text.RegularExpressions.Regex.IsMatch(strdltype, @"^-?\d+$") && System.Text.RegularExpressions.Regex.IsMatch(strrid, @"^-?\d+$"))
{
int dltype = Convert.ToInt32(strdltype);
string openid = context.Request["openid"].ToString();
int userid = 0;
Double yzzjfye = 0.00;
if (openid != "")
{
DataSet ds = daoUser.GetList1("id,umoney28", "(IFStores=0 or IFStores=2) and " + (dltype == 3 ? "openid1" : dltype == 2 ? "openid0" : "openid") + "='" + openid + "'");
if (ds.Tables[0].Rows.Count > 0)
{
userid = Convert.ToInt32(ds.Tables[0].Rows[0]["id"]);
yzzjfye = Convert.ToDouble(ds.Tables[0].Rows[0]["umoney28"]);
}
ds.Clear();
}
Int64 rid = 0;
if (userid > 0)
{
rid = Convert.ToInt64(strrid);
Model.user_Results_jl2 jlmodel = daojl2.GetModel(rid);
if (jlmodel != null)
{
if (jlmodel.utype == 31)
{
if (jlmodel.IFDelete == 0)
{
if (jlmodel.MemberId == userid)
{
if (jlmodel.Seef == 0)
{
DateTime dt = DateTime.Now;
daojl2.UpdateSeef("seef", 1, "seeftime", dt, jlmodel.Id);
Decimal zznum = 0, zzjg = 0, zzjf = 0;
DataSet zzds = daozzjf.GetList("", "gtype=" + gtype + "");
if (zzds.Tables[0].Rows.Count > 0)
{
zznum = Convert.ToDecimal(zzds.Tables[0].Rows[0]["zznum"]);
zzjg = Convert.ToDecimal(zzds.Tables[0].Rows[0]["zzjg"]);
zzjf = Convert.ToDecimal(zzds.Tables[0].Rows[0]["zzjf"]);
}
zzds.Clear();
Model.user_Results_jl2 mjl2 = new Model.user_Results_jl2();
mjl2.MemberId = jlmodel.MemberId;
mjl2.MemberId2 = 0;
mjl2.Addmoney = jlmodel.Addmoney;
mjl2.Cutmoney = Convert.ToDouble(zzjg);
mjl2.Totalmoney = (yzzjfye + jlmodel.Addmoney);
mjl2.addtime = dt;
mjl2.BZContent = jlmodel.BZContent;
mjl2.PayID = "";
mjl2.OrdersIDs = "";
mjl2.OrdersID = 0;
mjl2.utype = 9;
mjl2.utype2 = 1;
mjl2.Seef = 0;
mjl2.seeftime = dt;
mjl2.gtype = gtype;
Int64 jl2id = daojl2.Add(mjl2);
daojl2.Updatemoney("Totalmoney0", jlmodel.Totalmoney, jl2id);
daoUser.UpdateMoney("umoney28", jlmodel.Addmoney, jlmodel.MemberId);
daoUser.UpdateMoney("umoney4", jlmodel.Addmoney, jlmodel.MemberId);
DAL.MemberStatistics.Statistics(dt, jlmodel.MemberId, 0, (jlmodel.PayID != "" ? Convert.ToInt64(jlmodel.PayID) : 0), 2, 1, 1, jlmodel.BZContent, gtype);
data = "{\"status\":1,\"msg\":\"领取成功\"}";
}
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\":\"参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"登录参数错误\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数错误,请重新扫码\"}";
}
}
else
{
data = "{\"status\":0,\"msg\":\"参数为空\"}";
}
return data;
}
#endregion
#region //注销账号-----------------------------------------------------------------------------------------
///
/// 注销账号
///
protected string cancelaccount(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());
Mtxfw.Model.user_info model = new Mtxfw.DAL.user_info().GetModel(userId);
if (model != null)
{
if (model.LoginId == LoginId)
{
bool b = true;
b = false;
data = "{\"status\":0,\"msg\":\"暂时不能注销账号!\"}";
if (b)
{
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 = (ifweb == 0 ? "app" : "web") + "注销账号";
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
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;
string TXEnable0 = config.DZBZRDHBEnable;
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";
}
}
}
if (TXEnable0 == "0")
{
DayOfWeek day = dt.DayOfWeek;
string dayString = day.ToString().ToLower();
string HSJEnable = Mtxfw.Utility.Common.cweek(config.HSJEnable);
if (config.HSJEnable.IndexOf(dayString) == -1)
{
TXEnable0 = "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)
{
TXEnable0 = "1";
}
}
}
string ZZEnable = (umodel.uLevel47 == 1 ? "0" : config.JJBZZEnable);
string ZZEnable0 = (umodel.uLevel47 == 1 ? "0" : config.DZBZZEnable);
string ZZEnable1 = (umodel.uLevel47 == 1 ? "0" : config.FHEnable2);
string ZHEnable = "1";
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.uLevel == 1)
{
struLevel += "";
}
else if (umodel.uLevel == 2)
{
struLevel += "";
}*/
/*if (umodel.uLevel4 > 0)
{
struLevel += "-" + Mtxfw.Utility.Common.GetuLevel4name(umodel.uLevel4);
}*/
string struLevel0 = "普通会员";
string struLevel1 = "";
string xjjye = (umodel.umoney - umodel.umoney17).ToString("0.####");
string cfxfye = umodel.umoney22.ToString("0.####");
string ggjye = umodel.umoney29.ToString("0.####");
string dhjye = umodel.umoney30.ToString("0.####");
string btjye = umodel.umoney31.ToString("0.####");
string hkksye = umodel.umoney39.ToString("0.####");
string hkdjye = umodel.umoney40.ToString("0.####");
string hkjdye = umodel.umoney41.ToString("0.####");
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("f2"), jrsymoney = umodel.umoney24.ToString("f2"), zrsymoney = umodel.umoney25.ToString("f2");
int ordercount = daoorder.GetCount("ttype<>1 and IFDelete=0 and UserID=" + umodel.Id + " and O_Payed=0");
int ordercount0 = daoorder.GetCount("ttype<>1 and IFDelete=0 and UserID=" + umodel.Id + " and O_Payed=1");
int ordercount1 = daoorder.GetCount("ttype<>1 and IFDelete=0 and UserID=" + umodel.Id + " and O_Payed=2");
int ordercount2 = daoorder.GetCount("ttype<>1 and IFDelete=0 and UserID=" + umodel.Id + " and O_Payed=3");
Double zhsxf = 0.00;
//zhsxf = Mtxfw.Utility.Common.GetSXF(umodel.uLevel, config);
int wgkcount = 0, ygkcount = umodel.uLevel20, wgkcount0 = 0, ygkcount0 = umodel.uLevel23;
/*wgkcount = (Convert.ToInt32(config.webMoney82) - ygkcount);
if (wgkcount < 0)
{
wgkcount = 0;
}
/*wgkcount0 = (Convert.ToInt32(config.webMoney83) - ygkcount0);
if (wgkcount0 < 0)
{
wgkcount0 = 0;
}*/
strdata = "\"userInfo\":{\"point\":\"" + umodel.umoney30 + "\",\"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 + ",\"Paypush\":\"" + umodel.uLevel36 + "\",\"ifsmrz\":" + umodel.uLevel18 + ",\"UserName\":\"" + umodel.UserName + "\",\"NCName\":\"" + NCName + "\",\"RealName\":\"" + umodel.RealName + "\",\"Phone\":\"" + Phone + "\",\"Email\":\"" + umodel.Email + "\",\"UserPic\":\"" + (UserPic != "" ? Mtxfw.Utility.Common.cminimage(UserPic) : "../image/logo.png") + "\",\"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 + "\",\"xjjye\":\"" + xjjye + "\",\"ggjye\":\"" + ggjye + "\",\"dhjye\":\"" + dhjye + "\",\"btjye\":\"" + btjye + "\",\"hkksye\":\"" + hkksye + "\",\"hkdjye\":\"" + hkdjye + "\",\"hkjdye\":\"" + hkjdye + "\",\"ordercount\":\"" + ordercount + "\",\"ordercount0\":\"" + ordercount0 + "\",\"ordercount1\":\"" + ordercount1 + "\",\"ordercount2\":\"" + ordercount2 + "\",\"GGEnable\":\"" + config.FHEnable1 + "\",\"TXEnable\":\"" + TXEnable + "\",\"ZZEnable\":\"" + ZZEnable + "\",\"ZZEnable0\":\"" + ZZEnable0 + "\",\"ZZEnable1\":\"" + ZZEnable1 + "\",\"TXEnable0\":\"" + TXEnable0 + "\",\"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 + "\",\"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 FromcodeJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize(json);
}
public object FromstatusJson(string json)
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Deserialize(json);
}
public object FromsfzcodeJson(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_NATIVEreturnsJson(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 Fromkjpay_returns_gzhdata(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 returnProvincedata
{
public List Province { get; set; }
}
public class Provincedata
{
public String ProvinceID { get; set; }
public String ProvinceName { get; set; }
public List City { get; set; }
}
public class Citydata
{
public String CityID { get; set; }
public String CityName { get; set; }
public List County { get; set; }
}
public class Countydata
{
public String CountyID { get; set; }
public String CountyName { get; set; }
}
public class returncode
{
public String code { get; set; }
public String msg { get; set; }
}
public class returnstatus
{
public int status { get; set; }
public String msg { get; set; }
}
public class returnsfzcode
{
public String msg { get; set; }
public bool success { get; set; }
public int code { get; set; }
public returnsfzdata data { get; set; }
}
public class returnsfzdata
{
public int result { get; set; }
public String desc { get; set; }
public String sex { get; set; }
}
public class huifuresult
{
public huifuresult0 data { get; set; }
}
public class huifuresult0
{
public String resp_code { get; set; }
public String resp_desc { get; set; }
}
public class huifuresult1
{
public huifupayresult data { get; set; }
}
public class huifuresult2
{
public huifupayresult0 data { get; set; }
}
public class huifupayresult
{
public String qr_code { get; set; }
}
public class huifupayresult0
{
public String pay_info { get; set; }
}
public class huifupayresult1
{
public String req_seq_id { get; set; }
public String trans_stat { get; set; }
public String out_trans_id { get; set; }
public String party_order_id { get; set; }
}
public class huifupayresult2
{
public String req_seq_id { get; set; }
public String trans_status { get; set; }
public String acct_status { get; set; }
public String channel_status { get; set; }
}
public class huifubasicdataresult
{
public huifubasicdataresult0 data { get; set; }
}
public class huifubasicdataresult0
{
public String qry_cash_card_info_list { get; set; }
}
public class huifucardlist
{
public String bank_name { get; set; }
public String card_no { get; set; }
public String status { get; set; }
public String token_no { get; set; }
}
public class amap_Result
{
public String status { get; set; }
public String info { get; set; }
public List geocodes{ get; set; }
}
public class amap_Result0
{
public String location { get; set; }
}
}