4 changed files with 98 additions and 0 deletions
-
4app/Admin/Controllers/ImsCjdcOrderMainController.php
-
36app/Admin/Extensions/OrderRefund.php
-
4app/Admin/Extensions/OrderStateHandle.php
-
54app/Admin/Forms/RefundNote.php
@ -0,0 +1,36 @@ |
|||
<?php |
|||
|
|||
|
|||
namespace App\Admin\Extensions; |
|||
|
|||
|
|||
use App\Admin\Forms\RefundNote; |
|||
use Dcat\Admin\Grid\RowAction; |
|||
use Dcat\Admin\Widgets\Modal; |
|||
|
|||
class OrderRefund extends RowAction |
|||
{ |
|||
protected $title; |
|||
protected $order_id; |
|||
protected $currentPage; |
|||
public function __construct($orderId,$currentPage,$title=null) |
|||
{ |
|||
$this->order_id = $orderId; |
|||
$this->currentPage = $currentPage; |
|||
parent::__construct($title); |
|||
|
|||
} |
|||
|
|||
public function render() |
|||
{ |
|||
|
|||
// 实例化表单类并传递自定义参数
|
|||
$form = RefundNote::make(['order_id'=>$this->order_id,'current_page'=>$this->currentPage]); |
|||
return Modal::make() |
|||
->lg() |
|||
->title('拒绝理由') |
|||
->body($form) |
|||
->button($this->title); |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
<?php |
|||
|
|||
namespace App\Admin\Forms; |
|||
|
|||
use App\Models\ImsCjdcOrderMain; |
|||
use Dcat\Admin\Widgets\Form; |
|||
use Symfony\Component\HttpFoundation\Response; |
|||
|
|||
class RefundNote extends Form |
|||
{ |
|||
/** |
|||
* Handle the form request. |
|||
* |
|||
* @param array $input |
|||
* |
|||
* @return Response |
|||
*/ |
|||
public function handle(array $input) |
|||
{ |
|||
$note = request()->get('refuse_refund_note'); |
|||
$oid = request()->get('order_id'); |
|||
$current_page = request()->get('current_page'); |
|||
$result = ImsCjdcOrderMain::where('id', $oid)->update([ |
|||
'refuse_refund_note' => $note, |
|||
'state'=>10, |
|||
'updated_at' => time() |
|||
]); |
|||
if ($result) { |
|||
return $this->success('操作成功', "order?page={$current_page}"); |
|||
} else { |
|||
return $this->error('操作失败'); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* Build a form here. |
|||
*/ |
|||
public function form() |
|||
{ |
|||
$this->textarea('refuse_refund_note', '原因')->placeholder('请填写拒绝退款的理由,字数不得超过50个字')->required(); |
|||
$this->hidden('order_id')->value($this->data['order_id']); |
|||
$this->hidden('current_page')->value($this->data['current_page']); |
|||
} |
|||
|
|||
/** |
|||
* The data of the form. |
|||
* |
|||
* @return array |
|||
*/ |
|||
public function default() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue