12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using SinochemPosClient;
- using SinochemPosClient.Models;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Wayne.Lib.Log;
- namespace SinochemInternetPlusApp
- {
- public class PosManager
- {
- private readonly string UrlPrefix = GenericSinochemEpsApp.AppSettings["SinochemPosUrlPrefix"];
- private readonly string TrxNotifyApi = GenericSinochemEpsApp.AppSettings["SinochemPosNotifyApi"];
- static NLog.Logger logger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("SinochemEpsApp");
- public TrxNotificationResponse NotifyPosSuccessfulTrx(EpsTransactionModel epsTrxModel, DebugLogger debugLogger)
- {
- PosCommunicator<TrxNotificationRequest, TrxNotificationResponse> communicator =
- new PosCommunicator<TrxNotificationRequest, TrxNotificationResponse>(UrlPrefix + TrxNotifyApi);
- TrxNotificationRequest request = new TrxNotificationRequest
- {
- ticketId = epsTrxModel.ttc,
- person = "pump",
- cardNo = epsTrxModel.card_no,
- //oilCard=1, weixin=8
- cardType = ((int)epsTrxModel.cardType).ToString(),
- oilName = epsTrxModel.youpin,
- units = epsTrxModel.qty,
- price = epsTrxModel.danjia,
- totalAmount = epsTrxModel.amount,
- amount = epsTrxModel.real_pay_amount,
- oilLiuShuiNo = epsTrxModel.liushuino,
- gunNum = epsTrxModel.jihao.ToString(),
- oilTime = epsTrxModel.xf_time,
- promDiscount = 0.00,
- //01 -- oilCard, 07 -- weixin
- payMethod = epsTrxModel.payMethod,
- transId = epsTrxModel.bill_id,
- openId = epsTrxModel.openId
- };
- if (epsTrxModel.cardType == CardType.OilCard)
- {
- request.cardDiscount = epsTrxModel.amount - epsTrxModel.real_pay_amount;
- request.promDiscount = 0;
- }
- else
- {
- request.cardDiscount = 0;
- request.promDiscount = epsTrxModel.amount - epsTrxModel.real_pay_amount;
- }
- logger.Info("Send TrxNotify to Pos: \n" + request.ToString());
- communicator.SendRequest(request);
- logger.Info("Got TrxNotify response: " + communicator.Response?.ToString());
- return communicator.Response;
- }
- }
- }
|