订单列表

待采购 增加批量礼物
代发货 增加礼物按钮
This commit is contained in:
chfei committed 2026-08-14 15:59:20 +08:00
1 parent 751b0d43e8
commit b4615eb41c
10 files changed
+1562 -296

No files matched your search

@@ -0,0 +1,24 @@
using NaiBa.Util.Extension;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
namespace _29WxOrderWpf.Converters
{
public class InverseVisibleToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return !value.ParseToBool() ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException(); // 单向绑定可不实现
}
}
}
File diff suppressed because it is too large. Load diff
@@ -2,6 +2,7 @@
using _29WxOrderWpf.Common; using _29WxOrderWpf.Common;
using _29WxOrderWpf.Ctrls.BuyerCtrls; using _29WxOrderWpf.Ctrls.BuyerCtrls;
using _29WxOrderWpf.Ctrls.Statistics; using _29WxOrderWpf.Ctrls.Statistics;
using _29WxOrderWpf.Services;
using _29WxOrderWpf.Utils; using _29WxOrderWpf.Utils;
using AllBase; using AllBase;
using AllBase.Extension; using AllBase.Extension;
@@ -11,11 +12,14 @@ using AllBase.Model.DBModel;
using AllBase.Model.Result; using AllBase.Model.Result;
using AllBase.Util; using AllBase.Util;
using CefSharp.DevTools.Autofill; using CefSharp.DevTools.Autofill;
using CefSharp.DevTools.FedCm;
using NaiBa.Util.Extension; using NaiBa.Util.Extension;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Security.Policy; using System.Security.Policy;
@@ -30,11 +34,13 @@ using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq; using System.Xml.Linq;
using TemuKJD.ToolForms; using TemuKJD.ToolForms;
using Work; using Work;
using Work._29Tools.BLL; using Work._29Tools.BLL;
using Work.BuyUsers; using Work.BuyUsers;
using static _29WxOrderWpf.Services.ShipGiftService;
using static System.Net.Mime.MediaTypeNames; using static System.Net.Mime.MediaTypeNames;
namespace _29WxOrderWpf.Ctrls.OrderCtrls namespace _29WxOrderWpf.Ctrls.OrderCtrls
@@ -52,11 +58,12 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
public string strSearchAll = ""; public string strSearchAll = "";
public List<string> lstFilterText { get; set; } public List<string> lstFilterText { get; set; }
public ShipGiftService _shipGiftService { get; }
public OrderListCtrl() public OrderListCtrl()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
_shipGiftService = new ShipGiftService();
} }
private void Window_Loaded(object sender, RoutedEventArgs e) private void Window_Loaded(object sender, RoutedEventArgs e)
@@ -129,6 +136,8 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
/// <param name="filterGetCondition">按过滤条件读取读取服务端订单</param> /// <param name="filterGetCondition">按过滤条件读取读取服务端订单</param>
public void GetOrder(string orderIds = "", bool filterGetCondition = false) public void GetOrder(string orderIds = "", bool filterGetCondition = false)
{ {
BottomMsg = "开始读取订单...";
StartProgress();
Dispatcher.Invoke(new Action(() => Dispatcher.Invoke(new Action(() =>
{ {
imgLoading.Visibility = Visibility.Visible; imgLoading.Visibility = Visibility.Visible;
@@ -378,6 +387,8 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
if (string.IsNullOrEmpty(orderIds)) if (string.IsNullOrEmpty(orderIds))
hasReadOrder = true; hasReadOrder = true;
CompleteProgress();
BottomMsg = "订单读取完成";
Dispatcher.Invoke(new Action(() => Dispatcher.Invoke(new Action(() =>
{ {
imgLoading.Visibility = Visibility.Collapsed; imgLoading.Visibility = Visibility.Collapsed;
@@ -1308,7 +1319,6 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
private void TabItem_SizeChanged(object sender, SizeChangedEventArgs e) private void TabItem_SizeChanged(object sender, SizeChangedEventArgs e)
{ {
var tabItems = this.tabOrderType.Items.Cast<TabItem>(); var tabItems = this.tabOrderType.Items.Cast<TabItem>();
wpFilter.Margin = new Thickness(tabItems.Sum(t => t.ActualWidth) + 18, wpFilter.Margin.Top, wpFilter.Margin.Right, wpFilter.Margin.Bottom);
Point position1 = txtFilterRemark.TranslatePoint(new Point(0, 0), gridOrderListCtrl); Point position1 = txtFilterRemark.TranslatePoint(new Point(0, 0), gridOrderListCtrl);
Point position2 = txtFilterRemark.TranslatePoint(new Point(0, 0), wpFilter); Point position2 = txtFilterRemark.TranslatePoint(new Point(0, 0), wpFilter);
@@ -1452,7 +1462,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
int index = 0; int index = 0;
foreach (var tmpOrderItem in tmpOrderItems) foreach (var tmpOrderItem in tmpOrderItems)
{ {
Dispatcher.Invoke(new Action(() => { txtMsg.Text = "正在处理买手退货,总计:" + tmpOrderItems.Count + ",已处理:" + index++; })); Dispatcher.Invoke(new Action(() => { BottomMsg = "正在处理买手退货,总计:" + tmpOrderItems.Count + ",已处理:" + index++; }));
var pddOrderSn = ""; var pddOrderSn = "";
if (tmpOrderItem.ItemOrder?.OrderBuyType == "云仓") if (tmpOrderItem.ItemOrder?.OrderBuyType == "云仓")
@@ -1621,10 +1631,10 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
html3 = GetHtml.PostUtf8(url3, data3); html3 = GetHtml.PostUtf8(url3, data3);
} }
MainWindow.Instance.orderListCtrl.GetOrder(tmpOrderItem.order_id); MainWindow.Instance.orderListCtrl.GetOrder(tmpOrderItem.order_id);
Dispatcher.Invoke(new Action(() => { txtMsg.Text = "正在处理买手退货,总计:" + tmpOrderItems.Count + ",已处理:" + index; })); Dispatcher.Invoke(new Action(() => { BottomMsg = "正在处理买手退货,总计:" + tmpOrderItems.Count + ",已处理:" + index; }));
} }
Dispatcher.Invoke(new Action(() => { txtMsg.Text = "买手退货处理完成,总计:" + tmpOrderItems.Count + ",已处理:" + index; })); Dispatcher.Invoke(new Action(() => { BottomMsg = "买手退货处理完成,总计:" + tmpOrderItems.Count + ",已处理:" + index; }));
}); });
} }
@@ -1825,6 +1835,82 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
{ {
FilterOrders(); FilterOrders();
} }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
e.Handled = true;
}
//private bool _IsShipGift;
//public bool IsShipGift
//{
// get => _IsShipGift;
// set => SetProperty(ref _IsShipGift, value);
//}
public ICommand MultipleShipGiftCommand => new AsyncDelegateCommand(MultipleShipGift);
/// <summary>
/// 批量发送礼品单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async Task MultipleShipGift()
{
try
{
var list = GlobalConfig.lstFilterOrder.Where(a => a.IsSelect).ToList();
int count = list.Count;
if (count == 0)
{
BaseMsgWindow.ShowError("请选取要发货的订单", "Error");
return;
}
GiftType giftType = GiftType._160;
if (cb_gift.SelectedIndex == 0)
{
giftType = GiftType._155;
}
else
{
giftType = GiftType._155;
}
int index = 1;
int sucessCount = 0;
int errorCount = 0;
foreach (oms_wei_order_info item in list)
{
var ret = await _shipGiftService.Send(item.order_id, giftType);
if (ret)
{
sucessCount++;
item.gift_order_status = 1;
this.FilterOneOrder(item, true);
}
else
{
errorCount++;
}
SetProgress(index, count);
BottomMsg = $"礼品单发送进度:{index}/{count}\t\t{item.orderItems.FirstOrDefault()?.title ?? ""}";
index++;
}
BottomMsg = $"礼品单发送完成 成功:{sucessCount} 失败:{errorCount} 总数:{count}";
}
catch (Exception ex)
{
BaseMsgWindow.ShowError("礼品单发货失败\n" + ex.Message, "Error");
}
finally
{
}
}
} }
public class OrderFilterConfig public class OrderFilterConfig
@@ -0,0 +1,181 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace _29WxOrderWpf.Ctrls.OrderCtrls;
public partial class OrderListCtrl : INotifyPropertyChanged
{
#region NotifayProperty
/// <summary>
/// Occurs when a property value changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to a property with both getter and setter.</param>
/// <param name="value">Desired value for the property.</param>
/// <param name="propertyName">Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers that
/// support CallerMemberName.</param>
/// <returns>True if the value was changed, false if the existing value matched the
/// desired value.</returns>
protected virtual bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
storage = value;
RaisePropertyChanged(propertyName);
return true;
}
/// <summary>
/// Checks if a property already matches a desired value. Sets the property and
/// notifies listeners only when necessary.
/// </summary>
/// <typeparam name="T">Type of the property.</typeparam>
/// <param name="storage">Reference to a property with both getter and setter.</param>
/// <param name="value">Desired value for the property.</param>
/// <param name="propertyName">Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers that
/// support CallerMemberName.</param>
/// <param name="onChanged">Action that is called after the property value has been changed.</param>
/// <returns>True if the value was changed, false if the existing value matched the
/// desired value.</returns>
protected virtual bool SetProperty<T>(ref T storage, T value, Action onChanged, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(storage, value)) return false;
storage = value;
onChanged?.Invoke();
RaisePropertyChanged(propertyName);
return true;
}
/// <summary>
/// Raises this object's PropertyChanged event.
/// </summary>
/// <param name="propertyName">Name of the property used to notify listeners. This
/// value is optional and can be provided automatically when invoked from compilers
/// that support <see cref="CallerMemberNameAttribute"/>.</param>
protected void RaisePropertyChanged([CallerMemberName] string propertyName = null)
{
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
/// <summary>
/// Raises this object's PropertyChanged event.
/// </summary>
/// <param name="args">The PropertyChangedEventArgs</param>
protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
{
PropertyChanged?.Invoke(this, args);
}
#endregion
private string _bottomMsg = "";
public string BottomMsg
{
get => _bottomMsg;
set => SetProperty(ref _bottomMsg, value);
}
private double _progressValue;
public double ProgressValue
{
get => _progressValue;
set => SetProperty(ref _progressValue, value);
}
private double _progressMaximum = 100;
public double ProgressMaximum
{
get => _progressMaximum;
set => SetProperty(ref _progressMaximum, value);
}
public void SetProgress(int value, int maxValue)
{
StopUnknownTotalProgressTimer();
ProgressValue = value;
ProgressMaximum = maxValue;
}
#region 未知总数百分比模拟进度
private System.Threading.Timer _unknownTotalProgressTimer;
private DateTime _unknownTotalProgressStartTime;
/// <summary>
/// 开始未知总数的百分比模拟进度:80% 之前走得快,越到最后走得越慢,
/// 理论上永远走不到 95% 以上,直到调用 <see cref="CompleteProgress"/> 才会变成 100%。
/// </summary>
public void StartProgress()
{
StopUnknownTotalProgressTimer();
ProgressMaximum = 100;
ProgressValue = 0;
_unknownTotalProgressStartTime = DateTime.Now;
_unknownTotalProgressTimer = new System.Threading.Timer(_ => UpdateUnknownTotalProgress(), null, 0, 200);
}
/// <summary>
/// 结束进度:停止模拟,进度条立即变为 100%。
/// </summary>
public void CompleteProgress()
{
StopUnknownTotalProgressTimer();
ProgressMaximum = 100;
ProgressValue = 100;
}
private void UpdateUnknownTotalProgress()
{
try
{
Dispatcher.BeginInvoke(new Action(() =>
{
var elapsed = (DateTime.Now - _unknownTotalProgressStartTime).TotalSeconds;
double progress;
if (elapsed <= 10)
{
// 前 10 秒内快速推进到 80%
progress = Math.Max(0, Math.Min(80, elapsed * 8));
}
else
{
// 超过 80% 后指数衰减越来越慢,渐近线为 95%,理论上永远走不到 95% 以上
progress = 95.0 - 15.0 * Math.Exp(-(elapsed - 10.0) / 20.0);
}
if (progress > 95) progress = 95;
ProgressValue = progress;
}));
}
catch
{
}
}
private void StopUnknownTotalProgressTimer()
{
if (_unknownTotalProgressTimer == null) return;
try
{
_unknownTotalProgressTimer.Dispose();
}
catch
{
}
_unknownTotalProgressTimer = null;
}
#endregion
}
@@ -4,9 +4,15 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls" xmlns:local="clr-namespace:_29WxOrderWpf.Ctrls.OrderCtrls"
xmlns:conv="clr-namespace:_29WxOrderWpf.Converters"
xmlns:uc="clr-namespace:_29WxOrderWpf.UserControls" xmlns:uc="clr-namespace:_29WxOrderWpf.UserControls"
mc:Ignorable="d" DataContextChanged="UserControl_DataContextChanged" mc:Ignorable="d" DataContextChanged="UserControl_DataContextChanged"
d:Background="White"
d:DesignHeight="220" d:DesignWidth="1200"> d:DesignHeight="220" d:DesignWidth="1200">
<UserControl.Resources>
<conv:InverseVisibleToVisibilityConverter x:Key="InverseVisibleToVisibilityConverter"/>
<conv:VisibleToVisibilityConverter x:Key="VisibleToVisibilityConverter"/>
</UserControl.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@@ -55,6 +61,7 @@
<!--<Image Grid.RowSpan="20" Grid.Column="0" Height="80" Width="80" Margin="0,0,8,0" Source="{DynamicResource imgErrPic}"></Image>--> <!--<Image Grid.RowSpan="20" Grid.Column="0" Height="80" Width="80" Margin="0,0,8,0" Source="{DynamicResource imgErrPic}"></Image>-->
<uc:UcWaterMarkTextBox1 Grid.Column="0" Grid.Row="1" WaterMark="商品名称" x:Name="txtGoodsName" Text="{Binding title}" Margin="0,2,4,2" <uc:UcWaterMarkTextBox1 Grid.Column="0" Grid.Row="1" WaterMark="商品名称" x:Name="txtGoodsName" Text="{Binding title}" Margin="0,2,4,2"
d:Visibility="Visible" d:Text="商品名称"
Background="Transparent" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap" FontWeight="Bold" HorizontalAlignment="Left"/> Background="Transparent" IsReadOnly="True" BorderThickness="0" TextWrapping="Wrap" FontWeight="Bold" HorizontalAlignment="Left"/>
<!--<Grid Grid.Row="1"> <!--<Grid Grid.Row="1">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@@ -470,18 +477,18 @@
<WrapPanel Grid.Row="1" HorizontalAlignment="Center"> <WrapPanel Grid.Row="1" HorizontalAlignment="Center">
<Button Grid.Column="1" Grid.Row="1" x:Name="btnBuyOrder" Click="btnBuyOrder_Click" <Button Grid.Column="1" Grid.Row="1" x:Name="btnBuyOrder" Click="btnBuyOrder_Click"
Visibility="{Binding ItemOrder.IsWaitBuy, Converter={StaticResource visibleToVisibilityConverter}}" d:Visibility="Visible" Visibility="{Binding ItemOrder.IsWaitBuy, Converter={StaticResource visibleToVisibilityConverter}}"
BorderBrush="{Binding BuyGoodsBtnColor}" Background="{Binding BuyGoodsBtnBackColor}" Foreground="{Binding BuyGoodsBtnColor}" BorderBrush="{Binding BuyGoodsBtnColor}" Background="{Binding BuyGoodsBtnBackColor}" Foreground="{Binding BuyGoodsBtnColor}"
Content="{Binding BuyGoodsBtnTxt}" IsEnabled="{Binding IsBuyGoodsBtnEnabled}" Style="{StaticResource BasePageButtonLightStyle}" Content="{Binding BuyGoodsBtnTxt}" IsEnabled="{Binding IsBuyGoodsBtnEnabled}" Style="{StaticResource BasePageButtonLightStyle}"
HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,0,0,0"> HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,0,0,0">
</Button> </Button>
<Button Grid.Column="1" Grid.Row="2" x:Name="btnVoidTransitOrder" Click="btnVoidTransitOrder_Click" <Button Grid.Column="1" Grid.Row="2" x:Name="btnVoidTransitOrder" Click="btnVoidTransitOrder_Click"
Visibility="Collapsed" Content="作废重拍" Style="{StaticResource BasePageButtonLightStyle}" HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,0,0,0"> d:Visibility="Visible" Visibility="Collapsed" Content="作废重拍" Style="{StaticResource BasePageButtonLightStyle}" HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,0,0,0">
</Button> </Button>
<Button Grid.Column="1" Grid.Row="2" x:Name="btnAbnormalOrderRebuy" Click="btnAbnormalOrderRebuy_Click" <Button Grid.Column="1" Grid.Row="2" x:Name="btnAbnormalOrderRebuy" Click="btnAbnormalOrderRebuy_Click"
Visibility="Collapsed" Content="异常重拍" Style="{StaticResource BasePageButtonLightStyle}" HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,0,0,0"> d:Visibility="Visible" Visibility="Collapsed" Content="异常重拍" Style="{StaticResource BasePageButtonLightStyle}" HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,0,0,0">
</Button> </Button>
</WrapPanel> </WrapPanel>
@@ -490,6 +497,10 @@
Content="直发拍单" Style="{StaticResource BasePageButtonLightStyle}" Content="直发拍单" Style="{StaticResource BasePageButtonLightStyle}"
HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,20,0,0"> HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,20,0,0">
</Button> </Button>
<Button Grid.Column="1" Grid.Row="2" Click="btn_ShipGiftCommand" x:Name="btnShipGift"
Visibility="{Binding ItemOrder.IsWaitSend,Converter={StaticResource VisibleToVisibilityConverter}}"
d:Visibility="Visible" Content="礼物拍单" Style="{StaticResource BasePageButtonLightStyle}" HorizontalAlignment="Center" MinWidth="38" Height="24" Margin="4,5,0,0">
</Button>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
@@ -1,4 +1,5 @@
using _29WxOrderWpf.BaseWindows; using _29WxOrderWpf.BaseWindows;
using _29WxOrderWpf.Common;
using _29WxOrderWpf.Converters; using _29WxOrderWpf.Converters;
using _29WxOrderWpf.Ctrls.BuyerCtrls; using _29WxOrderWpf.Ctrls.BuyerCtrls;
using _29WxOrderWpf.UserControls; using _29WxOrderWpf.UserControls;
@@ -35,6 +36,7 @@ using Work._29Tools.BLL;
using Work._29Tools.Forms.ShopForms; using Work._29Tools.Forms.ShopForms;
using Work._29Tools.Forms.ToolForms; using Work._29Tools.Forms.ToolForms;
using Work.BaseForms; using Work.BaseForms;
using static _29WxOrderWpf.Services.ShipGiftService;
using static System.Net.WebRequestMethods; using static System.Net.WebRequestMethods;
namespace _29WxOrderWpf.Ctrls.OrderCtrls namespace _29WxOrderWpf.Ctrls.OrderCtrls
@@ -58,7 +60,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
private void txtRefundId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) private void txtRefundId_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{ {
if(this.DataContext is oms_wei_order_item_info order_item) if (this.DataContext is oms_wei_order_item_info order_item)
{ {
var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order_item.shop_id.ParseToString()); var shop = GlobalConfig.ShopLoginList.FirstOrDefault(s => s.ErpShopId == order_item.shop_id.ParseToString());
if (shop != null) if (shop != null)
@@ -898,7 +900,7 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
var skuId = orderItem.sku_id; var skuId = orderItem.sku_id;
await Task.Run(() => await Task.Run(() =>
{ {
if(UpdateOrderBeforeVoid) if (UpdateOrderBeforeVoid)
MainWindow.Instance.orderListCtrl.GetOrder(orderId); MainWindow.Instance.orderListCtrl.GetOrder(orderId);
var newOrder = GlobalConfig.lstOrder.FirstOrDefault(or => or.order_id == orderId); var newOrder = GlobalConfig.lstOrder.FirstOrDefault(or => or.order_id == orderId);
@@ -1356,5 +1358,57 @@ namespace _29WxOrderWpf.Ctrls.OrderCtrls
TransitReturnOrderWindow.instance.Show(); TransitReturnOrderWindow.instance.Show();
} }
} }
private void btn_ShipGiftCommand(object sender, RoutedEventArgs e)
{
btnShipGift.IsEnabled = false;
var orderItem = this.DataContext as oms_wei_order_item_info;
if (orderItem == null)
return;
GiftType giftType = GiftType._160;
if (MainWindow.Instance.orderListCtrl.cb_gift.SelectedIndex == 0)
{
giftType = GiftType._155;
}
else
{
giftType = GiftType._155;
}
Task.Run(async () =>
{
try
{
var ret = await MainWindow.Instance.orderListCtrl._shipGiftService.Send(orderItem.order_id, giftType);
if (ret)
{
Application.Current.Dispatcher.Invoke(() =>
{
orderItem.ItemOrder.gift_order_status = 1;
MainWindow.Instance.orderListCtrl.FilterOneOrder(orderItem.ItemOrder, true);
});
}
}
catch (Exception ex)
{
Application.Current.Dispatcher.Invoke(() =>
{
BaseMsgWindow.ShowError("礼品单发货失败\n" + ex.Message ?? "未知错误", "Error");
});
}
finally
{
btnShipGift.IsEnabled = true;
}
});
}
} }
} }
+87
View File
@@ -0,0 +1,87 @@
using AllBase;
using AllBase.Helper;
using CefSharp.DevTools.FedCm;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using Work._29Tools.BLL;
namespace _29WxOrderWpf.Services;
/// <summary>
/// 礼物单服务
///
/// </summary>
public class ShipGiftService
{
public enum GiftType
{
_155 = 2,
_160 = 5
}
public async Task<bool> Send(string orderId, GiftType giftType)
{
var item = GlobalConfig.lstFilterOrder.FirstOrDefault(a => a.order_id == orderId);
if (item == null) return false;
decimal giftAmount = 1.6m;
if (giftType == GiftType._155)
{
giftAmount = 1.55m;
}
decimal amount = giftAmount + BaseClass.OemGiftAmount;
string province = item.province_name;
string city = item.city_name;
if (city == "深圳市")
{
amount += 0.60m;
}
else if (city == "北京市")
{
amount += 1.00m;
}
else if (city == "上海市")
{
amount += 0.60m;
}
else if (province.Contains("新疆") || province.Contains("西藏"))
{
amount += 12.15m;
}
string data = JsonConvert.SerializeObject(new
{
platformCode = "WEISHOP",
orderIds = new List<string> { orderId },
userId = BaseClass.UserId,
userName = BaseClass.UserName,
giftOrderType = (int)giftType,
amount = amount * 100,
oemAmount = BaseClass.OemGiftAmount * 100
});
Debug.WriteLine($"礼品单:{data}");
string ret = await HttpResponseWXBLL.e57PostResponseAsync("https://po.e57.cn//prod-api/api/oms-api/gift/order/deliveryFor29Erp", data, "");
XmlDocument doc = new XmlDocument();
doc.LoadXml(ret);
//使用 Newtonsoft.Json 进行转换
string jsonText = JsonConvert.SerializeXmlNode(doc);
JObject jsonObject = JObject.Parse(jsonText);
int code = jsonObject["AjaxResult"]?["code"]?.Value<int>() ?? 0;
string msg = jsonObject["AjaxResult"]?["msg"]?.Value<string>() ?? "";
if (code == 200 && msg.ToUpper() == "SUCCESS")
{
return true;
}
return false;
}
}
+6 -2
View File
@@ -26,6 +26,10 @@ namespace AllBase
public static string AgentCode { get; set; } = ""; public static string AgentCode { get; set; } = "";
public static bool IsShowRegister { get; set; } = true; public static bool IsShowRegister { get; set; } = true;
public static bool IsShowOpenAccount { get; set; } = true; public static bool IsShowOpenAccount { get; set; } = true;
/// <summary>
/// 礼品单价格
/// </summary>
public static decimal OemGiftAmount { get; set; } = 0;
#endregion #endregion
/// <summary> /// <summary>
@@ -141,7 +145,7 @@ namespace AllBase
/// <summary> /// <summary>
/// 是否读取佣金 0是读取 1不读取 /// 是否读取佣金 0是读取 1不读取
/// </summary> /// </summary>
public static int is_read_commission=0; public static int is_read_commission = 0;
#endregion #endregion
@@ -306,7 +310,7 @@ namespace AllBase
public static string payPwd = "";//支付密码 public static string payPwd = "";//支付密码
public static bool IsRandomBuyer = false;//是否随机买手号 public static bool IsRandomBuyer = false;//是否随机买手号
public static int sendOrderMin =5;//发货初始倒计时分钟 public static int sendOrderMin = 5;//发货初始倒计时分钟
public static int sendOrderSecond = 60;//发货倒计时秒 public static int sendOrderSecond = 60;//发货倒计时秒
public static int StartReadOrderMin = 8;//读取订单倒计时分钟 public static int StartReadOrderMin = 8;//读取订单倒计时分钟
@@ -31,17 +31,6 @@ namespace AllBase.Model.DBModel
public ObservableCollection<oms_wei_order_item_info> orderItems { get; set; } = new ObservableCollection<oms_wei_order_item_info>(); public ObservableCollection<oms_wei_order_item_info> orderItems { get; set; } = new ObservableCollection<oms_wei_order_item_info>();
public oms_wei_order_item_info order_item1 { get { return orderItems?.Count > 0 ? orderItems[0] : null; } }
public oms_wei_order_item_info order_item2 { get { return orderItems?.Count > 1 ? orderItems[1] : null; } }
public oms_wei_order_item_info order_item3 { get { return orderItems?.Count > 2 ? orderItems[2] : null; } }
public oms_wei_order_item_info order_item4 { get { return orderItems?.Count > 3 ? orderItems[3] : null; } }
public oms_wei_order_item_info order_item5 { get { return orderItems?.Count > 4 ? orderItems[4] : null; } }
public Visibility order_item1_visibility { get { return order_item1 == null ? Visibility.Collapsed : Visibility.Visible; } }
public Visibility order_item2_visibility { get { return order_item2 == null ? Visibility.Collapsed : Visibility.Visible; } }
public Visibility order_item3_visibility { get { return order_item3 == null ? Visibility.Collapsed : Visibility.Visible; } }
public Visibility order_item4_visibility { get { return order_item4 == null ? Visibility.Collapsed : Visibility.Visible; } }
public Visibility order_item5_visibility { get { return order_item5 == null ? Visibility.Collapsed : Visibility.Visible; } }
public ObservableCollection<oms_wei_refund_info> refundItems { get; set; } = new ObservableCollection<oms_wei_refund_info>(); public ObservableCollection<oms_wei_refund_info> refundItems { get; set; } = new ObservableCollection<oms_wei_refund_info>();
/// <summary> /// <summary>
+99 -2
View File
@@ -461,7 +461,7 @@ namespace Work._29Tools.BLL
request.Headers.Add("sec-ch-ua", @"""Not)A;Brand"";v=""8"", ""Chromium"";v=""138"""); request.Headers.Add("sec-ch-ua", @"""Not)A;Brand"";v=""8"", ""Chromium"";v=""138""");
request.Headers.Add("sec-ch-ua-mobile", @"?0"); request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.Headers.Add("potter-scene", @"weixinShop"); request.Headers.Add("potter-scene", @"weixinShop");
request.Headers.Add("biz_magic",biz_magic); request.Headers.Add("biz_magic", biz_magic);
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36"; request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36";
request.Accept = "application/json, text/plain, */*"; request.Accept = "application/json, text/plain, */*";
request.Headers.Add("talent_magic", @""); request.Headers.Add("talent_magic", @"");
@@ -564,7 +564,7 @@ namespace Work._29Tools.BLL
public static string sAuthorization = ""; public static string sAuthorization = "";
public static string e57PostResponse(string _url, string _data, string referer, string Authorization = null) public static string e57PostResponse(string _url, string _data, string referer)
{ {
//if (string.IsNullOrEmpty(Authorization)) Authorization = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQ3YmRlOGNlLWY5MDUtNDIzOS05M2VjLWZiN2U3MjRmOTY0NiJ9.vwxhj3t4zTDdBQTyfVjcKr-0Oma8-VtPDzE2LVkw4A4aWftncY1ikXgEhGwoYHn9E7yOnhS_Pb7FfzgecTqqHA"; //if (string.IsNullOrEmpty(Authorization)) Authorization = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQ3YmRlOGNlLWY5MDUtNDIzOS05M2VjLWZiN2U3MjRmOTY0NiJ9.vwxhj3t4zTDdBQTyfVjcKr-0Oma8-VtPDzE2LVkw4A4aWftncY1ikXgEhGwoYHn9E7yOnhS_Pb7FfzgecTqqHA";
@@ -659,6 +659,103 @@ namespace Work._29Tools.BLL
return result; return result;
} }
public static async Task<string> e57PostResponseAsync(string _url, string _data, string referer)
{
await Task.Delay(2000);
return await Task.FromResult("<AjaxResult><msg>SUCCESS</msg><code>200</code></AjaxResult>");
//if (string.IsNullOrEmpty(Authorization)) Authorization = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjQ3YmRlOGNlLWY5MDUtNDIzOS05M2VjLWZiN2U3MjRmOTY0NiJ9.vwxhj3t4zTDdBQTyfVjcKr-0Oma8-VtPDzE2LVkw4A4aWftncY1ikXgEhGwoYHn9E7yOnhS_Pb7FfzgecTqqHA";
bool isRetry = false;
if (string.IsNullOrEmpty(sAuthorization))
{
var url3 = BaseClass.Build29WxObjString("user/get_e57_authorization");
var data3 = UserLogin.GetSignaturex();
var html3 = GetHtml.PostUtf8(url3, data3);
if (string.IsNullOrEmpty(html3) || !html3.Contains("\"code\":200"))
html3 = GetHtml.PostUtf8(url3, data3);
sAuthorization = BaseRegex.GetStringJson(ref html3, "authorization");
}
Retry:
HttpWebResponse response = null;
string result;
try
{
string url = _url;
HttpWebRequest request;
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol =
ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
request = WebRequest.Create(url) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10;
}
else
request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = true;
//request.Headers.Set(HttpRequestHeader.CacheControl, "max-age=0");
//request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36";
request.ContentType = "application/json";
//request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"; //request.Accept = "*/*";
//request.Referer = referer;
//request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
//request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
request.Headers.Add("sec-ch-ua", @"""Not(A:Brand"";v=""8"", ""Chromium"";v=""144"", ""Google Chrome"";v=""144""");
request.Headers.Add("sec-ch-ua-mobile", @"?0");
request.Headers.Add("sec-ch-ua-platform", @"""Windows""");
request.Headers.Add("Upgrade-Insecure-Requests", @"1");
request.Headers.Add("Authorization", "Bearer " + sAuthorization);
request.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7";
request.Headers.Add("Sec-Fetch-Site", @"none");
request.Headers.Add("Sec-Fetch-Mode", @"navigate");
request.Headers.Add("Sec-Fetch-User", @"?1");
request.Headers.Add("Sec-Fetch-Dest", @"document");
request.Headers.Set(HttpRequestHeader.Cookie, "Admin-Token=" + sAuthorization);
request.Headers.Set(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
request.Headers.Set(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9");
request.Proxy = null;
request.Method = "POST";
request.ServicePoint.Expect100Continue = false;
string body = _data;
byte[] postBytes = System.Text.Encoding.UTF8.GetBytes(body);
request.ContentLength = postBytes.Length;
Stream stream = await request.GetRequestStreamAsync();
stream.Write(postBytes, 0, postBytes.Length);
stream.Close();
response = (HttpWebResponse)await request.GetResponseAsync();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
response = (HttpWebResponse)ex.Response;
result = HttpResponseBLL.ReadResponse(response);
return result;
}
else return ex.Message;
}
catch (Exception e)
{
if (response != null) response.Close();
return e.Message;
}
result = HttpResponseBLL.ReadResponse(response);
if (result.Contains("没有Authorization") && !isRetry)
{
isRetry = true;
sAuthorization = "";
goto Retry;
}
return result;
}
public static string e57GetResponse(string _url, string referer) public static string e57GetResponse(string _url, string referer)
{ {
bool isRetry = false; bool isRetry = false;