QrcodeService.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace app\extra\service\saas;
  3. use app\extra\basic\Service;
  4. use app\model\saas\SaasOrderQrcode;
  5. class QrcodeService extends Service
  6. {
  7. /**
  8. * 列表
  9. * @param array $param
  10. */
  11. public function getList(array $param = [])
  12. {
  13. $this->mode = new SaasOrderQrcode();
  14. return $this->searchVal($param,$this->searchFilter($param))->with(['shop' => function($query){
  15. $query->field("shop_id,shop_name");
  16. }])->paginate([
  17. "list_rows" => $param['pageSize'],
  18. "page" => $param['page']
  19. ]);
  20. }
  21. public function getTotal(array $param = []): array
  22. {
  23. $this->mode = new SaasOrderQrcode();
  24. $total = ['t0' => 0, 't1' => 0, 'ta' => 0];
  25. foreach ($this->searchVal($param,[['status',">",0]])->field('create_at,status,count(1) total')->group('status,create_at')->cursor() as $vo)
  26. {
  27. [$total["t{$vo['status']}"] += $vo['total'], $total['ta'] += $vo['total']];
  28. }
  29. return $total;
  30. }
  31. protected function searchFilter(array $param = []): array
  32. {
  33. $filter = [];
  34. !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)];
  35. !empty($param['statusGt']) && $filter[] = ["status", '>', ($param['statusGt']-1)];
  36. !empty($param['orderid']) && $filter[] = ["order_sn", 'like', "%{$param['orderid']}%"];
  37. !empty($param['shop']) && $filter[] = ["shop_id", '=', $param['shop']];
  38. return $filter;
  39. }
  40. }