public ActionResult TradeExcel() { try { Yun.Interface.IYunClient client = new Yun.DefaultYunClient("http://127.0.0.1/router/rest", "47041605c97649dd9a25012a6a6d8ae3", "918e3735e87d46c4b00fa00e31291772"); var u = client.Execute(new Yun.User.Request.LoginRequest { AppSecret = "918e3735e87d46c4b00fa00e31291772", Ip = "192.168.1.200", Password = "******", UserName = "******", }); System.Collections.Generic.List<Yun.Trade.SnapshotTrade> tradelist = new System.Collections.Generic.List<Yun.Trade.SnapshotTrade>(); var r = client.Execute(new Yun.Trade.Request.GetTradesSoldRequest { PageNum = 1, PageSize = 50, TradeStatus = "PAID", }, u.Token); tradelist.AddRange(r.Trades); if (r.TotalItem > 50) { for (int i = 2; i <= (r.TotalItem / 50) + 1; i++) { var rr = client.Execute(new Yun.Trade.Request.GetTradesSoldRequest { PageNum = i, PageSize = 50, TradeStatus = "PAID", }, u.Token); tradelist.AddRange(rr.Trades); } } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); stringBuilder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n"); stringBuilder.Append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:html=\"http://2015.gogift.cn/TR/REC-html40\">\n"); stringBuilder.Append("<Worksheet ss:Name=\"Table1\">\n"); stringBuilder.Append("<Table>\n"); stringBuilder.Append("<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n"); stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">订单编号</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">创建时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">交易时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">客户昵称</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品编码</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品名称</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">规格型号</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品价格(元)</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">购买数量</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">总金额</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">金额</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">积分卡积分</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">俱乐部积分</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">收货人姓名</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">收货地址</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">接收电话</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">买家留言</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">状态</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); var Integral = YunShop.Core.DataProvider.GlobeInfo.GetIntegralRequest(); for (int i = 0; i < tradelist.Count; i++) { int num = 0; foreach (var a in tradelist[i].Orders) { var skuNames = ""; var ext = ",积分:0"; if (a.SkuNames != null && a.SkuNames.Any()) { skuNames = string.Join(",", a.SkuNames.Select(e => e.Value)); } if (((tradelist[i].Ext ?? "").IndexOf(',') >= 0)) { ext = ",积分:" + tradelist[i].Ext.Split(',')[1]; } else if (int.Parse((tradelist[i].Ext ?? "0")) > 0) { ext = ",积分:" + tradelist[i].Ext; } var status = ""; if (tradelist[i].TradeStatus == "WAIT_BUYER_CONFIRM_GOODS") { status = "卖家已发货"; } else if (tradelist[i].TradeStatus == "WAIT_BUYER_PAY") { status = "等待买家付款"; } else if (tradelist[i].TradeStatus == "TRADE_FINISHED") { status = "交易成功"; } if (tradelist[i].TradeStatus == "TRADE_CLOSED_BY_SELF" || tradelist[i].TradeStatus == "TRADE_CLOSED") { status = "交易关闭"; } if (num == 0) { stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Id + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].CreateTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].PayTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Nick + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Code + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.ItemTitle + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + skuNames + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Price + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Quantity + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "金额:" + (tradelist[i].TotalFunds - (tradelist[i].PaymentInfo.OnlineMoney > 0 ? 0 : tradelist[i].PaymentInfo.PrepaidCard * Integral.OneIntegralEqualMoney)).ToString() + ext + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + (tradelist[i].TotalFunds - (tradelist[i].PaymentInfo.OnlineMoney > 0 ? 0 : tradelist[i].PaymentInfo.PrepaidCard * Integral.OneIntegralEqualMoney)).ToString() + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].PaymentInfo.PrepaidCard + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + (double.Parse(ext.Replace(",积分:", "")) - tradelist[i].PaymentInfo.PrepaidCard).ToString() + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].RealName + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Address + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Mobile + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Remark + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + status + "</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); num += 1; } else { stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Code + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.ItemTitle + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + skuNames + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Price + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Quantity + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); num += 1; } } } stringBuilder.Append("</Table>\n"); stringBuilder.Append("</Worksheet>\n"); stringBuilder.Append("</Workbook>\n"); Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment;filename=trade" + System.DateTime.Now.ToString("_yy年MM月dd日hh:mm") + ".xls"); Response.Charset = "gb2312"; Response.ContentType = "application/ms-excel"; Response.Write(stringBuilder.ToString()); Response.End(); return PartialView(); } catch (Exception e) { ViewBag.Exception = e.ToString(); return PartialView(); } }
public ActionResult ItemExcel(int? id) { try { Yun.Interface.IYunClient client = new Yun.DefaultYunClient("http://a.gogift.cn/router/rest", "47041605c97649dd9a25012a6a6d8ae3", "918e3735e87d46c4b00fa00e31291772"); var u = client.Execute(new Yun.User.Request.LoginRequest { AppSecret = "918e3735e87d46c4b00fa00e31291772", Ip = "192.168.1.200", Password = "******", UserName = "******", }); System.Collections.Generic.List<Yun.Item.GoodsDetail> tradelist = new System.Collections.Generic.List<Yun.Item.GoodsDetail>(); var r = client.Execute(new GetItemsRequest { PageNum = 1, PageSize = 50, Sorts = "IdDesc", ItemState=id, }, u.Token); tradelist.AddRange(r.Items); if (r.TotalItem > 50) { for (int i = 2; i <= (r.TotalItem / 50) + 1; i++) { var rr = client.Execute(new GetItemsRequest { PageNum = i, PageSize = 50, Sorts = "IdDesc", ItemState = id, }, u.Token); tradelist.AddRange(rr.Items); } } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); stringBuilder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n"); stringBuilder.Append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:html=\"http://2015.gogift.cn/TR/REC-html40\">\n"); stringBuilder.Append("<Worksheet ss:Name=\"Table1\">\n"); stringBuilder.Append("<Table>\n"); stringBuilder.Append("<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n"); stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品id</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品名称</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品亮点</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">价格</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">原价</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">体积(m³):</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">重量(kg):</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品规则:</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">库存:</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">每账户限购:</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品编码:</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品图片:</Data></Cell>\n"); if (id == 2) { stringBuilder.Append("<Cell><Data ss:Type=\"String\">下架时间:</Data></Cell>\n"); } else { stringBuilder.Append("<Cell><Data ss:Type=\"String\">上架时间:</Data></Cell>\n"); } stringBuilder.Append("<Cell><Data ss:Type=\"String\">是否新品推荐:</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); foreach (var a in tradelist) { int num = 0; for (int i = 0; i < ( (a.ItemSkus==null||(a.ItemSkus!=null?!a.ItemSkus.Any()?true:false:false))?1:a.ItemSkus.Count); i++) { var b = (a.ItemSkus != null && (a.ItemSkus != null ? a.ItemSkus.Any() ? true : false : false)); var spe = ""; var b2 = (a.Pictures != null && (a.Pictures != null ? a.Pictures.Any() ? true : false : false)); if (b) { foreach (var a1 in a.ItemSkus[num].SpecNames) { spe += a1.Key + ":" + a1.Value + ","; } spe = spe + "价格:" + a.ItemSkus[num].Price + ",原价:" + a.ItemSkus[num].MarketPrice + ",数量:" + a.ItemSkus[num].Stock; } if (num == 0) { stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Id + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.ItemTitle + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.SubTitle + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Price + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.MarketPrice + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Volume + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Weight + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + spe + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Stock + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.BuyLimit + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.ItemCode + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + (b2?string.Join(",",a.Pictures):"") + "</Data></Cell>\n"); if (id == 2) { stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.OffShelfTime + "</Data></Cell>\n"); } else { stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.OnShelfTime + "</Data></Cell>\n"); } stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.IsRecommend + "</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); num += 1; } else { stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Id + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + spe + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\"></Data></Cell>\n"); stringBuilder.Append("</Row>\n"); num += 1; } } } stringBuilder.Append("</Table>\n"); stringBuilder.Append("</Worksheet>\n"); stringBuilder.Append("</Workbook>\n"); Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment;filename=trade" + System.DateTime.Now.ToString("_yy年MM月dd日hh:mm") + ".xls"); Response.Charset = "gb2312"; Response.ContentType = "application/ms-excel"; Response.Write(stringBuilder.ToString()); Response.End(); ViewBag.Json = "1"; return PartialView(); } catch (Exception e) { ViewBag.Json = e.ToString(); return PartialView(); } }
public ActionResult RefundExcel() { try { Yun.Interface.IYunClient client = new Yun.DefaultYunClient("http://127.0.0.1/router/rest", "47041605c97649dd9a25012a6a6d8ae3", "918e3735e87d46c4b00fa00e31291772"); var u = client.Execute(new Yun.User.Request.LoginRequest { AppSecret = "918e3735e87d46c4b00fa00e31291772", Ip = "192.168.1.200", Password = "******", UserName = "******", }); System.Collections.Generic.List<Yun.Trade.RefundDetail> tradelist = new System.Collections.Generic.List<Yun.Trade.RefundDetail>(); var r = client.Execute(new Yun.Trade.Request.GetSellerRefundsRequest { PageNum = 1, PageSize = 30, }, u.Token); tradelist.AddRange(r.Refunds); if (r.TotalItem > 30) { for (int i = 2; i <= (r.TotalItem / 30) + 1; i++) { var rr = client.Execute(new Yun.Trade.Request.GetSellerRefundsRequest { PageNum = i, PageSize = 30, }, u.Token); tradelist.AddRange(rr.Refunds); } } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); stringBuilder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n"); stringBuilder.Append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:html=\"http://2015.gogift.cn/TR/REC-html40\">\n"); stringBuilder.Append("<Worksheet ss:Name=\"Table1\">\n"); stringBuilder.Append("<Table>\n"); stringBuilder.Append("<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n"); stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">退款编号</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">订单编号</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">宝贝信息</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">买家</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">交易金额</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">退款金额</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">充值卡积分</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">申请时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">超时时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">退款状态</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); var Integral = YunShop.Core.DataProvider.GlobeInfo.GetIntegralRequest(); for (int i = 0; i < tradelist.Count; i++) { var trade = YunClient.Instance.Execute(new GetTradeRequest { Id = tradelist[i].TradeId }, Member.Token).Trade; var ext = ",积分:0"; if (((trade.Ext ?? "").IndexOf(',') >= 0)) { ext = ",积分" + trade.Ext.Split(',')[1]; } else if (int.Parse((trade.Ext ?? "0")) > 0) { ext = ",积分" + trade.Ext; } var status = YunShop.Core.Extension.Trade.GetTradeRefundStatusDescByCode(tradelist[i].Status); stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Id + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].OrderId + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].OrderInfo.ItemTitle + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + trade.Nick + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "金额:" + (trade.TotalFunds - (trade.PaymentInfo.OnlineMoney > 0 ? 0 : trade.PaymentInfo.PrepaidCard * Integral.OneIntegralEqualMoney)).ToString() + ext + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "金额:" + (tradelist[i].Balance).ToString() + ext + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + trade.PaymentInfo.PrepaidCard + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].CreateTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].EndTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + status + "</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); } stringBuilder.Append("</Table>\n"); stringBuilder.Append("</Worksheet>\n"); stringBuilder.Append("</Workbook>\n"); Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment;filename=refund" + System.DateTime.Now.ToString("_yy年MM月dd日hh:mm") + ".xls"); Response.Charset = "gb2312"; Response.ContentType = "application/ms-excel"; Response.Write(stringBuilder.ToString()); Response.End(); return PartialView(); } catch (Exception e) { ViewBag.Exception = e.ToString(); return PartialView(); } }
public ActionResult TradeExcel() { try { Yun.Interface.IYunClient client = new Yun.DefaultYunClient("http://a.gogift.cn/router/rest", "47041605c97649dd9a25012a6a6d8ae3", "918e3735e87d46c4b00fa00e31291772"); var u = client.Execute(new Yun.User.Request.LoginRequest { AppSecret = "918e3735e87d46c4b00fa00e31291772", Ip = "192.168.1.200", Password = "******", UserName = "******", }); System.Collections.Generic.List<Yun.Trade.SnapshotTrade> tradelist = new System.Collections.Generic.List<Yun.Trade.SnapshotTrade>(); var r = client.Execute(new Yun.Trade.Request.GetTradesSoldRequest { PageNum = 1, PageSize = 50, TradeStatus = "WAIT_SELLER_SEND_GOODS" }, u.Token); tradelist.AddRange(r.Trades); if (r.TotalItem > 50) { for (int i = 2; i <= (r.TotalItem / 50) + 1; i++) { var rr = client.Execute(new Yun.Trade.Request.GetTradesSoldRequest { PageNum = i, PageSize = 50, TradeStatus = "WAIT_SELLER_SEND_GOODS" }, u.Token); tradelist.AddRange(rr.Trades); } } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); stringBuilder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n"); stringBuilder.Append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:html=\"http://2015.gogift.cn/TR/REC-html40\">\n"); stringBuilder.Append("<Worksheet ss:Name=\"Table1\">\n"); stringBuilder.Append("<Table>\n"); stringBuilder.Append("<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n"); stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">订单号</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">宝贝名称</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">创建时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">付款时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">商品价格</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">购买数量</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">总金额</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">实际付款</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">收件人名字</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">地址</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">接收电话</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); for (int i = 0; i < tradelist.Count; i++) { int num = 0; foreach (var a in tradelist[i].Orders) { if (num == 0) { stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Id + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.ItemTitle + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].CreateTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].PayTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Money + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Quantity + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].TotalFunds + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Money + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].RealName + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Address + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Mobile + "</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); num += 1; } else { stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.ItemTitle + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Money + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + a.Quantity + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].TotalFunds + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Money + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + "" + "</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); num += 1; } } } stringBuilder.Append("</Table>\n"); stringBuilder.Append("</Worksheet>\n"); stringBuilder.Append("</Workbook>\n"); Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment;filename=trade" + System.DateTime.Now.ToString("_yy年MM月dd日hh:mm") + ".xls"); Response.Charset = "gb2312"; Response.ContentType = "application/ms-excel"; Response.Write(stringBuilder.ToString()); Response.End(); return PartialView(); } catch(Exception e) { ViewBag.Exception = e.ToString(); return PartialView(); } }
public ActionResult PrepaidCardExcel(DateTime? datebegin, DateTime? dateend,int company = 0) { try { Yun.Interface.IYunClient client = new Yun.DefaultYunClient("http://127.0.0.1/router/rest", "47041605c97649dd9a25012a6a6d8ae3", "918e3735e87d46c4b00fa00e31291772"); var u = client.Execute(new Yun.User.Request.LoginRequest { AppSecret = "918e3735e87d46c4b00fa00e31291772", Ip = "192.168.1.200", Password = "******", UserName = "******", }); System.Collections.Generic.List<Yun.Pay.PrepaidCardDomain> tradelist = new System.Collections.Generic.List<Yun.Pay.PrepaidCardDomain>(); var r = client.Execute(new GetPrepaidCardsListRequest { PageNum = 1, PageSize = 30, ShopId = company, IsBinded = true, StartBindTime=datebegin, EndBindTime=dateend, }, u.Token); tradelist.AddRange(r.PrepaidCards); if (r.TotalItem > 30) { for (int i = 2; i <= (r.TotalItem / 30) + 1; i++) { var rr = client.Execute(new GetPrepaidCardsListRequest { PageNum = 1, PageSize = 30, ShopId = company, IsBinded=true, StartBindTime = datebegin, EndBindTime = dateend, }, u.Token); tradelist.AddRange(r.PrepaidCards); } } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); stringBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); stringBuilder.Append("<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:x=\"urn:schemas-microsoft-com:office:excel\"\n"); stringBuilder.Append("xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\"\n"); stringBuilder.Append("xmlns:html=\"http://2015.gogift.cn/TR/REC-html40\">\n"); stringBuilder.Append("<Worksheet ss:Name=\"Table1\">\n"); stringBuilder.Append("<Table>\n"); stringBuilder.Append("<Column ss:Index=\"1\" ss:AutoFitWidth=\"0\" ss:Width=\"110\"/>\n"); stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">序号</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">绑定用户</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">创建时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">过期时间</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">所属公司</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">面额</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">充值卡余额</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); var Integral = YunShop.Core.DataProvider.GlobeInfo.GetIntegralRequest(); for (int i = 0; i < tradelist.Count; i++) { stringBuilder.Append("<Row>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].CardNumber + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].BindUserName + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].CreateTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].ExpiredTime + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].BindShopName + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Money + "</Data></Cell>\n"); stringBuilder.Append("<Cell><Data ss:Type=\"String\">" + tradelist[i].Balance + "</Data></Cell>\n"); stringBuilder.Append("</Row>\n"); } stringBuilder.Append("</Table>\n"); stringBuilder.Append("</Worksheet>\n"); stringBuilder.Append("</Workbook>\n"); Response.Clear(); Response.AppendHeader("Content-Disposition", "attachment;filename=refund" + System.DateTime.Now.ToString("_yy年MM月dd日hh:mm") + ".xls"); Response.Charset = "gb2312"; Response.ContentType = "application/ms-excel"; Response.Write(stringBuilder.ToString()); Response.End(); return PartialView(); } catch (Exception e) { ViewBag.Exception = e.ToString(); return PartialView(); } }