257 lines
7.6 KiB
C#
257 lines
7.6 KiB
C#
using _29WxOrderWpf.BaseWindows;
|
|
using AllBase;
|
|
using AllBase.Helper;
|
|
using AllBase.Model.DBModel;
|
|
using NaiBa.Util.Extension;
|
|
using OrderSupportTicket.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Animation;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
using Work;
|
|
using Work._29Tools.BLL;
|
|
using Work._29Tools.Forms.ShopForms;
|
|
|
|
namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
|
{
|
|
/// <summary>
|
|
/// OrderListRowHeaderCtrl.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class OrderListRowHeaderCtrl : UserControl
|
|
{
|
|
public static DateTime LastRefreshTime = DateTime.Now.AddSeconds(-5);
|
|
|
|
public OrderListRowHeaderCtrl()
|
|
{
|
|
InitializeComponent();
|
|
this.DataContextChanged += OrderListRowHeaderCtrl_DataContextChanged;
|
|
txtOrderId.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtOrderId_MouseLeftButtonUp), true);
|
|
txtShopName.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtShopName_MouseLeftButtonUp), true);
|
|
}
|
|
|
|
private void txtShopName_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (this.DataContext is oms_wei_order_info order)
|
|
{
|
|
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
|
|
if (shop != null)
|
|
{
|
|
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
|
ShopBLL.CheckShopLogin(shop);
|
|
if (shop.LoginStatus == "登录成功")
|
|
{
|
|
// 在线直接进店
|
|
shopLoginForm.openType = EnumOpenType.manage;
|
|
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/home";
|
|
shopLoginForm.Show();
|
|
}
|
|
else
|
|
{
|
|
// 掉线登录
|
|
shopLoginForm.openType = EnumOpenType.login;
|
|
shopLoginForm.ShowDialog();
|
|
|
|
if (shop.LoginStatus == "登录成功")
|
|
{
|
|
shop.Is29Supplier = false;
|
|
for (int i = 0; i < 100; i++)
|
|
{
|
|
var is29SupplierRst = WxSimOrderSupplierBLL.GetWxSupplierListV2(shop);
|
|
if (!is29SupplierRst.Contains("\"code\":0"))
|
|
is29SupplierRst = WxSimOrderSupplierBLL.GetWxSupplierListV2(shop);
|
|
if (is29SupplierRst.Contains("\"code\":0") && is29SupplierRst.Contains("\"name\":\"29供货商\""))
|
|
{
|
|
shop.Is29Supplier = true;
|
|
break;
|
|
}
|
|
else if (!is29SupplierRst.Contains("\"code\":0"))
|
|
{
|
|
ShopBLL.CheckShopLogin(shop);
|
|
}
|
|
int totalCount = BaseRegex.GetIntJson(ref is29SupplierRst, "totalCount");
|
|
if (i * 20 >= totalCount)
|
|
break;
|
|
}
|
|
|
|
foreach (var ord in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == shop.ErpShopId).ToList())
|
|
{
|
|
// 更新代发管理情况
|
|
foreach (var orderItem in ord.orderItems)
|
|
Dispatcher.Invoke(new Action(() => { orderItem.UpdateOrderItemBuyButton(); }));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void txtOrderId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (this.DataContext is oms_wei_order_info order)
|
|
{
|
|
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
|
|
if (shop != null)
|
|
{
|
|
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
|
shopLoginForm.openType = EnumOpenType.manage;
|
|
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
|
|
|
{
|
|
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/order/detail?orderid=" + order.order_id;
|
|
}
|
|
shopLoginForm.Show();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OrderListRowHeaderCtrl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
if (this.DataContext is oms_wei_order_info order)
|
|
{
|
|
if (order.orderItems.Count > 5)
|
|
{
|
|
//txtCount.Text = "该订单共计 " + order.orderItems.Count + " 件商品";
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
//var orderId = ((sender as Border)?.Tag).ParseToString();
|
|
if (this.DataContext is oms_wei_order_info order)
|
|
{
|
|
|
|
try
|
|
{
|
|
//Clipboard.SetText(order.order_id); // 复制成功,但会报错,改为SetDataObject
|
|
Clipboard.SetDataObject(order.order_id);
|
|
BaseMsgWindow.ShowAnimateMessage("复制成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void pathShop_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (this.DataContext is oms_wei_order_info order)
|
|
{
|
|
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order.shop_id.ParseToString());
|
|
if (shop != null)
|
|
{
|
|
try
|
|
{
|
|
Clipboard.SetDataObject(shop.ShopAccount);
|
|
BaseMsgWindow.ShowAnimateMessage("复制成功");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void borderFlag_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (this.DataContext is oms_wei_order_info order)
|
|
{
|
|
int flag = 0;
|
|
if (order.colour_flag == 4)
|
|
{
|
|
flag = 0;
|
|
}
|
|
else
|
|
{
|
|
flag = 4;
|
|
}
|
|
Task.Run(() =>
|
|
{
|
|
var url = BaseClass.Build29WxObjString("order/wx_update_erp_color_flag");
|
|
var data = UserLogin.GetSignaturex();
|
|
data += "&order_id=" + order.order_id;
|
|
data += "&colour_flag=" + flag;
|
|
var rst = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(rst) || !rst.Contains("\"code\":200"))
|
|
rst = GetHtml.PostUtf8(url, data);
|
|
if (string.IsNullOrEmpty(rst) || !rst.Contains("\"code\":200"))
|
|
{
|
|
BaseMsgWindow.ShowAnimateMessage(BaseRegex.GetStringJson(ref rst, "msg"), "Error", 5);
|
|
return;
|
|
}
|
|
BaseMsgWindow.ShowAnimateMessage("修改成功", "Msg", 2);
|
|
order.colour_flag = flag;
|
|
Thread.Sleep(1000);
|
|
Dispatcher.Invoke(new Action(() => { MainWindow.Instance.orderListCtrl.FilterOneOrder(order); }));
|
|
|
|
});
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 创建工单
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private async void btn_createOrderSupportTicket(object sender, RoutedEventArgs e)
|
|
{
|
|
if (!(this.DataContext is oms_wei_order_info order))
|
|
return;
|
|
|
|
var shop = order.Shop
|
|
?? GlobalConfig.ShopLoginList.FirstOrDefault(
|
|
s => s.ErpShopId == order.shop_id.ParseToString());
|
|
var appId = shop?.ShopId?.Trim();
|
|
if (string.IsNullOrWhiteSpace(appId)
|
|
|| string.IsNullOrWhiteSpace(order.order_id))
|
|
{
|
|
BaseMsgWindow.ShowAnimateMessage(
|
|
"订单缺少店铺 APPID 或订单号,无法创建工单",
|
|
"Error",
|
|
5);
|
|
return;
|
|
}
|
|
|
|
var ticketOrder = TicketOrderOption.FromWechatOrder(order, appId);
|
|
|
|
try
|
|
{
|
|
await MainWindow.Instance.CreateOrderSupportTicketAsync(ticketOrder);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
BaseMsgWindow.ShowError("打开工单窗口失败:" + ex.Message);
|
|
}
|
|
}
|
|
|
|
private async void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (!(this.DataContext is oms_wei_order_info order))
|
|
return;
|
|
|
|
if (LastRefreshTime > DateTime.Now.AddSeconds(-5))
|
|
{
|
|
BaseMsgWindow.ShowAnimateMessage("操作太快了请稍候再点击", "Error", 5);
|
|
return;
|
|
}
|
|
|
|
LastRefreshTime = DateTime.Now;
|
|
await Task.Run(async () => { await MainWindow.Instance.orderListCtrl.GetOrder(order.order_id); });
|
|
}
|
|
}
|
|
}
|