$goods_arr = array(
'2017-01-11'=> array(490,571,562),
'2017-01-12'=> array(570,569,565),
'2017-01-13'=> array(566,563,560),
);
$goods_time_arr = array('10:00:00', '15:00:00', '20:00:00');
$goods_ids = array();
foreach ($goods_arr as $goods_key => $goods_val) {
$goods_ids = array_merge($goods_ids, $goods_val);
}
$goods_ids_str = implode(',', $goods_ids);
$all_goods_list = $data_shop->get_goods_by_ids($goods_ids_str);//一次取出所有的数据
$format_goods_list = array_column($all_goods_list, NULL, 'id');//以id为key,重新拼接数组
unset($all_goods_list);
$final_goods_list = array();
foreach ($goods_arr as $goods_date => $goods_ids_arr) {
$final_goods_list[$goods_date] = array();
foreach($goods_ids_arr as $goods_time_key => $goods_id) {
$format_goods_list[$goods_id]['start_dt'] = $goods_date.' '.$goods_time_arr[$goods_time_key];
array_push($final_goods_list[$goods_date], $format_goods_list[$goods_id]);//将数据追加到日期的后面
}
}
最终的数据结构就是一个日期对应3个商品的对应信息