feat: 添加导出功能和优化查询逻辑
This commit is contained in:
parent
88c9fd557c
commit
18a7332f47
@ -8,13 +8,14 @@ use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow;
|
|||||||
use app\common\lists\ListsSearchInterface;
|
use app\common\lists\ListsSearchInterface;
|
||||||
use app\common\model\auth\Admin;
|
use app\common\model\auth\Admin;
|
||||||
use app\common\model\system_store\SystemStore;
|
use app\common\model\system_store\SystemStore;
|
||||||
|
use app\common\lists\ListsExcelInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 现金流水列表
|
* 现金流水列表
|
||||||
* Class StoreCashFinanceFlowLists
|
* Class StoreCashFinanceFlowLists
|
||||||
* @package app\admin\listsstore_cash_finance_flow
|
* @package app\admin\listsstore_cash_finance_flow
|
||||||
*/
|
*/
|
||||||
class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInterface
|
class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
|
|||||||
public function setSearch(): array
|
public function setSearch(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'=' => ['store_id','status'],
|
'=' => ['store_id', 'status'],
|
||||||
"between_time" => 'create_time'
|
"between_time" => 'create_time'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -45,13 +46,14 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
|
|||||||
public function lists(): array
|
public function lists(): array
|
||||||
{
|
{
|
||||||
return StoreCashFinanceFlow::where($this->searchWhere)
|
return StoreCashFinanceFlow::where($this->searchWhere)
|
||||||
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark','create_time', 'status'])
|
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark', 'create_time', 'status'])
|
||||||
->limit($this->limitOffset, $this->limitLength)
|
->limit($this->limitOffset, $this->limitLength)
|
||||||
->order(['id' => 'desc'])
|
->order(['id' => 'desc'])
|
||||||
->select()->each(function ($item) {
|
->select()->each(function ($item) {
|
||||||
$item->store_name =SystemStore::where('id', $item->store_id)->value('name');
|
$item->store_name = SystemStore::where('id', $item->store_id)->value('name');
|
||||||
if($item->admin_id>0){
|
$item->admin_name='';
|
||||||
$item->admin_name =Admin::where('id', $item->admin_id)->value('name');
|
if ($item->admin_id > 0) {
|
||||||
|
$item->admin_name = Admin::where('id', $item->admin_id)->value('name');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
@ -68,5 +70,35 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
|
|||||||
{
|
{
|
||||||
return StoreCashFinanceFlow::where($this->searchWhere)->count();
|
return StoreCashFinanceFlow::where($this->searchWhere)->count();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @notes 导出文件名
|
||||||
|
* @return string
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setFileName(): string
|
||||||
|
{
|
||||||
|
|
||||||
|
return '现金流水';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @notes 导出字段
|
||||||
|
* @return string[]
|
||||||
|
* @date 2022/11/24 16:17
|
||||||
|
*/
|
||||||
|
public function setExcelFields(): array
|
||||||
|
{
|
||||||
|
$data = [
|
||||||
|
'store_name' => '门店',
|
||||||
|
'create_time' => '时间',
|
||||||
|
'cash_price' => '交易金额',
|
||||||
|
'receivable' => '应收金额',
|
||||||
|
'receipts' => '实收金额',
|
||||||
|
'admin_name' => '操作人员',
|
||||||
|
'remark' => '备注',
|
||||||
|
'status'=>'状态',
|
||||||
|
];
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user