using AlibabaSDK.Api;
|
using AlibabaSDK.Request;
|
using Operater.DAL;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using YouZanSDKStandard.Api.Request;
|
using CommonUtil;
|
using YouZanSDKStandard.Api.Domain;
|
using Operater.Service.System;
|
using YouZanSDKStandard.Api;
|
using Operater.DbModel;
|
|
namespace ProductDistribution
|
{
|
public class ProductGetDetailHandle
|
{
|
public static void MainMethod()
|
{
|
try
|
{
|
var appSet = (new AppsetDAL().ListGet(t => t.Id != null))[0];
|
DateTime crea = Convert.ToDateTime("2023-03-28 00:00:00");
|
var proList = new DistributionRelationDAL().ListGet(t =>t.CreateTime>= crea);
|
int index = 0;
|
foreach (var pro in proList)
|
{
|
index++;
|
Console.WriteLine($"{index}/{proList.Count}");
|
try
|
{
|
////获取有赞商品详情
|
YouZanProductDetailGetRequest detailReq = new YouZanProductDetailGetRequest()
|
{
|
item_id = long.Parse(pro.YzProduct)
|
};
|
var detailRs = YouZanClient.Execute(detailReq, appSet.YzToken);
|
if (detailRs.IsNull() || !detailRs.success)
|
{
|
Console.WriteLine("获取有赞商品详情失败");
|
LogUtil.Info("获取有赞商品详情失败:" + detailRs.message, "错误");
|
continue;
|
}
|
DistributionRelation distributionRelation = new DistributionRelation()
|
{
|
YzskuInfo = JSONUtil.ObjectToJson(detailRs.data.sku_list)
|
};
|
new DistributionRelationDAL().Update(distributionRelation, i => new { i.YzskuInfo }, t => t.Id == pro.Id);
|
}
|
catch (Exception e)
|
{
|
LogUtil.Info(e.ToString(), "error1");
|
}
|
|
}
|
}
|
catch (Exception e)
|
{
|
LogUtil.Info(e.ToString(), "error");
|
}
|
}
|
}
|
}
|