PosManager.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using SinochemPosClient;
  2. using SinochemPosClient.Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Configuration;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Wayne.Lib.Log;
  10. namespace SinochemInternetPlusApp
  11. {
  12. public class PosManager
  13. {
  14. private readonly string UrlPrefix = App.AppSettings["SinochemPosUrlPrefix"];
  15. private readonly string TrxNotifyApi = App.AppSettings["SinochemPosNotifyApi"];
  16. public TrxNotificationResponse NotifyPosSuccessfulTrx(EpsTransactionModel epsTrxModel, DebugLogger debugLogger)
  17. {
  18. PosCommunicator<TrxNotificationRequest, TrxNotificationResponse> communicator =
  19. new PosCommunicator<TrxNotificationRequest, TrxNotificationResponse>(UrlPrefix + TrxNotifyApi);
  20. TrxNotificationRequest request = new TrxNotificationRequest
  21. {
  22. ticketId = epsTrxModel.ttc,
  23. person = "pump",
  24. cardNo = epsTrxModel.card_no,
  25. cardType = "1",
  26. oilName = epsTrxModel.youpin,
  27. units = epsTrxModel.qty,
  28. price = epsTrxModel.danjia,
  29. totalAmount = epsTrxModel.amount,
  30. amount = epsTrxModel.real_pay_amount,
  31. oilLiuShuiNo = epsTrxModel.liushuino,
  32. gunNum = epsTrxModel.jihao.ToString(),
  33. oilTime = epsTrxModel.xf_time,
  34. cardDiscount = epsTrxModel.amount - epsTrxModel.real_pay_amount,
  35. promDiscount = 0.00,
  36. payMethod = "01",
  37. transId = epsTrxModel.bill_id
  38. };
  39. debugLogger.Add("Send TrxNotify to Pos: \n" + request.ToString());
  40. communicator.SendRequest(request);
  41. debugLogger.Add("Got TrxNotify response: " + communicator.Response?.ToString());
  42. return communicator.Response;
  43. }
  44. }
  45. }