heyuntao
2023-05-04 fbd6a11a99051f425640bf352842f4a0ecaa7a4d
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
80
81
82
83
84
85
86
87
88
using CommonUtil.Top;
using DkSdkCore;
using DkSdkCore.Request;
using DkSdkCore.Response;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Operater.DTO.Tk;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
 
namespace Api.Operater.Controllers
{
    /// <summary>
    /// pdd商品
    /// </summary>
    [Route(TopConstants.API_ROUTE)]
    public class TkPddProductController : BaseController
    {
        /// <summary>
        /// pdd商品搜索
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetPddSearchGoodsList([FromBody] GetTkPddSearchProductListRequest request)
        {
            DtkApp app = new DtkApp();
            TkGetPddGoodsListResquest goodsListRequest = new TkGetPddGoodsListResquest();
            goodsListRequest.sortType = request.sort;
            goodsListRequest.page = request.PageNo.ToString();
            goodsListRequest.pageSize = request.PageSize.ToString();
            goodsListRequest.keyword = request.keyWords;
            goodsListRequest.withCoupon = request.hasCoupon;
            TkGetPddGoodsListResponse dtkresponse = Newtonsoft.Json.JsonConvert.DeserializeObject<TkGetPddGoodsListResponse>(app.Excute(goodsListRequest));
            List<GetTkPddSearchProductListReponse> getTkTbProductLists = new List<GetTkPddSearchProductListReponse>();
            if (dtkresponse == null || dtkresponse.data.goodsList.Count == 0)
            {
                return Error("没有数据啦!");
            }
            foreach (var item in dtkresponse.data.goodsList)
            {
                GetTkPddSearchProductListReponse tbProductListReponse = new GetTkPddSearchProductListReponse
                {
                    dtitle = item.goodsName,
                    shopname = item.mallName,
                    couponPrice = item.couponDiscount.ToString(),
                    couponEndTime = item.couponEndTime,
                    couponStartTime = item.couponStartTime,
                    desc = item.goodsDesc,
                    goodsId = item.goodsId,
                    actualPrice = item.minNormalPrice.ToString(),
                    allsale = item.salesTip,
                    mainPic = item.goodsThumbnailUrl,
                    goodsSign=item.goodsSign
                };
                getTkTbProductLists.Add(tbProductListReponse);
            }
            return Success(getTkTbProductLists);
        }
 
        /// <summary>
        /// 获取拼多多推广连接
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetPddProductShare([FromBody] GetTkPddProductUrlListRequest request)
        {
            DtkApp app = new DtkApp();
            TkGetPddGoodUrlRequest goodDetailRequest = new TkGetPddGoodUrlRequest();
            goodDetailRequest.pid = "36944097_265137240";
            goodDetailRequest.goodsSign = request.id;
            TkGetPddGoodUrlResponse dtkresponse = Newtonsoft.Json.JsonConvert.DeserializeObject<TkGetPddGoodUrlResponse>(app.Excute(goodDetailRequest));
            if (dtkresponse == null || dtkresponse.Data == null)
            {
                return Error("未查到数据");
            }
            else
            {
 
 
                return Success(dtkresponse.Data.weAppPagePath);
            }
        }
    }
}