Files
g.hnyhua.cn/Mtxfw.VipSite/Admin_Member_Products_Orders0.aspx.cs
2026-02-07 15:48:27 +08:00

560 lines
28 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;
namespace Mtxfw.VipSite
{
public partial class Admin_Member_Products_Orders0 : Mtxfw.Utility.MemberBase
{
Mtxfw.DAL.user_Results daoResults = new Mtxfw.DAL.user_Results();
Mtxfw.DAL.order_product_info daoorderproduct = new Mtxfw.DAL.order_product_info();
Mtxfw.DAL.order_info daoorder = new Mtxfw.DAL.order_info();
Mtxfw.Model.order_info model = new Mtxfw.Model.order_info();
Mtxfw.DAL.user_info daouser = new Mtxfw.DAL.user_info();
public Mtxfw.DAL.P_Product daoProduct = new Mtxfw.DAL.P_Product();
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
public int gtype = 0, t = 0;
public string strTitle = "批发订单";
#region
private bool _refreshState;
private bool _isRefresh;
/// <summary>
/// 判断页面是否刷新
/// </summary>
public bool IsRefresh
{
get
{
return _isRefresh;
}
}
protected override void LoadViewState(object savedState)
{
object[] allStates = (object[])savedState;
base.LoadViewState(allStates[0]);
_refreshState = (bool)allStates[1];
_isRefresh = _refreshState == (bool)Session["__ISREFRESH"];
}
protected override object SaveViewState()
{
Session["__ISREFRESH"] = _refreshState;
object[] allStates = new object[2];
allStates[0] = base.SaveViewState();
allStates[1] = !_refreshState;
return allStates;
}
#endregion
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string hostname = Request.Url.Host;
if (!String.IsNullOrEmpty(Request.QueryString["t"]))
{
t = Convert.ToInt32(Request.QueryString["t"].ToString());
}
if (t == 1)
{
strTitle = "申请退货订单";
}
if (!IsPostBack)
{
foreach (KeyValuePair<int, string> kv in Mtxfw.Utility.Common.GetTems())
{
Drop_Tem.Items.Add(new ListItem(kv.Value, kv.Key.ToString()));
}
if (Session["IFPassword"] == null)
{
Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_Products_Orders0.aspx");
}
if (IFStores != 1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
if (MemberJS.IndexOf("批发管理") == -1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
Page.Title = strTitle + GetWebName;
Data_Bind();
}
MyPager.PageChanged += delegate(object s, EventArgs ex)
{
Data_Bind();
};
}
protected String GetProvince()
{
StringBuilder sb = new StringBuilder();
Mtxfw.DAL.province daoPro = new Mtxfw.DAL.province();
System.Data.DataSet Ds = daoPro.GetCacheList("", "1=1 Order by Id Asc", "Province");
System.Data.DataTable Dt = (Ds != null && Ds.Tables[0] != null) ? Ds.Tables[0] : null;
foreach (System.Data.DataRow Dr in Dt.Rows)
{
sb.Append("<option value=\"" + Dr["ProvinceID"] + "\">" + Dr["ProvinceName"] + "</option>\r\n");
}
return sb.ToString();
}
protected void Data_Bind()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
String MemberId = HttpUtility.UrlDecode(Request.QueryString["MemberId"]);
String key = HttpUtility.UrlDecode(Request.QueryString["key"]);
String state = HttpUtility.UrlDecode(Request.QueryString["state"]);
//String ttype = HttpUtility.UrlDecode(Request.QueryString["ttype"]);
String paytype = HttpUtility.UrlDecode(Request.QueryString["paytype"]);
String peitype = HttpUtility.UrlDecode(Request.QueryString["peitype"]);
String tem = HttpUtility.UrlDecode(Request.QueryString["tem"]);
sb.Append(" and ttype=2 and ptype=1 and (Select Count(id) From User_info b where b.id=UserId)>0");
if (t == 1)
{
sb.Append(" and (O_Payed='6' or O_Payed='7')");
}
else
{
sb.Append(" and (O_Payed<>'6' and O_Payed<>'7')");
}
if (!String.IsNullOrEmpty(paytype))
{
sb.Append(" and utype=" + paytype);
Drop_paytype.Text = paytype;
}
if (!String.IsNullOrEmpty(peitype))
{
sb.Append(" and peitype=" + peitype);
Drop_peitype.Text = peitype;
}
if (!String.IsNullOrEmpty(state))
{
if (state == "1")
{
sb.Append(" And ifxnhy=0");
}
else if (state == "2")
{
sb.Append(" And pcount>0");
}
else if (state == "3")
{
sb.Append(" And ypcount>0");
}
else if (state == "4")
{
sb.Append(" And ypznum>0");
}
Drop_State.Text = state;
}
if (!String.IsNullOrEmpty(MemberId))
{
sb.Append("and MemberId=" + MemberId);
}
if (!String.IsNullOrEmpty(tem))
{
sb.Append(" and ptgroup=" + tem + "");
Drop_Tem.SelectedValue = tem;
}
if (!String.IsNullOrEmpty(key))
{
if (!System.Text.RegularExpressions.Regex.IsMatch(key, @"^[1]+[1,2,3,4,5,6,7,8,9]+\d{9}$"))
{
sb.Append("and (orderid like '%" + key + "%' Or Contactname like '%" + key + "%' Or Contacttel like '%" + key + "%' Or yundanhao like '%" + key + "%' Or UserID in (select id from user_info b where b.IFStores=0 and (b.UserName like '%" + key + "%' or b.realname like '%" + key + "%')))");
}
else
{
sb.Append("and (Contacttel like '%" + key + "%' Or UserID in (select id from user_info b where b.IFStores=0 and (b.UserName like '%" + key + "%')))");
}
}
string groupby = "";
string strOrder = " addtime desc";
int Start = 0;
int Limit = 0;
Int32 Recount = 0;
MyPager.PageSize = 50;
Start = MyPager.PageSize * (MyPager.CurrentPageIndex - 1);
Limit = MyPager.PageSize;
DataSet dss = daoorder.GetDataSet(groupby, strOrder, "ID,ttype,utype,orderid,ptype,peitype,O_SubmitDate,addtime,O_Payed,O_Payed_date,O_Shipped,O_Shipped_date,O_received,O_received_date,kdcompay,yundanhao,Guests,wlremarks,Contactname,Contacttel,Province,City,County,Address,Address0,Totalnum,pcount,ypcount,ypznum,Totalprice,refundstatus,refund_channel,user_received_account,success_time,ptgroup,O_Seef,O_ReturnReason,(select UserName from user_info c where c.ID=UserID) as UserName,(select RealName from user_info c where c.ID=UserID) as RealName", "", "gtype=" + gtype + " and IFDelete=0" + sb.ToString(), Start, Limit, out Recount);
Mtxfw.Utility.Tools.ToBind(Repeater1, dss.Tables[1]);
MyPager.RecordCount = Recount;
if (MyPager.RecordCount == 0)
{
MyPager.Visible = false;
}
DataSet ds = daoorder.GetList1("sum(Totalnum) as Totalnum,sum(pcount) as pcount,sum(ypcount) as ypcount,sum(ypznum) as ypznum,sum(Totalprice) as Totalprice", "gtype=" + gtype + " and IFDelete=0" + sb.ToString());
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["Totalnum"].ToString() != "")
{
Label_b1.Text = Convert.ToInt32(ds.Tables[0].Rows[0]["Totalnum"]).ToString();
}
else
{
Label_b1.Text = "0";
}
if (ds.Tables[0].Rows[0]["Totalnum"].ToString() != "" && ds.Tables[0].Rows[0]["pcount"].ToString() != "" && ds.Tables[0].Rows[0]["ypcount"].ToString() != "" && ds.Tables[0].Rows[0]["ypznum"].ToString() != "")
{
Label_b2.Text = (Convert.ToInt32(ds.Tables[0].Rows[0]["Totalnum"]) - Convert.ToInt32(ds.Tables[0].Rows[0]["pcount"]) - Convert.ToInt32(ds.Tables[0].Rows[0]["ypcount"]) - Convert.ToInt32(ds.Tables[0].Rows[0]["ypznum"])).ToString();
}
else
{
Label_b2.Text = "0";
}
if (ds.Tables[0].Rows[0]["pcount"].ToString() != "")
{
Label_b3.Text = Convert.ToInt32(ds.Tables[0].Rows[0]["pcount"]).ToString();
}
else
{
Label_b3.Text = "0";
}
if (ds.Tables[0].Rows[0]["ypcount"].ToString() != "")
{
Label_b4.Text = Convert.ToInt32(ds.Tables[0].Rows[0]["ypcount"]).ToString();
}
else
{
Label_b4.Text = "0";
}
if (ds.Tables[0].Rows[0]["ypznum"].ToString() != "")
{
Label_b5.Text = Convert.ToInt32(ds.Tables[0].Rows[0]["ypznum"]).ToString();
}
else
{
Label_b5.Text = "0";
}
if (ds.Tables[0].Rows[0]["Totalprice"].ToString() != "")
{
Label_b6.Text = Convert.ToDouble(ds.Tables[0].Rows[0]["Totalprice"]).ToString("f2");
}
else
{
Label_b6.Text = "0.00";
}
}
else
{
Label_b1.Text = "0";
Label_b2.Text = "0";
Label_b3.Text = "0";
Label_b4.Text = "0";
Label_b5.Text = "0";
Label_b6.Text = "0.00";
}
ds.Clear();
}
protected void Run_Click(object s, System.EventArgs e)
{
if (IsRefresh == false)
{
CheckBox Check = new CheckBox();
string strs = seclect_Drop.SelectedItem.Value;
foreach (RepeaterItem Item in Repeater1.Items)
{
//在行中查找到该单选框
Check = (CheckBox)Item.FindControl("checka");
int strID = int.Parse(Check.CssClass);
if (Check.Checked == true)
{
if (strs == "2")
{
Mtxfw.Model.order_info ModelOrder = daoorder.GetModel(strID);
if (ModelOrder != null)
{
if (ModelOrder.IFDelete == 0)
{
daoorder.UpdateIFDelete(1, DateTime.Now.ToString(), strID);
if (ModelOrder.O_Payed == "0" || ModelOrder.O_Payed == "1" || ModelOrder.O_Payed == "2" || ModelOrder.O_Payed == "3")
{
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();
}
Mtxfw.Model.user_info umodel = new Mtxfw.DAL.user_info().GetModel(ModelOrder.UserID);
if (umodel != null)
{
int ttype = ModelOrder.ttype;
if (ModelOrder.O_Payed != "6")
{
daouser.UpdateMoney("umoney21", -ModelOrder.Totalprice, umodel.Id);
}
Mtxfw.Model.Article amodel = new Mtxfw.Model.Article();
amodel.senderid = 0;
amodel.receiverid = umodel.Id;
amodel.Title = "订单删除通知";
amodel.ParentID = 30;
amodel.CategoryId = "0";
amodel.AddTime = DateTime.Now;
amodel.Author = "../image/order-ico.png";
amodel.Content = "您的订单" + ModelOrder.orderid + "1小时内未付款已被删除";
amodel.Paths = "orders.html";
amodel.Content2 = "";
amodel.Paths2 = "";
amodel.KeyWords = "";
amodel.media_id = "";
amodel.thumb_media_id = "";
amodel.wtype = 4;
amodel.wtype2 = 0;
amodel.LinkID = 1;
amodel.Seef = 0;
amodel.gtype = gtype;
string dataid = new DAL.Article().Add(amodel).ToString();
if (umodel.registrationId != "")
{
List<string> RegistrationIDList = new List<string>();
RegistrationIDList.Add(umodel.registrationId);
string title = amodel.Title;
string strMsg = amodel.Content;
bool is_production = true;
string strLog = "";
new Jiguang.JPush.JPushV3().SendPushV2(RegistrationIDList, title, dataid, strMsg, is_production, out strLog);
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "删除" + Mtxfw.Utility.Common.GetOrderType(ModelOrder.ttype) + ",会员:" + umodel.UserName + "(" + umodel.RealName + "),订单号:" + ModelOrder.orderid;
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
}
}
}
}
}
}
}
Response.Redirect(Request.Url.AbsoluteUri);
}
protected void IsGo_Click(object s, CommandEventArgs ex)
{
Int32 ID = int.Parse(ex.CommandName);
daoorder.UpdateqyState(1, "1", DateTime.Now, ID);
Mtxfw.Utility.Tools.Message("处理成功!", Request.Url.AbsoluteUri);
}
protected void Delete_Click(object s, CommandEventArgs ex)
{
Int32 ID = int.Parse(ex.CommandName);
Mtxfw.Model.order_info ModelOrder = daoorder.GetModel(ID);
if (ModelOrder != null)
{
if (ModelOrder.IFDelete == 0)
{
string O_Payed = ModelOrder.O_Payed;
Mtxfw.Model.user_info umodel = daouser.GetModel(ModelOrder.UserID);
if (umodel != null)
{
daouser.UpdateMoney("umoney21", -ModelOrder.Totalprice, umodel.Id);
daoorder.UpdateIFDelete(1, DateTime.Now.ToString(), "ttype=2 and IFDelete=0 and ptype=0 and UserID=" + ModelOrder.UserID + " and O_yhj='" + ModelOrder.Id + "'");
Mtxfw.Model.Article amodel = new Mtxfw.Model.Article();
amodel.senderid = 0;
amodel.receiverid = umodel.Id;
amodel.Title = "订单删除通知";
amodel.ParentID = 30;
amodel.CategoryId = "0";
amodel.AddTime = DateTime.Now;
amodel.Author = "../image/order-ico.png";
amodel.Content = "您的订单" + ModelOrder.orderid + "1小时内未付款已被删除";
amodel.Paths = "orders.html";
amodel.Content2 = "";
amodel.Paths2 = "";
amodel.KeyWords = "";
amodel.media_id = "";
amodel.thumb_media_id = "";
amodel.wtype = 4;
amodel.wtype2 = 0;
amodel.LinkID = 1;
amodel.Seef = 0;
amodel.gtype = gtype;
string dataid = new DAL.Article().Add(amodel).ToString();
if (umodel.registrationId != "")
{
List<string> RegistrationIDList = new List<string>();
RegistrationIDList.Add(umodel.registrationId);
string title = amodel.Title;
string strMsg = amodel.Content;
bool is_production = true;
string strLog = "";
new Jiguang.JPush.JPushV3().SendPushV2(RegistrationIDList, title, dataid, strMsg, is_production, out strLog);
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "删除" + Mtxfw.Utility.Common.GetOrderType(ModelOrder.ttype) + ",会员:" + umodel.UserName + "(" + umodel.RealName + "),订单号:" + ModelOrder.orderid;
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
}
daoorder.UpdateIFDelete(1, DateTime.Now.ToString(), ID);
}
}
Response.Redirect(Request.Url.AbsoluteUri);
}
protected string GetProducts(int O_Id)
{
string ShowConent = "";
System.Data.DataSet Ds_op = daoorderproduct.GetList("(Select utype from P_Product b where b.P_ID=a.pid) as cutype,(Select P_NAME from P_Product b where b.P_ID=a.pid) as prodName,(Select P_images from P_Product b where b.P_ID=a.pid) as prodimg,", "orderid=" + O_Id + " And IFDelete=0 Order By SubmitTime asc");
if (Ds_op.Tables[0].Rows.Count > 0)
{
for (int l = 0; l < Ds_op.Tables[0].Rows.Count; l++)
{
string pid2 = Ds_op.Tables[0].Rows[l]["id"].ToString();
string prodimg2 = Ds_op.Tables[0].Rows[l]["prodimg"].ToString();
string[] aprodimg = prodimg2.Split('|');
string prodid2 = Ds_op.Tables[0].Rows[l]["pid"].ToString();
string prodName2 = Ds_op.Tables[0].Rows[l]["prodName"].ToString();
string guige2 = Ds_op.Tables[0].Rows[l]["guige"].ToString();
string selcolor2 = Ds_op.Tables[0].Rows[l]["selcolor"].ToString();
string Totalnum2 = Ds_op.Tables[0].Rows[l]["Totalnum"].ToString();
string DJprice2 = Ds_op.Tables[0].Rows[l]["DJprice"].ToString();
string Totalprice2 = Ds_op.Tables[0].Rows[l]["Totalprice"].ToString();
string cutype = Ds_op.Tables[0].Rows[l]["cutype"].ToString();
string strimg = "";
string strUrl2 = "/shop/view-" + prodid2 + ".html";
if (cutype == "3")
{
/*System.Data.DataSet Ds_op2 = daoorderproduct.GetList("(Select P_NAME from P_Product b where b.P_ID=a.pid) as prodName,(Select P_images from P_Product b where b.P_ID=a.pid) as prodimg,", "utype='1' And orderid=" + pid2 + " And IFDelete=0 Order By SubmitTime asc");
if (Ds_op2.Tables[0].Rows.Count > 0)
{
for (int h = 0; h < Ds_op2.Tables[0].Rows.Count; h++)
{
string prodName3 = Ds_op2.Tables[0].Rows[h]["prodName"].ToString();
string guige3 = Ds_op2.Tables[0].Rows[h]["guige"].ToString();
string selcolor3 = Ds_op2.Tables[0].Rows[h]["selcolor"].ToString();
string[] aprodimg3 = Ds_op2.Tables[0].Rows[h]["prodimg"].ToString().Split('|');
string prodimg3 = aprodimg3[0].Split(',')[0];
foreach (string imgs in aprodimg3)
{
if (imgs != "")
{
string[] aimg = aprodimg3[0].Split(',');
if (aimg.Length >= 2)
{
if (aimg[1] == selcolor3)
{
prodimg3 = aimg[0];
}
}
}
}
ShowConent += "<span title=\"" + prodName3 + (guige3 == "" ? "" : " " + guige3) + (selcolor3 == "" ? "" : " " + selcolor3) + "\"><img src='" + Mtxfw.Utility.Common.GetCoverPic(prodimg3, "40x40", "cut") + "'/></span>\n";
}
}
Ds_op2.Clear();*/
ShowConent += "<span>" + prodName2 + "</span><br>\n";
}
else
{
if (guige2 != "")
{
Mtxfw.Model.P_Guige gmodel = new DAL.P_Guige().GetModel(Convert.ToInt32(guige2));
if (gmodel != null)
{
prodName2 += " " + gmodel.G_Name;
}
}
if (selcolor2 != "")
{
foreach (string img in aprodimg)
{
if (img.IndexOf(selcolor2) != -1)
{
strimg = img.Split(',')[0];
}
}
if (strimg == "")
{
strimg = prodimg2.Split('|')[0].Split(',')[0];
}
}
else
{
strimg = prodimg2.Split('|')[0].Split(',')[0];
}
ShowConent += "<span title=\"" + prodName2 + " " + selcolor2 + "\"><img src='" + Mtxfw.Utility.Common.GetCoverPic(strimg, "40x40", "cut") + "'/></span>\n";
}
}
}
Ds_op.Clear();
return ShowConent;
}
}
}