| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- using dodohold.core;
- using Dataoke;
- using TencentCloud.Scf.V20180416.Models;
- using System.Text.RegularExpressions;
- using TencentCloud.Teo.V20220901.Models;
- using static dodohold.core.ZTOExpress.CreateOrderArgs;
- using System.Xml.Linq;
- namespace molilian.core
- {
- public class ParseUrlDTO
- {
- public string? skuId { get; set; }
- public string? itemUrl { get; set; }
- public string? hasCoupon { get; set; }
- public string? couponLink { get; set; }
- }
- public class GoodsDetailDTO
- {
- public decimal actualPrice { get; set; }
- public int cid1 { get; set; }
- public string cid1Name { get; set; }
- public int cid2 { get; set; }
- public string cid2Name { get; set; }
- public int cid3 { get; set; }
- public string cid3Name { get; set; }
- public int comments { get; set; }
- public decimal commission { get; set; }
- public string commissionEndTime { get; set; }
- public decimal commissionShare { get; set; }
- public string commissionStartTime { get; set; }
- public decimal couponAmount { get; set; }
- public string couponConditions { get; set; }
- public string couponEndTime { get; set; }
- public string couponLink { get; set; }
- public int couponReceiveCount { get; set; }
- public int couponRemainCount { get; set; }
- public string couponStartTime { get; set; }
- public int couponTotalCount { get; set; }
- public int couponType { get; set; }
- public string couponUseStartTime { get; set; }
- public string couponUserEndTime { get; set; }
- public string[] detailImages { get; set; }
- public string extensionContent { get; set; }
- public int goodsCommentShare { get; set; }
- public int inOrderCount30Days { get; set; }
- public int isFlagship { get; set; }
- public int isFreeFreightRisk { get; set; }
- public int isFreeShipping { get; set; }
- public int isOwner { get; set; }
- public int isSeckill { get; set; }
- public string itemId { get; set; }
- public int lowest { get; set; }
- public string materialUrl { get; set; }
- public decimal originPrice { get; set; }
- public string picMain { get; set; }
- public decimal plusCommissionShare { get; set; }
- public string productIntro { get; set; }
- public int shopId { get; set; }
- public string shopName { get; set; }
- public long skuId { get; set; }
- public string skuName { get; set; }
- public string[] smallImages { get; set; }
- }
- public partial class DataokePlus
- {
- string _app_key = string.Empty;
- string _app_secret = string.Empty;
- public DataokePlus(string app_key, string app_secret)
- {
- _app_key = app_key;
- _app_secret = app_secret;
- }
- public string JDParse(string unionId, string materialId, string couponUrl = null)
- {
- string version = "v1.0.0";
- string api = "https://openapi.dataoke.com/api/dels/jd/kit/promotion-union-convert";
- DtkApp app = new(_app_key, _app_secret);
- ApiParameters apiParameters = new();
- apiParameters.Add("unionId", unionId);
- apiParameters.Add("materialId", materialId);
- if (!string.IsNullOrEmpty(couponUrl)) apiParameters.Add("couponUrl", couponUrl);
- var log = new LoggerLibrary("dataoke", "promotion-union-convert").Info(unionId, materialId);
- string body = app.Get(api, version, apiParameters);
- log.Info(body).Save();
- //var root = body.Convert2JsonElement();
- return body;
- }
- public GoodsDetailDTO? GetDetails(params string[] skuIds)
- {
- GoodsDetailDTO? result = null;
- string body = string.Empty;
- try
- {
- string version = "v1.0.0";
- string api = "https://openapi.dataoke.com/api/dels/jd/goods/get-details";
- DtkApp app = new(_app_key, _app_secret);
- ApiParameters apiParameters = new();
- apiParameters.Add("skuIds", string.Join(',', skuIds));
- var log = new LoggerLibrary("dataoke", "details").Info(string.Join(',', skuIds));
- body = app.Get(api, version, apiParameters);
- log.Info(body).Save();
- var root = body.Convert2JsonElement();
- int code = root.Read<int>("code", -1);
- if (code == 0)
- {
- var _goods = root.ElementRead("data")[0].GetRawText();
- result = _goods.Convert2Object<GoodsDetailDTO>();
- }
- }
- catch (Exception ex)
- {
- new LoggerLibrary("dtk_error", "fail")
- .Info(string.Join(',', skuIds), body)
- .Info(ex.Message, ex.StackTrace)
- .Save();
- NotifyCore.Notify(new NifyMessage
- {
- message = $"【大淘客异常】\n\n{ex.Message}\n{ex.StackTrace}",
- priority = NifyMessagePriority.high,
- tags = ["red_circle"]
- });
- }
- return result;
- }
- public GoodsDetailDTO? GetGoods(string url)
- {
- ParseUrlDTO? sku_info = ParseUrl(url);
- if (sku_info == null) { return null; }
- GoodsDetailDTO? result = GetDetails(sku_info.skuId);
- return result;
- }
- public ParseUrlDTO? ParseUrl(string url)
- {
- ParseUrlDTO? result = null;
- try
- {
- string version = "v1.0.0";
- string api = "https://openapi.dataoke.com/api/dels/jd/kit/parseUrl";
- DtkApp app = new(_app_key, _app_secret);
- ApiParameters apiParameters = new();
- apiParameters.Add("url", url);
- var log = new LoggerLibrary("dataoke", "parseUrl").Info(url);
- string body = app.Get(api, version, apiParameters);
- log.Info(body).Save();
- var root = body.Convert2JsonElement();
- int code = root.Read<int>("code", -1);
- if (code == 0)
- {
- result = new ParseUrlDTO
- {
- skuId = root.PathRead("data.skuId", string.Empty),
- itemUrl = root.PathRead("data.itemUrl", string.Empty),
- hasCoupon = root.PathRead("data.hasCoupon", string.Empty),
- couponLink = root.PathRead("data.couponLink", string.Empty)
- };
- }
- }
- catch (Exception e) { }
- return result;
- }
- }
- }
|