16 changed files with 496 additions and 42 deletions
-
58app/Admin/Actions/ModifyOrderState.php
-
78app/Admin/Actions/Show/OrderDetail.php
-
139app/Admin/Controllers/ImsCjdcOrderMainController.php
-
18app/Admin/Controllers/Test.php
-
61app/Admin/Extensions/CheckRow.php
-
16app/Admin/Extensions/OrderDetail.php
-
55app/Admin/Extensions/OrderStateHandle.php
-
6app/Admin/Repositories/ImsCjdcMarket.php
-
5app/Admin/Repositories/ImsCjdcOrderMain.php
-
3app/Admin/routes.php
-
14app/Models/ImsCjdcMarket.php
-
2app/Models/ImsCjdcOrderMain.php
-
5app/Models/StoreAccount.php
-
48config/order.php
-
16resources/lang/zh-CN/ims-cjdc-order-main.php
-
14resources/views/orderdetail.php
@ -0,0 +1,58 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions; |
||||
|
|
||||
|
use Dcat\Admin\Actions\Action; |
||||
|
use Dcat\Admin\Actions\Response; |
||||
|
use Dcat\Admin\Traits\HasPermissions; |
||||
|
use Illuminate\Contracts\Auth\Authenticatable; |
||||
|
use Illuminate\Database\Eloquent\Model; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class ModifyOrderState extends Action |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '状态'; |
||||
|
|
||||
|
/** |
||||
|
* Handle the action request. |
||||
|
* |
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(Request $request) |
||||
|
{ |
||||
|
// dump($this->getKey());
|
||||
|
|
||||
|
return $this->response()->success('Processed successfully.')->redirect('/'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|array|void |
||||
|
*/ |
||||
|
public function confirm() |
||||
|
{ |
||||
|
// return ['Confirm?', 'contents'];
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param Model|Authenticatable|HasPermissions|null $user |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
protected function authorize($user): bool |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return array |
||||
|
*/ |
||||
|
protected function parameters() |
||||
|
{ |
||||
|
return []; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,78 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Actions\Show; |
||||
|
|
||||
|
use Dcat\Admin\Actions\Response; |
||||
|
use Dcat\Admin\Show\AbstractTool; |
||||
|
use Dcat\Admin\Traits\HasPermissions; |
||||
|
use Illuminate\Contracts\Auth\Authenticatable; |
||||
|
use Illuminate\Database\Eloquent\Model; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class OrderDetail extends AbstractTool |
||||
|
{ |
||||
|
/** |
||||
|
* @return string |
||||
|
*/ |
||||
|
protected $title = '订单订单详情'; |
||||
|
|
||||
|
/** |
||||
|
* Handle the action request. |
||||
|
* |
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return Response |
||||
|
*/ |
||||
|
public function handle(Request $request) |
||||
|
{ |
||||
|
dd($this->getKey()); |
||||
|
|
||||
|
return $this->response() |
||||
|
->success('Processed successfully.') |
||||
|
->redirect('/'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|void |
||||
|
*/ |
||||
|
protected function href() |
||||
|
{ |
||||
|
return admin_url('auth/users'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @return string|array|void |
||||
|
*/ |
||||
|
public function confirm() |
||||
|
{ |
||||
|
return ['Confirm?', 'contents']; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @param Model|Authenticatable|HasPermissions|null $user |
||||
|
* |
||||
|
* @return bool |
||||
|
*/ |
||||
|
protected function authorize($user): bool |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
// 如果你想自定义动作按钮的HTML,可以重写此方法
|
||||
|
public function html() |
||||
|
{ |
||||
|
|
||||
|
return view('orderdetail'); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* @return array |
||||
|
*/ |
||||
|
protected function parameters() |
||||
|
{ |
||||
|
return []; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,139 @@ |
|||||
|
<?php |
||||
|
|
||||
|
namespace App\Admin\Controllers; |
||||
|
|
||||
|
use App\Admin\Extensions\OrderDetail; |
||||
|
use App\Admin\Extensions\OrderStateHandle; |
||||
|
use App\Admin\Repositories\ImsCjdcOrderMain; |
||||
|
use Dcat\Admin\Admin; |
||||
|
use Dcat\Admin\Form; |
||||
|
use Dcat\Admin\Grid; |
||||
|
use Dcat\Admin\Show; |
||||
|
use Dcat\Admin\Controllers\AdminController;; |
||||
|
|
||||
|
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('用户信息');
|
||||
|
$grid->column('user_name','用户信息'); |
||||
|
$grid->order_num; |
||||
|
|
||||
|
$grid->state('订单状态') |
||||
|
->using(config('order.state')) |
||||
|
->label([1=>'dark',2=>'danger',3=>'indigo',4=>'success']); |
||||
|
$grid->money; |
||||
|
$grid->column('market.name','所属市场'); |
||||
|
$grid->time; |
||||
|
$grid->pay_time; |
||||
|
$grid->actions(function (Grid\Displayers\Actions $actions) { |
||||
|
$state = $actions->row->state; |
||||
|
if ($state==2){ |
||||
|
$actions->append(new OrderStateHandle('接单',3)); |
||||
|
}elseif ($state==31){ |
||||
|
$actions->append(new OrderStateHandle('完成',4)); |
||||
|
} |
||||
|
$actions->append(new OrderDetail('详情')); |
||||
|
|
||||
|
//$actions->append("<a class='btn btn-xs action-btn btn-danger grid-row-refuse' data-id='{$actions->getKey()}'><i class='fa fa-close' title='拒绝退款'>拒绝</i></a> ");
|
||||
|
//$actions->append("<a class='btn btn-xs action-btn btn-success grid-row-pass' data-id='{$actions->getKey()}'><i class='fa fa-check' title='同意退款'>同意</i></a>");
|
||||
|
|
||||
|
|
||||
|
}); |
||||
|
//$grid->column('详情')->modal('详情',function ()use ($grid){
|
||||
|
// return view('orderdetail',['id'=>2]);
|
||||
|
//
|
||||
|
//});
|
||||
|
$grid->filter(function (Grid\Filter $filter) { |
||||
|
$filter->equal('id'); |
||||
|
|
||||
|
}); |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 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'); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function orderDetail() |
||||
|
{ |
||||
|
echo 111; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,18 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\Admin\Controllers; |
||||
|
|
||||
|
|
||||
|
use App\Admin\Repositories\ImsCjdcMarket; |
||||
|
use Dcat\Admin\Controllers\AdminController; |
||||
|
use Dcat\Admin\Grid; |
||||
|
|
||||
|
class Test extends AdminController |
||||
|
{ |
||||
|
public function test() |
||||
|
{ |
||||
|
$gird = new Grid(new \App\Models\ImsCjdcMarket()); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -1,42 +1,59 @@ |
|||||
<?php |
<?php |
||||
namespace App\Admin\Extensions; |
namespace App\Admin\Extensions; |
||||
|
|
||||
|
use App\Models\ImsCjdcOrderMain; |
||||
|
use App\Models\StoreAccount; |
||||
use Dcat\Admin\Grid\RowAction; |
use Dcat\Admin\Grid\RowAction; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
class CheckRow extends RowAction |
class CheckRow extends RowAction |
||||
{ |
{ |
||||
|
|
||||
public function title() |
|
||||
|
protected $model; |
||||
|
protected $state; |
||||
|
protected $title; |
||||
|
public function __construct($title=null,$state=null) |
||||
{ |
{ |
||||
return 'Check row'; |
|
||||
|
|
||||
|
parent::__construct($title); |
||||
|
$this->state = $state; |
||||
|
|
||||
} |
} |
||||
|
|
||||
|
|
||||
/** |
/** |
||||
* 添加JS |
|
||||
|
* 处理请求 |
||||
* |
* |
||||
* @return string |
|
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return \Dcat\Admin\Actions\Response |
||||
*/ |
*/ |
||||
protected function script() |
|
||||
|
public function handle(Request $request) |
||||
{ |
{ |
||||
return <<<JS |
|
||||
$('.grid-check-row').on('click', function () { |
|
||||
|
|
||||
// Your code.
|
|
||||
console.log($(this).data('id')); |
|
||||
|
|
||||
}); |
|
||||
JS; |
|
||||
} |
|
||||
public function html() |
|
||||
{ |
|
||||
// 获取当前行数据ID
|
|
||||
|
// 获取当前行ID
|
||||
$id = $this->getKey(); |
$id = $this->getKey(); |
||||
|
$orderMain = new ImsCjdcOrderMain(); |
||||
|
$state = $request->get('state'); |
||||
|
$res = $orderMain->modifyState($id,$state); |
||||
|
if ($res==true){ |
||||
|
return $this->response()->success('操作成功')->refresh(); |
||||
|
}else{ |
||||
|
return $this->response()->error('操作失败'); |
||||
|
} |
||||
|
|
||||
|
|
||||
// 获取当前行数据的用户名
|
|
||||
$username = $this->row->username; |
|
||||
|
|
||||
// 这里需要添加一个class, 和上面script方法对应
|
|
||||
$this->setHtmlAttribute(['data-id' => $id, 'email' => $username, 'class' => 'grid-check-row']); |
|
||||
|
} |
||||
|
|
||||
return parent::html(); |
|
||||
|
/** |
||||
|
* 设置要POST到接口的数据 |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function parameters() |
||||
|
{ |
||||
|
return [ |
||||
|
'state' => $this->state, |
||||
|
]; |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
<?php |
||||
|
|
||||
|
|
||||
|
namespace App\Admin\Extensions; |
||||
|
|
||||
|
|
||||
|
use Dcat\Admin\Grid\RowAction; |
||||
|
|
||||
|
class OrderDetail extends RowAction |
||||
|
{ |
||||
|
public function __construct($title=null) |
||||
|
{ |
||||
|
parent::__construct($title); |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
<?php |
||||
|
namespace App\Admin\Extensions; |
||||
|
|
||||
|
use App\Models\ImsCjdcOrderMain; |
||||
|
use Dcat\Admin\Grid\RowAction; |
||||
|
use Illuminate\Http\Request; |
||||
|
|
||||
|
class OrderStateHandle extends RowAction |
||||
|
{ |
||||
|
|
||||
|
protected $model; |
||||
|
protected $state; |
||||
|
protected $title; |
||||
|
public function __construct($title=null,$state=null) |
||||
|
{ |
||||
|
|
||||
|
parent::__construct($title); |
||||
|
$this->state = $state; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 处理请求 |
||||
|
* |
||||
|
* @param Request $request |
||||
|
* |
||||
|
* @return \Dcat\Admin\Actions\Response |
||||
|
*/ |
||||
|
public function handle(Request $request) |
||||
|
{ |
||||
|
// 获取当前行ID
|
||||
|
$id = $this->getKey(); |
||||
|
$orderMain = new ImsCjdcOrderMain(); |
||||
|
$state = $request->get('state'); |
||||
|
$res = $orderMain->modifyState($id,$state); |
||||
|
if ($res==true){ |
||||
|
return $this->response()->success('操作成功')->refresh(); |
||||
|
}else{ |
||||
|
return $this->response()->error('操作失败'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 设置要POST到接口的数据 |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function parameters() |
||||
|
{ |
||||
|
return [ |
||||
|
'state' => $this->state, |
||||
|
]; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
<?php |
||||
|
return [ |
||||
|
//自营平台订单状态
|
||||
|
'state'=>[ |
||||
|
0=>'错误状态', |
||||
|
1=>'待付款', |
||||
|
2=>'待接单', |
||||
|
3=>'待发货', |
||||
|
31=>'配送中',//state==3&&order_shipping_code==1
|
||||
|
4=>'已完成', |
||||
|
5=>'已评价', |
||||
|
6=>'已取消', |
||||
|
7=>'拒绝', |
||||
|
8=>'申请退款', |
||||
|
9=>'已退款', |
||||
|
10=>'退款拒绝', |
||||
|
9999=>'虚拟订单' |
||||
|
], |
||||
|
//达达平台的订单状态
|
||||
|
'dada_status'=>[ |
||||
|
1=>'待快递员接单', |
||||
|
2=>'待取货', |
||||
|
3=>'配送中', |
||||
|
4=>'已完成', |
||||
|
5=>'已取消', |
||||
|
8=>'指派单', |
||||
|
9=>'妥投异常之物品返回中', |
||||
|
10=>'妥投异常之物品返回完成', |
||||
|
100=>'骑士到店', |
||||
|
1000=>'创建达达运单失败', |
||||
|
|
||||
|
], |
||||
|
//达达测试0 如果为1则用为正式环境
|
||||
|
'online'=>0, |
||||
|
'dada_test_config'=>[ |
||||
|
'source_id'=>'73753', |
||||
|
'shop_no'=>'11047059', |
||||
|
'app_key'=>'dada91f5568c2fa580b', |
||||
|
'app_secret'=>'851019e075fd94d00942289c9161008c', |
||||
|
'url'=>'http://newopen.qa.imdada.cn' |
||||
|
], |
||||
|
'dada_config'=>[ |
||||
|
'source_id'=>'49325', |
||||
|
'app_key'=>'dada9c5cebc86361427', |
||||
|
'app_secret'=>'bd3cedf12d2749aa8791f1686a9d9a54', |
||||
|
'url'=>'https://newopen.imdada.cn' |
||||
|
], |
||||
|
]; |
||||
@ -0,0 +1,16 @@ |
|||||
|
<?php |
||||
|
return [ |
||||
|
'labels' => [ |
||||
|
'ImsCjdcOrderMain' => 'ImsCjdcOrderMain', |
||||
|
], |
||||
|
'fields' => [ |
||||
|
'user_id' => '用户id', |
||||
|
'order_num' => '订单号', |
||||
|
'state' => '1.待付款2.待结单3.等待送达4.完成5.已评价6.取消7.拒绝8.退款中9.已退款10.退款拒绝', |
||||
|
'time' => '下单时间', |
||||
|
'pay_time' => '支付时间', |
||||
|
'money' => '付款金额', |
||||
|
], |
||||
|
'options' => [ |
||||
|
], |
||||
|
]; |
||||
@ -0,0 +1,14 @@ |
|||||
|
<!DOCTYPE html> |
||||
|
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}"> |
||||
|
<head> |
||||
|
<meta charset="utf-8"> |
||||
|
<title>Laravel</title> |
||||
|
|
||||
|
|
||||
|
|
||||
|
</head> |
||||
|
<body > |
||||
|
|
||||
|
<h1>{{$id}}</h1> |
||||
|
</body> |
||||
|
</html> |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue