@@ -1,36 +0,0 @@ | |||||
using HKCardIN.Helper; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Linq; | |||||
using System.IO.Ports; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | |||||
namespace COM | |||||
{ | |||||
public class COMHelper : Singleton<COMHelper> | |||||
{ | |||||
public SerialPort serialPort; | |||||
public void OpenCOM(string input) | |||||
{ | |||||
serialPort = new SerialPort(input, 9600, Parity.None, 8, StopBits.One); | |||||
//数据接收 | |||||
serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived); | |||||
serialPort.ReceivedBytesThreshold = 1; | |||||
serialPort.RtsEnable = true; | |||||
try | |||||
{ | |||||
if (serialPort.IsOpen) return; | |||||
serialPort.Open(); | |||||
} | |||||
catch { } | |||||
} | |||||
/// 数据接收事件 | |||||
private void DataReceived(object sender, SerialDataReceivedEventArgs e) | |||||
{ | |||||
byte[] readBuffer = new byte[serialPort.ReadBufferSize]; | |||||
serialPort.Read(readBuffer, 0, readBuffer.Length); | |||||
string str = Encoding.Default.GetString(readBuffer); | |||||
} | |||||
} | |||||
} |
@@ -33,13 +33,13 @@ | |||||
<PackageReference Include="HandyControls" Version="3.4.1" /> | <PackageReference Include="HandyControls" Version="3.4.1" /> | ||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> | <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> | ||||
<PackageReference Include="Stylet" Version="1.3.6" /> | <PackageReference Include="Stylet" Version="1.3.6" /> | ||||
<PackageReference Include="System.IO.Ports" Version="6.0.0" /> | |||||
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> | <PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> | ||||
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> | <PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> | ||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | <PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<ProjectReference Include="..\HKLog\HKLog.csproj" /> | <ProjectReference Include="..\HKLog\HKLog.csproj" /> | ||||
<ProjectReference Include="..\UHFHelper\UHFHelper.csproj" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
<Resource Include="HKResouces\头像.png" /> | <Resource Include="HKResouces\头像.png" /> | ||||
@@ -26,5 +26,9 @@ namespace HKCardIN.Helper | |||||
/// 推送充值到服务器 | /// 推送充值到服务器 | ||||
/// </summary> | /// </summary> | ||||
public static string PushMoneyToServer = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge"; | public static string PushMoneyToServer = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge"; | ||||
/// <summary> | |||||
/// 根据会员手机获取卡号 | |||||
/// </summary> | |||||
public static string GetCardNoByPhone = DataBus.SaasRoute + "api/"; | |||||
} | } | ||||
} | } |
@@ -41,5 +41,17 @@ namespace HKCardIN.Logic | |||||
}).Build().RunStringFirst(); | }).Build().RunStringFirst(); | ||||
return bool.Parse(data.ToModel<JObject>()["data"].ToString()); | return bool.Parse(data.ToModel<JObject>()["data"].ToString()); | ||||
} | } | ||||
/// <summary> | |||||
/// 根据会员手机获取卡号 | |||||
/// </summary> | |||||
/// <param name="Phone"></param> | |||||
/// <returns></returns> | |||||
public string GetCardNoByPhone(string Phone) | |||||
{ | |||||
var data = IHttpMultiClient.HttpMulti.AddNode(t => { | |||||
t.NodePath = ApiRoute.GetCardNoByPhone; | |||||
}).Build().RunStringFirst(); | |||||
return data; | |||||
} | |||||
} | } | ||||
} | } |
@@ -1,11 +1,16 @@ | |||||
using HKCardIN.Helper; | |||||
using HandyControl.Data; | |||||
using HKCardIN.Helper; | |||||
using HKCardIN.Logic; | using HKCardIN.Logic; | ||||
using HKCardIN.Logic.Model; | using HKCardIN.Logic.Model; | ||||
using HKCardIN.Views; | |||||
using HKLog; | |||||
using Stylet; | using Stylet; | ||||
using System; | using System; | ||||
using System.Text.RegularExpressions; | |||||
using System.Threading; | using System.Threading; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows; | using System.Windows; | ||||
using UHFHelper; | |||||
namespace HKCardIN.ViewModels | namespace HKCardIN.ViewModels | ||||
{ | { | ||||
@@ -64,6 +69,44 @@ namespace HKCardIN.ViewModels | |||||
#endregion | #endregion | ||||
#region 命令 | #region 命令 | ||||
public void ReadAction() | |||||
{ | |||||
if (!UHFCardHelper.GetInstance().ComOpen) | |||||
{ | |||||
var res = UHFCardHelper.GetInstance().OpenPort(); | |||||
HKLogImport.WriteInfo(res.ResMes); | |||||
} | |||||
var RCardNo = UHFCardHelper.GetInstance().ReadCard(); | |||||
if (!Regex.IsMatch(RCardNo, "\\d{19}")) | |||||
{ | |||||
var res = HandyControl.Controls.MessageBox.Show(new MessageBoxInfo | |||||
{ | |||||
Button = MessageBoxButton.YesNo, | |||||
IconKey = "InfoGeometry", | |||||
IconBrushKey = "InfoBrush", | |||||
YesContent = "是", | |||||
NoContent = "否", | |||||
Message = "此卡是新卡,前往制卡", | |||||
Caption = "提示!" | |||||
}); | |||||
if (res == MessageBoxResult.Yes) | |||||
{ | |||||
CardView view = new CardView(); | |||||
if (view.ShowDialog().Value) HandyControl.Controls.Growl.InfoGlobal("制卡成功"); | |||||
else HandyControl.Controls.Growl.InfoGlobal("制卡失败"); | |||||
} | |||||
Info = BaseLogic.GetInstance().PullUserAndCardInfo(CardNo); | |||||
UHFCardHelper.GetInstance().ClosePort(); | |||||
} | |||||
else | |||||
{ | |||||
CardNo = RCardNo; | |||||
Info = BaseLogic.GetInstance().PullUserAndCardInfo(CardNo); | |||||
UHFCardHelper.GetInstance().ClosePort(); | |||||
} | |||||
} | |||||
public void InputAction(string input) | public void InputAction(string input) | ||||
{ | { | ||||
if (IsLocker) return; | if (IsLocker) return; | ||||
@@ -110,7 +153,6 @@ namespace HKCardIN.ViewModels | |||||
protected override void OnViewLoaded() | protected override void OnViewLoaded() | ||||
{ | { | ||||
MainThread(); | MainThread(); | ||||
//Info = BaseLogic.GetInstance().PullUserAndCardInfo("1569245210230263808"); | |||||
} | } | ||||
private void MainThread() | private void MainThread() | ||||
{ | { | ||||
@@ -0,0 +1,49 @@ | |||||
<Window | |||||
x:Class="HKCardIN.Views.CardView" | |||||
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:hc="https://handyorg.github.io/handycontrol" | |||||
xmlns:local="clr-namespace:HKCardIN.Views" | |||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||||
Title="海科智慧一卡通平台" | |||||
Width="300" | |||||
Height="200" | |||||
ResizeMode="CanMinimize" | |||||
WindowStartupLocation="CenterScreen" | |||||
mc:Ignorable="d"> | |||||
<Window.Background> | |||||
<ImageBrush ImageSource="/HKResouces/背景.jpg" /> | |||||
</Window.Background> | |||||
<WrapPanel | |||||
HorizontalAlignment="Center" | |||||
VerticalAlignment="Center" | |||||
Orientation="Vertical"> | |||||
<TextBox | |||||
x:Name="Phone" | |||||
Width="200" | |||||
hc:InfoElement.Placeholder="请输入手机号" | |||||
Style="{StaticResource TextBoxExtend}" /> | |||||
<WrapPanel Margin="0,10,0,0" HorizontalAlignment="Center"> | |||||
<Button | |||||
x:Name="Query" | |||||
Width="80" | |||||
Height="50" | |||||
Margin="0,0,10,0" | |||||
Click="QueryClick" | |||||
Content="查询" | |||||
FontSize="18" | |||||
Style="{StaticResource ButtonDefault}" /> | |||||
<Button | |||||
x:Name="Create" | |||||
Width="80" | |||||
Height="50" | |||||
Margin="10,0,0,0" | |||||
Click="CreateClick" | |||||
Content="制卡" | |||||
FontSize="18" | |||||
IsEnabled="False" | |||||
Style="{StaticResource ButtonDefault}" /> | |||||
</WrapPanel> | |||||
</WrapPanel> | |||||
</Window> |
@@ -0,0 +1,35 @@ | |||||
using HKLog; | |||||
using System.Text.RegularExpressions; | |||||
using System.Windows; | |||||
using UHFHelper; | |||||
using XExten.Advance.LinqFramework; | |||||
namespace HKCardIN.Views | |||||
{ | |||||
/// <summary> | |||||
/// CardView.xaml 的交互逻辑 | |||||
/// </summary> | |||||
public partial class CardView : System.Windows.Window | |||||
{ | |||||
public CardView() | |||||
{ | |||||
InitializeComponent(); | |||||
} | |||||
private void QueryClick(object sender, RoutedEventArgs e) | |||||
{ | |||||
if (this.Phone.Text.IsNullOrEmpty()) HandyControl.Controls.Growl.InfoGlobal("手机号不能为空!"); | |||||
if (!Regex.IsMatch(this.Phone.Text, "\\d{11}")) HandyControl.Controls.Growl.InfoGlobal("请输入正确的手机号!"); | |||||
//查询接口 | |||||
Create.IsEnabled = true; | |||||
} | |||||
private void CreateClick(object sender, RoutedEventArgs e) | |||||
{ | |||||
var res = UHFCardHelper.GetInstance().WriteCard("1569245210230263808"); | |||||
HKLogImport.WriteInfo(res.ResMes); | |||||
DialogResult = true; | |||||
Close(); | |||||
} | |||||
} | |||||
} |
@@ -10,8 +10,8 @@ | |||||
xmlns:viewModels="clr-namespace:HKCardIN.ViewModels" | xmlns:viewModels="clr-namespace:HKCardIN.ViewModels" | ||||
x:Name="Root" | x:Name="Root" | ||||
Title="海科智慧一卡通平台" | Title="海科智慧一卡通平台" | ||||
Width="800" | |||||
Height="460" | |||||
Width="900" | |||||
Height="480" | |||||
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}" | d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}" | ||||
ResizeMode="CanMinimize" | ResizeMode="CanMinimize" | ||||
WindowStartupLocation="CenterScreen" | WindowStartupLocation="CenterScreen" | ||||
@@ -52,6 +52,7 @@ | |||||
Key="E" | Key="E" | ||||
Command="{s:Action UnLockAction}" | Command="{s:Action UnLockAction}" | ||||
CommandParameter="{Binding ., ElementName=Pwd}" /> | CommandParameter="{Binding ., ElementName=Pwd}" /> | ||||
<KeyBinding Key="R" Command="{s:Action ReadAction}" /> | |||||
<KeyBinding | <KeyBinding | ||||
Key="F1" | Key="F1" | ||||
Command="{s:Action InputAction}" | Command="{s:Action InputAction}" | ||||
@@ -301,6 +302,11 @@ | |||||
FontWeight="Bold" | FontWeight="Bold" | ||||
Foreground="WhiteSmoke" /> | Foreground="WhiteSmoke" /> | ||||
<WrapPanel HorizontalAlignment="Center"> | <WrapPanel HorizontalAlignment="Center"> | ||||
<Button | |||||
Command="{s:Action ReadAction}" | |||||
Content="读卡[R]" | |||||
IsDefault="True" | |||||
Style="{StaticResource 操作}" /> | |||||
<Button | <Button | ||||
Command="{s:Action SaveAction}" | Command="{s:Action SaveAction}" | ||||
Content="确定[Enter]" | Content="确定[Enter]" | ||||
@@ -1,34 +0,0 @@ | |||||
using HKCardOUT.Helper; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.IO.Ports; | |||||
using System.Text; | |||||
namespace COM | |||||
{ | |||||
public class COMHelper : Singleton<COMHelper> | |||||
{ | |||||
public SerialPort serialPort; | |||||
public void OpenCOM() | |||||
{ | |||||
serialPort = new SerialPort("COM3", 9600, Parity.None, 8, StopBits.One); | |||||
//数据接收 | |||||
serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived); | |||||
serialPort.ReceivedBytesThreshold = 1; | |||||
serialPort.RtsEnable = true; | |||||
try | |||||
{ | |||||
if (serialPort.IsOpen) return; | |||||
serialPort.Open(); | |||||
} | |||||
catch { } | |||||
} | |||||
/// 数据接收事件 | |||||
private void DataReceived(object sender, SerialDataReceivedEventArgs e) | |||||
{ | |||||
byte[] readBuffer = new byte[serialPort.ReadBufferSize]; | |||||
serialPort.Read(readBuffer, 0, readBuffer.Length); | |||||
string str = Encoding.Default.GetString(readBuffer); | |||||
} | |||||
} | |||||
} |
@@ -38,7 +38,6 @@ | |||||
<PackageReference Include="Quartz" Version="3.4.0" /> | <PackageReference Include="Quartz" Version="3.4.0" /> | ||||
<PackageReference Include="Stylet" Version="1.3.6" /> | <PackageReference Include="Stylet" Version="1.3.6" /> | ||||
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> | <PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> | ||||
<PackageReference Include="System.IO.Ports" Version="6.0.0" /> | |||||
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> | <PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> | ||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -16,11 +16,6 @@ namespace HKCardOUT.Logic.Model | |||||
[SugarColumn(IsNullable = false)] | [SugarColumn(IsNullable = false)] | ||||
public string CardNo { get; set; } | public string CardNo { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 消费金额 | |||||
/// </summary> | |||||
[SugarColumn(IsNullable = false, ColumnDataType = "decimal(10,2)")] | |||||
public decimal Money { get; set; } | |||||
/// <summary> | |||||
/// 消费位置 | /// 消费位置 | ||||
/// </summary> | /// </summary> | ||||
[SugarColumn(IsNullable = false)] | [SugarColumn(IsNullable = false)] | ||||
@@ -59,6 +59,10 @@ namespace Logic.RemoteModel | |||||
/// </summary> | /// </summary> | ||||
public string GateId { get; set; } | public string GateId { get; set; } | ||||
/// <summary> | /// <summary> | ||||
/// 地址 | |||||
/// </summary> | |||||
public string Address { get; set; } | |||||
/// <summary> | |||||
/// 刷卡间隔时间 | /// 刷卡间隔时间 | ||||
/// </summary> | /// </summary> | ||||
public int SleepTime { get; set; } | public int SleepTime { get; set; } | ||||
@@ -31,12 +31,12 @@ namespace HKCardOUT.Logic | |||||
/// </summary> | /// </summary> | ||||
/// <param name="CardNo"></param> | /// <param name="CardNo"></param> | ||||
/// <param name="Money"></param> | /// <param name="Money"></param> | ||||
public static bool SyncSaleLog(string CardNo, decimal Money) | |||||
public static bool SyncSaleLog(string CardNo, string StallId) | |||||
{ | { | ||||
var data = IHttpMultiClient.HttpMulti.AddNode(t => | var data = IHttpMultiClient.HttpMulti.AddNode(t => | ||||
{ | { | ||||
t.ReqType = MultiType.POST; | t.ReqType = MultiType.POST; | ||||
t.JsonParam = (new { Money, Type = -1, CardNum = CardNo }).ToJson(); | |||||
t.JsonParam = (new { GateId=StallId, Type = -1, CardNum = CardNo }).ToJson(); | |||||
t.NodePath = ApiRoute.SyncSaleLog; | t.NodePath = ApiRoute.SyncSaleLog; | ||||
}).Build().RunStringFirst(); | }).Build().RunStringFirst(); | ||||
return bool.Parse(data.ToModel<JObject>()["data"].ToString()); | return bool.Parse(data.ToModel<JObject>()["data"].ToString()); | ||||
@@ -31,7 +31,7 @@ namespace HKCardOUT.Logic.Service | |||||
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); | var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); | ||||
if (entity.Id!=Guid.Empty) | if (entity.Id!=Guid.Empty) | ||||
{ | { | ||||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Money); | |||||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); | |||||
Main.GetInstance.Start(input.Location.AsInt()); | Main.GetInstance.Start(input.Location.AsInt()); | ||||
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); | DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); | ||||
return res; | return res; | ||||
@@ -44,7 +44,7 @@ namespace HKCardOUT.Logic.Service | |||||
var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); | var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity(); | ||||
if (entity.Id!=Guid.Empty) | if (entity.Id!=Guid.Empty) | ||||
{ | { | ||||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Money); | |||||
var res = RemoteService.SyncSaleLog(input.CardNo, input.Location); | |||||
Main.GetInstance.Start(input.Location.AsInt()); | Main.GetInstance.Start(input.Location.AsInt()); | ||||
DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); | DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand(); | ||||
return res; | return res; | ||||
@@ -4,7 +4,7 @@ | |||||
<TargetFramework>net6.0</TargetFramework> | <TargetFramework>net6.0</TargetFramework> | ||||
<ImplicitUsings>enable</ImplicitUsings> | <ImplicitUsings>enable</ImplicitUsings> | ||||
<Nullable>enable</Nullable> | <Nullable>enable</Nullable> | ||||
<Platforms>AnyCPU;x86</Platforms> | |||||
<Platforms>x86</Platforms> | |||||
</PropertyGroup> | </PropertyGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||