初始版本
This commit is contained in:
51
server/app/shopapi/lists/CoachApplyLists.php
Executable file
51
server/app/shopapi/lists/CoachApplyLists.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user