erp_old/app/admin/lists/operation/OpurchaseclassLists.php

78 lines
2.1 KiB
PHP
Raw Normal View History

2024-04-27 11:41:34 +08:00
<?php
namespace app\admin\lists\operation;
use app\admin\lists\BaseAdminDataLists;
2024-05-13 16:03:16 +08:00
use app\common\model\merchant\Merchant;
2024-04-27 11:41:34 +08:00
use app\common\model\operation\Opurchaseclass;
use app\common\lists\ListsSearchInterface;
/**
* 采购订单列表
* Class OpurchaseclassLists
* @package app\admin\listsoperation
*/
class OpurchaseclassLists extends BaseAdminDataLists implements ListsSearchInterface
{
2024-05-17 09:08:33 +08:00
protected $where;
2024-04-27 11:41:34 +08:00
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function setSearch(): array
{
return [
2024-05-17 09:08:33 +08:00
'=' => ['order_arr', 'number','is_mer'],
2024-04-27 11:41:34 +08:00
];
}
/**
* @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
{
2024-05-17 09:08:33 +08:00
$where=[];
$merchant=$this->request->get('merchant');
if($merchant){
$mer_id= Merchant::where('mer_id','like','%'.$merchant.'%')->column('mer_id');
$where['mer_id']=['in',$mer_id];
}
$this->where=$where;
2024-04-27 11:41:34 +08:00
return Opurchaseclass::where($this->searchWhere)
2024-05-17 09:08:33 +08:00
->where($where)
2024-04-27 11:41:34 +08:00
->field(['id', 'merchant', 'order_arr', 'cart_id', 'number', 'total', 'deduction_price', 'actual', 'money', 'paid'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
2024-05-13 16:03:16 +08:00
->select()->each(function($data){
$merchant = Merchant::field('mer_name')->where('mer_id',$data['merchant'])->findOrEmpty();
$data['merchant_name'] = !$merchant->isEmpty() ? $merchant['mer_name'] : '';
})
2024-04-27 11:41:34 +08:00
->toArray();
}
/**
* @notes 获取采购订单数量
* @return int
* @author likeadmin
* @date 2024/04/27 11:26
*/
public function count(): int
{
2024-05-17 09:08:33 +08:00
return Opurchaseclass::where($this->searchWhere)->where($this->where)->count();
2024-04-27 11:41:34 +08:00
}
}