/** * 功能: 从log文件中提取上传资料 */ private function readProductInfo($file, $spu) { $data = file_get_contents($file); $dataArr = explode('{"errCode', $data); $hasTags = false; $ret = array(); $account = isset($_COOKIE['account']) ? $_COOKIE['account'] : 'geshan0728'; $accountAbbr = strtoupper(C('ACCOUNTABBR')[$account]); $price = WishProductModel::spuPrice($spu); //获取价格已经减去$1的运费 foreach ($dataArr as $k => $v) { if (strlen($v) < 100) { continue; } $json = json_decode('{"errCode' . $v, true); $ret = explode("\n", $json['data']); foreach ($ret as $retKey => $retVal) { if (empty($retVal)) { //删除无用数据 unset($ret[$retKey]); continue; } $ret[$retKey] = json_decode($retVal, true); unset($ret[$retKey]['key']); if (isset($ret[$retKey]['main_image'])) { $ret[$retKey]['main_image'] = self::imageReplace($ret[$retKey]['main_image'], 'img.pics.valsun.cn'); } if (isset($ret[$retKey]['extra_images'])) { $ret[$retKey]['extra_images'] = self::imageReplace($ret[$retKey]['extra_images'], 'img.pics.valsun.cn'); } if (stripos($ret[$retKey]['name'], '#') > 0) { //对标题进行重新组装 $titleInfo = explode('#', $ret[$retKey]['name']); array_pop($titleInfo); $ret[$retKey]['name'] = implode('#', $titleInfo); } $ret[$retKey]['name'] = trim($ret[$retKey]['name']) . ' ' . $accountAbbr; if (isset($ret[$retKey]['sku'])) { $skuInfo = explode('#', $ret[$retKey]['sku']); $spuInfo = explode('#', $ret[$retKey]['parent_sku']); $ret[$retKey]['sku'] = substr_replace($skuInfo[0], $accountAbbr, 4, 0); $ret[$retKey]['parent_sku'] = substr_replace($spuInfo[0], $accountAbbr, 4, 0); $ret[$retKey]['price'] = $price; $ret[$retKey]['shipping'] = 1; } } if (!empty($ret)) { break; } } $ret = array_filter($ret); return $ret; }
<?php /** * 功能: 拉取tags数据 author: zxh * 日期: 2016/1/23 23:04 */ error_reporting(E_ALL); define("SYSTEM_CRONTAB_USER", "true"); //跳过所有权限验证 set_time_limit(0); include substr(str_replace(DIRECTORY_SEPARATOR, '/', __DIR__), 0, stripos(__DIR__, 'crontab')) . "framework.php"; Core::getInstance(); global $dbConn; $price = WishProductModel::spuPrice('YSC000026'); echo $price;