using AllBase.Helper; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Work.BaseForms; namespace _29WxOrder.OrderForms { public partial class BuyOrderPifaSelectForm : BaseGeneralForm { public string cookies = ""; public string sku = ""; List listpifa = new List(); public string order_sn = ""; public decimal pay_amount = 0; public BuyOrderPifaSelectForm instance = null; public BuyOrderPifaSelectForm() { InitializeComponent(); instance = this; } private void pnlSave_Click(object sender, EventArgs e) { this.Close(); } private void rbOrder1_CheckedChanged(object sender, EventArgs e) { if (rbOrder1.Checked) { var o = rbOrder1.Tag as PifaOrderModel; if (o != null) { order_sn = o.ordersn?.ToString(); pay_amount = o.payAmount / 100m; label1.Text = "当前选择订单:" + order_sn + " " + "规格:" + o.goodsspec; } } } private void rbOrder2_CheckedChanged(object sender, EventArgs e) { if (rbOrder2.Checked) { var o = rbOrder2.Tag as PifaOrderModel; if (o != null) { order_sn = o.ordersn?.ToString(); pay_amount = o.payAmount / 100m; label1.Text = "当前选择订单:" + order_sn + " " + "规格:" + o.goodsspec; } } } private void BuyOrderPifaSelectForm_Load(object sender, EventArgs e) { this.label1.Text = "请选择订单号"; this.label1.ForeColor = Color.Red; string html_data = HttpHelper.Request_pifa_pinduoduo_com("https://pifa.pinduoduo.com/pifa/order/pageQuery", "https://pifa.pinduoduo.com", "{\"page\":1,\"pageSize\":10}", cookies); if (!string.IsNullOrEmpty(html_data) && html_data.Contains("\"success\":true")) { var pageItems = JObject.Parse(html_data)["result"]["pageItems"]; //orderStatus=2 0待支付 2退款待处理/待发货 3已发货 foreach (var item in pageItems) { var items = item["items"]; foreach (var order in items) { string ordersn = order["orderSn"].ToString(); string goodsid = order["goodsId"].ToString(); string goodsspec = order["goodsSpec"].ToString(); string orderstatus = order["orderStatus"].ToString(); PifaOrderModel pifaOrderModel = new PifaOrderModel(); pifaOrderModel.ordersn = ordersn; pifaOrderModel.goodsid = goodsid; pifaOrderModel.goodsspec = goodsspec; pifaOrderModel.orderstatus = orderstatus; pifaOrderModel.payAmount = Convert.ToInt32(order["payAmount"].ToString()); pifaOrderModel.status = orderstatus == "2" ? "待发货" : "待支付"; if (listpifa.Where(x => x.ordersn == ordersn).Count() > 0) { PifaOrderModel _pifaOrderModel = listpifa.Find(x => x.ordersn == ordersn); _pifaOrderModel.orderstatus = pifaOrderModel.orderstatus; _pifaOrderModel.status = pifaOrderModel.status; } else { listpifa.Add(pifaOrderModel); } if (sku == goodsspec) { if (label1.Text.ToString().Contains("请选择订单")) { label1.Text = "保留订单号:" + ordersn; } } //if (orderstatus == "2") //{ // timer.Stop(); //} } break; } if (listpifa.Count >= 2) { rbOrder1.Text = listpifa[0].ordersn + " " + listpifa[0].goodsspec; rbOrder1.Tag = listpifa[0]; rbOrder2.Text = listpifa[1].ordersn + " " + listpifa[1].goodsspec; rbOrder2.Tag = listpifa[1]; //gridpifadata.ItemsSource = null; //gridpifadata.ItemsSource = listpifa; } } } } public class PifaOrderModel { public string ordersn { get; set; } public string goodsid { get; set; } public int payAmount { get; set; } public string goodsspec { get; set; } public string orderstatus { get; set; } public string status { get; set; } } }