添加作废货运单
parent
b7baaa2d79
commit
8b49e0d263
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Actions\Grid;
|
namespace App\Admin\Actions\Grid;
|
||||||
|
|
||||||
use App\Admin\Services\AdminSendCouponService;
|
use App\Admin\Services\SendCouponService;
|
||||||
use Dcat\Admin\Actions\Response;
|
use Dcat\Admin\Actions\Response;
|
||||||
use Dcat\Admin\Grid\RowAction;
|
use Dcat\Admin\Grid\RowAction;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -46,8 +46,8 @@ class CouponTaskStart extends RowAction
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$adminSendCouponService = new AdminSendCouponService();
|
$SendCouponService = new SendCouponService();
|
||||||
$adminSendCouponService->startTaskById($this->getKey());
|
$SendCouponService->startTaskById($this->getKey());
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Actions\Grid;
|
namespace App\Admin\Actions\Grid;
|
||||||
|
|
||||||
|
use App\Admin\Services\OrderPackageService;
|
||||||
use App\Models\OrderPackage;
|
use App\Models\OrderPackage;
|
||||||
use Dcat\Admin\Grid\RowAction;
|
use Dcat\Admin\Grid\RowAction;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
@ -46,7 +47,8 @@ class OrderPackageFailed extends RowAction
|
||||||
$package = OrderPackage::findOrFail($this->getKey());
|
$package = OrderPackage::findOrFail($this->getKey());
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$user->enable();
|
$packageService = new OrderPackageService();
|
||||||
|
$packageService->failPackage($package);
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Actions\Show;
|
namespace App\Admin\Actions\Show;
|
||||||
|
|
||||||
use App\Admin\Services\AdminOrderService;
|
use App\Admin\Services\OrderService;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Dcat\Admin\Show\AbstractTool;
|
use Dcat\Admin\Show\AbstractTool;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Illuminate\Contracts\Auth\Authenticatable;
|
||||||
|
|
@ -48,7 +48,7 @@ class OrderPay extends AbstractTool
|
||||||
// 获取主键
|
// 获取主键
|
||||||
$key = $this->getKey();
|
$key = $this->getKey();
|
||||||
|
|
||||||
$orderService = new AdminOrderService();
|
$orderService = new OrderService();
|
||||||
$order = Order::where('status', Order::STATUS_PENDING)->findOrFail($key);
|
$order = Order::where('status', Order::STATUS_PENDING)->findOrFail($key);
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Controllers;
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Admin\Actions\Grid\OrderPackageFailed;
|
||||||
use App\Admin\Renderable\PackageProductSimpleTable;
|
use App\Admin\Renderable\PackageProductSimpleTable;
|
||||||
use App\Admin\Repositories\OrderPackage;
|
use App\Admin\Repositories\OrderPackage;
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
|
|
@ -29,15 +30,21 @@ class OrderPackageController extends AdminController
|
||||||
$grid->column('order.sn');
|
$grid->column('order.sn');
|
||||||
$grid->column('order.consignee_name');
|
$grid->column('order.consignee_name');
|
||||||
$grid->column('order.consignee_telephone');
|
$grid->column('order.consignee_telephone');
|
||||||
$grid->column('order.consignee_zone');
|
$grid->column('address', '收货地址')->display(function () {
|
||||||
$grid->column('order.consignee_address');
|
return $this->order->consignee_zone.$this->order->consignee_address;
|
||||||
|
});
|
||||||
|
// $grid->column('order.consignee_zone');
|
||||||
|
// $grid->column('order.consignee_address');
|
||||||
$grid->column('packageProduct')->display('包裹商品')->modal(function ($modal) {
|
$grid->column('packageProduct')->display('包裹商品')->modal(function ($modal) {
|
||||||
$modal->title('商品');
|
$modal->title('商品');
|
||||||
return PackageProductSimpleTable::make(['id'=>$this->id]);
|
return PackageProductSimpleTable::make(['id'=>$this->id]);
|
||||||
})->setHeaderAttributes(['style' => 'color:#5b69bc']);
|
})->setHeaderAttributes(['style' => 'color:#5b69bc']);
|
||||||
$grid->column('shipping_company');
|
$grid->column('shipping_company');
|
||||||
$grid->column('shipping_number');
|
$grid->column('shipping_number');
|
||||||
$grid->column('is_failed')->bool();
|
$grid->column('is_failed', '正常')->bool([
|
||||||
|
0=>true,
|
||||||
|
1=>false,
|
||||||
|
]);
|
||||||
$grid->column('status')->using([
|
$grid->column('status')->using([
|
||||||
OrderPackageModel::STATUS_WAIT => '揽收',
|
OrderPackageModel::STATUS_WAIT => '揽收',
|
||||||
OrderPackageModel::STATUS_ONTHEWAY =>'途中',
|
OrderPackageModel::STATUS_ONTHEWAY =>'途中',
|
||||||
|
|
@ -73,6 +80,9 @@ class OrderPackageController extends AdminController
|
||||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||||
$actions->disableDelete(Admin::user()->cannot('dcat.admin.order_packages.destroy'));
|
$actions->disableDelete(Admin::user()->cannot('dcat.admin.order_packages.destroy'));
|
||||||
$actions->disableQuickEdit(Admin::user()->cannot('dcat.admin.order_packages.edit'));
|
$actions->disableQuickEdit(Admin::user()->cannot('dcat.admin.order_packages.edit'));
|
||||||
|
if (!in_array($actions->row->status, [OrderPackageModel::STATUS_CHECK, OrderPackageModel::STATUS_AUTOCHECK])) {
|
||||||
|
$actions->append(new OrderPackageFailed());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 查询 **/
|
/** 查询 **/
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Forms;
|
namespace App\Admin\Forms;
|
||||||
|
|
||||||
use App\Admin\Services\AdminOrderService;
|
use App\Admin\Services\OrderService;
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Dcat\Admin\Contracts\LazyRenderable;
|
use Dcat\Admin\Contracts\LazyRenderable;
|
||||||
|
|
@ -38,7 +38,7 @@ class OrderConsigneeInfo extends Form implements LazyRenderable
|
||||||
{
|
{
|
||||||
$orderId = $this->payload['id'] ?? 0;
|
$orderId = $this->payload['id'] ?? 0;
|
||||||
$order = Order::findOrFail($orderId);
|
$order = Order::findOrFail($orderId);
|
||||||
$orderService = new AdminOrderService();
|
$orderService = new OrderService();
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$orderService->adminEditConsignee($order, $input);
|
$orderService->adminEditConsignee($order, $input);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Forms;
|
namespace App\Admin\Forms;
|
||||||
|
|
||||||
use App\Admin\Services\AdminOrderService;
|
use App\Admin\Services\OrderPackageService;
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Dcat\Admin\Contracts\LazyRenderable;
|
use Dcat\Admin\Contracts\LazyRenderable;
|
||||||
|
|
@ -41,8 +41,8 @@ class OrderPackage extends Form implements LazyRenderable
|
||||||
$order = Order::findOrFail($orderId);
|
$order = Order::findOrFail($orderId);
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$orderService = new AdminOrderService();
|
$orderPackageService = new OrderPackageService();
|
||||||
$orderService->createPackage($order, $input);
|
$orderPackageService->createPackage($order, $input);
|
||||||
DB::commit();
|
DB::commit();
|
||||||
} catch (BizException $e) {
|
} catch (BizException $e) {
|
||||||
DB::rollBack();
|
DB::rollBack();
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Forms;
|
namespace App\Admin\Forms;
|
||||||
|
|
||||||
use App\Admin\Services\AdminOrderService;
|
use App\Admin\Services\OrderService;
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Dcat\Admin\Admin;
|
use Dcat\Admin\Admin;
|
||||||
|
|
@ -47,7 +47,7 @@ class OrderReduce extends Form implements LazyRenderable
|
||||||
if ($reduceAmount == $order->total_amount) {
|
if ($reduceAmount == $order->total_amount) {
|
||||||
throw new BizException('调整价格和订单原价格一致,无需调整');
|
throw new BizException('调整价格和订单原价格一致,无需调整');
|
||||||
}
|
}
|
||||||
$orderService = new AdminOrderService();
|
$orderService = new OrderService();
|
||||||
|
|
||||||
$reduced = $order->total_amount-$reduceAmount;
|
$reduced = $order->total_amount-$reduceAmount;
|
||||||
//判断是否在当前操作人调价权限范围内
|
//判断是否在当前操作人调价权限范围内
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Admin\Forms;
|
namespace App\Admin\Forms;
|
||||||
|
|
||||||
use App\Admin\Services\AdminOrderService;
|
use App\Admin\Services\OrderService;
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use Dcat\Admin\Contracts\LazyRenderable;
|
use Dcat\Admin\Contracts\LazyRenderable;
|
||||||
|
|
@ -40,7 +40,7 @@ class OrderRemark extends Form implements LazyRenderable
|
||||||
$order = Order::findOrFail($orderId);
|
$order = Order::findOrFail($orderId);
|
||||||
|
|
||||||
$remark = $input['remark']??'';
|
$remark = $input['remark']??'';
|
||||||
$orderService = new AdminOrderService();
|
$orderService = new OrderService();
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
$orderService->adminRemark($order, $remark);
|
$orderService->adminRemark($order, $remark);
|
||||||
|
|
|
||||||
|
|
@ -4,95 +4,14 @@ namespace App\Admin\Services;
|
||||||
|
|
||||||
use App\Exceptions\BizException;
|
use App\Exceptions\BizException;
|
||||||
use App\Models\Order;
|
use App\Models\Order;
|
||||||
use App\Models\OrderLog;
|
|
||||||
use App\Models\OrderPackage;
|
use App\Models\OrderPackage;
|
||||||
use App\Models\OrderPackageProduct;
|
use App\Models\OrderPackageProduct;
|
||||||
use App\Models\OrderProduct;
|
use App\Models\OrderProduct;
|
||||||
use App\Services\Kuaidi100Service;
|
use App\Services\Kuaidi100Service;
|
||||||
use Illuminate\Support\Arr;
|
use Illuminate\Support\Arr;
|
||||||
|
|
||||||
class AdminOrderService
|
class OrderPackageService
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 订单调整价格
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function adminReduceOrder(Order $order, int $reduceAmount)
|
|
||||||
{
|
|
||||||
if ($order->isPending()) {
|
|
||||||
$res = $order->where('updated_at', $order->updated_at)->update([
|
|
||||||
'reduced_amount' => $order->total_amount - $reduceAmount + $order->reduced_amount,
|
|
||||||
'total_amount' => $reduceAmount,
|
|
||||||
]);
|
|
||||||
if ($res === 0) {
|
|
||||||
throw new BizException('订单已发生改变');
|
|
||||||
}
|
|
||||||
OrderLog::create([
|
|
||||||
'order_id'=>$order->id,
|
|
||||||
'content'=> '调整订单支付价格为:¥'.bcdiv($reduceAmount, 100, 2),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 后台支付订单
|
|
||||||
*
|
|
||||||
* @param Order $order
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function adminPay(Order $order)
|
|
||||||
{
|
|
||||||
if ($order->isPending()) {
|
|
||||||
//操作订单状态-需要调整为统一支付方法
|
|
||||||
$order->update([
|
|
||||||
'status' => Order::STATUS_PAID,
|
|
||||||
]);
|
|
||||||
|
|
||||||
OrderLog::create([
|
|
||||||
'order_id'=>$order->id,
|
|
||||||
'content'=> '改变订单状态为【已支付】',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加后台备注
|
|
||||||
*
|
|
||||||
* @param Order $order
|
|
||||||
* @param string $remark
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function adminRemark(Order $order, string $remark)
|
|
||||||
{
|
|
||||||
//操作订单状态-需要调整为统一支付方法
|
|
||||||
$order->update([
|
|
||||||
'remark' => $remark,
|
|
||||||
]);
|
|
||||||
|
|
||||||
OrderLog::create([
|
|
||||||
'order_id'=>$order->id,
|
|
||||||
'content'=> '修改订单备注:'.$remark,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改订单收货信息
|
|
||||||
*
|
|
||||||
* @param Order $order
|
|
||||||
* @param array $params
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function adminEditConsignee(Order $order, array $params)
|
|
||||||
{
|
|
||||||
$oldOrderConsignee = $order->consignee_name.','.$order->consignee_telephone.','.$order->consignee_zone.$order->consignee_address;
|
|
||||||
$order->update($params);
|
|
||||||
OrderLog::create([
|
|
||||||
'order_id'=>$order->id,
|
|
||||||
'content'=> '修改订单收货信息<br\>原收货信息:'.$oldOrderConsignee,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建订单发货单
|
* 创建订单发货单
|
||||||
*
|
*
|
||||||
|
|
@ -102,6 +21,10 @@ class AdminOrderService
|
||||||
{
|
{
|
||||||
//合并同样商品,并检验是否能发货
|
//合并同样商品,并检验是否能发货
|
||||||
$packageProducts = [];
|
$packageProducts = [];
|
||||||
|
//待发货,发货中的可以发货
|
||||||
|
if (!($order->isWaitShipping() || $order->isShipping())) {
|
||||||
|
throw new BizException('订单状态异常,无法发货');
|
||||||
|
}
|
||||||
if (count($params['packages']) <= 0) {
|
if (count($params['packages']) <= 0) {
|
||||||
throw new BizException('请选择发货商品');
|
throw new BizException('请选择发货商品');
|
||||||
}
|
}
|
||||||
|
|
@ -166,4 +89,39 @@ class AdminOrderService
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作废发货单
|
||||||
|
*
|
||||||
|
* @param OrderPackage $package
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function failPackage(OrderPackage $package)
|
||||||
|
{
|
||||||
|
//如果订单完成了,不能作废货运单
|
||||||
|
if ($package->order->isCompleted()) {
|
||||||
|
throw new BizException('订单已完成,无法作废该货运单');
|
||||||
|
}
|
||||||
|
|
||||||
|
$changeQuantity = [];
|
||||||
|
foreach ($package->packageProducts as $packageProduct) {
|
||||||
|
if (isset($changeQuantity[$packageProduct->order_product_id])) {
|
||||||
|
$changeQuantity[$packageProduct->order_product_id] += $packageProduct->quantity;
|
||||||
|
} else {
|
||||||
|
$changeQuantity[$packageProduct->order_product_id] = $packageProduct->quantity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//作废货运单,恢复订单商品发货数量
|
||||||
|
foreach ($package->orderProducts as $orderProduct) {
|
||||||
|
$orderProduct->increment('remain_quantity', $changeQuantity[$orderProduct->id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新订单状态:如果发货完成,则恢复为发货中
|
||||||
|
if ($package->order->isShipped()) {
|
||||||
|
$package->order()->update([
|
||||||
|
'shipping_state'=>Order::SHIPPING_STATE_PROCESSING,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,90 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Services;
|
||||||
|
|
||||||
|
use App\Exceptions\BizException;
|
||||||
|
use App\Models\Order;
|
||||||
|
use App\Models\OrderLog;
|
||||||
|
|
||||||
|
class OrderService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 订单调整价格
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function adminReduceOrder(Order $order, int $reduceAmount)
|
||||||
|
{
|
||||||
|
if ($order->isPending()) {
|
||||||
|
$res = $order->where('updated_at', $order->updated_at)->update([
|
||||||
|
'reduced_amount' => $order->total_amount - $reduceAmount + $order->reduced_amount,
|
||||||
|
'total_amount' => $reduceAmount,
|
||||||
|
]);
|
||||||
|
if ($res === 0) {
|
||||||
|
throw new BizException('订单已发生改变');
|
||||||
|
}
|
||||||
|
OrderLog::create([
|
||||||
|
'order_id'=>$order->id,
|
||||||
|
'content'=> '调整订单支付价格为:¥'.bcdiv($reduceAmount, 100, 2),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 后台支付订单
|
||||||
|
*
|
||||||
|
* @param Order $order
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function adminPay(Order $order)
|
||||||
|
{
|
||||||
|
if ($order->isPending()) {
|
||||||
|
//操作订单状态-需要调整为统一支付方法
|
||||||
|
$order->update([
|
||||||
|
'status' => Order::STATUS_PAID,
|
||||||
|
]);
|
||||||
|
|
||||||
|
OrderLog::create([
|
||||||
|
'order_id'=>$order->id,
|
||||||
|
'content'=> '改变订单状态为【已支付】',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加后台备注
|
||||||
|
*
|
||||||
|
* @param Order $order
|
||||||
|
* @param string $remark
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function adminRemark(Order $order, string $remark)
|
||||||
|
{
|
||||||
|
//操作订单状态-需要调整为统一支付方法
|
||||||
|
$order->update([
|
||||||
|
'remark' => $remark,
|
||||||
|
]);
|
||||||
|
|
||||||
|
OrderLog::create([
|
||||||
|
'order_id'=>$order->id,
|
||||||
|
'content'=> '修改订单备注:'.$remark,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改订单收货信息
|
||||||
|
*
|
||||||
|
* @param Order $order
|
||||||
|
* @param array $params
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function adminEditConsignee(Order $order, array $params)
|
||||||
|
{
|
||||||
|
$oldOrderConsignee = $order->consignee_name.','.$order->consignee_telephone.','.$order->consignee_zone.$order->consignee_address;
|
||||||
|
$order->update($params);
|
||||||
|
OrderLog::create([
|
||||||
|
'order_id'=>$order->id,
|
||||||
|
'content'=> '修改订单收货信息<br\>原收货信息:'.$oldOrderConsignee,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ namespace App\Admin\Services;
|
||||||
use App\Models\CouponSendTask;
|
use App\Models\CouponSendTask;
|
||||||
use App\Models\CouponTaskLog;
|
use App\Models\CouponTaskLog;
|
||||||
|
|
||||||
class AdminSendCouponService
|
class SendCouponService
|
||||||
{
|
{
|
||||||
public function startTaskById(int $id)
|
public function startTaskById(int $id)
|
||||||
{
|
{
|
||||||
|
|
@ -49,14 +49,35 @@ class OrderProduct extends Model
|
||||||
return $this->hasMany(AfterSale::class, 'order_product_id');
|
return $this->hasMany(AfterSale::class, 'order_product_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关联的订单包裹
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function packages()
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(OrderPackage::class, 'order_package_products', 'order_product_id', 'order_package_id');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取订单商品是否能发起售后
|
* 获取订单商品是否能发起售后
|
||||||
*
|
*
|
||||||
* @return void
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getCanAfterSaleAttribute()
|
public function getCanAfterSaleAttribute(): bool
|
||||||
{
|
{
|
||||||
return !is_null($this->after_expire_at) && $this->after_expire_at < now() && $this->after_sale_state == 0;
|
$res = false;
|
||||||
|
|
||||||
|
//老判断,有过期时间,且未到过期时间,未发起过售后
|
||||||
|
// $oldJudge = !is_null($this->after_expire_at) && $this->after_expire_at < now() && $this->after_sale_state == 0;
|
||||||
|
|
||||||
|
//新判断, 有发货单,有过期期时间需要判断未过到过期时间, 未发起过售后;
|
||||||
|
if ($this->packages()->where('is_failed', false)->count() >0) {
|
||||||
|
if ((is_null($this->after_expire_at) || $this->after_expire_at < now()) && $this->after_sale_state == 0) {
|
||||||
|
$res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue