1
0

提交代码

This commit is contained in:
2020-08-06 14:45:56 +08:00
commit 9d0d5f4be9
361 changed files with 36445 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Admin\Exporters;
use App\Models\User;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
class AccountLog extends ExcelExporter implements WithMapping
{
protected $fileName = '佣金明细.xlsx';
protected $headings = [
'序号',
'用户编号',
'用户账号',
'用户名称',
'佣金名称',
'佣金金额',
'佣金描述',
'产生时间',
];
public function __construct()
{
$this->fileName = '佣金明细' . date('YmdHis') . '.xlsx';
}
public function map($info): array
{
$data = [
'id' => (string) $info->id,
'user_id' => (string) $info->user_id,
'username' => '`' . $info->user->username,
'nickname' => (string) $info->userinfo->nickname,
'title' => (string) $info->rule->title,
'variable' => (string) $info->variable,
'remark' => (string) $info->rule->remark,
'created_at' => (string) $info->created_at,
];
return $data;
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace App\Admin\Exporters;
use App\Models\User;
use Encore\Admin\Grid\Exporters\CsvExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
class CardExporters extends CsvExporter implements WithMapping, WithStrictNullComparison
{
protected $fileName = '联卡蝠激活卡.csv';
protected $mapTrue = true;
protected $users = [];
public function __construct()
{
$this->fileName = '联卡蝠激活卡' . date('YmdHis') . '.csv';
$this->users = User::pluck('username', 'id')->toArray();
}
protected $headings = ['卡序号', '归属', '卡号', '打印卡号', '卡密', '类型', '专项', '状态', '激活用户', '激活时间', '创建时间', '更改时间'];
public function map($info): array
{
$data = [
$info->id,
$this->users[$info->user_id] ?? '无',
'`' . $info->code,
$info->type . $info->code,
$info->pass,
$info->type,
$info->type == 'K' ? '商品ID' . $info->source['goods'] . '规格ID' . $info->source['param'] : '非专项',
$info->status_text,
$this->users[$info->active_id] ?? '无',
$info->actived_at,
$info->created_at,
$info->updated_at,
];
return $data;
}
}

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Admin\Exporters;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
class CashOutExport extends ExcelExporter implements WithMapping
{
protected $fileName = '提现用户.xlsx';
protected $columns = [
'id' => '序号',
'user_id' => '用户ID',
'user.username' => '用户账号',
'user.info.nickname' => '用户昵称',
'cash_account_no' => '支付宝账户',
'variable' => '提现金额',
'state' => '提现状态',
'created_at' => '提现时间',
];
public function map($info): array
{
$data = [
'id' => $info->id,
'user_id' => $info->user_id,
'user.username' => ' ' . $info->user->username,
'user.info.nickname' => ' ' . $info->user->info->nickname,
'cash_account_no' => ' ' . $info->cash_account_no,
'variable' => ' ' . $info->variable,
'state' => $info->state_text,
'created_at' => $info->created_at,
];
return $data;
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* Created by PhpStorm.
* User: 朝霞
* Date: 2019/5/14
* Time: 1:51 PM
*/
namespace App\Admin\Exporters;
use Encore\Admin\Grid\Exporters\AbstractExporter;
use Maatwebsite\Excel\Facades\Excel;
class GoodsExporter extends AbstractExporter
{
/**
* @Notes 商品导出
* @Author 朝霞
* @DateTime 2019/5/14 2:09 PM
*/
public function export()
{
Excel::create('商品导出', function ($excel) {
$excel->sheet('Sheetname', function ($sheet) {
$head = ['商品ID','商品名称','成本价','销售价','市场价','销量','库存','销售分公司','状态','开团时间','截团时间','创建时间', '最后更新时间'];
$body = ['id','name','cost_price','price','original_price','sales','stock','companies','status','activity_begined_at','activity_ended_at','created_at', 'updated_at'];
$bodyRows = collect($this->getData())->map(function ($item)use($body) {
foreach ($body as $keyName){
switch ($keyName) {
case 'status' :
switch (array_get($item, $keyName)) {
case 0:
$arr[] = '审核中';
break;
case 1:
$arr[] = '上架';
break;
case -1:
$arr[] = '下架';
break;
default:
$arr[] = '未知状态';
break;
}
break;
case 'companies' :
$companies = array_get($item, 'companies');
$arr[] = count($companies) > 0 ? implode('/', array_column($companies,'name')) : '';
break;
default:
$arr[] = array_get($item, $keyName);
break;
}
}
return $arr;
});
$rows = collect([$head])->merge($bodyRows);
$sheet->rows($rows);
});
})->export('xlsx');
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace App\Admin\Exporters;
use App\Models\User;
use Encore\Admin\Grid\Exporters\CsvExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
class OrderExporter extends CsvExporter implements WithMapping, WithStrictNullComparison
{
protected $mapTrue = true;
public function __construct()
{
$this->fileName = '订单导出' . date('YmdHis') . '.csv';
}
protected $headings = ['订单编号', '商品总数', '订单类型', '商品信息', '下单用户', '价格', '状态', '下单时间', '付款时间'];
public function map($info): array
{
$data = [
'`' . $info->orderid,
$info->details()->sum('number'),
$info->type_text,
self::getGoodsValue($info->details),
$info->user->info->nickname . "\r\n" . $info->user->username,
"商品小计:" . number_format($info->amount, 2) . "\r\n" . "应收总额:" . number_format($info->total, 2),
self::getOrderStatus($info),
$info->created_at,
$info->paid_at,
];
return $data;
}
protected function getGoodsValue($details)
{
$ret = '';
foreach ($details as $detail) {
$ret .= $detail['item']['name'] . number_format($detail['price'], 2) . "\r\n";
}
return $ret;
}
protected function getOrderStatus($order)
{
$ret = $order->state_text . "\r\n";
if ($order->payment) {
$ret .= $order->payment->type_text . "\r\n";
$ret .= $order->payment->trade_no . "\r\n";
$ret .= $order->payment->transaction_id;
}
return $ret;
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Admin\Exporters;
use Encore\Admin\Grid\Exporters\ExcelExporter;
use Maatwebsite\Excel\Concerns\WithMapping;
class ProvinceExporter extends ExcelExporter implements WithMapping
{
protected $fileName = '省市管理.xlsx';
protected $columns = [
'shortname' => '省市区名称',
];
public function map($area): array
{
return [
$area->shortname,
];
}
}