conditions = $conditions; parent::__construct(); } public function query() { $builder = app(OrderCardPartitionRepository::class)->with('order')->forceNoReset()->select(['sim', 'order_id', 'counts', 'refunded_at']) ->withRefunded()->withConditions($this->conditions)->orderBy('order_id')->orderBy('sim')->skipCache(); return $builder; } public function headings(): array { $headings = [ '订单编号', '企业名称', '运营商', '套餐名称', '套餐单价', '支付方式', '支付流水号', '订单时间', 'SIM', '数量', '退货', ]; if ($this->conditions['type'] == 0) { array_splice($headings, 6, 0, [ '订单状态', // '收款状态', ]); } return $headings; } /** * @param mixed $row * * @return mixed */ public function rows($rows) { $array = []; $carrierOperators = app(Dicts::class)->get('carrier_operator'); $orderStatues = app(Dicts::class)->get('order_status'); $transactionStatuses = app(Dicts::class)->get('transaction_status'); foreach ($rows as $item) { $carrier_operator = PackageService::load($item['order']['package_id'])['carrier_operator']; $data = [ "{$item['order']['sn']}\t", CompanyService::load($item['order']['company_id'])['name'] ?? '', $carrierOperators[$carrier_operator], PackageService::load($item['order']['package_id'])['name'] ?? '', sprintf('%.02f', $item['order']['unit_price'] / 100), CommonService::namePayChannel($item['order']['pay_channel']), "{$item['order']['transaction_no']}\t", Carbon::parse($item['order']['order_at'])->format('Y-m-d'), "{$item['sim']}\t", $item['counts'], $item['refunded_at'] ? '是' : '', ]; if ($this->conditions['type'] == 0) { array_splice($data, 6, 0, [ $orderStatues[$item['order']['order_status']], // $transactionStatuses[$item['order']['transaction_status']], ]); } $array[] = $data; } return $array; } /** * @return array */ public function columnFormats(): array { return [ 'E' => NumberFormat::FORMAT_NUMBER_00, ]; } }