OrderPackageExpressBillPrintRecordService.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Services;
  3. use App\OrderPackage;
  4. use App\Traits\ServiceAppAop;
  5. use App\OrderPackageExpressBillPrintRecord;
  6. use Illuminate\Support\Facades\Auth;
  7. class OrderPackageExpressBillPrintRecordService
  8. {
  9. use ServiceAppAop;
  10. protected $modelClass=OrderPackageExpressBillPrintRecord::class;
  11. // 添加 快递面单打印记录
  12. public function expressBillPrintRecord($logisticNumber,$task_id): array
  13. {
  14. $orderPackage = OrderPackage::query()->with('order')->where('logistic_number',$logisticNumber)->first();
  15. $data = ['logistic_number' => $logisticNumber];
  16. if ($orderPackage){
  17. $data['order_id'] = $orderPackage['order']['id'];
  18. $data['order_package_id'] = $orderPackage['id'];
  19. }
  20. $printCount = OrderPackageExpressBillPrintRecord::query()->where('logistic_number',$logisticNumber)->max("print_count");
  21. if ($printCount == 0) $printCount = 1;
  22. else $printCount ++;
  23. $data['print_count'] = $printCount;
  24. $data['task_id'] = $task_id;
  25. $data['process_id'] = Auth::user()['id'];
  26. OrderPackageExpressBillPrintRecord::query()->create($data);
  27. return ['success' => true];
  28. }
  29. }