|
- using GpsCardGatewayPosition.Model.Config;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TelpoDataService.Util.Clients;
- using TelpoDataService.Util.Entities.GpsCard;
- using TelpoDataService.Util;
-
- namespace GpsCardGatewayPosition.Service.Biz.Pay
- {
- public class PayLogic
- {
- private readonly ServiceConfig _configService;
- private readonly GpsCardAccessorClient<GpsPayLog> _payLogApiClient;
- private readonly ILogger<PayLogic> _logger;
-
- public PayLogic(IOptions<ServiceConfig> optConfigService, GpsCardAccessorClient<GpsPayLog> payLogApiClient,
- ILogger<PayLogic> logger)
- {
- _configService = optConfigService.Value;
- _payLogApiClient = payLogApiClient;
- _logger = logger;
- }
-
- public async Task<GpsPayLog> GetPayLogAsync(string messageId, string payId)
- {
- try
- {
- var alarm = await _payLogApiClient.GetByIdAsync(payId, new RequestHeader { RequestId = messageId }).ConfigureAwait(false);
- return alarm;
- }
- catch (Exception ex)
- {
- _logger.LogError($"根据{payId}获取指定支付信息失败, {ex.Message}, {ex.StackTrace}");
- return null;
- }
- }
-
- public async Task<bool> AddPayLogAsync(string messageId, GpsPayLog pay)
- {
- try
- {
- await _payLogApiClient.AddAsync(pay).ConfigureAwait(false);
- return true;
- }
- catch (Exception ex)
- {
- _logger.LogError($"新增支付信息发生异常:{ex.Message}, {ex.StackTrace}");
- }
-
- return false;
- }
-
- public async Task<bool> UpdatePayLogAsync(string messageId, GpsPayLog pay)
- {
- try
- {
- await _payLogApiClient.UpdateAsync(pay, new RequestHeader { RequestId = messageId }).ConfigureAwait(false);
- return true;
- }
- catch (Exception ex)
- {
- _logger.LogError($"更新支付信息发生异常:{ex.Message}, {ex.StackTrace}");
- }
-
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- }
|