作者 xieweiping
1 个管道 的构建 通过 耗费 0 秒

店铺详情显示课程列表优化

... ... @@ -134,27 +134,27 @@ class Store extends Api
$where['status'] = 'confirmed';
$courseStore = $courseStore->with('course')->where($where)->order('date','desc')->select();
$course_id = [];
$course = [];
foreach ($courseStore as $k){
if(!isset( $course_id[$k['course_id']])){
if(!isset($course_id[$k['course_id']])){
$course_id[$k['course_id']] = $k['course_id'];
$course[$k['course_id']] = [];
}
}
$course = [];
foreach ($course_id as $v){
//查询门店课程
$courseStore = new \app\admin\model\CourseStore();
$where['store_id'] = $id;
$where['course_id'] = $v;
$where['status'] = 'confirmed';
$where['is_end'] = false;
$where['end'] = ['>',date('Y-m-d H:i:s')];
$courseStore = $courseStore->with('course')->where($where)->order('date','desc')->select();
foreach ($courseStore as $k){
if(!isset($course[$k['course_id']])){
$sign = new \app\admin\model\CourseSign();
$k['course']['sign_count'] = $sign->where(['course_id'=>$k['course_id'],'store_id'=>$id,'publish_time'=>['>',date('Y-m-d H:i:s')]])->count();
$course[$k['course_id']] = $k['course'];
}
$sign = new \app\admin\model\CourseSign();
$k['course']['sign_count'] = $sign->where(['course_id'=>$k['course_id'],'store_id'=>$id,'publish_time'=>['>',date('Y-m-d H:i:s')]])->count();
$course[$k['course_id']] = $k['course'];
}
}
... ...