using AlibabaSDK.Api;
|
using AlibabaSDK.Request;
|
using CommonUtil;
|
using Operater.DAL;
|
using Operater.DbModel;
|
using Operater.Service.System;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace ProductDistribution
|
{
|
public class AliProductGet
|
{
|
public static void MainMethod()
|
{
|
try
|
{
|
string aliToken = "1c57c663-6657-41af-85e1-77dec6ec500b";
|
var proList = new DistributionRelationDAL().ListGet(t => t.ProSource == 1);
|
int index = 0;
|
foreach (var pro in proList)
|
{
|
index++;
|
Console.WriteLine($"{index}/{proList.Count}");
|
//获取1688商品详情
|
FenXiaoProductInfoGetRequest request = new FenXiaoProductInfoGetRequest()
|
{
|
offerId = long.Parse(pro.SourceProduct)
|
};
|
var response = AliabaClient.Execute(request, aliToken);
|
if (response.IsNull() || !response.Success)
|
{//获取商品详情失败
|
LogUtil.Info($"获取商品详情失败:{pro.SourceProduct}", "循环错误");
|
continue;
|
}
|
//判断是否包邮
|
bool isPost = new ItemDistributionService().IsPost(response.productInfo);
|
int isFreeShipping = isPost ? 1 : 0;
|
DistributionHistory distributionHistory = new DistributionHistory()
|
{
|
IsFreeShipping = isFreeShipping
|
};
|
new DistributionHistoryDAL().Update(distributionHistory, i => new { i.IsFreeShipping }, t => t.ProductId == pro.SourceProduct);
|
|
}
|
}
|
catch(Exception e)
|
{
|
|
}
|
|
Console.WriteLine("执行完成!");
|
}
|
}
|
}
|