mode = new SaasOrder(); return $this->searchVal($param,$this->searchFilter($param))->field("*")->with(['detail'])->paginate([ "list_rows" => $param['pageSize'], "page" => $param['page'] ]); } public function getTotal(array $param = []): array { $this->mode = new SaasOrder(); $total = ['t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 't4' => 0, 't5' => 0, 't6' => 0, 'ta' => 0]; $where = []; if (!empty($param['shop'])) { $where[] = ['shop_id','=',$param['shop']]; } $where[] = ['status',">",0]; foreach ($this->searchVal($param,$where)->field('create_at,status,count(1) total')->group('status,create_at')->cursor() as $vo) { [$total["t{$vo['status']}"] += $vo['total'], $total['ta'] += $vo['total']]; } return $total; } public function getTotalToday(array $param = []): array { $this->mode = new SaasOrder(); $total = ['ta' => 0,'t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 't4' => 0, 't5' => 0, 't6' => 0, 'tm' => 0, 'p1' => 0, 'p2' => 0, 'p1m' => 0, 'p2m' => 0]; $where = []; if (!empty($param['shop'])) { $where[] = ['shop_id','=',$param['shop']]; } foreach ($this->mode->whereDay("create_at")->where($where)->whereIn("status",[1,2,3])->field('create_at,pay_type,status,sum(discount) as money,count(1) as total')->group('status,create_at,pay_type')->cursor() as $vo) { $total["t{$vo['status']}"] += $vo['total']; $total['ta'] += $vo['total']; $total['tm'] += $vo['money']; if ($vo['pay_type'] == 1) { $total["p1"] += $vo['total']; $total["p1m"] += $vo['money']; } if ($vo['pay_type'] == 2) { $total["p2"] += $vo['total']; $total["p2m"] += $vo['money']; } } return $total; } protected function searchFilter(array $param = []): array { $filter = []; !empty($param['status']) && $filter[] = ["status", '=', ($param['status']-1)]; !empty($param['statusGt']) && $filter[] = ["status", '>', ($param['statusGt']-1)]; !empty($param['orderid']) && $filter[] = ["order_sn", 'like', "%{$param['orderid']}%"]; !empty($param['shop']) && $filter[] = ["shop_id", '=', $param['shop']]; return $filter; } }