调整售后补货流程
parent
5ba6a166ae
commit
f0be8a6174
|
|
@ -2,13 +2,9 @@
|
||||||
|
|
||||||
namespace App\Admin\Actions\Show;
|
namespace App\Admin\Actions\Show;
|
||||||
|
|
||||||
use App\Models\AfterSale;
|
use App\Admin\Forms\AfterSaleShippingFail as AfterSaleShippingFailForm;
|
||||||
use App\Services\AfterSaleService;
|
|
||||||
use Dcat\Admin\Show\AbstractTool;
|
use Dcat\Admin\Show\AbstractTool;
|
||||||
use Illuminate\Contracts\Auth\Authenticatable;
|
use Dcat\Admin\Widgets\Modal;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Throwable;
|
|
||||||
|
|
||||||
class AfterSaleShippingFail extends AbstractTool
|
class AfterSaleShippingFail extends AbstractTool
|
||||||
{
|
{
|
||||||
|
|
@ -24,59 +20,13 @@ class AfterSaleShippingFail extends AbstractTool
|
||||||
*/
|
*/
|
||||||
protected $style = 'btn btn-sm btn-danger';
|
protected $style = 'btn btn-sm btn-danger';
|
||||||
|
|
||||||
/**
|
public function render()
|
||||||
* 权限判断,如不需要可以删除此方法
|
|
||||||
*
|
|
||||||
* @param Model|Authenticatable|HasPermissions|null $user
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
protected function authorize($user): bool
|
|
||||||
{
|
{
|
||||||
return $user->can('dcat.admin.after_sales.shipping');
|
$form = AfterSaleShippingFailForm::make()->payload(['id'=>$this->getKey()]);
|
||||||
}
|
return Modal::make()
|
||||||
|
->lg()
|
||||||
/**
|
->title($this->title)
|
||||||
* 处理请求,如果不需要接口处理,请直接删除这个方法
|
->body($form)
|
||||||
*
|
->button("<a href=\"javascript:void(0)\" class=\"btn btn-sm {$this->style}\">{$this->title}</a> ");
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @return Response
|
|
||||||
*/
|
|
||||||
public function handle(Request $request)
|
|
||||||
{
|
|
||||||
// 获取主键
|
|
||||||
$key = $this->getKey();
|
|
||||||
|
|
||||||
$afterSaleService = new AfterSaleService();
|
|
||||||
try {
|
|
||||||
DB::beginTransaction();
|
|
||||||
$afterSale = AfterSale::where('state', AfterSale::STATE_SHIPPING)->findOrFail($key);
|
|
||||||
$afterSaleService->shippingFail($afterSale);
|
|
||||||
DB::commit();
|
|
||||||
} catch (Throwable $th) {
|
|
||||||
DB::rollBack();
|
|
||||||
report($th);
|
|
||||||
return $this->response()->error('操作失败:'.$th->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->response()
|
|
||||||
->success(__('admin.update_succeeded'))
|
|
||||||
->refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function html()
|
|
||||||
{
|
|
||||||
return parent::html().' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确认弹窗信息,如不需要可以删除此方法
|
|
||||||
*
|
|
||||||
* @return string|array|void
|
|
||||||
*/
|
|
||||||
public function confirm()
|
|
||||||
{
|
|
||||||
return ['是否拒绝收货?', '该操作不可逆,确认后将退回客服审核。'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Actions\Show;
|
||||||
|
|
||||||
|
use App\Admin\Forms\AfterSaleShippingFill as AfterSaleShippingFillForm;
|
||||||
|
use Dcat\Admin\Show\AbstractTool;
|
||||||
|
use Dcat\Admin\Widgets\Modal;
|
||||||
|
|
||||||
|
class AfterSaleShippingFill extends AbstractTool
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected $title = '<i class="fa fa-exclamation-triangle icon-shuffle"></i> 确认补货';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按钮样式定义,默认 btn btn-white waves-effect
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $style = 'btn btn-sm btn-success';
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
$form = AfterSaleShippingFillForm::make()->payload(['id'=>$this->getKey()]);
|
||||||
|
return Modal::make()
|
||||||
|
->lg()
|
||||||
|
->title($this->title)
|
||||||
|
->body($form)
|
||||||
|
->button("<a href=\"javascript:void(0)\" class=\"btn btn-sm {$this->style}\">{$this->title}</a> ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,7 @@ use App\Admin\Actions\Show\AfterSaleFinance;
|
||||||
use App\Admin\Actions\Show\AfterSaleFinanceShipping;
|
use App\Admin\Actions\Show\AfterSaleFinanceShipping;
|
||||||
use App\Admin\Actions\Show\AfterSaleShipping;
|
use App\Admin\Actions\Show\AfterSaleShipping;
|
||||||
use App\Admin\Actions\Show\AfterSaleShippingFail;
|
use App\Admin\Actions\Show\AfterSaleShippingFail;
|
||||||
|
use App\Admin\Actions\Show\AfterSaleShippingFill;
|
||||||
use App\Admin\Actions\Show\AfterSaleVerify;
|
use App\Admin\Actions\Show\AfterSaleVerify;
|
||||||
use App\Admin\Repositories\AfterSale;
|
use App\Admin\Repositories\AfterSale;
|
||||||
use App\Models\AfterSale as AfterSaleModel;
|
use App\Models\AfterSale as AfterSaleModel;
|
||||||
|
|
@ -105,6 +106,7 @@ class AfterSaleController extends AdminController
|
||||||
$show->field('id');
|
$show->field('id');
|
||||||
$show->field('sn');
|
$show->field('sn');
|
||||||
$show->field('order.sn');
|
$show->field('order.sn');
|
||||||
|
$show->field('user.phone');
|
||||||
$show->field('order_product.name');
|
$show->field('order_product.name');
|
||||||
$show->field('num');
|
$show->field('num');
|
||||||
if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND])) {
|
if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND])) {
|
||||||
|
|
@ -151,8 +153,13 @@ class AfterSaleController extends AdminController
|
||||||
if ($show->model()->state == AfterSaleModel::STATE_SHIPPING) {
|
if ($show->model()->state == AfterSaleModel::STATE_SHIPPING) {
|
||||||
//拒绝确认收货
|
//拒绝确认收货
|
||||||
$tools->append(new AfterSaleShippingFail());
|
$tools->append(new AfterSaleShippingFail());
|
||||||
//同意确认收货
|
if ($show->model()->type == AfterSaleModel::TYPE_FILL) {
|
||||||
$tools->append(new AfterSaleShipping());
|
//同意确认收货
|
||||||
|
$tools->append(new AfterSaleShippingFill());
|
||||||
|
} else {
|
||||||
|
//同意确认收货
|
||||||
|
$tools->append(new AfterSaleShipping());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($show->model()->state == AfterSaleModel::STATE_FINANCE) {
|
if ($show->model()->state == AfterSaleModel::STATE_FINANCE) {
|
||||||
if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND])) {
|
if (in_array($show->model()->type, [AfterSaleModel::TYPE_REFUND_AND_RETURN, AfterSaleModel::TYPE_REFUND])) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Forms;
|
||||||
|
|
||||||
|
use App\Models\AfterSale;
|
||||||
|
use App\Services\AfterSaleService;
|
||||||
|
use Dcat\Admin\Contracts\LazyRenderable;
|
||||||
|
use Dcat\Admin\Traits\LazyWidget;
|
||||||
|
use Dcat\Admin\Widgets\Form;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class AfterSaleShippingFail extends Form implements LazyRenderable
|
||||||
|
{
|
||||||
|
use LazyWidget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限判断,如不需要可以删除此方法
|
||||||
|
*
|
||||||
|
* @param Model|Authenticatable|HasPermissions|null $user
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function authorize($user): bool
|
||||||
|
{
|
||||||
|
return $user->can('dcat.admin.after_sales.shipping');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the form request.
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(array $input)
|
||||||
|
{
|
||||||
|
$afterSaleService = new AfterSaleService();
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
$afterSale = AfterSale::where('state', AfterSale::STATE_SHIPPING)->findOrFail($this->payload['id']);
|
||||||
|
$afterSaleService->shippingFail($afterSale, $input['remarks']);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
} catch (Throwable $th) {
|
||||||
|
DB::rollBack();
|
||||||
|
report($th);
|
||||||
|
return $this->response()->error('操作失败:'.$th->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response()
|
||||||
|
->success(__('admin.update_succeeded'))
|
||||||
|
->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a form here.
|
||||||
|
*/
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
$this->text('remarks', '备注')->required();
|
||||||
|
$this->confirm('是否拒绝通过?', '该操作不可逆,确认后将退回客服审核。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Forms;
|
||||||
|
|
||||||
|
use App\Models\AfterSale;
|
||||||
|
use App\Services\AfterSaleService;
|
||||||
|
use Dcat\Admin\Contracts\LazyRenderable;
|
||||||
|
use Dcat\Admin\Traits\LazyWidget;
|
||||||
|
use Dcat\Admin\Widgets\Form;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class AfterSaleShippingFill extends Form implements LazyRenderable
|
||||||
|
{
|
||||||
|
use LazyWidget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 权限判断,如不需要可以删除此方法
|
||||||
|
*
|
||||||
|
* @param Model|Authenticatable|HasPermissions|null $user
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function authorize($user): bool
|
||||||
|
{
|
||||||
|
return $user->can('dcat.admin.after_sales.shipping');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the form request.
|
||||||
|
*
|
||||||
|
* @param array $input
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function handle(array $input)
|
||||||
|
{
|
||||||
|
$afterSaleService = new AfterSaleService();
|
||||||
|
try {
|
||||||
|
DB::beginTransaction();
|
||||||
|
$afterSale = AfterSale::where('state', AfterSale::STATE_SHIPPING)->findOrFail($this->payload['id']);
|
||||||
|
$afterSaleService->shippingFill($afterSale, $input['remarks']);
|
||||||
|
|
||||||
|
DB::commit();
|
||||||
|
} catch (Throwable $th) {
|
||||||
|
DB::rollBack();
|
||||||
|
report($th);
|
||||||
|
return $this->response()->error('操作失败:'.$th->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->response()
|
||||||
|
->success(__('admin.update_succeeded'))
|
||||||
|
->refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a form here.
|
||||||
|
*/
|
||||||
|
public function form()
|
||||||
|
{
|
||||||
|
$this->text('remarks', '填写补货物流单号')->required();
|
||||||
|
$this->confirm('是否确认补货完成', '该操作不可逆,确认后将完成该售后单。');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ class AfterSaleVerify extends Form implements LazyRenderable
|
||||||
$defaultRemarks = '同意换货,请填入回寄单号';//需要用户确认并填入回寄单号
|
$defaultRemarks = '同意换货,请填入回寄单号';//需要用户确认并填入回寄单号
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$defaultRemarks = '同意补货, 新的订单号:';//需要用户收到补货后确认,可后台关闭
|
$defaultRemarks = '同意补货';//需要用户收到补货后确认,可后台关闭
|
||||||
}
|
}
|
||||||
$this->text('remarks3')->value($defaultRemarks);
|
$this->text('remarks3')->value($defaultRemarks);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,8 @@ class AfterSale extends Model
|
||||||
if ($afterSale->sn === null) {
|
if ($afterSale->sn === null) {
|
||||||
$afterSale->sn = self::createSn();
|
$afterSale->sn = self::createSn();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
parent::saved(function ($afterSale) {
|
||||||
//如果取消订单
|
//如果取消订单
|
||||||
if ($afterSale->state == self::STATE_CANCEL) {
|
if ($afterSale->state == self::STATE_CANCEL) {
|
||||||
$afterSale->createCancelLog();
|
$afterSale->createCancelLog();
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,11 @@ class AfterSaleService
|
||||||
public function agree(AfterSale $afterSale, array $params, $remarks = '用户已同意客服审核结果')
|
public function agree(AfterSale $afterSale, array $params, $remarks = '用户已同意客服审核结果')
|
||||||
{
|
{
|
||||||
if ($this->isWaitAgree($afterSale)) {
|
if ($this->isWaitAgree($afterSale)) {
|
||||||
|
AfterSaleLog::create([
|
||||||
|
'after_sale_id' => $afterSale->id,
|
||||||
|
'name' => '客户确认',
|
||||||
|
'desc' => $remarks,
|
||||||
|
]);
|
||||||
switch ($afterSale->type) {
|
switch ($afterSale->type) {
|
||||||
case AfterSale::TYPE_REFUND_AND_RETURN:
|
case AfterSale::TYPE_REFUND_AND_RETURN:
|
||||||
$afterSale->update([
|
$afterSale->update([
|
||||||
|
|
@ -258,15 +263,10 @@ class AfterSaleService
|
||||||
case AfterSale::TYPE_FILL:
|
case AfterSale::TYPE_FILL:
|
||||||
$afterSale->update([
|
$afterSale->update([
|
||||||
'remarks' => $remarks,
|
'remarks' => $remarks,
|
||||||
'state' => AfterSale::STATE_FINISH,
|
'state' => AfterSale::STATE_SHIPPING,
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
AfterSaleLog::create([
|
|
||||||
'after_sale_id' => $afterSale->id,
|
|
||||||
'name' => '客户确认',
|
|
||||||
'desc' => $remarks,
|
|
||||||
]);
|
|
||||||
return $afterSale;
|
return $afterSale;
|
||||||
} else {
|
} else {
|
||||||
throw new BizException('售后订单状态异常,请稍后再试');
|
throw new BizException('售后订单状态异常,请稍后再试');
|
||||||
|
|
@ -280,7 +280,7 @@ class AfterSaleService
|
||||||
* @param string $remarks
|
* @param string $remarks
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function shippingFail(AfterSale $afterSale, $remarks ='物流收货未通过')
|
public function shippingFail(AfterSale $afterSale, $remarks ='仓库验收未通过')
|
||||||
{
|
{
|
||||||
if ($this->isWaitShipping($afterSale)) {
|
if ($this->isWaitShipping($afterSale)) {
|
||||||
$afterSale->update([
|
$afterSale->update([
|
||||||
|
|
@ -297,6 +297,31 @@ class AfterSaleService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物流补货
|
||||||
|
*
|
||||||
|
* @param AfterSale $afterSale
|
||||||
|
* @param string $remarks
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function shippingFill(AfterSale $afterSale, $remarks)
|
||||||
|
{
|
||||||
|
$remarks = '补货完成,新的物流单号:'.$remarks;
|
||||||
|
if ($this->isWaitShipping($afterSale)) {
|
||||||
|
AfterSaleLog::create([
|
||||||
|
'after_sale_id' => $afterSale->id,
|
||||||
|
'name' => '仓库审核',
|
||||||
|
'desc' => $remarks,
|
||||||
|
]);
|
||||||
|
$afterSale->update([
|
||||||
|
'state' => $afterSale::STATE_FINISH,
|
||||||
|
'remarks' => $remarks,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
throw new BizException('该售后订单状态异常');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物流确认收货
|
* 物流确认收货
|
||||||
*
|
*
|
||||||
|
|
@ -304,7 +329,7 @@ class AfterSaleService
|
||||||
* @param string $remarks
|
* @param string $remarks
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function shipping(AfterSale $afterSale, $remarks ='物流确认收货')
|
public function shipping(AfterSale $afterSale, $remarks ='仓库验收通过')
|
||||||
{
|
{
|
||||||
if ($this->isWaitShipping($afterSale)) {
|
if ($this->isWaitShipping($afterSale)) {
|
||||||
$afterSale->update([
|
$afterSale->update([
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue