using Ant.Core.Utils; using Central.Control.WebApi.DbEntity; using Central.Control.WebApi.EFDbContext; using Central.Control.WebApi.Enum; using Central.Control.WebApi.Log4net; using Central.Control.WebApi.Service.Interface; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace Central.Control.WebApi.Service { /// /// 业务日志相关 /// public class YWLogService: IYWLogService { private readonly IDbContext _dbContent; private readonly ILog4NetHelper _log4NetHelper; /// /// /// /// /// public YWLogService( IDbContext dbContent, ILog4NetHelper log4NetHelper) { _dbContent = dbContent; _log4NetHelper = log4NetHelper; } /// /// 写入订单日志 /// /// /// /// /// public void WriteOrderLog(string orderId, string title, string content, string opreater) { try { if (content == null) content = string.Empty; YW_OrderLog orderLog = new YW_OrderLog() { Id = IdGenerator.NewId(), OrderId = orderId ?? string.Empty, Title = title ?? string.Empty, Content = content.Length >= 500 ? content.Substring(0, 499) : content, CreateBY = opreater ?? string.Empty }; _dbContent.Set().Add(orderLog); _dbContent.SaveChanges(); } catch (Exception ee) { _log4NetHelper.Error("[写入订单日志WriteOrderLogAsync]", ee); } } /// /// 写入支付回写日志 /// /// 支付流水号 /// 外部订单号 /// 支付类型 /// 回写原始内容 public void WritePayCallLog(string paySerialId, string outTradeNo, PayWayEnum payWay, string payResponse) { try { YW_PayCallLog payCallLog = new YW_PayCallLog() { Id = IdGenerator.NewId(), PaySerialId = paySerialId ?? string.Empty, OutTradeNo = outTradeNo ?? string.Empty, PayWay = payWay, PayResponse = payResponse ?? string.Empty, CreateBY = "支付回写" }; _dbContent.Set().Add(payCallLog); _dbContent.SaveChanges(); } catch (Exception ee) { _log4NetHelper.Error("[写入支付回写日志WritePayCallLog]", ee); } } /// /// 写入订单流程信息 /// /// /// /// /// /// public void WriteOrderProcess(string orderId, string deviceId, OrderStatusEnum orderStatus, string message, string opreater) { try { YW_OrderProcess orderProcess = new YW_OrderProcess() { Id = IdGenerator.NewId(), OrderId = orderId, DeviceId = deviceId, CurrentOrderStatus = orderStatus, Message = message, CreateBY = opreater }; _dbContent.Set().Add(orderProcess); _dbContent.SaveChanges(); } catch (Exception ee) { _log4NetHelper.Error("[写入订单流程WriteOrderProcess]", ee); } } } }