where("agent_id",$data['account'])->findOrEmpty(); $config['version'] = "res"; if ($config->isEmpty()) return true; $cursor = ""; $hasMore = true; $mode = (new HxGoods); while ($hasMore) { $result = (new Store)->config($config->toArray())->token()->getStoreGoods($config['account'], $cursor); if (empty($result)) { $hasMore = false; break; } echo $result['has_more']."====\n"; if (!$result['has_more']) { $hasMore = false; echo getDateFull()."==数据获取结束-has_more\n"; } if (empty($result['products'])) { $hasMore = false; echo getDateFull()."==数据获取结束\n"; break; } foreach ($result['products'] as $key=>$val) { if ($val['product']['category_id']) { echo getDateFull()."==商品=={$val['product']['product_id']}===\n"; $goods = $mode->where("product_id",$val['product']['product_id'])->findOrEmpty(); if ($goods->isEmpty()) { echo getDateFull()."==新增商品=={$val['product']['product_name']}===\n"; $goods->insertGetId([ "biz_line" => $val['product']['biz_line'], "agent_id" => $data['account'], "pois" => json_encode($val['product']['pois']??[]), "product_id" => $val['product']['product_id'], "product_name" => $val['product']['product_name'], "sold_end_time" => $val['product']['sold_end_time'], "sold_start_time" => $val['product']['sold_start_time'], "product_type" => $val['product']['product_type'], "actual_amount" => $val['sku']['actual_amount']??0, "create_at" => date("Y-m-d H:i:s", $val['product']['create_time']), ]); } } else { echo getDateFull()."==跳过商品=={$val['product']['product_name']}===\n"; } } $cursor = $result["next_cursor"]; $hasMore = true; } } catch (\Throwable $throwable) { echo getDateFull()."==获取商品失败\n"; echo $throwable->getMessage()."\n"; echo $throwable->getFile()."【".$throwable->getLine()."】\n"; } return true; } }