| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- using dodohold.core;
- namespace molilian.core
- {
- public partial class VeapiPlus
- {
- private string _accountName;
- private string _key;
- private string _sessionKey;
- public VeapiPlus(string accountName, string key, string sessionKey)
- {
- _accountName = accountName;
- _key = key;
- _sessionKey = sessionKey;
- }
- public TkDataDTO UnionParse(string content, ref TkDataDTO result)
- {
- string para = content.UrlEncode();
- string url = $"http://api.veapi.cn/tbk/hcapi?vekey={_key}&sessionkey={_sessionKey}¶={para}";
- var response = new WebClientUtility().Request(url);
- var body = response.Body();
- var root = body.Convert2JsonElement();
- int error = root.Read<int>("error", 0);
- bool success = error == 0;
- string message = root.Read("msg", string.Empty);
- string taoToken = root.PathRead("data.ios_tbk_pwd", string.Empty);
- string num_iid = root.PathRead("data.num_iid", string.Empty);
- decimal couponAmount = root.PathRead<decimal>("data.coupon_amount", 0);
- string shortLinkurl = root.PathRead("data.coupon_short_url", string.Empty);
- string shortLink = AlimamaPlus.GetLink(taoToken);
- content = AlimamaPlus.ReplaceUrls(content, shortLink);
- if (!success)
- {
- shortLinkurl = AlimamaPlus.GetLink(content);
- }
- string deeplink_url = AlimamaPlus.GetDeeplink(shortLinkurl);
- result.channel = TkChannelEnum.tb;
- result.accountName = _accountName;
- result.success = success;
- result.message = message;
- result.content = content;
- result.couponAmount = couponAmount;
- result.taoToken = taoToken;
- result.shortLinkurl = shortLinkurl;
- result.deeplink_url = deeplink_url;
- result.num_iid = num_iid;
- return result;
- }
- public PromotionQueryDTO picSimilaritem(string pic, ref PromotionQueryDTO result)
- {
- string url = $"http://api.veapi.cn/tbk/picsimilaritem";
- string base64 = $"data:image/jpeg;base64,{pic}";
- var client = new WebClientUtility();
- client.SetContentType("application/x-www-form-urlencoded");
- client.Post("vekey", _key);
- client.Post("pic", base64);
- var response = client.Request(url);
- var body = response.Body();
- var root = body.Convert2JsonElement();
- int error = root.Read<int>("error", 0);
- bool success = error == 0;
- string message = root.Read("msg", string.Empty);
- result.success = success;
- if (!success)
- {
- result.message = "调用失败";
- result.reason = message;
- return result;
- }
- List<PromotionQueryItemDTO> arr = [];
- var list = root.ElementRead("data");
- foreach (var e in list.EnumerateArray())
- {
- var item = e.ElementRead("Result");
- string itemId = item.Read<string>("ItemId", string.Empty);
- string h5_url = $"https://uland.taobao.com/item/edetail?id={itemId}";
- string deeplink_url = AlimamaPlus.GetDeeplink(h5_url);
- PromotionQueryItemDTO newItem = new PromotionQueryItemDTO();
- newItem.itemId = itemId;
- newItem.h5_url = h5_url;
- newItem.deeplink_url = deeplink_url;
- newItem.userType = item.Read<string>("UserType", string.Empty);
- newItem.shopTitle = item.Read<string>("ShopTitle", string.Empty);
- newItem.itemName = item.Read<string>("Title", string.Empty);
- newItem.pic = item.Read<string>("PicUrl", string.Empty);
- newItem.price = item.Read<string>("ReservePrice", string.Empty);
- newItem.promotionPrice = item.Read<string>("PriceAfterCoupon", string.Empty);
- newItem.couponAmount = item.Read<string>("CouponAmount", string.Empty);
- newItem.couponEffectiveStartTime = item.Read<string>("CouponStartTime", string.Empty);
- newItem.couponEffectiveEndTime = item.Read<string>("CouponEndTime", string.Empty);
- newItem.sellCountStr = item.Read<string>("sellCountStr", string.Empty);
- newItem.provcity = item.Read<string>("Provcity", string.Empty);
- arr.Add(newItem);
- }
- result.message = "OK";
- result.reason = string.Empty;
- result.PromotionImg = arr;
- //PromotionImg
- /*
- *
- public string h5_url { get; set; } = string.Empty;
- public string deeplink_url { get; set; } = string.Empty;
- /// <summary>
- /// 店铺信息-卖家类型:1天猫,0淘宝,3淘特
- /// </summary>
- public string userType { get; set; } = string.Empty;
- public string shopTitle { get; set; } = string.Empty;
- public string itemId { get; set; } = string.Empty;
- public string itemName { get; set; } = string.Empty;
- public string pic { get; set; } = string.Empty;
- public string price { get; set; } = string.Empty;
- public string promotionPrice { get; set; } = string.Empty;
- public string couponAmount { get; set; } = string.Empty;
- public string couponEffectiveStartTime { get; set; } = string.Empty;
- public string couponEffectiveEndTime { get; set; } = string.Empty;
- public string sellCountStr { get; set; } = string.Empty;
- public string provcity { get; set; } = string.Empty;
- {
- "error": "0",
- "msg": "查询成功",
- "data": [
- {
- "RankScore": "0.8065",
- "Result": {
- "CategoryName": "跑步鞋",
- "CommissionRate": "135",
- "CouponAmount": 50,
- "CouponEndTime": "2025-01-31",
- "CouponInfo": "满99.0元减50.0元",
- "CouponRemainCount": 99656,
- "CouponStartFee": "99.0",
- "CouponStartTime": "2024-12-24",
- "CouponTotalCount": "100000",
- "ItemId": "jOZk7gxcAfJZ6zGz8bFKjwSJte-Z9Z023UAg5djJmJSRp",
- "LevelOneCategoryName": "运动鞋new",
- "MaxCommission": {},
- "Nick": "",
- "PicUrl": "https://img.alicdn.com/i2/1994113638/O1CN015M0Aqf1ckFs5UI2eJ_!!0-item_pic.jpg",
- "PriceAfterCoupon": "109.00",
- "Provcity": "福建 泉州",
- "ReservePrice": "259.00",
- "SellerId": "1994113638",
- "ShopTitle": "361度户外旗舰店",
- "ShortTitle": "加绒保暖老爹鞋361女鞋运动鞋女",
- "SubTitle": "新款加绒女鞋运动鞋",
- "Title": "361女鞋运动鞋女2024冬季新款加绒保暖棉鞋轻便老爹鞋休闲跑步鞋",
- "UserType": 1,
- "Volume": 10,
- "ZkFinalPrice": "159"
- }
- }
- ]
- ],
- "request_id": "4eZfpBu"
- }
- */
- return result;
- }
- public async Task<TkDataDTO> UnionParseAsync(string content, TkDataDTO result, CancellationToken cancellationToken)
- {
- string para = content.UrlEncode();
- string url = $"http://api.veapi.cn/tbk/hcapi?vekey={_key}&sessionkey={_sessionKey}¶={para}";
- var response = await new WebClientUtility().RequestAsync(url, "GET", cancellationToken);
- var body = response.Body();
- var root = body.Convert2JsonElement();
- int error = root.Read<int>("error", 0);
- bool success = error == 0;
- string message = root.Read("msg", string.Empty);
- string taoToken = root.PathRead("data.ios_tbk_pwd", string.Empty);
- string num_iid = root.PathRead("data.num_iid", string.Empty);
- decimal couponAmount = root.PathRead<decimal>("data.coupon_amount", 0);
- string shortLinkurl = root.PathRead("data.coupon_short_url", string.Empty);
- string shortLink = AlimamaPlus.GetLink(taoToken);
- content = AlimamaPlus.ReplaceUrls(content, shortLink);
- if (!success)
- {
- shortLinkurl = AlimamaPlus.GetLink(content);
- }
- string deeplink_url = AlimamaPlus.GetDeeplink(shortLinkurl);
- result.channel = TkChannelEnum.tb;
- result.accountName = _accountName;
- result.success = success;
- result.message = message;
- result.content = content;
- result.couponAmount = couponAmount;
- result.taoToken = taoToken;
- result.shortLinkurl = shortLinkurl;
- result.deeplink_url = deeplink_url;
- result.num_iid = num_iid;
- return result;
- }
- }
- }
|