[ 'waybill_apply_subscription_cols' => [ [ 'wp_type' => 3, 'branch_account_cols' => [ [ 'quantity' => 0, 'shipp_address_cols' => [ [ 'country' => '中国', 'province' => '云南省', 'city' => '昆明市', 'district' => '官渡区', 'detail' => '肖家营花卉市场1期-2', ], [ 'country' => '中国', 'province' => '云南省', 'city' => '昆明市', 'district' => '官渡区', 'detail' => '肖家营花卉市场1期-3', ], [ 'country' => '中国', 'province' => '云南省', 'city' => '昆明市', 'district' => '官渡区', 'detail' => '肖家营花卉市场1期', ], ] ] ] ] ] ] ]; $shopId = 6; $shopShip = ShopShip::query() ->where('shop_id', $shopId) ->first(); if (empty($shopShip)) { exit(1); } if (!isset($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'])) { exit(2); } foreach ($resp['pdd_waybill_search_response']['waybill_apply_subscription_cols'] as $subCols) { foreach ($subCols['branch_account_cols'] as $accountCols) { foreach ($accountCols['shipp_address_cols'] as $item) { ShopSender::query()->updateOrCreate( ['shop_id' => $shopId, 'shop_ship_id' => $shopShip->id, 'detail' => $item['detail']], $item ); } } } } }