94 lines
3.1 KiB
PHP
94 lines
3.1 KiB
PHP
<?php
|
|
|
|
|
|
namespace Yunshop\TeamDividend\admin;
|
|
|
|
use app\common\components\BaseController;
|
|
use app\common\helpers\PaginationHelper;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Yunshop\TeamDividend\models\Order;
|
|
use app\common\services\ExportService;
|
|
use Yunshop\TeamDividend\admin\models\TeamDividendAgencyModel;
|
|
use Yunshop\TeamDividend\admin\models\TeamDividendModel;
|
|
use Yunshop\TeamDividend\admin\models\OrderGoods;
|
|
|
|
class StatisticsController extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
$search = request()->search;
|
|
$list = OrderGoods::getList($search)->simplePaginate(20);
|
|
$statistics = OrderGoods::getList($search, DB::raw("sum(payment_amount) as amount_sum,count(*) as count"))->first();
|
|
$amount = $statistics['amount_sum'];
|
|
$pager = PaginationHelper::show($statistics['count'], $list->currentPage(), $list->perPage());
|
|
if (!$search['time']) {
|
|
$search['time']['start'] = date("Y-m-d H:i:s", time());
|
|
$search['time']['end'] = date("Y-m-d H:i:s", time());
|
|
}
|
|
|
|
return view('Yunshop\TeamDividend::admin.statistics-list', [
|
|
'list' => $list->toArray(),
|
|
'search' => $search,
|
|
'pager' => $pager,
|
|
'orderAmount' =>$amount
|
|
]);
|
|
}
|
|
|
|
public function export()
|
|
{
|
|
$file_name = date('Ymdhis', time()) . '经销商提成明细导出';
|
|
$search = \YunShop::request()->get('search');
|
|
$page = request()->export_page ?: 1;
|
|
$list = OrderGoods::getList($search);
|
|
$export_model = new ExportService($list, $page);
|
|
|
|
$list = $export_model->builder_model->toArray();
|
|
|
|
$export_data[0] = [
|
|
'ID',
|
|
'日期',
|
|
'会员ID',
|
|
'会员',
|
|
'订单号',
|
|
'商品',
|
|
'订单金额',
|
|
'订单状态',
|
|
];
|
|
foreach ($list as $key => $item) {
|
|
switch ($item['order']['status']) {
|
|
case-1:
|
|
$item['status_name'] = '已关闭';
|
|
break;
|
|
case 0:
|
|
$item['status_name'] = '待支付';
|
|
break;
|
|
case 1:
|
|
$item['status_name'] = '待发货';
|
|
break;
|
|
case 2:
|
|
$item['status_name'] = '待收货';
|
|
break;
|
|
case 3:
|
|
$item['status_name'] = '已完成';
|
|
break;
|
|
case 11:
|
|
$item['status_name'] = '已退款';
|
|
break;
|
|
}
|
|
$export_data[$key + 1] = [
|
|
$item['id'],
|
|
$item['created_at'],
|
|
$item['uid'],
|
|
$item['has_one_member']['nickname'],
|
|
$item['order']['order_sn'],
|
|
$item['goods_title'],
|
|
$item['order']['price'],
|
|
$item['status_name'],
|
|
];
|
|
}
|
|
|
|
$export_model->export($file_name, $export_data, 'plugin.team-dividend.admin.statistics.index');
|
|
// return \app\exports\ExcelService::fromArrayExport($export_data, $file_name);
|
|
}
|
|
|
|
} |