conditions = $conditions; parent::__construct(); } /** * @return Builder */ public function query() { if (!isset(self::$types[$this->conditions['type']])) { throw new NotAllowedException('统计类型不存在'); } $builder = app(OrderCardPartitionRepository::class)->forceNoReset()->withConditions($this->conditions)->applyConditions()->orderBy('sim'); return $builder; } public function headings(): array { return [ 'SIM', '企业名称', '套餐名称', '套餐周期', '支付方式', '价格', '数量', '订单时间', ]; } /** * @param mixed $row * * @return mixed */ public function rows($rows) { $rows = OrderService::detailTransformer(collect($rows)); $array = []; foreach ($rows as $item) { $array[] = [ $item['sim'], $item['company_name'], $item['package_name'], $item['service_months'], $item['pay_channel_name'], $item['unit_price'], $item['counts'], $item['order_at'], ]; } return $array; } /** * @return array */ public function columnFormats(): array { return [ 'A' => NumberFormat::FORMAT_NUMBER, 'F' => NumberFormat::FORMAT_NUMBER_00, 'G' => NumberFormat::FORMAT_NUMBER, 'H' => NumberFormat::FORMAT_DATE_YYYYMMDD2, ]; } /** * 类型 * * @return void */ protected function tag() { if (!isset(self::$types[$this->conditions['type']])) { throw new NotAllowedException('类型不允许'); } $tag = self::$types[$this->conditions['type']] . $tag; return $tag; } }