75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace app\api\lists\operation;
|
|
|
|
|
|
use app\admin\lists\BaseAdminDataLists;
|
|
use app\common\model\merchant\Merchant;
|
|
use app\common\model\operation\Opurchaseclass;
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\Request;
|
|
|
|
/**
|
|
* 采购订单列表
|
|
* Class OpurchaseclassLists
|
|
* @package app\api\listsoperation
|
|
*/
|
|
class OpurchaseclassLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 设置搜索条件
|
|
* @return \string[][]
|
|
* @author likeadmin
|
|
* @date 2024/04/27 11:26
|
|
*/
|
|
public function setSearch(): array
|
|
{
|
|
return [
|
|
'=' => ['merchant', 'order_arr', 'number'],
|
|
'between_time' => 'create_time',
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* @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
|
|
{
|
|
return Opurchaseclass::where($this->searchWhere)
|
|
->where('merchant',Request()->userInfo['merchant']['mer_id'])
|
|
->field(['id', 'merchant', 'order_arr', 'cart_id', 'number', 'total', 'deduction_price', 'actual', 'money', 'paid','create_time'])
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
->order(['id' => 'desc'])
|
|
->select()
|
|
->each(function($data){
|
|
$data['order_count']=count(explode(',',$data['order_arr']));
|
|
// $merchant = Merchant::field('mer_name')->where('mer_id',$data['merchant'])->findOrEmpty();
|
|
// $data['merchant_name'] = !$merchant->isEmpty() ? $merchant['mer_name'] : '';
|
|
})
|
|
->toArray();
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取采购订单数量
|
|
* @return int
|
|
* @author likeadmin
|
|
* @date 2024/04/27 11:26
|
|
*/
|
|
public function count(): int
|
|
{
|
|
return Opurchaseclass::where($this->searchWhere)
|
|
->where('merchant',Request()->userInfo['merchant']['mer_id'])
|
|
->count();
|
|
}
|
|
|
|
} |