|
@@ -243,7 +243,7 @@ static void UserScanFunction(void)
|
|
|
confirmSelGun(pSysInfo->CurGunSelected);
|
|
|
setSelGunWaitToAuthor(pSysInfo->CurGunSelected);
|
|
|
StartSystemTimeoutDet(Timeout_Authorizing);
|
|
|
-
|
|
|
+ AuthorizingStart();
|
|
|
pDcChargingInfo->SystemStatus = S_AUTHORIZING;
|
|
|
AuthorizingStart();
|
|
|
|
|
@@ -278,9 +278,9 @@ void AuthorizeToCharge()
|
|
|
if(isAuthorizedComplete())
|
|
|
{
|
|
|
// StopSystemTimeoutDet();
|
|
|
- StartSystemTimeoutDet(Timeout_WaitBalance);
|
|
|
- if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) {
|
|
|
- StopSystemTimeoutDet();
|
|
|
+ //StartSystemTimeoutDet(Timeout_WaitBalance);
|
|
|
+ // if (ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance != FAIL_BALANCE_PRICES) {
|
|
|
+ // StopSystemTimeoutDet();
|
|
|
// 判斷後台回覆狀態
|
|
|
if (canStartCharging()) {
|
|
|
// LCM => Authorize complete
|
|
@@ -288,16 +288,17 @@ void AuthorizeToCharge()
|
|
|
//pSysInfo->SystemPage = _PAGE_PLUGIN;
|
|
|
//log_info("Wait Gun(%d) plugin",pSysInfo->CurGunSelected);
|
|
|
DetectPluginStart();
|
|
|
- if (ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] == TRUE)
|
|
|
- pSysInfo->SystemPage = _PAGE_PLUGIN;
|
|
|
+ if (ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] == TRUE) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_PLUGIN;
|
|
|
+ }
|
|
|
//log_info("Gun(%d) Balance: %f",pSysInfo->CurGunSelected,
|
|
|
// ShmSelectGunInfo->PricesInfo[pSysInfo->CurGunSelected].Balance);
|
|
|
} else {
|
|
|
log_info("LCM => Authorize fail");
|
|
|
- //pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
+ pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
strcpy((char *)pSysConfig->UserId, "");
|
|
|
}
|
|
|
- }
|
|
|
+ //}
|
|
|
ClearAuthorizedFlag();
|
|
|
}
|
|
|
}
|
|
@@ -347,7 +348,7 @@ void WritePayResult(int result ,uint8_t gunIndex)
|
|
|
void PreAuthCompleteToCardReader(int fd,uint8_t gunIndex)
|
|
|
{
|
|
|
int result = 0;
|
|
|
- result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->finalcost[pSysInfo->CurGunSelected] ,"TCC Test",
|
|
|
+ result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->finalcost[pSysInfo->CurGunSelected], "TCC Test",
|
|
|
&ShmDcCommonData->pCreditCard[gunIndex].VemData[0],
|
|
|
&ShmDcCommonData->pCreditCard[gunIndex]);
|
|
|
|
|
@@ -356,8 +357,7 @@ void PreAuthCompleteToCardReader(int fd,uint8_t gunIndex)
|
|
|
log_info("Credit Card Spend Money:%.1f",ShmDcCommonData->finalcost[gunIndex]);
|
|
|
pSysInfo->SystemPage = _PAGE_COMPLETE;
|
|
|
WritePayResult(TRUE,gunIndex);
|
|
|
- ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
|
|
|
-
|
|
|
+ ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
|
|
|
} else {
|
|
|
log_info("PAYING FAIL");
|
|
|
ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
|
|
@@ -393,7 +393,27 @@ static int InitialRfidPort(void)
|
|
|
|
|
|
return fd;
|
|
|
}
|
|
|
+int CreditCardCancelPreAuth(int fd,uint8_t gunIndex)
|
|
|
+{
|
|
|
+ struct SysConfigData* pSysConfig = (struct SysConfigData*)GetShmSysConfigData();
|
|
|
+ ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd, PREAUTHMONEY, "TCC Test",
|
|
|
+ &ShmDcCommonData->pCreditCard[gunIndex].ApprovalNo[0],
|
|
|
+ &ShmDcCommonData->pCreditCard[gunIndex].CardNo[0],
|
|
|
+ &ShmDcCommonData->pCreditCard[gunIndex].VemData[0]);
|
|
|
+ sleep(10);
|
|
|
+ if (ShmDcCommonData->PreAuth_Result > 0) {
|
|
|
+ strcpy((char*)pSysConfig->UserId, "");
|
|
|
+ ShmDcCommonData->PayFinish[gunIndex] = TRUE;
|
|
|
+ log_info("Card Reader PreAuth Cancel Success");
|
|
|
+ memset(&ShmDcCommonData->pCreditCard[gunIndex], 0, sizeof(TransInfo));
|
|
|
|
|
|
+ }
|
|
|
+ else if (ShmDcCommonData->PreAuth_Result < 0) {
|
|
|
+ log_info("Card Reader PreAuth Cancel Failure");
|
|
|
+ }
|
|
|
+ ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
+ return ShmDcCommonData->PreAuth_Result;
|
|
|
+}
|
|
|
void CreateRfidFork(void)
|
|
|
{
|
|
|
pid_t rfidRecPid;
|
|
@@ -457,7 +477,34 @@ void CreateRfidFork(void)
|
|
|
ShmDcCommonData->reupload_deduct_status = 0;
|
|
|
}
|
|
|
}
|
|
|
+ if (is_idle == TRUE && tm->tm_min % 15 == 0 &&
|
|
|
+ pSysInfo->SystemPage == _PAGE_IDLE && ShmDcCommonData->reupload_deduct_status == 0) {
|
|
|
+ sleep(1);
|
|
|
+ if (DB_GetReDeductInfo(&ReAuthComplete_Index, &ShmDcCommonData->ReAuthComplete) == PASS) {
|
|
|
+
|
|
|
+ result = CreditCardPreAuthComplete(fd, (int)ShmDcCommonData->ReAuthComplete.Amount, "TCC Test",
|
|
|
+ &ShmDcCommonData->ReAuthComplete.VemData[0],
|
|
|
+ &ShmDcCommonData->pCreditCard[0]);
|
|
|
+ sleep(10);
|
|
|
+ if (result > 0) {
|
|
|
+ ShmDcCommonData->ReAuthComplete.DeductResult = YES;
|
|
|
+ ShmDcCommonData->ReAuthComplete.IsUpload = NO;
|
|
|
+ UpdateDeductInfoStatus(&ReAuthComplete_Index, &ShmDcCommonData->ReAuthComplete);
|
|
|
+ log_info("PreAuthComplete OK");
|
|
|
+ }
|
|
|
+ else if (result < 0) {
|
|
|
+ log_info("Backgroud ID:%d Amount:%d VemData:%s PreAuthComplete fail",
|
|
|
+ ShmDcCommonData->ReAuthComplete.TransactionId,
|
|
|
+ (int)ShmDcCommonData->ReAuthComplete.Amount,
|
|
|
+ ShmDcCommonData->ReAuthComplete.VemData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //log_info("DB_GetReDeductInfo Fail");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ // Scan Card to get card number
|
|
|
if (pSysInfo->SystemPage == _PAGE_AUTHORIZE && ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected] == FALSE) {
|
|
|
result = CreditCardSearch(fd,"TCC Test",&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
|
|
|
//result = 1;
|
|
@@ -480,75 +527,41 @@ void CreateRfidFork(void)
|
|
|
if (pDcChargingInfo->SystemStatus == S_IDLE) {
|
|
|
is_idle = TRUE;
|
|
|
}
|
|
|
-
|
|
|
if (ShmDcCommonData->StopCharge[gunIndex] == TRUE && ShmDcCommonData->finalcost_flag[gunIndex]) {
|
|
|
- if (ShmDcCommonData->finalcost[gunIndex] <= 0) {
|
|
|
-
|
|
|
- } else {
|
|
|
- ShmDcCommonData->StopCharge[gunIndex] = FALSE;
|
|
|
- StopGunInfoTimeoutDet(gunIndex); //Timeout_FinalCost
|
|
|
+ ShmDcCommonData->StopCharge[gunIndex] = FALSE;
|
|
|
+ pSysInfo->SystemPage = _PAGE_PAYING;
|
|
|
+ StopGunInfoTimeoutDet(gunIndex); //Timeout_FinalCost
|
|
|
+ if (ShmDcCommonData->finalcost[gunIndex] < 1) {
|
|
|
+ log_info("Final Cost less 1 , Cancel Trade!!");
|
|
|
+ if (CreditCardCancelPreAuth(fd, gunIndex) > 0) {
|
|
|
+ pSysInfo->SystemPage = _PAGE_COMPLETE;
|
|
|
+ ShmDcCommonData->PayPass_flag[gunIndex] = TRUE;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ pSysInfo->SystemPage = _PAGE_PAYFAIL;
|
|
|
+ ShmDcCommonData->PayPass_flag[gunIndex] = FALSE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
PreAuthCompleteToCardReader(fd,gunIndex);
|
|
|
- ShmDcCommonData->PayFinish[gunIndex] = TRUE;
|
|
|
}
|
|
|
}
|
|
|
} // for
|
|
|
- if (is_idle == TRUE && tm->tm_min%15 == 0 &&
|
|
|
- pSysInfo->SystemPage == _PAGE_IDLE && ShmDcCommonData->reupload_deduct_status == 0) {
|
|
|
- sleep(1);
|
|
|
- if (DB_GetReDeductInfo(&ReAuthComplete_Index,&ShmDcCommonData->ReAuthComplete) == PASS ) {
|
|
|
-
|
|
|
- result = CreditCardPreAuthComplete(fd,(int)ShmDcCommonData->ReAuthComplete.Amount ,"TCC Test",
|
|
|
- &ShmDcCommonData->ReAuthComplete.VemData[0],
|
|
|
- &ShmDcCommonData->pCreditCard[0]);
|
|
|
- sleep(10);
|
|
|
- if (result > 0) {
|
|
|
- ShmDcCommonData->ReAuthComplete.DeductResult = YES;
|
|
|
- ShmDcCommonData->ReAuthComplete.IsUpload = NO;
|
|
|
- UpdateDeductInfoStatus(&ReAuthComplete_Index,&ShmDcCommonData->ReAuthComplete);
|
|
|
- log_info("PreAuthComplete OK");
|
|
|
- } else if ( result < 0) {
|
|
|
- log_info("Backgroud ID:%d Amount:%d VemData:%s PreAuthComplete fail",
|
|
|
- ShmDcCommonData->ReAuthComplete.TransactionId,
|
|
|
- (int)ShmDcCommonData->ReAuthComplete.Amount,
|
|
|
- ShmDcCommonData->ReAuthComplete.VemData);
|
|
|
- }
|
|
|
- } else {
|
|
|
- log_info("DB_GetReDeductInfo Fail");
|
|
|
- }
|
|
|
- }
|
|
|
- if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
|
|
|
- ShmDcCommonData->PreAuth_Result = CreditCardPreAuthCancel(fd,PREAUTHMONEY,"TCC Test",
|
|
|
- &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].ApprovalNo[0],
|
|
|
- &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo[0],
|
|
|
- &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].VemData[0]);
|
|
|
- sleep(10);
|
|
|
- if (ShmDcCommonData->PreAuth_Result > 0 ) {
|
|
|
- strcpy((char *)pSysConfig->UserId,"");
|
|
|
- log_info("Card Reader Stop");
|
|
|
- memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo));
|
|
|
- } else if (ShmDcCommonData->PreAuth_Result < 0) {
|
|
|
- log_info("Car Reader Stop Fail");
|
|
|
|
|
|
- }
|
|
|
- ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
- } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH) {
|
|
|
+ if(ShmDcCommonData->PreAuth_Config == _CREDITCARD_CANCEL) {
|
|
|
+ CreditCardCancelPreAuth(fd,pSysInfo->CurGunSelected);
|
|
|
+ } else if (ShmDcCommonData->PreAuth_Config == _CREDITCARD_PREAUTH && ShmDcCommonData->GetCardNo[pSysInfo->CurGunSelected]) {
|
|
|
result = CreditCardPreAuth(fd, PREAUTHMONEY,"TCC Test", &ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected]);
|
|
|
- sleep(10);
|
|
|
+ sleep(7);
|
|
|
//result = 1;
|
|
|
if (result > 0) {
|
|
|
ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = TRUE;
|
|
|
- //pSysInfo->SystemPage = _PAGE_PLUGIN;
|
|
|
- //strncpy((char *)pSysConfig->UserId,ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected].CardNo,20);
|
|
|
log_info("PreAuth OK");
|
|
|
} else if (result < 0) {
|
|
|
struct ChargingInfoData *pDcChargingInfo = NULL;
|
|
|
- //pDcChargingInfo = (struct ChargingInfoData *)GetDcChargingInfoData(pSysInfo->CurGunSelected);
|
|
|
pSysInfo->SystemPage = _PAGE_AUTHORIZE_FAIL;
|
|
|
- //pDcChargingInfo->SystemStatus = S_IDLE;
|
|
|
ShmDcCommonData->AuthPass_flag[pSysInfo->CurGunSelected] = FALSE;
|
|
|
memset(&ShmDcCommonData->pCreditCard[pSysInfo->CurGunSelected], 0, sizeof(TransInfo));
|
|
|
log_info("PreAuth Fail");
|
|
|
- ShmDcCommonData->PreAuth_Config = _CREDITCARD_CANCEL;
|
|
|
}
|
|
|
ShmDcCommonData->PreAuth_Config = _CREDITCARD_IDLE;
|
|
|
}
|