Files
29WxOrder/29WxOrderWpf/Ctrls/OrderCtrls/OrderGetOrderListHelper.cs
T
2026-11-13 14:48:01 +08:00

88 lines
2.7 KiB
C#
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using _29WxOrderWpf.BaseWindows;
using AllBase;
using AllBase.Helper;
using AllBase.Model.DBModel;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work;
namespace _29WxOrderWpf.Ctrls.OrderCtrls;
public class OrderGetOrderListHelper
{
/// <summary>
/// 读取订单详情信息
/// </summary>
/// <param name="orderIds"></param>
/// <returns></returns>
static async Task<List<oms_wei_order_info>> GetOrderInfoBase(string orderIds, string shopIds = null, DateTime? beginUpdateTime = null, DateTime? endUpdateTime = null)
{
if (string.IsNullOrEmpty(orderIds))
return new List<oms_wei_order_info>();
Thread.Sleep(100);
try
{
var url = BaseClass.Build29WxObjString("order/get_erp_order_list");
var data = UserLogin.GetSignaturex();
data += "&erp_order_id_in=" + orderIds;
data += "&page_size=" + 100;
if (!string.IsNullOrWhiteSpace(shopIds))
data += "&erp_shop_id_in=" + shopIds;
if (beginUpdateTime != null && beginUpdateTime != DateTime.MinValue)
{
var startTime = BaseClass.DateTimeToTimestampSeconds(beginUpdateTime.Value);
data += "&start_time=" + startTime;
}
if (endUpdateTime != null && endUpdateTime != DateTime.MinValue)
{
var endTime = BaseClass.DateTimeToTimestampSeconds(endUpdateTime.Value);
data += "&end_time=" + endTime;
}
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
{
throw new Exception("订单读取失败 " + BaseRegex.GetStringJson(ref html, "msg"));
}
List<oms_wei_order_info> orders = new List<oms_wei_order_info>();
orders = JsonHelper.DeserializeJsonToList<oms_wei_order_info>(JObject.Parse(html)["data"].ParseToString());
if (orders == null)
orders = new List<oms_wei_order_info>();
var orderItems = await OrderListCtrl.GetOrderItemInfo(orderIds);
foreach (var orderItem in orderItems)
{
var order = orders.FirstOrDefault(o => o.order_id == orderItem.order_id);
orderItem.ItemOrder = order;
order.orderItems.Add(orderItem);
}
return orders;
}
catch (Exception ex)
{
BaseMsgWindow.ShowAnimateMessage(ex.Message, "Error", 6);
return new List<oms_wei_order_info>();
}
}
public static async Task<List<oms_wei_order_info>> GetOrderInfo(string order_ids)
{
return await GetOrderInfoBase(order_ids, null, null);
}
public static async Task<List<oms_wei_order_info>> GetWxOrder‌IncrementAsync()
{
return new List<oms_wei_order_info>();
}
}