72 lines
2.4 KiB
PHP
72 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace app\admin\lists;
|
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\model\beforehand_order\BeforehandOrder;
|
|
use app\common\model\finance\AccountsReceivable;
|
|
use app\common\model\system_store\SystemStore;
|
|
use app\common\model\user\User;
|
|
use Illuminate\Contracts\Cache\Store;
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
$list = $query->with('info')
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->order(['id' => 'desc'])
|
|
->select()
|
|
->toArray();
|
|
$stores = SystemStore::field('id,name')->whereIn('id', array_column($list, 'store_id'))->select()->toArray();
|
|
$stores = reset_index($stores, 'id');
|
|
$orderInfo = BeforehandOrder::field('id,order_id')->whereIn('id', array_column($list, 'order_id'))->select()->toArray();
|
|
$orderInfo = reset_index($orderInfo, 'id');
|
|
$orderInfo = reset_index($orderInfo, 'id');
|
|
foreach ($list as &$item) {
|
|
$item['store_name'] = $stores[$item['store_id']]['name'];
|
|
$item['order_sn'] = $orderInfo[$item['order_id']]['order_id'];
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
/**
|
|
* @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();
|
|
}
|
|
|
|
} |