123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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
- {
- /// <summary>
- /// 业务日志相关
- /// </summary>
- public class YWLogService: IYWLogService
- {
- private readonly IDbContext _dbContent;
- private readonly ILog4NetHelper _log4NetHelper;
- /// <summary>
- ///
- /// </summary>
- /// <param name="dbContent"></param>
- /// <param name="log4NetHelper"></param>
- public YWLogService(
- IDbContext dbContent,
- ILog4NetHelper log4NetHelper)
- {
- _dbContent = dbContent;
- _log4NetHelper = log4NetHelper;
- }
- /// <summary>
- /// 写入订单日志
- /// </summary>
- /// <param name="orderId"></param>
- /// <param name="title"></param>
- /// <param name="content"></param>
- /// <param name="opreater"></param>
- 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<YW_OrderLog>().Add(orderLog);
- _dbContent.SaveChanges();
- }
- catch (Exception ee)
- {
- _log4NetHelper.Error("[写入订单日志WriteOrderLogAsync]", ee);
- }
- }
- /// <summary>
- /// 写入支付回写日志
- /// </summary>
- /// <param name="paySerialId">支付流水号</param>
- /// <param name="outTradeNo">外部订单号</param>
- /// <param name="payWay">支付类型</param>
- /// <param name="payResponse">回写原始内容</param>
- 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<YW_PayCallLog>().Add(payCallLog);
- _dbContent.SaveChanges();
- }
- catch (Exception ee)
- {
- _log4NetHelper.Error("[写入支付回写日志WritePayCallLog]", ee);
- }
- }
- /// <summary>
- /// 写入订单流程信息
- /// </summary>
- /// <param name="orderId"></param>
- /// <param name="deviceId"></param>
- /// <param name="orderStatus"></param>
- /// <param name="message"></param>
- /// <param name="opreater"></param>
- 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<YW_OrderProcess>().Add(orderProcess);
- _dbContent.SaveChanges();
- }
- catch (Exception ee)
- {
- _log4NetHelper.Error("[写入订单流程WriteOrderProcess]", ee);
- }
- }
- }
- }
|