768 lines
36 KiB
C#
768 lines
36 KiB
C#
using _29WxOrderWpf.BaseWindows;
|
||
using _29WxOrderWpf.Converters;
|
||
using _29WxOrderWpf.Ctrls.BuyerCtrls;
|
||
using _29WxOrderWpf.UserControls;
|
||
using AllBase;
|
||
using AllBase.Helper;
|
||
using AllBase.Model;
|
||
using AllBase.Model.DBModel;
|
||
using AllBase.Model.Result;
|
||
using CefSharp.DevTools.DOM;
|
||
using NaiBa.Util.Extension;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Security.Policy;
|
||
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 TemuKJD.ToolForms;
|
||
using Work;
|
||
using Work._29Tools.BLL;
|
||
using Work._29Tools.Forms.ShopForms;
|
||
using Work._29Tools.Forms.ToolForms;
|
||
using Work.BaseForms;
|
||
using static System.Net.WebRequestMethods;
|
||
|
||
namespace _29WxOrderWpf.Ctrls.OrderCtrls
|
||
{
|
||
/// <summary>
|
||
/// OrderListRowItemCtrl.xaml 的交互逻辑
|
||
/// </summary>
|
||
public partial class OrderListRowItemCtrl : UserControl
|
||
{
|
||
public OrderListRowItemCtrl()
|
||
{
|
||
InitializeComponent();
|
||
txtOutOrderBuyerStr.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtOutOrderNumStr_MouseLeftButtonUp), true);
|
||
txtOutOrderNumStr.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtOutOrderNumStr_MouseLeftButtonUp), true);
|
||
txtRefundId.AddHandler(TextBox.MouseUpEvent, new MouseButtonEventHandler(txtRefundId_MouseLeftButtonUp), true);
|
||
|
||
txtWarehouseStatus.AddHandler(TextBox.MouseEnterEvent, new MouseEventHandler(txtWarehouseStatus_MouseEnter), true);
|
||
}
|
||
|
||
private void txtRefundId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||
{
|
||
if(this.DataContext is oms_wei_order_item_info order_item)
|
||
{
|
||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order_item.shop_id.ParseToString());
|
||
if (shop != null)
|
||
{
|
||
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
||
shopLoginForm.openType = Work._29Tools.Forms.ShopForms.EnumOpenType.manage;
|
||
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||
|
||
{
|
||
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/aftersale/detail?orderid=" + order_item.ItemRefund.after_sale_order_id;
|
||
}
|
||
shopLoginForm.Show();
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnSeeAddressDetail_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
var order = this.DataContext as oms_wei_order_item_info;
|
||
if (order == null)
|
||
return;
|
||
}
|
||
|
||
private void btnGetRefundAddress_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
var order = this.DataContext as oms_wei_order_item_info;
|
||
if (order == null)
|
||
return;
|
||
}
|
||
|
||
private void CheckBox_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void btnEditShopRemark_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info orderItem)
|
||
{
|
||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == orderItem.shop_id.ParseToString());
|
||
if (shop == null)
|
||
return;
|
||
|
||
if (btnEditShopRemark.Content.ParseToString() == "保存")
|
||
{
|
||
var notesRst = OrderListCtrl.addNotes(shop, orderItem.order_id, txtShopRemark.Text);
|
||
if (!notesRst.Contains("\"code\":0"))
|
||
{
|
||
ShopBLL.CheckShopLogin(shop);
|
||
BaseMsgForm.ShowError("保存失败请重试");
|
||
return;
|
||
}
|
||
|
||
btnCancelEditShopRemark.Visibility = Visibility.Collapsed;
|
||
btnEditShopRemark.Content = "编辑";
|
||
txtShopRemark.SetValue(WidthProperty, Double.NaN);
|
||
txtShopRemark.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 50, 150));
|
||
txtShopRemark.IsReadOnly = true;
|
||
}
|
||
else
|
||
{
|
||
btnCancelEditShopRemark.Visibility = Visibility.Visible;
|
||
btnEditShopRemark.Content = "保存";
|
||
txtShopRemark.SetValue(WidthProperty, 135.0);
|
||
txtShopRemark.BorderBrush = new SolidColorBrush(Color.FromArgb(50, 0, 50, 150));
|
||
txtShopRemark.IsReadOnly = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnCancelEditShopRemark_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
btnCancelEditShopRemark.Visibility = Visibility.Collapsed;
|
||
btnEditShopRemark.Content = "编辑";
|
||
txtShopRemark.SetValue(WidthProperty, Double.NaN);
|
||
txtShopRemark.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 50, 150));
|
||
txtShopRemark.IsReadOnly = true;
|
||
}
|
||
|
||
private void btnEditAppRemark_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info orderItem)
|
||
{
|
||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == orderItem.shop_id.ParseToString());
|
||
if (shop == null)
|
||
return;
|
||
|
||
if (btnEditAppRemark.Content.ParseToString() == "保存")
|
||
{
|
||
var url = BaseClass.Build29WxObjString("order/wx_update_erp_soft_remark");
|
||
var data = UserLogin.GetSignaturex();
|
||
data += "&order_id=" + orderItem.order_id;
|
||
data += "&soft_remark=" + txtAppRemark.Text;
|
||
var html = GetHtml.PostUtf8(url, data);
|
||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||
html = GetHtml.PostUtf8(url, data);
|
||
|
||
if (!html.Contains("\"code\":200"))
|
||
{
|
||
BaseMsgForm.ShowError("保存失败请重试");
|
||
return;
|
||
}
|
||
if (BaseRegex.GetIntJson(ref html, "affected_rows") == 0)
|
||
{
|
||
BaseMsgForm.ShowError("未找到指定订单");
|
||
return;
|
||
}
|
||
orderItem.ItemOrder.soft_remark = txtAppRemark.Text;
|
||
|
||
btnCancelEditAppRemark.Visibility = Visibility.Collapsed;
|
||
btnEditAppRemark.Content = "编辑";
|
||
txtAppRemark.SetValue(WidthProperty, Double.NaN);
|
||
txtAppRemark.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 50, 150));
|
||
txtAppRemark.IsReadOnly = true;
|
||
}
|
||
else
|
||
{
|
||
btnCancelEditAppRemark.Visibility = Visibility.Visible;
|
||
btnEditAppRemark.Content = "保存";
|
||
txtAppRemark.SetValue(WidthProperty, 135.0);
|
||
txtAppRemark.BorderBrush = new SolidColorBrush(Color.FromArgb(50, 0, 50, 150));
|
||
txtAppRemark.IsReadOnly = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void btnCancelEditAppRemark_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
btnCancelEditAppRemark.Visibility = Visibility.Collapsed;
|
||
btnEditAppRemark.Content = "编辑";
|
||
txtAppRemark.SetValue(WidthProperty, Double.NaN);
|
||
txtAppRemark.BorderBrush = new SolidColorBrush(Color.FromArgb(0, 0, 50, 150));
|
||
txtAppRemark.IsReadOnly = true;
|
||
}
|
||
|
||
private void btnBuyOrder_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
var orderItem = this.DataContext as oms_wei_order_item_info;
|
||
var refundItem = orderItem.ItemRefund;
|
||
if (orderItem == null)
|
||
{
|
||
BaseMsgWindow.ShowError("订单信息为空");
|
||
return;
|
||
}
|
||
if (GlobalConfig.CurrentPddBuyer == null)
|
||
{
|
||
BaseMsgWindow.ShowError("请选择买手号");
|
||
return;
|
||
}
|
||
if (orderItem.sku_cnt > 1 || orderItem.ItemOrder.orderItems.Count > 1)
|
||
{
|
||
BaseMsgWindow.ShowError("多单或多件商品订单中转仓暂不支持");
|
||
return;
|
||
}
|
||
|
||
btnBuyOrder.Cursor = Cursors.Wait;
|
||
btnBuyOrder.IsEnabled = false;
|
||
Task.Run(() =>
|
||
{
|
||
Thread.Sleep(2000);
|
||
Dispatcher.Invoke(new Action(() => { btnBuyOrder.IsEnabled = true; }));
|
||
});
|
||
Task.Run(() =>
|
||
{
|
||
// 拍单前查询订单是否退款
|
||
var orderId = orderItem.order_id;
|
||
var skuId = orderItem.sku_id;
|
||
MainWindow.Instance.orderListCtrl.GetOrder(orderId);
|
||
var newOrder = GlobalConfig.lstOrder.FirstOrDefault(or => or.order_id == orderId);
|
||
if (newOrder.orderItems.Count == 1)
|
||
orderItem = newOrder?.orderItems?.FirstOrDefault();
|
||
else
|
||
orderItem = newOrder?.orderItems?.FirstOrDefault(oi => oi.sku_id == skuId);
|
||
if (orderItem == null)
|
||
return;
|
||
// 如果是退款单,弹出退款窗口
|
||
if (/*orderItem?.ItemRefund?.count > 0 &&*/ orderItem.refund_status > 1)
|
||
{
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == orderItem.shop_id.ParseToString());
|
||
if (shop != null)
|
||
{
|
||
WXShopLoginForm shopLoginForm = new WXShopLoginForm(shop);
|
||
shopLoginForm.openType = Work._29Tools.Forms.ShopForms.EnumOpenType.manage;
|
||
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/aftersale/detail?orderid=" + orderItem.ItemRefund.after_sale_order_id;
|
||
shopLoginForm.Show();
|
||
}
|
||
else
|
||
{
|
||
BaseMsgWindow.ShowError("订单有售后,请去店铺后台退款");
|
||
}
|
||
}));
|
||
return;
|
||
}
|
||
|
||
|
||
// 拍单前检测买手号是否在线
|
||
if (GlobalConfig.CurrentPddBuyer.status == "在线")
|
||
{
|
||
PddMobileLoginForm.CheckBuyerLogin(GlobalConfig.CurrentPddBuyer);
|
||
}
|
||
if (GlobalConfig.CurrentPddBuyer.status != "在线")
|
||
{
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
BaseMsgWindow.ShowError("买手号掉线");
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
return;
|
||
}
|
||
|
||
//if (!GlobalConfig.BuyConfig.IsUseAppBalance)
|
||
//{
|
||
|
||
// var url = BaseClass.Build29WxObjString("shop/get_shop_erp_merchant");
|
||
// var data = UserLogin.GetSignaturex();
|
||
// data += "&corporate_account_user_id=" + orderItem.Shop.ErpCorporateAccountUserId;
|
||
// data += "&manage_user_id=" + orderItem.Shop.ErpManageUserId;
|
||
// data += "&shop_id=" + orderItem.Shop.ErpShopId;
|
||
// 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"))
|
||
// {
|
||
// Dispatcher.Invoke(new Action(() =>
|
||
// {
|
||
// //BaseMsgWindow.ShowError("未找到店铺账户!" + BaseRegex.GetStringJson(ref html, "msg"));
|
||
// //btnBuyOrder.Cursor = Cursors.Hand;
|
||
// GlobalConfig.BuyConfig.IsUseAppBalance = true;
|
||
// }));
|
||
// //return;
|
||
// }
|
||
//}
|
||
|
||
orderRetry:
|
||
// 拍单前查询账户余额
|
||
if (GlobalConfig.BuyConfig.IsUseAppBalance)
|
||
{
|
||
if (BaseClass.Balance < 10)
|
||
{
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
BaseMsgWindow.ShowError("软件快递余额不足(剩余" + BaseClass.Balance.ToString("0.00") + "元,拍单至少需保留10元),无法中转拍单,请先充值!");
|
||
}));
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
var url = BaseClass.Build29WxObjString("shop/get_shop_erp_merchant");
|
||
var data = UserLogin.GetSignaturex();
|
||
data += "&corporate_account_user_id=" + orderItem.Shop.ErpCorporateAccountUserId;
|
||
data += "&manage_user_id=" + orderItem.Shop.ErpManageUserId;
|
||
data += "&shop_id=" + orderItem.Shop.ErpShopId;
|
||
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"))
|
||
{
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
//BaseMsgWindow.ShowError("未找到店铺账户!" + BaseRegex.GetStringJson(ref html, "msg"));
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
if (orderItem.Shop.ErpCorporateAccountUserId == null && orderItem.Shop.ErpManageUserId == null)
|
||
{
|
||
GlobalConfig.BuyConfig.IsUseAppBalance = true;
|
||
StartUp.SaveBuyConfig();
|
||
BaseMsgWindow.ShowError("未找到店铺账户!" + BaseRegex.GetStringJson(ref html, "msg") + ",自动切换为快递余额拍单。");
|
||
goto orderRetry;
|
||
}
|
||
//return;
|
||
}
|
||
if (!string.IsNullOrEmpty(html) && html.Contains("\"code\":200"))
|
||
{
|
||
try
|
||
{
|
||
var erpMs = JsonHelper.DeserializeJsonToList<ErpMerchantInfo>(JsonHelper.JObjectParse(html)["data"].ParseToString());
|
||
var erpM = erpMs.FirstOrDefault();
|
||
if (erpM == null)
|
||
{
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
//BaseMsgWindow.ShowError("未找到店铺账户!");
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
GlobalConfig.BuyConfig.IsUseAppBalance = true;
|
||
StartUp.SaveBuyConfig();
|
||
BaseMsgWindow.ShowError("未找到店铺账户!自动切换为快递余额拍单。");
|
||
goto orderRetry;
|
||
//return;
|
||
}
|
||
|
||
var balance = erpM.balance.ParseToDecimal();
|
||
if (balance < 10)
|
||
{
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
BaseMsgWindow.ShowError("ERP账户余额不足(剩余" + balance.ToString("0.00") + "元,拍单至少需保留10元),无法中转拍单,请先充值!");
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
return;
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
BaseMsgWindow.ShowError("拍单校验出错,请稍后重试");
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (orderItem.BuyGoodsBtnTxt == "去店铺后台绑定代发")
|
||
{
|
||
if (orderItem.Shop != null)
|
||
{
|
||
WXShopLoginForm shopLoginForm = new WXShopLoginForm(orderItem.Shop);
|
||
shopLoginForm.openType = Work._29Tools.Forms.ShopForms.EnumOpenType.manage;
|
||
shopLoginForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||
shopLoginForm.InitUrl = "https://store.weixin.qq.com/shop/supply/consignmentOrderList";
|
||
shopLoginForm.IsGetSupplierPage = true;
|
||
shopLoginForm.ShowDialog();
|
||
|
||
// 不是立即生效的,不用立即刷新
|
||
//var is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierList(orderItem.Shop);
|
||
//if (!is29SupplierRst.Contains("\"code\":0"))
|
||
// is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierList(orderItem.Shop);
|
||
//if (is29SupplierRst.Contains("\"code\":0") && is29SupplierRst.Contains("\"name\":\"29供货商\""))
|
||
//{
|
||
// orderItem.Shop.Is29Supplier = true;
|
||
//}
|
||
//else
|
||
//{
|
||
// ShopBLL.CheckShopLogin(orderItem.Shop);
|
||
// orderItem.Shop.Is29Supplier = false;
|
||
//}
|
||
//foreach (var order in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == orderItem.Shop.ErpShopId).ToList())
|
||
//{
|
||
// // 更新代发管理情况
|
||
// foreach (var o in order.orderItems)
|
||
// Dispatcher.Invoke(new Action(() => { o.UpdateOrderItemBuyButton(); }));
|
||
//}
|
||
}
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
return;
|
||
}
|
||
|
||
if (orderItem.Shop?.LoginStatus != "登录成功")
|
||
{
|
||
foreach (var ord in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == orderItem.Shop.ErpShopId).ToList())
|
||
{
|
||
// 更新代发管理情况
|
||
foreach (var oi in ord.orderItems)
|
||
Dispatcher.Invoke(new Action(() => { oi.UpdateOrderItemBuyButton(); }));
|
||
}
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
BaseMsgWindow.ShowError("请登录店铺");
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
return;
|
||
}
|
||
// 检测是否加入代发
|
||
if (orderItem.Shop?.LoginStatus == "登录成功")
|
||
{
|
||
var is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierOrderList(orderItem.Shop, orderItem.order_id);
|
||
if (!is29SupplierRst.Contains("\"code\":0"))
|
||
is29SupplierRst = WxOrderSupplierBLL.GetWxSupplierOrderList(orderItem.Shop, orderItem.order_id);
|
||
if (is29SupplierRst.Contains("\"code\":0") && is29SupplierRst.Contains("\"supplierName\":\"29供货商\"")) // "supplierName":"29供货商"
|
||
{
|
||
orderItem.Shop.Is29Supplier = true;
|
||
}
|
||
else
|
||
{
|
||
ShopBLL.CheckShopLogin(orderItem.Shop);
|
||
if (orderItem.Shop?.LoginStatus != "登录成功")
|
||
{
|
||
foreach (var ord in GlobalConfig.lstFilterOrder.Where(o => o.shop_id.ParseToString() == orderItem.Shop.ErpShopId).ToList())
|
||
{
|
||
// 更新代发管理情况
|
||
foreach (var oi in ord.orderItems)
|
||
Dispatcher.Invoke(new Action(() => { oi.UpdateOrderItemBuyButton(); }));
|
||
}
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
BaseMsgWindow.ShowError("请登录店铺");
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
return;
|
||
}
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
BaseMsgWindow.ShowError("店铺后台未查询到该代发单,请确认店铺在线且商品加入代发");
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
}));
|
||
return;
|
||
}
|
||
}
|
||
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
btnBuyOrder.Cursor = Cursors.Hand;
|
||
|
||
PddMobileBuyOrderForm buyOrderForm = new PddMobileBuyOrderForm(MainWindow.Instance.orderListCtrl.FilterOneOrder, orderItem, GlobalConfig.CurrentPddBuyer, orderItem.BuyMap);
|
||
|
||
// 未关联拍单的跳到所有订单页面
|
||
buyOrderForm.InitUrl = "https://mobile.yangkeduo.com/orders.html"; //"?type=0&comment_tab=1&combine_orders=1&main_orders=1&refer_page_name=personal&refer_page_id=10001_1782219035613_a9ulipk4k3&refer_page_sn=10001";
|
||
buyOrderForm.pnlBuy.Visible = false;
|
||
|
||
// 已有拍单关联的跳的到订单确认界面
|
||
if (orderItem.BuyMap != null)
|
||
{
|
||
//buyOrderForm.InitUrl = "https://mobile.yangkeduo.com/order_checkout.html?sku_id=" + orderItem.BuyMap.map_sku_id +
|
||
// "&group_id=1" + Randomx.GetNumber(11) + "&goods_id=" + orderItem.BuyMap.map_goods_id + "&goods_number=" + +orderItem.sku_cnt +
|
||
// "&page_from=101&detail_id=" + Randomx.GetNumber(11) + "&_oak_rcto=YW" +
|
||
// Randomx.GetWordNumber("JvLXvJ8Fx9mUIW34yn103TOlATJGk5PaZshD6pY1bsVrsIjWdxWwjCoNX3IGT".Length) + "_VWkP5_q-1QNqGg" +
|
||
// "&order_extra_type=1&refer_page_element=open_btn&source_channel=0&refer_page_name=goods_detail" +
|
||
// "&refer_page_id=10014_" + BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + Randomx.GetNumber(3) + "_tny5ifswls&refer_page_sn=10014";
|
||
|
||
buyOrderForm.InitUrl = "https://mobile.yangkeduo.com/order_checkout.html?sku_id=" + orderItem.BuyMap.map_sku_id +
|
||
"&group_id=1" + Randomx.GetNumber(11) + "&goods_id=" + orderItem.BuyMap.map_goods_id + "&goods_number=" + orderItem.sku_cnt +
|
||
"&page_from=101";
|
||
|
||
//buyOrderForm.InitUrl = "https://mobile.yangkeduo.com/order_checkout.html?sku_id=" + orderItem.BuyMap.map_sku_id +
|
||
// "&group_id=1" + Randomx.GetNumber(11) + "&goods_id=" + orderItem.BuyMap.map_goods_id + "&goods_number=" + orderItem.sku_cnt +
|
||
// "&page_from=0&refer_page_element=open_btn&source_channel=0&refer_page_name=goods_detail&refer_page_id=10014_" +
|
||
// BaseClass.DateTimeToTimestampSeconds(DateTime.Now) + Randomx.GetNumber(3) + "_" + Randomx.GetWordNumber(10) + "&refer_page_sn=10014";
|
||
|
||
buyOrderForm.pnlBuy.Visible = true;
|
||
buyOrderForm.pnlMap.Visible = false;
|
||
}
|
||
buyOrderForm.ShowDialog();
|
||
MainWindow.Instance.Balance = BaseClass.Balance.ToString("0.00");
|
||
}));
|
||
});
|
||
}
|
||
|
||
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info order_item)
|
||
{
|
||
//btnBuyOrder.Content = "关联拍单";
|
||
|
||
// 显示预估利润
|
||
//if (order_item.BuyMap == null && order_item.ItemOrder.out_amount == 0)
|
||
// txtProfitForecast.Visibility = Visibility.Visible;
|
||
|
||
btnDeleteTransitOrder.Visibility = Visibility.Collapsed;
|
||
//if (BaseClass.SaLevel == 1 && order_item.ItemTransitOrder != null)
|
||
//{
|
||
// btnDeleteTransitOrder.Visibility = Visibility.Visible;
|
||
//}
|
||
|
||
order_item.UpdateOrderItemBuyButton();
|
||
|
||
Task.Run(() =>
|
||
{
|
||
// 异步加载图片防止卡顿
|
||
// 缩略图在有的电脑上无法显示
|
||
//BitmapImage bImg = ImageUrlToBitmapImageConverter.LoadImageFromUrl(order_item.thumb_img + "?imageView2/1/w/100/format/webp|imageMogr2/auto-orient=");
|
||
BitmapImage bImg = ImageUrlToBitmapImageConverter.LoadImageFromUrl(order_item.thumb_img);
|
||
Dispatcher.Invoke(new Action(() =>
|
||
{
|
||
imgOrderItem.Source = bImg;
|
||
}));
|
||
});
|
||
|
||
if (order_item.ItemOrder.status == 20 /*&& order_item.refund_status <= 1*/ && order_item.ItemTransitOrder != null)
|
||
{
|
||
btnDeleteTransitOrder.Visibility = Visibility.Visible;
|
||
}
|
||
//待采购不显示所有采购信息状态(否则会显示作废订单状态)
|
||
if (GlobalConfig.OrderTabHeaderStr.StartsWith("待采购"))
|
||
{
|
||
wpBuyAccount.Visibility = Visibility.Collapsed;
|
||
wpBuyOrderId.Visibility = Visibility.Collapsed;
|
||
wpBuyTime.Visibility = Visibility.Collapsed;
|
||
wpTransitWaybillStatus.Visibility = Visibility.Collapsed;
|
||
wpTransitBuyerRefundStatus.Visibility = Visibility.Collapsed;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//imgOrderItem.Source = null;
|
||
}
|
||
}
|
||
|
||
private void txtOutOrderNumStr_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
|
||
{
|
||
var buyerName = txtOutOrderBuyerStr.Text.Split(':').LastOrDefault();
|
||
var outOrderId = txtOutOrderNumStr.Text.Split(':').LastOrDefault();
|
||
if (string.IsNullOrEmpty(buyerName) || string.IsNullOrEmpty(outOrderId))
|
||
{
|
||
return;
|
||
}
|
||
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(p => p.buyer_name == buyerName);
|
||
var url = "";
|
||
if (buyer != null)
|
||
{
|
||
if (sender == txtOutOrderBuyerStr)
|
||
url = "https://mobile.yangkeduo.com/index.html";
|
||
else
|
||
url = "https://mobile.yangkeduo.com/order.html?order_sn=" + outOrderId + "&page_from=1&main_orders=1&is_tester=1&refer_page_name=my_order" +
|
||
"&refer_page_id=10032_" + BaseClass.ConvertDateTimeLong(DateTime.Now) + "_" + Randomx.GetWordNumber(10) + "&refer_page_sn=10032";
|
||
}
|
||
|
||
var orderItem = this.DataContext as oms_wei_order_item_info;
|
||
if (orderItem == null)
|
||
{
|
||
BaseMsgWindow.ShowError("订单信息为空");
|
||
return;
|
||
}
|
||
if (GlobalConfig.CurrentPddBuyer == null)
|
||
{
|
||
BaseMsgWindow.ShowError("请选择买手号");
|
||
return;
|
||
}
|
||
// 拍单的时候检测一下买手号
|
||
if (GlobalConfig.CurrentPddBuyer.status == "在线")
|
||
{
|
||
PddMobileLoginForm.CheckBuyerLogin(GlobalConfig.CurrentPddBuyer);
|
||
}
|
||
if (GlobalConfig.CurrentPddBuyer.status != "在线")
|
||
{
|
||
BaseMsgWindow.ShowError("买手号掉线");
|
||
return;
|
||
}
|
||
|
||
PddMobileBuyOrderForm buyOrderForm = new PddMobileBuyOrderForm(MainWindow.Instance.orderListCtrl.FilterOneOrder, orderItem, GlobalConfig.CurrentPddBuyer, orderItem.BuyMap);
|
||
|
||
//所有订单页面
|
||
buyOrderForm.InitUrl = url;
|
||
buyOrderForm.pnlBuy.Visible = false;
|
||
|
||
//已有拍单关联的控制界面显示隐藏
|
||
if (orderItem.BuyMap != null)
|
||
{
|
||
buyOrderForm.pnlBuy.Visible = true;
|
||
buyOrderForm.pnlMap.Visible = false;
|
||
}
|
||
buyOrderForm.ShowDialog();
|
||
}
|
||
|
||
private void Path_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info orderItem)
|
||
{
|
||
try
|
||
{
|
||
Clipboard.SetText(orderItem.ItemTransitOrderWithVoid.out_order_no);
|
||
BaseMsgWindow.ShowAnimateMessage("复制成功");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void pathRefundId_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info order_item)
|
||
{
|
||
try
|
||
{
|
||
Clipboard.SetText(order_item.ItemRefund.after_sale_order_id);
|
||
BaseMsgWindow.ShowAnimateMessage("复制成功");
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
BaseMsgWindow.ShowError("复制失败 " + ex.Message);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void imgOrderItem_MouseEnter(object sender, MouseEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void imgOrderItem_MouseLeave(object sender, MouseEventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void imgOrderItem_MouseDown(object sender, MouseButtonEventArgs e)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info orderItem)
|
||
{
|
||
ShowImgForm imgFrom = new ShowImgForm(orderItem.thumb_img);
|
||
imgFrom.ShowDialog();
|
||
}
|
||
}
|
||
|
||
private async void btnDeleteTransitOrder_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info orderItem)
|
||
{
|
||
// 拍单前查询订单是否退款
|
||
var orderId = orderItem.order_id;
|
||
var skuId = orderItem.sku_id;
|
||
await Task.Run(() =>
|
||
{
|
||
MainWindow.Instance.orderListCtrl.GetOrder(orderId);
|
||
var newOrder = GlobalConfig.lstOrder.FirstOrDefault(or => or.order_id == orderId);
|
||
if (newOrder.orderItems.Count == 1)
|
||
orderItem = newOrder?.orderItems?.FirstOrDefault();
|
||
else
|
||
orderItem = newOrder?.orderItems?.FirstOrDefault(oi => oi.sku_id == skuId);
|
||
if (orderItem == null)
|
||
{
|
||
BaseMsgWindow.ShowError("订单查询失败,请重试");
|
||
return;
|
||
}
|
||
|
||
if (orderItem.ItemTransitOrder == null)
|
||
{
|
||
BaseMsgWindow.ShowError("订单状态已修改,请确认后重试");
|
||
return;
|
||
}
|
||
});
|
||
|
||
bool noBuyer = false;
|
||
var buyer = GlobalConfig.PDDBuyerLoginList.FirstOrDefault(b => b.buyer_name == orderItem.ItemTransitOrder.buyer_account);
|
||
if (buyer == null)
|
||
{
|
||
if (BaseMsgWindow.ShowConfirm("拍单买手不存在,点击确定直接作废中转单并手动取消买手单,点击取消登录买手后重试").DialogResult != true)
|
||
return;
|
||
noBuyer = true;
|
||
}
|
||
|
||
// 检测一下买手号
|
||
if (GlobalConfig.CurrentPddBuyer.status == "在线")
|
||
{
|
||
await Task.Run(() =>
|
||
{
|
||
PddMobileLoginForm.CheckBuyerLogin(GlobalConfig.CurrentPddBuyer);
|
||
});
|
||
}
|
||
if (GlobalConfig.CurrentPddBuyer.status != "在线")
|
||
{
|
||
if (BaseMsgWindow.ShowConfirm("买手掉线,点击确定直接作废中转单并手动取消买手单,点击取消登录买手后重试").DialogResult != true)
|
||
return;
|
||
noBuyer = true;
|
||
}
|
||
|
||
if (!noBuyer)
|
||
{
|
||
var pddAfterRst = PDDBuyerOrderReadCtrl.SimPddAfterSale(buyer, new PddBuyerOrderLiteInfo() { order_status_prompt = "待发货",
|
||
order_amount = orderItem.ItemTransitOrder.out_amount, order_sn = orderItem.ItemTransitOrder.out_order_no });
|
||
if (pddAfterRst.Contains("\"after_sales_status\":1") || pddAfterRst.Contains("该订单已全额退款") || pddAfterRst.Contains("订单未付款"))
|
||
{
|
||
}
|
||
else
|
||
{
|
||
if (BaseMsgWindow.ShowConfirm("买手退款失败,点击确定直接作废中转单并手动取消买手单,点击取消稍候重试").DialogResult != true)
|
||
return;
|
||
}
|
||
}
|
||
|
||
//订单作废接口(作废重拍)
|
||
//postman request POST 'http://localhost:8088/oms-api/external_procurement/discardOrder' \
|
||
// --header 'Content-Type: application/json' \
|
||
// --body '{
|
||
// "orderNo":"12334534534",
|
||
// "outOrderNo":"12312312"
|
||
//}' 成功返回code:0 失败返回code:1
|
||
|
||
string url2 = "https://po.e57.cn/prod-api/api/oms-api/external_procurement/discardOrder";
|
||
var data = new JObject();
|
||
data["orderNo"] = orderItem.order_id;
|
||
data["outOrderNo"] = orderItem.ItemTransitOrder.out_order_no;
|
||
var dataStr2 = JsonHelper.SerializeObject(data);
|
||
var discardRst = HttpResponseWXBLL.e57PostResponse(url2, dataStr2, "");
|
||
if (discardRst.Contains("<code>0</code>") || discardRst.Contains("<code>200</code>"))
|
||
{
|
||
MainWindow.Instance.orderListCtrl.GetOrder(orderId);
|
||
MainWindow.Instance.orderListCtrl.FilterOrders();
|
||
BaseMsgWindow.ShowInfo("订单作废成功,请重新拍单");
|
||
}
|
||
else
|
||
{
|
||
var msg = BaseRegex.GetStringXml(ref discardRst, "msg");
|
||
BaseMsgWindow.ShowInfo("订单作废失败,服务端返回 " + msg);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void txtWarehouseStatus_MouseEnter(object sender, MouseEventArgs e)
|
||
{
|
||
if (txtWarehouseStatus.ToolTip == null)
|
||
{
|
||
if (this.DataContext is oms_wei_order_item_info orderItem)
|
||
{
|
||
if (orderItem.ItemTransitOrderWithVoid.raw_message != null && orderItem.ItemTransitOrderWithVoid.raw_message.Contains("取号异常"))
|
||
this.txtWarehouseStatus.ToolTip = orderItem.ItemTransitOrderWithVoid.raw_message;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|