16 changed files with 516 additions and 59 deletions
@ -1,21 +1,65 @@ |
|||||
using BBWY.Client.Helpers; |
using BBWY.Client.Helpers; |
||||
|
using Newtonsoft.Json.Linq; |
||||
using System; |
using System; |
||||
|
using System.Collections.Concurrent; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
|
||||
namespace BBWY.Client.ViewModels |
namespace BBWY.Client.ViewModels |
||||
{ |
{ |
||||
public partial class OrderListViewModel |
public partial class OrderListViewModel |
||||
{ |
{ |
||||
private PipeHelper pipeHelper; |
private PipeHelper pipeHelper; |
||||
|
private ConcurrentDictionary<string, string> dongdongBuyerDictionary; |
||||
|
|
||||
public void InitDongDong() |
public void InitDongDong() |
||||
{ |
{ |
||||
|
dongdongBuyerDictionary = new ConcurrentDictionary<string, string>(); |
||||
pipeHelper.ServerReceiveCallback = OnDongDongSendMessage; |
pipeHelper.ServerReceiveCallback = OnDongDongSendMessage; |
||||
pipeHelper.CreateServer("bbwyPipeServer"); |
pipeHelper.CreateServer("bbwyPipeServer"); |
||||
} |
} |
||||
|
|
||||
private void OnDongDongSendMessage(string msg) |
private void OnDongDongSendMessage(string msg) |
||||
{ |
{ |
||||
Console.WriteLine(msg); |
if (string.IsNullOrEmpty(msg)) |
||||
|
return; |
||||
|
try |
||||
|
{ |
||||
|
var j = JObject.Parse(msg); |
||||
|
var buyerAccount = j.Value<string>("user"); |
||||
|
var phone = j.Value<string>("phone"); |
||||
|
if (!string.IsNullOrEmpty(buyerAccount) && !string.IsNullOrEmpty(phone)) |
||||
|
{ |
||||
|
var key = $"{buyerAccount}_{phone}"; |
||||
|
if (!dongdongBuyerDictionary.TryAdd(key, phone)) |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var order = OrderList.FirstOrDefault(o => !string.IsNullOrEmpty(o.BuyerAccount) && o.BuyerAccount == buyerAccount); |
||||
|
if (order != null && order.Consignee != null && order.Consignee.IsDecode) |
||||
|
return; //已经解密过
|
||||
|
|
||||
|
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) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
@ -0,0 +1,19 @@ |
|||||
|
using Jd.Api; |
||||
|
using Jd.Api.Request; |
||||
|
using Newtonsoft.Json; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace BBWY.Test |
||||
|
{ |
||||
|
public class JDDongDongAPITest |
||||
|
{ |
||||
|
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)); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
using Jd.Api; |
||||
|
using Jd.Api.Request; |
||||
|
using Newtonsoft.Json; |
||||
|
using Newtonsoft.Json.Linq; |
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace BBWY.Test |
||||
|
{ |
||||
|
public class JDPromotionAPITest |
||||
|
{ |
||||
|
public void GetPromotionDetailById(IJdClient client, string token, long promotionId) |
||||
|
{ |
||||
|
{ |
||||
|
|
||||
|
var req = new SellerPromotionV2GetRequest(); |
||||
|
req.promoId = promotionId; |
||||
|
req.promoType = 4; |
||||
|
var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); |
||||
|
Console.WriteLine(JsonConvert.SerializeObject(response)); |
||||
|
|
||||
|
Console.WriteLine(); |
||||
|
} |
||||
|
{ |
||||
|
var pageIndex = 1; |
||||
|
while (true) |
||||
|
{ |
||||
|
var req = new SellerPromotionV2SkuListRequest(); |
||||
|
req.promoId = promotionId; |
||||
|
//req.bindType = ;
|
||||
|
|
||||
|
req.promoType = 4; |
||||
|
|
||||
|
req.page = pageIndex.ToString(); |
||||
|
|
||||
|
req.pageSSize = "100"; |
||||
|
var response = client.Execute(req, token, DateTime.Now.ToLocalTime()); |
||||
|
Console.WriteLine(JsonConvert.SerializeObject(response)); |
||||
|
if (response.IsError) |
||||
|
continue; |
||||
|
if (response.Json == null) |
||||
|
response.Json = JObject.Parse(response.Body); |
||||
|
var jarray = response.Json["jingdong_seller_promotion_v2_sku_list_responce"]["promotion_sku_list"] as JArray; |
||||
|
if (jarray.Count() >= 100) |
||||
|
pageIndex++; |
||||
|
else |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,241 @@ |
|||||
|
|
||||
|
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; |
||||
|
} |
Binary file not shown.
@ -0,0 +1,35 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Diagnostics; |
||||
|
using System.Linq; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using System.Windows; |
||||
|
using System.Xml.Linq; |
||||
|
|
||||
|
namespace QYDongDongTool.Unitls |
||||
|
{ |
||||
|
public class MP |
||||
|
{ |
||||
|
[DllImport("DllInLine.dll", EntryPoint = "Hook", CallingConvention = CallingConvention.Cdecl)] |
||||
|
public static extern int DllHook(int pid, string dLLPath); |
||||
|
|
||||
|
|
||||
|
[DllImport("DllInLine.dll", EntryPoint = "UnHook", CallingConvention = CallingConvention.Cdecl)] |
||||
|
public static extern int UnHookDll(int pid); |
||||
|
|
||||
|
|
||||
|
public static bool Hook(int pid) |
||||
|
{ |
||||
|
string sDllPath = System.Environment.CurrentDirectory+ "\\sendPhone.dll"; |
||||
|
return DllHook(pid, sDllPath) ==0; |
||||
|
} |
||||
|
|
||||
|
public static bool UnHook(int pid) |
||||
|
{ |
||||
|
int val= UnHookDll(pid); |
||||
|
return val==0; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>netcoreapp3.1</TargetFramework> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Update="DllInLine.dll"> |
||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
|
</None> |
||||
|
<None Update="sendPhone.dll"> |
||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
|
</None> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
@ -0,0 +1,61 @@ |
|||||
|
// See https://aka.ms/new-console-template for more information
|
||||
|
using QYDongDongTool; |
||||
|
using QYDongDongTool.Unitls; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Diagnostics; |
||||
|
using System.Linq; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
|
||||
|
public static void Main() |
||||
|
{ |
||||
|
|
||||
|
var list = GetAllDongdongUser(); |
||||
|
|
||||
|
Console.WriteLine(string.Join(",",list)); |
||||
|
|
||||
|
//var list = new CSharpAPIs().GetAllDesktopWindows();
|
||||
|
|
||||
|
//var windows = list.Where(c => c.szClassName == "DD_JM_Workbench_DLG").ToList();
|
||||
|
|
||||
|
//windows.ForEach(info =>
|
||||
|
//{
|
||||
|
|
||||
|
// foreach (ProcessModule module in Process.GetProcessById(info.ProcessId).Modules)
|
||||
|
// {
|
||||
|
// //检测是否已经注入
|
||||
|
// if (module.ModuleName.Contains("sendPhone.dll"))
|
||||
|
// {
|
||||
|
// return;
|
||||
|
// }
|
||||
|
// }
|
||||
|
|
||||
|
// //注入dll
|
||||
|
// MP.Hook((int)info.ProcessId);
|
||||
|
|
||||
|
//});
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取全部登录咚咚账号
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
public static List<string> GetAllDongdongUser() |
||||
|
{ |
||||
|
|
||||
|
List<string> dongdongList = new List<string>(); |
||||
|
var list = new CSharpAPIs().GetAllDesktopWindows(); |
||||
|
|
||||
|
var windows = list.Where(c => c.szClassName == "DD_JM_Workbench_DLG").ToList(); |
||||
|
|
||||
|
windows.ForEach(info => |
||||
|
{ |
||||
|
dongdongList.Add(info.szWindowName.Replace("的工作台", "")); |
||||
|
}); |
||||
|
|
||||
|
return dongdongList; |
||||
|
} |
||||
|
} |
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue