|
|
@@ -2,13 +2,36 @@
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
+use App\Terminal;
|
|
|
+use App\TerminalPrinter;
|
|
|
use App\Traits\ServiceAppAop;
|
|
|
use App\TerminalPrinterLogistic;
|
|
|
+use Illuminate\Support\Facades\Request;
|
|
|
|
|
|
class TerminalPrinterLogisticService
|
|
|
{
|
|
|
use ServiceAppAop;
|
|
|
protected $modelClass=TerminalPrinterLogistic::class;
|
|
|
|
|
|
+ // 匹配设置好的打印机
|
|
|
+ // $results 集合 DeliveryService->getDelivery 返回面单信息
|
|
|
+ public function setPrinterName(&$results)
|
|
|
+ {
|
|
|
+ $ip = Request::ip();
|
|
|
+ $terminalQuery = Terminal::query()->select('id')->where('ip', $ip);
|
|
|
+ $terminalPrinterQuery = TerminalPrinter::query()->select('id')->whereIn('terminal_id',$terminalQuery);
|
|
|
+ $terminalPrinterLogistics = TerminalPrinterLogistic::query()->with('terminalPrinter','logistic')->whereIn('terminal_printer_id',$terminalPrinterQuery)->get();
|
|
|
|
|
|
+ foreach ($terminalPrinterLogistics as &$item) {
|
|
|
+ $logisticCode = $item['logistic']['code'];
|
|
|
+ $terminalPrinterName = $item['terminalPrinter']['printer_name'];
|
|
|
+ $data[$logisticCode] = $terminalPrinterName;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach ($results as &$result){
|
|
|
+ $result['printerName'] = $data[$result['logistic_code']] ?? '';
|
|
|
+ }
|
|
|
+
|
|
|
+ return $results;
|
|
|
+ }
|
|
|
}
|