erp/app/admin/lists/operation/OpurchaseclassofferAllLists.php

108 lines
3.0 KiB
PHP

<?php
namespace app\admin\lists\operation;
use app\admin\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\lists\ListsSortInterface;
use app\common\model\auth\Admin;
use app\common\model\goods\Goods;
use app\common\model\opurchase\OpurchaseGoodsOffer;
use app\common\model\supplier\Supplier;
/**
* 采购供应链商户报价
* Class OpurchaseclassofferAllLists
* @package app\admin\listsoperation
*/
class OpurchaseclassofferAllLists extends BaseAdminDataLists implements ListsSearchInterface,ListsSortInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function setSearch(): array
{
return [
'=' => ['is_adopt', 'is_storage', 'is_stream'],
'between_time' => 'create_time'
];
}
/**
* @notes 设置支持排序字段
* @return string[]
* @date 2021/12/29 10:07
* @remark 格式: ['前端传过来的字段名' => '数据库中的字段名'];
*/
public function setSortFields(): array
{
return ['id' => 'id'];
}
/**
* @notes 设置默认排序
* @return string[]
* @date 2021/12/29 10:06
*/
public function setDefaultOrder(): array
{
return ['id' => 'desc'];
}
/**
* @notes 获取采购供应链商户报价列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function lists(): array
{
$list = OpurchaseGoodsOffer::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength)
->order($this->sortOrder)
->select()->each(function ($item) {
$find = Goods::where('id', $item['goods_id'])->with('unitName')->find();
if ($find) {
$item['goods_name'] = $find['name'];
$item['unit_name'] = $find['unit_name'];
}
if($item['stream_admin_id']){
$item['stream_admin_name']=Admin::where('id', $item['stream_admin_id'])->value('name');
}else{
$item['stream_admin_name']='';
}
if($item['storage_admin_id']){
$item['storage_admin_name']=Admin::where('id', $item['storage_admin_id'])->value('name');
}else{
$item['storage_admin_name']='';
}
$item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name');
})->toArray();
return $list;
}
/**
* @notes 获取采购供应链商户报价数量
* @return int
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function count(): int
{
return OpurchaseGoodsOffer::where($this->searchWhere)->count();
}
}