|
@@ -16,7 +16,7 @@ static DcCommonInfo *ShmDcCommonData = NULL;
|
|
|
static SelectGunInfo *ShmSelectGunInfo = NULL;
|
|
|
static struct SysInfoData *pSysInfo = NULL;
|
|
|
#define PREAUTHMONEY 888
|
|
|
-bool isDeductDb_ready;
|
|
|
+bool isDb_ready;
|
|
|
static RecordTransactionInfo LocalTransactionInfo;
|
|
|
//------------------------------------------------------------------------------
|
|
|
static char *rfidPortName = "/dev/ttyS2";
|
|
@@ -108,6 +108,28 @@ bool isAutorCompleteHandle(/*uint8_t *authorizeIndex*/)
|
|
|
}*/
|
|
|
}
|
|
|
|
|
|
+void showDeductInfo(RecordTransactionInfo* transactionInfo)
|
|
|
+{
|
|
|
+ char ApprovalNo[10];
|
|
|
+ char vemdata[65];
|
|
|
+ char cardno[21];
|
|
|
+ memset(ApprovalNo,'\0',sizeof(ApprovalNo));
|
|
|
+ memset(vemdata,'\0',sizeof(vemdata));
|
|
|
+ memset(cardno,'\0',sizeof(cardno));
|
|
|
+ memcpy(ApprovalNo,&transactionInfo->pCreditCard.ApprovalNo[0],9);
|
|
|
+ memcpy(vemdata,&transactionInfo->pCreditCard.VemData[0],64);
|
|
|
+ memcpy(cardno,&transactionInfo->pCreditCard.CardNo[0],20);
|
|
|
+ log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f Approva Num:[%s] VemData:[%s] CardNo:[%s]",
|
|
|
+ transactionInfo->ConnectorID,
|
|
|
+ transactionInfo->TransactionId,
|
|
|
+ transactionInfo->DeductResult,
|
|
|
+ transactionInfo->IsDonateInvoice,
|
|
|
+ transactionInfo->Amount,
|
|
|
+ ApprovalNo,
|
|
|
+ vemdata,
|
|
|
+ cardno);
|
|
|
+}
|
|
|
+
|
|
|
bool RfidStopCharging(void)
|
|
|
{
|
|
|
//當前沒有選槍
|
|
@@ -265,84 +287,110 @@ void ScannerCardProcess(int gunIndex)
|
|
|
isCardScan = false;
|
|
|
}
|
|
|
}
|
|
|
+void storePayResult(uint8_t gunIndex)
|
|
|
+{
|
|
|
+ memset(&LocalTransactionInfo, 0x00, sizeof(RecordTransactionInfo));
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus > _TCC_PARKING_NONE) {
|
|
|
+ memcpy(&LocalTransactionInfo, &ShmDcCommonData->ParkingInfo[gunIndex] ,sizeof(RecordTransactionInfo));
|
|
|
+ } else
|
|
|
+ memcpy(&LocalTransactionInfo, &ShmDcCommonData->TransactionInfo[gunIndex] ,sizeof(RecordTransactionInfo));
|
|
|
+
|
|
|
+}
|
|
|
+void getPayResult(uint8_t gunIndex)
|
|
|
+{
|
|
|
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus > _TCC_PARKING_NONE) {
|
|
|
+ memcpy(&ShmDcCommonData->ParkingInfo[gunIndex], &LocalTransactionInfo, sizeof(RecordTransactionInfo));
|
|
|
+ } else {
|
|
|
+ memcpy(&ShmDcCommonData->TransactionInfo[gunIndex], &LocalTransactionInfo, sizeof(RecordTransactionInfo));
|
|
|
+ }
|
|
|
+}
|
|
|
void WritePayResult(int result ,uint8_t gunIndex)
|
|
|
{
|
|
|
- memcpy(&ShmDcCommonData->TransactionInfo[gunIndex], &LocalTransactionInfo, sizeof(RecordTransactionInfo));
|
|
|
if (result == TRUE)
|
|
|
ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = _DEDUCT_COMPLETE_PASS;
|
|
|
else
|
|
|
ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = _DEDUCT_COMPLETE_FAIL;
|
|
|
|
|
|
- log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f VemData:%s",
|
|
|
+ log_info("Gun[%d] TransactionId:%d DeductResult:%d IsDonateInvoice:%d Amount:%f VemData:%s Approve No:%s",
|
|
|
gunIndex, ShmDcCommonData->TransactionInfo[gunIndex].TransactionId,
|
|
|
ShmDcCommonData->TransactionInfo[gunIndex].DeductResult,
|
|
|
ShmDcCommonData->TransactionInfo[gunIndex].IsDonateInvoice,
|
|
|
ShmDcCommonData->TransactionInfo[gunIndex].Amount,
|
|
|
- ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.VemData);
|
|
|
-}
|
|
|
-void storePayResult(uint8_t gunIndex)
|
|
|
-{
|
|
|
- memset(&LocalTransactionInfo, 0, sizeof(RecordTransactionInfo));
|
|
|
- memcpy(&LocalTransactionInfo, &ShmDcCommonData->TransactionInfo[gunIndex] ,sizeof(RecordTransactionInfo));
|
|
|
- //LocalTransactionInfo.Amount = ShmDcCommonData->finalcost[gunIndex];
|
|
|
-}
|
|
|
-void getPayResult(uint8_t gunIndex)
|
|
|
-{
|
|
|
- memcpy(&ShmDcCommonData->TransactionInfo[gunIndex], &LocalTransactionInfo, sizeof(RecordTransactionInfo));
|
|
|
- memset(&LocalTransactionInfo, 0, sizeof(RecordTransactionInfo));
|
|
|
+ ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.VemData,
|
|
|
+ ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.ApprovalNo);
|
|
|
}
|
|
|
+
|
|
|
void PreAuthCompleteToCardReader(int fd,uint8_t gunIndex)
|
|
|
{
|
|
|
struct SysConfigData* pSysConfig = (struct SysConfigData*)GetShmSysConfigData();
|
|
|
int result = 0;
|
|
|
|
|
|
- if (ShmDcCommonData->TransactionInfo[gunIndex].Amount > 0 && ShmDcCommonData->TransactionInfo[gunIndex].Amount < 1) {
|
|
|
+ storePayResult(gunIndex);
|
|
|
+ if (ShmDcCommonData->TransactionInfo[gunIndex].Amount > 0 && ShmDcCommonData->TransactionInfo[gunIndex].Amount < 1 &&
|
|
|
+ ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus == 0) {
|
|
|
log_info("final cost less 1 : %f", ShmDcCommonData->TransactionInfo[gunIndex].Amount);
|
|
|
ShmDcCommonData->TransactionInfo[gunIndex].Amount = 1;
|
|
|
}
|
|
|
- storePayResult(gunIndex);
|
|
|
|
|
|
- result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->TransactionInfo[gunIndex].Amount, &pSysConfig->ModelName[0],
|
|
|
+ result = CreditCardPreAuthComplete(fd,(int)LocalTransactionInfo.Amount, &pSysConfig->ModelName[0],
|
|
|
&ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.VemData[0],
|
|
|
- &ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard);
|
|
|
+ &ShmDcCommonData->TransactionInfo[gunIndex]);
|
|
|
+ getPayResult(gunIndex);
|
|
|
+
|
|
|
//sleep(10);
|
|
|
if (result > 0 ) {
|
|
|
- log_info("Credit Card Spend Money:%.1f", LocalTransactionInfo.Amount);
|
|
|
+ log_info("Credit Card Spend Money:%.1f", ShmDcCommonData->TransactionInfo[gunIndex].Amount);
|
|
|
pSysInfo->SystemPage = _PAGE_COMPLETE;
|
|
|
- LocalTransactionInfo.DeductResult = _DEDUCT_COMPLETE_PASS;
|
|
|
+ ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = _DEDUCT_COMPLETE_PASS;
|
|
|
WritePayResult(TRUE,gunIndex);
|
|
|
ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
|
|
|
} else {
|
|
|
log_info("PAYING FAIL");
|
|
|
ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
|
|
|
pSysInfo->SystemPage = _PAGE_PAYFAIL;
|
|
|
- LocalTransactionInfo.DeductResult = _DEDUCT_COMPLETE_FAIL;
|
|
|
+ ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = _DEDUCT_COMPLETE_FAIL;
|
|
|
WritePayResult(FALSE,gunIndex);
|
|
|
}
|
|
|
ShmDcCommonData->TransactionInfo[gunIndex].IsUpload = FALSE;
|
|
|
+ //getPayResult(gunIndex);
|
|
|
+
|
|
|
UpdateDeductInfoStatus(gunIndex, &ShmDcCommonData->TransactionInfo[gunIndex]);
|
|
|
|
|
|
+ ShmDcCommonData->PreAuth_Result = result;
|
|
|
}
|
|
|
int CreditCardCancelPreAuth(int fd, uint8_t gunIndex)
|
|
|
{
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
struct SysConfigData* pSysConfig = (struct SysConfigData*)GetShmSysConfigData();
|
|
|
- ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd, PREAUTHMONEY, &pSysConfig->ModelName[0],
|
|
|
- &ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.ApprovalNo[0],
|
|
|
- &ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.CardNo[0],
|
|
|
- &ShmDcCommonData->TransactionInfo[gunIndex].pCreditCard.VemData[0]);
|
|
|
+ storePayResult(gunIndex);
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus)
|
|
|
+ ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd, LocalTransactionInfo.Amount, &pSysConfig->ModelName[0],
|
|
|
+ &LocalTransactionInfo.pCreditCard.ApprovalNo[0],
|
|
|
+ &LocalTransactionInfo.pCreditCard.CardNo[0],
|
|
|
+ &LocalTransactionInfo.pCreditCard.VemData[0]);
|
|
|
+ else
|
|
|
+ ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd, PREAUTHMONEY, &pSysConfig->ModelName[0],
|
|
|
+ &LocalTransactionInfo.pCreditCard.ApprovalNo[0],
|
|
|
+ &LocalTransactionInfo.pCreditCard.CardNo[0],
|
|
|
+ &LocalTransactionInfo.pCreditCard.VemData[0]);
|
|
|
//sleep(10);
|
|
|
if (ShmDcCommonData->PreAuth_Result >= 0) {
|
|
|
strcpy((char*)pSysConfig->UserId, "");
|
|
|
//ShmDcCommonData->PayFinish[gunIndex] = TRUE;
|
|
|
log_info("Gun%d Card Reader PreAuth Cancel Success",gunIndex);
|
|
|
- ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = _DEDUCT_CANCEL;
|
|
|
+ LocalTransactionInfo.DeductResult = _DEDUCT_CANCEL;
|
|
|
} else if (ShmDcCommonData->PreAuth_Result < 0) {
|
|
|
log_info("Gun%d Card Reader PreAuth Cancel Failure",gunIndex);
|
|
|
- ShmDcCommonData->TransactionInfo[gunIndex].DeductResult = _DEDUCT_PREAUTH;
|
|
|
+ LocalTransactionInfo.DeductResult = _DEDUCT_PREAUTH;
|
|
|
}
|
|
|
- ShmDcCommonData->TransactionInfo[gunIndex].IsUpload = FALSE;
|
|
|
- UpdateDeductInfoStatus(gunIndex, &ShmDcCommonData->TransactionInfo[gunIndex]);
|
|
|
+ LocalTransactionInfo.IsUpload = FALSE;
|
|
|
+ getPayResult(gunIndex);
|
|
|
+
|
|
|
+ UpdateDeductInfoStatus(gunIndex, &LocalTransactionInfo);
|
|
|
+
|
|
|
memset(&ShmDcCommonData->TransactionInfo[gunIndex], 0x00, sizeof(RecordTransactionInfo));
|
|
|
ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
return ShmDcCommonData->PreAuth_Result;
|
|
@@ -356,6 +404,7 @@ void ReDeductProcess(int fd)
|
|
|
int rededuct_gunIndex[128];
|
|
|
RecordTransactionInfo deductInfo[128];
|
|
|
int rededuct_num = 0;
|
|
|
+ // 充電費補扣款
|
|
|
rededuct_num = DB_GetMultiReDeductInfo(&rededuct_gunIndex[0], &deductInfo[0]);
|
|
|
|
|
|
if (rededuct_num == 0) {
|
|
@@ -406,6 +455,41 @@ void ReDeductProcess(int fd)
|
|
|
UpdateDeductInfoStatus(rededuct_gunIndex[j], &deductInfo[j]);
|
|
|
}
|
|
|
}
|
|
|
+ // 佔位費補扣款
|
|
|
+ /*
|
|
|
+ rededuct_num = DB_GetParkingDeductResult(&rededuct_gunIndex[0], &deductInfo[0]);
|
|
|
+
|
|
|
+ if (rededuct_num == 0) {
|
|
|
+ log_info("No Parking Rededuct Information");
|
|
|
+ } else {
|
|
|
+ ShmDcCommonData->CreditCardUpload = TRUE;
|
|
|
+ pSysInfo->SystemPage = _PAGE_PAYING;
|
|
|
+ log_info("Parking Rededuct Total Number:%d", rededuct_num);
|
|
|
+ for (j = rededuct_num-1; j >= 0 ; j--) {
|
|
|
+ sleep(3);
|
|
|
+
|
|
|
+ log_info("Start Parking Rededuct item [%d]",j);
|
|
|
+
|
|
|
+ result = CreditCardPreAuthComplete(fd, (int)deductInfo[j].Amount, &pSysConfig->ModelName[0],
|
|
|
+ &deductInfo[j].pCreditCard.VemData[0],
|
|
|
+ &ShmDcCommonData->ParkingInfo[0].pCreditCard);
|
|
|
+ if (result > 0) {
|
|
|
+ deductInfo[j].DeductResult = _DEDUCT_COMPLETE_PASS;
|
|
|
+ log_info("Backgroud Parking PreAuthComplete OK");
|
|
|
+ } else if (result < 0) {
|
|
|
+ deductInfo[j].DeductResult = _DEDUCT_COMPLETE_FAIL;
|
|
|
+ log_info("Backgroud Parking ID:%d Amount:%d VemData:%s PreAuthComplete fail",
|
|
|
+ deductInfo[j].TransactionId,
|
|
|
+ (int)deductInfo[j].Amount,
|
|
|
+ deductInfo[j].pCreditCard.VemData);
|
|
|
+ }
|
|
|
+
|
|
|
+ deductInfo[j].IsUpload = FALSE;
|
|
|
+ deductInfo[j].RedeductTime++;
|
|
|
+ UpdateParkingDeductInfo(rededuct_gunIndex[j], &deductInfo[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
ShmDcCommonData->RoutineReduct = TRUE;
|
|
|
}
|
|
|
static int InitialRfidPort(void)
|
|
@@ -440,7 +524,52 @@ void RemoteStartCancelPreAuth(int sel_gun)
|
|
|
memset(&ShmDcCommonData->TransactionInfo[sel_gun], 0x00, sizeof(RecordTransactionInfo));
|
|
|
ShmDcCommonData->TransactionInfo[sel_gun].LineStatus = ShmDcCommonData->RedeductBill.LineStatus;
|
|
|
}
|
|
|
+void PreAuthCreditCard(int fd, uint8_t gunIndex)
|
|
|
+{
|
|
|
+ struct SysConfigData* pSysConfig = (struct SysConfigData*)GetShmSysConfigData();
|
|
|
+ struct ChargingInfoData *pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(gunIndex);;
|
|
|
+ int result = 0;
|
|
|
+ storePayResult(gunIndex);
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus)
|
|
|
+ result = CreditCardPreAuth(fd, LocalTransactionInfo.Amount,&pSysConfig->ModelName[0], &LocalTransactionInfo.pCreditCard);
|
|
|
+ else
|
|
|
+ result = CreditCardPreAuth(fd, PREAUTHMONEY,&pSysConfig->ModelName[0], &LocalTransactionInfo.pCreditCard);
|
|
|
+ ShmDcCommonData->PreAuth_Result = result;
|
|
|
+ pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(gunIndex);
|
|
|
+ {
|
|
|
+ if (!checkRemoteStart(gunIndex)) {
|
|
|
+ if (!ShmDcCommonData->TradeCancel)
|
|
|
+ StopSystemTimeoutDet();
|
|
|
+ if (ShmDcCommonData->TradeCancel == FALSE && result > 0) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_SENSING;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ if (result > 0 && strcmp((char*)LocalTransactionInfo.pCreditCard.CardNo, "") != 0) {
|
|
|
+ log_info("Gun%d PreAuth card:%s", gunIndex, LocalTransactionInfo.pCreditCard.CardNo);
|
|
|
+ LocalTransactionInfo.DeductResult = _DEDUCT_PREAUTH;
|
|
|
+ LocalTransactionInfo.IsUpload = FALSE;
|
|
|
+ LocalTransactionInfo.ConnectorID = ShmDcCommonData->ConnectorID[gunIndex];
|
|
|
+ //log_info("Gun%d Line Status:%d", LocalTransactionInfo.LineStatus);
|
|
|
+ if (ShmDcCommonData->pGunInfo[gunIndex].ParkingStatus)
|
|
|
+ InsertParkingDeductInfo(ShmDcCommonData->ConnectorID[gunIndex], &LocalTransactionInfo);
|
|
|
+ else {
|
|
|
+ ShmDcCommonData->AuthPass_flag[gunIndex] = TRUE;
|
|
|
+ strncpy((char*)pSysConfig->UserId, (char*)LocalTransactionInfo.pCreditCard.CardNo, 20);
|
|
|
+ InsertDeductInfo(ShmDcCommonData->ConnectorID[gunIndex], &LocalTransactionInfo);
|
|
|
+ }
|
|
|
+ getPayResult(gunIndex);
|
|
|
+ //log_info("Gun%d PreAuth OK",gunIndex);
|
|
|
+ } else if (result < 0) {
|
|
|
+ if (ShmDcCommonData->TradeCancel == FALSE && !checkRemoteStart(gunIndex))
|
|
|
+ pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
+ ShmDcCommonData->AuthPass_flag[gunIndex] = FALSE;
|
|
|
+ memset(&LocalTransactionInfo.pCreditCard, 0, sizeof(TransInfo));
|
|
|
+ log_info("Gun%d PreAuth Fail",gunIndex);
|
|
|
+ }
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
+ }
|
|
|
+}
|
|
|
void CreateRfidFork(void)
|
|
|
{
|
|
|
pid_t rfidRecPid;
|
|
@@ -463,9 +592,19 @@ void CreateRfidFork(void)
|
|
|
ShmSelectGunInfo = (SelectGunInfo *)GetShmSelectGunInfo();
|
|
|
struct ChargingInfoData *pDcChargingInfo = NULL;
|
|
|
if (DeductDB_Open() != PASS) {
|
|
|
- isDeductDb_ready = false;
|
|
|
+ isDb_ready = false;
|
|
|
+ log_info("DeductDB_Open Fail");
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
+ isDb_ready = true;
|
|
|
+ //InsertDeductInfo(0, &ShmDcCommonData->TransactionInfo);
|
|
|
+ }
|
|
|
+ if (ParkingDB_Open() != PASS) {
|
|
|
+ isDb_ready = false;
|
|
|
+ log_info("ParkingDB_Open Fail");
|
|
|
+ return;
|
|
|
} else {
|
|
|
- isDeductDb_ready = true;
|
|
|
+ isDb_ready = true;
|
|
|
//InsertDeductInfo(0, &ShmDcCommonData->TransactionInfo);
|
|
|
}
|
|
|
int gunIndex;
|
|
@@ -505,7 +644,6 @@ void CreateRfidFork(void)
|
|
|
}
|
|
|
|
|
|
if (ShmDcCommonData->StopCharge[gunIndex] == TRUE && pDcChargingInfo->Replug_flag == TRUE) {
|
|
|
- ShmDcCommonData->StopCharge[gunIndex] = FALSE;
|
|
|
// Remote Start of AutoStart ByPass Credit Card Reader
|
|
|
if (ShmDcCommonData->DebugFlag == TRUE ||
|
|
|
ShmDcCommonData->is_RemoteStart[gunIndex] == TRUE ||
|
|
@@ -522,10 +660,11 @@ void CreateRfidFork(void)
|
|
|
pSysInfo->CurGunSelected = gunIndex;
|
|
|
pSysInfo->SystemPage = _PAGE_PLUGOUT;
|
|
|
StopSystemTimeoutDet();
|
|
|
+ ShmDcCommonData->StopCharge[gunIndex] = FALSE;
|
|
|
} else {
|
|
|
if (ShmDcCommonData->StopCharge[gunIndex] && ShmDcCommonData->finalcost_flag[gunIndex] &&
|
|
|
ShmDcCommonData->PreAuth_Config != _CREDITCARD_CANCEL) {
|
|
|
- ShmDcCommonData->StopCharge[gunIndex] = FALSE;
|
|
|
+
|
|
|
pSysInfo->CurGunSelected = gunIndex;
|
|
|
StopGunInfoTimeoutDet(gunIndex); //Timeout_FinalCost
|
|
|
|
|
@@ -535,6 +674,7 @@ void CreateRfidFork(void)
|
|
|
if (ShmDcCommonData->is_AutoStart[gunIndex]) {
|
|
|
ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
|
|
|
}
|
|
|
+ ShmDcCommonData->StopCharge[gunIndex] = FALSE;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -549,80 +689,76 @@ void CreateRfidFork(void)
|
|
|
ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
|
|
|
}
|
|
|
} else {
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_PREAUTHCOMPLETE;
|
|
|
PreAuthCompleteToCardReader(fd, gunIndex);
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
}
|
|
|
+ ShmDcCommonData->StopCharge[gunIndex] = FALSE;
|
|
|
}
|
|
|
}
|
|
|
} // for
|
|
|
- /*
|
|
|
- if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_SALE) {
|
|
|
+ if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_SALE /*&& ShmDcCommonData->pGunInfo[pSysInfo->CurGunSelected].isParking*/) {
|
|
|
sel_gun = pSysInfo->CurGunSelected;
|
|
|
- memset(&ShmDcCommonData->TransactionInfo[sel_gun], 0, sizeof(RecordTransactionInfo));
|
|
|
- CreditCardSale(fd, 1, &pSysConfig->ModelName[0], &ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard);
|
|
|
- log_info("TransDate:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.TransDate);
|
|
|
- log_info("TransTime:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.TransTime);
|
|
|
- log_info("ROC:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.ROC);
|
|
|
- log_info("ApprovalNo:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.ApprovalNo);
|
|
|
- log_info("StoreId:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.StoreId);
|
|
|
- log_info("RRN:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.RRN);
|
|
|
-
|
|
|
- log_info("CardNo:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.CardNo);
|
|
|
- log_info("TransAmount:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.TransAmount);
|
|
|
- log_info("VemData:[%s]", ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.VemData);
|
|
|
+ ShmDcCommonData->PreAuth_Result = 0;
|
|
|
+ ShmDcCommonData->PreAuth_Result = CreditCardSale(fd,(int)ShmDcCommonData->ParkingInfo[sel_gun].Amount,
|
|
|
+ &pSysConfig->ModelName[0],
|
|
|
+ &ShmDcCommonData->ParkingInfo[sel_gun].pCreditCard);
|
|
|
+ StopSystemTimeoutDet(); //Timeout_ScanCard
|
|
|
+ if (ShmDcCommonData->PreAuth_Result > 0 ) {
|
|
|
+ log_info("Gun%d Parking Fee PreAuthComplete Success",sel_gun);
|
|
|
+ pSysInfo->SystemPage = _PAGE_PLUGIN;
|
|
|
+ ShmDcCommonData->ParkingInfo[sel_gun].IsUpload = FALSE;
|
|
|
+ //ShmDcCommonData->pGunInfo[sel_gun].GetParkingBill = FALSE;
|
|
|
+ ShmDcCommonData->ParkingInfo[sel_gun].DeductResult = _DEDUCT_SALE_PASS;
|
|
|
+ InsertParkingDeductInfo(ShmDcCommonData->ConnectorID[sel_gun], &ShmDcCommonData->ParkingInfo[sel_gun]);
|
|
|
+ } else {
|
|
|
+ log_info("Gun%d Parking Fee PreAuthComplete Fail",sel_gun);
|
|
|
+ if (!ShmDcCommonData->TradeCancel) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ShmDcCommonData->PreAuth_Result = 0;
|
|
|
ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
- } else*/ if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
|
|
|
+ } else if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
|
|
|
// 取消預授權
|
|
|
CreditCardCancelPreAuth(fd,pSysInfo->CurGunSelected);
|
|
|
- // 預授權
|
|
|
- } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH /* && ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected]*/) {
|
|
|
+ } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH ) {
|
|
|
+ // 預授權
|
|
|
sel_gun = pSysInfo->CurGunSelected;
|
|
|
- donate = (int)ShmDcCommonData->TransactionInfo[sel_gun].IsDonateInvoice;
|
|
|
- linestatus = (int)ShmDcCommonData->TransactionInfo[sel_gun].LineStatus;
|
|
|
- memset(&ShmDcCommonData->TransactionInfo[sel_gun], 0x00, sizeof(RecordTransactionInfo));
|
|
|
- ShmDcCommonData->TransactionInfo[sel_gun].IsDonateInvoice = (unsigned char)donate;
|
|
|
- ShmDcCommonData->TransactionInfo[sel_gun].LineStatus = linestatus;
|
|
|
- result = CreditCardPreAuth(fd, PREAUTHMONEY,&pSysConfig->ModelName[0], &ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard);
|
|
|
-
|
|
|
- pDcChargingInfo = (struct ChargingInfoData*)GetDcChargingInfoData(sel_gun);
|
|
|
- {
|
|
|
- if (!checkRemoteStart(sel_gun)) {
|
|
|
- if (!ShmDcCommonData->TradeCancel)
|
|
|
- StopSystemTimeoutDet();
|
|
|
- if (ShmDcCommonData->TradeCancel == FALSE && result > 0) {
|
|
|
- pSysInfo->SystemPage = _PAGE_SENSING;
|
|
|
- }
|
|
|
- /*
|
|
|
- if (result > 0) {
|
|
|
- storePayResult(sel_gun);
|
|
|
- log_info("sleep");
|
|
|
- sleep(3);
|
|
|
- log_info("Wake");
|
|
|
- getPayResult(sel_gun);
|
|
|
- }*/
|
|
|
+ PreAuthCreditCard(fd,sel_gun);
|
|
|
+ // 佔位費預授權並扣款
|
|
|
+ /*
|
|
|
+ if (ShmDcCommonData->PreAuth_Result > 0 ) {
|
|
|
+ log_info("Gun%d Parking Fee PreAuthComplete Success",sel_gun);
|
|
|
+ pSysInfo->SystemPage = _PAGE_PLUGIN;
|
|
|
+ StartSystemTimeoutDet(Timeout_ReturnViewPage);
|
|
|
+ } else {
|
|
|
+ log_info("Gun%d Parking Fee PreAuthComplete Fail",sel_gun);
|
|
|
+ if (!ShmDcCommonData->TradeCancel) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
+ StartSystemTimeoutDet(Timeout_VerifyFail);
|
|
|
}
|
|
|
- ShmDcCommonData->PreAuth_Result = result;
|
|
|
-
|
|
|
- //result = 1;
|
|
|
- if (result > 0 && strcmp((char*)ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.CardNo, "") != 0) {
|
|
|
-
|
|
|
- ShmDcCommonData->AuthPass_flag[sel_gun] = TRUE;
|
|
|
- strncpy((char*)pSysConfig->UserId, (char*)ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard.CardNo, 20);
|
|
|
- log_info("Gun%d Authorize card:%s", sel_gun, pSysConfig->UserId);
|
|
|
- ShmDcCommonData->TransactionInfo[sel_gun].DeductResult = _DEDUCT_PREAUTH;
|
|
|
- ShmDcCommonData->TransactionInfo[sel_gun].IsUpload = FALSE;
|
|
|
- ShmDcCommonData->TransactionInfo[sel_gun].ConnectorID = ShmDcCommonData->ConnectorID[sel_gun];
|
|
|
- //log_info("Gun%d Line Status:%d", ShmDcCommonData->TransactionInfo[sel_gun].LineStatus);
|
|
|
- InsertDeductInfo(ShmDcCommonData->ConnectorID[sel_gun], &ShmDcCommonData->TransactionInfo[sel_gun]);
|
|
|
- //log_info("Gun%d PreAuth OK",sel_gun);
|
|
|
- } else if (result < 0) {
|
|
|
- if (ShmDcCommonData->TradeCancel == FALSE && !checkRemoteStart(sel_gun))
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ShmDcCommonData->pGunInfo[sel_gun].ParkingStatus && ShmDcCommonData->PreAuth_Result > 0 &&
|
|
|
+ !ShmDcCommonData->TradeCancel && ShmDcCommonData->PreAuth_Config != _CREDITCARD_CANCEL ) {
|
|
|
+ ShmDcCommonData->PreAuth_Result = 0;
|
|
|
+ sleep(10);
|
|
|
+ PreAuthCompleteToCardReader(fd, sel_gun);
|
|
|
+ if (ShmDcCommonData->PreAuth_Result > 0 ) {
|
|
|
+ log_info("Gun%d Parking Fee PreAuthComplete Success",sel_gun);
|
|
|
+ pSysInfo->SystemPage = _PAGE_PLUGIN;
|
|
|
+ StartSystemTimeoutDet(Timeout_ReturnViewPage);
|
|
|
+ } else {
|
|
|
+ log_info("Gun%d Parking Fee PreAuthComplete Fail",sel_gun);
|
|
|
+ if (!ShmDcCommonData->TradeCancel) {
|
|
|
pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
- ShmDcCommonData->AuthPass_flag[sel_gun] = FALSE;
|
|
|
- memset(&ShmDcCommonData->TransactionInfo[sel_gun].pCreditCard, 0, sizeof(TransInfo));
|
|
|
- log_info("Gun%d PreAuth Fail",sel_gun);
|
|
|
+ StartSystemTimeoutDet(Timeout_VerifyFail);
|
|
|
+ }
|
|
|
}
|
|
|
- ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
- }
|
|
|
+ ShmDcCommonData->PreAuth_Result = 0;
|
|
|
+ }*/
|
|
|
}
|
|
|
|
|
|
// 每30分鐘檢查補扣款
|
|
@@ -666,91 +802,6 @@ void CreateRfidFork(void)
|
|
|
if (tm->tm_hour == 16 && tm->tm_min == 0) {
|
|
|
ShmDcCommonData->RoutineSettlement = FALSE;
|
|
|
}
|
|
|
- /*
|
|
|
- // 刷卡判斷
|
|
|
- if (pSysConfig->OfflinePolicy == _OFFLINE_POLICY_NO_CHARGING ||
|
|
|
- !pSysConfig->isRFID) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if (getRequestCardSN(fd, 0, &rfid) == false) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- //log_info("Get Card..-%s- ", pSysConfig->UserId);
|
|
|
- if (strlen((char *)pSysConfig->UserId) != 0) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_LITTLE) {
|
|
|
- switch (rfid.snType) {
|
|
|
- case RFID_SN_TYPE_6BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[0], rfid.currentCard[1],
|
|
|
- rfid.currentCard[2], rfid.currentCard[3],
|
|
|
- rfid.currentCard[4], rfid.currentCard[5]);
|
|
|
- break;
|
|
|
- case RFID_SN_TYPE_7BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[0], rfid.currentCard[1],
|
|
|
- rfid.currentCard[2], rfid.currentCard[3],
|
|
|
- rfid.currentCard[4], rfid.currentCard[5],
|
|
|
- rfid.currentCard[6]);
|
|
|
- break;
|
|
|
- case RFID_SN_TYPE_10BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[0], rfid.currentCard[1],
|
|
|
- rfid.currentCard[2], rfid.currentCard[3],
|
|
|
- rfid.currentCard[4], rfid.currentCard[5],
|
|
|
- rfid.currentCard[6], rfid.currentCard[7],
|
|
|
- rfid.currentCard[8], rfid.currentCard[9]);
|
|
|
- break;
|
|
|
- case RFID_SN_TYPE_4BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[0], rfid.currentCard[1],
|
|
|
- rfid.currentCard[2], rfid.currentCard[3]);
|
|
|
- break;
|
|
|
- }
|
|
|
- } else if (pSysConfig->RfidCardNumEndian == RFID_ENDIAN_BIG) {
|
|
|
- switch (rfid.snType) {
|
|
|
- case RFID_SN_TYPE_6BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[5], rfid.currentCard[4],
|
|
|
- rfid.currentCard[3], rfid.currentCard[2],
|
|
|
- rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
- break;
|
|
|
- case RFID_SN_TYPE_7BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[6], rfid.currentCard[5],
|
|
|
- rfid.currentCard[4], rfid.currentCard[3],
|
|
|
- rfid.currentCard[2], rfid.currentCard[1],
|
|
|
- rfid.currentCard[0]);
|
|
|
- break;
|
|
|
- case RFID_SN_TYPE_10BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[9], rfid.currentCard[8],
|
|
|
- rfid.currentCard[7], rfid.currentCard[6],
|
|
|
- rfid.currentCard[5], rfid.currentCard[4],
|
|
|
- rfid.currentCard[3], rfid.currentCard[2],
|
|
|
- rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
- break;
|
|
|
- case RFID_SN_TYPE_4BYTE:
|
|
|
- sprintf((char *) pSysConfig->UserId,
|
|
|
- "%02X%02X%02X%02X",
|
|
|
- rfid.currentCard[3], rfid.currentCard[2],
|
|
|
- rfid.currentCard[1], rfid.currentCard[0]);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- log_info("card number = %s", pSysConfig->UserId);
|
|
|
- */
|
|
|
}
|
|
|
}
|
|
|
}
|