function add_deal_tweet_pool($provider, $message, $itemID, $legoID, $price) { $arrfields = array(); $arrfields["Provider"] = $provider; $arrfields["Type"] = "Deals"; $arrfields["ContentID"] = md5($provider . $message); //$arrfields["PicPath"] = $news->{"PicPath"}; $arrfields["ItemID"] = $itemID; $arrfields["LegoID"] = $legoID; $arrfields["Price"] = $price; if (!empty($arrfields["PicPath"])) { $maxlen = 140 - 23 - 22; } else { $maxlen = 140 - 22; } if (strlen($message) > $maxlen) { echo "[Error][" . date('Y-m-d H:i:s') . "] Message is too long: " . $message . "\n"; return false; } else { $arrfields["Message"] = $message . get_url_by_itemID($provider, $itemID); $ret = db_insert("Twitter_Pool", $arrfields, null, false); if (!$ret->{'Status'}) { echo "[Info][" . date('Y-m-d H:i:s') . "] Publishing to Twitter_Pool: [" . $arrfields["ContentID"] . "] " . $arrfields["Message"] . "\n"; return true; } else { echo "[Error][" . date('Y-m-d H:i:s') . "] Publishing failed: "; var_dump($ret); return false; } } }
$minrate = min($minrate, $jsonitem->{'amazon_rate'}); } } if (isset($Target["{$legoID}"])) { if ($Target["{$legoID}"]->{'Price'} > 0 && $Target["{$legoID}"]->{'Availability'} == "Available") { $jsonitem->{'target_rate'} = floatval(round($Target["{$legoID}"]->{'Price'} / $item->{'MSRP'} * 100, 2)); $jsonitem->{'target_url'} = get_url_by_itemID("Target", $Target["{$legoID}"]->{'ItemID'}); $jsonitem->{'target_price'} = $Target["{$legoID}"]->{'Price'}; $jsonitem->{'target_availability'} = $Target["{$legoID}"]->{'Availability'}; $minrate = min($minrate, $jsonitem->{'target_rate'}); } } if (isset($BN["{$legoID}"])) { if ($BN["{$legoID}"]->{'Price'} > 0 && $BN["{$legoID}"]->{'Availability'} == "Available") { $jsonitem->{'bn_rate'} = floatval(round($BN["{$legoID}"]->{'Price'} / $item->{'MSRP'} * 100, 2)); $jsonitem->{'bn_url'} = get_url_by_itemID("BN", $BN["{$legoID}"]->{'ItemID'}); $jsonitem->{'bn_price'} = $BN["{$legoID}"]->{'Price'}; $jsonitem->{'bn_availability'} = $BN["{$legoID}"]->{'Availability'}; $minrate = min($minrate, $jsonitem->{'bn_rate'}); } } if (isset($Taobao["{$legoID}"])) { if ($Taobao["{$legoID}"]->{'Low'} > 0) { $jsonitem->{'taobao_price'} = $Taobao["{$legoID}"]->{'Low'}; $jsonitem->{'taobao_avg'} = $Taobao["{$legoID}"]->{'Avg'}; $jsonitem->{'taobao_nid'} = $Taobao["{$legoID}"]->{'ItemID'}; $jsonitem->{'taobao_vol'} = $Taobao["{$legoID}"]->{'Volume'}; $jsonitem->{'taobao_sellers'} = $Taobao["{$legoID}"]->{'Sellers'}; } } $jsonitem->{'min_rate'} = $minrate;