Example #1
0
 public function calculateForeverListingSchedule()
 {
     echo date("H") . "\n";
     if (in_array(date("H"), array('02', '12', '17', '18'))) {
         require_once __DOCROOT__ . '/module/template.php';
         $today = date("Y-m-d");
         //$Site = $argv[2];
         switch (date("H")) {
             case "02":
                 $day = date("Y-m-d", time() + 24 * 60 * 60);
                 $Site = "Australia";
                 $sql_1 = "select Id,accountId,ForeverListingTime,ForeverListingChinaTime from template where status = 7 and Site = 'Australia'";
                 break;
             case "12":
                 $day = date("Y-m-d", time() + 24 * 60 * 60);
                 $Site = "US";
                 $sql_1 = "select Id,accountId,ForeverListingTime,ForeverListingChinaTime from template where status = 7 and (Site = 'US' or Site = 'eBayMotors')";
                 break;
             case "17":
                 $day = date("Y-m-d", time() + 24 * 60 * 60);
                 $Site = "UK";
                 $sql_1 = "select Id,accountId,ForeverListingTime,ForeverListingChinaTime from template where status = 7 and Site = 'UK'";
                 break;
             case "18":
                 $day = date("Y-m-d", time() + 24 * 60 * 60);
                 $Site = "Germany";
                 $sql_1 = "select Id,accountId,ForeverListingTime,ForeverListingChinaTime from template where status = 7 and (Site = 'Germany' or Site = 'France')";
                 break;
         }
         //$sql_1 = "select scheduleTemplateName,accountId from template where status = 2 and Site = '".$Site."'";
         $this->log("calculateForeverListingSchedule-" . $Site . ".html", $sql_1 . "<br>");
         $result_1 = mysql_query($sql_1, Cron::$database_connect);
         $i = 0;
         $template = new Template();
         $template->setBatch(true);
         while ($row_1 = mysql_fetch_assoc($result_1)) {
             $sql_2 = "select count(*) as num from items where Status = 2 and TemplateID = " . $row_1['Id'];
             $result_2 = mysql_query($sql_2, Cron::$database_connect);
             $row_2 = mysql_fetch_assoc($result_2);
             if ($row_2['num'] > 0) {
                 $this->log("calculateForeverListingSchedule-" . $Site . ".html", $row_1['Id'] . " has active listings.<br>");
                 continue;
             }
             $template->setAccountId($row_1['accountId']);
             //$local_time = $day." ".$row_1['ForeverListingTime'];
             $china_time = $day . " " . substr($template->getSiteTime($Site, "1983-11-16", $row_1['ForeverListingTime']), 11, 5);
             $local_time = $template->getLocalTimeByChinaTime($Site, $china_time);
             //$china_time = $day." ".$row_1['ForeverListingChinaTime'];
             $item_id = $template->changeTemplateToItem($row_1['Id'], $china_time, $local_time, 1);
             if (strpos($item_id, "error") !== false) {
                 $this->log("calculateForeverListingSchedule-" . $Site . ".html", $item_id . "<br>");
                 continue;
             }
             $this->log("calculateForeverListingSchedule-" . $Site . ".html", "t:" . $row_1['Id'] . " ==> i:" . $item_id . ". BeiJing:" . $china_time . ", " . $Site . ": " . $local_time . "<br>");
             $this->log("calculateForeverListingSchedule-" . $Site . ".html", "<br><font color='red'>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</font><br>");
         }
     }
 }
Example #2
0
 private function eBayUpdateItem($item, $userId)
 {
     global $nest, $storeNest;
     switch ($item->SellingStatus->ListingStatus) {
         case "Active":
             $Status = 2;
             break;
         case "Completed":
             if ($item->SellingStatus->QuantitySold > 0) {
                 $Status = 6;
             } else {
                 $Status = 5;
             }
             break;
         case "Ended":
             if ($item->SellingStatus->QuantitySold > 0) {
                 $Status = 6;
             } else {
                 $Status = 5;
             }
             break;
     }
     switch ($item->PictureDetails->GalleryType) {
         case "Featured":
             $GalleryTypeFeatured = 1;
             $GalleryTypeGallery = 0;
             $GalleryTypePlus = 0;
             break;
         case "Gallery":
             $GalleryTypeGallery = 1;
             $GalleryTypeFeatured = 0;
             $GalleryTypePlus = 0;
             break;
         case "Plus":
             $GalleryTypePlus = 1;
             $GalleryTypeFeatured = 0;
             $GalleryTypeGallery = 0;
             break;
     }
     $nest = 0;
     $storeNest = 0;
     $PrimaryCategoryCategoryName = $this->getCategoryPathById($this->getSiteIdByName($item->Site), $item->PrimaryCategory->CategoryID);
     $SecondaryCategoryCategoryName = $this->getCategoryPathById($this->getSiteIdByName($item->Site), $item->SecondaryCategory->CategoryID);
     $StoreCategoryName = $this->getStoreCategoryPathById($this->account_id, $item->Storefront->StoreCategoryID);
     $StoreCategory2Name = $this->getStoreCategoryPathById($this->account_id, $item->Storefront->StoreCategory2ID);
     /*
     $sql = "update items set AutoPay='".mysql_escape_string($item->AutoPay)."',
     BuyItNowPrice='".mysql_escape_string($item->BuyItNowPrice)."',Country='".mysql_escape_string($item->Country)."',
     Currency='".mysql_escape_string($item->Currency)."',
     DispatchTimeMax='".mysql_escape_string($item->DispatchTimeMax)."',StartTime='".mysql_escape_string($item->ListingDetails->StartTime)."',
     EndTime='".mysql_escape_string($item->ListingDetails->EndTime)."',ViewItemURL='".mysql_escape_string($item->ListingDetails->ViewItemURL)."',ListingDuration='".mysql_escape_string($item->ListingDuration)."',
     ListingType='".mysql_escape_string($item->ListingType)."',Location='".mysql_escape_string($item->Location)."',
     PaymentMethods='".mysql_escape_string($item->PaymentMethods)."',PayPalEmailAddress='".mysql_escape_string($item->PayPalEmailAddress)."',
     PostalCode='".mysql_escape_string($item->PostalCode)."',PrimaryCategoryCategoryID='".mysql_escape_string($item->PrimaryCategory->CategoryID)."',
     PrimaryCategoryCategoryName='".mysql_escape_string($PrimaryCategoryCategoryName)."',Quantity='".mysql_escape_string($item->Quantity)."',
     ReturnPolicyDescription='".mysql_escape_string($item->ReturnPolicy->Description)."',ReturnPolicyRefundOption='".mysql_escape_string($item->ReturnPolicy->RefundOption)."',
     ReturnPolicyReturnsAcceptedOption='".mysql_escape_string($item->ReturnPolicy->ReturnsAcceptedOption)."',ReturnPolicyReturnsWithinOption='".mysql_escape_string($item->ReturnPolicy->ReturnsWithinOption)."',
     ReturnPolicyShippingCostPaidByOption='".mysql_escape_string($item->ReturnPolicy->ShippingCostPaidByOption)."',
     CurrentPrice='".mysql_escape_string($item->SellingStatus->CurrentPrice)."',QuantitySold='".mysql_escape_string($item->SellingStatus->QuantitySold)."',
     ListingStatus='".mysql_escape_string($item->SellingStatus->ListingStatus)."',SecondaryCategoryCategoryID='".$item->SecondaryCategory->CategoryID."',SecondaryCategoryCategoryName='".mysql_escape_string($SecondaryCategoryCategoryName)."',
     ShippingType='".mysql_escape_string($item->ShippingDetails->ShippingType)."',
     Site='".mysql_escape_string($item->Site)."',SKU='".mysql_escape_string($item->SKU)."',
     StartPrice='".mysql_escape_string($item->StartPrice)."',StoreCategory2ID='".mysql_escape_string($item->Storefront->StoreCategory2ID)."',StoreCategory2Name='".mysql_escape_string($StoreCategory2Name)."',
     StoreCategoryID='".mysql_escape_string($item->Storefront->StoreCategoryID)."',StoreCategoryName='".mysql_escape_string($StoreCategoryName)."',Title='".htmlentities($item->Title, ENT_QUOTES)."',
     UserID='".mysql_escape_string($userId)."',Status='".$Status."',
     GalleryTypeFeatured=".$GalleryTypeFeatured.",GalleryTypeGallery=".$GalleryTypeGallery.",GalleryTypePlus=".$GalleryTypePlus.",GalleryURL='".$item->PictureDetails->GalleryURL."' where ItemID = '".$item->ItemID."'";
     */
     $sql = "update items set QuantitySold='" . mysql_escape_string($item->SellingStatus->QuantitySold) . "',\n\tListingStatus='" . mysql_escape_string($item->SellingStatus->ListingStatus) . "',\n\tUserID='" . mysql_escape_string($userId) . "',Status='" . $Status . "' where ItemID = '" . $item->ItemID . "'";
     //echo $sql;
     //echo "<br>";
     //debugLog("eBay-update-item-track.log", $sql);
     //$sql = "update items set CurrentPrice='".$item->SellingStatus->CurrentPrice."',QuantitySold='".$item->SellingStatus->QuantitySold."',ListingStatus='".$item->SellingStatus->ListingStatus.",Status='".$Status."''
     //where ItemID = '".$item->ItemID."'";
     echo $sql;
     echo "<br>\n";
     $result = mysql_query($sql, eBayListing::$database_connect);
     $sql = "select Id,TemplateID from items where ItemID = '" . $item->ItemID . "'";
     $result = mysql_query($sql, eBayListing::$database_connect);
     $row = mysql_fetch_assoc($result);
     //get template status for forever listing
     $sql_1 = "select status from template where Id = " . $row['TemplateID'];
     $result_1 = mysql_query($sql_1, eBayListing::$database_connect);
     $row_1 = mysql_fetch_assoc($result_1);
     if ($row_1 == 7) {
         require_once "template.php";
         $template = new Template();
         $item_id = $template->changeTemplateToItem($row['TemplateID'], '', date("Y-m-d H:i:s", time() + 2 * 60), 1);
         $this->log("template", "TemplateID: " . $row['TemplateID'] . " auto change to item upload(forever listing status).");
     }
     return $row['Id'];
 }