erp_old/app/api/lists/operation/OpurchaseGoodsOfferList.php

102 lines
3.3 KiB
PHP
Raw Normal View History

2024-04-29 16:36:12 +08:00
<?php
namespace app\api\lists\operation;
use app\admin\lists\BaseAdminDataLists;
2024-05-30 10:30:18 +08:00
use app\common\lists\ListsExtendInterface;
2024-04-29 16:36:12 +08:00
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
*/
2024-05-30 10:30:18 +08:00
class OpurchaseGoodsOfferList extends BaseAdminDataLists implements ListsSearchInterface,ListsExtendInterface
2024-04-29 16:36:12 +08:00
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
*/
public function setSearch(): array
{
return [];
2024-04-29 16:36:12 +08:00
}
/**
* @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
{
$supplier_id = $this->request->userInfo['supplier']['id'] ?? 0;
if (!$supplier_id) return [];
$params = $this->request->get();
if (isset($params['type']) && $params['type'] == 2) {
$where[] = ['price', '<>', 0];
$where[] = ['is_adopt', '<>', 0];
$where[] = ['supplier_id', '=', $supplier_id];
} else {
$where[] = ['price', '=', 0];
$where[] = ['is_adopt', '=', 0];
$where[] = ['supplier_id', '=', $supplier_id];
}
if ($params['date']) {
$where[] = ['create_time', 'between', [strtotime($params['date']), strtotime($params['date']) + 86400]];
} else {
2024-05-18 15:28:17 +08:00
return [];
}
return OpurchaseGoodsOffer::where($this->searchWhere)->where($where)
2024-04-29 16:36:12 +08:00
->limit($this->limitOffset, $this->limitLength)
->order(['is_adopt' => 'desc','id' => 'desc'])
->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) {
2024-05-18 15:28:17 +08:00
$goods['goods_name'] = $find['name'];
$goods['unit_name'] = $find['unit_name'];
$goods['imgs'] = $find['imgs'];
$data['goods'] = $goods;
2024-05-18 15:28:17 +08:00
}
return $data;
})
2024-04-29 16:36:12 +08:00
->toArray();
}
/**
* @notes 获取采购供应链商户报价数量
* @return int
* @date 2024/04/27 11:26
*/
public function count(): int
{
$supplier_id = $this->request->userInfo['supplier']['id'] ?? 0;
$params = $this->request->get();
if (isset($params['type']) && $params['type'] == 2) {
$where[] = ['price', '<>', 0];
} else {
$where[] = ['price', '=', 0];
}
return OpurchaseGoodsOffer::where($this->searchWhere)->where('supplier_id', $supplier_id)->where($where)->count();
2024-04-29 16:36:12 +08:00
}
2024-05-30 10:30:18 +08:00
public function extend(){
$supplier_id = $this->request->userInfo['supplier']['id'] ?? 0;
$where=['supplier_id'=> $supplier_id,'is_adopt'=>2,'status'=>0];
$delivery=OpurchaseGoodsOffer::where($this->searchWhere)->where($where)->count();
return ['delivery'=>$delivery];
}
}