Browse Source

继承启动器

qianyi
shanji 2 years ago
parent
commit
17243b7ba1
  1. 10
      BBWY.Client/APIServices/ShopService.cs
  2. 15
      BBWY.Client/App.xaml.cs
  3. 19
      BBWY.Client/BBWY.Client.csproj
  4. 6
      BBWY.Client/GlobalContext.cs
  5. 239
      BBWY.Client/Helpers/CSharpAPIs.cs
  6. 100
      BBWY.Client/Helpers/DongDongHelper.cs
  7. 80
      BBWY.Client/Helpers/PipeHelper.cs
  8. 36
      BBWY.Client/Helpers/ShellExecuteHelper.cs
  9. 59
      BBWY.Client/Helpers/WSHelper.cs
  10. 11
      BBWY.Client/Models/APIModel/Response/ServiceGroup/WaiterResponse.cs
  11. 26
      BBWY.Client/Properties/Settings.Designer.cs
  12. 6
      BBWY.Client/Properties/Settings.settings
  13. 19
      BBWY.Client/ViewModels/MainViewModel.cs
  14. 42
      BBWY.Client/ViewModels/Order/OrderListViewModel.cs
  15. 51
      BBWY.Client/ViewModels/Order/OrderListVoewModel_DongDong.cs
  16. 2
      BBWY.Client/Views/MainWindow.xaml.cs
  17. 18
      BBWY.Client/Views/Order/GrabJDMibole.xaml.cs
  18. 2
      BBWY.Client/Views/Order/OrderListControl.xaml
  19. 78
      BBWY.Client/app.manifest
  20. 11
      BBWY.Server.API/Controllers/VenderController.cs
  21. 18
      BBWY.Server.Business/PlatformSDK/JDBusiness.cs
  22. 5
      BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs
  23. 12
      BBWY.Server.Business/Vender/VenderBusiness.cs
  24. 11
      BBWY.Server.Model/Dto/Response/ServiceGroup/WaiterResponse.cs
  25. 24
      BBWY.Test/JDDongDongAPITest.cs
  26. 8
      InDll2/InDll2.csproj
  27. 34
      InDll2/Program.cs
  28. 78
      InDll2/app.manifest
  29. BIN
      InDll2/dllin.exe
  30. BIN
      InDll2/sendPhone.dll
  31. 11
      JD.API/Controllers/PlatformSDKController.cs

10
BBWY.Client/APIServices/ShopService.cs

@ -77,5 +77,15 @@ namespace BBWY.Client.APIServices
}, HttpMethod.Post);
}
public ApiResponse<IList<WaiterResponse>> GetServiceGroupList()
{
return SendRequest<IList<WaiterResponse>>(globalContext.BBYWApiHost, "api/vender/GetServiceGroupList", new
{
globalContext.User.Shop.Platform,
globalContext.User.Shop.AppKey,
globalContext.User.Shop.AppSecret,
globalContext.User.Shop.AppToken,
}, null, HttpMethod.Post);
}
}
}

15
BBWY.Client/App.xaml.cs

@ -11,6 +11,7 @@ using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Security.Principal;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
@ -25,8 +26,18 @@ namespace BBWY.Client
public IServiceProvider ServiceProvider { get; private set; }
public IConfiguration Configuration { get; private set; }
public bool IsAdministrator()
{
WindowsIdentity current = WindowsIdentity.GetCurrent();
WindowsPrincipal windowsPrincipal = new WindowsPrincipal(current);
return windowsPrincipal.IsInRole(WindowsBuiltInRole.Administrator);
}
protected override void OnStartup(StartupEventArgs e)
{
{
var isAdmin = IsAdministrator();
Console.WriteLine($"run as admin : {isAdmin}");
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
var gl = new GlobalContext();
string userToken = string.Empty;
@ -87,7 +98,7 @@ namespace BBWY.Client
{
AutomaticDecompression = System.Net.DecompressionMethods.GZip
});
serviceCollection.AddMemoryCache();
serviceCollection.AddSingleton<RestApiService>();
serviceCollection.AddSingleton(gl);

19
BBWY.Client/BBWY.Client.csproj

@ -1,10 +1,11 @@
 <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<ApplicationIcon>Resources\Images\bbwylogo.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
@ -28,6 +29,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fleck" Version="1.2.0" />
<PackageReference Include="HandyControl" Version="3.3.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="3.1.28" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
@ -55,4 +57,19 @@
</Resource>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

6
BBWY.Client/GlobalContext.cs

@ -7,9 +7,7 @@ namespace BBWY.Client
{
public GlobalContext()
{
DongDongServiceNameList = new List<string>();
ShopServiceGroupList = new List<string>();
}
private User user;
@ -20,7 +18,7 @@ namespace BBWY.Client
public IList<LogisticsResponse> LogisticsResponseList { get; set; }
public IList<string> DongDongServiceNameList { get; set; }
public IList<string> ShopServiceGroupList { get; set; }
/// <summary>
/// JD客户端

239
BBWY.Client/Helpers/CSharpAPIs.cs

@ -0,0 +1,239 @@

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace QYDongDongTool
{
public class CSharpAPIs
{
private delegate bool WNDENUMPROC(IntPtr hWnd, int lParam);
[DllImport("user32.dll")]
private static extern bool EnumWindows(WNDENUMPROC lpEnumFunc, int lParam);
//[DllImport("user32.dll")]
//private static extern IntPtr FindWindowW(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern int GetWindowTextW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
private static extern int GetClassNameW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpString, int nMaxCount);
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern int GetWindowThreadProcessId(IntPtr hwnd, out int ID);
[DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
public static extern int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("user32.dll")]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndlnsertAfter, int X, int Y, int cx, int cy, uint Flags);
[DllImport("user32.dll", EntryPoint = "SetParent")]
public static extern int SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int MoveWindow(IntPtr hWnd, int x, int y, int nWidth, int nHeight, bool BRePaint);
[DllImport("user32.dll")]
public static extern IntPtr GetTopWindow(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "GetWindow", SetLastError = true)]
public static extern IntPtr GetNextWindow(IntPtr hwnd, [MarshalAs(UnmanagedType.U4)] int wFlag);
[DllImport("user32.dll", EntryPoint = "GetDesktopWindow", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll", EntryPoint = "GetWindowLong")]
private static extern IntPtr GetWindowLongPtr32(IntPtr hWnd, int nIndex);
[DllImport("user32.dll", EntryPoint = "GetWindowLongPtr")]
private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex);
// This static method is required because Win32 does not support
// GetWindowLongPtr directly
public static IntPtr GetWindowLong(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 8)
return GetWindowLongPtr64(hWnd, nIndex);
else
return GetWindowLongPtr32(hWnd, nIndex);
}
public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
{
if (IntPtr.Size == 8)
return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
else
return new IntPtr(SetWindowLong32(hWnd, nIndex, dwNewLong.ToInt32()));
}
[DllImport("user32.dll", EntryPoint = "SetWindowLong")]
private static extern int SetWindowLong32(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", EntryPoint = "SetWindowLongPtr")]
private static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
//根据窗口来获取进程ID,
public static int GetCurrentProcessID(IntPtr handle)
{
GetWindowThreadProcessId(handle, out int oo);
return oo;
}
public struct WindowInfo
{
public IntPtr hWnd;
public string szWindowName;
public string szClassName;
public int ProcessId { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int Left; //最左坐标
public int Top; //最上坐标
public int Right; //最右坐标
public int Bottom; //最下坐标
}
public static (int width, int height, int x, int y) GetWindowSize(IntPtr hwnd)
{
RECT rc = new RECT();
GetWindowRect(hwnd, ref rc);
int width = rc.Right - rc.Left; //窗口的宽度
int height = rc.Bottom - rc.Top; //窗口的高度
int x = rc.Left;
int y = rc.Top;
return (width, height, x, y);
}
/*
SetWindowLong(ChildWindowHandle, GWL_EXSTYLE, (GetWindowLong(ChildWindowHandle, GWL_EXSTYLE) | WS_EX_NOPARENTNOTIFY));
*/
public enum GWL
{
GWL_WNDPROC = (-4),
GWL_HINSTANCE = (-6),
GWL_HWNDPARENT = (-8),
GWL_STYLE = (-16),
GWL_EXSTYLE = (-20),
GWL_USERDATA = (-21),
GWL_ID = (-12)
}
public static bool ReSetParent(IntPtr hWnd)
{
int row= SetParent(hWnd, GetDesktopWindow());
MoveWindow(hWnd, 0, 0, 0, 0, true);
return row > 0;
}
public static WindowInfo GetWindowInfo(IntPtr hWnd)
{
WindowInfo wnd = new WindowInfo();
StringBuilder sb = new StringBuilder(256);
//get hwnd
wnd.hWnd = hWnd;
//get window name
GetWindowTextW(hWnd, sb, sb.Capacity);
wnd.szWindowName = sb.ToString();
//get window class
GetClassNameW(hWnd, sb, sb.Capacity);
wnd.szClassName = sb.ToString();
wnd.ProcessId = GetCurrentProcessID(hWnd);
var size = GetWindowSize(hWnd);
wnd.Width = size.width;
wnd.Height = size.height;
wnd.X = size.x;
wnd.Y = size.y;
return wnd;
}
public List<WindowInfo> GetAllDesktopWindows()
{
List<WindowInfo> wndList = new List<WindowInfo>();
//enum all desktop windows
EnumWindows(delegate (IntPtr hWnd, int lParam)
{
WindowInfo wnd = new WindowInfo();
StringBuilder sb = new StringBuilder(256);
//get hwnd
wnd.hWnd = hWnd;
//get window name
GetWindowTextW(hWnd, sb, sb.Capacity);
wnd.szWindowName = sb.ToString();
//get window class
GetClassNameW(hWnd, sb, sb.Capacity);
wnd.szClassName = sb.ToString();
wnd.ProcessId = GetCurrentProcessID(hWnd);
var (width, height, x, y) = GetWindowSize(hWnd);
wnd.Width = width;
wnd.Height = height;
wnd.X = x;
wnd.Y = y;
//add it into list
wndList.Add(wnd);
return true;
}, 0);
return wndList;
}
//获取窗体位置 最小化 最大化 隐藏 api
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetWindowPlacement(IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl);
}
}
public struct WINDOWPLACEMENT
{
public int length;
public int flags;
public int showCmd;
public System.Drawing.Point ptMinPosition;
public System.Drawing.Point ptMaxPosition;
public System.Drawing.Rectangle rcNormalPosition;
}

100
BBWY.Client/Helpers/DongDongHelper.cs

@ -0,0 +1,100 @@
using BBWY.Common.Models;
using QYDongDongTool;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows;
namespace BBWY.Client.Helpers
{
public class DongDongHelper : IDenpendency
{
private CSharpAPIs csapi;
private System.Timers.Timer inJectionTimer;
public DongDongHelper()
{
csapi = new CSharpAPIs();
inJectionTimer = new System.Timers.Timer(10000);
inJectionTimer.Elapsed += InJectionTimer_Elapsed;
}
private void InJectionTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
InJection();
}
private void InJection()
{
try
{
ProcessStartInfo p = new ProcessStartInfo();
//p.UseShellExecute = true;
p.CreateNoWindow = true;
p.FileName= Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "InJectionDongDong", "dllin.exe");
p.Verb = "runas";
Process.Start(p);
}
catch (Exception ex)
{
Console.WriteLine($"InJection Error, {ex.Message}");
}
}
public void StartInJection()
{
if (!inJectionTimer.Enabled)
{
InJection();
inJectionTimer.Start();
}
}
/// <summary>
/// 获取全部登录咚咚账号
/// </summary>
/// <returns></returns>
public List<string> GetAllDongdongUser()
{
List<string> dongdongList = new List<string>();
var list = csapi.GetAllDesktopWindows();
var windows = list.Where(c => c.szClassName == "DD_JM_Workbench_DLG").ToList();
windows.ForEach(info =>
{
dongdongList.Add(info.szWindowName.Replace("的工作台", ""));
});
return dongdongList;
}
/// <summary>
/// 唤醒咚咚
/// </summary>
/// <param name="waiterName"></param>
/// <param name="buyerAccount"></param>
public void WakeUpDongDong(string waiterName, string buyerAccount)
{
var url = $"jdworkstation://jm/?command=openDD&pin={waiterName}&client={buyerAccount}";
try
{
try
{
//Process.Start("explorer.exe", url);
ShellExecuteHelper.ShellExecute(IntPtr.Zero, "open", url, string.Empty, string.Empty, ShellExecuteHelper.ShowCommands.SW_SHOWNORMAL);
}
catch (Exception ex)
{
Clipboard.SetText(url);
MessageBox.Show($"{ex.Message}\r\n唤醒咚咚失败,唤醒链接已复制到剪切板,请手动打开浏览器唤醒", "提示");
}
}
catch { throw; }
}
}
}

80
BBWY.Client/Helpers/PipeHelper.cs

@ -1,80 +0,0 @@
using BBWY.Common.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace BBWY.Client.Helpers
{
public class PipeHelper: IDenpendency
{
public PipeHelper()
{
_pipeServerDictionary = new Dictionary<string, NamedPipeServerStream>();
}
private IDictionary<string, NamedPipeServerStream> _pipeServerDictionary;
public Action<string> ServerReceiveCallback;
private async Task WaitForClientConnectionsAsync(NamedPipeServerStream pipeServer)
{
while (true)
{
await pipeServer.WaitForConnectionAsync().ConfigureAwait(false);
try
{
const int bufferLength = 1024;
var buffer = new byte[bufferLength];
using (var stream = new MemoryStream())
{
while (true)
{
var bytesRead = await pipeServer.ReadAsync(buffer.AsMemory(0, bufferLength), CancellationToken.None).ConfigureAwait(false);
if (bytesRead == 0)
{
break;
}
stream.Write(buffer, 0, bytesRead);
}
stream.Seek(0, SeekOrigin.Begin);
ServerReceiveCallback?.Invoke(Encoding.UTF8.GetString(stream.ToArray()));
}
}
finally
{
pipeServer.Disconnect();
}
}
}
public void CreateServer(string pipeName)
{
var _pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.InOut, 100, PipeTransmissionMode.Byte, PipeOptions.Asynchronous | PipeOptions.CurrentUserOnly);
_ = WaitForClientConnectionsAsync(_pipeServer);
}
public void CloseServer(string pipeName)
{
if (_pipeServerDictionary.TryGetValue(pipeName, out NamedPipeServerStream pipeServer))
{
try
{
pipeServer.Disconnect();
pipeServer.Dispose();
pipeServer.Close();
_pipeServerDictionary.Remove(pipeName);
}
catch (Exception ex)
{
}
}
}
}
}

36
BBWY.Client/Helpers/ShellExecuteHelper.cs

@ -0,0 +1,36 @@
using System;
using System.Runtime.InteropServices;
namespace BBWY.Client.Helpers
{
public class ShellExecuteHelper
{
public enum ShowCommands : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}
[DllImport("shell32.dll")]
public static extern IntPtr ShellExecute(
IntPtr hwnd,
string lpOperation,
string lpFile,
string lpParameters,
string lpDirectory,
ShowCommands nShowCmd);
}
}

59
BBWY.Client/Helpers/WSHelper.cs

@ -0,0 +1,59 @@
using BBWY.Common.Models;
using Fleck;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace BBWY.Client.Helpers
{
public class WSHelper : IDenpendency
{
//private List<IWebSocketConnection> connectSocketPool = new List<IWebSocketConnection>();
private WebSocketServer wsServer;
public WSHelper()
{
wsServer = new WebSocketServer("ws://127.0.0.1:35192");
}
public Action<string> ServerReceiveCallback;
public void Start()
{
//开启监听
wsServer.Start(socket =>
{
//注册客户端连接建立事件
socket.OnOpen = () =>
{
Console.WriteLine("建立连接");
//将当前客户端连接对象放入连接池中
//connectSocketPool.Add(socket);
};
//注册客户端连接关闭事件
socket.OnClose = () =>
{
//Console.WriteLine("Close");
//将当前客户端连接对象从连接池中移除
//connectSocketPool.Remove(socket);
};
//注册客户端发送信息事件
socket.OnMessage = message =>
{
Console.WriteLine($"收到webSocket消息:{message}");
socket.Close();
////向客户端发送消息
//socket.Send($"服务端接收到信息:{message}");
ServerReceiveCallback?.Invoke(message);
};
});
}
}
}

11
BBWY.Client/Models/APIModel/Response/ServiceGroup/WaiterResponse.cs

@ -0,0 +1,11 @@
namespace BBWY.Client.Models
{
public class WaiterResponse
{
public string Id { get; set; }
public string Name { get; set; }
public string Level { get; set; }
}
}

26
BBWY.Client/Properties/Settings.Designer.cs

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace BBWY.Client.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.0.3.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

6
BBWY.Client/Properties/Settings.settings

@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>

19
BBWY.Client/ViewModels/MainViewModel.cs

@ -1,4 +1,5 @@
using BBWY.Client.APIServices;
using BBWY.Client.Helpers;
using BBWY.Client.Models;
using BBWY.Client.Views;
using BBWY.Common.Extensions;
@ -85,7 +86,8 @@ namespace BBWY.Client.ViewModels
LogisticsService logisticsService,
ShopService shopService,
IHttpClientFactory httpClientFactory,
WebView2Manager w2m)
WebView2Manager w2m,
DongDongHelper dongdongHelper)
{
this.w2m = w2m;
this.managerDepartment = new List<string>() { "董事办", "财务部", "技术部", "总经办" };
@ -109,8 +111,10 @@ namespace BBWY.Client.ViewModels
//下载webview2 runtime
Task.Factory.StartNew(DownloadWebview2Runtime);
}
dongdongHelper.StartInJection();
}
private void CreateMenu()
{
if (GlobalContext.User.TeamName == "刷单组")
@ -409,7 +413,18 @@ namespace BBWY.Client.ViewModels
private void GetJDServiceGroup()
{
var apiResponse = shopService.GetServiceGroupList();
if (!apiResponse.Success)
{
MessageBox.Show(apiResponse.Msg, "获取客服组");
Environment.Exit(Environment.ExitCode);
}
GlobalContext.ShopServiceGroupList.Clear();
if (apiResponse.Data != null && apiResponse.Data.Count() > 0)
{
foreach (var waiter in apiResponse.Data)
GlobalContext.ShopServiceGroupList.Add(waiter.Name);
}
}
#endregion
}

42
BBWY.Client/ViewModels/Order/OrderListViewModel.cs

@ -26,7 +26,7 @@ namespace BBWY.Client.ViewModels
private StatisticsService statisticsService;
private AfterOrderService afterOrderService;
private ChoosePurchaseSchemeViewModel choosePurchaseSchemeViewModel;
private DongDongHelper dongdongHelper;
private bool isLoading;
private string searchOrderId;
@ -160,7 +160,7 @@ namespace BBWY.Client.ViewModels
/// </summary>
public bool IsSDGroup { get => isSDGroup; set { Set(ref isSDGroup, value); } }
public OrderListViewModel(OrderService orderService, StatisticsService statisticsService, AfterOrderService afterOrderService, GlobalContext globalContext, ChoosePurchaseSchemeViewModel choosePurchaseSchemeViewModel, PipeHelper pipeHelper)
public OrderListViewModel(OrderService orderService, StatisticsService statisticsService, AfterOrderService afterOrderService, GlobalContext globalContext, ChoosePurchaseSchemeViewModel choosePurchaseSchemeViewModel, WSHelper pipeHelper, DongDongHelper dongdongHelper)
{
IsSDGroup = globalContext.User.TeamName == "刷单组";
if (IsSDGroup)
@ -174,7 +174,8 @@ namespace BBWY.Client.ViewModels
}
random = new Random();
this.pipeHelper = pipeHelper;
this.wsHelper = pipeHelper;
this.dongdongHelper = dongdongHelper;
this.globalContext = globalContext;
this.orderService = orderService;
this.statisticsService = statisticsService;
@ -533,19 +534,38 @@ namespace BBWY.Client.ViewModels
private void GetBuyerAccount(Order order)
{
var buyerAccount = string.Empty;
var grab = new GrabJDMibole(order.Id);
if (grab.ShowDialog() == true)
buyerAccount = grab.Tag.ToString();
if (string.IsNullOrEmpty(buyerAccount))
if (string.IsNullOrEmpty(order.BuyerAccount))
{
var buyerAccount = string.Empty;
var grab = new GrabJDMibole(order.Id);
if (grab.ShowDialog() == true)
buyerAccount = grab.Tag.ToString();
if (string.IsNullOrEmpty(buyerAccount))
{
MessageBox.Show("未获取到买家账号", "提示");
return;
}
order.BuyerAccount = buyerAccount;
}
//获取本机咚咚客服列表
var currentMachineServiceGroupList = dongdongHelper.GetAllDongdongUser();
if (currentMachineServiceGroupList == null || currentMachineServiceGroupList.Count() == 0)
{
MessageBox.Show("未获取到买家账号", "提示");
MessageBox.Show("未获取到本机咚咚客服账号列表", "提示");
return;
}
order.BuyerAccount = buyerAccount;
//唤醒咚咚
//匹配客服账号
var waiter = currentMachineServiceGroupList.Intersect(globalContext.ShopServiceGroupList)?.FirstOrDefault();
if (string.IsNullOrEmpty(waiter))
{
MessageBox.Show("未匹配到当前店铺客服组和本机咚咚客服账号的交集", "提示");
return;
}
//唤醒咚咚
dongdongHelper.WakeUpDongDong(waiter, order.BuyerAccount);
}
private void ChooseStorageType(object param)

51
BBWY.Client/ViewModels/Order/OrderListVoewModel_DongDong.cs

@ -1,4 +1,5 @@
using BBWY.Client.Helpers;
using GalaSoft.MvvmLight.Messaging;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Concurrent;
@ -10,18 +11,19 @@ namespace BBWY.Client.ViewModels
{
public partial class OrderListViewModel
{
private PipeHelper pipeHelper;
private WSHelper wsHelper;
private ConcurrentDictionary<string, string> dongdongBuyerDictionary;
public void InitDongDong()
{
dongdongBuyerDictionary = new ConcurrentDictionary<string, string>();
pipeHelper.ServerReceiveCallback = OnDongDongSendMessage;
pipeHelper.CreateServer("bbwyPipeServer");
wsHelper.ServerReceiveCallback = OnDongDongSendMessage;
wsHelper.Start();
}
private void OnDongDongSendMessage(string msg)
{
Console.WriteLine($"OnDongDongSendMessage 接收到消息 {msg}");
if (string.IsNullOrEmpty(msg))
return;
try
@ -37,23 +39,40 @@ namespace BBWY.Client.ViewModels
}
var order = OrderList.FirstOrDefault(o => !string.IsNullOrEmpty(o.BuyerAccount) && o.BuyerAccount == buyerAccount);
if (order != null && order.Consignee != null && order.Consignee.IsDecode)
if (order == null || order.Consignee == null || order.Consignee.IsDecode)
return; //已经解密过
Task.Factory.StartNew(() => orderService.DecodeConsignee(order.Id, phone)).ContinueWith(t =>
var response = orderService.DecodeConsignee(order.Id, phone);
if (!response.Success)
{
var response = t.Result;
IsLoading = false;
if (!response.Success)
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "解密失败"));
return;
}
order.Consignee.ContactName = response.Data.ContactName;
order.Consignee.Address = response.Data.Address;
order.Consignee.Mobile = response.Data.Mobile;
order.Consignee.IsDecode = true;
App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "解密失败"));
return;
}
order.Consignee.ContactName = response.Data.ContactName;
order.Consignee.Address = response.Data.Address;
order.Consignee.Mobile = response.Data.Mobile;
order.Consignee.IsDecode = true;
App.Current.Dispatcher.BeginInvoke((Action)delegate
{
Messenger.Default.Send(string.Empty, "ActiveMainWindow");
});
;
//Task.Factory.StartNew(() => orderService.DecodeConsignee(order.Id, phone)).ContinueWith(t =>
//{
// var response = t.Result;
// IsLoading = false;
// if (!response.Success)
// {
// App.Current.Dispatcher.Invoke(() => MessageBox.Show(response.Msg, "解密失败"));
// return;
// }
// order.Consignee.ContactName = response.Data.ContactName;
// order.Consignee.Address = response.Data.Address;
// order.Consignee.Mobile = response.Data.Mobile;
// order.Consignee.IsDecode = true;
//});
}
catch (Exception ex)

2
BBWY.Client/Views/MainWindow.xaml.cs

@ -18,7 +18,7 @@ namespace BBWY.Client.Views
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<string>(this, "ActiveMainWindow", (x) => this.Activate());
}
private void frame_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)

18
BBWY.Client/Views/Order/GrabJDMibole.xaml.cs

@ -65,22 +65,24 @@ namespace BBWY.Client.Views.Order
}
else if (w2m.wb2.CoreWebView2.Source.StartsWith("https://neworder.shop.jd.com/order/orderDetail"))
{
Console.WriteLine($"{orderId}触发手机号查看");
//Console.WriteLine($"{orderId}触发手机号查看");
//进入订单详情页面,触发点击查看手机号
txtMsg.Text = "Grabbing Mobile";
txtMsg.Text = "Grabbing BuyerAccount";
//w2m.wb2.Width = 0.1;
//w2m.wb2.Height = 0.1;
var js = @"var mobileNode = document.getElementById('mobile');
mobileNode.addEventListener('DOMNodeInserted',function(e){ var m=mobileNode.innerText; window.chrome.webview.postMessage(m);});
document.getElementById('viewOrderMobile').click();";
//var js = @"var mobileNode = document.getElementById('mobile');
// mobileNode.addEventListener('DOMNodeInserted',function(e){ var m=mobileNode.innerText; window.chrome.webview.postMessage(m);});
// document.getElementById('viewOrderMobile').click();";
var js = "var d = document.getElementsByName('dongdongICON')[0]; window.chrome.webview.postMessage(d.innerText);";
_ = await w2m.wb2.CoreWebView2.ExecuteScriptAsync(js);
}
};
w2m.OnWebMessageReceived = (e) =>
{
var mobole = e.TryGetWebMessageAsString();
Console.WriteLine($"{orderId}接收手机号{mobole}");
this.Tag = mobole;
var buyerAccount = e.TryGetWebMessageAsString().Trim();
Console.WriteLine($"{orderId}接收买家账号{buyerAccount}");
this.Tag = buyerAccount;
this.DialogResult = true;
this.Close();
};

2
BBWY.Client/Views/Order/OrderListControl.xaml

@ -88,7 +88,7 @@
<c:BButton x:Name="btn_orderState" Content="{Binding OrderState}" Margin="5,0,0,0" Height="25" Padding="5,0" Background="{StaticResource Text.Link.Color}"/>
<Border Width="1" Margin="5,5,0,5" Background="{StaticResource Border.Brush}"/>
<c:BButton x:Name="btn_decodeCommand" Content="解密收货信息" Style="{StaticResource LinkButton}" Margin="5,0,0,0"
Command="{Binding DataContext.DecodeConsigneeCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
Command="{Binding DataContext.GetBuyerAccountCommand,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type ListBox}}}"
CommandParameter="{Binding }"/>
<StackPanel x:Name="txt_consignee" Margin="5,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="收货人:"/>

78
BBWY.Client/app.manifest

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

11
BBWY.Server.API/Controllers/VenderController.cs

@ -99,5 +99,16 @@ namespace BBWY.Server.API.Controllers
{
return venderBusiness.GetShopListByShopIds(request);
}
/// <summary>
/// 获取店铺客服组
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<WaiterResponse> GetServiceGroupList([FromBody]PlatformRequest request)
{
return venderBusiness.GetServiceGroupList(request);
}
}
}

18
BBWY.Server.Business/PlatformSDK/JDBusiness.cs

@ -1187,5 +1187,23 @@ namespace BBWY.Server.Business
if (res.IsError)
throw new BusinessException($"暂停JD活动失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
}
public override IList<WaiterResponse> GetServiceGroupList(PlatformRequest request)
{
var jdClient = GetJdClient(request.AppKey, request.AppSecret);
var req = new ImPopGroupinfoGetRequest();
var res = jdClient.Execute(req, request.AppToken, DateTime.Now.ToLocalTime());
if (res.IsError)
throw new BusinessException($"查询客服组失败-{(string.IsNullOrEmpty(res.ErrorMsg) ? res.ErrMsg : res.ErrorMsg)}");
if (res.Json == null)
res.Json = JsonConvert.DeserializeObject<JObject>(res.Body);
return res.Json["jingdong_im_pop_groupinfo_get_responce"]["popgroup"]["waiterList"].Select(j => new WaiterResponse()
{
Id = "",
Level = j.Value<string>("level"),
Name = j.Value<string>("waiter")
}).ToList();
}
}
}

5
BBWY.Server.Business/PlatformSDK/PlatformSDKBusiness.cs

@ -177,5 +177,10 @@ namespace BBWY.Server.Business
{
throw new NotImplementedException();
}
public virtual IList<WaiterResponse> GetServiceGroupList(PlatformRequest request)
{
throw new NotImplementedException();
}
}
}

12
BBWY.Server.Business/Vender/VenderBusiness.cs

@ -309,5 +309,17 @@ namespace BBWY.Server.Business
{
return freeSqlMultiDBManager.MDSfsql.Select<Shops>().Where(s => s.ShopId == shopId).ToOne<ShopResponse>();
}
public IList<WaiterResponse> GetServiceGroupList(PlatformRequest request)
{
var relayAPIHost = GetPlatformRelayAPIHost(request.Platform);
var sendResult = restApiService.SendRequest(relayAPIHost, "api/PlatformSDK/GetServiceGroupList", request, GetYunDingRequestHeader(), HttpMethod.Post);
if (sendResult.StatusCode != System.Net.HttpStatusCode.OK)
throw new BusinessException(sendResult.Content) { Code = (int)sendResult.StatusCode };
var response = JsonConvert.DeserializeObject<ApiResponse<IList<WaiterResponse>>>(sendResult.Content);
if (!response.Success)
throw new BusinessException(response.Msg) { Code = response.Code };
return response.Data;
}
}
}

11
BBWY.Server.Model/Dto/Response/ServiceGroup/WaiterResponse.cs

@ -0,0 +1,11 @@
namespace BBWY.Server.Model.Dto
{
public class WaiterResponse
{
public string Id { get; set; }
public string Name { get; set; }
public string Level { get; set; }
}
}

24
BBWY.Test/JDDongDongAPITest.cs

@ -1,8 +1,11 @@
using Jd.Api;
using BBWY.Server.Model.Dto;
using Jd.Api;
using Jd.Api.Request;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BBWY.Test
@ -11,9 +14,24 @@ namespace BBWY.Test
{
public void GetServiceGroup(IJdClient client, string token)
{
//var req = new ImPopGroupinfoGetRequest();
//var response = client.Execute(req, token, DateTime.Now.ToLocalTime());
//Console.WriteLine(JsonConvert.SerializeObject(response));
var req = new ImPopGroupinfoGetRequest();
var response = client.Execute(req, token, DateTime.Now.ToLocalTime());
Console.WriteLine(JsonConvert.SerializeObject(response));
var res = client.Execute(req, token, DateTime.Now.ToLocalTime());
if (res.Json == null)
res.Json = JsonConvert.DeserializeObject<JObject>(res.Body);
var list = res.Json["jingdong_im_pop_groupinfo_get_responce"]["popgroup"]["waiterList"].Select(j => new WaiterResponse()
{
Id = "",
Level = j.Value<string>("level"),
Name = j.Value<string>("waiter")
}).ToList();
Console.WriteLine(JsonConvert.SerializeObject(list));
}
}
}

8
InDll2/InDll2.csproj

@ -3,9 +3,17 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<None Update="app.manifest">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</None>
<None Update="dllin.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="DllInLine.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>

34
InDll2/Program.cs

@ -12,30 +12,30 @@ public class Program
public static void Main()
{
var list = GetAllDongdongUser();
//var list = GetAllDongdongUser();
Console.WriteLine(string.Join(",",list));
//Console.WriteLine(string.Join(",",list));
//var list = new CSharpAPIs().GetAllDesktopWindows();
var list = new CSharpAPIs().GetAllDesktopWindows();
//var windows = list.Where(c => c.szClassName == "DD_JM_Workbench_DLG").ToList();
var windows = list.Where(c => c.szClassName == "DD_JM_Workbench_DLG").ToList();
//windows.ForEach(info =>
//{
windows.ForEach(info =>
{
// foreach (ProcessModule module in Process.GetProcessById(info.ProcessId).Modules)
// {
// //检测是否已经注入
// if (module.ModuleName.Contains("sendPhone.dll"))
// {
// return;
// }
// }
foreach (ProcessModule module in Process.GetProcessById(info.ProcessId).Modules)
{
//检测是否已经注入
if (module.ModuleName.Contains("sendPhone.dll"))
{
return;
}
}
// //注入dll
// MP.Hook((int)info.ProcessId);
//注入dll
MP.Hook((int)info.ProcessId);
//});
});
}

78
InDll2/app.manifest

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

BIN
InDll2/dllin.exe

Binary file not shown.

BIN
InDll2/sendPhone.dll

Binary file not shown.

11
JD.API/Controllers/PlatformSDKController.cs

@ -317,5 +317,16 @@ namespace JD.API.API.Controllers
{
platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).SuspendJDPromotionTask(request);
}
/// <summary>
/// 查询店铺客服组
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
public IList<WaiterResponse> GetServiceGroupList([FromBody] PlatformRequest request)
{
return platformSDKBusinessList.FirstOrDefault(p => p.Platform == request.Platform).GetServiceGroupList(request);
}
}
}

Loading…
Cancel
Save