You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB

  1. using HKCardOUT.Logic.Model;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace HKCardOUT.Logic.Service
  8. {
  9. public class HKCore
  10. {
  11. /// <summary>
  12. /// 刷卡消费
  13. /// </summary>
  14. /// <param name="input"></param>
  15. /// <returns></returns>
  16. public bool DeviceSale(SaleLog input)
  17. {
  18. var Old = DbContext.Context.Queryable<SaleLog>()
  19. .Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First();
  20. if (Old != null)
  21. {
  22. //10秒防止重复刷卡
  23. if (Old.CreateTime.Subtract(DateTime.Now).TotalSeconds > 10d)
  24. {
  25. return DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0;
  26. }
  27. return false;
  28. }
  29. else
  30. return DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0;
  31. }
  32. /// <summary>
  33. /// 获取当天消费前100条展示
  34. /// </summary>
  35. /// <returns></returns>
  36. public List<SaleLog> PullDaySaleLog()
  37. {
  38. var Begin = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  39. var End = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  40. return DbContext.Context.Queryable<SaleLog>()
  41. .Where(t => t.CreateTime >= Begin)
  42. .Where(t => t.CreateTime < End)
  43. .OrderByDescending(t => t.CreateTime).ToPageList(0, 100);
  44. }
  45. }
  46. }