添加导出发货单
parent
3b8eb74a13
commit
0bedac5f1f
|
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\Grid\Exports;
|
||||||
|
|
||||||
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
|
use Dcat\Admin\Actions\Response;
|
||||||
|
use Dcat\Admin\Grid\RowAction;
|
||||||
|
use Dcat\Admin\Traits\HasPermissions;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ShippingOrder extends RowAction
|
||||||
|
{
|
||||||
|
public function title()
|
||||||
|
{
|
||||||
|
if ($this->title) {
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
return '<i class="feather grid-action-icon icon-download"></i> 导出发货单 ';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Model|Authenticatable|HasPermissions|null $user
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function authorize($user): bool
|
||||||
|
{
|
||||||
|
return $user->can('dcat.admin.articles.index');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the action request.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function handle(Request $request)
|
||||||
|
{
|
||||||
|
// return response()->streamDownload(function () {
|
||||||
|
// $writer = WriterEntityFactory::createXLSXWriter();
|
||||||
|
// $writer->openToBrowser('测试'.date('Ymd'));
|
||||||
|
|
||||||
|
// $writer->addRow(WriterEntityFactory::createRowFromArray([
|
||||||
|
// '订单编号', '商品编号', '商品名称', '数量', '姓名', '电话', '地址', '下单时间', '发货数量', '发货单号',
|
||||||
|
// ]));
|
||||||
|
// $writer->close();
|
||||||
|
// });
|
||||||
|
return $this->response()->download(admin_route('orders.export_shipping_orders'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Admin\Controllers;
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
use App\Admin\Actions\Grid\CreateOrderPackage;
|
use App\Admin\Actions\Grid\CreateOrderPackage;
|
||||||
|
use App\Admin\Actions\Grid\Exports\ShippingOrder as ExportShippingOrder;
|
||||||
use App\Admin\Actions\Grid\OrderSetTag;
|
use App\Admin\Actions\Grid\OrderSetTag;
|
||||||
use App\Admin\Actions\Show\OrderConsigneeInfo;
|
use App\Admin\Actions\Show\OrderConsigneeInfo;
|
||||||
use App\Admin\Actions\Show\OrderCreatePackage;
|
use App\Admin\Actions\Show\OrderCreatePackage;
|
||||||
|
|
@ -17,6 +18,7 @@ use App\Models\OrderLog;
|
||||||
use App\Models\OrderPackage;
|
use App\Models\OrderPackage;
|
||||||
use App\Models\OrderProduct;
|
use App\Models\OrderProduct;
|
||||||
use App\Models\Tag;
|
use App\Models\Tag;
|
||||||
|
use Box\Spout\Writer\Common\Creator\WriterEntityFactory;
|
||||||
use Dcat\Admin\Admin;
|
use Dcat\Admin\Admin;
|
||||||
use Dcat\Admin\Form;
|
use Dcat\Admin\Form;
|
||||||
use Dcat\Admin\Grid;
|
use Dcat\Admin\Grid;
|
||||||
|
|
@ -40,6 +42,12 @@ class OrderController extends AdminController
|
||||||
|
|
||||||
return Grid::make($builder, function (Grid $grid) {
|
return Grid::make($builder, function (Grid $grid) {
|
||||||
// $grid->column('id')->sortable();
|
// $grid->column('id')->sortable();
|
||||||
|
$grid->tools(function (Grid\Tools $tools) {
|
||||||
|
//设置规格
|
||||||
|
if (Admin::user()->can('dcat.admin.orders.export_shipping_orders')) {
|
||||||
|
$tools->append(new ExportShippingOrder());
|
||||||
|
}
|
||||||
|
});
|
||||||
$grid->column('sn')->copyable();
|
$grid->column('sn')->copyable();
|
||||||
$grid->column('tags', '标签')->display(function ($tags) {
|
$grid->column('tags', '标签')->display(function ($tags) {
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|
@ -382,4 +390,33 @@ class OrderController extends AdminController
|
||||||
|
|
||||||
return response()->json($query->get());
|
return response()->json($query->get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exportShippingOrder(Request $request)
|
||||||
|
{
|
||||||
|
return response()->streamDownload(function () {
|
||||||
|
$writer = WriterEntityFactory::createXLSXWriter();
|
||||||
|
$writer->openToBrowser('测试'.date('Ymd').'.xlsx');
|
||||||
|
|
||||||
|
$writer->addRow(WriterEntityFactory::createRowFromArray([
|
||||||
|
'订单编号', '商品编号', '商品名称', '数量', '姓名', '电话', '地址', '下单时间', '发货数量', '发货单号',
|
||||||
|
]));
|
||||||
|
foreach (OrderModel::with('products')->needShipping()->cursor() as $order) {
|
||||||
|
foreach ($order->products as $product) {
|
||||||
|
if ($product->remain_quantity > 0) {
|
||||||
|
$writer->addRow(WriterEntityFactory::createRowFromArray([
|
||||||
|
$order->sn,
|
||||||
|
$product->sku_id,
|
||||||
|
$product->name.'数量:'.$product->remain_quantity,
|
||||||
|
$product->remain_quantity,
|
||||||
|
$order->consignee_name,
|
||||||
|
$order->consignee_telephone,
|
||||||
|
$order->consignee_zone.$order->consignee_address,
|
||||||
|
$order->created_at->toDateTimeString(),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$writer->close();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@ class AfterSaleShippingFill extends Form implements LazyRenderable
|
||||||
'EMS'=>'EMS',
|
'EMS'=>'EMS',
|
||||||
'顺丰速运'=>'顺丰速运',
|
'顺丰速运'=>'顺丰速运',
|
||||||
'德邦快递'=>'德邦快递',
|
'德邦快递'=>'德邦快递',
|
||||||
])->required();
|
])->default('韵达快递')->required();
|
||||||
$this->text('shipping_number', '快递单号')->required();
|
$this->text('shipping_number', '快递单号')->required();
|
||||||
// $this->text('remarks', '填写补货物流单号')->required();
|
// $this->text('remarks', '填写补货物流单号')->required();
|
||||||
$this->confirm('是否确认补货完成', '该操作不可逆,确认后将完成该售后单。');
|
$this->confirm('是否确认补货完成', '该操作不可逆,确认后将完成该售后单。');
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class OrderPackage extends Form implements LazyRenderable
|
||||||
'EMS'=>'EMS',
|
'EMS'=>'EMS',
|
||||||
'顺丰速运'=>'顺丰速运',
|
'顺丰速运'=>'顺丰速运',
|
||||||
'德邦快递'=>'德邦快递',
|
'德邦快递'=>'德邦快递',
|
||||||
])->required();
|
])->default('韵达快递')->required();
|
||||||
$this->text('shipping_number')->required();
|
$this->text('shipping_number')->required();
|
||||||
$this->hasMany('packages', function (Form $form) use ($order) {
|
$this->hasMany('packages', function (Form $form) use ($order) {
|
||||||
$form->select('order_product_id')->options($order->products()->where('after_sale_state', '<>', 1)->pluck('name', 'id'));
|
$form->select('order_product_id')->options($order->products()->where('after_sale_state', '<>', 1)->pluck('name', 'id'));
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ Route::group([
|
||||||
'index', 'create', 'store', 'edit', 'update', 'destroy',
|
'index', 'create', 'store', 'edit', 'update', 'destroy',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$router->get('orders/export/shipping-order', 'OrderController@exportShippingOrder')->name('orders.export_shipping_orders');
|
||||||
$router->resource('orders', 'OrderController')->only([
|
$router->resource('orders', 'OrderController')->only([
|
||||||
'index', 'show', 'edit', 'update',
|
'index', 'show', 'edit', 'update',
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
|
|
@ -42,19 +42,22 @@ class QuotaV1SendCommand extends Command
|
||||||
//依次分红
|
//依次分红
|
||||||
foreach ($userInfos as $userInfo) {
|
foreach ($userInfos as $userInfo) {
|
||||||
if ($userInfo->bonusable) {//只针对享受分红的人发放
|
if ($userInfo->bonusable) {//只针对享受分红的人发放
|
||||||
$log = new QuotaV1SendLog();
|
$quotaV1amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3));
|
||||||
$log->user_id = $userInfo->user_id;
|
if ($quotaV1amount >0) {
|
||||||
$log->job_id = $job->id;
|
$log = new QuotaV1SendLog();
|
||||||
$log->amount = round(bcmul(bcdiv($job->amount, $totalQuotaV1, 5), $userInfo->quota_v1, 3));
|
$log->user_id = $userInfo->user_id;
|
||||||
$log->save();
|
$log->job_id = $job->id;
|
||||||
try {
|
$log->amount = $quotaV1amount;
|
||||||
DB::beginTransaction();
|
$log->save();
|
||||||
$log->update(['status'=>1]);
|
try {
|
||||||
$walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log);
|
DB::beginTransaction();
|
||||||
DB::commit();
|
$log->update(['status'=>1]);
|
||||||
} catch (Throwable $th) {
|
$walletService->changeBalance($userInfo->user, $log->amount, WalletLog::ACTION_QUOTA_V1, '老配额分红', $log);
|
||||||
DB::rollBack();
|
DB::commit();
|
||||||
report($th);
|
} catch (Throwable $th) {
|
||||||
|
DB::rollBack();
|
||||||
|
report($th);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ class CouponRange extends Model
|
||||||
/**
|
/**
|
||||||
* 仅查询可用的券规则
|
* 仅查询可用的券规则
|
||||||
*/
|
*/
|
||||||
public function scopeIsEnable()
|
public function scopeIsEnable($query)
|
||||||
{
|
{
|
||||||
return $this->where('is_enable', true);
|
return $query->where('is_enable', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function coupon()
|
public function coupon()
|
||||||
|
|
|
||||||
|
|
@ -100,18 +100,18 @@ class Order extends Model
|
||||||
/**
|
/**
|
||||||
* 仅查询支付过期的订单
|
* 仅查询支付过期的订单
|
||||||
*/
|
*/
|
||||||
public function scopeExpired()
|
public function scopeExpired($query)
|
||||||
{
|
{
|
||||||
return $this->where('status', static::STATUS_PENDING)
|
return $query->where('status', static::STATUS_PENDING)
|
||||||
->where('created_at', '<=', now()->subSeconds(app_settings('app.order_payment_expires_at')));
|
->where('created_at', '<=', now()->subSeconds(app_settings('app.order_payment_expires_at')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅查询可自动完成的订单
|
* 仅查询可自动完成的订单
|
||||||
*/
|
*/
|
||||||
public function scopeCompletable()
|
public function scopeCompletable($query)
|
||||||
{
|
{
|
||||||
return $this->where('status', static::STATUS_PAID)
|
return $query->where('status', static::STATUS_PAID)
|
||||||
->where('shipping_state', static::SHIPPING_STATE_PROCESSED)
|
->where('shipping_state', static::SHIPPING_STATE_PROCESSED)
|
||||||
->where('auto_complete_at', '<=', now());
|
->where('auto_complete_at', '<=', now());
|
||||||
}
|
}
|
||||||
|
|
@ -119,13 +119,22 @@ class Order extends Model
|
||||||
/**
|
/**
|
||||||
* 仅查询可结算的订单
|
* 仅查询可结算的订单
|
||||||
*/
|
*/
|
||||||
public function scopeSettlable()
|
public function scopeSettlable($query)
|
||||||
{
|
{
|
||||||
return $this->where('status', static::STATUS_COMPLETED)
|
return $query->where('status', static::STATUS_COMPLETED)
|
||||||
->where('completed_at', '<=', now()->subDays(app_settings('distribution.settle_days', 7)))
|
->where('completed_at', '<=', now()->subDays(app_settings('distribution.settle_days', 7)))
|
||||||
->where('is_settle', false);
|
->where('is_settle', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅查询待发货的订单
|
||||||
|
*/
|
||||||
|
public function scopeNeedShipping($query)
|
||||||
|
{
|
||||||
|
return $query->where('status', static::STATUS_PAID)
|
||||||
|
->where('shipping_state', '<', static::SHIPPING_STATE_PROCESSED);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下单人
|
* 下单人
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -34,18 +34,18 @@ class Tag extends Model
|
||||||
// return $this->morphedByMany(OrderPackage::class, 'taggable');
|
// return $this->morphedByMany(OrderPackage::class, 'taggable');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public function scopeOrderTag()
|
public function scopeOrderTag($query)
|
||||||
{
|
{
|
||||||
return $this->where('type', self::TYPE_ORDER);
|
return $query->where('type', self::TYPE_ORDER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeOrderPackageTag()
|
public function scopeOrderPackageTag($query)
|
||||||
{
|
{
|
||||||
return $this->where('type', self::TYPE_PACKAGE);
|
return $query->where('type', self::TYPE_PACKAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scopeAfterSaleTag()
|
public function scopeAfterSaleTag($query)
|
||||||
{
|
{
|
||||||
return $this->where('type', self::TYPE_AFTER_SALE);
|
return $query->where('type', self::TYPE_AFTER_SALE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
"alibabacloud/sts": "^1.8",
|
"alibabacloud/sts": "^1.8",
|
||||||
"alipaysdk/easysdk": "^2.2",
|
"alipaysdk/easysdk": "^2.2",
|
||||||
"alphasnow/aliyun-oss-laravel": "^3.0",
|
"alphasnow/aliyun-oss-laravel": "^3.0",
|
||||||
|
"box/spout": "^3.3",
|
||||||
"dcat/laravel-admin": "2.1.5-beta",
|
"dcat/laravel-admin": "2.1.5-beta",
|
||||||
"fruitcake/laravel-cors": "^2.0",
|
"fruitcake/laravel-cors": "^2.0",
|
||||||
"gregwar/captcha": "^1.1",
|
"gregwar/captcha": "^1.1",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "e29674f9d20d1f4352e096af590c340b",
|
"content-hash": "a1bf80b8df4152dc433261263b5aa05f",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "adbario/php-dot-notation",
|
"name": "adbario/php-dot-notation",
|
||||||
|
|
@ -705,6 +705,86 @@
|
||||||
},
|
},
|
||||||
"time": "2021-06-18T13:26:35+00:00"
|
"time": "2021-06-18T13:26:35+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "box/spout",
|
||||||
|
"version": "v3.3.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/box/spout.git",
|
||||||
|
"reference": "9bdb027d312b732515b884a341c0ad70372c6295"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/box/spout/zipball/9bdb027d312b732515b884a341c0ad70372c6295",
|
||||||
|
"reference": "9bdb027d312b732515b884a341c0ad70372c6295",
|
||||||
|
"shasum": "",
|
||||||
|
"mirrors": [
|
||||||
|
{
|
||||||
|
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
|
||||||
|
"preferred": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"ext-dom": "*",
|
||||||
|
"ext-xmlreader": "*",
|
||||||
|
"ext-zip": "*",
|
||||||
|
"php": ">=7.2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^2",
|
||||||
|
"phpunit/phpunit": "^8"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-iconv": "To handle non UTF-8 CSV files (if \"php-intl\" is not already installed or is too limited)",
|
||||||
|
"ext-intl": "To handle non UTF-8 CSV files (if \"iconv\" is not already installed)"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.1.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Box\\Spout\\": "src/Spout"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"Apache-2.0"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Adrien Loison",
|
||||||
|
"email": "adrien@box.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way",
|
||||||
|
"homepage": "https://www.github.com/box/spout",
|
||||||
|
"keywords": [
|
||||||
|
"OOXML",
|
||||||
|
"csv",
|
||||||
|
"excel",
|
||||||
|
"memory",
|
||||||
|
"odf",
|
||||||
|
"ods",
|
||||||
|
"office",
|
||||||
|
"open",
|
||||||
|
"php",
|
||||||
|
"read",
|
||||||
|
"scale",
|
||||||
|
"spreadsheet",
|
||||||
|
"stream",
|
||||||
|
"write",
|
||||||
|
"xlsx"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/box/spout/issues",
|
||||||
|
"source": "https://github.com/box/spout/tree/v3.3.0"
|
||||||
|
},
|
||||||
|
"time": "2021-05-14T21:18:09+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "brick/math",
|
"name": "brick/math",
|
||||||
"version": "0.9.3",
|
"version": "0.9.3",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue