74 lines
2.3 KiB
PHP
74 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\operation;
|
|
|
|
use app\admin\controller\BaseAdminController;
|
|
use app\admin\lists\operation\OpurchaseclassofferLists;
|
|
use app\api\logic\operation\OpurchaseGoodsOfferLogic;
|
|
use app\api\validate\OpurchaseGoodsOfferValidate;
|
|
use think\facade\Db;
|
|
|
|
class OpurchaseGoodsOfferController extends BaseAdminController
|
|
{
|
|
/**
|
|
* 供应商报价列表
|
|
*/
|
|
public function lists()
|
|
{
|
|
return $this->dataLists(new OpurchaseclassofferLists());
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 供应商报价日期列表
|
|
*/
|
|
public function date_lists()
|
|
{
|
|
$supplierId=$this->request->supplierId;
|
|
if(!$supplierId) return $this->success('供应商不存在', []);
|
|
$page_no = $this->request->get('page_no', 1);
|
|
$page_size = $this->request->get('page_size', 15);
|
|
$date = $this->request->get('date');
|
|
$where=['supplier_id' =>$supplierId];
|
|
if($date){
|
|
$date=strtotime($date);
|
|
$where[]=['create_time','between',[$date, $date+24*3600-1]];
|
|
}
|
|
$data = Db::name('opurchase_goods_offer_date')->where($where)->page($page_no, $page_size)->order('create_time desc')->select()->each(function ($item) {
|
|
$item['name']=date('Y-m-d', $item['create_time']).' 报价清单';
|
|
return $item;
|
|
})->toArray();
|
|
$count = Db::name('opurchase_goods_offer_date')->where($where)->count();
|
|
return $this->success('请求成功', ['lists' => $data, 'count' => $count, 'page_no' => $page_no, 'page_size' => $page_size]);
|
|
}
|
|
/**
|
|
* 提交报价
|
|
*/
|
|
public function offer()
|
|
{
|
|
$supplier=$this->request->supplierId;
|
|
if(!$supplier) return $this->fail('非供应商用户不能报价');
|
|
$params = (new OpurchaseGoodsOfferValidate())->post()->goCheck('offer');
|
|
$result = OpurchaseGoodsOfferLogic::offer($params);
|
|
if (true === $result) {
|
|
return $this->success('报价成功', [], 1, 1);
|
|
}
|
|
return $this->fail(OpurchaseGoodsOfferLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* 提交配送
|
|
*/
|
|
public function express(){
|
|
$params = (new OpurchaseGoodsOfferValidate())->post()->goCheck('express');
|
|
$supplier=$this->request->supplierId;
|
|
if(!$supplier) return $this->fail('非供应商用户不能填写');
|
|
$params['supplier_id']=$supplier;
|
|
$result = OpurchaseGoodsOfferLogic::express($params);
|
|
if (true === $result) {
|
|
return $this->success('提交成功', [], 1, 1);
|
|
}
|
|
return $this->fail(OpurchaseGoodsOfferLogic::getError());
|
|
}
|
|
}
|