1
0
mirror of synced 2024-11-22 21:36:10 +03:00

fix orderHistory init time;

This commit is contained in:
Grisha Pomadchin 2014-01-28 17:44:21 +04:00
parent 83f84ebb7f
commit 08c5169417
3 changed files with 28 additions and 17 deletions

View File

@ -20,6 +20,7 @@ class ICrmOrderActions
/** /**
* Mass order uploading, without repeating; always returns true, but writes error log * Mass order uploading, without repeating; always returns true, but writes error log
* @param $pSize
* @param $failed -- flag to export failed orders * @param $failed -- flag to export failed orders
* @return boolean * @return boolean
*/ */
@ -365,7 +366,6 @@ class ICrmOrderActions
$dateStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY_DATE, null); $dateStart = COption::GetOptionString(self::$MODULE_ID, self::$CRM_ORDER_HISTORY_DATE, null);
if(!$dateStart) { if(!$dateStart) {
$dateStart = new \DateTime(); $dateStart = new \DateTime();
$dateStart = $dateStart->format('Y-m-d H:i:s'); $dateStart = $dateStart->format('Y-m-d H:i:s');
@ -373,8 +373,15 @@ class ICrmOrderActions
$orderHistory = $api->orderHistory($dateStart); $orderHistory = $api->orderHistory($dateStart);
echo $dateStart;
echo '<br />';
$dateStart = new \DateTime($dateStart); $dateStart = new \DateTime($dateStart);
echo json_encode($orderHistory);
self::eventLog('ICrmOrderActions::orderHistory', 'history_log', json_encode($orderHistory));
// pushing existing orders // pushing existing orders
foreach ($orderHistory as $order) { foreach ($orderHistory as $order) {
@ -399,7 +406,7 @@ class ICrmOrderActions
$arUser = $dbUser->Fetch(); $arUser = $dbUser->Fetch();
$registeredUserID = $arUser['ID']; $registeredUserID = $arUser['ID'];
} else { } else {
$loginEmail ? $login = $order['customer']['email'] : $login = 'user_' . (microtime(true) * 100); $login = 'user_' . (microtime(true) * 100);
$registerNewUser = true; $registerNewUser = true;
} }
} }
@ -504,7 +511,7 @@ class ICrmOrderActions
break; break;
} }
if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']] > 4)) { if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']]) > 4) {
switch ($ar['CODE']) { switch ($ar['CODE']) {
/* case $optionsOrderProps[$arFields['PERSON_TYPE_ID']]['country']: $resOrderDeliveryAddress['country'] = self::toJSON($ar['VALUE']); /* case $optionsOrderProps[$arFields['PERSON_TYPE_ID']]['country']: $resOrderDeliveryAddress['country'] = self::toJSON($ar['VALUE']);
break; break;
@ -573,7 +580,7 @@ class ICrmOrderActions
if (isset($order['deliveryAddress']['text'])) if (isset($order['deliveryAddress']['text']))
self::addOrderProperty($optionsOrderProps[$arFields['PERSON_TYPE_ID']]['text'], self::fromJSON($order['deliveryAddress']['text']), $order['externalId']); self::addOrderProperty($optionsOrderProps[$arFields['PERSON_TYPE_ID']]['text'], self::fromJSON($order['deliveryAddress']['text']), $order['externalId']);
if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']] > 4)) { if (count($optionsOrderProps[$arFields['PERSON_TYPE_ID']]) > 4) {
if (isset($order['deliveryAddress']['street'])) if (isset($order['deliveryAddress']['street']))
self::addOrderProperty($optionsOrderProps[$arFields['PERSON_TYPE_ID']]['street'], self::addOrderProperty($optionsOrderProps[$arFields['PERSON_TYPE_ID']]['street'],
self::fromJSON($order['deliveryAddress']['street']), $order['externalId']); self::fromJSON($order['deliveryAddress']['street']), $order['externalId']);
@ -875,10 +882,10 @@ class ICrmOrderActions
* *
* creates order or returns array of order and customer for mass upload * creates order or returns array of order and customer for mass upload
* *
* @param type $orderId * @param array $arFields
* @param type $api * @param $api
* @param type $arParams * @param $arParams
* @param type $send * @param $send
* @return boolean * @return boolean
* @return array - array('order' = $order, 'customer' => $customer) * @return array - array('order' = $order, 'customer' => $customer)
*/ */
@ -1117,7 +1124,7 @@ class ICrmOrderActions
* removes all empty fields from arrays * removes all empty fields from arrays
* working with nested arrs * working with nested arrs
* *
* @param type $arr * @param array $arr
* @return boolean * @return boolean
*/ */
public static function clearArr($arr) { public static function clearArr($arr) {
@ -1137,9 +1144,9 @@ class ICrmOrderActions
/** /**
* *
* @global type $APPLICATION * @global $APPLICATION
* @param type $str in SITE_CHARSET * @param $str in SITE_CHARSET
* @return type $str in utf-8 * @return $str in utf-8
*/ */
public static function toJSON($str) { public static function toJSON($str) {
global $APPLICATION; global $APPLICATION;
@ -1149,9 +1156,9 @@ class ICrmOrderActions
/** /**
* *
* @global type $APPLICATION * @global $APPLICATION
* @param type $str in utf-8 * @param $str in utf-8
* @return type $str in SITE_CHARSET * @return $str in SITE_CHARSET
*/ */
public static function fromJSON($str) { public static function fromJSON($str) {
global $APPLICATION; global $APPLICATION;

View File

@ -75,7 +75,9 @@ class ICrmOrderEvent {
/** /**
* writeDataOnOrderCreate via api * writeDataOnOrderCreate via api
* *
* @param integer $ID - Order Id * @param $ID - Order Id
* @param array $arFields
* @return boolean
*/ */
function writeDataOnOrderCreate($ID, $arFields) { function writeDataOnOrderCreate($ID, $arFields) {

View File

@ -807,7 +807,6 @@ class intaro_intarocrm extends CModule {
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_LAST_ID, 0);
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_DISCHARGE, 1);
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array())); COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_FAILED_IDS, serialize(array()));
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY_DATE, date('Y-m-d H:i:s'));
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), GetMessage('MODULE_INSTALL_TITLE'),
@ -1159,6 +1158,9 @@ class intaro_intarocrm extends CModule {
$this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key); $this->INTARO_CRM_API = new \IntaroCrm\RestApi($api_host, $api_key);
$this->INTARO_CRM_API->statisticUpdate(); $this->INTARO_CRM_API->statisticUpdate();
// in fin order
COption::SetOptionString($this->MODULE_ID, $this->CRM_ORDER_HISTORY_DATE, date('Y-m-d H:i:s'));
$APPLICATION->IncludeAdminFile( $APPLICATION->IncludeAdminFile(
GetMessage('MODULE_INSTALL_TITLE'), GetMessage('MODULE_INSTALL_TITLE'),
$_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step6.php' $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/' . $this->MODULE_ID . '/install/step6.php'