Files
29WxOrder/29WxOrderWpf/Ctrls/OrderCtrls/OrderListRowItemCtrl.xaml.cs
T

336 lines
15 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using _29WxOrderWpf.BaseWindows;
using _29WxOrderWpf.Converters;
using AllBase;
using AllBase.Helper;
using AllBase.Model;
using AllBase.Model.Local;
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Policy;
using System.Text;
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._29Tools.BLL;
using Work._29Tools.Forms.ShopForms;
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);
}
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 btnCopyRemark_Click(object sender, RoutedEventArgs e)
{
}
private void btnBuyOrder_Click(object sender, RoutedEventArgs e)
{
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;
}
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(); }));
//}
}
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(); }));
}
BaseMsgWindow.ShowError("请登录店铺");
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(); }));
}
BaseMsgWindow.ShowError("请登录店铺");
return;
}
BaseMsgWindow.ShowError("店铺后台未查询到该代发单,请确认店铺在线且商品加入代发");
return;
}
}
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();
}
private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (this.DataContext is oms_wei_order_item_info order_item)
{
// 显示预估利润
//if (order_item.BuyMap == null && order_item.ItemOrder.out_amount == 0)
// txtProfitForecast.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;
}));
});
}
else
{
btnBuyOrder.Content = "关联拍单";
//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.ItemTransitOrder.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);
}
}
}
}
}