public HttpResponseBase GetOrderChildList() { List<OrderDetailQuery> stores = new List<OrderDetailQuery>(); string json = string.Empty; try { OrderDetailQuery query = new OrderDetailQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "5");//用於分頁的變量 //付款單號 query.Order_Id = Convert.ToUInt32(Request.Params["OrderId"].ToString()); query.Parent_Id = Convert.ToInt32(Request.Params["ParentId"].ToString()); query.pack_id = Convert.ToUInt32(Request.Params["PackId"].ToString()); query.isChildItem = 1; _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString); int totalCount = 0; stores = _orderDetailMgr.GetOrderDetailList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; //listUser是准备转换的对象 foreach (var item in stores) {//訂單內容頁面查詢的是自商品信息需要*parent_num item.Buy_Num = item.Buy_Num * item.parent_num; } json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetOrderDetailList() { List<OrderDetailQuery> stores = new List<OrderDetailQuery>(); string json = string.Empty; try { OrderDetailQuery query = new OrderDetailQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 //付款單號 query.Order_Id = Convert.ToUInt32(Request.Params["OrderId"].ToString()); query.isChildItem = 0; _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString); int totalCount = 0; stores = _orderDetailMgr.GetOrderDetailList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; //listUser是准备转换的对象 //獲取供應商後臺登陸的vendorMd5加密 _vendorImp = new VendorMgr(mySqlConnectionString); foreach (OrderDetailQuery item in stores) { string str = _vendorImp.GetLoginId(Convert.ToInt32(item.Vendor_Id)); if (str != "") { HashEncrypt hmd5 = new HashEncrypt(); string mdlogin_id = hmd5.Md5Encrypt(str, "MD5"); item.VendorMd5 = hmd5.Md5Encrypt(mdlogin_id + str, "MD5"); } if (item.item_mode == 2) { item.subtotal = (item.Single_Money * item.parent_num)-uint.Parse(item.Deduct_Happygo_Money.ToString())-item.Deduct_Welfare-item.Deduct_Bonus; } else { item.subtotal = (item.Single_Money * item.Buy_Num) -uint.Parse( item.Deduct_Happygo_Money.ToString()) - item.Deduct_Welfare - item.Deduct_Bonus; } } json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
/// <summary> /// 品牌營業額統計匯出 /// </summary> /// <returns></returns> public void GetNewOrderRevenueExprot() { string json = string.Empty; try { OrderDetailQuery query = new OrderDetailQuery(); #region 前置查詢條件 if (!string.IsNullOrEmpty(Request.Params["Brand_Id"]))/*品牌編號*/ { query.Brand_Id_In = Request.Params["Brand_Id"]; } if (!string.IsNullOrEmpty(Request.Params["product_manage"]) && Request.Params["product_manage"] != "null")//管理人員 {//獲取管理人 query.product_manage = int.Parse(Request.Params["product_manage"]); } if (!string.IsNullOrEmpty(Request.Params["dateOne"])) { query.time_start = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateOne"]).ToString("yyyy/MM/dd 00:00:00")); } if (!string.IsNullOrEmpty(Request.Params["dateTwo"])) { query.time_end = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateTwo"]).ToString("yyyy/MM/dd 23:59:59")); } long start = query.time_start;//開始時間 long end = query.time_end;//結束時間 if (!string.IsNullOrEmpty(Request.Params["Channel_Id"]) && Request.Params["Channel_Id"] != "null")//賣場 { query.channel = int.Parse(Request.Params["Channel_Id"]); } if (!string.IsNullOrEmpty(Request.Params["slave_status"]) && Request.Params["slave_status"]!="null")//訂單狀態 { query.Status = int.Parse(Request.Params["slave_status"]); } if (!string.IsNullOrEmpty(Request.Params["order_payment"]) && Request.Params["order_payment"] != "null")//付款方式 { query.order_payment = int.Parse(Request.Params["order_payment"]); } if (!string.IsNullOrEmpty(Request.Params["selecttype"]))//關鍵字查詢類型 { query.select_type = int.Parse(Request.Params["selecttype"]); if (!string.IsNullOrEmpty(Request.Params["searchcon"]))//關鍵字查詢內容 { query.select_con = Request.Params["searchcon"]; } } #endregion VendorBrandQuery Vendorbrandquery = new VendorBrandQuery(); Dictionary<uint, VendorBrandQuery> brands = new Dictionary<uint, VendorBrandQuery>();///字典----儲存供應商編號,供應商名稱和錧別,錧別編號的信息 Dictionary<uint, Dictionary<string, Dictionary<string, uint>>> brandDailyTotal = new Dictionary<uint, Dictionary<string, Dictionary<string, uint>>>();///字典,儲存錧別,每天的計算和每天的購物金 ///////////////brand_id//////////daysum,dayduct/////日期///值 List<VendorBrandQuery> aDB_Brand_Select = new List<VendorBrandQuery>(); _vbrand = new VendorBrandMgr(mySqlConnectionString); aDB_Brand_Select = _vbrand.GetBandList(Vendorbrandquery);//把錧別和供應商信息保存到字典里 for (int i = 0; i < aDB_Brand_Select.Count; i++) { if (!brands.Keys.Contains(aDB_Brand_Select[i].Brand_Id)) { brands.Add(aDB_Brand_Select[i].Brand_Id, aDB_Brand_Select[i]); } } bool CrossMonth = CommonFunction.GetNetTime(start).Month == CommonFunction.GetNetTime(end).Month ? false : true; string timelong = ""; while (start <= end)//時間格式化,用來保存每天的小計 { timelong += CommonFunction.GetNetTime(start).ToString("yyyy/MM/dd") + ","; start += 86400; } timelong = timelong.Substring(0, timelong.LastIndexOf(",")); string[] times = timelong.Split(','); Dictionary<string, uint> timetro = new Dictionary<string, uint>(); for (int i = 0; i < times.Count(); i++)//字典加上日期時間 { timetro.Add(times[i], 0); } Dictionary<string, Dictionary<string, uint>> daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();//保存每個商品每日的小計和購物金 daysum_deduct.Add("daysum", timetro);//每日小計 daysum_deduct.Add("daydeduct", timetro);//每日小計 _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString); List<OrderDetailQuery> ordertailList = new List<OrderDetailQuery>(); DataTable _dt = new DataTable(); ordertailList = _orderDetailMgr.GetOrderDetailList(query);//通過查詢條件獲取的數據 string[] quanxuan = query.Brand_Id_In.Split(','); foreach (uint item in brands.Keys) { if (!brandDailyTotal.Keys.Contains(item)) { daysum_deduct = new Dictionary<string, Dictionary<string, uint>>(); timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daysum", timetro);//每日小計 timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daydeduct", timetro);//購物金 brandDailyTotal.Add(item, daysum_deduct); } } //if (ordertailList.Count > 0) //{ for (int i = 0; i < ordertailList.Count; i++) { ordertailList[i].subtotal = ordertailList[i].Single_Money * ordertailList[i].Buy_Num; ordertailList[i].cost = (ordertailList[i].Event_Cost != 0 && ordertailList[i].Single_Cost != ordertailList[i].Single_Money) ? ordertailList[i].Event_Cost : ordertailList[i].Single_Cost; if (!brands.Keys.Contains(ordertailList[i].Brand_Id)) { VendorBrandQuery brand = new VendorBrandQuery(); brand.Vendor_Id = ordertailList[i].Vendor_Id; brand.Brand_Name = ordertailList[i].Brand_Name; brand.Brand_Id = ordertailList[i].Brand_Id; brand.vendor_name_simple = ordertailList[i].Vendor_Name_Simple; brands.Add(ordertailList[i].Brand_Id, brand); } if (!brandDailyTotal.Keys.Contains(ordertailList[i].Brand_Id)) { daysum_deduct = new Dictionary<string, Dictionary<string, uint>>(); timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daysum", timetro);//每日小計 timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daydeduct", timetro);//購物金 brandDailyTotal.Add(ordertailList[i].Brand_Id, daysum_deduct); } string time = CommonFunction.GetNetTime(ordertailList[i].Order_Createdate).ToString("yyyy/MM/dd"); brandDailyTotal[ordertailList[i].Brand_Id]["daysum"][time] += ordertailList[i].subtotal;//每個商品的小計 brandDailyTotal[ordertailList[i].Brand_Id]["daydeduct"][time] += ordertailList[i].Deduct_Bonus;//每個商品的購物金小計 } Dictionary<string, uint> daysum_allbrand = new Dictionary<string, uint>();//所有品牌的每日小計 Dictionary<string, uint> deductsum_allbrand = new Dictionary<string, uint>();//所有品牌的每日購物金 foreach (uint key in brandDailyTotal.Keys) { foreach (string time in brandDailyTotal[key]["daysum"].Keys)//循環每個品牌的每日小計,計算到所有品牌的每日小計 { if (!daysum_allbrand.Keys.Contains(time)) { daysum_allbrand.Add(time, brandDailyTotal[key]["daysum"][time]); } else { daysum_allbrand[time] += brandDailyTotal[key]["daysum"][time]; } } foreach (string time in brandDailyTotal[key]["daydeduct"].Keys)//循環每個品牌的每日購物金小計,計算到所有品牌的每日小計 { if (!deductsum_allbrand.Keys.Contains(time)) { deductsum_allbrand.Add(time, brandDailyTotal[key]["daydeduct"][time]); } else { deductsum_allbrand[time] += brandDailyTotal[key]["daydeduct"][time]; } } } // _dt.Columns.Add("品牌名稱", typeof(String)); _dt.Columns.Add("供應商名稱", typeof(String)); string ym_last = ""; foreach (string it in timetro.Keys) { string ym = it.Substring(0, 7); if (string.IsNullOrEmpty(ym_last)) ym_last = ym; if (!ym_last.Equals(ym)) { _dt.Columns.Add(ym_last.Split('/')[1] + "月小計", typeof(String)); _dt.Columns.Add("購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String)); _dt.Columns.Add("扣除購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String)); ym_last = ym; } _dt.Columns.Add(it, typeof(String)); _dt.Columns.Add("購物金(" + it + ")", typeof(String)); _dt.Columns.Add("扣除購物金(" + it + ")", typeof(String)); } if (CrossMonth) { _dt.Columns.Add(ym_last.Split('/')[1] + "月小計", typeof(String)); _dt.Columns.Add("購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String)); _dt.Columns.Add("扣除購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String)); } _dt.Columns.Add("品牌總計", typeof(String)); _dt.Columns.Add(" 購物金總計", typeof(String)); _dt.Columns.Add(" 扣除購物金總計", typeof(String)); DataRow addrow = _dt.NewRow();//添加一行 addrow[0] = " "; addrow[1] = "每日小計"; int r = 2; ym_last = ""; uint sum_monthly = 0;//每月小計 uint deduct_monthly = 0;//每月購物金小計 uint sum_year = 0;//總計 uint deduct_year = 0;//購物金總計 foreach (string it in daysum_allbrand.Keys) { string ym = it.Substring(0, 7); if (string.IsNullOrEmpty(ym_last)) ym_last = ym; if (!ym_last.Equals(ym)) { addrow[r] = sum_monthly; r++; addrow[r] = deduct_monthly; r++; addrow[r] = sum_monthly - deduct_monthly; r++; ym_last = ym; sum_monthly = 0; deduct_monthly = 0; } sum_monthly += daysum_allbrand[it]; deduct_monthly += deductsum_allbrand[it]; sum_year += daysum_allbrand[it]; deduct_year += deductsum_allbrand[it]; addrow[r] = daysum_allbrand[it]; r++; addrow[r] = deductsum_allbrand[it]; r++; addrow[r] = daysum_allbrand[it] - deductsum_allbrand[it]; r++; } if (CrossMonth) { addrow[r] = sum_monthly; r++; addrow[r] = deduct_monthly; r++; addrow[r] = sum_monthly - deduct_monthly; r++; } addrow[r] = sum_year; r++; addrow[r] = deduct_year; r++; addrow[r] = sum_year - deduct_year; _dt.Rows.Add(addrow); foreach (uint it in brandDailyTotal.Keys) { ym_last = ""; sum_monthly = 0; deduct_monthly = 0; sum_year = 0; deduct_year = 0; r = 0; addrow = _dt.NewRow(); if (brands.Keys.Contains(it)) { addrow[r] = brands[it].Brand_Name; r++; addrow[r] = brands[it].vendor_name_simple; r++; } else { addrow[r] = " "; r++; addrow[r] = " "; r++; } foreach (string ite in brandDailyTotal[it]["daysum"].Keys) { string ym = ite.Substring(0, 7); if (string.IsNullOrEmpty(ym_last)) ym_last = ym; if (!ym_last.Equals(ym)) { addrow[r] = sum_monthly; r++; addrow[r] = deduct_monthly; r++; addrow[r] = sum_monthly - deduct_monthly; r++; ym_last = ym; sum_monthly = 0; deduct_monthly = 0; } sum_monthly += brandDailyTotal[it]["daysum"][ite]; sum_year += brandDailyTotal[it]["daysum"][ite]; deduct_monthly += brandDailyTotal[it]["daydeduct"][ite]; deduct_year += brandDailyTotal[it]["daydeduct"][ite]; addrow[r] = brandDailyTotal[it]["daysum"][ite]; r++; addrow[r] = brandDailyTotal[it]["daydeduct"][ite]; r++; addrow[r] = brandDailyTotal[it]["daysum"][ite] - brandDailyTotal[it]["daydeduct"][ite]; r++; } if (CrossMonth) { addrow[r] = sum_monthly; r++; addrow[r] = deduct_monthly; r++; addrow[r] = sum_monthly - deduct_monthly; r++; } addrow[r] = sum_year; r++; addrow[r] = deduct_year; r++; addrow[r] = sum_year - deduct_year; _dt.Rows.Add(addrow); } // } //if (_dt.Rows.Count > 0) //{ //string fileName = "品牌營業額匯出_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; //MemoryStream ms = ExcelHelperXhf.ExportDT(_dt, ""); //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); //Response.BinaryWrite(ms.ToArray()); string fileName = "品牌營業額匯出_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv"; //MemoryStream ms = ExcelHelperXhf.ExportDT(_dt, ""); //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); //Response.BinaryWrite(ms.ToArray()); StringWriter sw = ExcelHelperXhf.SetCsvFromData(_dt, fileName); Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.ContentType = "application/ms-excel"; Response.ContentEncoding = Encoding.Default; Response.Write(sw); Response.End(); //} //else //{ // Response.Write("匯出數據不存在"); //} } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } }
public HttpResponseBase GetNewOrderRevenueList() { string json = string.Empty; try { OrderDetailQuery query = new OrderDetailQuery(); #region 前置查詢條件 if (!string.IsNullOrEmpty(Request.Params["Brand_Id"]))/*品牌編號*/ { query.Brand_Id_In = Request.Params["Brand_Id"]; } if (!string.IsNullOrEmpty(Request.Params["product_manage"]))//管理人員 {//獲取管理人 query.product_manage = int.Parse(Request.Params["product_manage"]); } if (!string.IsNullOrEmpty(Request.Params["dateOne"])) { query.time_start = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateOne"]).ToString("yyyy/MM/dd 00:00:00")); } if (!string.IsNullOrEmpty(Request.Params["dateTwo"])) { query.time_end = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateTwo"]).ToString("yyyy/MM/dd 23:59:59")); } long start = query.time_start;//開始時間 long end = query.time_end;//結束時間 if (!string.IsNullOrEmpty(Request.Params["Channel_Id"]))//賣場 { query.channel = int.Parse(Request.Params["Channel_Id"]); } if (!string.IsNullOrEmpty(Request.Params["slave_status"]))//訂單狀態 { query.Status = int.Parse(Request.Params["slave_status"]); } if (!string.IsNullOrEmpty(Request.Params["order_payment"]))//付款方式 { query.order_payment = int.Parse(Request.Params["order_payment"]); } if (!string.IsNullOrEmpty(Request.Params["selecttype"]))//關鍵字查詢類型 { query.select_type = int.Parse(Request.Params["selecttype"]); if (!string.IsNullOrEmpty(Request.Params["searchcon"]))//關鍵字查詢內容 { query.select_con = Request.Params["searchcon"]; } } #endregion VendorBrandQuery Vendorbrandquery = new VendorBrandQuery(); Dictionary<uint, VendorBrandQuery> brands = new Dictionary<uint, VendorBrandQuery>();///字典----儲存供應商編號,供應商名稱和錧別,錧別編號的信息 Dictionary<uint, Dictionary<string, Dictionary<string, uint>>> brandDailyTotal = new Dictionary<uint, Dictionary<string, Dictionary<string, uint>>>();///字典,儲存錧別,每天的計算和每天的購物金 ///////////////brand_id//////////daysum,dayduct/////日期///值 List<VendorBrandQuery> aDB_Brand_Select = new List<VendorBrandQuery>(); _vbrand = new VendorBrandMgr(mySqlConnectionString); aDB_Brand_Select = _vbrand.GetBandList(Vendorbrandquery);//把錧別和供應商信息保存到字典里 for (int i = 0; i < aDB_Brand_Select.Count; i++) { if (!brands.Keys.Contains(aDB_Brand_Select[i].Brand_Id)) { brands.Add(aDB_Brand_Select[i].Brand_Id, aDB_Brand_Select[i]); } } bool CrossMonth = CommonFunction.GetNetTime(start).Month == CommonFunction.GetNetTime(end).Month ? false : true; string timelong = ""; while (start <= end)//時間格式化,用來保存每天的小計 { timelong += CommonFunction.GetNetTime(start).ToString("yyyy/MM/dd") + ","; start += 86400; } timelong = timelong.Substring(0, timelong.LastIndexOf(",")); string[] times = timelong.Split(','); Dictionary<string, uint> timetro = new Dictionary<string, uint>(); for (int i = 0; i < times.Count(); i++)//字典加上日期時間 { timetro.Add(times[i], 0); } Dictionary<string, Dictionary<string, uint>> daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();//保存每個商品每日的小計和購物金 daysum_deduct.Add("daysum", timetro);//每日小計 daysum_deduct.Add("daydeduct", timetro);//每日小計 _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString); List<OrderDetailQuery> ordertailList = new List<OrderDetailQuery>(); ordertailList = _orderDetailMgr.GetOrderDetailList(query);//通過查詢條件獲取的數據 //if (ordertailList.Count == 0) //{ // json = "{success:true,msg:\"" + "<div style='overflow:auto;text-align:center;width:1650px;height:550px;><p tyle='text-align:center'>~~暫無數據~~</p></div>" + "\"}"; //} //else //{ string[] quanxuan = query.Brand_Id_In.Split(','); foreach (uint item in brands.Keys) { if (!brandDailyTotal.Keys.Contains(item)) { daysum_deduct = new Dictionary<string, Dictionary<string, uint>>(); timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daysum", timetro);//每日小計 timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daydeduct", timetro);//購物金 brandDailyTotal.Add(item, daysum_deduct); } } for (int i = 0; i < ordertailList.Count; i++) { ordertailList[i].subtotal = ordertailList[i].Single_Money * ordertailList[i].Buy_Num; ordertailList[i].cost = (ordertailList[i].Event_Cost != 0 && ordertailList[i].Single_Cost != ordertailList[i].Single_Money) ? ordertailList[i].Event_Cost : ordertailList[i].Single_Cost; if (!brands.Keys.Contains(ordertailList[i].Brand_Id)) { VendorBrandQuery brand = new VendorBrandQuery(); brand.Vendor_Id = ordertailList[i].Vendor_Id; brand.Brand_Name = ordertailList[i].Brand_Name; brand.Brand_Id = ordertailList[i].Brand_Id; brand.vendor_name_simple = ordertailList[i].Vendor_Name_Simple; brands.Add(ordertailList[i].Brand_Id, brand); } if (!brandDailyTotal.Keys.Contains(ordertailList[i].Brand_Id)) { daysum_deduct = new Dictionary<string, Dictionary<string, uint>>(); timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daysum", timetro);//每日小計 timetro = new Dictionary<string, uint>(); for (int a = 0; a < times.Count(); a++)//字典加上日期時間 { timetro.Add(times[a], 0); } daysum_deduct.Add("daydeduct", timetro);//購物金 brandDailyTotal.Add(ordertailList[i].Brand_Id, daysum_deduct); } string time = CommonFunction.GetNetTime(ordertailList[i].Order_Createdate).ToString("yyyy/MM/dd"); brandDailyTotal[ordertailList[i].Brand_Id]["daysum"][time] += ordertailList[i].subtotal;//每個商品的小計 brandDailyTotal[ordertailList[i].Brand_Id]["daydeduct"][time] += ordertailList[i].Deduct_Bonus;//每個商品的購物金小計 } Dictionary<string, uint> daysum_allbrand = new Dictionary<string, uint>();//所有品牌的每日小計 Dictionary<string, uint> deductsum_allbrand = new Dictionary<string, uint>();//所有品牌的每日購物金 foreach (uint key in brandDailyTotal.Keys) { foreach (string time in brandDailyTotal[key]["daysum"].Keys)//循環每個品牌的每日小計,計算到所有品牌的每日小計 { if (!daysum_allbrand.Keys.Contains(time)) { daysum_allbrand.Add(time, brandDailyTotal[key]["daysum"][time]); } else { daysum_allbrand[time] += brandDailyTotal[key]["daysum"][time]; } } foreach (string time in brandDailyTotal[key]["daydeduct"].Keys)//循環每個品牌的每日購物金小計,計算到所有品牌的每日小計 { if (!deductsum_allbrand.Keys.Contains(time)) { deductsum_allbrand.Add(time, brandDailyTotal[key]["daydeduct"][time]); } else { deductsum_allbrand[time] += brandDailyTotal[key]["daydeduct"][time]; } } } StringBuilder html_table = new StringBuilder();//匯出html頁面 html_table.AppendFormat(@"<div style='overflow:auto;text-align:right;width:1590px;height:580px;'><table style='border:0px;'>"); html_table.AppendFormat("<thead style='text-align:center;border-bottom: 1px solid #ccc;color: #000;'><tr><td style='border-bottom: 1px solid #ccc;color: #000;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center; text-align: center;'> 品牌名稱 </td>"); html_table.AppendFormat("<td style='border-bottom: 1px solid #ccc;color: #000;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center; text-align: center;'> 供應商名稱 </td>"); string ym_last = ""; foreach (string it in timetro.Keys) { string ym = it.Substring(0, 7); if (string.IsNullOrEmpty(ym_last)) ym_last = ym; if (!ym_last.Equals(ym)) { html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center;'> {0} </td>", ym_last.Split('/')[1] + "月小計"); ym_last = ym; } html_table.AppendFormat("<td style='color: #000;border-bottom: 1px solid #ccc; text-align: center;'> {0} </td>", it); } if (CrossMonth) { html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center;'> {0} </td>", ym_last.Split('/')[1] + "月小計"); } html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center;'> 品牌總計 </td></tr>"); html_table.AppendFormat("<tr><td colspan='2' style= 'text-align: right;border-bottom: 1px solid #ccc;color: #000;'> 每日小計 </td>"); ym_last = ""; uint sum_monthly = 0; uint sum_year = 0; foreach (string it in daysum_allbrand.Keys) { string ym = it.Substring(0, 7); if (string.IsNullOrEmpty(ym_last)) ym_last = ym; if (!ym_last.Equals(ym)) { html_table.AppendFormat("<td style= 'border-bottom: 1px solid #ccc; text-align: right;color: #c00; '> {0} </td>", sum_monthly); ym_last = ym; sum_monthly = 0; } sum_monthly += daysum_allbrand[it]; sum_year += daysum_allbrand[it]; html_table.AppendFormat("<td style='text-align:right;border-bottom: 1px solid #ccc; '> {0} </td>", daysum_allbrand[it]); } if (CrossMonth) { html_table.AppendFormat("<td style= 'text-align:right;color: #c00;border-bottom: 1px solid #ccc; '> {0} </td>", sum_monthly); } html_table.AppendFormat("<td style= 'text-align:right;color: #c00;border-bottom: 1px solid #ccc; '> {0} </td></tr></thead>", sum_year); html_table.AppendFormat("<tbody>"); foreach (uint it in brandDailyTotal.Keys) { ym_last = ""; sum_monthly = 0; sum_year = 0; if (brands.Keys.Contains(it)) { html_table.AppendFormat("<tr><td style=' white-space: nowrap;text-align:left;line-height: 1.2em;font-size: 12px;'> {0} </td><td style='text-align:left; white-space: nowrap;line-height: 1.2em;font-size: 12px;'> {1} </td>", brands[it].Brand_Name, brands[it].vendor_name_simple); } else { html_table.AppendFormat("<tr><td> {0} </td><td > {1} </td>", " ", " "); } foreach (string ite in brandDailyTotal[it]["daysum"].Keys) { string ym = ite.Substring(0, 7); if (string.IsNullOrEmpty(ym_last)) ym_last = ym; if (!ym_last.Equals(ym)) { html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'> {0} </td>", sum_monthly); ym_last = ym; sum_monthly = 0; } sum_monthly += brandDailyTotal[it]["daysum"][ite]; sum_year += brandDailyTotal[it]["daysum"][ite]; html_table.AppendFormat("<td style='text-align:right;white-space: nowrap;line-height: 1.2em;font-size: 12px;'> {0} </td>", brandDailyTotal[it]["daysum"][ite]); } if (CrossMonth) { html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'> {0} </td>", sum_monthly); } html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'> {0} </td> </tr>", sum_year); } html_table.AppendFormat("</tbody></table>"); json = "{success:true,msg:\"" + html_table.ToString() + "\"}"; } // } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetOrderDeliverDetailList() { StringBuilder addsql = new StringBuilder(); string json = string.Empty; string startTime = Request.Params["start_time"]; string endTime = Request.Params["end_time"]; if (!string.IsNullOrEmpty(startTime)) { addsql.AppendFormat(" and om.order_date_pay>='{0}' ", CommonFunction.GetPHPTime(DateTime.Parse(startTime).ToString("yyyy/MM/dd 00:00:00"))); } if (!string.IsNullOrEmpty(endTime)) { addsql.AppendFormat(" and om.order_date_pay<='{0}' ", CommonFunction.GetPHPTime(DateTime.Parse(endTime).ToString("yyyy/MM/dd 23:59:59"))); } addsql.Append(" AND od.detail_status = 2 AND product_mode = 1 "); BLL.gigade.Model.Vendor modelVendor = Session["vendor"] as BLL.gigade.Model.Vendor; StringBuilder sbHtml = new StringBuilder(); try { //OrderSlave OrderSlaveQuery orderSlaveQuery = new OrderSlaveQuery() { vendor_id = modelVendor.vendor_id, Slave_Status = 2,//待出貨 IsPage = false }; OrderSlaveQuery orderSlave = new OrderSlaveQuery(); DataTable dtOrderSlave = new DataTable(); _OrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString); //OrderDetail OrderDetailQuery orderDetailQuery = new OrderDetailQuery(); List<OrderDetailQuery> list = new List<OrderDetailQuery>(); _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString); int totalCount_OrderDetail = 0; Dictionary<OrderDetailQuery, List<OrderDetailQuery>> product_freight_set_mapping = new Dictionary<OrderDetailQuery, List<OrderDetailQuery>>(); //根據時間搜索order_id dtOrderSlave = _OrderSlaveMgr.GetListPrint(orderSlaveQuery, addsql.ToString()); if (dtOrderSlave.Rows.Count > 0) { //循環order_id foreach (DataRow item in dtOrderSlave.Rows) { //orderSlave orderSlave.order_id = Convert.ToUInt32(item["order_id"]); orderSlave.order_createdate = Convert.ToDateTime(item["order_createdate"]).ToString("yyyy-MM-dd HH:mm:ss"); orderSlave.pay_time = Convert.ToDateTime(item["order_date_pay"]).ToString("yyyy-MM-dd HH:mm:ss"); orderSlave.order_name = item["order_name"].ToString(); orderSlave.delivery_name = item["delivery_name"].ToString(); orderSlave.estimated_arrival_period = Convert.ToInt32(item["estimated_arrival_period"]); orderSlave.note_order = item["note_order"].ToString(); orderSlave.dispatch = 0; orderSlave.delivery_zip = Convert.ToUInt32(item["delivery_zip"]); orderSlave.delivery_address = item["delivery_address"].ToString(); orderSlave.delivery_mobile = item["delivery_mobile"].ToString(); //供查詢列表使用 orderDetailQuery.Slave_Id = Convert.ToUInt32(item["slave_id"]); list = _OrderDetailMgr.GetOrderDetailList(orderDetailQuery, out totalCount_OrderDetail); sbHtml.Append(GetOrderDeliverDetailHtml(orderSlave, list)); } } IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd"; //json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據 json = "{success:true,msg:\"" + sbHtml.ToString() + "\"}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:0}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetOrderDeliverDetail() { string json = string.Empty; string order_id = Request.Params["oid"]; string p_mode = Request.Params["p_mode"]; BLL.gigade.Model.Vendor modelVendor = Session["vendor"] as BLL.gigade.Model.Vendor; //OrderSlave OrderSlaveQuery orderSlaveQuery = new OrderSlaveQuery() { order_id = Convert.ToUInt32(order_id), vendor_id = modelVendor.vendor_id, Slave_Status = 2,//待出貨 IsPage = false }; OrderSlaveQuery orderSlave = new OrderSlaveQuery(); DataTable dtOrderSlave = new DataTable(); _OrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString); int totalCount_OrderSlave = 0; //OrderDetail OrderDetailQuery orderDetailQuery = new OrderDetailQuery(); //orderDetailQuery.Order_Id = uint.Parse(order_id); List<OrderDetailQuery> list = new List<OrderDetailQuery>(); _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString); int totalCount_OrderDetail = 0; try { dtOrderSlave = _OrderSlaveMgr.GetList(orderSlaveQuery, out totalCount_OrderSlave); if (dtOrderSlave.Rows.Count > 0) { //orderSlave orderSlave.order_id = Convert.ToUInt32(dtOrderSlave.Rows[0]["order_id"]); orderSlave.order_createdate = dtOrderSlave.Rows[0]["order_createdate"].ToString(); orderSlave.pay_time = dtOrderSlave.Rows[0]["order_date_pay"].ToString(); orderSlave.order_name = dtOrderSlave.Rows[0]["order_name"].ToString(); orderSlave.delivery_name = dtOrderSlave.Rows[0]["delivery_name"].ToString(); orderSlave.estimated_arrival_period = Convert.ToInt32(dtOrderSlave.Rows[0]["estimated_arrival_period"]); orderSlave.note_order = dtOrderSlave.Rows[0]["note_order"].ToString(); orderSlave.dispatch = modelVendor.dispatch; orderSlave.delivery_zip = Convert.ToUInt32(dtOrderSlave.Rows[0]["delivery_zip"]); orderSlave.delivery_address = dtOrderSlave.Rows[0]["delivery_address"].ToString(); orderSlave.delivery_mobile = dtOrderSlave.Rows[0]["delivery_mobile"].ToString(); //供查詢列表使用 orderDetailQuery.Slave_Id = Convert.ToUInt32(dtOrderSlave.Rows[0]["slave_id"]); } list = _OrderDetailMgr.GetOrderDetailList(orderDetailQuery, out totalCount_OrderDetail); List<OrderDetailQuery> stroes = new List<OrderDetailQuery>(); stroes = getList(list); string html = GetOrderDeliverDetailHtml(orderSlave, stroes); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd"; //json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據 json = "{success:true,msg:\"" + html + "\"}"; } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,msg:0}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }