getKey(); $result = $this->doPrint($oid); if ($result){ return $this->response()->success('操作成功'); }else{ return $this->response()->success('打印失败'); } } /** * 设置要POST到接口的数据 * * @return array */ public function parameters() { } public function doPrint($oid) { $row = ImsCjdcOrderMain::find($oid); //>>1.获取打印机状态 $result = $this->getPrintStatus($row->market_id); //>>2.调用打印 if ($result == 1) { $res = Rpc::doPrint($row->global_order_id); $res = json_decode($res, true)['result']; $res = json_decode($res); //>>3.记录打印次数 if ($res->msg == 'ok' && $res->ret == 0) { //记录打印次数 $row->print_num +=1; return $row->save(); } else { return false; } } } /** * @param $oid //主订单ID * @return int */ public function getPrintStatus($mid) { $fe = Feprint::where('market_id', $mid)->first(); if ($fe) { return $fe->status; } else { return -1; } } }