更新
This commit is contained in:
parent
f6f99275e4
commit
9df4bc54ec
@ -17,10 +17,9 @@ class ExceptionHandler extends Handler
|
||||
|
||||
public function render(Request $request, Throwable $exception): Response
|
||||
{
|
||||
// if ($exception instanceof Dumper) {
|
||||
// return \response(self::convertToHtml($exception));
|
||||
// }
|
||||
// return parent::render($request, $exception);
|
||||
return json(json_decode($exception->getMessage(),true));
|
||||
if ($exception instanceof Dumper) {
|
||||
return \response(self::convertToHtml($exception));
|
||||
}
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@ use app\admin\validate\operation\OpurchaseclassValidate;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||
use app\common\model\opurchase\Opurchaseinfo;
|
||||
use app\common\model\supplier\Supplier;
|
||||
|
||||
/**
|
||||
* 采购订单控制器
|
||||
@ -96,30 +97,71 @@ class OpurchaseclassController extends BaseAdminController
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 采购子订单详情
|
||||
*/
|
||||
public function sub_orders()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$page_no = $this->request->get('page_no', 1);
|
||||
$result = OpurchaseclassLogic::sub_detail($id, $page_no);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 采购订单列表
|
||||
*/
|
||||
public function opurchaseinfo_list(){
|
||||
$id=$this->request->get('id');
|
||||
$page_no=$this->request->get('page_no',1);
|
||||
$res=Opurchaseinfo::where('pid',$id)->page($page_no,25)->select()->each(function ($item) {
|
||||
$find=Goods::where('id', $item['goods'])->with('unitName')->find();
|
||||
$item['goods_name']=$find['name'];
|
||||
$item['unit_name']=$find['unit_name'];
|
||||
public function opurchaseinfo_list()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$page_no = $this->request->get('page_no', 1);
|
||||
$res = Opurchaseinfo::where('pid', $id)->page($page_no, 25)->select()->each(function ($item) {
|
||||
$find = Goods::where('id', $item['goods'])->with('unitName')->find();
|
||||
$item['goods_name'] = $find['name'];
|
||||
$item['unit_name'] = $find['unit_name'];
|
||||
});
|
||||
return $this->success('ok',$res?->toArray());
|
||||
$data['count'] = Opurchaseinfo::where('pid', $id)->count();
|
||||
$data['lists'] = $res?->toArray();
|
||||
$data['page_no'] = $page_no;
|
||||
$data['page_siz'] = 15;
|
||||
return $this->success('ok', $data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 采购订单报价列表
|
||||
*/
|
||||
public function goods_offer_list()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$page_no = $this->request->get('page_no', 1);
|
||||
$params=$this->request->get();
|
||||
$where['order_id']=$id;
|
||||
if(isset($params['is_adopt']) && $params['is_adopt']!==''){
|
||||
$where['is_adopt']=$params['is_adopt'];
|
||||
}
|
||||
$res = OpurchaseGoodsOffer::where($where)->page($page_no, 25)->select()->each(function ($item) {
|
||||
$find = Goods::where('id', $item['goods_id'])->with('unitName')->find();
|
||||
$item['goods_name'] = $find['name'];
|
||||
$item['unit_name'] = $find['unit_name'];
|
||||
$item['supplier_name'] = Supplier::where('id',$item['supplier_id'])->value('mer_name');
|
||||
});
|
||||
$data['count'] = Opurchaseinfo::where('pid', $id)->count();
|
||||
$data['lists'] = $res?->toArray();
|
||||
$data['page_no'] = $page_no;
|
||||
$data['page_siz'] = 15;
|
||||
return $this->success('ok', $data);
|
||||
}
|
||||
/**
|
||||
* @notes 推送给供应商报价
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 11:26
|
||||
*/
|
||||
public function createSupplierGoods(){
|
||||
public function createSupplierGoods()
|
||||
{
|
||||
return $this->success('禁止后台推送');
|
||||
$params=$this->request->post();
|
||||
$params = $this->request->post();
|
||||
$result = OpurchaseclassLogic::createSupplierGoods($params);
|
||||
if (true === $result) {
|
||||
return $this->success('推送成功', [], 1, 1);
|
||||
@ -133,12 +175,13 @@ class OpurchaseclassController extends BaseAdminController
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 11:26
|
||||
*/
|
||||
public function goods_offer_update(){
|
||||
$id=$this->request->post('id');
|
||||
public function goods_offer_update()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
$result = OpurchaseclassLogic::goodsOfferUpdate($id);
|
||||
if ($result) {
|
||||
return $this->success('已采纳', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OpurchaseclassLogic::getError());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,8 +6,10 @@ namespace app\admin\logic\operation;
|
||||
use app\common\model\operation\Opurchaseclass;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\merchant\Merchant;
|
||||
use app\common\model\opurchase\OpurchaseGoodsOffer;
|
||||
use app\common\model\opurchase\Opurchaseinfo;
|
||||
use app\common\model\retail\Cashierclass;
|
||||
use app\common\model\supplier\Supplier;
|
||||
use support\Log;
|
||||
use think\facade\Db;
|
||||
@ -93,9 +95,11 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
$data = Opurchaseclass::findOrEmpty($params['id'])->toArray();
|
||||
if ($data) {
|
||||
$data['goods_info'] = Opurchaseinfo::where('pid', $params['id'])->limit(25)->select()->each(function ($item) {
|
||||
$find=Goods::where('id', $item['goods'])->with('unitName')->find();
|
||||
$item['goods_name']=$find['name'];
|
||||
$item['unit_name']=$find['unit_name'];
|
||||
$find = Goods::where('id', $item['goods'])->with('unitName')->find();
|
||||
if ($find) {
|
||||
$item['goods_name'] = $find['name'];
|
||||
$item['unit_name'] = $find['unit_name'];
|
||||
}
|
||||
// $sys_labels = Goods::where('id', $item['goods'])->value('sys_labels');
|
||||
// $supplier_arr=[];
|
||||
// if($sys_labels){
|
||||
@ -112,21 +116,49 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
// $item['supplier'] = array_unique($supplier_arr);
|
||||
|
||||
});
|
||||
$data['merchant_name'] = Merchant::where('mer_id', $data['merchant'])->value('mer_name');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* @notes 采购订单子订单详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2024/04/27 11:26
|
||||
*/
|
||||
public static function sub_detail($id, $page_no): array
|
||||
{
|
||||
$order_arr = Opurchaseclass::where('id', $id)->value('order_arr');
|
||||
$data = [];
|
||||
if ($order_arr) {
|
||||
$order_arr = explode(',', $order_arr);
|
||||
$order_arr_count = count($order_arr);
|
||||
$offset = ($page_no - 1) * $order_arr_count;
|
||||
$paged_items = array_slice($order_arr, $offset, $order_arr_count);
|
||||
if (!$paged_items) {
|
||||
return [];
|
||||
}
|
||||
$list = Cashierclass::whereIn('id', $order_arr)->select()?->toArray();
|
||||
$data['count'] = $order_arr_count;
|
||||
$data['lists'] = $list;
|
||||
$data['page_no'] = $page_no;
|
||||
$data['page_siz'] = 15;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 推送供应商商品
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @date 2024/04/27 11:26
|
||||
*/
|
||||
public static function createSupplierGoods($goods){
|
||||
try{
|
||||
$sys_labels = Goods::where('id', $goods['goods'])->value('sys_labels');
|
||||
$supplier_arr=[];
|
||||
$goods_offer=[];
|
||||
public static function createSupplierGoods($goods)
|
||||
{
|
||||
try {
|
||||
$sys_labels = Goods::where('id', $goods['goods'])->value('sys_labels');
|
||||
$supplier_arr = [];
|
||||
$goods_offer = [];
|
||||
|
||||
if ($sys_labels) {
|
||||
$sys_labels_arr = explode(',', $sys_labels);
|
||||
@ -139,38 +171,39 @@ class OpurchaseclassLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($supplier_arr as $k=>$v){
|
||||
$goods_offer[]=[
|
||||
'supplier_id'=>$v['supplier'],
|
||||
'goods_id'=>$v['goods'],
|
||||
'price'=>0,
|
||||
'need_num' => $v['nums']
|
||||
foreach ($supplier_arr as $k => $v) {
|
||||
$goods_offer[] = [
|
||||
'supplier_id' => $v['supplier'],
|
||||
'goods_id' => $v['goods'],
|
||||
'price' => 0,
|
||||
'need_num' => $v['nums']
|
||||
];
|
||||
}
|
||||
if($goods_offer){
|
||||
$res=OpurchaseGoodsOffer::insertAll($goods_offer);
|
||||
if($res){
|
||||
if ($goods_offer) {
|
||||
$res = OpurchaseGoodsOffer::insertAll($goods_offer);
|
||||
if ($res) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
Log::error('添加采购订单报价失败:'.$e->getMessage());
|
||||
Log::error('添加采购订单报价失败:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* @notes 设置采纳商品
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @date 2024/04/27 11:26
|
||||
*/
|
||||
public static function goodsOfferUpdate($params){
|
||||
try{
|
||||
OpurchaseGoodsOffer::where('id',$params)->update(['is_adopt'=>1]);
|
||||
public static function goodsOfferUpdate($params)
|
||||
{
|
||||
try {
|
||||
OpurchaseGoodsOffer::where('id', $params)->update(['is_adopt' => 1]);
|
||||
return true;
|
||||
}catch (\Exception $e){
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
@ -26,19 +26,6 @@ class PushSupplierProductsSend implements Consumer
|
||||
OpurchaseclassLogic::createSupplierGoods($arr);
|
||||
}
|
||||
}
|
||||
// 消费失败回调
|
||||
/*
|
||||
$package = [
|
||||
'id' => 1357277951, // 消息ID
|
||||
'time' => 1709170510, // 消息时间
|
||||
'delay' => 0, // 延迟时间
|
||||
'attempts' => 2, // 消费次数
|
||||
'queue' => 'send-mail', // 队列名
|
||||
'data' => ['to' => 'tom@gmail.com', 'content' => 'hello'], // 消息内容
|
||||
'max_attempts' => 5, // 最大重试次数
|
||||
'error' => '错误信息' // 错误信息
|
||||
]
|
||||
*/
|
||||
public function onConsumeFailure(\Throwable $e, $package)
|
||||
{
|
||||
$package['max_attempts']=0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user