You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
1.4 KiB
72 lines
1.4 KiB
<?php
|
|
|
|
|
|
namespace App\Admin\Extensions;
|
|
|
|
|
|
use App\Models\Feprint;
|
|
use App\Models\ImsCjdcOrderMain;
|
|
use Dcat\Admin\Grid\RowAction;
|
|
use Illuminate\Http\Request;
|
|
|
|
class OrderPrint extends RowAction
|
|
{
|
|
protected $title;
|
|
public function __construct($title=null)
|
|
{
|
|
parent::__construct($title);
|
|
|
|
}
|
|
|
|
public function handle(Request $request)
|
|
{
|
|
$id = $this->getKey();
|
|
$this->doPrint();
|
|
dd($id);
|
|
}
|
|
|
|
/**
|
|
* 设置要POST到接口的数据
|
|
*
|
|
* @return array
|
|
*/
|
|
public function parameters()
|
|
{
|
|
|
|
}
|
|
|
|
public function doPrint()
|
|
{
|
|
$oid = $this->getKey();
|
|
$row = ImsCjdcOrderMain::find($oid);
|
|
|
|
//>>1.获取打印机状态
|
|
$result = $this->getPrintStatus($row->market_id);
|
|
//>>2.调用打印
|
|
if ($result==1){
|
|
$this->feiErPrint($row->order_num);
|
|
}
|
|
//>>3.记录打印次数
|
|
}
|
|
|
|
/**
|
|
* @param $oid //主订单ID
|
|
* @return int
|
|
*/
|
|
public function getPrintStatus($mid)
|
|
{
|
|
$fe = Feprint::where('market_id',$mid)->first();
|
|
if ($fe){
|
|
return $fe->status;
|
|
}else{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
public function feiErPrint($order_num)
|
|
{
|
|
include_once app_path('Libs\feier_print\api_php_demo.php');
|
|
$result = json_decode(FeiePrint($order_num));
|
|
dd($result);
|
|
}
|
|
}
|