Browse Source

新增pin逻辑

qianyi
shanji 3 years ago
parent
commit
62c7ae21f7
  1. 28
      BBWY.Server.Business/Sync/JDPopularizeSyncBusiness.cs
  2. 22
      BBWY.Server.Model/Db/Shop/JdShopPin.cs

28
BBWY.Server.Business/Sync/JDPopularizeSyncBusiness.cs

@ -65,7 +65,30 @@ namespace BBWY.Server.Business.Sync
ShopId = shopId ShopId = shopId
}); });
} }
#region 新增pin保存逻辑
var pinList = jArray.Select(j => j.Value<string>("pin")).Distinct().ToList();
var dbPinList = fsql.Select<JdShopPin>().Where(p => p.ShopId == shopId).ToList(p => p.AccessPin);
var pinchajiList = pinList.Except(dbPinList).ToList();
List<JdShopPin> insertJDShopPinList = null;
if (pinchajiList.Count() > 0)
{
insertJDShopPinList = pinchajiList.Select(pin => new JdShopPin()
{
Id = idGenerator.NewLong(),
AccessPin = pin,
CreateTime = DateTime.Now,
ShopId = shopId
}).ToList();
}
#endregion
fsql.Transaction(() =>
{
if (insertJDShopPinList != null)
fsql.Insert(insertJDShopPinList).ExecuteAffrows();
fsql.Insert(insertList).ExecuteAffrows(); fsql.Insert(insertList).ExecuteAffrows();
});
} }
private void SyncShopPopularizeRecord(ShopResponse shop, DateTime startDate, DateTime endDate, int pageIndex, out int currentCount) private void SyncShopPopularizeRecord(ShopResponse shop, DateTime startDate, DateTime endDate, int pageIndex, out int currentCount)
@ -117,7 +140,12 @@ namespace BBWY.Server.Business.Sync
private void DeleteOldData(IList<ShopResponse> shops, DateTime startDate, DateTime endDate) private void DeleteOldData(IList<ShopResponse> shops, DateTime startDate, DateTime endDate)
{ {
var shopIds = shops.Select(s => Convert.ToInt64(s.ShopId)).ToList(); var shopIds = shops.Select(s => Convert.ToInt64(s.ShopId)).ToList();
fsql.Transaction(() =>
{
fsql.Delete<JdShopPin>().Where(p => shopIds.Contains(p.ShopId.Value)).ExecuteAffrows();
fsql.Delete<Shoppopularize>().Where(s => shopIds.Contains(s.ShopId.Value) && s.Date >= startDate && s.Date <= endDate).ExecuteAffrows(); fsql.Delete<Shoppopularize>().Where(s => shopIds.Contains(s.ShopId.Value) && s.Date >= startDate && s.Date <= endDate).ExecuteAffrows();
});
} }
public void SyncAllShopPopularizeRecord() public void SyncAllShopPopularizeRecord()

22
BBWY.Server.Model/Db/Shop/JdShopPin.cs

@ -0,0 +1,22 @@
using FreeSql.DataAnnotations;
using System;
namespace BBWY.Server.Model.Db
{
[ Table(Name = "jdshoppin", DisableSyncStructure = true)]
public partial class JdShopPin {
[Column(StringLength = 100)]
public string AccessPin { get; set; }
[Column(DbType = "datetime")]
public DateTime? CreateTime { get; set; }
public long Id { get; set; }
public long? ShopId { get; set; }
}
}
Loading…
Cancel
Save