Browse Source

新增数据sku变化结构

master
С·æ 4 years ago
parent
commit
a6ecc0f714
  1. 10
      JdShopListener/JdShopListener/Converters/ToStringConverter.cs
  2. 2
      JdShopListener/JdShopListener/JdShopListener.csproj
  3. 12
      JdShopListener/JdShopListener/MainWindow.xaml
  4. 351
      JdShopListener/JdShopListener/MainWindowViewModel.cs
  5. 27
      JdShopListener/JdShopListener/Migrations/20210418094901_InitialCreate.Designer.cs
  6. 17
      JdShopListener/JdShopListener/Migrations/20210418094901_InitialCreate.cs
  7. 25
      JdShopListener/JdShopListener/Migrations/JdDBContextModelSnapshot.cs
  8. 3
      JdShopListener/JdShopListener/Models/ItemChangeModel.cs
  9. 6
      JdShopListener/JdShopListener/Models/ProModel.cs
  10. 11
      JdShopListener/JdShopListener/Models/SkuModel.cs
  11. 15
      JdShopListener/JdShopListener/SqlHelpers/DbHelper.cs
  12. BIN
      JdShopListener/JdShopListener/db/items.db

10
JdShopListener/JdShopListener/Converters/ToStringConverter.cs

@ -37,6 +37,8 @@ namespace WPF.Converters
dic.Add(drr[0].ToLower(), drr[1]); dic.Add(drr[0].ToLower(), drr[1]);
} }
string defa = dic.FirstOrDefault().Value.ToString();
if (dic.ContainsKey(key)) if (dic.ContainsKey(key))
{ {
if (dic[key] == "Collapsed") if (dic[key] == "Collapsed")
@ -46,15 +48,15 @@ namespace WPF.Converters
return dic[key]; return dic[key];
} }
else else if (defa == "Visible")
if (dic.FirstOrDefault().Value.ToString() == "Visible")
{ {
return System.Windows.Visibility.Collapsed; return System.Windows.Visibility.Collapsed;
} }
else else
if (dic.FirstOrDefault().Value.ToString() == "Collapsed") if (defa == "Collapsed")
return System.Windows.Visibility.Visible; return System.Windows.Visibility.Visible;
return value;
return defa;
} }

2
JdShopListener/JdShopListener/JdShopListener.csproj

@ -30,7 +30,7 @@
<ItemGroup> <ItemGroup>
<None Update="db\items.db"> <None Update="db\items.db">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>

12
JdShopListener/JdShopListener/MainWindow.xaml

@ -214,7 +214,7 @@
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBox Tag="请输入备注" Text="{Binding Desc}" Width="350" Margin="0 10 0 0" HorizontalAlignment="Left"></TextBox> <TextBox Tag="请输入备注" Text="{Binding Desc}" Width="350" Margin="0 10 0 0" HorizontalAlignment="Left"></TextBox>
<Button Content="开始监控" IsEnabled="{Binding IsStart,Converter={StaticResource toString},ConverterParameter=true----false|false----true}" Command="{Binding Btn_Start}" Margin="10 10 0 0"></Button> <Button Content="{Binding IsStart,Converter={StaticResource toString},ConverterParameter=true----停止监控|Null----正在停止|false----开始监控}" Command="{Binding Btn_Start}" Margin="10 10 0 0"></Button>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
@ -268,20 +268,20 @@
<StackPanel x:Name="spList" Orientation="Horizontal" DockPanel.Dock="Right"> <StackPanel x:Name="spList" Orientation="Horizontal" DockPanel.Dock="Right">
<StackPanel VerticalAlignment="Center"> <StackPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="原:" VerticalAlignment="Center"></TextBlock> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.SelectPro.Type,Converter={StaticResource toString},ConverterParameter=0----原:|sku----减:}" VerticalAlignment="Center"></TextBlock>
<ListBox Style="{StaticResource ListPro}" ItemsSource="{Binding OldProList}"> <ListBox Style="{StaticResource ListPro}" ItemsSource="{Binding OldProList}">
</ListBox> </ListBox>
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="新:" VerticalAlignment="Center"></TextBlock> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.SelectPro.Type,Converter={StaticResource toString},ConverterParameter=0----新:|sku----增:}" VerticalAlignment="Center"></TextBlock>
<ListBox Style="{StaticResource ListPro}" ItemsSource="{Binding NewProList}"> <ListBox Style="{StaticResource ListPro}" ItemsSource="{Binding NewProList}">
</ListBox> </ListBox>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</DockPanel> </DockPanel>
<DataTemplate.Triggers> <DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.SelectPro.Type}" Value="1"> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.SelectPro.Type}" Value="1">

351
JdShopListener/JdShopListener/MainWindowViewModel.cs

@ -33,7 +33,8 @@ namespace JdShopListener
new ProModel(){ Name="价格" , Type= ProType.Price}, new ProModel(){ Name="价格" , Type= ProType.Price},
new ProModel(){ Name="活动" , Type= ProType.Active}, new ProModel(){ Name="活动" , Type= ProType.Active},
new ProModel(){ Name="促销" , Type= ProType.Promotion}, new ProModel(){ Name="促销" , Type= ProType.Promotion},
new ProModel(){ Name="优惠券" , Type= ProType.Coupons} new ProModel(){ Name="优惠券" , Type= ProType.Coupons},
new ProModel(){ Name="Sku" , Type= ProType.Sku},
}; };
DateList = new System.Collections.ObjectModel.ObservableCollection<DateModel>() { DateList = new System.Collections.ObjectModel.ObservableCollection<DateModel>() {
@ -61,7 +62,10 @@ namespace JdShopListener
SkuList.Clear(); SkuList.Clear();
var list= DbHelper.Db.GetSkuList(); var list= DbHelper.Db.GetSkuList();
list.ForEach(c => { list.ForEach(c => {
SkuList.Add(c); if (c.IsShow == 1)
{
SkuList.Add(c);
}
}); });
} }
@ -191,9 +195,9 @@ namespace JdShopListener
set { Set(ref _IsAdd, value); } set { Set(ref _IsAdd, value); }
} }
private bool _IsStart; private bool? _IsStart=false;
public bool IsStart public bool? IsStart
{ {
get { return _IsStart; } get { return _IsStart; }
set { Set(ref _IsStart, value); } set { Set(ref _IsStart, value); }
@ -245,12 +249,38 @@ namespace JdShopListener
SpuId = spuId SpuId = spuId
}; };
if (model.SkuId == Sku)
{
model.IsShow = 1;
}
//去除重复 //去除重复
if (SkuList.Count(c => c.SkuId == model.SkuId) > 0) if (SkuList.Count(c => c.SkuId == model.SkuId) > 0)
{
if (model.IsShow == 1)
{
var osku = SkuList.FirstOrDefault(c => c.SkuId == model.SkuId);
if (osku.IsShow != 1)
{
osku.IsShow = 1;
DbHelper.Db.UpdateSkuModel(osku);
}
}
continue; continue;
}
//加入本地数据库 //加入本地数据库
skus.Add(model); skus.Add(model);
Application.Current.Dispatcher.Invoke(() => Application.Current.Dispatcher.Invoke(() =>
{ {
SkuList.Add(model); SkuList.Add(model);
@ -331,7 +361,7 @@ namespace JdShopListener
/// </summary> /// </summary>
public void Start() public void Start()
{ {
if (!IsStart) if (IsStart==false)
{ {
IsStart = true; IsStart = true;
Thread t = new Thread(() => Thread t = new Thread(() =>
@ -339,12 +369,36 @@ namespace JdShopListener
LastItemChangeList.Clear(); LastItemChangeList.Clear();
LastItemChangeList = DbHelper.Db.GetLastItemChanges(); LastItemChangeList = DbHelper.Db.GetLastItemChanges();
DoWork(); while (IsStart==true)
{
AddLog("开始sku定时监控!");
DoWork();
AddLog("全部sku监控执行完成,等待一小时后开始下一轮监控!");
for(int i=0;i<60;i++)
{
if (IsStart != true)
break;
for (int s = 0; s < 60; s++)
{
if (IsStart != true)
break;
//等待一小时
Thread.Sleep(1000);
}
}
}
IsStart = false; IsStart = false;
}); });
t.Start(); t.Start();
} }
else {
IsStart = null;
AddLog("开始停止监控!");
}
} }
/// <summary> /// <summary>
@ -488,6 +542,66 @@ namespace JdShopListener
}); });
} }
break; break;
case ProType.Sku:
{
var data = list.Where(c => c.NewSkus != c.OldSkus).ToList();
data.ForEach(item =>
{
ItemData change = new ItemData()
{
Date = item.Date,
Desc = item.Desc,
ImgUrl = item.ImgUrl,
SkuId = item.SkuId
};
if (item.OldSkus == null)
{
item.OldSkus = "[]";
}
if (item.NewSkus == null)
{
item.NewSkus = "[]";
}
List<ProListModel> addSkus = new List<ProListModel>();
List<ProListModel> removeSkus = new List<ProListModel>();
var oldList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProListModel>>(item.OldSkus).Select(c => c.Title);
var newList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ProListModel>>(item.NewSkus).Select(c => c.Title);
foreach (var sku in newList)
{
//如果旧列表不存在就是新增
if (!oldList.Contains(sku))
{
addSkus.Add(new ProListModel() { Title=sku });
}
}
foreach (var sku in oldList)
{
//如果新列表没有就是删除
if (!newList.Contains(sku))
{
removeSkus.Add(new ProListModel() { Title = sku });
}
}
change.OldProList = removeSkus;
change.NewProList = addSkus;
Application.Current.Dispatcher.Invoke(() =>
{
ItemList.Add(change);
});
});
}
break;
} }
} }
@ -532,139 +646,176 @@ namespace JdShopListener
//开始监控全部 //开始监控全部
foreach (var sku in SkuList) foreach (var sku in SkuList)
{ {
var lastSku = LastItemChangeList.FirstOrDefault(c => c.SkuId == sku.SkuId); if (IsStart != true)
if(lastSku==null)
{ {
lastSku = new ItemChangeModel(); break;
} }
ItemChangeModel item = new ItemChangeModel() try
{ {
Date = DateTime.Now, var lastSku = LastItemChangeList.FirstOrDefault(c => c.SkuId == sku.SkuId);
Desc = sku.Desc,
ImgUrl = sku.ImgUrl,
SkuId = sku.SkuId
};
var result = GetWareBusiness(sku); if (lastSku == null)
{
lastSku = new ItemChangeModel();
}
//价格 ItemChangeModel item = new ItemChangeModel()
decimal? price = result.price.p; {
if (price == null || price == 0) Date = DateTime.Now,
{ Desc = sku.Desc,
price = result.price.op ?? 0; ImgUrl = sku.ImgUrl,
} SkuId = sku.SkuId
};
item.NewPrice = (decimal)price; var result = GetWareBusiness(sku);
#region 活动 //价格
var newActive = new List<object>(); decimal? price = result.price.p;
//活动 if (price == null || price == 0)
var miaoshaInfo = result.miaoshaInfo; {
//判断是否有活动 price = result.price.op ?? 0;
if (miaoshaInfo != null) }
{
string miaoshaTitle = miaoshaInfo.title;
DateTime endDate = ToDateTime((long)miaoshaInfo.endTime); item.NewPrice = (decimal)price;
decimal? msPrice = result.price.p; #region 活动
var newActive = new List<object>();
//活动
var miaoshaInfo = result.miaoshaInfo;
//判断是否有活动
if (miaoshaInfo != null)
{
string miaoshaTitle = miaoshaInfo.title;
newActive.Add(new { title= $"{miaoshaTitle} 价格:{msPrice} 结束时间:{endDate.ToString("yyyy-MM-dd")}", value=string.Empty }); DateTime endDate = ToDateTime((long)miaoshaInfo.endTime);
}
//活动 decimal? msPrice = result.price.p;
var yuyueInfo = result.yuyueInfo;
if (yuyueInfo != null)
{
string title = "预约抢购";
string time = yuyueInfo.buyTime; newActive.Add(new { title = $"{miaoshaTitle} 价格:{msPrice} 结束时间:{endDate.ToString("yyyy-MM-dd")}", value = string.Empty });
time = (time.Split("-")[3] + time.Split("-")[4] + time.Split("-")[5]); }
//DateTime endDate = ToDateTime((long)yuyueInfo.endTime);
decimal? msPrice = result.price.p; //活动
var yuyueInfo = result.yuyueInfo;
if (yuyueInfo != null)
{
string title = "预约抢购";
newActive.Add(new { title= $"{title} 价格:{msPrice} 结束时间:{time}", value=string.Empty }); string time = yuyueInfo.buyTime;
} time = (time.Split("-")[3] + time.Split("-")[4] + time.Split("-")[5]);
//DateTime endDate = ToDateTime((long)yuyueInfo.endTime);
item.NewActive = Newtonsoft.Json.JsonConvert.SerializeObject(newActive); decimal? msPrice = result.price.p;
#endregion
#region 促销 newActive.Add(new { title = $"{title} 价格:{msPrice} 结束时间:{time}", value = string.Empty });
}
var newPromotion = new List<object>(); item.NewActive = Newtonsoft.Json.JsonConvert.SerializeObject(newActive);
#endregion
//促销 #region 促销
var promotion = result.promotion;
if (promotion != null) var newPromotion = new List<object>();
{
//促销活动列表 //促销
var activity = promotion.activity; var promotion = result.promotion;
if (activity != null) if (promotion != null)
{ {
foreach (var active in activity) //促销活动列表
var activity = promotion.activity;
if (activity != null)
{ {
string title = active.text; foreach (var active in activity)
string value = active.value; {
newPromotion.Add(new { title, value }); string title = active.text;
string value = active.value;
newPromotion.Add(new { title, value });
}
} }
}
//赠品列表 //赠品列表
var gift = promotion.gift; var gift = promotion.gift;
if (gift != null) if (gift != null)
{
string title = "赠品";
string value = string.Empty;
foreach (var gif in gift)
{ {
value += gif.skuId + ",";
string title = "赠品";
string value = string.Empty;
foreach (var gif in gift)
{
value += gif.skuId + ",";
}
if (!string.IsNullOrEmpty(value))
{
newPromotion.Add(new { title, value });
}
} }
if (!string.IsNullOrEmpty(value)) item.NewPromotion = Newtonsoft.Json.JsonConvert.SerializeObject(newPromotion);
{ }
#endregion
newPromotion.Add(new { title, value }); #region 优惠券
var newCoupons = new List<object>();
//优惠券
var couponInfo = result.couponInfo;
if (couponInfo != null)
{
foreach (var coupon in couponInfo)
{
string title = $"满{coupon.quota}减{coupon.discount}";
newCoupons.Add(new { title, value = string.Empty });
} }
} }
item.NewPromotion = Newtonsoft.Json.JsonConvert.SerializeObject( newPromotion); item.NewCoupons = Newtonsoft.Json.JsonConvert.SerializeObject(newCoupons);
} #endregion
#endregion
#region 优惠券 #region sku
var newCoupons = new List<object>();
//优惠券 var newSkus = new List<object>();
var couponInfo = result.couponInfo;
if (couponInfo != null) var detail = GetItemDetail(item.SkuId);
{
foreach (var coupon in couponInfo) //相邻的Sku列表
var nearSkus = detail.product.colorSize;
foreach (var near in nearSkus)
{ {
string title = $"满{coupon.quota}减{coupon.discount}"; if (near != null)
newCoupons.Add(new { title, value = string.Empty }); {
newSkus.Add(new { title= near.skuId, value = string.Empty });
}
} }
} item.NewSkus = Newtonsoft.Json.JsonConvert.SerializeObject(newSkus);
#endregion
item.NewCoupons =Newtonsoft.Json.JsonConvert.SerializeObject( newCoupons); //判断是否有变化
#endregion if (lastSku.NewSkus!=item.NewSkus|| lastSku.NewActive != item.NewActive || lastSku.NewCoupons != item.NewCoupons || lastSku.NewPrice != item.NewPrice || lastSku.NewPromotion != item.NewPromotion)
{
//判断是否有变化 item.OldActive = lastSku.NewActive;
if (lastSku.NewActive != item.NewActive||lastSku.NewCoupons!=item.NewCoupons||lastSku.NewPrice!=item.NewPrice||lastSku.NewPromotion!=item.NewPromotion) item.OldCoupons = lastSku.NewCoupons;
{ item.OldPrice = lastSku.NewPrice;
item.OldActive = lastSku.NewActive; item.OldPromotion = lastSku.NewPromotion;
item.OldCoupons = lastSku.NewCoupons; item.OldSkus = lastSku.NewSkus;
item.OldPrice = lastSku.NewPrice;
item.OldPromotion = lastSku.NewPromotion;
DbHelper.Db.AddItemChangeModel(item); DbHelper.Db.AddItemChangeModel(item);
AddLog($"{sku.SkuId}监控完成!已产生变化记录");
}
else {
AddLog($"{sku.SkuId}监控完成!未发生变化");
}
Thread.Sleep(3000);
}
catch(Exception ex)
{
AddLog(sku.SkuId + "监控失败," + ex.Message);
} }
Thread.Sleep(3000);
} }
} }

27
JdShopListener/JdShopListener/Migrations/20210414042219_InitialCreate.Designer.cs → JdShopListener/JdShopListener/Migrations/20210418094901_InitialCreate.Designer.cs

@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace JdShopListener.Migrations namespace JdShopListener.Migrations
{ {
[DbContext(typeof(JdDBContext))] [DbContext(typeof(JdDBContext))]
[Migration("20210414042219_InitialCreate")] [Migration("20210418094901_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -33,31 +33,37 @@ namespace JdShopListener.Migrations
b.Property<string>("ImgUrl") b.Property<string>("ImgUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("NewActive")
.HasColumnType("TEXT");
b.Property<string>("NewCoupons")
.HasColumnType("TEXT");
b.Property<decimal>("NewPrice") b.Property<decimal>("NewPrice")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<decimal>("OldPrice") b.Property<string>("NewPromotion")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("SkuId") b.Property<string>("NewSkus")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("newActive") b.Property<string>("OldActive")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("newCoupons") b.Property<string>("OldCoupons")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("newPromotion") b.Property<decimal>("OldPrice")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("oldActive") b.Property<string>("OldPromotion")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("oldCoupons") b.Property<string>("OldSkus")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("oldPromotion") b.Property<string>("SkuId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@ -80,6 +86,9 @@ namespace JdShopListener.Migrations
b.Property<string>("ImgUrl") b.Property<string>("ImgUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("IsShow")
.HasColumnType("INTEGER");
b.Property<string>("ShopId") b.Property<string>("ShopId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");

17
JdShopListener/JdShopListener/Migrations/20210414042219_InitialCreate.cs → JdShopListener/JdShopListener/Migrations/20210418094901_InitialCreate.cs

@ -17,12 +17,14 @@ namespace JdShopListener.Migrations
ImgUrl = table.Column<string>(type: "TEXT", nullable: true), ImgUrl = table.Column<string>(type: "TEXT", nullable: true),
OldPrice = table.Column<decimal>(type: "TEXT", nullable: false), OldPrice = table.Column<decimal>(type: "TEXT", nullable: false),
NewPrice = table.Column<decimal>(type: "TEXT", nullable: false), NewPrice = table.Column<decimal>(type: "TEXT", nullable: false),
oldActive = table.Column<string>(type: "TEXT", nullable: true), OldActive = table.Column<string>(type: "TEXT", nullable: true),
newActive = table.Column<string>(type: "TEXT", nullable: true), NewActive = table.Column<string>(type: "TEXT", nullable: true),
oldPromotion = table.Column<string>(type: "TEXT", nullable: true), OldPromotion = table.Column<string>(type: "TEXT", nullable: true),
newPromotion = table.Column<string>(type: "TEXT", nullable: true), NewPromotion = table.Column<string>(type: "TEXT", nullable: true),
oldCoupons = table.Column<string>(type: "TEXT", nullable: true), OldCoupons = table.Column<string>(type: "TEXT", nullable: true),
newCoupons = table.Column<string>(type: "TEXT", nullable: true), NewCoupons = table.Column<string>(type: "TEXT", nullable: true),
NewSkus = table.Column<string>(type: "TEXT", nullable: true),
OldSkus = table.Column<string>(type: "TEXT", nullable: true),
Date = table.Column<DateTime>(type: "TEXT", nullable: false) Date = table.Column<DateTime>(type: "TEXT", nullable: false)
}, },
constraints: table => constraints: table =>
@ -42,7 +44,8 @@ namespace JdShopListener.Migrations
Cat = table.Column<string>(type: "TEXT", nullable: true), Cat = table.Column<string>(type: "TEXT", nullable: true),
Title = table.Column<string>(type: "TEXT", nullable: true), Title = table.Column<string>(type: "TEXT", nullable: true),
ShopId = table.Column<string>(type: "TEXT", nullable: true), ShopId = table.Column<string>(type: "TEXT", nullable: true),
VenderId = table.Column<string>(type: "TEXT", nullable: true) VenderId = table.Column<string>(type: "TEXT", nullable: true),
IsShow = table.Column<int>(type: "INTEGER", nullable: false)
}, },
constraints: table => constraints: table =>
{ {

25
JdShopListener/JdShopListener/Migrations/JdDBContextModelSnapshot.cs

@ -31,31 +31,37 @@ namespace JdShopListener.Migrations
b.Property<string>("ImgUrl") b.Property<string>("ImgUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("NewActive")
.HasColumnType("TEXT");
b.Property<string>("NewCoupons")
.HasColumnType("TEXT");
b.Property<decimal>("NewPrice") b.Property<decimal>("NewPrice")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<decimal>("OldPrice") b.Property<string>("NewPromotion")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("SkuId") b.Property<string>("NewSkus")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("newActive") b.Property<string>("OldActive")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("newCoupons") b.Property<string>("OldCoupons")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("newPromotion") b.Property<decimal>("OldPrice")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("oldActive") b.Property<string>("OldPromotion")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("oldCoupons") b.Property<string>("OldSkus")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<string>("oldPromotion") b.Property<string>("SkuId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@ -78,6 +84,9 @@ namespace JdShopListener.Migrations
b.Property<string>("ImgUrl") b.Property<string>("ImgUrl")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<int>("IsShow")
.HasColumnType("INTEGER");
b.Property<string>("ShopId") b.Property<string>("ShopId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");

3
JdShopListener/JdShopListener/Models/ItemChangeModel.cs

@ -67,7 +67,6 @@ namespace JdShopListener.Models
set { Set(ref _NewPrice, value); } set { Set(ref _NewPrice, value); }
} }
public string OldActive { get; set; } public string OldActive { get; set; }
public string NewActive { get; set; } public string NewActive { get; set; }
@ -83,6 +82,8 @@ namespace JdShopListener.Models
public string NewCoupons { get; set; } public string NewCoupons { get; set; }
public string NewSkus { get; set; }
public string OldSkus { get; set; }
private DateTime _Date; private DateTime _Date;
/// <summary> /// <summary>

6
JdShopListener/JdShopListener/Models/ProModel.cs

@ -43,6 +43,10 @@ namespace JdShopListener.Models
/// <summary> /// <summary>
/// 优惠券 /// 优惠券
/// </summary> /// </summary>
Coupons=4 Coupons=4,
/// <summary>
/// 相邻的SKu
/// </summary>
Sku = 5,
} }
} }

11
JdShopListener/JdShopListener/Models/SkuModel.cs

@ -96,5 +96,16 @@ namespace JdShopListener.Models
set { Set(ref _VenderId, value); } set { Set(ref _VenderId, value); }
} }
private int _IsShow;
/// <summary>
/// 是否显示
/// </summary>
public int IsShow
{
get { return _IsShow; }
set { Set(ref _IsShow, value); }
}
} }
} }

15
JdShopListener/JdShopListener/SqlHelpers/DbHelper.cs

@ -28,6 +28,21 @@ namespace JdShopListener.SqlHelpers
} }
} }
/// <summary>
/// 更新sku
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool UpdateSkuModel(SkuModel model)
{
using (var db = new JdDBContext())
{
db.SkuItems.Update(model);
var count = db.SaveChanges();
return count > 0;
}
}
/// <summary> /// <summary>
/// 批量添加sku监控 /// 批量添加sku监控
/// </summary> /// </summary>

BIN
JdShopListener/JdShopListener/db/items.db

Binary file not shown.
Loading…
Cancel
Save