|
|
@@ -0,0 +1,48 @@ |
|
|
|
using HKCardOUT.Logic.Model; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
namespace HKCardOUT.Logic.Service |
|
|
|
{ |
|
|
|
public class HKCore |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
/// 刷卡消费 |
|
|
|
/// </summary> |
|
|
|
/// <param name="input"></param> |
|
|
|
/// <returns></returns> |
|
|
|
public bool DeviceSale(SaleLog input) |
|
|
|
{ |
|
|
|
var Old = DbContext.Context.Queryable<SaleLog>() |
|
|
|
.Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First(); |
|
|
|
if (Old != null) |
|
|
|
{ |
|
|
|
//10秒防止重复刷卡 |
|
|
|
if (Old.CreateTime.Subtract(DateTime.Now).TotalSeconds > 10d) |
|
|
|
{ |
|
|
|
return DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
else |
|
|
|
return DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0; |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 获取当天消费前100条展示 |
|
|
|
/// </summary> |
|
|
|
/// <returns></returns> |
|
|
|
public List<SaleLog> PullDaySaleLog() |
|
|
|
{ |
|
|
|
var Begin = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00")); |
|
|
|
var End = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59")); |
|
|
|
return DbContext.Context.Queryable<SaleLog>() |
|
|
|
.Where(t => t.CreateTime >= Begin) |
|
|
|
.Where(t => t.CreateTime < End) |
|
|
|
.OrderByDescending(t => t.CreateTime).ToPageList(0, 10); |
|
|
|
} |
|
|
|
} |
|
|
|
} |