164 lines
4.8 KiB
PHP
164 lines
4.8 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\operation;
|
|
|
|
|
|
use app\admin\controller\BaseAdminController;
|
|
use app\admin\lists\operation\OpurchaseclassLists;
|
|
use app\admin\lists\operation\OpurchaseclassofferLists;
|
|
use app\admin\logic\operation\OpurchaseclassLogic;
|
|
use app\admin\validate\operation\OpurchaseclassValidate;
|
|
use app\common\logic\PayNotifyLogic;
|
|
use app\common\model\goods\Goods;
|
|
use app\common\model\goods\GoodsLabel;
|
|
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
|
use app\common\model\opurchase\Opurchaseinfo;
|
|
use app\common\model\supplier\Supplier;
|
|
use Webman\RedisQueue\Redis;
|
|
|
|
/**
|
|
* 采购订单控制器
|
|
* Class OpurchaseclassController
|
|
* @package app\admin\controller\operation
|
|
*/
|
|
class OpurchaseclassController extends BaseAdminController
|
|
{
|
|
|
|
|
|
/**
|
|
* @notes 获取采购订单列表
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/27 11:26
|
|
*/
|
|
public function lists()
|
|
{
|
|
return $this->dataLists(new OpurchaseclassLists());
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 添加采购订单
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/27 11:26
|
|
*/
|
|
public function add()
|
|
{
|
|
$params=$this->request->post();
|
|
$order=OpurchaseclassLogic::createOpurchaseOrder(request()->userInfo,$params);
|
|
if($order==false){
|
|
return $this->fail(OpurchaseclassLogic::getError());
|
|
}else{
|
|
PayNotifyLogic::handle('operated', $order['number']);
|
|
//推送队列
|
|
Redis::send('push-supplier-products', ['order_id'=>$order['id']]);
|
|
return $this->success('支付成功');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 获取采购订单详情
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/27 11:26
|
|
*/
|
|
public function detail()
|
|
{
|
|
$params = (new OpurchaseclassValidate())->goCheck('detail');
|
|
$result = OpurchaseclassLogic::detail($params);
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 采购子订单详情
|
|
*/
|
|
public function sub_orders()
|
|
{
|
|
$id = $this->request->get('id');
|
|
$is_mer = $this->request->get('is_mer',1);
|
|
$page_no = $this->request->get('page_no', 1);
|
|
$result = OpurchaseclassLogic::sub_detail($id,$is_mer,$page_no);
|
|
return $this->data($result);
|
|
}
|
|
|
|
/**
|
|
* @notes 采购订单列表
|
|
*/
|
|
public function opurchaseinfo_list()
|
|
{
|
|
$id = $this->request->get('id');
|
|
$page_no = $this->request->get('page_no', 1);
|
|
$page_size = $this->request->get('page_size', 15);
|
|
$is_push = $this->request->get('is_push');
|
|
$where['pid']=$id;
|
|
if($is_push){
|
|
$where['is_push'] = $is_push;
|
|
}
|
|
$res = Opurchaseinfo::where($where)->page($page_no, $page_size)->select()->each(function ($item) {
|
|
$item['sys_labels_arr']='';
|
|
$find = Goods::where('id', $item['goods'])->with('unitName')->find();
|
|
if($find){
|
|
$item['goods_name'] = $find['name'];
|
|
$item['unit_name'] = $find['unit_name'];
|
|
$goodslabel = GoodsLabel::where('id','in',$find['sys_labels'])->column('id,name');
|
|
$item['sys_labels_arr'] = $goodslabel;
|
|
|
|
}
|
|
|
|
});
|
|
$data['count'] = Opurchaseinfo::where('pid', $id)->count();
|
|
$data['lists'] = $res?->toArray();
|
|
$data['page_no'] = $page_no;
|
|
$data['page_siz'] = $page_size;
|
|
return $this->success('ok', $data);
|
|
}
|
|
|
|
|
|
/**
|
|
* @notes 采购订单报价列表
|
|
*/
|
|
public function goods_offer_list()
|
|
{
|
|
|
|
return $this->dataLists(new OpurchaseclassofferLists());
|
|
}
|
|
/**
|
|
* @notes 推送给供应商报价
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/27 11:26
|
|
*/
|
|
public function createSupplierGoods()
|
|
{
|
|
$id = $this->request->post('id');
|
|
Redis::send('push-supplier-products', ['order_id'=>$id]);
|
|
|
|
// $result = OpurchaseclassLogic::createSupplierGoods($params);
|
|
// if (true === $result) {
|
|
return $this->success('已推送,请刷新后查看', [], 1, 1);
|
|
// }
|
|
// return $this->fail(OpurchaseclassLogic::getError());
|
|
}
|
|
|
|
/**
|
|
* @notes 设置采纳商品
|
|
* @return \think\response\Json
|
|
* @author likeadmin
|
|
* @date 2024/04/27 11:26
|
|
*/
|
|
public function goods_offer_update()
|
|
{
|
|
$id = $this->request->post('id');
|
|
$type = $this->request->post('type');
|
|
$notes = $this->request->post('notes');
|
|
$nums = $this->request->post('nums');
|
|
$result = OpurchaseclassLogic::goodsOfferUpdate($id,$type,$notes,$nums);
|
|
if ($result==true) {
|
|
return $this->success('已设置', [], 1, 1);
|
|
}
|
|
return $this->fail(OpurchaseclassLogic::getError());
|
|
}
|
|
}
|