zhaojs
2023-09-15 fc13938ff90213060532d99a600dea4a84456885
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
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("执行完成!");
        }
    }
}