WeighExceptedService.php 1.8 KB

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