链街Dcat后台
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

5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Extensions;
  3. use App\Models\Feprint;
  4. use App\Models\ImsCjdcOrderMain;
  5. use Dcat\Admin\Grid\RowAction;
  6. use Illuminate\Http\Request;
  7. class OrderPrint extends RowAction
  8. {
  9. protected $title;
  10. public function __construct($title=null)
  11. {
  12. parent::__construct($title);
  13. }
  14. public function handle(Request $request)
  15. {
  16. $id = $this->getKey();
  17. $this->doPrint();
  18. dd($id);
  19. }
  20. /**
  21. * 设置要POST到接口的数据
  22. *
  23. * @return array
  24. */
  25. public function parameters()
  26. {
  27. }
  28. public function doPrint()
  29. {
  30. $oid = $this->getKey();
  31. $row = ImsCjdcOrderMain::find($oid);
  32. //>>1.获取打印机状态
  33. $result = $this->getPrintStatus($row->market_id);
  34. //>>2.调用打印
  35. if ($result==1){
  36. $this->feiErPrint($row->order_num);
  37. }
  38. //>>3.记录打印次数
  39. }
  40. /**
  41. * @param $oid //主订单ID
  42. * @return int
  43. */
  44. public function getPrintStatus($mid)
  45. {
  46. $fe = Feprint::where('market_id',$mid)->first();
  47. if ($fe){
  48. return $fe->status;
  49. }else{
  50. return -1;
  51. }
  52. }
  53. public function feiErPrint($order_num)
  54. {
  55. include_once app_path('Libs\feier_print\api_php_demo.php');
  56. $result = json_decode(FeiePrint($order_num));
  57. dd($result);
  58. }
  59. }