From b6e4d3ed0ccb1e8a20a77d0d34fa0202ae35d844 Mon Sep 17 00:00:00 2001 From: shanj <18996038927@163.com> Date: Mon, 14 Nov 2022 21:57:53 +0800 Subject: [PATCH] 1 --- .../Sync/OrderSyncBusiness.cs | 21 +++++++++++++--- BBWY.Server.Model/Db/Order/GiftOrder.cs | 25 ++++++++++--------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs index 2309d966..3ff53502 100644 --- a/BBWY.Server.Business/Sync/OrderSyncBusiness.cs +++ b/BBWY.Server.Business/Sync/OrderSyncBusiness.cs @@ -12,6 +12,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using NLog; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; using System.Net.Http; @@ -171,12 +172,13 @@ namespace BBWY.Server.Business List insertOrderSkuList = new List(); List insertOrderCouponList = new List(); List insertSkuDailySaleDetailList = new List(); + List insertGiftorderList = new List(); IList> updateOrderList = new List>(); IList> updatePurchaseOrderList = new List>(); IList> updateSkuDailySalesDetailList = new List>(); - IDictionary> skuDailySalesDetailDictionary = new Dictionary>(); + ConcurrentDictionary> skuDailySalesDetailDictionary = new ConcurrentDictionary>(); #endregion #region 赠品 @@ -189,9 +191,18 @@ namespace BBWY.Server.Business if (exceptIds.Count() > 0) { var newGiftOrderJArray = giftOrderJArray.Where(o => exceptIds.Contains(o.Value("orderId"))); - foreach(var orderJToken in newGiftOrderJArray) + foreach (var orderJToken in newGiftOrderJArray) { var orderStartTime = orderJToken.Value("orderStartTime"); + insertGiftorderList.Add(new Giftorder() + { + Id = orderJToken.Value("orderId"), + CreateTime = DateTime.Now, + Platform = Enums.Platform.京东, + ShopId = shopId, + StartTime = orderStartTime + }); + var itemInfoList = orderJToken["itemInfoList"] as JArray; foreach (var orderSkuJToken in itemInfoList) { @@ -717,6 +728,8 @@ namespace BBWY.Server.Business fsql.Insert(insertOrderCouponList).ExecuteAffrows(); if (insertSkuDailySaleDetailList.Count() > 0) fsql.Insert(insertSkuDailySaleDetailList).ExecuteAffrows(); + if (insertGiftorderList.Count > 0) + fsql.Insert(insertGiftorderList).ExecuteAffrows(); if (updatePurchaseOrderList.Count() > 0) { @@ -758,7 +771,7 @@ namespace BBWY.Server.Business /// /// /// - private void CumulativeSkuDailySalesDetail(IDictionary> skuDailySalesDetailDictionary, + private void CumulativeSkuDailySalesDetail(ConcurrentDictionary> skuDailySalesDetailDictionary, DateTime orderStartTime, long shopId, string skuId, @@ -770,7 +783,7 @@ namespace BBWY.Server.Business if (!skuDailySalesDetailDictionary.TryGetValue(startDate, out List skuDailySalesDetailList)) { skuDailySalesDetailList = new List(); - skuDailySalesDetailDictionary.Add(orderStartTime, skuDailySalesDetailList); + skuDailySalesDetailDictionary.TryAdd(startDate, skuDailySalesDetailList); } var skuDailySalesDetail = skuDailySalesDetailList.FirstOrDefault(s => s.Sku == skuId); if (skuDailySalesDetail == null) diff --git a/BBWY.Server.Model/Db/Order/GiftOrder.cs b/BBWY.Server.Model/Db/Order/GiftOrder.cs index 34354519..906a8b0d 100644 --- a/BBWY.Server.Model/Db/Order/GiftOrder.cs +++ b/BBWY.Server.Model/Db/Order/GiftOrder.cs @@ -5,23 +5,24 @@ namespace BBWY.Server.Model.Db { [Table(Name = "giftorder", DisableSyncStructure = true)] - public partial class Giftorder { + public partial class Giftorder + { - [Column(StringLength = 50, IsPrimary = true, IsNullable = false)] - public string Id { get; set; } + [Column(StringLength = 50, IsPrimary = true, IsNullable = false)] + public string Id { get; set; } - [Column(DbType = "datetime")] - public DateTime? CreateTime { get; set; } + [Column(DbType = "datetime")] + public DateTime? CreateTime { get; set; } - - public int? Platform { get; set; } + [Column(MapType = typeof(int))] + public Enums.Platform Platform { get; set; } - - public long ShopId { get; set; } - [Column(DbType = "datetime")] - public DateTime? StartTime { get; set; } + public long ShopId { get; set; } - } + [Column(DbType = "datetime")] + public DateTime? StartTime { get; set; } + + } }