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', 'all'); if ($is_push != 'all') { $where['is_push'] = $is_push; } $where['pid'] = $id; $res = Opurchaseinfo::where($where)->page($page_no, $page_size)->select() ->each(function ($item) { $find = Goods::where('id', $item['goods'])->with('unitName')->find(); if ($find) { $item['goods_name'] = $find['name']; $item['unit_name'] = $find['unit_name']; } $where = [ 'goods_id' => $item['goods'], 'order_id' => $item['pid'], 'is_adopt' => 1 ]; $item['nums_count'] = OpurchaseGoodsOffer::where($where)->sum('nums'); }); $data['count'] = Opurchaseinfo::where($where)->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 采购订单入库列表 */ public function storage_list() { $this->request->__set('storage_list',1); return $this->dataLists(new OpurchaseclassofferLists()); } /** * @notes 采购订单出库列表 */ public function stream_list() { $id=$this->request->get('id'); $order_arr= Opurchaseclass::where('id',$id)->where('is_mer',2)->value('order_arr'); $arr=Opurchaseclass::where('id','in',explode(',',$order_arr))->where('is_mer',1)->value('order_arr'); if($arr){ $this->request->__set('class_value',['id'=>explode(',',$arr)]); $this->request->__set('class_key',['in'=>'id']); } return $this->dataLists(new CashierclassStreamLists()); } /** * @notes 采购订单设置已出库 */ public function stream_update() { $id=$this->request->post('id'); $order_code=$this->request->post('order_code'); if($id){ Cashierclass::where('id',$id)->update(['is_stream'=>1,'stream_admin_id'=>$this->request->adminId,'stream_time'=>time()]); return $this->success('更新成功'); } if($order_code){ Cashierclass::where('number',$order_code)->update(['is_stream'=>1,'stream_admin_id'=>$this->request->adminId,'stream_time'=>time()]); return $this->success('更新成功'); } return $this->fail('没有任何更新'); } /** * @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]); // $select=Opurchaseinfo::where('pid',$id)->where('is_push',0)->select(); // foreach ($select as $key => $arr) { // $result = OpurchaseclassLogic::createSupplierGoods($arr); // } // 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()); } }