WeighExceptedService.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Services;
  3. use App\OrderPackage;
  4. use App\Services\common\QueryService;
  5. use Illuminate\Database\Eloquent\Builder;
  6. const TABLE = "order_packages.";
  7. Class WeighExceptedService
  8. {
  9. /**
  10. * @param array $params
  11. * @return Builder
  12. */
  13. private function conditionQuery(array $params){
  14. $query = OrderPackage::query()->orderBy(TABLE.'id','DESC')->selectRaw(TABLE."* ");
  15. $columnQueryRules=[
  16. 'id' => ['multi' => ','],
  17. ];
  18. return app(QueryService::class)->query($params,$query,$columnQueryRules,"order_packages");
  19. }
  20. public function getCreateExceptionSql(array $params){
  21. return $this->conditionQuery($params)->where(TABLE.'status',"上传异常")->orWhere(TABLE.'status',"测量异常")
  22. ->leftJoin('orders',TABLE.'order_id','orders.id')
  23. ->LeftJoin('logistics','orders.logistic_id','logistics.id')
  24. ->selectRaw('logistics.name logistic_name')
  25. ->LeftJoin('paper_boxes',TABLE.'paper_box_id','paper_boxes.id')
  26. ->selectRaw('paper_boxes.model paper_box_name')
  27. ->LeftJoin('measuring_machines',TABLE.'measuring_machine_id','measuring_machines.id')
  28. ->selectRaw('measuring_machines.name measuring_machine_name')
  29. ->sql();
  30. }
  31. public function getIssuedExceptionSql(array $params){
  32. return $this->conditionQuery($params)->where(TABLE.'status',"下发异常")->orWhere(TABLE.'status',"记录异常")
  33. ->orWhere(TABLE.'status',"已上传异常")
  34. ->leftJoin('orders',TABLE.'order_id','orders.id')
  35. ->LeftJoin('logistics','orders.logistic_id','logistics.id')
  36. ->selectRaw('logistics.name logistic_name')
  37. ->sql();
  38. }
  39. }