|
|
|
@ -274,18 +274,20 @@ class Collector extends BaseService |
|
|
|
|
* @param int $storeId [description] |
|
|
|
|
* @return [type] [description] |
|
|
|
|
*/ |
|
|
|
|
public function updateGoods(string $url, array $form, int $storeId): bool |
|
|
|
|
public function updateGoods(string $url, array $form, int $storeId): array |
|
|
|
|
{ |
|
|
|
|
$goods = GoodsModel::where('goods_id', $form['goods_id'])->find(); |
|
|
|
|
|
|
|
|
|
$goods = GoodsModel::where('goods_id', $form['goods_id'])->where('is_delete',0)->find(); |
|
|
|
|
$errorLog = []; |
|
|
|
|
//商品不存在 |
|
|
|
|
if (!$goods || !$url) { |
|
|
|
|
return true; |
|
|
|
|
$errorLog = ['goodsSn' => $form['goods_id'], 'message' =>trim($url)."商品或者url不存在"]; |
|
|
|
|
return [false, $errorLog]; |
|
|
|
|
} |
|
|
|
|
//新阙通信的抓取过了,就不抓取了;京东价拖抓取过了就不抓取了 |
|
|
|
|
if (isset($form['is_cover']) && $form['is_cover'] == 0) { |
|
|
|
|
if (($goods['channel'] == 'xqtx' && $goods['content']) || $goods->goods_no_other) { |
|
|
|
|
return true; |
|
|
|
|
GoodsModel::where('goods_id', $form['goods_id'])->update(['import_time' => time()]); |
|
|
|
|
return [true, $errorLog]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -323,8 +325,8 @@ class Collector extends BaseService |
|
|
|
|
// var_dump($e->getMessage()); |
|
|
|
|
// exit; |
|
|
|
|
tre($e->getTraceAsString()); |
|
|
|
|
$this->errorLog[] = ['url' => trim($url), 'message' => $e->getMessage()]; |
|
|
|
|
return false; |
|
|
|
|
$errorLog = ['goodsSn' => $form['goods_id'], 'message' => trim($url).$e->getMessage()]; |
|
|
|
|
return [true, $errorLog]; |
|
|
|
|
} |
|
|
|
|
// if ($original['goods_price'] == 0) { |
|
|
|
|
// return false; |
|
|
|
@ -388,6 +390,7 @@ class Collector extends BaseService |
|
|
|
|
// exit(); |
|
|
|
|
$model->transaction(function () use ($form, $data, $original, $goodsSku) { |
|
|
|
|
$data['update_time'] = time(); |
|
|
|
|
$data['import_time'] = time(); |
|
|
|
|
// 添加商品 |
|
|
|
|
GoodsModel::where('goods_id', $form['goods_id'])->update($data); |
|
|
|
|
// 新增商品与图片关联 |
|
|
|
@ -395,8 +398,8 @@ class Collector extends BaseService |
|
|
|
|
//更新sku信息 |
|
|
|
|
GoodsSkuModel::where('goods_id', $form['goods_id'])->update($goodsSku); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
// 更新采集记录 |
|
|
|
|
return [true, $errorLog]; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 检查采集记录状态是否异常 |
|
|
|
|