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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using AlibabaSDK.Api;
using AlibabaSDK.Request;
using Operater.DTO.System;
using CommonUtil;
using System;
using System.Collections.Generic;
using System.Text;
using AlibabaSDK.Domain;
 
namespace Operater.Service.System
{
    public class ProductManageService : IProductManageService
    {
        /// <summary>
        /// 获取1688商品详情
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public GetAliProductInfoResponse GetAliProductInfo(CompareChangeRequest request)
        {
            GetAliProductInfoResponse rsp= new GetAliProductInfoResponse()
            {
                Success = false
            };
            if (request.ProSource == 0)
            {//精选
                List<string> ls = new List<string>();
                ls.Add(request.AliProductId.ToString());
                PFTProductDetailRequest jxrequest = new PFTProductDetailRequest()
                {
                    offerIds = ls
                };
                var response = AliabaClient.Execute(jxrequest, request.AliToken);
                if (response.IsNull() || !response.result.success || response.result.result.Count == 0)
                {//获取商品详情失败
                    rsp.Error = $"获取精选商品详情错误:" + response.result.message;
                    return rsp;
                }
                rsp.Success = true;
                rsp.JXProduct = response.result.result[0].productInfo;
                return rsp;
            }
            else
            {//代发
                FenXiaoProductInfoGetRequest dfrequest = new FenXiaoProductInfoGetRequest()
                {
                    offerId = request.AliProductId
                };
                var dfresponse = AliabaClient.Execute(dfrequest, request.AliToken);
                if (dfresponse.IsNull() || !dfresponse.Success)
                {//获取商品详情失败
                    rsp.Error = $"获取代发商品详情错误:" + dfresponse.ErrorMsg;
                    return rsp;
                }
                List<SkuInfosItem> res = JSONUtil.JsonToObject<List<SkuInfosItem>>(JSONUtil.ObjectToJson(dfresponse.productInfo.productSkuInfos));
                rsp.Success = true;
                rsp.DFProduct = dfresponse.productInfo;
                return rsp;
            }
        }
 
        public class GetAliProductInfoResponse
        {
            public bool Success { get; set; }
 
            public string Error { get; set; }
 
            /// <summary>
            /// 精选
            /// </summary>
            public PFTProductDetailDomainProInfo JXProduct { get; set; }
 
            /// <summary>
            /// 代发
            /// </summary>
            public FenXiaoProductInfoGetDomain DFProduct { get; set; }
        }
    }
}