function checkAuctionForVirtualBank($TradingDate, $BankID) { $function_name = 'checkAuctionForVirtualBank'; $class_name = $this->class_name; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $query = sprintf("CALL sp_VirtualBank_CheckAuction('%s', %u)", $TradingDate, $BankID); $result = $this->_MDB2->extended->getAll($query); for ($i = 0; $i < count($result); $i++) { $this->items[$i] = new SOAP_Value('item', $struct, array("OrderID" => new SOAP_Value("OrderID", "string", $result[$i]['orderid']), "AccountNo" => new SOAP_Value("AccountNo", "string", $result[$i]['accountno']), "Symbol" => new SOAP_Value("Symbol", "string", $result[$i]['symbol']), "Amount" => new SOAP_Value("Amount", "string", $result[$i]['amount']), "BidAmount" => new SOAP_Value("BidAmount", "string", $result[$i]['bidamount']), "Delta" => new SOAP_Value("Delta", "string", $result[$i]['delta']))); } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
/** Chi them ngay 04-03-2010 Function: insertTradeForHNX Description: insert deal for hnx Input: $'OrderQuantity', 'Session', 'FromTypeID', 'OldOrderID', 'Note', 'OrderDate', 'IsAssigner', 'CreatedBy' Output: ID / error code */ function insertTradeForHNX($ConfirmNo, $OrderNumber, $MatchedQuantity, $MatchedPrice, $MatchedSession, $TradingDate, $CreatedBy) { $function_name = 'insertTradeForHNX'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } if (!required($ConfirmNo) || !required($OrderNumber) || !required($MatchedQuantity) || !required($MatchedPrice) || !required($MatchedSession) || !required($TradingDate)) { if (!required($ConfirmNo)) { $this->_ERROR_CODE = 99999; } if (!required($OrderNumber)) { $this->_ERROR_CODE = 99999; } if (!required($MatchedQuantity)) { $this->_ERROR_CODE = 99999; } if (!required($MatchedPrice)) { $this->_ERROR_CODE = 99999; } if (!required($MatchedSession)) { $this->_ERROR_CODE = 99999; } if (!required($TradingDate)) { $this->_ERROR_CODE = 99999; } } else { $query = sprintf("CALL sp_hnx_Trade_Insert('%s', '%s', %u, %u, %u, '%s', '%s')", $ConfirmNo, $OrderNumber, $MatchedQuantity, $MatchedPrice, $MatchedSession, $TradingDate, $CreatedBy); $rs = $this->_MDB2_WRITE->extended->getRow($query); if (empty($rs)) { $this->_ERROR_CODE = 999998; } else { $result = $rs['varerror']; if ($result < 0) { switch ($result) { case '-1': $this->_ERROR_CODE = 999997; break; default: $this->_ERROR_CODE = $result; } } else { $this->_ERROR_CODE = 0; } } } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function ReportVirtualBank_GetAccountBalanceByDate($BankID, $AccountNo, $FromDate, $ToDate) { $function_name = 'ReportVirtualBank_GetAccountBalanceByDate'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $query = sprintf("CALL sp_VirtualBank_getAccountBalanceByDate('%s','%s','%s','%s')", $BankID, $AccountNo, $FromDate, $ToDate); $result = $this->_MDB2->extended->getAll($query); $num_row = count($result); if ($num_row > 0) { for ($i = 0; $i < $num_row; $i++) { $this->items[$i] = new SOAP_Value('items', '{urn:' . $this->class_name . '}' . $function_name . 'Struct', array('PrevBalance' => new SOAP_Value("PrevBalance", "string", $result[$i]['prevbalance']), 'NextBalance' => new SOAP_Value("NextBalance", "string", $result[$i]['nextbalance']), 'AccountNo' => new SOAP_Value("AccountNo", "string", $result[$i]['accountno']), 'InvestorName' => new SOAP_Value("InvestorName", "string", $result[$i]['investorname']))); } } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function getAdvanceAmountforBankAndDate($AdvanceDate, $TDate, $BankID) { try { $class_name = $this->class_name; $function_name = 'getAdvanceAmountforBankAndDate'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $this->items = array(); $query = sprintf("CALL sp_getAdvanceAmountforBankAndDate('%s','%s','%s')", $AdvanceDate, $TDate, $BankID); $result = $this->_MDB2->extended->getAll($query); $num_row = count($result); if ($num_row > 0) { for ($i = 0; $i < $num_row; $i++) { $this->items[$i] = new SOAP_Value('items', '{urn:' . $class_name . '}' . $function_name . 'Struct', array('AdvanceAmount' => new SOAP_Value("AdvanceAmount", "string", $result[$i]['advanceamount']), 'Numday' => new SOAP_Value("Numday", "string", $result[$i]['numday']), 'Val' => new SOAP_Value("Val", "string", $result[$i]['val']))); } } } catch (Exception $e) { write_my_log_path('PHP-Exception', $function_name . ' Caught exception: ' . $e->getMessage() . ' ' . date('Y-m-d h:i:s'), DEBUG_PATH); $this->_ERROR_CODE = 23022; } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function insertBuyingStockDivident($AccountID, $BankID, $Amount, $DepositDate, $Note, $CreatedBy) { $function_name = 'insertBuyingStockDivident'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } if (!required($AccountID) || !unsigned($AccountID) || !required($BankID) || !unsigned($BankID) || !required($Amount) || !unsigned($Amount) || !required($DepositDate)) { if (!required($AccountID) || !unsigned($AccountID)) { $this->_ERROR_CODE = 22230; } if (!required($BankID) || !unsigned($BankID)) { $this->_ERROR_CODE = 22231; } if (!required($Amount) || !unsigned($Amount)) { $this->_ERROR_CODE = 22232; } if (!required($DepositDate)) { $this->_ERROR_CODE = 22233; } } else { $query = sprintf("CALL sp_VirtualBank_insertBuyingStockDivident(%u, %u, %f, '%s', '%s', '%s' )", $AccountID, $BankID, $Amount, $DepositDate, $Note, $CreatedBy); $rs = $this->_MDB2_WRITE->extended->getRow($query); if (empty($rs)) { $this->_ERROR_CODE = 22234; } else { $result = $rs['varerror']; if ($result < 0) { switch ($result) { case '-1': $this->_ERROR_CODE = 22235; break; case '-2': $this->_ERROR_CODE = 22236; break; case '-3': $this->_ERROR_CODE = 22237; break; case '-4': $this->_ERROR_CODE = 22238; break; case '-5': $this->_ERROR_CODE = 22239; break; case '-9': $this->_ERROR_CODE = 22240; break; default: $this->_ERROR_CODE = $result; } } } } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function checkQuotaAccountIsExisted($AccountNo) { $function_name = 'checkQuotaAccountIsExisted'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $MDB2 = initDB(); $query = sprintf("SELECT f_quota_QuotaAccount_IsExisted('%s') AS Boolean", $AccountNo); $result = $MDB2->extended->getRow($query); $this->items[0] = new SOAP_Value('item', $struct, array("Boolean" => new SOAP_Value("Boolean", "string", $result['boolean']))); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function ConfirmExtraCollectDisbursement($ID, $UpdatedBy) { $function_name = 'ConfirmExtraCollectDisbursement'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $query = sprintf("CALL sp_ExtraCollectDisbursement_getInfo('%s')", $ID); $rs = $this->_MDB2->extended->getRow($query); $BankAccount = $rs['bankaccount']; $BankID = (int) $rs['bankid']; $BravoCode = (int) $rs['bravocode']; $Amount = $rs['amount']; $AccountNo = $rs['accountno']; $TradingDate = $rs['tradingdate']; $Note = $rs['note']; $TranTypeID = (int) $rs['trantypeid']; if ($BankAccount != '') { switch ($BankID) { case DAB_ID: $dab =& new CDAB(); $refno = $AccountNo . "_" . $ID . "_" . date('Y-m-d'); if ($TranTypeID == 1) { // Thu tien $dab_rs = $dab->transfertoEPS($BankAccount, $AccountNo, $refno, $Amount, $Note); } elseif ($TranTypeID == 2) { // Chuyen tien $dab_rs = $dab->transferfromEPS($BankAccount, $AccountNo, $refno, $Amount, $Note); } break; case OFFLINE: $mdb = initWriteDB(); $query = sprintf("CALL sp_VirtualBank_ExtraCollectDisbursement(%u, '%s', '%s')", $ID, date("Y-m-d"), $UpdatedBy); $offline_rs = $mdb->extended->getRow($query); $mdb->disconnect(); if (PEAR::isError($offline_rs)) { $this->_ERROR_CODE = 31500; } else { $result = $offline_rs['varerror']; if ($result < 0) { switch ($result) { case '-1': $this->_ERROR_CODE = 31501; break; case '-2': $this->_ERROR_CODE = 31502; break; case '-3': $this->_ERROR_CODE = 31503; break; case '-4': $this->_ERROR_CODE = 30624; // khong du tien break; case '-5': $this->_ERROR_CODE = 31504; break; case '-9': $this->_ERROR_CODE = 31505; break; } //switch } else { //if $dab_rs = 0; } } //if PEAR break; } //switch if ($dab_rs == 0) { $query = sprintf("CALL sp_ExtraCollectDisbursement_Confirm(%u,'%s')", $ID, $UpdatedBy); $rs = $this->_MDB2_WRITE->extended->getRow($query); if ($rs['varerror'] < 0) { switch ($rs['varerror']) { case '-2': $this->_ERROR_CODE = 31450; break; } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } else { //update Bank $soap =& new Bravo(); if ($TranTypeID == 1) { // Thu tien $transactionType = "M13.09"; } elseif ($TranTypeID == 2) { // Chuyen tien $transactionType = "M13.08"; } $Deposit_value = array("TradingDate" => date('Y-m-d'), 'TransactionType' => $transactionType, "AccountNo" => $AccountNo, "Amount" => $Amount, "Bank" => $BravoCode, "Branch" => "", "Note" => $Note); $ret = $soap->deposit($Deposit_value); if ($ret['table0']['Result'] != 1) { switch ($ret['table0']['Result']) { case 0: $this->_ERROR_CODE = 0; break; case -2: //Error - bravo $this->_ERROR_CODE = 23002; break; case -1: //Invalid key $this->_ERROR_CODE = 23003; break; case -13: /*Invalid Transaction Type*/ $this->_ERROR_CODE = 23006; break; case -15: /*Invalid CustomerCode*/ $this->_ERROR_CODE = 23005; break; case -16: /*Invalid DestCustomerCode*/ $this->_ERROR_CODE = 23004; break; default: //Unknown Error $this->_ERROR_CODE = $ret['table0']['Result']; break; } if ($this->_ERROR_CODE != 0 && $Deposit_value['Amount'] > 0) { $soap->rollback($ret['table1']['Id'], date('Y-m-d')); } } } //update bank } else { switch ($dab_rs) { case '-1': //unauthenticate partner $this->_ERROR_CODE = 22135; break; case '-2': //invalid parameters $this->_ERROR_CODE = 22136; break; case '-3': //invalid date $this->_ERROR_CODE = 22137; break; case '-4': //no customer found $this->_ERROR_CODE = 22140; break; case '-5': //transfer unsuccessful $this->_ERROR_CODE = 22141; break; case '1': //invalid account $this->_ERROR_CODE = 22142; break; case '2': //invalid amount $this->_ERROR_CODE = 22143; break; case '3': //duplicate transfer $this->_ERROR_CODE = 22147; break; case '5': //not enough balance $this->_ERROR_CODE = 22144; break; case '6': //duplicate account $this->_ERROR_CODE = 22145; break; case '99': //unknown error $this->_ERROR_CODE = 22138; break; default: $this->_ERROR_CODE = 22139; } } // bank } else { //bank account $this->_ERROR_CODE = 31452; } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
/** * (Function nay chi khac ConfirmBuyingStockForDividend_CutMoney o cho tham so $Note - Tao ngay 20100712, request ngay 20100709) * Function ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu : Ke toan cat tien -- day dl qua Bravo -- cap nhat bankid khi cat tien thanh cong * Input : $EventID, $AccountID, $Today, $UpdatedBy, $Note * OutPut : error code. Return 0 if success else return error code (number >0). */ function ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu($EventID, $AccountID, $UpdatedBy, $Today, $BankID, $Note) { try { $class_name = $this->class_name; $function_name = 'ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } if (!required($EventID) || !numeric($EventID)) { $this->_ERROR_CODE = 22042; } if ($this->_ERROR_CODE == 0 && (!required($AccountID) || !numeric($AccountID))) { $this->_ERROR_CODE = 22005; } if ($this->_ERROR_CODE == 0 && (!required($Today) || !valid_date($Today))) { $this->_ERROR_CODE = 22056; } if ($this->_ERROR_CODE == 0) { $Withdrawal = $this->CheckConfirmBuyingStock_CutMoney($EventID, $AccountID, $Today); if ($Withdrawal['ErrorCode'] == '0') { // money in bank $query = sprintf("SELECT BankID, BankAccount, BravoCode FROM vw_ListAccountBank_Detail WHERE AccountID='%s' AND BankID ='%s' ", $AccountID, $BankID); $this->_MDB2->disconnect(); $this->_MDB2->connect(); $bank_rs = $this->_MDB2->extended->getAll($query); $dab_rs = 999; $BankID = 0; $TransactionType = BRAVO_BUYING_STOCK; // phat hanh them cp if ($Withdrawal['AccountNo'] != PAGODA_ACCOUNT) { if (count($bank_rs) > 0) { $i = 0; $BankID = $bank_rs[$i]['bankid']; $BravoCode = $bank_rs[$i]['bravocode']; switch ($BankID) { case DAB_ID: $dab =& new CDAB(); $dab_rs = $dab->transfertoEPS($bank_rs[$i]['bankaccount'], $Withdrawal['AccountNo'], '3_' . $EventID . '_' . $AccountID, $Withdrawal['Amount'], $Note); write_my_log_path('transfertoEPS', $function_name . ' BankAccount ' . $bank_rs[$i]['bankaccount'] . ' AccountNo ' . $Withdrawal['AccountNo'] . ' Event_AccountID ' . '3_' . $EventID . ' ' . $AccountID . ' Amount ' . $Withdrawal['Amount'] . ' Description ' . $Note . ' Error ' . $dab_rs, EVENT_PATH); break; case OFFLINE: $mdb2 = initWriteDB(); //`sp_VirtualBank_insertBuyingStockDivident`(inAccountID bigint, inBankID int, inAmount double,inTransactionDate date, inNote text(1000), inCreatedBy varchar(100)) $query = sprintf("CALL sp_VirtualBank_insertBuyingStockDivident(%u, %u, %f, '%s', '%s', '%s' )", $AccountID, $BankID, $Withdrawal['Amount'], $Today, $Note, $UpdatedBy); $rs = $mdb2->extended->getRow($query); $mdb2->disconnect(); $dab_rs = $rs["varerror"]; break; default: $dab_rs = 0; } } else { $dab_rs = 9999; $this->_ERROR_CODE = 22155; //TK k co TK Ngan hang nay } } else { $TransactionType = BRAVO_BUYING_STOCK; // phat hanh them cp $dab_rs = 0; $BankID = EXI_ID; } if ($dab_rs == 0) { if ($BankID == OFFLINE) { $query = "SELECT mobilephone,ab.usableamount FROM " . TBL_INVESTOR; $query .= " i INNER JOIN " . TBL_ACCOUNT . " a ON(i.id=a.investorId)"; $query .= " INNER JOIN " . TBL_ACCOUNT_BANK . " ab ON(a.id=ab.accountid)"; $query .= " WHERE a.accountNo='" . $Withdrawal['AccountNo'] . "' AND ab.bankid=" . OFFLINE; $mdb = initWriteDB(); $acc_rs = $mdb->extended->getRow($query); $mdb->disconnect(); if (!empty($acc_rs['mobilephone'])) { $message = 'Tai khoan cua quy khach tai KIS da thay doi: -' . number_format($Withdrawal['Amount'], 0, '.', ',') . '. ' . $Note; $message .= '. So du hien tai la: ' . number_format($acc_rs['usableamount'], 0, '.', ','); sendSMS(array('Phone' => $acc_rs['mobilephone'], 'Content' => $message), 'ConfirmBuyingStockForDividend_CutMoney_ForTraiPhieu'); } } $soap =& new Bravo(); $Withdrawal_value = array("TradingDate" => $Today, 'TransactionType' => $TransactionType, "AccountNo" => $Withdrawal['AccountNo'], "Amount" => $Withdrawal['Amount'], "Bank" => $BravoCode, "Branch" => "", "Note" => $Note); //'011C001458' //var_dump($withdraw_value); $ret = $soap->withdraw($Withdrawal_value); if ($ret['table0']['Result'] == 1) { $query = sprintf("CALL sp_UpdateDividendPrivilege_BankID ('%s','%s','%s','%s')", $BankID, $EventID, $AccountID, $UpdatedBy); //echo $query; $result = $this->_MDB2_WRITE->extended->getAll($query); //Can not update if (empty($result) || is_object($result)) { $this->_ERROR_CODE = 22120; write_my_log_path('ErrorCallStore', $query . ' ' . $result->backtrace[0]['args'][4], EVENT_PATH); } else { if (isset($result[0]['varerror'])) { //p_iDividentPrivilege sai hoac dang ky mua chua xac nhan hoac da cat tien roi if ($result[0]['varerror'] == -2) { $this->_ERROR_CODE = 22121; } else { if ($result[0]['varerror'] == -3) { //qua ngay cat tien $this->_ERROR_CODE = 22149; } else { if ($result[0]['varerror'] == -1) { //Exception $this->_ERROR_CODE = 22122; } else { if ($result[0]['varerror'] < 0) { $this->_ERROR_CODE = 22134; write_my_log_path($function_name, $query . ' VarError ' . $result[0]['varerror'], EVENT_PATH); } } } } } } if ($this->_ERROR_CODE != 0) { $soap->rollback($ret['table1']['Id'], $Today); } } else { switch ($ret['table0']['Result']) { case 0: $this->_ERROR_CODE = 0; break; case -2: //Error - bravo $this->_ERROR_CODE = 23002; break; case -1: //Invalid key $this->_ERROR_CODE = 23003; break; case -13: /*Invalid Transaction Type*/ $this->_ERROR_CODE = 23006; break; case -15: /*Invalid CustomerCode*/ $this->_ERROR_CODE = 23005; break; case -16: /*Invalid DestCustomerCode*/ $this->_ERROR_CODE = 23004; break; default: //Unknown Error $this->_ERROR_CODE = 23009; write_my_log_path($function_name, ' Bravo ' . $ret['table0']['Result'], EVENT_PATH); break; } } } else { switch ($dab_rs) { case '-1': //unauthenticate partner $this->_ERROR_CODE = 22135; break; case '-2': //invalid parameters $this->_ERROR_CODE = 22136; break; case '-3': //invalid date $this->_ERROR_CODE = 22137; break; case '-12': // Tai khoan khong ton tai $this->_ERROR_CODE = 12001; break; case '-4': //no customer found $this->_ERROR_CODE = 22140; break; case '-5': //transfer unsuccessful $this->_ERROR_CODE = 22141; break; case '-13': case '1': //invalid account $this->_ERROR_CODE = 22142; break; case '2': //invalid amount $this->_ERROR_CODE = 22143; break; case '3': //duplicate transfer $this->_ERROR_CODE = 22147; break; case '-14': case '5': //not enough balance $this->_ERROR_CODE = 22144; break; case '6': //duplicate account $this->_ERROR_CODE = 22145; break; case '-15': //can not add history transaction $this->_ERROR_CODE = 22228; break; case '-11': case '99': //unknown error $this->_ERROR_CODE = 22138; break; default: $this->_ERROR_CODE = 22139; } } } else { $this->_ERROR_CODE = $Withdrawal['ErrorCode']; } } } catch (Exception $e) { write_my_log_path('PHP-Exception', $function_name . ' Caught exception: ' . $e->getMessage() . ' ' . date('Y-m-d h:i:s'), DEBUG_PATH); $this->_ERROR_CODE = 23022; } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function insertCoSellOrder($CoAccountNo, $AccountNo, $StockID, $OrderQuantity, $OrderPrice, $Session, $FromTypeID, $Note, $OrderDate, $IsAssigner, $IsGotPaper, $CreatedBy, $AccountNoContra, $CompanyNameContra) { $function_name = 'insertCoSellOrder'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; $log[] = sprintf('insertCoSellOrder - CoAccountNo:%s;AccountNo:%s;StockID:%s;OrderQuantity:%s;OrderPrice:%s;Session:%s;FromTypeID:%s;Note:%s;OrderDate:%s;IsAssigner:%s;IsGotPaper:%s;CreatedBy:%s;AccountNoContra:%s;CompanyNameContra:%s;ExecutedTime:%s', $CoAccountNo, $AccountNo, $StockID, $OrderQuantity, $OrderPrice, $Session, $FromTypeID, $Note, $OrderDate, $IsAssigner, $IsGotPaper, $CreatedBy, $AccountNoContra, $CompanyNameContra, date('Y-m-d h:i:s')); if (authenUser(func_get_args(), $this, $function_name) > 0) { $log[] = sprintf('authenUser: ERROR_CODE: %s', $this->_ERROR_CODE); write_my_log_path("insertCoSellOrder", implode("\n --> ", $log), '/home/vhosts/eSMS/htdocs/logs/otc/'); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $log[] = sprintf('authenUser: ERROR_CODE: %s', $this->_ERROR_CODE); // checking account is active / not if (!checkAccountIsActive($AccountNo) || !checkAccountIsActive($CoAccountNo)) { $this->_ERROR_CODE = 30275; $log[] = sprintf('checkAccountIsActive: ERROR_CODE: %s; AccountNo:%s,%s;CoAccountNo: %s,%s', $this->_ERROR_CODE, $AccountNo, checkAccountIsActive($AccountNo) ? 'TRUE' : 'FALSE', $CoAccountNo, checkAccountIsActive($CoAccountNo) ? 'TRUE' : 'FALSE'); write_my_log_path("insertCoSellOrder", implode("\n --> ", $log), '/home/vhosts/eSMS/htdocs/logs/otc/'); return returnXML(func_get_args(), $this->class_name, $function_name, 30275, $this->items, $this); } $log[] = sprintf('checkAccountIsActive: ERROR_CODE: %s; AccountNo:%s,%s;CoAccountNo: %s,%s', $this->_ERROR_CODE, $AccountNo, checkAccountIsActive($AccountNo) ? 'TRUE' : 'FALSE', $CoAccountNo, checkAccountIsActive($CoAccountNo) ? 'TRUE' : 'FALSE'); if (!required($CoAccountNo) || !required($AccountNo) || !required($OrderDate) || !required($StockID) || !required($OrderQuantity) || !required($OrderPrice) || !required($Session) || !unsigned($OrderQuantity) || !unsigned($StockID)) { if (!required($AccountNo) || !required($CoAccountNo)) { $this->_ERROR_CODE = 30051; } if (!required($OrderDate)) { $this->_ERROR_CODE = 30052; } if (!required($StockID) || !unsigned($StockID)) { $this->_ERROR_CODE = 30053; } if (!required($OrderQuantity) || !unsigned($OrderQuantity)) { $this->_ERROR_CODE = 30054; } if (!required($Session)) { $this->_ERROR_CODE = 30055; } if (!required($OrderPrice)) { $this->_ERROR_CODE = 30056; } $log[] = sprintf('check require: ERROR_CODE: %s', $this->_ERROR_CODE); } else { $vip = checkVIPAccount($AccountNo); // 1: exist 0: not exist $vipCo = checkVIPAccount($CoAccountNo); // 1: exist 0: not exist if (($vip == 1 || $vipCo == 1) && $FromTypeID == 5) { // web $this->_ERROR_CODE = 30602; $log[] = sprintf('Vip on web: Fail; AccountNo: %s;CoAccountNo: %s', $vip == 0 ? 'not vip' : 'vip', $vipCo == 0 ? 'not vip' : 'vip'); write_my_log_path("insertCoSellOrder", implode("\n --> ", $log), '/home/vhosts/eSMS/htdocs/logs/otc/'); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } if ((strpos(EOT_PROHIBITION_ACCOUNT, $AccountNo) !== false || strpos(EOT_PROHIBITION_ACCOUNT, $CoAccountNo) !== false) && $FromTypeID == 5) { $this->_ERROR_CODE = 30602; $log[] = sprintf('check EOT_PROHIBITION_ACCOUNT: ERROR_CODE: %s;AccountNo:%s,%s;CoAccountNo:%s,%s', $this->_ERROR_CODE, $AccountNo, strpos(EOT_PROHIBITION_ACCOUNT, $AccountNo), $CoAccountNo, strpos(EOT_PROHIBITION_ACCOUNT, $CoAccountNo)); write_my_log_path("insertCoSellOrder", implode("\n --> ", $log), '/home/vhosts/eSMS/htdocs/logs/otc/'); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } if (!checkStockPrice($StockID, $OrderPrice, $OrderDate)) { $this->_ERROR_CODE = 30057; } $log[] = sprintf('checkStockPrice: ERROR_CODE: %s', $this->_ERROR_CODE); $sellingOrderID = ''; $buyingOrderID = ''; try { if ($this->_ERROR_CODE == 0) { // -------------------------------------------------------------------------------------- // // Insert sell order for $CoAccountNo // -------------------------------------------------------------------------------------- // $query = sprintf("CALL sp_upcom_insertSellingOrder('%s', %u, %u, %u, %u, '%u', '%s', '%s', '%u', '%u', '%s', '%s', '%s')", $CoAccountNo, $StockID, $OrderQuantity, $OrderPrice, $Session, $FromTypeID, $Note, $OrderDate, $IsAssigner, $IsGotPaper, $CreatedBy, $AccountNoContra, $CompanyNameContra); $log[] = sprintf('%s', $query); $mdb = initWriteDB(); $rs = $mdb->extended->getRow($query); $mdb->disconnect(); if (empty($rs)) { $this->_ERROR_CODE = 30060; } else { $result = $rs['varerror']; if ($result < 0) { switch ($result) { case '-1': $this->_ERROR_CODE = 19010; break; case '-2': $this->_ERROR_CODE = 19011; break; case '-3': $this->_ERROR_CODE = 19012; break; case '-4': $this->_ERROR_CODE = 19013; break; case '-5': $this->_ERROR_CODE = 19014; break; case '-6': $this->_ERROR_CODE = 19015; break; default: $this->_ERROR_CODE = $result; } } else { $sellingOrderID = $result; } } $log[] = sprintf('ERROR_CODE: %s', $this->_ERROR_CODE); $log[] = sprintf('SellingOrderID: %s', $sellingOrderID); } if ($this->_ERROR_CODE == 0) { // -------------------------------------------------------------------------------------- // // Insert buy order for $AccountNo // -------------------------------------------------------------------------------------- // $query = sprintf("CALL sp_upcom_insertBuyingOrder('%s', %u, %u, %u, %u, %u, '%s', '%s', '%u', '%u', '%s', '%s', '%s')", $AccountNo, $StockID, $OrderQuantity, $OrderPrice, $Session, $FromTypeID, $Note, $OrderDate, $IsAssigner, $IsGotPaper, $CreatedBy, $AccountNoContra, $CompanyNameContra); $log[] = sprintf('%s', $query); $rs = $this->_MDB2_WRITE->extended->getRow($query); if (empty($rs)) { $this->_ERROR_CODE = 30015; $log[] = sprintf('ERROR_CODE: %s', $this->_ERROR_CODE); } else { $result = $rs['varerror']; if ($result < 0) { switch ($result) { case '-1': $this->_ERROR_CODE = 19001; break; case '-2': $this->_ERROR_CODE = 19002; break; case '-3': $this->_ERROR_CODE = 19003; break; case '-4': $this->_ERROR_CODE = 19004; break; case '-5': $this->_ERROR_CODE = 19005; break; default: $this->_ERROR_CODE = $result; } $log[] = sprintf('ERROR_CODE: %s', $this->_ERROR_CODE); } else { $isQuotaAccount = CheckIsQuotaAccount($AccountNo); $vip = checkVIPAccount($AccountNo); // 1: exist 0: not exist $log[] = sprintf('ERROR_CODE: %s', $this->_ERROR_CODE); $log[] = sprintf('BuyingOrderID: %s', $result); $buyingOrderID = $result; //block money in bank $query = sprintf("SELECT * FROM vw_ListAccountBank_Detail WHERE AccountNo='%s' ORDER BY Priority ", $AccountNo); $log[] = sprintf('%s', $query); $mdb = initWriteDB(); $bank_rs = $mdb->extended->getAll($query); $log[] = sprintf('PAGODA_ACCOUNT: %s', strpos(PAGODA_ACCOUNT, $AccountNo) === false ? 'FALSE' : 'TRUE'); $log[] = sprintf('VIP_ACCOUNT: %s', $vip == 0 ? 'FALSE' : 'TRUE'); if (strpos(PAGODA_ACCOUNT, $AccountNo) === false && $vip == 0) { $dab_rs = 999; if ($isQuotaAccount != 0) { $BankID = NHHM; $mdb = initWriteDB(); $query = sprintf("CALL sp_VirtualBank_Lock('%s', %u, %u, %f, '%s', '%s')", $AccountNo, NHHM, $result, $rs['varordervalue'], $OrderDate, $CreatedBy); $off_rs = $mdb->extended->getRow($query); $mdb->disconnect(); $dab_rs = $off_rs['varerror']; $log[] = sprintf('block_money: bankid:NHHM;result:%s', $dab_rs); } else { for ($i = 0; $i < count($bank_rs); $i++) { switch ($bank_rs[$i]['bankid']) { case DAB_ID: $dab =& new CDAB(); $dab_rs = $dab->blockMoney($bank_rs[$i]['bankaccount'], $bank_rs[$i]['cardno'], $AccountNo, $result, $rs['varordervalue'], $OrderDate); $log[] = sprintf('block_money: bankid:DAB_ID;result:%s', $dab_rs); break; case VCB_ID: $dab =& new CVCB(); $OrderID = $result . $rs['varunitcode']; if (!killStupidBank()) { // VCB is stupid $dab_rs = $dab->blockMoney($AccountNo, $OrderID, $rs['varordervalue']); } else { $dab_rs = 30999; } $log[] = sprintf('block_money: bankid:VCB_ID;result:%s', $dab_rs); break; case ANZ_ID: $OrderID = $result; $query = sprintf("CALL sp_anz_money_request_lock( %u, '%s', '%s', '%s' )", $OrderID, $AccountNo, $rs['varordervalue'], $CreatedBy); $this->_MDB2_WRITE->connect(); $rs1 = $this->_MDB2_WRITE->extended->getRow($query); $this->_MDB2_WRITE->disconnect(); switch ($rs1['varerror']) { case -1: $dab_rs = 34511; //database error break; case -2: $dab_rs = 34512; //not enough money to unlock break; case -3: $dab_rs = 34513; //account does not exist break; default: $dab_rs = $rs1['varerror']; } $log[] = sprintf('block_money: bankid:ANZ_ID;result:%s', $dab_rs); // added by Quang, 20100407 ------------------------------------ break; case OFFLINE: //inAccountNo varchar(20),inBankID int,inOrderID bigint,inOrderAmount double,inOrderDate date,inCreatedBy $mdb = initWriteDB(); $query = sprintf("CALL sp_VirtualBank_Lock('%s', %u, %u, %f, '%s', '%s')", $AccountNo, OFFLINE, $result, $rs['varordervalue'], $OrderDate, $CreatedBy); $off_rs = $mdb->extended->getRow($query); $mdb->disconnect(); $dab_rs = $off_rs['varerror']; $log[] = sprintf('block_money: bankid:OFFLINE;result:%s', $dab_rs); break; // end add ----------------------------------------------------- } if ($dab_rs == 0) { $BankID = $bank_rs[$i]['bankid']; break; } } } } else { $dab_rs = 0; } if ($dab_rs == 0) { //Successfully $log[] = sprintf('successded_block_money'); $mdb = initWriteDB(); if ($Session <= 3) { $query = sprintf("CALL sp_updateBuyingOrderFromPendingToApproved(%u, %u) ", $result, $BankID); } else { $query = sprintf("CALL sp_updateBuyingOrderFromPendingToTransfered(%u, %u) ", $result, $BankID); } $log[] = sprintf('%s', $query); $status_rs = $mdb->extended->getRow($query); $mdb->disconnect(); if (empty($status_rs)) { $this->_ERROR_CODE = 30143; } else { $result = $status_rs['varerror']; if ($result < 0) { //update Order Status fail switch ($result) { case '-1': $this->_ERROR_CODE = 30141; break; case '-2': $this->_ERROR_CODE = 30142; break; } //switch } // if } // if WS $log[] = sprintf('ERROR_CODE: %s', $this->_ERROR_CODE); } else { // bank fail $log[] = sprintf('failed_block_money'); switch ($dab_rs) { case '-1': $this->_ERROR_CODE = 41020; break; case '-2': $this->_ERROR_CODE = 41021; break; case '-3': $this->_ERROR_CODE = 41022; break; case '-4': $this->_ERROR_CODE = 41023; break; case '-5': $this->_ERROR_CODE = 41024; break; case '1': $this->_ERROR_CODE = 41025; break; case '2': $this->_ERROR_CODE = 41026; break; case '3': $this->_ERROR_CODE = 41027; break; case '4': $this->_ERROR_CODE = 41028; break; case '5': $this->_ERROR_CODE = 41030; break; case '99': $this->_ERROR_CODE = 41029; break; default: $this->_ERROR_CODE = $dab_rs; } $log[] = sprintf('ERROR_CODE: %s', $this->_ERROR_CODE); $mdb = initWriteDB(); $query = sprintf("CALL sp_updateBuyingOrderFromPendingToDenied(%u, '%s') ", $result, $dab_rs); $log[] = sprintf('%s', $query); $status_rs = $mdb->extended->getRow($query); $mdb->disconnect(); if (empty($status_rs)) { $this->_ERROR_CODE = 30144; } else { $result = $status_rs['varerror']; if ($result < 0) { //update Order Status fail switch ($result) { case '-1': $this->_ERROR_CODE = 30145; break; case '-2': $this->_ERROR_CODE = 30146; break; } //switch } // if } // if WS $log[] = sprintf('ERROR_CODE: %s', $this->_ERROR_CODE); } } } // -------------------------------------------------------------------------------------- // // End Insert buy order for $AccountNo // -------------------------------------------------------------------------------------- // } $this->items[0] = new SOAP_Value('item', $struct, array("BuyingOrderID" => new SOAP_Value("BuyingOrderID", "string", $buyingOrderID), "SellingOrderID" => new SOAP_Value("SellingOrderID", "string", $sellingOrderID))); } catch (Exception $e) { $log[] = sprintf('Exception: %s', $e->getMessage()); $this->_ERROR_CODE = 30060; } } write_my_log_path("insertCoSellOrder", implode("\n --> ", $log), '/home/vhosts/eSMS/htdocs/logs/otc/'); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function getTransferingOrderForReSend($OrderDate, $AccountNo, $OrderID) { $function_name = 'getTransferingOrderForReSend'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } try { $this->_MDB2_WRITE = newInitWriteDB(); $query = sprintf("CALL sp_hnx_GetTransferingOrderForReSend('%s', '%s', %u)", $OrderDate, $AccountNo, $OrderID); $result = $this->_MDB2_WRITE->extended->getAll($query); $count = count($result); if ($count > 0) { for ($i = 0; $i < $count; $i++) { $this->items[$i] = new SOAP_Value('item', $struct, array("OrderID" => new SOAP_Value("OrderID", "string", $result[$i]['OrderID']), "OrderNumber" => new SOAP_Value("OrderNumber", "string", $result[$i]['OrderNumber']), "AccountNo" => new SOAP_Value("AccountNo", "string", $result[$i]['AccountNo']), "OrderSideName" => new SOAP_Value("OrderSideName", "string", $result[$i]['OrderSideName']), "Symbol" => new SOAP_Value("Symbol", "string", $result[$i]['Symbol']), "OrderStyleName" => new SOAP_Value("OrderStyleName", "string", $result[$i]['OrderStyleName']), "OrderPrice" => new SOAP_Value("OrderPrice", "string", $result[$i]['OrderPrice']), "OrderQuantity" => new SOAP_Value("OrderQuantity", "string", $result[$i]['OrderQuantity']), "StatusName" => new SOAP_Value("StatusName", "string", $result[$i]['StatusName']), "GetNumber" => new SOAP_Value("GetNumber", "string", $result[$i]['o.GetNumber']))); } } $content = date("d/m/Y H:i:s") . "\t" . $query . "\t--> " . $count; another_write_log($function_name, $content, 'directly_tranfer'); } catch (Exception $e) { $this->_ERROR_CODE = $e->getMessage(); } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function deleteSetOfEmployee4Group($GroupID, $SetOfEmployeeID, $UpdatedBy) { $function_name = 'deleteSetOfEmployee4Group'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; $delete_log = array(); $lastest_error = 0; if (authenUser(func_get_args(), $this, $function_name) > 0) { $delete_log[] = sprintf('GroupID:%s;SetOfEmployeeID:%s;UpdatedBy:%s;ErrorCode:%s;ExecutedTime:%s', $GroupID, $SetOfEmployeeID, $UpdatedBy, $this->_ERROR_CODE, date('Y-m-d h:i:s')); write_my_log_path("deleteSetOfEmployee4Group", implode("\n --> ", $delete_log), '/home/vhosts/eSMS/htdocs/logs/employee/'); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } if (!required($GroupID) || !unsigned($GroupID) || !required($SetOfEmployeeID)) { if (!required($GroupID) || !unsigned($GroupID)) { $this->_ERROR_CODE = $lastest_error = 32071; } if (!required($SetOfEmployeeID)) { $this->_ERROR_CODE = $lastest_error = 32070; } $delete_log[] = sprintf('GroupID:%s;SetOfEmployeeID:%s;UpdatedBy:%s;ErrorCode:%s;ExecutedTime:%s', $GroupID, $SetOfEmployeeID, $UpdatedBy, $this->_ERROR_CODE, date('Y-m-d h:i:s')); } else { $arr_epm = explode(',', $SetOfEmployeeID); $delete_success = array(); $delete_fail = array(); $delete_log[] = sprintf('GroupID:%s;SetOfEmployeeID:%s;UpdatedBy:%s;ExecutedTime:%s', $GroupID, $SetOfEmployeeID, $UpdatedBy, date('Y-m-d h:i:s')); foreach ($arr_epm as $emp_id) { $this->_ERROR_CODE = 0; $result = NULL; if (!unsigned($emp_id)) { $this->_ERROR_CODE = 32070; $delete_fail[] = trim($emp_id); } else { $query = sprintf("CALL sp_deleteEmployeeGroup(%u, %u, '%s')", trim($emp_id), $GroupID, $UpdatedBy); $mdb = initWriteDB(); $rs = $mdb->extended->getRow($query); if (empty($rs)) { $this->_ERROR_CODE = 32072; $delete_fail[] = trim($emp_id); } else { $result = $rs['varerror']; if ($result < 0) { $delete_fail[] = trim($emp_id); switch ($result) { case '-1': $this->_ERROR_CODE = 32073; break; case '-2': $this->_ERROR_CODE = 32074; break; } } } } if ($this->_ERROR_CODE == 0) { $delete_success[] = trim($emp_id); } else { $lastest_error = $this->_ERROR_CODE; } $delete_log[] = sprintf('GroupID:%s;EmployeeID:%s;UpdatedBy:%s;ErrorCode:%s;ExecutedTime:%s', $GroupID, trim($emp_id), $UpdatedBy, $this->_ERROR_CODE, date('Y-m-d h:i:s')); } $this->items[] = new SOAP_Value('item', $struct, array("SuccessdedEmployeeID" => new SOAP_Value("SuccessdedEmployeeID", "string", implode(', ', $delete_success)), "FailedEmployeeID" => new SOAP_Value("FailedEmployeeID", "string", implode(', ', $delete_fail)))); } write_my_log_path("deleteSetOfEmployee4Group", implode("\n --> ", $delete_log), '/home/vhosts/eSMS/htdocs/logs/employee/'); return returnXML(func_get_args(), $this->class_name, $function_name, $lastest_error, $this->items, $this); }
function InsertListOfQuota4AcountVB($TradingDate) { $class_name = $this->class_name; $function_name = 'InsertListOfQuota4AcountVB'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; $log[] = sprintf('InsertListOfQuota4AcountVB - TradingDate:%s;BankID:%s;ExecutedTime:%s', $TradingDate, OFFLINE, date('Y-m-d h:i:s')); if (authenUser(func_get_args(), $this, $function_name) > 0) { $log[] = sprintf('ErrorCode:%s(authenUser);', $this->_ERROR_CODE); write_my_log_path("InsertListOfQuota4AcountVB", implode("\n --> ", $log), '/home/vhosts/eSMS/htdocs/logs/quota/'); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $query = sprintf("CALL sp_quota_getQuota4Bravo('%s', %u)", $TradingDate, OFFLINE); $result = $this->_MDB2->extended->getAll($query); $count = count($result); $log[] = sprintf('Query:%s;Count:%s', $query, $count); $f_args = func_get_args(); $argscount = count($f_args); for ($i = 0; $i < $count; $i++) { $error_code = 0; $query = sprintf("CALL sp_quota_insertQuota4AccountVB(%u, %f, '%s', '%s', %u, '%s')", $result[$i]['accountid'], $result[$i]['debtamount'], 'Nộp hạn mức', $TradingDate, OFFLINE, $f_args[$argscount - 2]); $mdb = initWriteDB(); $result2 = $mdb->extended->getAll($query); $log[] = sprintf('Query:%s; Times:%s', $query, $i); if (!isset($result2[0]['varerror'])) { $error_code = 40001; } else { $varerror = $result2[0]['varerror']; if ($varerror < 0) { switch ($varerror) { case '-1': $error_code = 40002; break; case '-2': $error_code = 40047; break; case '-3': $error_code = 40048; break; case '-4': $error_code = 40049; break; case '-5': $error_code = 40050; break; default: $error_code = $varerror; break; } } } $log[] = sprintf('ErrorCode:%s;', $error_code); if ($error_code == 0) { $deposit = array("TradingDate" => date("Y-m-d"), 'TransactionType' => BRAVO_QUOTA, "AccountNo" => $result[$i]['accountno'], "Amount" => $result[$i]['debtamount'], "Fee" => $result[$i]['debtamount'], "Bank" => VIRTUAL_BANK_BRAVO_BANKCODE, "Branch" => "", "Note" => 'Nop han muc'); $log[] = sprintf('Bravo: TransactionType:%s;AccountNo:%s;Amount:%s;Fee:%s;Bank:%s;', BRAVO_QUOTA, $result[$i]['accountno'], $result[$i]['debtamount'], $result[$i]['debtamount'], VIRTUAL_BANK_BRAVO_BANKCODE); $soap =& new Bravo(); $ret = $soap->deposit($deposit); if ($ret['table0']['Result'] != 1) { switch ($ret['table0']['Result']) { case '-2': $error_code = 23002; break; case '-1': $error_code = 23003; break; case '-13': $error_code = 23006; break; case '-15': $error_code = 23005; break; case '-16': $error_code = 23004; break; default: $error_code = 'Bravo' . $ret['table0']['Result']; } } $log[] = sprintf('ErrorCode:%s;', $error_code); } if ($error_code != 0) { $this->_ERROR_CODE = $error_code; $this->items[] = new SOAP_Value('item', $struct, array("AccountID" => new SOAP_Value("AccountID", "string", $result[$i]['accountid']), "AccountNo" => new SOAP_Value("AccountNo", "string", $result[$i]['accountno']), "DebtAmount" => new SOAP_Value("DebtAmount", "string", $result[$i]['debtamount']), "BravoCode" => new SOAP_Value("BravoCode", "string", $result[$i]['bravocode']), "ErrorCode" => new SOAP_Value("ErrorCode", "string", $error_code))); } } $log[] = "\n\n"; write_my_log_path("InsertListOfQuota4AcountVB", implode("\n --> ", $log), '/home/vhosts/eSMS/htdocs/logs/quota/'); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function UpdateIsCollectedVSDFee() { $class_name = $this->class_name; $function_name = 'UpdateIsCollectedVSDFee'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $date_array = getdate(); $csv_dir = $this->path . 'vcb_kq/'; if (!is_dir($csv_dir)) { mkdir($csv_dir, 0755); } $csv_dir = $csv_dir . 'logs/'; if (!is_dir($csv_dir)) { mkdir($csv_dir, 0755); } $csv_dir = $csv_dir . $date_array['year'] . '/'; if (!is_dir($csv_dir)) { mkdir($csv_dir, 0755); } $csv_dir = $csv_dir . $date_array['mon'] . '/'; if (!is_dir($csv_dir)) { mkdir($csv_dir, 0755); } $filename = 'eps' . date('Ymd') . '_buy_log.vcbit'; $filepath = $csv_dir . $filename; $vsdlogfile = 'vsdrefno_' . date('Ymd') . '.txt'; $vsdlogfile = sprintf('%s%s%s/%s/%s', $this->path, 'vcb_kq/', $date_array['year'], $date_array['mon'], $vsdlogfile); if (is_file($vsdlogfile)) { if (!is_file($filepath)) { $conn_id = ftp_connect($this->ftp_server); // login with username and password $login_result = ftp_login($conn_id, $this->ftp_user_name, $this->ftp_user_pass); // check connection if (!$conn_id || !$login_result) { $this->_ERROR_CODE = 24001; } else { $destination_file = $filepath; // open some file to write to $handle = fopen($destination_file, 'w'); $source_file = 'OUT/' . $filename; // get the size of $file $res = ftp_size($conn_id, $source_file); if ($res != -1) { $upload = ftp_fget($conn_id, $handle, $source_file, FTP_BINARY); // check upload status if (!$upload) { $this->_ERROR_CODE = 24002; } else { $this->_ERROR_CODE = 0; } } else { //echo "couldn't get the size"; $this->_ERROR_CODE = 24005; } // close the FTP stream ftp_close($conn_id); fclose($handle); } } if (file_exists($filepath) === true) { $handle = fopen($vsdlogfile, "r"); $vsdlogcontent = fgets($handle); fclose($handle); $vsdrefarray = explode('_', $vsdlogcontent); $handle = fopen($filepath, "r"); while (!feof($handle)) { $line = fgets($handle); $splited = explode(';', $line); if (in_array($splited[1], $vsdrefarray)) { $orderID = substr($splited[1], 0, strlen($splited[1]) - 6); $unitCode = substr($splited[1], -6); if ($splited[15] == '0000') { $this->_MDB2->connect(); $query = sprintf("CALL sp_FeeForVSD_updateIsCollectedForVCB('%s')", $orderID); $result = $this->_MDB2->extended->getAll($query); $this->_MDB2->disconnect(); } $content = $line . ' ' . $query . ' varerror: ' . $result[0]['varerror']; write_my_log_path('UpdateIsCollectedVSDFee', $content, $csv_dir); $this->items[] = new SOAP_Value('item', $struct, array('Refno' => new SOAP_Value("Refno", "string", $splited[1]), 'OrderID' => new SOAP_Value("OrderID", "string", $orderID), 'UnitCode' => new SOAP_Value("UnitCode", "string", $unitCode), 'AccountNo' => new SOAP_Value("AccountNo", "string", $splited[4]), 'Amount' => new SOAP_Value("Amount", "string", $splited[12]), 'VCBResult' => new SOAP_Value("VCBResult", "string", $splited[15]), 'Note' => new SOAP_Value("Note", "string", substr($splited[16], 0, strlen($splited[16]) - 1)), 'UpdateIsCollectedResult' => new SOAP_Value("UpdateIsCollectedResult", "string", $result[0]['varerror']))); } } fclose($handle); } else { // Chua co log file $this->_ERROR_CODE = 24004; } } else { // Khong tim thay file vsdfee refno log $this->_ERROR_CODE = 43007; } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
/** Function: NewGetPaymentDetailListWithCondition Description: Input: Output: ??? */ function NewGetPaymentDetailListWithCondition($WhereClause, $TimeZone) { $function_name = 'NewGetPaymentDetailListWithCondition'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $query = sprintf("CALL sp_Mortage_getPaymentDetailConditionList( \"%s\", \"%s\")", $WhereClause, $TimeZone); $result = $this->_MDB2->extended->getAll($query); for ($i = 0; $i < count($result); $i++) { $this->items[$i] = new SOAP_Value('item', $struct, array("ID" => new SOAP_Value("ID", "string", $result[$i]['id']), "MortageID" => new SOAP_Value("MortageID", "string", $result[$i]['mortageid']), "AccountID" => new SOAP_Value("AccountNo", "string", $result[$i]['accountid']), "AccountNo" => new SOAP_Value("AccountNo", "string", $result[$i]['accountno']), "StockID" => new SOAP_Value("StockID", "string", $result[$i]['stockid']), "Symbol" => new SOAP_Value("Symbol", "string", $result[$i]['symbol']), "Quantity" => new SOAP_Value("Quantity", "string", $result[$i]['quantity']), "PaymentDate" => new SOAP_Value("PaymentDate", "string", $result[$i]['paymentdate']), "Note" => new SOAP_Value("Note", "string", $result[$i]['note']), "IsConfirmed" => new SOAP_Value("IsConfirmed", "string", $result[$i]['isconfirmed']), "FullName" => new SOAP_Value("FullName", "string", $result[$i]['fullname']), "CreatedBy" => new SOAP_Value("CreatedBy", "string", $result[$i]['createdby']), "CreatedDate" => new SOAP_Value("CreatedDate", "string", $result[$i]['createddate']), "UpdatedBy" => new SOAP_Value("UpdatedBy", "string", $result[$i]['updatedby']), "UpdatedDate" => new SOAP_Value("UpdatedDate", "string", $result[$i]['updateddate']))); } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
/** * Function CloseBravoAccount : update money --> bravo * Input : $TradingDate * OutPut : error code and items ( AccountNo, success or fail) */ function CloseBravoAccount($AccountNo) { $class_name = $this->class_name; $function_name = 'CloseBravoAccount'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $this->items = array(); $soap =& new Bravo(); $this->_ERROR_CODE = $soap->closeCustomer($AccountNo); $this->write_my_log('MoneyBravo', $function_name . ' AccountNo ' . $AccountNo . ' ' . $date . ' varerror ' . $this->_ERROR_CODE . ' ' . date('Y-m-d h:i:s')); return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }
function ConfirmExtraCollectDisbursement($ID, $UpdatedBy) { $function_name = 'ConfirmExtraCollectDisbursement'; $struct = '{urn:' . $this->class_name . '}' . $function_name . 'Struct'; if (authenUser(func_get_args(), $this, $function_name) > 0) { return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } $query = sprintf("CALL sp_ExtraCollectDisbursement_getInfo('%s')", $ID); $rs = $this->_MDB2->extended->getRow($query); $BankAccount = $rs['bankaccount']; $BankID = (int) $rs['bankid']; $BravoCode = (int) $rs['bravocode']; $Amount = $rs['amount']; $AccountNo = $rs['accountno']; $TradingDate = $rs['tradingdate']; $Note = $rs['note']; $TranTypeID = (int) $rs['trantypeid']; if ($BankAccount != '') { switch ($BankID) { case DAB_ID: $dab =& new CDAB(); $refno = $AccountNo . "_" . $ID . "_" . date('Y-m-d'); if ($TranTypeID == 1) { // Thu tien $dab_rs = $dab->transfertoEPS($BankAccount, $AccountNo, $refno, $Amount, $Note); } elseif ($TranTypeID == 2) { // Chuyen tien $dab_rs = $dab->transferfromEPS($BankAccount, $AccountNo, $refno, $Amount, $Note); } break; case OFFLINE: $mdb = initWriteDB(); $query = sprintf("CALL sp_VirtualBank_ExtraCollectDisbursement(%u, '%s', '%s')", $ID, date("Y-m-d"), $UpdatedBy); $offline_rs = $mdb->extended->getRow($query); $mdb->disconnect(); if (PEAR::isError($offline_rs)) { $this->_ERROR_CODE = 31500; } else { $result = $offline_rs['varerror']; if ($result < 0) { switch ($result) { case '-1': $this->_ERROR_CODE = 31501; break; case '-2': $this->_ERROR_CODE = 31502; break; case '-3': $this->_ERROR_CODE = 31503; break; case '-4': $this->_ERROR_CODE = 30624; // khong du tien break; case '-5': $this->_ERROR_CODE = 31504; break; case '-9': $this->_ERROR_CODE = 31505; break; } //switch } else { //if $dab_rs = 0; } } //if PEAR break; } //switch if ($dab_rs == 0) { $query = sprintf("CALL sp_ExtraCollectDisbursement_Confirm(%u,'%s')", $ID, $UpdatedBy); $rs = $this->_MDB2_WRITE->extended->getRow($query); if ($rs['varerror'] < 0) { switch ($rs['varerror']) { case '-2': $this->_ERROR_CODE = 31450; break; } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); } else { //update Bank $soap =& new Bravo(); if ($TranTypeID == 1) { // Thu tien $transactionType = "M13.09"; $sign = '-'; } elseif ($TranTypeID == 2) { // Chuyen tien $transactionType = "M13.08"; $sign = '%2B'; } if ($BankID == OFFLINE) { $query = "SELECT mobilephone,ab.usableamount FROM " . TBL_INVESTOR; $query .= " i INNER JOIN " . TBL_ACCOUNT . " a ON(i.id=a.investorId)"; $query .= " INNER JOIN " . TBL_ACCOUNT_BANK . " ab ON(a.id=ab.accountid)"; $query .= " WHERE a.accountNo='" . $AccountNo . "' AND ab.bankid=" . OFFLINE; $mdb = initWriteDB(); $acc_rs = $mdb->extended->getRow($query); $mdb->disconnect(); if (!empty($acc_rs['mobilephone'])) { $message = 'Tai khoan cua quy khach tai KIS da thay doi: ' . $sign . number_format($Amount, 0, '.', ',') . '. ' . $Note; $message .= '. So du hien tai la: ' . number_format($acc_rs['usableamount'], 0, '.', ','); sendSMS(array('Phone' => $acc_rs['mobilephone'], 'Content' => $message)); } } $Deposit_value = array("TradingDate" => date('Y-m-d'), 'TransactionType' => $transactionType, "AccountNo" => $AccountNo, "Amount" => $Amount, "Bank" => $BravoCode, "Branch" => "", "Note" => $Note); $ret = $soap->deposit($Deposit_value); if ($ret['table0']['Result'] != 1) { switch ($ret['table0']['Result']) { case 0: $this->_ERROR_CODE = 0; break; case -2: //Error - bravo $this->_ERROR_CODE = 23002; break; case -1: //Invalid key $this->_ERROR_CODE = 23003; break; case -13: /*Invalid Transaction Type*/ $this->_ERROR_CODE = 23006; break; case -15: /*Invalid CustomerCode*/ $this->_ERROR_CODE = 23005; break; case -16: /*Invalid DestCustomerCode*/ $this->_ERROR_CODE = 23004; break; default: //Unknown Error $this->_ERROR_CODE = $ret['table0']['Result']; break; } if ($this->_ERROR_CODE != 0 && $Deposit_value['Amount'] > 0) { $soap->rollback($ret['table1']['Id'], date('Y-m-d')); } } } //update bank } else { switch ($dab_rs) { case '-1': //unauthenticate partner $this->_ERROR_CODE = 22135; break; case '-2': //invalid parameters $this->_ERROR_CODE = 22136; break; case '-3': //invalid date $this->_ERROR_CODE = 22137; break; case '-4': //no customer found $this->_ERROR_CODE = 22140; break; case '-5': //transfer unsuccessful $this->_ERROR_CODE = 22141; break; case '1': //invalid account $this->_ERROR_CODE = 22142; break; case '2': //invalid amount $this->_ERROR_CODE = 22143; break; case '3': //duplicate transfer $this->_ERROR_CODE = 22147; break; case '5': //not enough balance $this->_ERROR_CODE = 22144; break; case '6': //duplicate account $this->_ERROR_CODE = 22145; break; case '99': //unknown error $this->_ERROR_CODE = 22138; break; default: $this->_ERROR_CODE = 22139; } } // bank } else { //bank account $this->_ERROR_CODE = 31452; } return returnXML(func_get_args(), $this->class_name, $function_name, $this->_ERROR_CODE, $this->items, $this); }