Skip to content

Commit

Permalink
支持自动下单(购物车已选)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerwin committed Apr 17, 2022
1 parent bcc3afc commit aca12ab
Show file tree
Hide file tree
Showing 8 changed files with 1,505 additions and 79 deletions.
4 changes: 2 additions & 2 deletions DingDong.Core/DingDong/DingDongCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void CheckOrder(New_Order_Product_List2 cart)
bodys.Add("showData", "true");
var result = RequestPost(url, GetCommonParams(bodys));
var obj = JObject.Parse(result);
if (obj["success"].ToString() != "true")
if (obj["success"].ToString().ToLower() != "true")
{
_log?.Invoke($"检查订单失败. {obj["msg"]}");
throw new DingDongException(obj["msg"].ToString());
Expand Down Expand Up @@ -142,7 +142,7 @@ public void CreateNewOrder(CartData data, (long startTime, long endTime) reserve
var result = RequestPost(url, GetCommonParams(bodys));
// {"success":true,"code":0,"msg":"success","data":{"pay_url":"{\"timeStamp\":\"1650182341\",\"package\":\"prepay_id=wx17155901110395404e2ec64b5eccda0000\",\"appId\":\"wx1e113254eda17715\",\"sign\":\"082F7C89FE3FBFB545D9E82EB3712FBF\",\"signType\":\"MD5\",\"nonceStr\":\"70MAHai08O9KqLbll7RVMTAovjgGsj03\"}","pay_online":true,"order_number":"2204171874886872238","cart_count":28,"station_id":"5c8879d1716de1f6468b456d","event_tracking":{"post_product_algo":"{}"}},"tradeTag":"success","server_time":1650182341,"is_trade":1}
var obj = JObject.Parse(result);
if (obj["success"].ToString() != "true")
if (obj["success"].ToString().ToLower() != "true")
{
_log?.Invoke($"创建订单失败. {obj["msg"]}");
throw new DingDongException("");
Expand Down
23 changes: 21 additions & 2 deletions DingDong.Core/Models/DingDongUtils.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text;
using RestSharp;
using System.Text;
using System.Web;

namespace DingDong.Monitor.Models
Expand Down Expand Up @@ -70,6 +71,24 @@ public static string ToBody(this Dictionary<string, string?> body)

public static long NowTimeStamp => new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();


/// <summary>
///
/// </summary>
/// <param name="url"></param>
/// <param name="message"></param>
public static void Push(string url, string message)
{
if (string.IsNullOrWhiteSpace(url))
{
return;
}
var groupName = HttpUtility.UrlEncode("叮咚助手");
var msg = HttpUtility.UrlEncode(message);
var client = new RestClient($"{url.TrimEnd('/')}/{groupName}/{msg}?group={groupName}");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
}
}
}
6 changes: 6 additions & 0 deletions DingDong.Monitor/DingDong.Monitor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
<Folder Include="Properties\DataSources\" />
</ItemGroup>

<ItemGroup>
<None Update="Music\order.wav">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
52 changes: 43 additions & 9 deletions DingDong.Monitor/MainFrm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit aca12ab

Please sign in to comment.