Browse Source

********init專案git版本號********
1. 台泥更新 Finalcost 充電度數0度 0 元 超過0度 最低1元

Jessica Tseng 3 years ago
parent
commit
39f88b4f13

+ 36 - 21
EVCB_OCPP.WSServer/Message/CoreProfileHandler.cs

@@ -83,7 +83,7 @@ namespace EVCB_OCPP.WSServer.Message
 
                             if (_request.messageId == "ID_CreditDeductResult")
                             {
-                               
+
                                 var creditDeductResult = JsonConvert.DeserializeObject<ID_CreditDeductResult>(_request.data);
                                 if (session.CustomerId == new Guid("009E603C-79CD-4620-A2B8-D9349C0E8AD8"))
                                 {
@@ -116,11 +116,11 @@ namespace EVCB_OCPP.WSServer.Message
                             if (_request.messageId == "ID_ReaderStatus")
                             {
                                 if (session.CustomerId == new Guid("009E603C-79CD-4620-A2B8-D9349C0E8AD8"))
-                                {                                   
+                                {
                                     var creditDeductResult = JsonConvert.DeserializeObject<ID_ReaderStatus>(_request.data);
                                     logger.Debug(JsonConvert.SerializeObject(creditDeductResult));
                                     confirm.status = DataTransferStatus.Accepted;
-                                }    
+                                }
                             }
                             result.Message = confirm;
                             result.Success = true;
@@ -688,7 +688,7 @@ namespace EVCB_OCPP.WSServer.Message
             {
                 switch (action)
                 {
-                    
+
                     case Actions.DataTransfer:
                         {
                             DataTransferConfirmation _confirm = confirm as DataTransferConfirmation;
@@ -732,7 +732,7 @@ namespace EVCB_OCPP.WSServer.Message
 
                                         if (feedto == null || string.IsNullOrEmpty(feedto.Fee)) return result;
                                         string currency = feedto.Fee.Substring(feedto.Fee.Length - 3);
-                                        decimal sum = 0;
+                                        decimal chargingCost = 0;
                                         if (feedto.Fee.Length > 10)
                                         {
                                             chargingPrices = JsonConvert.DeserializeObject<List<ChargingPrice>>(feedto.Fee.Split('|')[0]);
@@ -777,13 +777,13 @@ namespace EVCB_OCPP.WSServer.Message
                                                 if (bill.Count > 0)
                                                 {
                                                     bill[bill.Count - 1].Total += DollarRounding(perfee, session.Currency);
-                                                    sum += bill[bill.Count - 1].Total;
+                                                    chargingCost += bill[bill.Count - 1].Total;
 
                                                     if (bill.Count == 1)
                                                     {
 
                                                         bill[bill.Count - 1].Total = DollarRounding(Decimal.Multiply(bill[0].PeriodEnergy, bill[0].Fee), session.Currency);
-                                                        sum = bill[bill.Count - 1].Total;
+                                                        chargingCost = bill[bill.Count - 1].Total;
                                                     }
                                                 }
                                             }
@@ -854,13 +854,30 @@ namespace EVCB_OCPP.WSServer.Message
                                                 startTime = startTime.AddHours(1);
 
                                             }
-                                            if (confirmbill.Count > 1)
+
+                                            if (session.CustomerId == new Guid("009E603C-79CD-4620-A2B8-D9349C0E8AD8"))
+                                            {
+                                                // if (confirmbill.Count > 1)
+                                                {
+                                                    chargingCost = confirmbill.Sum(x => x.Total);
+                                                    chargingCost = confirmbill.Sum(x => x.PeriodEnergy) == 0 ? 0 : (chargingCost + parkingCost < 1 ? 1 : chargingCost);  //台泥最低一元
+                                                    receipt += string.Format("|Total Energy Fee : ${0}", chargingCost);
+                                                }
+                                                receipt += string.Format("|Parking Fee: | {0} - {1} @ ${2}/hr=${3}", feedto.StartTime.ToString("hh:mm tt", new CultureInfo("en-us")),
+                                                feedto.StopTime.ToString("hh:mm tt", new CultureInfo("en-us")), fee, parkingCost);
+                                                tx.Cost = chargingCost + parkingCost;
+                                            }
+                                            else
                                             {
-                                                receipt += string.Format("|Total Energy Fee : ${0}", confirmbill.Sum(x => x.Total));
+                                                if (confirmbill.Count > 1)
+                                                {
+                                                    receipt += string.Format("|Total Energy Fee : ${0}", confirmbill.Sum(x => x.Total));
+                                                }
+                                                receipt += string.Format("|Parking Fee: | {0} - {1} @ ${2}/hr=${3}", feedto.StartTime.ToString("hh:mm tt", new CultureInfo("en-us")),
+                                                feedto.StopTime.ToString("hh:mm tt", new CultureInfo("en-us")), fee, parkingCost);
+                                                tx.Cost = chargingCost + parkingCost;
                                             }
-                                            receipt += string.Format("|Parking Fee: | {0} - {1} @ ${2}/hr=${3}", feedto.StartTime.ToString("hh:mm tt", new CultureInfo("en-us")),
-                                            feedto.StopTime.ToString("hh:mm tt", new CultureInfo("en-us")), fee, parkingCost);
-                                            tx.Cost = sum + parkingCost;
+
                                             tx.Receipt = receipt;
                                             tx.UploadedtoTTIA = true;
                                             db.Configuration.AutoDetectChangesEnabled = false;
@@ -884,12 +901,10 @@ namespace EVCB_OCPP.WSServer.Message
                                                                 data = JsonConvert.SerializeObject(new
                                                                 {
                                                                     txId = txEnergy.TxId,
-                                                                    //   description = string.Format("Connection Fee: $0.00 {0}; Session Fee: ${1} {0}; Occupancy Fee: " +
-                                                                    //"${2} {0}; Total Cost: ${3} {0}; Account Balance: ${4} {0}", currency, sum, parkingCost, tx.Cost, accountBalance - tx.Cost)
                                                                     description = JsonConvert.SerializeObject(new
                                                                     {
                                                                         chargedEnergy = bill.Sum(x => x.PeriodEnergy),
-                                                                        chargingFee = sum,
+                                                                        chargingFee = chargingCost,
                                                                         parkTime = (int)stoptime.Subtract(starttime).TotalSeconds,
                                                                         parkingFee = parkingCost,
                                                                         currency = currency,
@@ -916,7 +931,7 @@ namespace EVCB_OCPP.WSServer.Message
                                                 {
                                                       new SqlParameter("ChargeBoxId",session.ChargeBoxId),
                                                       new SqlParameter("ConnectorId",  (byte)feedto.ConnectorId),
-                                                      new SqlParameter("Value",sum),
+                                                      new SqlParameter("Value",chargingCost),
                                                       new SqlParameter("CreatedOn",DateTime.UtcNow),
                                                       new SqlParameter("ContextId",(int)ReadingContext.Sample_Periodic),
                                                       new SqlParameter("FormatId",(int)ValueFormat.Raw),
@@ -987,7 +1002,7 @@ namespace EVCB_OCPP.WSServer.Message
                                                          description = JsonConvert.SerializeObject(new
                                                          {
                                                              chargedEnergy = bill.Sum(x => x.PeriodEnergy),
-                                                             chargingFee = sum,
+                                                             chargingFee = chargingCost,
                                                              parkTime = (int)stoptime.Subtract(starttime).TotalSeconds,
                                                              parkingFee = parkingCost,
                                                              currency = currency
@@ -1013,7 +1028,7 @@ namespace EVCB_OCPP.WSServer.Message
                                                 {
                                                       new SqlParameter("ChargeBoxId",session.ChargeBoxId),
                                                       new SqlParameter("ConnectorId",  (byte)feedto.ConnectorId),
-                                                      new SqlParameter("Value",sum),
+                                                      new SqlParameter("Value",chargingCost),
                                                       new SqlParameter("CreatedOn",DateTime.UtcNow),
                                                       new SqlParameter("ContextId",(int)ReadingContext.Sample_Periodic),
                                                       new SqlParameter("FormatId",(int)ValueFormat.Raw),
@@ -1035,7 +1050,7 @@ namespace EVCB_OCPP.WSServer.Message
 
 
                                 }
-                                if(_request.messageId== "ID_GetTxUserInfo")
+                                if (_request.messageId == "ID_GetTxUserInfo")
                                 {
                                     var txUserInfo = JsonConvert.DeserializeObject<ID_GetTxUserInfo>(_confirm.data);
                                     if (session.CustomerId == new Guid("009E603C-79CD-4620-A2B8-D9349C0E8AD8"))
@@ -1048,8 +1063,8 @@ namespace EVCB_OCPP.WSServer.Message
                                             SerialNo = txUserInfo.SerialNo,
                                             StartTime = txUserInfo.StartTime.ToString(GlobalConfig.UTC_DATETIMEFORMAT)
                                         };
-                                      
-                                        var response =  httpClient.Post(GlobalConfig.TCC_API_URL + "start_session", new Dictionary<string, string>()
+
+                                        var response = httpClient.Post(GlobalConfig.TCC_API_URL + "start_session", new Dictionary<string, string>()
                                         {
                                             { "PartnerId",session.CustomerId.ToString()}
 

+ 1 - 1
EVCB_OCPP.WSServer/Properties/AssemblyInfo.cs

@@ -35,4 +35,4 @@ using System.Runtime.InteropServices;
 [assembly: AssemblyVersion("0.1.0.0")]
 [assembly: AssemblyFileVersion("0.1.0.0")]
 
-[assembly: AssemblyInformationalVersion("defcf52")]
+[assembly: AssemblyInformationalVersion("0f7be57")]