zhaojs
2023-09-27 74098f1401afe40f961d1d167bb18dd0a71c4d59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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");
            }
        }
    }
}