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 _payLogApiClient; private readonly ILogger _logger; public PayLogic(IOptions optConfigService, GpsCardAccessorClient payLogApiClient, ILogger logger) { _configService = optConfigService.Value; _payLogApiClient = payLogApiClient; _logger = logger; } public async Task 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 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 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; } //public async Task UpdatePayLogAsync(string messageId, string PayId, decimal oLat, decimal oLng, decimal baiduLat, decimal baiduLng, decimal gLat, decimal gLng) //{ // try // { // var pay = await _payLogApiClient.GetByIdAsync(PayId, new RequestHeader { RequestId = messageId }).ConfigureAwait(false); // if (pay != null) // { // pay.Olat = oLat; // pay.Olng = oLng; // pay.BaiduLat = baiduLat; // pay.BaiduLng = baiduLng; // pay.Glat = gLat; // pay.Glng = gLng; // _payLogApiClient.UpdateAsync(pay, new RequestHeader { RequestId = messageId }); // } // } // catch (Exception ex) // { // _logger.LogError($"更新PayLog发生异常:{ex.Message}, {ex.StackTrace}"); // } //} //public void SavePayLog(string messageId, GpsPayLog pay) //{ // try // { // var url = _configService.TelpoDataUrl; // _payLogApiClient.AddAsync(pay, new RequestHeader { RequestId = messageId }); // } // catch (Exception ex) // { // _logger.LogError($"保存PayLog发生异常:{ex.Message}, {ex.StackTrace}"); // } //} } }