59 lines
1.7 KiB
PHP
Executable File
59 lines
1.7 KiB
PHP
Executable File
<?php
|
|
namespace app\shopapi\lists;
|
|
|
|
use app\common\enum\accountLog\ShopAccountLogEnum;
|
|
use app\common\model\accountLog\ShopAccountLog;
|
|
use app\common\model\shop\Shop;
|
|
use app\common\lists\ListsExtendInterface;
|
|
|
|
/**
|
|
* 财务管理列表
|
|
* Class FinanceLists
|
|
* @package app\shopapi\lists
|
|
*/
|
|
class FinanceLists extends BaseShopApiDataLists implements ListsExtendInterface
|
|
{
|
|
|
|
public function setWhere()
|
|
{
|
|
$where = [];
|
|
$type = $this->params['type'] ?? '';
|
|
$where[] = ['shop_id','=',$this->shopId];
|
|
switch ($type){
|
|
case 1:
|
|
$where[] = ['change_type','in',ShopAccountLogEnum::MONEY_DESC];
|
|
break;
|
|
case 2:
|
|
$where[] = ['change_type','in',ShopAccountLogEnum::DEPOSIT_DESC];
|
|
break;
|
|
}
|
|
return $where;
|
|
}
|
|
public function lists(): array
|
|
{
|
|
$lists = ShopAccountLog::where(['shop_id'=>$this->shopId])
|
|
->where($this->setWhere())
|
|
->field('id,sn,action,change_object,change_type,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 ShopAccountLog::where(['shop_id'=>$this->shopId])
|
|
->where($this->setWhere())
|
|
->count();
|
|
}
|
|
|
|
public function extend()
|
|
{
|
|
$shop = Shop::where(['id'=>$this->shopId])->field('money,deposit')->findOrEmpty();
|
|
return [
|
|
'money' => $shop['money'],
|
|
'deposit' => $shop['deposit'],
|
|
];
|
|
}
|
|
} |