product_importer.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: stanley-king
  5. * Date: 15/11/2
  6. * Time: 下午2:59
  7. */
  8. require_once(BASE_DATA_PATH . '/model/goods.model.php');
  9. class product_importer
  10. {
  11. private $tm_goods;
  12. private $mod_spec;
  13. private $mod_spec_value;
  14. private $mod_type_spec;
  15. private $tm_spvid_tpvid; //spec value id => tmall props vid
  16. private $mod_attribute;
  17. private $tm_cpid_attrid;
  18. private $mod_attribute_value;
  19. private $tm_tvid_attrvid;
  20. private $mod_goods_common;
  21. private $mod_goods;
  22. private $mod_goods_images;
  23. private $mod_goods_attr_index;
  24. private $cls_tree;
  25. private $down_path;
  26. public function __construct()
  27. {
  28. $this->tm_goods = Model('tm_goods');
  29. $this->mod_spec = Model('spec');
  30. $this->mod_good_class = Model('goods_class');
  31. $this->mod_spec_value = Model('spec_value');
  32. $this->mod_type = Model('type');
  33. $this->mod_type_spec = Model('type_spec');
  34. $this->tm_spvid_tpvid = Model('tm_spvid_tpvid');
  35. $this->mod_attribute = Model('attribute');
  36. $this->tm_cpid_attrid = Model('tm_cpid_attrid');
  37. $this->mod_attribute_value = Model('attribute_value');
  38. $this->tm_tvid_attrvid = Model('tm_tvid_attrvid');
  39. $this->mod_goods_images = Model('goods_images');
  40. $this->mod_goods = new goodsModel();
  41. $this->mod_goods_common = Model('goods_common');
  42. $this->cls_tree = new class_tree();
  43. $this->mod_goods_attr_index = Model('goods_attr_index');
  44. $this->down_path = BASE_DATA_PATH . '/Download';
  45. }
  46. private function get_tmgoods($bodys)
  47. {
  48. $result = array();
  49. foreach($bodys as $body) {
  50. $item = json_decode($body['body'],true);
  51. $product = array();
  52. $product['body'] = $item['item_seller_get_response']['item'];
  53. $product['desc'] = $body['description'];
  54. $product['num_iid'] = $body['num_iid'];
  55. $product['shop_id'] = $body['shop_id'];
  56. $product['picnum'] = $body['picnum'];
  57. array_push($result,$product);
  58. }
  59. return $result;
  60. }
  61. private function fill_class($cid,&$general,&$name)
  62. {
  63. $this->cls_tree->get_info($cid,$cid_1,$cid_2,$cid_3,$name);
  64. $general['gc_id'] = $cid;
  65. $general['gc_id_1'] = $cid_1;
  66. $general['gc_id_2'] = $cid_2;
  67. $general['gc_id_3'] = $cid_3;
  68. }
  69. private function get_sp_name($sp_id)
  70. {
  71. $items = $this->mod_spec->where(array('sp_id' => $sp_id))->limit(false)->select();
  72. foreach($items as $item) {
  73. $name = $item['sp_name'];
  74. return $name;
  75. }
  76. return '';
  77. }
  78. private function get_specar($typeid)
  79. {
  80. $items = $this->mod_type_spec->where(array("type_id" => $typeid))->limit(false)->select();
  81. $ret = array();
  82. foreach($items as $item)
  83. {
  84. $sp_id = $item['sp_id'];
  85. $sp_name = $this->get_sp_name($sp_id);
  86. $ret[$sp_id] = $sp_name;
  87. }
  88. return $ret;
  89. }
  90. private function get_spec_name($sp_id)
  91. {
  92. $items = $this->mod_spec->field('sp_name')->where(array('sp_id' => $sp_id))->limit(false)->select();
  93. if(empty($items)) {
  94. return '';
  95. } else {
  96. return $items[0]['sp_name'];
  97. }
  98. }
  99. /**
  100. * @param $spid
  101. * @param $spvid
  102. * @return mixed
  103. */
  104. private function get_specval_name($spid, $spvid)
  105. {
  106. $items = $this->mod_spec_value->field('sp_value_name')->where(array('sp_id' => $spid, 'sp_value_id' => $spvid))->limit(false)->select();
  107. if(empty($items)) {
  108. return '';
  109. } else {
  110. return $items[0]['sp_value_name'];
  111. }
  112. }
  113. private function get_spvid($cid,$pid,$vid)
  114. {
  115. $items = $this->tm_spvid_tpvid->field('spvid')->where(array('tpcid' => $cid,'tppid' => $pid,'tpvid' => $vid))->limit(false)->select();
  116. if(empty($items)) {
  117. return '';
  118. } else {
  119. return $items[0]['spvid'];
  120. }
  121. }
  122. private function get_attrid($cid,$pid)
  123. {
  124. $items = $this->tm_cpid_attrid->field('attr_id')->where(array('cid' => $cid,'pid' => $pid))->limit(false)->select();
  125. if(empty($items)) {
  126. return '';
  127. } else {
  128. return $items[0]['attr_id'];
  129. }
  130. }
  131. private function get_attrvid($cid,$pid,$vid)
  132. {
  133. $items = $this->tm_tvid_attrvid->field('attr_vid')->where(array('tcid' => $cid,'tpid' => $pid,'tvid' => $vid))->limit(false)->select();
  134. if(empty($items)) {
  135. return '';
  136. } else {
  137. return $items[0]['attr_vid'];
  138. }
  139. }
  140. private function parse_sku_properties($cid,$props,&$spec_name,&$spec_val)
  141. {
  142. $spec_vals = preg_split("/[;]+/", $props);
  143. foreach($spec_vals as $sv)
  144. {
  145. $data = preg_split("/[:]+/", $sv);
  146. if(!empty($data)) {
  147. $tmpid = $data[0];
  148. $tmpvid = $data[1];
  149. $spvid = $this->get_spvid($cid,$tmpid,$tmpvid);
  150. $spid = $tmpid;
  151. $sp_name = $this->get_spec_name($spid);
  152. $spval_name = $this->get_specval_name($spid, $spvid);
  153. $spec_val[$spid][$spvid] = $spval_name;
  154. $spec_name[$spid] = $sp_name;
  155. }
  156. }
  157. }
  158. private function get_attr_name($attrid)
  159. {
  160. $items = $this->mod_attribute->table('attribute')->field('attr_name')->where(array('attr_id' => $attrid))->limit(false)->select();
  161. if(empty($items)) {
  162. return NULL;
  163. } else {
  164. return $items[0]['attr_name'];
  165. }
  166. }
  167. private function get_attr_vname($typeid,$attrid,$attrvid)
  168. {
  169. $items = $this->mod_attribute_value->table('attribute_value')->field('attr_value_name')->where(array('attr_id' => $attrid,'type_id' => $typeid,'attr_value_id' => $attrvid))->limit(false)->select();
  170. if(empty($items)) {
  171. return NULL;
  172. } else {
  173. return $items[0]['attr_value_name'];
  174. }
  175. }
  176. private function get_common_attr($cid,$props)
  177. {
  178. $ar_attr= array();
  179. $spec_vals = preg_split("/[;]+/", $props);
  180. foreach($spec_vals as $sv)
  181. {
  182. $data = preg_split("/[:]+/", $sv);
  183. if(!empty($data))
  184. {
  185. $tmpid = $data[0];
  186. $tmvid = $data[1];
  187. $attr_id = $this->get_attrid($cid,$tmpid);
  188. if(!empty($attr_id)) {
  189. $attr_name = $this->get_attr_name($attr_id);
  190. $ar_attr[$attr_id]['name'] = $attr_name;
  191. $attr_vid = $this->get_attrvid($cid,$tmpid,$tmvid);
  192. $type_id = $cid;
  193. $attr_vname = $this->get_attr_vname($type_id,$attr_id,$attr_vid);
  194. $ar_attr[$attr_id][$attr_vid] = $attr_vname;
  195. }
  196. }
  197. }
  198. return $ar_attr;
  199. }
  200. private function get_common_spec_nameval($cid,$skus,&$spec_name,&$spec_val)
  201. {
  202. $ar_spec_name = array();
  203. $ar_spec_val = array();
  204. foreach($skus as $skuex)
  205. {
  206. foreach($skuex as $sku) {
  207. $properties = $sku['properties'];
  208. $this->parse_sku_properties($cid,$properties,$ar_spec_name,$ar_spec_val);
  209. }
  210. }
  211. $spec_name = serialize($ar_spec_name);
  212. $spec_val = serialize($ar_spec_val);
  213. }
  214. private function get_goods_spec($cid,$properties)
  215. {
  216. $ar_spec_name = array();
  217. $ar_spec_val = array();
  218. $this->parse_sku_properties($cid,$properties,$ar_spec_name,$ar_spec_val);
  219. $specs = array();
  220. foreach($ar_spec_val as $spec_val)
  221. {
  222. foreach($spec_val as $key => $val) {
  223. $specs[$key] = $val;
  224. }
  225. }
  226. return $specs;
  227. }
  228. private function fill_general($cid,$item, &$general,&$name,$num_iid,$shop_id)
  229. {
  230. $this->fill_class($cid, $general,$name);
  231. $general['num_iid'] = $num_iid;
  232. $general['tm_shop'] = $shop_id;
  233. $general['store_id'] = fetch_config::store_id;
  234. $general['store_name'] = fetch_config::store_name;
  235. $general['goods_name'] = not_null($item['title']);
  236. $general['goods_mobile_name'] = not_null($item['title']);
  237. $general['goods_jingle'] = not_null($item['sell_point']);
  238. $general['goods_price'] = $item['price'];
  239. $general['goods_marketprice'] = $item['price'];
  240. $general['goods_image'] = $item['pic_url'];
  241. $general['goods_state'] = fetch_config::goods_state;
  242. $general['goods_verify'] = 1;
  243. $general['goods_commend'] = strtolower($item['has_showcase']) ? 1 : 0;
  244. $general['goods_vat'] = strtolower($item['has_invoice']) ? 1 : 0;
  245. $general['is_virtual'] = strtolower($item['is_virtual']) ? 1 : 0;
  246. $general['store_name'] = $item['nick'];
  247. $general['goods_serial_tm'] = not_null($item['outer_id']);
  248. $general['goods_addtime'] = strtotime($item['created']);
  249. }
  250. private function reset_imgs($imges)
  251. {
  252. if(empty($imges)) return '';
  253. $ret = array();
  254. foreach($imges as $img) {
  255. $ret[$img['position']]['url'] = $img['url'];
  256. }
  257. return $ret;
  258. }
  259. private function upload_imges(&$imges,$storeid)
  260. {
  261. foreach($imges as &$img)
  262. {
  263. static $pngext = array('png','jpg','jpeg');
  264. $url = $img['url'];
  265. $info = pathinfo($url);
  266. $src_name = $this->down_path . '/' . md5($url) . '.' . $info['extension'];
  267. if(empty($info['extension'])) continue;
  268. $err = true;
  269. if(file_exists($src_name))
  270. {
  271. $fh = fopen($src_name, "rb");
  272. $head = fread($fh, 8);
  273. fclose($fh);
  274. $err = false;
  275. if(empty($head)) {
  276. unlink($src_name);
  277. Log::record("{$src_name} file is empty.",Log::ERR);
  278. $err = true;
  279. }
  280. if(in_array($info['extension'],$pngext))
  281. {
  282. $arr = unpack("C4", $head);
  283. if($arr[1] == 137 && $arr[2] == 80) {
  284. Log::record("{$src_name} is a png file.",Log::ERR);
  285. $err = true;
  286. }
  287. }
  288. }
  289. if($err) {
  290. Log::record("{$src_name} file is error.",Log::ERR);
  291. continue;
  292. }
  293. $upctl = new upload_control();
  294. $upctl->set_store($storeid);
  295. $up_name = $upctl->upload_img($src_name);
  296. $img['upname'] = $up_name;
  297. $img['file'] = $src_name;
  298. }
  299. return true;
  300. }
  301. private function add_attr($gd_id,$gdcommon_id,$gc_id,$type_id,$goods_attr)
  302. {
  303. foreach($goods_attr as $attrid => $values)
  304. {
  305. foreach($values as $vid => $vname)
  306. {
  307. if($vid != 'name')
  308. {
  309. $index = $this->mod_goods_attr_index->insert(array('goods_id' => $gd_id,'goods_commonid' => $gdcommon_id,
  310. 'gc_id' => $gc_id,'type_id' => $type_id, 'attr_id' => $attrid,'attr_value_id' => $vid));
  311. if($index == false) {
  312. Log::record('Cannot insert attr_index');
  313. }
  314. }
  315. }
  316. }
  317. }
  318. private function color_spec()
  319. {
  320. return 1627207;
  321. }
  322. private function goods_colorid($cid,$properties)
  323. {
  324. $data = preg_split("/[:]+/", $properties);
  325. if(!empty($data))
  326. {
  327. $tm_pid = $data[0];
  328. $tm_pvid = $data[1];
  329. if($tm_pid != $this->color_spec()) {
  330. return 0;
  331. } else {
  332. return $this->get_spvid($cid,$tm_pid,$tm_pvid);
  333. }
  334. }
  335. return 0;
  336. }
  337. private function import_item($item,$desc,$num_iid,$shop_id,&$nsku)
  338. {
  339. $cid = $item['cid'];
  340. $general = array();
  341. $this->fill_general($cid,$item,$general,$name,$num_iid,$shop_id);
  342. //属于SKU 信息中
  343. $skus = $item['skus'];
  344. $typeid = $cid;
  345. $goods_attr = $this->get_common_attr($cid,$item['props']);
  346. $goods_common = $general;
  347. {
  348. $goods_common['type_id'] = $typeid;
  349. $goods_common['goods_body'] = $desc;
  350. $goods_common['mobile_body'] = $desc;
  351. $goods_common['gc_name'] = $name;
  352. $goods_common['goods_selltime'] = strtotime($item['list_time']);
  353. $goods_common['goods_costprice'] = $item['price'];
  354. $goods_common['goods_attr'] = serialize($goods_attr);
  355. if(empty($skus)) {
  356. $spec_name = 'N';
  357. $spec_val = 'N';
  358. } else {
  359. $this->get_common_spec_nameval($cid,$skus,$spec_name,$spec_val);
  360. }
  361. $goods_common['spec_name'] = $spec_name;
  362. $goods_common['spec_value'] = $spec_val;
  363. $common_id = $this->mod_goods->addGoodsCommon($goods_common);
  364. $prop_imgs = $item['prop_imgs']['prop_img'];
  365. if(!empty($prop_imgs)) {
  366. $this->upload_imges($prop_imgs,fetch_config::store_id);
  367. }
  368. $imgs = $this->reset_imgs($item['item_imgs']['item_img']);
  369. $this->upload_imges($imgs,fetch_config::store_id);
  370. if(empty($prop_imgs))
  371. {
  372. foreach($imgs as $pos => $img)
  373. {
  374. $upname = $img['upname'];
  375. if(empty($upname)) continue;
  376. if(empty($main_pic)) {
  377. $main_pic = $upname;
  378. $default = 1;
  379. } else {
  380. $default = 0;
  381. }
  382. $file_sig = '';
  383. if(isset($img['file'])) {
  384. $file_sig = md5_file($img['file']);
  385. }
  386. $this->mod_goods_images->insert(array('goods_commonid' => $common_id,
  387. 'store_id' => fetch_config::store_id,'goods_image' => $upname,'goods_image_sort' => $pos,'is_default' => $default,'filesig' => $file_sig));
  388. }
  389. }
  390. else
  391. {
  392. foreach($prop_imgs as $pimg)
  393. {
  394. $default = 1;
  395. $pos = 0;
  396. $pupname = $pimg['upname'];
  397. if(empty($pupname)) continue;
  398. $file_sig = '';
  399. if(isset($pimg['file'])) {
  400. $file_sig = md5_file($pimg['file']);
  401. }
  402. $color_id = $this->goods_colorid($cid,$pimg['properties']);
  403. $this->mod_goods_images->insert(array('goods_commonid' => $common_id,'color_id' => $color_id,
  404. 'store_id' => fetch_config::store_id,'goods_image' => $pupname,'goods_image_sort' => $pos,'is_default' => $default,'filesig' => $file_sig));
  405. $main_pic = $pupname;
  406. $default = 0;
  407. foreach($imgs as $pos => $img)
  408. {
  409. $upname = $img['upname'];
  410. if(empty($upname)) continue;
  411. $file_sig = '';
  412. if(isset($img['file'])) {
  413. $file_sig = md5_file($img['file']);
  414. }
  415. $this->mod_goods_images->insert(array('goods_commonid' => $common_id,'color_id' => $color_id,
  416. 'store_id' => fetch_config::store_id,'goods_image' => $upname,'goods_image_sort' => $pos + 1,'is_default' => $default,'filesig' => $file_sig));
  417. }
  418. }
  419. }
  420. $this->mod_goods_common->where(array('goods_commonid' => $common_id))->update(array('goods_image' => $main_pic));
  421. }
  422. if(empty($skus))
  423. {
  424. $nsku = 1;
  425. $goods = $general;
  426. $goods['goods_edittime'] = strtotime($item['modified']);
  427. $goods['goods_serial_tm'] = not_null($item['outer_id']);
  428. $goods['goods_price'] = $item['price'];
  429. $goods['goods_addtime'] = strtotime($item['created']);
  430. $goods['goods_storage'] = empty($item['quantity']) ? 0 : $item['quantity'];
  431. $goods['goods_commonid'] = $common_id;
  432. //$goods['color_id'] = $this->goods_colorid($cid,$item['properties']);
  433. $goods['goods_spec'] = 'N';
  434. $goods['goods_image'] = $main_pic;
  435. $gd_id = $this->mod_goods->addGoods($goods);
  436. $this->add_attr($gd_id,$common_id,$cid,$typeid,$goods_attr);
  437. }
  438. else
  439. {
  440. foreach($skus as $skuex)
  441. {
  442. $nsku = count($skuex);
  443. foreach($skuex as $sku)
  444. {
  445. $goods = $general;
  446. $goods['goods_edittime'] = strtotime($sku['modified']);
  447. $goods['goods_price'] = $sku['price'];
  448. $goods['goods_addtime'] = strtotime($sku['created']);
  449. $goods['goods_storage'] = $sku['quantity'];
  450. $goods['goods_commonid'] = $common_id;
  451. $goods_spec = $this->get_goods_spec($cid,$sku['properties']);
  452. $goods['goods_spec'] = serialize($goods_spec);
  453. $goods['goods_image'] = $main_pic;
  454. $goods['color_id'] = $this->goods_colorid($cid,$sku['properties']);
  455. $goods['goods_serial_tm'] = not_null($sku['outer_id']);
  456. $gd_id = $this->mod_goods->addGoods($goods);
  457. $this->add_attr($gd_id,$common_id,$cid,$typeid,$goods_attr);
  458. }
  459. }
  460. }
  461. return $common_id;
  462. }
  463. public function proc()
  464. {
  465. $condition = array('num_iid' => 13898341378);
  466. //$condition = array('imported' => 0);
  467. $bodys = $this->tm_goods->field('num_iid,shop_id,body,description')->where($condition)->limit(false)->order('num_iid')->select();
  468. $items = $this->get_tmgoods($bodys);
  469. foreach($items as $item) {
  470. print "handle num_iid=" . $item['num_iid'] . " start.\r\n";
  471. $this->import_item($item['body'],$item['desc'],$item['num_iid'],$item['shop_id']);
  472. $this->tm_goods->where(array('num_iid' => $item['num_iid']))->update(array('imported' => 1));
  473. print "handle num_iid=" . $item['num_iid'] . " end. \r\n";
  474. }
  475. }
  476. private function goods_exist($num_iid)
  477. {
  478. $items = $this->mod_goods->where(array('num_iid' => $num_iid))->select();
  479. if(!empty($items) && count($items) > 0) {
  480. return true;
  481. } else {
  482. return false;
  483. }
  484. }
  485. public function proc_shop()
  486. {
  487. $shopes = $this->tm_goods->field('shop_id,count(*) as n')->group('shop_id')->limit(false)->select();
  488. foreach($shopes as $shop)
  489. {
  490. $shopid = $shop['shop_id'];
  491. $count = $shop['n'];
  492. Log::record("begin shop_id={$shopid} spu count= {$count}",Log::DEBUG);
  493. $con = array('imported' => 0,'shop_id' => $shopid);
  494. $bodys = $this->tm_goods->field('num_iid,cid,shop_id,body,description,picnum')->where($con)->limit(false)->order('num_iid')->select();
  495. $items = $this->get_tmgoods($bodys);
  496. foreach($items as $item)
  497. {
  498. $num_iid = $item['num_iid'];
  499. $picnum = $item['picnum'];
  500. Log::record("handle num_iid={$num_iid} start.\r\n",Log::DEBUG);
  501. if($this->goods_exist($num_iid)) {
  502. Log::record("handle num_iid={$item['num_iid']} has existed.",Log::DEBUG);
  503. continue;
  504. }
  505. $cid = $item['cid'];
  506. if(is_excids($cid)) {
  507. --$count;
  508. Log::record("handle num_iid={$item['num_iid']} cid is exclude.",Log::DEBUG);
  509. continue;
  510. }
  511. $commonid =$this->import_item($item['body'],$item['desc'],$num_iid,$item['shop_id'],$nsku);
  512. if($commonid)
  513. {
  514. if($this->check($num_iid,$nsku,$picnum,$commonid) == false) {
  515. $this->mod_goods_attr_index->where(array('goods_commonid' => $commonid))->delete();
  516. $this->mod_goods_common->where(array('goods_commonid' => $commonid))->delete();
  517. $this->mod_goods_images->where(array('goods_commonid' => $commonid))->delete();
  518. $this->mod_goods->where(array('goods_commonid' => $commonid))->delete();
  519. $this->mod_goods->where(array('num_iid' => $num_iid))->delete();
  520. $this->mod_goods_common->where(array('num_iid' => $num_iid))->delete();
  521. Log::record("shopid = {$shopid} and num_iid = {$num_iid} nsku = {$nsku} cannot be imported.",Log::ERR);
  522. } else {
  523. $this->tm_goods->where(array('num_iid' => $item['num_iid']))->update(array('imported' => 1,'commonid' => $commonid));
  524. --$count;
  525. }
  526. }
  527. else
  528. {
  529. Log::record("goods_commonid is error num_iid={$item['num_iid']}.",Log::DEBUG);
  530. }
  531. Log::record("handle num_iid={$item['num_iid']} end.",Log::DEBUG);
  532. }
  533. Log::record("end shop_id = {$shopid} Error= {$count}",Log::DEBUG);
  534. }
  535. }
  536. private function check($num_iid,$nsku,$picnum,$commonid)
  537. {
  538. $ret = true;
  539. $ncommon = $this->mod_goods_common->where(array('num_iid' => $num_iid))->count();
  540. if($ncommon != 1) {
  541. Log::record("goods_common table's data is not equal 1 where num_iid = {$num_iid}",Log::ERR);
  542. if($ret) $ret = false;
  543. }
  544. $ngoods = $this->mod_goods->where(array('num_iid' => $num_iid))->count();
  545. if($ngoods != $nsku) {
  546. Log::record("goods table's data is not equal {$nsku} where num_iid = {$num_iid}",Log::ERR);
  547. if($ret) $ret = false;
  548. }
  549. $npics = $this->mod_goods_images->where(array('goods_commonid' => $commonid))->count();
  550. if($npics < $picnum) {
  551. Log::record("imageerror: goods image import error where goods_commonid = {$commonid} picnum={$picnum} npics={$npics}",Log::ERR);
  552. if($ret) $ret = false;
  553. }
  554. return $ret;
  555. }
  556. }