using Castle.Components.DictionaryAdapter.Xml; using Edge.Core.Domain.FccOrderInfo; using Edge.Core.Domain.FccStationInfo.Output; using Edge.Core.Parser.BinaryParser.MessageEntity; using Microsoft.EntityFrameworkCore.Metadata.Internal; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace HengshanPaymentTerminal.MessageEntity.Incoming { /// /// 油机推送订单信息数据对象 /// public class OrderFromMachine:CommonMessage { /// /// 枪号 /// public int nozzleNum { get; set; } /// /// 交易流水号 /// public int ttc { get; set; } /// /// 加油时间 /// public DateTime dispenserTime { get; set; } /// /// 挂枪时间 /// public DateTime endTime { get; set; } /// /// 油品代码 /// public string oilCode { get; set; } /// /// 付款方式/地点 /// public byte payType { get; set; } /// /// 价格 /// public decimal price { get; set; } /// /// 金额 /// public decimal amount { get; set; } /// /// 升数 /// public decimal volume { get; set; } /// /// 泵码 /// public decimal pumpCode { get; set; } public override byte[] ToCommonByteArray() { byte[] content = new byte[] { 0x55, this.Handle, (byte)this.nozzleNum, ((byte)RESULT.OVER) }; return content2data(content); } public override CommonMessage ToObject(byte[] datas) { getBaseData(datas); this.nozzleNum = datas[7]; this.ttc = Bytes2Number(datas, 8, 4); Span dispenserSpan = datas.AsSpan(12, 7); this.dispenserTime = bytes2DateTime(dispenserSpan.ToArray()); Span endSpan = datas.AsSpan(19, 7); this.endTime = bytes2DateTime(endSpan.ToArray()); Span oilCodeSpan = datas.AsSpan(26, 2); this.oilCode = BitConverter.ToString(oilCodeSpan.ToArray()).Replace("-", ""); this.payType = datas[28]; ushort priceShort = Bytes2Number(datas,29, 2); this.price = priceShort / 100m; uint amountInt = Bytes2Number(datas, 31, 3); this.amount = amountInt / 100m; uint volumeInt = Bytes2Number(datas, 34, 3); this.volume = volumeInt / 100m; int punpCodeInt = Bytes2Number(datas, 37, 4); this.pumpCode = punpCodeInt / 100m; return this; } public FccOrderInfo ToComponent(string? oilName) { return new FccOrderInfo { Ttc = this.ttc, AuthorizationTime = this.dispenserTime, EndTime = this.endTime, PaymentTime = null, NozzleNum = this.nozzleNum, OilName = oilName ?? "", PaymentStatus = 0, //PayType = 0x21, CloundOrderId = null, Amount = this.amount, Volume = this.volume, //AmountPayable = this.amount, UploadState = 0, IsDelete = 0, Price = this.price, //RefundAmount = 0, UserName = "", PhoneNumber = "", PaymentName = "", PumpCode = this.pumpCode }; } /// /// 补充授权订单数据 /// /// 当前数据库中订单数据 /// public FccOrderInfo PaddingAuthorizationOrderData(FccOrderInfo order) { order.AuthorizationTime = this.dispenserTime; order.EndTime = this.endTime; order.Amount = this.amount; order.Volume = this.volume; order.Price = this.price; return order; } } }