PosManager.cs 1.9 KB

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