zhengyiming
2025-04-16 5a09f64b974521e25ef07c0691361ba5d71e919b
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
using LifePayment.Domain.Shared;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;
 
namespace LifePayment.Domain;
 
public class ACOOLYManager : ACOOLYClient, IACOOLYManager
{
    private readonly ILogger<ACOOLYClient> _logger;
    private readonly ACOOLYOption _options;
 
    public ACOOLYManager(ILogger<ACOOLYClient> logger, IOptionsMonitor<ACOOLYOption> optionsMonitor) : base(logger, optionsMonitor)
    {
        _logger = logger;
        _options = optionsMonitor.CurrentValue;
    }
 
    #region 燃气
 
    /// <summary>
    /// 获取燃气面值
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<GasParValueResponse> GasParValue(GasParValueRequestInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.GasParValue);
        return await PostAsync<GasParValueRequestInput, GasParValueResponse>(input);
    }
 
    public async Task<GasOrgTypeValueResponse> GasOrgType(GasOrgTypeRequestInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.QueryGasOrgType);
        return await PostAsync<GasOrgTypeRequestInput, GasOrgTypeValueResponse>(input);
    }
 
    /// <summary>
    /// 提交燃气订单
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<ConfirmGasOrderResponse> ConfirmGasOrder(ConfirmGasOrderRequestInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.ConfirmGasOrder);
        return await PostAsync<ConfirmGasOrderRequestInput, ConfirmGasOrderResponse>(input);
    }
 
    #endregion
 
    #region 电费
 
    /// <summary>
    /// 获取电费面值
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<ElectricParValueResponse> ElectricParValue(ACOOLYRequestBaseInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.ElectricParValue);
 
#if DEBUG
 
        //return new ElectricParValueResponse
        //{
        //    Code = ACOOLYConstant.Code.SUCCESS,
        //    ElectricParValue = new List<ElectricParValueOutput>()
        //    {
        //       new ElectricParValueOutput()
        //       {
        //           AreaName = "北京",
        //           Comments = "测试数据",
        //           ElectricType = "guowang",
        //           ParValue = "100,200,300",
        //           Rate = 0.93m
        //       },
 
        //        new ElectricParValueOutput()
        //       {
        //           AreaName = "上海",
        //           Comments = "测试数据",
        //           ElectricType = "nanwang",
        //           ParValue = "100,200,300",
        //           Rate = 0.93m
        //       }
 
        //    },
        //    RequestNo = input.RequestNo,
        //    Service = input.Service,
        //    PartnerId = input.PartnerId,
        //    Success = "true",
        //};
 
#endif
 
        return await PostAsync<ACOOLYRequestBaseInput, ElectricParValueResponse>(input);
    }
 
    /// <summary>
    /// 获取电费充值区域
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<ElectricSupportAreaResponse> GetElectricSupportArea(ACOOLYRequestBaseInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.ElectricSupportArea);
 
        return await PostAsync<ACOOLYRequestBaseInput, ElectricSupportAreaResponse>(input);
    }
 
    /// <summary>
    /// 提交电费订单
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<ConfirmElectricOrderResponse> ConfirmElectricOrder(ConfirmElectricOrderRequestInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.ConfirmElectricOrder);
 
#if DEBUG
 
        //return new ConfirmElectricOrderResponse
        //{
        //    Code = ACOOLYConstant.Code.PROCESSING,
        //    ElectricChargeOrder = new ElectricChargeOrderOutput
        //    {
        //        AreaName = input.Province,
        //        ElectricAccount = input.ElectricAccount,
        //        ElectricType = input.ElectricType,
        //        OutOrderNo = input.OutOrderNo,
        //        BusiOrderNo = "Test000000001",
        //        ParValue = input.ParValue,
        //        PayAmount = input.ParValue,
        //        Status = ACOOLYConstant.Code.PROCESSING,
        //        StatusText = "处理中"
        //    },
        //    RequestNo = input.RequestNo,
        //    Service = input.Service,
        //    PartnerId = input.PartnerId,
        //    Success = true,
        //};
 
#endif
 
        return await PostAsync<ConfirmElectricOrderRequestInput, ConfirmElectricOrderResponse>(input);
    }
 
    #endregion
 
    #region 话费
 
    /// <summary>
    /// 获取话费面值
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<PhoneParValueResponse> PhoneParValue(ACOOLYRequestBaseInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.PhoneParValue);
 
#if DEBUG
 
        //return new PhoneParValueResponse
        //{
        //    Code = ACOOLYConstant.Code.SUCCESS,
        //    PhoneParValue = new List<PhoneParValueOutput>()
        //    {
        //       new PhoneParValueOutput()
        //       {
        //           IspCode="yidong",
        //           IspName="移动",
        //           PhoneSection="",
        //           Comments= "测试数据",
        //           ParValue = "100,200,300",
        //           Rate = 0.93m
        //       },
 
        //       new PhoneParValueOutput()
        //       {
        //           IspCode="dianxin",
        //           IspName="电信",
        //           PhoneSection="",
        //           Comments= "测试数据",
        //           ParValue = "100,200,300",
        //           Rate = 0.93m
        //       },
 
        //       new PhoneParValueOutput()
        //       {
        //           IspCode="liantong",
        //           IspName="联通",
        //           PhoneSection="",
        //           Comments= "测试数据",
        //           ParValue = "100,200,300",
        //           Rate = 0.93m
        //       },
        //    },
        //    RequestNo = input.RequestNo,
        //    Service = input.Service,
        //    PartnerId = input.PartnerId,
        //    Success =  true,
        //};
 
#endif
 
        return await PostAsync<ACOOLYRequestBaseInput, PhoneParValueResponse>(input);
    }
 
    /// <summary>
    /// 提交话费订单
    /// </summary>
    /// <param name="input"></param>
    /// <returns></returns>
    public async Task<ConfirmPhoneOrderResponse> ConfirmPhoneOrder(ConfirmPhoneOrderRequestInput input)
    {
        SetBaseInfo(input, ACOOLYConstant.Sevice.ConfirmPhoneOrder);
 
#if DEBUG
 
        //return new ConfirmPhoneOrderResponse
        //{
        //    Code = ACOOLYConstant.Code.PROCESSING,
        //    PhoneChargeOrder = new PhoneChargeOrderOutput()
        //    {
        //        OutOrderNo = input.OutOrderNo,
        //        BusiOrderNo = "Test000000001",
        //        ParValue = input.ParValue,
        //        PayAmount = input.ParValue,
        //        Status = ACOOLYConstant.Code.PROCESSING,
        //        StatusText = "处理中",
        //    },
        //    RequestNo = input.RequestNo,
        //    Service = input.Service,
        //    PartnerId = input.PartnerId,
        //    Success = true,
        //};
 
#endif
 
        return await PostAsync<ConfirmPhoneOrderRequestInput, ConfirmPhoneOrderResponse>(input);
    }
 
    #endregion
 
    #region 私有
 
    private void SetBaseInfo(ACOOLYRequestBaseInput input, string service)
    {
        input.RequestNo = GuidGenerator.Create().ToString();
        input.Service = service;
        input.PartnerId = _options.PartnerId;
        input.NotifyUrl = _options.NotifyUrl + ACOOLYConstant.NotifyUrl;
    }
 
    #endregion
 
}