Files
KJD/Work/Business/CpsApiBLL.cs
T

48 lines
1.3 KiB
C#

using AllBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Work.Api;
namespace Work.Business
{
public class CpsApiBLL
{
public string Name = "";
public CpsApiBLL(string name = "")
{
Name = name;
}
public void GetCpsMall(List<ShopChatBase> shops)
{
foreach (var shop in shops)
{
Thread.Sleep(250 + Randomx.GetId(500));
GetCpsMallRate(shop);
}
}
public void GetCpsMallRate(ShopChatBase shop)
{
PinduoduoApiGetProduct api = new PinduoduoApiGetProduct(shop);
string html = api.GetCpsShopSet();
if (html.Contains("goods_cps_mall_unit_query_response"))
{
int rate = BaseRegex.GetIntJson(ref html, "rate");
int status = BaseRegex.GetIntJson(ref html, "status");
shop.CpsShop.Percent = (rate / 10m) + "%";
shop.CpsShop.Message = status == 1 ? "全店推广中" + shop.CpsShop.Percent : "未开启全店推广";
}
else
{
LogSave.Add(Name, "店铺" + shop.ShopName + "(" + shop.Name + ")" + "读取推广数据失败。");
}
}
}
}