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
{
///
/// 刷卡消费
///
///
///
public bool DeviceSale(SaleLog input)
{
var Old = DbContext.Context.Queryable()
.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;
}
///
/// 获取当天消费前100条展示
///
///
public List 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()
.Where(t => t.CreateTime >= Begin)
.Where(t => t.CreateTime < End)
.OrderByDescending(t => t.CreateTime).ToPageList(0, 100);
}
}
}