51 lines
1.6 KiB
PHP
Executable File
51 lines
1.6 KiB
PHP
Executable File
<?php
|
|
namespace app\shopapi\lists;
|
|
use app\common\enum\shop\ShopEnum;
|
|
use app\common\model\coach\Coach;
|
|
use app\common\model\goods\GoodsComment;
|
|
use app\common\model\skill\Skill;
|
|
use app\shopapi\lists\BaseShopApiDataLists;
|
|
|
|
/**
|
|
*
|
|
* Class CoachController
|
|
* @package app\shopapi\controller
|
|
*/
|
|
class CoachApplyLists extends BaseShopApiDataLists{
|
|
public function setWhere()
|
|
{
|
|
$where = [];
|
|
$type = $this->params['type'] ?? 1;
|
|
$where[] = ['SCA.shop_id','=',$this->shopId];
|
|
$where[] = ['SCA.type','=',$type];
|
|
$where[] = ['SCA.audit_status','=',ShopEnum::AUDIT_STATUS_WAIT];
|
|
return $where;
|
|
}
|
|
|
|
public function lists(): array
|
|
{
|
|
$lists = Coach::alias('C')
|
|
->join('shop_coach_apply SCA','C.id = SCA.coach_id')
|
|
->field('SCA.id,SCA.coach_id,SCA.type,C.name,C.good_comment,C.work_photo,C.order_num,C.skill_id')
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->where($this->setWhere())
|
|
->select()
|
|
->toArray();
|
|
$skillIds = array_column($lists,'skill_id');
|
|
$skillLists = Skill::where(['id'=>$skillIds])->column('name','id');
|
|
foreach ($lists as $key => $coach){
|
|
$lists[$key]['good_comment'] = $coach['good_comment'].'%';
|
|
$lists[$key]['skill_name'] = $skillLists[$coach['skill_id']] ?? '';
|
|
}
|
|
return $lists;
|
|
|
|
}
|
|
|
|
public function count(): int
|
|
{
|
|
return Coach::alias('C')
|
|
->join('shop_coach_apply SCA','C.id = SCA.coach_id')
|
|
->where($this->setWhere())
|
|
->count();
|
|
}
|
|
} |