2024-04-29 16:36:12 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\lists\operation;
|
|
|
|
|
|
|
|
|
|
|
|
use app\admin\lists\BaseAdminDataLists;
|
|
|
|
use app\common\lists\ListsSearchInterface;
|
2024-05-18 15:28:17 +08:00
|
|
|
use app\common\model\goods\Goods;
|
2024-05-08 18:00:04 +08:00
|
|
|
use app\common\model\goods\Unit;
|
2024-04-29 16:36:12 +08:00
|
|
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 采购供应链商户报价列表
|
|
|
|
* Class OpurchaseclassLists
|
|
|
|
* @package app\api\operation
|
|
|
|
*/
|
|
|
|
class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes 设置搜索条件
|
|
|
|
* @return \string[][]
|
|
|
|
* @author likeadmin
|
|
|
|
*/
|
|
|
|
public function setSearch(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes 获取采购供应链商户报价列表
|
|
|
|
* @return array
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
* @date 2024/04/27 11:26
|
|
|
|
*/
|
|
|
|
public function lists(): array
|
|
|
|
{
|
2024-05-11 10:05:38 +08:00
|
|
|
$supplier_id=$this->request->userInfo['supplier']['id'] ?? 0;
|
2024-05-18 15:28:17 +08:00
|
|
|
if(!$supplier_id) return [];
|
2024-05-08 16:42:07 +08:00
|
|
|
$params = $this->request->get();
|
|
|
|
if(isset($params['type']) && $params['type'] == 2){
|
2024-05-11 18:47:04 +08:00
|
|
|
$where[] = ['price','<>',0];
|
|
|
|
$where[] = ['is_adopt','<>',0];
|
2024-05-18 15:28:17 +08:00
|
|
|
$where[] = ['supplier_id','=',$supplier_id];
|
2024-05-08 16:42:07 +08:00
|
|
|
}else{
|
2024-05-18 15:28:17 +08:00
|
|
|
$where[] = ['price','=',0];
|
2024-05-11 19:01:08 +08:00
|
|
|
$where[] = ['is_adopt','=',0];
|
2024-05-18 15:28:17 +08:00
|
|
|
$where[] = ['supplier_id','=',$supplier_id];
|
2024-05-08 16:42:07 +08:00
|
|
|
}
|
2024-05-18 15:28:17 +08:00
|
|
|
if($params['date']){
|
|
|
|
$where[] = ['create_time','between',[strtotime($params['date']),strtotime($params['date'])+86400]];
|
|
|
|
}else{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return OpurchaseGoodsOffer::where($this->searchWhere)->where($where)
|
2024-04-29 16:36:12 +08:00
|
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
|
|
->order(['id' => 'desc'])
|
2024-05-08 16:42:07 +08:00
|
|
|
->select()->each(function($data){
|
|
|
|
$data['is_adopt_text'] = $data->is_adopt_text;
|
2024-05-18 15:28:17 +08:00
|
|
|
$find = Goods::where('id', $data['goods_id'])->with('unitName')->find();
|
|
|
|
if($find){
|
|
|
|
$goods['goods_name'] = $find['name'];
|
|
|
|
$goods['unit_name'] = $find['unit_name'];
|
|
|
|
$goods['imgs'] = $find['imgs'];
|
|
|
|
$data['goods']=$goods;
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
|
2024-05-08 16:42:07 +08:00
|
|
|
})
|
2024-04-29 16:36:12 +08:00
|
|
|
->toArray();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @notes 获取采购供应链商户报价数量
|
|
|
|
* @return int
|
|
|
|
* @date 2024/04/27 11:26
|
|
|
|
*/
|
|
|
|
public function count(): int
|
|
|
|
{
|
2024-05-13 17:41:29 +08:00
|
|
|
$supplier_id=$this->request->userInfo['supplier']['id'] ?? 0;
|
2024-05-08 16:42:07 +08:00
|
|
|
$params = $this->request->get();
|
|
|
|
if(isset($params['type']) && $params['type'] == 2){
|
2024-05-18 15:28:17 +08:00
|
|
|
$where[] = ['price','<>',0];
|
2024-05-08 16:42:07 +08:00
|
|
|
}else{
|
2024-05-18 15:28:17 +08:00
|
|
|
$where[] = ['price','=',0];
|
2024-05-08 16:42:07 +08:00
|
|
|
}
|
|
|
|
return OpurchaseGoodsOffer::where($this->searchWhere)->where('supplier_id',$supplier_id)->where($where)->count();
|
2024-04-29 16:36:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|