multi-store/app/admin/lists/AccountsReceivableLists.php

60 lines
1.7 KiB
PHP
Raw Normal View History

2025-02-05 11:15:40 +08:00
<?php
namespace app\admin\lists;
use app\common\lists\ListsSearchInterface;
use app\common\model\beforehand_order\BeforehandOrder;
use app\common\model\finance\AccountsReceivable;
/**
* AccountsReceivableLists
* Class AccountsReceivableLists
* @package app\admin\lists
*/
class AccountsReceivableLists extends BaseAdminDataLists implements ListsSearchInterface
{
public function setSearch(): array
{
return [
'=' => ['store_id', 'user_id'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function lists(): array
{
$query = AccountsReceivable::where($this->searchWhere);
if (!empty($this->params['order_sn'])) {
$orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id');
$query->whereIn('order_id', $orderIds);
}
return $query
->with('info')
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
*/
public function count(): int
{
$query = AccountsReceivable::where($this->searchWhere);
if (!empty($this->params['order_sn'])) {
$orderIds = BeforehandOrder::where('order_id', 'like', '%' . $this->params['order_sn'] . '%')->column('id');
$query->whereIn('order_id', $orderIds);
}
return $query->count();
}
}