问题说明:专栏专题学习进度导出数据有误
修改文件:application/admin/model/special/LearningRecords.php
修改方法:specialLearningRecordsLists()
/**学习记录
* @param $where
* @param $id
*/
public static function specialLearningRecordsLists($where, $id)
{
$model = self::getOrderWhere($where, $id);
if (isset($where['excel']) && $where['excel'] == 1) {
$data = ($data = $model->select()) && count($data) ? $data->toArray() : [];
} else {
$data = ($data = $model->page((int)$where['page'], (int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
}
foreach ($data as $key => &$value) {
$value['last_study_time'] = date('Y-m-d', $value['add_time']);
if($where['excel'] == 1){
$type = Special::where(['id'=>$value['special_id']])->value('type');
if($type == 5){
$special_ids = SpecialSource::where('special_id', $value['special_id'])->column('source_id');
$value['percentage'] = SpecialWatch::where(['uid'=>$value['uid']])->where('special_id','in',$special_ids)->avg('percentage');
} else {
$value['percentage'] = SpecialWatch::where(['uid'=>$value['uid'],'special_id'=>$value['special_id']])->avg('percentage');
}
}
}
if (isset($where['excel']) && $where['excel'] == 1) {
self::SaveExcel($data);
}
$count = self::getOrderWhere($where, $id)->count();
return compact('count', 'data');
}
