链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

176 lines
6.5 KiB

<?php
namespace App\Admin\Controllers;
use App\Admin\Common\Auth;
use App\Admin\Common\Rpc;
use App\Admin\Extensions\CheckRow;
use App\Admin\Extensions\MyDetailPage;
use App\Admin\Extensions\OrderDetail;
use App\Admin\Extensions\OrderPrint;
use App\Admin\Extensions\OrderRefund;
use App\Admin\Extensions\OrderStateHandle;
use App\Admin\Repositories\ImsCjdcOrderMain;
use App\Models\ImsCjdcMarket;
use Dcat\Admin\Admin;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Layout\Content;
use Dcat\Admin\Show;
use Dcat\Admin\Controllers\AdminController;
use Dcat\Admin\Widgets\Lazy;
class ImsCjdcOrderMainController extends AdminController
{
/**
* Make a grid builder.
*
* @return Grid
*/
protected function grid()
{
return Grid::make(new ImsCjdcOrderMain(), function (Grid $grid) {
//>>1.只展示线上订单打√
//>>2.不同服务站只能看到自己的市场订单
//>>3.订单不允许有添加,编辑,删除
//>>4.订单状态变更√
//>>5.打印功能
//>6.退款
$grid->paginate(10);//每页展示数据10条
//$grid->id;
//$grid->user_id('用户信息');
if (!(Admin::user()->isRole('market_service'))){
$marketId = \Request::get('market_id');
if ($marketId){
$grid->model()->where('market_id',$marketId);
}
}else{
$marketId =Auth::getMarket();
$grid->model()->where('market_id',$marketId);
}
$grid->column('nick_name', '用户信息');
$grid->order_num;
$grid->state('订单状态')
->using(config('order.state'))
->label([1 => 'dark', 2 => 'danger', 3 => 'indigo', 4 => 'success',8=>'warning',311=>'#bd10e0']);
$grid->money;
$grid->column('market.name', '所属市场');
$grid->pay_time('支付时间')->display(function ($time) {
if ($time){
return date('Y-m-d H:i:s',$time);
}
return '<span style="color: #ceccce">未支付</span>';
});
$grid->created_at('下单时间')->display(function ($time) {
return date('Y-m-d H:i:s',$time);
});
$grid->actions(function (Grid\Displayers\Actions $actions) use ($grid) {
$state = $actions->row->state;
if ($state == 2) {
$actions->append(new OrderStateHandle('<div type="button" style="width:140px" class="btn btn-outline-danger">接单</div>', 3));
} elseif ($state == 311) {
$actions->append(new OrderStateHandle('<div type="button" style="width:140px" class="btn btn-outline-warning">完成</div>', 4));
$actions->append(new OrderPrint('<div type="button" style="width:140px" class="btn btn-outline-dark">打印</div>'));
} elseif ($state == 3) {
$actions->append(new OrderPrint('<div type="button" style="width:140px" class="btn btn-outline-dark">打印</div>'));
$actions->append(new CheckRow($actions->row->id, $grid->model()->getCurrentPage(), '<div type="button" style="width:140px" class="btn btn-outline-info">自送</div>'));
} elseif ($state == 8) {
$actions->append(new OrderStateHandle('<div type="button" style="width:140px" class="btn btn-outline-secondary">同意退款</div>', 9));
$actions->append(new OrderRefund($actions->row->id, $grid->model()->getCurrentPage(), '<div type="button" style="width:140px" class="btn btn-outline-secondary">拒绝退款</div>'));
}
$actions->append(new OrderDetail($actions->row->id, $grid->model()->getCurrentPage(), '<div type="button" style="width:140px" class="btn btn-outline-primary">详情</div>'));
});
$grid->filter(function (Grid\Filter $filter) {
$filter->equal('order_num');
if (!(Admin::user()->isRole('market_service'))){
$filter->equal('market_id','所属市场')->select(ImsCjdcMarket::getMarket());
}
});
$grid->disableViewButton();
$grid->disableEditButton();
$grid->disableDeleteButton();
$grid->disableCreateButton();
});
}
/**
* Make a show builder.
*
* @param mixed $id
*
* @return Show
*/
protected function detail($id)
{
return Show::make($id, new ImsCjdcOrderMain(), function (Show $show) {
$show->id;
$show->user_id;
$show->order_num;
$show->state;
$show->time;
$show->pay_time;
$show->money;
$show->tools(function (Show\Tools $tools) {
$tools->append(new \App\Admin\Actions\Show\OrderDetail());
});
});
}
/**
* Make a form builder.
*
* @return Form
*/
protected function form()
{
return Form::make(new ImsCjdcOrderMain(), function (Form $form) {
$form->display('id');
$form->text('user_id');
$form->text('order_num');
$form->text('state');
$form->text('time');
$form->text('pay_time');
$form->text('money');
});
}
/**
* 订单详情
* @param Content $content
* @return Content
*/
public function orderDetail(Content $content)
{
$oid = request()->get('order_id');
$page = request()->get('page');
// 实例化表单类并传递自定义参数
$detail = MyDetailPage::make(['order_id' => $oid]);
return $content->header('订单详情')
->breadcrumb(
['text' => '列表', 'url' => "order?page={$page}"],
['text' => '详情', 'url' => 'detail']
)
->body(Lazy::make($detail));
}
public function orderGoodsRefund()
{
$uid = request()->get('user_id');
$note = request()->get('note');
$global_order_id = request()->get('global_order_id');
$order_child_id = request()->get('order_child_id');
$order_goods_id = request()->get('order_goods_id');
$result = Rpc::onlineSingleRefund($uid, $note, $global_order_id, $order_child_id, $order_goods_id);
return json_encode($result['result']);
}
}