|
@@ -63,6 +63,45 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public class ID_GetOccupancyFee
|
|
|
+ {
|
|
|
+ public int ConnectorId { set; get; }
|
|
|
+
|
|
|
+ public string occupancySN { set; get; }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ID_GetOccupancyFeeResult
|
|
|
+ {
|
|
|
+ public string msgId { set; get; }
|
|
|
+ public int ConnectorId { set; get; }
|
|
|
+
|
|
|
+ public string occupancySN { set; get; }
|
|
|
+
|
|
|
+ public string chargeEndTime { set; get; }
|
|
|
+
|
|
|
+ public int occupancyDuration { set; get; }
|
|
|
+
|
|
|
+
|
|
|
+ public decimal occupancyFee { set; get; }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public class ID_OccupancyFeeResult
|
|
|
+ {
|
|
|
+ public string occupancySN { set; get; }
|
|
|
+
|
|
|
+ public string creditNo { set; get; }
|
|
|
+
|
|
|
+
|
|
|
+ public bool deductResult { set; get; }
|
|
|
+
|
|
|
+ public decimal amount { set; get; }
|
|
|
+
|
|
|
+ public string approvalNo { set; get; }
|
|
|
+
|
|
|
+ }
|
|
|
internal partial class ProfileHandler
|
|
|
{
|
|
|
static private ILogger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
@@ -85,6 +124,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
case Actions.DataTransfer:
|
|
|
{
|
|
|
DataTransferRequest _request = request as DataTransferRequest;
|
|
|
+
|
|
|
var confirm = new DataTransferConfirmation() { status = DataTransferStatus.UnknownMessageId };
|
|
|
|
|
|
if (_request.messageId == "ID_CreditDeductResult")
|
|
@@ -156,6 +196,82 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
confirm.status = DataTransferStatus.Accepted;
|
|
|
}
|
|
|
+ if (_request.messageId == "ID_GetOccupancyFee")
|
|
|
+ {
|
|
|
+
|
|
|
+ var getOccupancyFee = JsonConvert.DeserializeObject<ID_GetOccupancyFee>(_request.data);
|
|
|
+ ID_GetOccupancyFeeResult occupancyFeeResult = new ID_GetOccupancyFeeResult()
|
|
|
+ {
|
|
|
+ msgId = _request.messageId,
|
|
|
+ ConnectorId = getOccupancyFee.ConnectorId,
|
|
|
+ occupancySN = getOccupancyFee.occupancySN
|
|
|
+ };
|
|
|
+ var report = new
|
|
|
+ {
|
|
|
+ ChargeBoxId = session.ChargeBoxId,
|
|
|
+ occupancySN = getOccupancyFee.occupancySN
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ var response = await httpClient.Post(GlobalConfig.TCC_API_URL + "occupancy_payment", new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId",session.CustomerId.ToString()}
|
|
|
+
|
|
|
+ }, report, GlobalConfig.TCC_SALTKEY);
|
|
|
+
|
|
|
+ logger.Debug(JsonConvert.SerializeObject(response));
|
|
|
+
|
|
|
+ var _httpResult = JsonConvert.DeserializeObject<CPOOuterResponse>(response.Response);
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(_httpResult.Data))
|
|
|
+ {
|
|
|
+ JObject jo = JObject.Parse(_httpResult.Data);
|
|
|
+ if (jo.ContainsKey("ChargeEndTime"))
|
|
|
+ {
|
|
|
+ occupancyFeeResult.chargeEndTime = jo["ChargeEndTime"].Value<string>();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (jo.ContainsKey("OccupancyDuration"))
|
|
|
+ {
|
|
|
+ occupancyFeeResult.occupancyDuration = jo["OccupancyDuration"].Value<int>();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (jo.ContainsKey("OccupancyFee"))
|
|
|
+ {
|
|
|
+ occupancyFeeResult.occupancyFee = jo["OccupancyFee"].Value<decimal>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ confirm.status = DataTransferStatus.Accepted;
|
|
|
+ confirm.data = JsonConvert.SerializeObject(occupancyFeeResult);
|
|
|
+ }
|
|
|
+ if (_request.messageId == "ID_OccupancyFeeResult")
|
|
|
+ {
|
|
|
+
|
|
|
+ var occupancyFeeResult = JsonConvert.DeserializeObject<ID_OccupancyFeeResult>(_request.data);
|
|
|
+ var report = new
|
|
|
+ {
|
|
|
+ OccupancySN = occupancyFeeResult.occupancySN,
|
|
|
+ CreditNo = occupancyFeeResult.creditNo,
|
|
|
+ DeductResult = occupancyFeeResult.deductResult,
|
|
|
+ Amount = occupancyFeeResult.amount,
|
|
|
+ ApprovalNo = occupancyFeeResult.approvalNo
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ var response = await httpClient.Post(GlobalConfig.TCC_API_URL + "occupancyfee_result", new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "PartnerId",session.CustomerId.ToString()}
|
|
|
+
|
|
|
+ }, report, GlobalConfig.TCC_SALTKEY);
|
|
|
+
|
|
|
+ logger.Debug(JsonConvert.SerializeObject(response));
|
|
|
+
|
|
|
+ confirm.status = DataTransferStatus.Accepted;
|
|
|
+ confirm.data = JsonConvert.SerializeObject(new { msgId = _request.messageId, occupancySN = occupancyFeeResult.occupancySN });
|
|
|
+ }
|
|
|
result.Message = confirm;
|
|
|
result.Success = true;
|
|
|
}
|
|
@@ -525,7 +641,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
var transaction = db.TransactionRecord.Where(x => x.Id == _request.transactionId
|
|
|
&& x.ChargeBoxId == session.ChargeBoxId).FirstOrDefault();
|
|
|
|
|
|
- // throw new Exception("123");
|
|
|
+ // throw new Exception("123");
|
|
|
//遠傳太久以前的停止充電 直接拒絕 避免電樁持續重送~~~~~~~
|
|
|
if (_request.timestamp < new DateTime(2021, 11, 1))
|
|
|
{
|
|
@@ -646,15 +762,15 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- catch(Exception ex)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
- result.Exception = new Exception("TransactionId " + _request.transactionId+" "+ ex.Message);
|
|
|
+ result.Exception = new Exception("TransactionId " + _request.transactionId + " " + ex.Message);
|
|
|
result.CallErrorMsg = "Reject Response Message";
|
|
|
result.Success = false;
|
|
|
- // return result;
|
|
|
+ // return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|
|
@@ -858,8 +974,8 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
chargingCost = DollarRounding(chargingCost, session.Currency);
|
|
|
}
|
|
|
|
|
|
- // 計算停車費
|
|
|
- var parkingFee = decimal.Parse(feedto.Fee.Split('&')[1]);
|
|
|
+ // 計算停車費 台泥不適用此停車費模式
|
|
|
+ var parkingFee = 0;// decimal.Parse(feedto.Fee.Split('&')[1]);
|
|
|
var stoptime = feedto.StopTime == GlobalConfig.DefaultNullTime ? DateTime.Parse(DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm")) : DateTime.Parse(feedto.StopTime.ToString("yyyy/MM/dd HH:mm"));
|
|
|
var starttime = DateTime.Parse(feedto.StartTime.ToString("yyyy/MM/dd HH:mm"));
|
|
|
var totalHours = stoptime.Subtract(starttime).TotalHours;
|