diff --git a/app/Admin/Common/Rpc.php b/app/Admin/Common/Rpc.php index d980c3d..544ab71 100644 --- a/app/Admin/Common/Rpc.php +++ b/app/Admin/Common/Rpc.php @@ -15,6 +15,7 @@ class Rpc const GET_DISTANCE = "/location/getDistanceByTencent"; const DO_BY_ORDER = "/badge/doByOrder"; const ALI_SMS_SENT = "/alisms/sent"; + const FEI_E_PRINT = '/feie/doPrint'; @@ -135,5 +136,20 @@ class Rpc return $response->getBody()->getContents(); } + /** + * 订单打印 + * @param $oid + * @return string + */ + public static function doPrint($oid) + { + $client = Client::factory(env('RPC_SITE_HOST')); + $request = $client->request(uniqid(), + self::FEI_E_PRINT, + ['oid' => $oid] + ); + $response = $client->send($request); + return $response->getBody()->getContents(); + } } diff --git a/app/Admin/Extensions/OrderPrint.php b/app/Admin/Extensions/OrderPrint.php index c37c576..74eb744 100644 --- a/app/Admin/Extensions/OrderPrint.php +++ b/app/Admin/Extensions/OrderPrint.php @@ -4,6 +4,7 @@ namespace App\Admin\Extensions; +use App\Admin\Common\Rpc; use App\Models\Feprint; use App\Models\ImsCjdcOrderMain; use Dcat\Admin\Grid\RowAction; @@ -44,7 +45,6 @@ class OrderPrint extends RowAction public function doPrint($oid) { - $row = ImsCjdcOrderMain::find($oid); //>>1.获取打印机状态 @@ -52,7 +52,7 @@ class OrderPrint extends RowAction //>>2.调用打印 if ($result == 1) { - $res = $this->rpcPrint($oid); + $res = Rpc::doPrint($row->global_order_id); $res = json_decode($res, true)['result']; $res = json_decode($res); @@ -81,20 +81,4 @@ class OrderPrint extends RowAction return -1; } } - - - public function rpcPrint($oid) - { - $client = Client::factory(env('RPC_SITE_HOST')); - $request = $client->request(uniqid(), '/feie/doPrint', ['oid' => $oid]); - $response = $client->send($request); - return $response->getBody()->getContents(); - } - - public function feiErPrint($order_num) - { - include_once app_path('Libs\feier_print\api_php_demo.php'); - $result = json_decode(FeiePrint($order_num)); - dd($result); - } }