Browse Source

完成数据结构设计

master
С·æ 4 years ago
commit
6cfd7deaf2
  1. 3
      .gitignore
  2. 25
      JdShopListener/JdShopListener.sln
  3. 9
      JdShopListener/JdShopListener/App.xaml
  4. 17
      JdShopListener/JdShopListener/App.xaml.cs
  5. 10
      JdShopListener/JdShopListener/AssemblyInfo.cs
  6. 20
      JdShopListener/JdShopListener/JdDBContext.cs
  7. 14
      JdShopListener/JdShopListener/JdShopListener.csproj
  8. 14
      JdShopListener/JdShopListener/JdShopListener.csproj.user
  9. 303
      JdShopListener/JdShopListener/MainWindow.xaml
  10. 28
      JdShopListener/JdShopListener/MainWindow.xaml.cs
  11. 237
      JdShopListener/JdShopListener/MainWindowViewModel.cs
  12. 13
      JdShopListener/JdShopListener/Models/DateModel.cs
  13. 133
      JdShopListener/JdShopListener/Models/ItemChangeModel.cs
  14. 95
      JdShopListener/JdShopListener/Models/ItemData.cs
  15. 48
      JdShopListener/JdShopListener/Models/ProModel.cs
  16. 69
      JdShopListener/JdShopListener/Models/SkuModel.cs
  17. 29
      JdShopListener/JdShopListener/SqlHelpers/SkuModelSql.cs

3
.gitignore

@ -0,0 +1,3 @@
/JdShopListener/JdShopListener/obj
/JdShopListener/JdShopListener/bin
/JdShopListener/.vs

25
JdShopListener/JdShopListener.sln

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30804.86
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JdShopListener", "JdShopListener\JdShopListener.csproj", "{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {17EF939B-B35E-4DD1-98F5-A6A9829CE9BA}
EndGlobalSection
EndGlobal

9
JdShopListener/JdShopListener/App.xaml

@ -0,0 +1,9 @@
<Application x:Class="JdShopListener.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:JdShopListener"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

17
JdShopListener/JdShopListener/App.xaml.cs

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace JdShopListener
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

10
JdShopListener/JdShopListener/AssemblyInfo.cs

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

20
JdShopListener/JdShopListener/JdDBContext.cs

@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Text;
namespace JdShopListener
{
public class JdDBContext: DbContext
{
public DbSet<Models.SkuModel> SkuItems { get; set; }
public DbSet<Models.ItemChangeModel> ItemChanges { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=db/items.db");
}
}
}

14
JdShopListener/JdShopListener/JdShopListener.csproj

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MvvmLightLibsStd10" Version="5.4.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
</Project>

14
JdShopListener/JdShopListener/JdShopListener.csproj.user

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

303
JdShopListener/JdShopListener/MainWindow.xaml

@ -0,0 +1,303 @@
<Window x:Class="JdShopListener.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:JdShopListener"
mc:Ignorable="d"
DataContext="{x:Static local:MainWindowViewModel.MainViewModel}"
Title="MainWindow" Height="450" Width="800" >
<Window.Resources>
<Style
TargetType="{x:Type TabItem}">
<Setter Property="Header"
Value="{Binding Name}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Border x:Name="border"
BorderThickness="0.5 0.5 0.5 0.5"
BorderBrush="Gray"
Padding="20 3"
Margin="0 10">
<ContentPresenter x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{Binding HorizontalContentAlignment,
RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
VerticalAlignment="{Binding VerticalContentAlignment,
RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"
ContentSource="Header"
Focusable="False"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Self}}"
Value="true" />
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}"
Value="Top" />
</MultiDataTrigger.Conditions>
<Setter TargetName="border"
Property="Cursor"
Value="Hand" />
<Setter Property="BorderBrush"
Value="#007ACC" />
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}"
Value="true" />
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}"
Value="Top" />
</MultiDataTrigger.Conditions>
<Setter Property="Panel.ZIndex"
Value="1" />
<Setter Property="BorderBrush"
Value="#007ACC" />
<Setter Property="Foreground"
Value="#007ACC" />
<Setter Property="Background"
Value="#FFFFFF" />
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding IsEnabled, RelativeSource={RelativeSource Self}}"
Value="false" />
<Condition Binding="{Binding TabStripPlacement, RelativeSource={RelativeSource AncestorType={x:Type TabControl}}}"
Value="Top" />
</MultiDataTrigger.Conditions>
<Setter TargetName="contentPresenter"
Property="Opacity"
Value="0.56" />
</MultiDataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Grid x:Name="PART_Root">
<Border x:Name="Bg" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" />
<Grid x:Name="PART_InnerGrid">
<!--水印-->
<TextBlock x:Name="Message" Padding="{TemplateBinding Padding}" Visibility="Collapsed"
Text="{TemplateBinding Property=Tag}"
Foreground="Gray" IsHitTestVisible="False"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="5,2,5,2" />
<!--内容区域-->
<ScrollViewer x:Name="PART_ContentHost" BorderThickness="0" IsTabStop="False" Margin="2"
VerticalAlignment="Stretch" Background="{x:Null}" />
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="Text" Value="">
<Setter Property="Visibility" Value="Visible" TargetName="Message"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button">
<Setter Property="Padding" Value="20 0"></Setter>
<Setter Property="Margin" Value="10 0"></Setter>
</Style>
<Style TargetType="ListBox" x:Key="ListMenu">
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Name}"></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
<Setter Property="BorderThickness" Value="0"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="border" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="Blue" Padding="10 5">
<ContentPresenter/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="#007ACC"></Setter>
<Setter Property="BorderThickness" Value="0 0 0 1"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="#007ACC"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="ListBox" x:Key="ListPro">
<Setter Property="BorderBrush" Value="Transparent"></Setter>
<Setter Property="Background" Value="Transparent"></Setter>
<Setter Property="ItemTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding}"></TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemContainerStyle">
<Setter.Value>
<Style TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="border" BorderThickness="1" Margin="5 0 0 0" BorderBrush="Black" Padding="5 2">
<ContentPresenter/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<TabControl>
<TabItem Header="单品监控">
<DockPanel Margin="0 10">
<StackPanel DockPanel.Dock="Top">
<StackPanel Orientation="Horizontal">
<TextBox Tag="请输入SKu" Width="350" Text="{Binding Sku}"></TextBox>
<Button Content="添加" Command="{Binding Btn_Add}"></Button>
<Button Content="监控列表" Command="{Binding Btn_ShowList}"></Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox Tag="请输入备注" Text="{Binding Desc}" Width="350" Margin="0 10 0 0" HorizontalAlignment="Left"></TextBox>
<Button Content="开始监控" Command="{Binding Btn_Start}" Margin="10 10 0 0"></Button>
</StackPanel>
</StackPanel>
<Border DockPanel.Dock="Bottom" Margin="0 10 0 0">
<DockPanel>
<UniformGrid DockPanel.Dock="Top" Rows="1" Columns="2">
<ListBox ItemsSource="{Binding ProList}" SelectedItem="{Binding SelectPro}" HorizontalAlignment="Left" BorderBrush="Transparent" Style="{StaticResource ListMenu}">
</ListBox>
<ListBox ItemsSource="{Binding DateList}" SelectedItem="{Binding SelectDate}" HorizontalAlignment="Right" BorderBrush="Transparent" Style="{StaticResource ListMenu}">
</ListBox>
</UniformGrid>
<GroupBox Header="商品" DockPanel.Dock="Bottom">
<ListBox BorderBrush="Transparent" ItemsSource="{Binding ItemList}">
<ListBox.ItemTemplate>
<DataTemplate>
<DockPanel>
<StackPanel Orientation="Horizontal" Width="380" DockPanel.Dock="Left">
<Image Width="50" Height="50" Source="{Binding ImgUrl}"></Image>
<StackPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal">
<TextBlock Text="ID:"></TextBlock>
<TextBlock Text="{Binding SkuId}"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 10 0 0">
<TextBlock Text="备注:"></TextBlock>
<TextBlock Text="{Binding Desc}"></TextBlock>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel x:Name="sptext" Orientation="Horizontal" DockPanel.Dock="Right" Visibility="Collapsed">
<StackPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="原:" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding OldPro}"></TextBlock>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="新:" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding NewPro}"></TextBlock>
</StackPanel>
</StackPanel>
</StackPanel>
<StackPanel x:Name="spList" Orientation="Horizontal" DockPanel.Dock="Right">
<StackPanel VerticalAlignment="Center">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Text="原:" VerticalAlignment="Center"></TextBlock>
<ListBox Style="{StaticResource ListPro}" ItemsSource="{Binding OldProList}">
</ListBox>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBlock Text="新:" VerticalAlignment="Center"></TextBlock>
<ListBox Style="{StaticResource ListPro}" ItemsSource="{Binding NewProList}">
</ListBox>
</StackPanel>
</StackPanel>
</StackPanel>
</DockPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=DataContext.SelectPro.Type}" Value="1">
<Setter Property="Visibility" Value="Visible" TargetName="sptext"></Setter>
<Setter Property="Visibility" Value="Collapsed" TargetName="spList"></Setter>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</GroupBox>
</DockPanel>
</Border>
</DockPanel>
</TabItem>
<TabItem Header="店铺监控">
</TabItem>
</TabControl>
</Grid>
</Window>

28
JdShopListener/JdShopListener/MainWindow.xaml.cs

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace JdShopListener
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

237
JdShopListener/JdShopListener/MainWindowViewModel.cs

@ -0,0 +1,237 @@
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using JdShopListener.Models;
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Http;
namespace JdShopListener
{
public class MainWindowViewModel : ViewModelBase
{
private static MainWindowViewModel _mainWindowViewModel = new MainWindowViewModel();
public MainWindow Window;
public static MainWindowViewModel MainViewModel
{
get
{
return _mainWindowViewModel;
}
}
public MainWindowViewModel() {
ProList = new System.Collections.ObjectModel.ObservableCollection<ProModel>() {
new ProModel(){ Name="价格" , Type= ProType.Price},
new ProModel(){ Name="活动" , Type= ProType.Active},
new ProModel(){ Name="促销" , Type= ProType.Promotion},
new ProModel(){ Name="优惠券" , Type= ProType.Coupons}
};
DateList = new System.Collections.ObjectModel.ObservableCollection<DateModel>() {
new DateModel(){ Name="今天",Day=0 },
new DateModel(){ Name="昨天",Day=-1 },
new DateModel(){ Name="前天",Day=-2 }
};
Btn_Add = new RelayCommand(Add);
Btn_ShowList = new RelayCommand(ShowList);
Btn_Start = new RelayCommand(Start);
ItemList = new System.Collections.ObjectModel.ObservableCollection<ItemData>() {
new ItemData(){ Desc="测试", OldPro="100",NewPro="120",SkuId="123123",OldProList=new List<string>(){ "满额返券","换购" } ,NewProList =new List<string>(){ "满额返券", "多买优惠" } },
new ItemData(){Desc="测试", OldPro="120",NewPro="111",SkuId="123123",OldProList=new List<string>(){ "满额返券","换购" } ,NewProList =new List<string>(){ "满额返券", "多买优惠", "换购" } }
};
SkuList = new System.Collections.ObjectModel.ObservableCollection<SkuModel>();
}
private System.Collections.ObjectModel.ObservableCollection<ProModel> _ProList;
/// <summary>
/// 属性列表
/// </summary>
public System.Collections.ObjectModel.ObservableCollection<ProModel> ProList
{
get { return _ProList; }
set { Set(ref _ProList, value); }
}
private System.Collections.ObjectModel.ObservableCollection<DateModel> _DateList;
/// <summary>
/// 日期
/// </summary>
public System.Collections.ObjectModel.ObservableCollection<DateModel> DateList
{
get { return _DateList; }
set { Set(ref _DateList, value); }
}
private ProModel _SelectPro;
/// <summary>
/// 选中的属性
/// </summary>
public ProModel SelectPro
{
get { return _SelectPro; }
set { Set(ref _SelectPro, value); }
}
private DateModel _SelectDate;
/// <summary>
/// 选中的日期
/// </summary>
public DateModel SelectDate
{
get { return _SelectDate; }
set { Set(ref _SelectDate, value); }
}
private System.Collections.ObjectModel.ObservableCollection<ItemData> _ItemList;
/// <summary>
/// 商品变化列表
/// </summary>
public System.Collections.ObjectModel.ObservableCollection<ItemData> ItemList
{
get { return _ItemList; }
set { Set(ref _ItemList, value); }
}
private System.Collections.ObjectModel.ObservableCollection<SkuModel> _SkuList;
/// <summary>
/// sku监控列表
/// </summary>
public System.Collections.ObjectModel.ObservableCollection<SkuModel> SkuList
{
get { return _SkuList; }
set { Set(ref _SkuList, value); }
}
private string _Sku;
/// <summary>
/// 添加的Sku
/// </summary>
public string Sku
{
get { return _Sku; }
set { Set(ref _Sku, value); }
}
private string _Desc;
/// <summary>
/// 添加的备注
/// </summary>
public string Desc
{
get { return _Desc; }
set { Set(ref _Desc, value); }
}
/// <summary>
/// 添加事件
/// </summary>
public RelayCommand Btn_Add { get; set; }
/// <summary>
/// 打开监控列表
/// </summary>
public RelayCommand Btn_ShowList { get; set; }
/// <summary>
/// 开始
/// </summary>
public RelayCommand Btn_Start { get; set; }
/// <summary>
/// 添加
/// </summary>
public void Add()
{
var detail= GetItemDetail("69920799280");
var list = detail.product.colorSize;
//spuId
string spuId = detail.product.mainSkuId;
//主图
string src = detail.product.src;
//标题
string title = detail.product.name;
foreach (var sku in list)
{
SkuModel model = new SkuModel()
{
Desc = Desc,
SkuId = sku.skuId,
SpuId=spuId
};
//加入本地数据库
SkuList.Add(model);
}
}
/// <summary>
/// 打开监控列表
/// </summary>
public void ShowList()
{
}
/// <summary>
/// 开始
/// </summary>
public void Start()
{
}
/// <summary>
/// 根据Sku获取详情
/// </summary>
/// <param name="skuId"></param>
/// <returns></returns>
public dynamic GetItemDetail(string skuId)
{
try
{
HttpClient http = new HttpClient();
string html = http.GetStringAsync($"https://item.jd.com/{skuId}.html").Result;
int start = html.IndexOf("var pageConfig");
int end = html.IndexOf("};", start);
string json = html.Substring(start, end - start);
start = json.IndexOf("{");
json = json.Substring(start, json.Length - start);
json += "}";
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(json);
return data;
}
catch (Exception ex)
{
return null;
}
}
}
}

13
JdShopListener/JdShopListener/Models/DateModel.cs

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace JdShopListener.Models
{
public class DateModel
{
public string Name { get; set; }
public int Day { get; set; }
}
}

133
JdShopListener/JdShopListener/Models/ItemChangeModel.cs

@ -0,0 +1,133 @@
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace JdShopListener.Models
{
/// <summary>
/// 商品变化
/// </summary>
[Table("ItemChange")]
public class ItemChangeModel:ViewModelBase
{
public Guid Id { get; set; }
private string _SpuId;
/// <summary>
/// spu
/// </summary>
public string SpuId
{
get { return _SpuId; }
set { Set(ref _SpuId, value); }
}
private string _Desc;
/// <summary>
/// 备注
/// </summary>
public string Desc
{
get { return _Desc; }
set { Set(ref _Desc, value); }
}
private decimal _OldPrice;
/// <summary>
/// 原价格
/// </summary>
public decimal OldPrice
{
get { return _OldPrice; }
set { Set(ref _OldPrice, value); }
}
private decimal _NewPrice;
/// <summary>
/// 新价格
/// </summary>
public decimal NewPrice
{
get { return _NewPrice; }
set { Set(ref _NewPrice, value); }
}
private List<string> _OldActive;
/// <summary>
/// 旧活动
/// </summary>
public List<string> OldActive
{
get { return _OldActive; }
set { Set(ref _OldActive, value); }
}
private List<string> _NewActive;
/// <summary>
/// 新活动
/// </summary>
public List<string> NewActive
{
get { return _NewActive; }
set { Set(ref _NewActive, value); }
}
private List<string> _OldPromotion;
/// <summary>
/// 旧促销
/// </summary>
public List<string> OldPromotion
{
get { return _OldPromotion; }
set { Set(ref _OldPromotion, value); }
}
private List<string> _NewPromotion;
/// <summary>
/// 新促销
/// </summary>
public List<string> NewPromotion
{
get { return _NewPromotion; }
set { Set(ref _NewPromotion, value); }
}
private List<string> _OldCoupons;
/// <summary>
/// 旧优惠券
/// </summary>
public List<string> OldCoupons
{
get { return _OldCoupons; }
set { Set(ref _OldCoupons, value); }
}
private List<string> _NewCoupons;
/// <summary>
/// 新优惠券
/// </summary>
public List<string> NewCoupons
{
get { return _NewCoupons; }
set { Set(ref _NewCoupons, value); }
}
private DateTime _Date;
/// <summary>
/// 日期
/// </summary>
public DateTime Date
{
get { return _Date; }
set { Set(ref _Date, value); }
}
}
}

95
JdShopListener/JdShopListener/Models/ItemData.cs

@ -0,0 +1,95 @@
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Text;
namespace JdShopListener.Models
{
public class ItemData : ViewModelBase
{
private List<string> _OldProList;
/// <summary>
/// 旧的数据变化集合
/// </summary>
public List<string> OldProList
{
get { return _OldProList; }
set { Set(ref _OldProList, value); }
}
private List<string> _NewProList;
/// <summary>
/// 新的数据变化集合
/// </summary>
public List<string> NewProList
{
get { return _NewProList; }
set { Set(ref _NewProList, value); }
}
private string _ImgUrl;
/// <summary>
/// 图片地址
/// </summary>
public string ImgUrl
{
get { return _ImgUrl; }
set { Set(ref _ImgUrl, value); }
}
private string _SkuId;
/// <summary>
/// Sku
/// </summary>
public string SkuId
{
get { return _SkuId; }
set { Set(ref _SkuId, value); }
}
private string _Desc;
/// <summary>
/// 备注
/// </summary>
public string Desc
{
get { return _Desc; }
set { Set(ref _Desc, value); }
}
private string _OldPro;
/// <summary>
/// 旧的字符串变化
/// </summary>
public string OldPro
{
get { return _OldPro; }
set { Set(ref _OldPro, value); }
}
private string _NewPro;
/// <summary>
/// 新的字符串变化
/// </summary>
public string NewPro
{
get { return _NewPro; }
set { Set(ref _NewPro, value); }
}
private DateTime _Date;
/// <summary>
/// 变化时间
/// </summary>
public DateTime Date
{
get { return _Date; }
set { Set(ref _Date, value); }
}
}
}

48
JdShopListener/JdShopListener/Models/ProModel.cs

@ -0,0 +1,48 @@
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Text;
namespace JdShopListener.Models
{
/// <summary>
/// 属性
/// </summary>
public class ProModel:ViewModelBase
{
/// <summary>
/// 类型
/// </summary>
public ProType Type { get; set; }
/// <summary>
/// 名称
/// </summary>
public string Name { get; set; }
}
/// <summary>
/// 属性类型
/// </summary>
public enum ProType
{
/// <summary>
/// 价格
/// </summary>
Price=1,
/// <summary>
/// 活动
/// </summary>
Active=2,
/// <summary>
/// 促销
/// </summary>
Promotion=3,
/// <summary>
/// 优惠券
/// </summary>
Coupons=4
}
}

69
JdShopListener/JdShopListener/Models/SkuModel.cs

@ -0,0 +1,69 @@
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace JdShopListener.Models
{
[Table("SkuModel")]
public class SkuModel:ViewModelBase
{
public Guid Id { get; set; }
private string _SkuId;
/// <summary>
/// Sku
/// </summary>
public string SkuId
{
get { return _SkuId; }
set { Set(ref _SkuId, value); }
}
private string _ImgUrl;
/// <summary>
/// 商品主图
/// </summary>
public string ImgUrl
{
get { return _ImgUrl; }
set { Set(ref _ImgUrl, value); }
}
private string _SpuId;
/// <summary>
/// Spu
/// </summary>
public string SpuId
{
get { return _SpuId; }
set { Set(ref _SpuId, value); }
}
private string _Desc;
/// <summary>
/// 备注
/// </summary>
public string Desc
{
get { return _Desc; }
set { Set(ref _Desc, value); }
}
private string _Title;
/// <summary>
/// 标题
/// </summary>
public string Title
{
get { return _Title; }
set { Set(ref _Title, value); }
}
}
}

29
JdShopListener/JdShopListener/SqlHelpers/SkuModelSql.cs

@ -0,0 +1,29 @@
using JdShopListener.Models;
using System;
using System.Collections.Generic;
using System.Text;
namespace JdShopListener.SqlHelpers
{
public class SkuModelSql
{
/// <summary>
/// 添加sku监控
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddSkuModel(SkuModel model)
{
using (var db = new JdDBContext())
{
model.Id = Guid.NewGuid();
db.SkuItems.Add(model);
var count = db.SaveChanges();
return count > 0;
}
}
}
}
Loading…
Cancel
Save