初始版本
This commit is contained in:
56
server/app/coachapi/lists/FinanceLists.php
Executable file
56
server/app/coachapi/lists/FinanceLists.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
|
||||
use app\common\enum\accountLog\CoachAccountLogEnum;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\accountLog\CoachAccountLog;
|
||||
use app\common\model\coach\Coach;
|
||||
|
||||
/**
|
||||
* 财务管理列表
|
||||
* Class FinanceLists
|
||||
* @package app\coachapi\lists
|
||||
*/
|
||||
class FinanceLists extends BaseCoachApiDataLists implements ListsExtendInterface
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['coach_id','=',$this->coachId];
|
||||
$type = $this->params['type'] ?? '';
|
||||
switch ($type){
|
||||
case 1:
|
||||
$where[] = ['change_type','in',CoachAccountLogEnum::MONEY_DESC];
|
||||
break;
|
||||
case 2:
|
||||
$where[] = ['change_type','in',CoachAccountLogEnum::DEPOSIT_DESC];
|
||||
break;
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = CoachAccountLog::where($this->setWhere())
|
||||
->field('id,sn,action,change_object,change_type,action,change_amount,left_amount,create_time')
|
||||
->append(['change_type_desc'])
|
||||
->order('id desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->toArray();
|
||||
return $lists;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return CoachAccountLog::where($this->setWhere())->count();
|
||||
}
|
||||
|
||||
public function extend()
|
||||
{
|
||||
$coach = Coach::where(['id'=>$this->coachId])->field('deposit,money')->findOrEmpty();
|
||||
return [
|
||||
'money' => $coach['money'],
|
||||
'deposit' => $coach['deposit'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user