mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-12-01 14:40:44 +00:00
a订单导出
This commit is contained in:
parent
67dd4ea4fb
commit
c60786f798
@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Http\Enum\AfterSaleOrderStatusEnum;
|
||||
use App\Models\DailyReport;
|
||||
use App\Models\Shop;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Illuminate\Support\Collection;
|
||||
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
||||
|
||||
class BusinessAfterOrderExport implements FromCollection, ShouldAutoSize
|
||||
{
|
||||
@ -43,19 +43,15 @@ class BusinessAfterOrderExport implements FromCollection, ShouldAutoSize
|
||||
];
|
||||
$bodyData = [];
|
||||
foreach ($orders as $order) {
|
||||
$productInfo = "";
|
||||
foreach ($order['items'] as $item) {
|
||||
$productInfo .= $item['goods_name'] . "|" . $item['goods_number'] . ",";
|
||||
}
|
||||
rtrim($productInfo, ",");
|
||||
$bodyData[] = [
|
||||
$order['order_sn'],
|
||||
$order['shop']['name'],
|
||||
bcdiv($order['refund_amount'],100,2),
|
||||
bcdiv($order['refund_shipping_amount'],100,2),
|
||||
$order['reason'],
|
||||
$order['description'],
|
||||
implode(",",$order['image_list']),
|
||||
$order['cancel_status'],
|
||||
AfterSaleOrderStatusEnum::getData($order['after_sales_status']),
|
||||
$order['after_sale_created_at']
|
||||
];
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers\Business;
|
||||
|
||||
use App\Exports\BusinessAfterOrderExport;
|
||||
use App\Exports\BusinessOrderExport;
|
||||
use App\Exports\OrderBlankExport;
|
||||
use App\Http\Controllers\Controller;
|
||||
@ -27,12 +28,14 @@ class BusinessAfterSaleOrderController extends Controller
|
||||
->where('plat_id', Shop::$PLAT_KTT)
|
||||
->pluck('id');
|
||||
$builder = BusinessAfterSaleOrder::query()
|
||||
->with(["shop:id,name"])
|
||||
->whereIn('shop_id', $shopIds)
|
||||
->filter();
|
||||
if (!empty($request->created_at_start) & !empty($request->created_at_end)) {
|
||||
$builder = $builder->whereBetween("after_sale_created_at"
|
||||
, [$request->created_at_start, $request->created_at_end]);
|
||||
}
|
||||
|
||||
if ($request->get("is_export")) {
|
||||
$params = $request->validate([
|
||||
'created_at_start' => 'required',
|
||||
@ -48,7 +51,7 @@ class BusinessAfterSaleOrderController extends Controller
|
||||
throw new \Exception("导出时间超出一个月");
|
||||
}
|
||||
|
||||
return Excel::download(new BusinessOrderExport($builder->get()->toArray())
|
||||
return Excel::download(new BusinessAfterOrderExport($builder->get()->toArray())
|
||||
, $startDate . '~' . $endDate . "售后订单数据" . '.xlsx');
|
||||
}
|
||||
$businessOrders = $builder->orderByDesc('after_sale_created_at')
|
||||
|
||||
34
app/Http/Enum/AfterSaleOrderStatusEnum.php
Normal file
34
app/Http/Enum/AfterSaleOrderStatusEnum.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Enum;
|
||||
|
||||
|
||||
class AfterSaleOrderStatusEnum
|
||||
{
|
||||
const WAIT = 0;
|
||||
const REFUNDING = 1;
|
||||
const REFUNDED_SUCCESS = 2;
|
||||
const WAIT_HANDLE = 3;
|
||||
const REFUND_REFUSE = 4;
|
||||
const WAIT_RETURN_GOOD = 6;
|
||||
const WAIT_CONFIRM_RETURN_GOOD = 7;
|
||||
const USER_CANCEL = 8;
|
||||
const CLOSE = 9;
|
||||
|
||||
const MAP = [
|
||||
self::WAIT => "未发起售后",
|
||||
self::REFUNDING => "退款中",
|
||||
self::REFUNDED_SUCCESS => "退款成功",
|
||||
self::WAIT_HANDLE => "待处理",
|
||||
self::REFUND_REFUSE => "拒绝退款",
|
||||
self::WAIT_RETURN_GOOD => "待退货",
|
||||
self::WAIT_CONFIRM_RETURN_GOOD => "待团长确认退货",
|
||||
self::USER_CANCEL => "用户取消",
|
||||
self::CLOSE => "系统已关闭",
|
||||
];
|
||||
|
||||
public static function getData($key)
|
||||
{
|
||||
return self::MAP[$key] ?? '';
|
||||
}
|
||||
}
|
||||
@ -30,4 +30,8 @@ class BusinessAfterSaleOrder extends Model
|
||||
{
|
||||
return !empty($value) ? json_decode($value, true) : $value;
|
||||
}
|
||||
public function shop()
|
||||
{
|
||||
return $this->belongsTo(Shop::class, 'shop_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user