647556386
3 天以前 bfa52edd6a430978873367426da7b379730da411
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
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common.APIEnum;
using WIDESEA_Core.Helper;
using WIDESEA_DTO.PLS;
using WIDESEA_External.IPLSService;
using WIDESEA_External.Model;
using WIDESEA_IBasicRepository;
using WIDESEA_Model.Models;
 
namespace WIDESEA_External.PLSService
{
    public class InvokePLSService : IInvokePLSService
    {
        private readonly IApiInfoRepository _apiInfoRepository;
 
        public InvokePLSService(IApiInfoRepository apiInfoRepository)
        {
            _apiInfoRepository = apiInfoRepository;
        }
        JsonSerializerSettings settings = new JsonSerializerSettings
        {
            ContractResolver = new CamelCasePropertyNamesContractResolver()
        };
 
        /// <summary>
        /// 获取MO票
        /// </summary>
        /// <param name="moInboundStatuModel"></param>
        /// <returns></returns>
        public string InvokeMoInboundStatuApi(ReturnMoInboundStatuModel moInboundStatuModel)
        {
            Dt_ApiInfo apiInfo = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.InvokePLSApi.ToString());
 
            string appId = AppSettings.Get("LocalAppId");
            string appSecret = AppSettings.Get("LocalAppSecret");
 
            var requestModel = new
            {
                Data = moInboundStatuModel,
                TimeStamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                AppId = appId
            };
 
            string paramStr = MD5Util.GetParamStr(requestModel);
 
            string sign = MD5Util.GetMD5_32(paramStr + appSecret);
 
            var finalRequest = new
            {
                requestModel.Data,
                requestModel.TimeStamp,
                requestModel.AppId,
                Sign = sign
            };
 
            string requestJson = JsonConvert.SerializeObject(finalRequest, settings);
 
            string response = HttpHelper.Post(apiInfo.ApiAddress, requestJson);
 
            return response;
        }
    }
}