diff --git a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/ChargeFeeSendTypeEnum.cs b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/ChargeFeeSendTypeEnum.cs index 881085fa..9ddb6656 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/ChargeFeeSendTypeEnum.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Dtos/Enum/ChargeFeeSendTypeEnum.cs @@ -17,6 +17,16 @@ namespace DS.WMS.Core.Op.Dtos /// [Description("新增")] ADD = 0, + /// + /// VOLTA订舱 + /// + [Description("VOLTA订舱")] + VOLTA_SO = 1104, + /// + /// VOLTA截单 + /// + [Description("VOLTA截单")] + VOLTA_SI = 1105 } /// diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/DJYChargeFee/DJYChargeFeeService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/DJYChargeFee/DJYChargeFeeService.cs index 10c8adba..78eb3b18 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/DJYChargeFee/DJYChargeFeeService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/DJYChargeFee/DJYChargeFeeService.cs @@ -23,6 +23,8 @@ using DS.Module.Core.Data; using DS.WMS.Core.Sys.Interface; using DS.WMS.Core.Code.Method; using DS.WMS.Core.Code.Interface; +using DS.WMS.Core.Utils; +using NPOI.SS.Formula.PTG; namespace DS.WMS.Core.Op.Method { @@ -34,6 +36,7 @@ namespace DS.WMS.Core.Op.Method private readonly ISaasDbService saasService; private readonly IConfigService _configService; private readonly ICodeThirdPartyService _codeThirdPartyService; + private readonly IDingTalkGroupHelper _dingTalkGroupHelper; private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger(); @@ -42,6 +45,10 @@ namespace DS.WMS.Core.Op.Method _serviceProvider = serviceProvider; _configService = serviceProvider.GetRequiredService(); _codeThirdPartyService = serviceProvider.GetRequiredService(); + _dingTalkGroupHelper = serviceProvider.GetRequiredService(); + saasService = _serviceProvider.GetRequiredService(); + user = _serviceProvider.GetRequiredService(); + db = _serviceProvider.GetRequiredService(); } #region 扣费 @@ -131,6 +138,13 @@ namespace DS.WMS.Core.Op.Method string feeUserId = webAccountConfig.AppKey; string feeUserKey = webAccountConfig.AppSecret; + var c = tenantDb.Queryable().Filter(null, true).Count(x => x.Id == id); + if (c > 0) + { + Logger.Log(NLog.LogLevel.Info, $"{batchId}-已存在扣费记录,id:{id},提单号:{orderInfo.MBLNO}"); + continue; + } + var runId = Guid.NewGuid().ToString(); var seconds = DateTime.Now.ToTimestamp(); var srcBeforMD5 = $"{runId}{feeUserId}expend{(int)model.BSType}{(int)model.SendType}{id}{orderInfo.MBLNO}{seconds}{feeUserKey}"; @@ -214,7 +228,7 @@ namespace DS.WMS.Core.Op.Method Logger.Log(NLog.LogLevel.Info, $"批次号={batchId}-扣费失败,原因:{msg}"); - //DingTalkGroupHelper.SendDingTalkGroupMessage("bookingFeeNotify", "扣费失败提醒", errMsg); + _dingTalkGroupHelper.SendDingTalkGroupMessage("bookingFeeNotify", "扣费失败提醒", msg); } } catch (Exception ex) @@ -226,6 +240,8 @@ namespace DS.WMS.Core.Op.Method detail.Status = "EXCEPTION"; detail.Message = ex.Message; + + _dingTalkGroupHelper.SendDingTalkGroupMessage("bookingFeeNotify", "扣费失败提醒", record.ResultNote); } resultDto.ExcuteDetail.Add(detail); diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs index cc17305b..3c99878a 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportBookingOrClosingEDIService.cs @@ -1820,6 +1820,8 @@ namespace DS.WMS.Core.Op.Method if (ediRouteEnum == EDIRouteEnum.TSL) { sendStatus = await InnerSendBookingOrClosingEDIToPOST(result.ExtraData1.ToString(), postSpiderUrl, userWebAccountConfig); + + } else { @@ -1853,6 +1855,25 @@ namespace DS.WMS.Core.Op.Method } } + if (sendStatus.Succeeded) + { + if (ediRouteEnum == EDIRouteEnum.VOLTA) + { + var feeRlt = await _dJYChargeFeeService.ChargeFee(new DJYChargeFeeRequestDto + { + BSType = ChargeFeeBSTypeEnum.BOOKING_CHANNEL_FEE, + SendType = req.SendType.Equals("B") ? ChargeFeeSendTypeEnum.VOLTA_SO : ChargeFeeSendTypeEnum.VOLTA_SI, + BusinessIdList = new List { + order.Id + } + }); + + _logger.Info($"批次={batchNo} 扣费完成,结果{JsonConvert.SerializeObject(feeRlt)}"); + } + } + + _logger.Info("批次={no} 扣费", batchNo, result.ExtraData1.ToString()); + DateTime eDate = DateTime.Now; TimeSpan ts = eDate.Subtract(bDate); var timeDiff = ts.TotalMilliseconds; diff --git a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs index 2152faf6..aa78f579 100644 --- a/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs +++ b/ds-wms-service/DS.WMS.Core/Op/Method/SeaExportService.cs @@ -50,6 +50,8 @@ public partial class SeaExportService : ISeaExportService private readonly ISysCacheService _sysCacheService; private readonly IRabbitMQService _rabbitMQService; private readonly IRedisService _redisBaseService; + private readonly IDJYChargeFeeService _dJYChargeFeeService; + //private readonly IBookingSlotService _bookingSlotService; private readonly Lazy _taskManageBaseService; @@ -88,6 +90,7 @@ public partial class SeaExportService : ISeaExportService _configService = _serviceProvider.GetRequiredService(); _rabbitMQService = _serviceProvider.GetRequiredService(); _redisBaseService = _serviceProvider.GetRequiredService(); + _dJYChargeFeeService = _serviceProvider.GetRequiredService(); //_bookingSlotService = _serviceProvider.GetRequiredService(); diff --git a/ds-wms-service/DS.WMS.Core/Utils/DingTalkGroupHelper.cs b/ds-wms-service/DS.WMS.Core/Utils/DingTalkGroupHelper.cs new file mode 100644 index 00000000..d0971f5d --- /dev/null +++ b/ds-wms-service/DS.WMS.Core/Utils/DingTalkGroupHelper.cs @@ -0,0 +1,135 @@ +using DS.Module.Core; +using DS.Module.SqlSugar; +using DS.Module.UserModule; +using DS.WMS.Core.Op.Dtos; +using DS.WMS.Core.Op.Entity; +using DS.WMS.Core.Op.Interface; +using DS.WMS.Core.Sys.Entity; +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; +using NLog; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DS.Module.Core.Extensions; +using LogicExtensions; +using DS.Module.Core.Helpers; +using Newtonsoft.Json.Linq; +using DS.Module.Core.Data; +using DS.WMS.Core.Sys.Interface; +using DS.WMS.Core.Code.Method; +using DS.WMS.Core.Code.Interface; +using System.Text.Json.Nodes; + +namespace DS.WMS.Core.Utils +{ + public class DingTalkGroupHelper : IDingTalkGroupHelper + { + private static readonly NLog.Logger Logger = LogManager.GetCurrentClassLogger(); + private readonly IServiceProvider _serviceProvider; + private readonly ISqlSugarClient db; + private readonly IUser user; + private readonly ISaasDbService saasService; + private readonly IConfigService _configService; + private readonly ICodeThirdPartyService _codeThirdPartyService; + + public DingTalkGroupHelper(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + _configService = serviceProvider.GetRequiredService(); + _codeThirdPartyService = serviceProvider.GetRequiredService(); + db = _serviceProvider.GetRequiredService(); + } + + /// + /// 发送钉钉客服群组消息通知 + /// + /// 钉钉群配置code + /// 标题 + /// 内容 + public async Task SendDingTalkGroupMessage(string code, string title, string content) + { + var dingdingCfg = db.Queryable().Filter(null, true) + .Where(x => x.Code == code && x.TenantId == 1288018625843826688).First(); + + var postdata = new + { + text = + new + { + content = $"【{title}】\r\n{content}\r\n----{dingdingCfg.Note}" + }, + msgtype = "text" + }; + + Logger.Log(NLog.LogLevel.Info, $"准备发送钉钉消息:{postdata.ToJsonString()}"); + + var rtn = RequestHelper.Post(JsonConvert.SerializeObject(postdata), dingdingCfg.Value); + + Logger.Log(NLog.LogLevel.Info, $"发送钉钉消息返回:{rtn}"); + } + + /// + /// 发送钉钉客服群组消息通知 + /// + /// 钉钉群配置code + /// 标题 + /// 内容 + /// @所有人 + /// @手机号数组 + /// @用户id数组 + public async Task SendDingTalkGroupMessage(string code, string title, string content, bool atAll, string[] atMobiles, string[] atUserIds) + { + var dingdingCfg = db.Queryable().Filter(null, true) + .Where(x => x.Code == code && x.TenantId == 1288018625843826688).First(); + + var postdata = new + { + text = + new + { + content = $"【{title}】\r\n{content}\r\n----{dingdingCfg.Note}" + }, + msgtype = "text", + at = new + { + isAtAll = atAll, + atMobiles = atMobiles, + atUserIds = atUserIds + } + }; + + Logger.Log(NLog.LogLevel.Info, $"准备发送钉钉消息:{postdata.ToJsonString()}"); + + var rtn = RequestHelper.Post(JsonConvert.SerializeObject(postdata), dingdingCfg.Value); + + Logger.Log(NLog.LogLevel.Info, $"发送钉钉消息返回:{rtn}"); + } + } + + public interface IDingTalkGroupHelper + { + /// + /// 发送钉钉客服群组消息通知 + /// + /// 钉钉群配置code + /// 标题 + /// 内容 + Task SendDingTalkGroupMessage(string code, string title, string content); + + /// + /// 发送钉钉客服群组消息通知 + /// + /// 钉钉群配置code + /// 标题 + /// 内容 + /// @所有人 + /// @手机号数组 + /// @用户id数组 + Task SendDingTalkGroupMessage(string code, string title, string content, bool atAll, string[] atMobiles, string[] atUserIds); + } +}