read_file($path)); $mod_price = Model(''); foreach($lines as $line) { $row = explode(';',$line); $omsid = intval($row[0]); $market_price = intval($row[1] * 100 + 0.5) / 100; $purchase_price = intval($row[2] * 100 + 0.5) / 100; $sku_price = intval($row[3] * 100 + 0.5) / 100; if($omsid <= 0) continue; $val = ['omsid' => $omsid,'purchase_price' => $purchase_price,'market_price' => $market_price,'sku_price' => $sku_price]; $ret = $mod_price->table('goods_orgprice')->insert($val); if($ret == false) { Log::record("cannot insert row",Log::DEBUG); } } } private function read_file($path) { $file = fopen($path, "r"); $datas = ''; while (!feof($file)) { $datas .= fgets($file); } return $datas; } public function testEvaluate() { $mod = Model('goods'); $i = 0; while (true) { $start = $i * 1000; $items = Model()->table('evaluate_goods')->field('geval_commonid,geval_goodsid')->order('geval_id asc')->limit("{$start},1000")->select(); if(empty($items)) { return; } $i++; foreach ($items as $item) { $cid = intval($item['geval_commonid']); if($cid <= 0) continue; $mod->editGoodsCommon(['comments' => array('exp', "comments+1")],['goods_commonid' => $cid]); } } } public function testSetLowprice() { $mod = Model('goods'); $i = 0; while (true) { $start = $i * 1000; $items = $mod->field('goods_id,goods_price')->order('goods_id asc')->limit("{$start},1000")->select(); if(empty($items)) { return; } $i++; foreach ($items as $item) { $gid = intval($item['goods_id']); if($gid <= 0) continue; $price_cent = intval(doubleval($item['goods_price']) * 100 + 0.5); $lowest_price = intval($price_cent / 2) / 100; $mod->editGoods(['goods_lowest_price' => $lowest_price],['goods_id' => $gid]); } } } }