订单列表增加 同步订单
This commit is contained in:
1 parent
4f606c3561
commit
cef6300e8e
24 files changed
+2674
-1211
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using _29WxOrderWpf.BaseWindows;
|
||||
using _29WxOrderWpf.Commands;
|
||||
using _29WxOrderWpf.Common;
|
||||
using _29WxOrderWpf.Ctrls.BuyerCtrls;
|
||||
using _29WxOrderWpf.Ctrls.Statistics;
|
||||
@@ -1936,25 +1937,36 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
int errorCount = 0;
|
||||
foreach (oms_wei_order_info item in list)
|
||||
{
|
||||
var rst = await WxApiBLL.WxSearchAndDropshipCancelAsync(item.Shop, item);
|
||||
if (rst == "success")
|
||||
try
|
||||
{
|
||||
var ret = await _shipGiftService.Send(item.order_id, giftType);
|
||||
if (ret)
|
||||
var rst = await WxApiBLL.WxSearchAndDropshipCancelAsync(item.Shop, item);
|
||||
if (rst == "success")
|
||||
{
|
||||
sucessCount++;
|
||||
item.gift_order_status = 1;
|
||||
this.FilterOneOrder(item, true);
|
||||
var ret = await _shipGiftService.Send(item.order_id, giftType);
|
||||
if (ret)
|
||||
{
|
||||
sucessCount++;
|
||||
item.gift_order_status = 1;
|
||||
this.FilterOneOrder(item, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
errorCount++;
|
||||
}
|
||||
finally
|
||||
{
|
||||
item.IsSelect = false;
|
||||
}
|
||||
|
||||
SetProgress(index, count);
|
||||
BottomMsg = $"礼品单发送进度:{index}/{count}\t\t{item.orderItems.FirstOrDefault()?.title ?? ""}";
|
||||
@@ -1972,6 +1984,181 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拉取微信订单到任务列表
|
||||
/// </summary>
|
||||
public ICommand PullWXOrderCommand => new AsyncDelegateCommand(PullWXOrder);
|
||||
|
||||
private async Task PullWXOrder()
|
||||
{
|
||||
try
|
||||
{
|
||||
var isAfterSales = GlobalConfig.OrderTabHeaderStr.StartsWith("需处理售后单");//是否售后
|
||||
|
||||
var selectedShops = GlobalConfig.ShopLoginList.Where(a => a.IsSelect).ToList();
|
||||
if (selectedShops.Count == 0)
|
||||
{
|
||||
selectedShops = GlobalConfig.ShopLoginList.ToList();
|
||||
}
|
||||
|
||||
var selectedOrders = GlobalConfig.lstFilterOrder.Where(a => a.IsSelect).ToList();
|
||||
int count = selectedOrders.Count;
|
||||
if (count > 0 && isAfterSales == false)//非售后订单
|
||||
{
|
||||
if (BaseMsgWindow.ShowConfirm($"已选取:{count}个订单", "同步订单", MainWindow.Instance, MsgWindowLevel.MEDIUM).DialogResult == false) return;
|
||||
BottomMsg = $"订单同步进度....";
|
||||
int index = 1;
|
||||
int sucessCount = 0;
|
||||
int errorCount = 0;
|
||||
foreach (var item in selectedOrders)
|
||||
{
|
||||
var ret = await PullWXOrderService.Instance.PullOrderDetailAsync(item.shop_id, item.order_id); ;
|
||||
if (ret)
|
||||
{
|
||||
sucessCount++;
|
||||
this.GetOrder(item.order_id);
|
||||
SetProgress(index, count);
|
||||
item.IsSelect = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorCount++;
|
||||
}
|
||||
BottomMsg = $"订单同步进度:{index}/{count}\t\t{item.orderItems.FirstOrDefault()?.title ?? ""}";
|
||||
index++;
|
||||
}
|
||||
BottomMsg = $"订单同步进度完成 成功:{sucessCount} 失败:{errorCount} 总数:{count}";
|
||||
}
|
||||
else if (count > 0 && isAfterSales == true)//售后订单
|
||||
{
|
||||
if (BaseMsgWindow.ShowConfirm($"已选取:{count}个售后订单", "同步订单", MainWindow.Instance, MsgWindowLevel.MEDIUM).DialogResult == false) return;
|
||||
//var dictionaryResult = selectedOrders
|
||||
// .Where(o => o?.refundItems != null)
|
||||
// .SelectMany(o => o.refundItems
|
||||
// .Where(item => item != null)
|
||||
// .Select(item => new { o.shop_id, item.after_sale_order_id }))
|
||||
// .GroupBy(x => x.shop_id)
|
||||
// .ToDictionary(
|
||||
// g => g.Key,
|
||||
// g => g.Select(x => x.after_sale_order_id).ToArray()
|
||||
// );
|
||||
|
||||
|
||||
//BottomMsg = $"售后订单同步进度....";
|
||||
//foreach (var item in dictionaryResult)
|
||||
//{
|
||||
// var ret = await PullWXOrderService.Instance.PullAfterSaleOrdersAsync(item.Key, item.Value);
|
||||
//}
|
||||
//BottomMsg = $"售后同步任务已发送,等待同步完成";
|
||||
|
||||
|
||||
|
||||
int index = 1;
|
||||
int sucessCount = 0;
|
||||
int errorCount = 0;
|
||||
BottomMsg = $"售后订单同步进度....";
|
||||
foreach (KeyValuePair<long, List<oms_wei_order_info>> item in selectedOrders.GroupBy(a => a.shop_id).ToDictionary(a => a.Key, a => a.ToList()))
|
||||
{
|
||||
long shopid = item.Key;
|
||||
string shopName = item.Value.FirstOrDefault()?.shop_name ?? "";
|
||||
string[] afterSaleOrderIds = item.Value.SelectMany(a => a.refundItems).Where(a => a != null).Select(a => a.after_sale_order_id).ToArray();
|
||||
var ret = await PullWXOrderService.Instance.PullAfterSaleOrdersAsync(shopid, afterSaleOrderIds);
|
||||
if (ret)
|
||||
{
|
||||
sucessCount++;
|
||||
SetProgress(index, count);
|
||||
item.Value.ForEach(a => a.IsSelect = false);
|
||||
}
|
||||
else
|
||||
{
|
||||
errorCount++;
|
||||
}
|
||||
BottomMsg = $"售后订单同步进度:{index}/{count}\t\t{shopName}";
|
||||
index++;
|
||||
|
||||
}
|
||||
BottomMsg = $"售后同步任务已发送,等待同步完成";
|
||||
}
|
||||
else
|
||||
{
|
||||
count = selectedShops.Count;
|
||||
string prefix = $"已选取:{count}个商铺";
|
||||
if (count == GlobalConfig.ShopLoginList.Count)
|
||||
{
|
||||
prefix = "已选取全部商铺";
|
||||
}
|
||||
|
||||
|
||||
var startTime = dateStart.SelectedDate.Value;
|
||||
var endTime = dateEnd.SelectedDate.Value;
|
||||
|
||||
string msg = "";
|
||||
if (isAfterSales)
|
||||
{
|
||||
msg = $"{prefix}";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = $"{prefix}\n\n时间范围:{startTime.ToString("yyyy-MM-dd")}-{endTime.ToString("yyyy-MM-dd")}";
|
||||
}
|
||||
|
||||
if (BaseMsgWindow.ShowConfirm(msg, $"{(isAfterSales ? "售后" : "")}同步订单", MainWindow.Instance, MsgWindowLevel.MEDIUM).DialogResult == false) return;
|
||||
|
||||
if ((endTime - startTime).Days > 7)
|
||||
{
|
||||
throw new Exception("时间范围最大7天");
|
||||
}
|
||||
|
||||
var ret = false;
|
||||
if (isAfterSales)
|
||||
{
|
||||
ret = await PullWXOrderService.Instance.PullRefundOrderByShopsAsync(selectedShops.Select(a => a.ErpShopId.ParseToLong()).ToArray(), startTime, endTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = await PullWXOrderService.Instance.PullOrderByShopIdsAndTimeRangeAsync(selectedShops.Select(a => a.ErpShopId.ParseToLong()).ToArray(), startTime, endTime);
|
||||
}
|
||||
if (ret)
|
||||
{
|
||||
BaseMsgWindow.ShowInfo("同步任务已发送,等待同步完成\n任务详情查看任务列表");
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseMsgWindow.ShowError("同步任务失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BaseMsgWindow.ShowError("同步订单失败\n" + ex.Message, "Error");
|
||||
}
|
||||
//var service = PullWXOrderService.Instance;
|
||||
//foreach (var item in list)
|
||||
//{
|
||||
// await service.PullOrderDetailAsync(item.shop_id, item.order_id);
|
||||
//}
|
||||
}
|
||||
|
||||
private DialogWindow _taskDialog;
|
||||
public ICommand ShowTaskDialogViewCommand => new DelegateCommand(ShowTaskDialogView);
|
||||
|
||||
private void ShowTaskDialogView()
|
||||
{
|
||||
if (_taskDialog == null)
|
||||
{
|
||||
_taskDialog = new DialogWindow()
|
||||
{
|
||||
Title = "任务列表",
|
||||
Content = new OrderTaskDialogView(),
|
||||
|
||||
};
|
||||
_taskDialog.Closed += (s, e) => _taskDialog = null;
|
||||
}
|
||||
_taskDialog.Show();
|
||||
}
|
||||
}
|
||||
|
||||
public class OrderFilterConfig
|
||||
|
||||
Reference in new issue
Block a user