98 lines
3.8 KiB
PHP
98 lines
3.8 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Exports;
|
||
|
|
|
||
|
|
|
||
|
|
use Illuminate\Support\Collection;
|
||
|
|
use Maatwebsite\Excel\Concerns\FromCollection;//设置单元格数据格式
|
||
|
|
|
||
|
|
|
||
|
|
class TouristOrdersEarningExport //implements FromCollection //,WithHeadings//,WithStrictNullComparison,ShouldAutoSize,WithStyles//,WithCustomValueBinder //,WithColumnFormatting
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* @return Collection
|
||
|
|
*/
|
||
|
|
protected $data;
|
||
|
|
private $title;
|
||
|
|
private $earningNum = []; //一个订单的商品数量
|
||
|
|
private $column; //总行数
|
||
|
|
public function __construct($data, $title = '')
|
||
|
|
{
|
||
|
|
$this->data = $data;
|
||
|
|
$this->title = $title;
|
||
|
|
}
|
||
|
|
public function headings(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'订单号','序号(系统订单号)','支付微信昵称','手机号','订单金额', '商家收入','系统支付状态', '系统支付时间', '购买渠道', '物品名称', '推广用户昵称',
|
||
|
|
'推广用户手机号','推广比例','推广金额','推广类型','分成时间',
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function collection_a()
|
||
|
|
{
|
||
|
|
$list = [];
|
||
|
|
$data = $this->data;
|
||
|
|
foreach ($data as $key =>$value){
|
||
|
|
$this->earningNum[] = count($value['m_earning']);
|
||
|
|
if(!empty($value['m_earning'])) {
|
||
|
|
foreach ($value['m_earning'] as $k => $item) {
|
||
|
|
if (!empty($item['user'])) {
|
||
|
|
$share_name = $item['user']['nickname'];
|
||
|
|
$share_mobile = $item['user']['mobile'];
|
||
|
|
} elseif (!empty($item['merchant'])) {
|
||
|
|
$share_name = $item['merchant']['share_title'];
|
||
|
|
$share_mobile = $item['merchant']['mobile'];
|
||
|
|
} else {
|
||
|
|
$share_name = '';
|
||
|
|
$share_mobile = '';
|
||
|
|
}
|
||
|
|
$list[] = [
|
||
|
|
'id'=>$value['id'],
|
||
|
|
'trade_no' => $value['trade_no'],
|
||
|
|
'name' => $value['name'],
|
||
|
|
'mobile' => $value['mobile'],
|
||
|
|
'price' => $value['price'],
|
||
|
|
'merchant_price' => $value['can_withdraw_count'],
|
||
|
|
'pay_status' => '完成支付',
|
||
|
|
'created_at' => $value['created_at'],
|
||
|
|
'channel' => $value['channel'],
|
||
|
|
'goods' => $value['desc'],
|
||
|
|
'share_name' => $share_name,
|
||
|
|
'share_mobile' => (string)$share_mobile,
|
||
|
|
'share_ratio' => $item['ratio'],
|
||
|
|
'share_value' => $item['value'],
|
||
|
|
'share_type' => $item['sharer'],
|
||
|
|
'share_data' => $item['created_at'],
|
||
|
|
'total' => $value['total'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}else{
|
||
|
|
$list[] = [
|
||
|
|
'id'=>$value['id'],
|
||
|
|
'trade_no' => $value['trade_no'],
|
||
|
|
'name' => $value['name'],
|
||
|
|
'mobile' => $value['mobile'],
|
||
|
|
'price' => $value['price'],
|
||
|
|
'merchant_price' =>'0.00',
|
||
|
|
'pay_status' => '完成支付',
|
||
|
|
'created_at' => $value['created_at'],
|
||
|
|
'channel' => $value['channel'],
|
||
|
|
'goods' => $value['desc'],
|
||
|
|
'share_name' => '',
|
||
|
|
'share_mobile' => '',
|
||
|
|
'share_ratio' => '',
|
||
|
|
'share_value' => '',
|
||
|
|
'share_type' => '',
|
||
|
|
'share_data' => '',
|
||
|
|
'total' => $value['total'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
//$this->column = count($list);
|
||
|
|
//return collect($list);
|
||
|
|
return $list;
|
||
|
|
}
|
||
|
|
}
|