|
@@ -70,6 +70,11 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
public string occupancySN { set; get; }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 1. Get occupancy fee info. 2. Cancel local deduction
|
|
|
+ /// </summary>
|
|
|
+ public int Action { set; get; }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public class ID_GetOccupancyFeeResult
|
|
@@ -81,10 +86,10 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
public string startTime { set; get; }
|
|
|
|
|
|
- public int duration { set; get; }
|
|
|
+ public int? duration { set; get; }
|
|
|
|
|
|
|
|
|
- public decimal occupancyFee { set; get; }
|
|
|
+ public decimal? occupancyFee { set; get; }
|
|
|
|
|
|
|
|
|
}
|
|
@@ -197,7 +202,7 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
|
|
|
confirm.status = DataTransferStatus.Accepted;
|
|
|
}
|
|
|
- if (_request.messageId == "ID_GetOccupancyFee")
|
|
|
+ if (_request.messageId == "ID_OccupancyFeeAct")
|
|
|
{
|
|
|
var getOccupancyFee = JsonConvert.DeserializeObject<ID_GetOccupancyFee>(_request.data);
|
|
|
ID_GetOccupancyFeeResult occupancyFeeResult = new ID_GetOccupancyFeeResult()
|
|
@@ -206,56 +211,97 @@ namespace EVCB_OCPP.WSServer.Message
|
|
|
ConnectorId = getOccupancyFee.ConnectorId,
|
|
|
occupancySN = getOccupancyFee.occupancySN
|
|
|
};
|
|
|
- var report = new
|
|
|
+
|
|
|
+ if(getOccupancyFee.Action==1)
|
|
|
{
|
|
|
- ChargeBoxId = session.ChargeBoxId,
|
|
|
- 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>()
|
|
|
+ };
|
|
|
+ var response = await httpClient.Post(GlobalConfig.TCC_API_URL + "occupancy_payment", new Dictionary<string, string>()
|
|
|
{
|
|
|
{ "PartnerId",session.CustomerId.ToString()}
|
|
|
|
|
|
- }, report, GlobalConfig.TCC_SALTKEY);
|
|
|
-
|
|
|
- if (!response.Success)
|
|
|
- {
|
|
|
- confirm.status = DataTransferStatus.Rejected;
|
|
|
- confirm.data = JsonConvert.SerializeObject(occupancyFeeResult);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
-
|
|
|
- var _httpResult = JsonConvert.DeserializeObject<CPOOuterResponse>(response.Response);
|
|
|
- if (_httpResult.StatusCode != 1000)
|
|
|
+ }, report, GlobalConfig.TCC_SALTKEY);
|
|
|
+
|
|
|
+ if (!response.Success)
|
|
|
{
|
|
|
confirm.status = DataTransferStatus.Rejected;
|
|
|
confirm.data = JsonConvert.SerializeObject(occupancyFeeResult);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- confirm.status = DataTransferStatus.Accepted;
|
|
|
-
|
|
|
- JObject jo = JObject.Parse(_httpResult.Data);
|
|
|
- if (jo.ContainsKey("ChargeEndTime"))
|
|
|
- {
|
|
|
- occupancyFeeResult.startTime = jo["ChargeEndTime"].Value<string>();
|
|
|
|
|
|
+ var _httpResult = JsonConvert.DeserializeObject<CPOOuterResponse>(response.Response);
|
|
|
+ if (_httpResult.StatusCode != 1000)
|
|
|
+ {
|
|
|
+ confirm.status = DataTransferStatus.Rejected;
|
|
|
+ confirm.data = JsonConvert.SerializeObject(occupancyFeeResult);
|
|
|
}
|
|
|
- if (jo.ContainsKey("OccupancyDuration"))
|
|
|
+ else
|
|
|
{
|
|
|
- occupancyFeeResult.duration = jo["OccupancyDuration"].Value<int>();
|
|
|
+ confirm.status = DataTransferStatus.Accepted;
|
|
|
+
|
|
|
+ JObject jo = JObject.Parse(_httpResult.Data);
|
|
|
+ if (jo.ContainsKey("ChargeEndTime"))
|
|
|
+ {
|
|
|
+ occupancyFeeResult.startTime = jo["ChargeEndTime"].Value<string>();
|
|
|
+
|
|
|
+ }
|
|
|
+ if (jo.ContainsKey("OccupancyDuration"))
|
|
|
+ {
|
|
|
+ occupancyFeeResult.duration = jo["OccupancyDuration"].Value<int>();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (jo.ContainsKey("OccupancyFee"))
|
|
|
+ {
|
|
|
+ occupancyFeeResult.occupancyFee = jo["OccupancyFee"].Value<decimal>();
|
|
|
+ }
|
|
|
+
|
|
|
+ confirm.data = JsonConvert.SerializeObject(occupancyFeeResult);
|
|
|
+
|
|
|
}
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var report = new
|
|
|
+ {
|
|
|
+ ChargeBoxId = session.ChargeBoxId,
|
|
|
+ occupancySN = getOccupancyFee.occupancySN
|
|
|
|
|
|
- if (jo.ContainsKey("OccupancyFee"))
|
|
|
+ };
|
|
|
+ var response = await httpClient.Post(GlobalConfig.TCC_API_URL + "resume_occupancy", new Dictionary<string, string>()
|
|
|
{
|
|
|
- occupancyFeeResult.occupancyFee = jo["OccupancyFee"].Value<decimal>();
|
|
|
- }
|
|
|
+ { "PartnerId",session.CustomerId.ToString()}
|
|
|
|
|
|
- confirm.data = JsonConvert.SerializeObject(occupancyFeeResult);
|
|
|
+ }, report, GlobalConfig.TCC_SALTKEY);
|
|
|
+
|
|
|
+ if (!response.Success)
|
|
|
+ {
|
|
|
+ confirm.status = DataTransferStatus.Rejected;
|
|
|
+ confirm.data = JsonConvert.SerializeObject(occupancyFeeResult, GlobalConfig.JSONSERIALIZER_FORMAT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
|
|
|
- }
|
|
|
+ var _httpResult = JsonConvert.DeserializeObject<CPOOuterResponse>(response.Response);
|
|
|
+ if (_httpResult.StatusCode != 1000)
|
|
|
+ {
|
|
|
+ confirm.status = DataTransferStatus.Rejected;
|
|
|
+ confirm.data = JsonConvert.SerializeObject(occupancyFeeResult, GlobalConfig.JSONSERIALIZER_FORMAT);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ confirm.status = DataTransferStatus.Accepted;
|
|
|
+ confirm.data = JsonConvert.SerializeObject(occupancyFeeResult,GlobalConfig.JSONSERIALIZER_FORMAT);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
if (_request.messageId == "ID_OccupancyDeductResult")
|
|
|
{
|