25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

70 satır
2.8 KiB

  1. using HandyControl.Controls;
  2. using HKCardOUT.Logic.Model;
  3. using HKControl;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using XExten.Advance.LinqFramework;
  10. namespace HKCardOUT.Logic.Service
  11. {
  12. public class HKCore
  13. {
  14. /// <summary>
  15. /// 刷卡消费
  16. /// </summary>
  17. /// <param name="input"></param>
  18. /// <returns></returns>
  19. public bool DeviceSale(SaleLog input)
  20. {
  21. if (RemoteService.CheckCardStuatas(input.CardNo) != 1) return false;
  22. if (!Main.GetInstance.GetIsSwipe(input.Location.AsInt())) return false;
  23. var Old = DbContext.Context.Queryable<SaleLog>()
  24. .Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First();
  25. if (Old != null)
  26. {
  27. //10秒防止重复刷卡
  28. if (Old.CreateTime.Subtract(DateTime.Now).TotalSeconds > 10d)
  29. {
  30. var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
  31. if (entity.Id!=Guid.Empty)
  32. {
  33. var res = RemoteService.SyncSaleLog(input.CardNo, input.Money);
  34. Main.GetInstance.Start(input.Location.AsInt());
  35. DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
  36. return res;
  37. }
  38. }
  39. return false;
  40. }
  41. else
  42. {
  43. var entity = DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteReturnEntity();
  44. if (entity.Id!=Guid.Empty)
  45. {
  46. var res = RemoteService.SyncSaleLog(input.CardNo, input.Money);
  47. Main.GetInstance.Start(input.Location.AsInt());
  48. DbContext.Context.Updateable<SaleLog>().SetColumns(t => t.IsSync == true).Where(t => t.Id == entity.Id).ExecuteCommand();
  49. return res;
  50. }
  51. return false;
  52. }
  53. }
  54. /// <summary>
  55. /// 获取当天消费前100条展示
  56. /// </summary>
  57. /// <returns></returns>
  58. public List<SaleLog> PullDaySaleLog()
  59. {
  60. var Begin = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
  61. var End = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
  62. return DbContext.Context.Queryable<SaleLog>()
  63. .Where(t => t.CreateTime >= Begin)
  64. .Where(t => t.CreateTime < End)
  65. .OrderByDescending(t => t.CreateTime).ToPageList(0, 100);
  66. }
  67. }
  68. }