作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

代码修整

... ... @@ -9,7 +9,6 @@ use app\common\controller\Api;
use app\common\library\Sms as Smslib;
use app\mobile\controller\Sms;
use app\mobile\model\CompanyUser;
use app\mobile\model\Agreement;
use app\mobile\model\Exam;
use app\mobile\model\CourseOrder;
use app\mobile\model\CourseAppraise;
... ... @@ -109,14 +108,15 @@ class Company extends Api
"data": [{
"id": 9, //课程订单ID
"pay_price": "50.00", //实际支付金额
"people_num": 20, //限制人数
"people_num": 20, //限制人数(斜杠后数字)
"is_top": "0", //是否顶配:0=否,1=是
"secret": { //课程信息
"course": { //课程信息
"id": 1, //课程ID
"title": "测试课程", //课程标题
"cover": "" //课程封面图
},
"is_have_qi": 0 //是否有企字:0=否,1=是
"user_count": 0 //当前企业下员工含管理员数量(斜杠前数字)
"is_have_appraise": 0 //是否已评价:0=否,1=是
}]
})
*/
... ... @@ -133,7 +133,14 @@ class Company extends Api
foreach ($list as $v) {
// 当前企业下员工含管理员人数
$v['user_count'] = $user_count + 1;
$v->visible(['id','pay_price','people_num','is_top','course'])->append(['user_count']);
// 是否已评价
$have_appraise = CourseAppraise::where('user_id',$this->auth->id)
->where('course_id',$v['course_id'])
->where('course_order_id',$v['id'])
->field('id')
->find();
$v['is_have_appraise'] = !empty($have_appraise) ? 1 : 0;
$v->visible(['id','pay_price','people_num','is_top','course'])->append(['user_count','is_have_appraise']);
$v->getRelation('course')->visible(['id','cover','title']);
}
$this->success('成功',$list);
... ...
... ... @@ -10,7 +10,6 @@ use app\common\library\Sms as Smslib;
use app\mobile\controller\Sms;
use app\mobile\model\Company;
use app\mobile\model\CompanyUser;
use app\mobile\model\Agreement;
use app\mobile\model\Exam;
use app\mobile\model\CourseOrder;
use app\mobile\model\CourseAppraise;
... ... @@ -528,7 +527,7 @@ class User extends Api
// 是否有企字
$v['is_have_qi'] = in_array($v['id'], $course_id_arr) ? 1 : 0;
// 是否已评价
$have_appraise = Appraise::where('user_id',$this->auth->id)
$have_appraise = CourseAppraise::where('user_id',$this->auth->id)
->where('course_id',$v['course_id'])
->where('course_order_id',$v['id'])
->field('id')
... ...
此 diff 太大无法显示。