diff --git a/app/Admin/Actions/ModifyOrderState.php b/app/Admin/Actions/ModifyOrderState.php new file mode 100644 index 0000000..4cc0f48 --- /dev/null +++ b/app/Admin/Actions/ModifyOrderState.php @@ -0,0 +1,58 @@ +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 []; + } +} diff --git a/app/Admin/Actions/Show/OrderDetail.php b/app/Admin/Actions/Show/OrderDetail.php new file mode 100644 index 0000000..318f14a --- /dev/null +++ b/app/Admin/Actions/Show/OrderDetail.php @@ -0,0 +1,78 @@ +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 []; + } +} diff --git a/app/Admin/Controllers/ImsCjdcOrderMainController.php b/app/Admin/Controllers/ImsCjdcOrderMainController.php new file mode 100644 index 0000000..b8d4ecc --- /dev/null +++ b/app/Admin/Controllers/ImsCjdcOrderMainController.php @@ -0,0 +1,139 @@ +>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("拒绝  "); + //$actions->append("同意"); + + + }); + //$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; + } +} diff --git a/app/Admin/Controllers/Test.php b/app/Admin/Controllers/Test.php new file mode 100644 index 0000000..7ef955c --- /dev/null +++ b/app/Admin/Controllers/Test.php @@ -0,0 +1,18 @@ +state = $state; + } + + /** - * 添加JS + * 处理请求 * - * @return string + * @param Request $request + * + * @return \Dcat\Admin\Actions\Response */ - protected function script() + public function handle(Request $request) { - return <<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, + ]; } } diff --git a/app/Admin/Extensions/OrderDetail.php b/app/Admin/Extensions/OrderDetail.php new file mode 100644 index 0000000..7ae0e87 --- /dev/null +++ b/app/Admin/Extensions/OrderDetail.php @@ -0,0 +1,16 @@ +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, + ]; + } +} diff --git a/app/Admin/Repositories/ImsCjdcMarket.php b/app/Admin/Repositories/ImsCjdcMarket.php index 09e1e92..d498e9e 100644 --- a/app/Admin/Repositories/ImsCjdcMarket.php +++ b/app/Admin/Repositories/ImsCjdcMarket.php @@ -13,4 +13,10 @@ class ImsCjdcMarket extends EloquentRepository * @var string */ protected $eloquentClass = Model::class; + + // 通过这个方法可以指定查询的字段,默认"*" + public function getGridColumns() + { + return [$this->getKeyName(), 'name']; + } } diff --git a/app/Admin/Repositories/ImsCjdcOrderMain.php b/app/Admin/Repositories/ImsCjdcOrderMain.php index c09e322..97349dc 100644 --- a/app/Admin/Repositories/ImsCjdcOrderMain.php +++ b/app/Admin/Repositories/ImsCjdcOrderMain.php @@ -18,9 +18,9 @@ class ImsCjdcOrderMain extends EloquentRepository public function get(Grid\Model $model) { $builder = new \App\Models\ImsCjdcOrderMain(); - $builder = $builder::leftJoin('ims_cjdc_user','ims_cjdc_user.id','ims_cjdc_order_main.user_id') + $builder = $builder::leftJoin('ims_cjdc_user as u','u.id','ims_cjdc_order_main.user_id') ->with('market') - ->select('ims_cjdc_order_main.*','ims_cjdc_user.name as user_name') + ->select('ims_cjdc_order_main.*','u.name as user_name') ->where('type',1) ->orderBy('ims_cjdc_order_main.id','desc');//只取线上订单数据 @@ -38,6 +38,7 @@ class ImsCjdcOrderMain extends EloquentRepository }); $query = $query->toArray(); + //如果订单状态为配送中 将state设置为31 foreach ($query['data'] as &$value){ if ($value['state']==3&&$value['order_shipping_code']==1){ $value['state'] = 31; diff --git a/app/Admin/routes.php b/app/Admin/routes.php index a6102e8..4b9dbcf 100644 --- a/app/Admin/routes.php +++ b/app/Admin/routes.php @@ -44,5 +44,8 @@ Route::group([ //统计店铺新增用户 $router->resource('/storeUserReport', 'StoreUserReportController'); + $router->resource('/order', 'ImsCjdcOrderMainController'); + $router->any('/detail', 'ImsCjdcOrderMainController@orderDetail'); + $router->any('/test', 'Test@test'); }); diff --git a/app/Models/ImsCjdcMarket.php b/app/Models/ImsCjdcMarket.php index 8f441d5..1496a8c 100644 --- a/app/Models/ImsCjdcMarket.php +++ b/app/Models/ImsCjdcMarket.php @@ -29,18 +29,6 @@ class ImsCjdcMarket extends Model return $this->hasOne('\App\Models\LanzuMpInfo','id','mp_id'); } - /** - * 获取市场信息 - * @return \Illuminate\Http\JsonResponse - */ - public static function getMarket() - { - $markets = self::get(); - $item = []; - foreach ($markets as $market) { - $item[$market->id] = $market->name; - } - return $item; - } + } diff --git a/app/Models/ImsCjdcOrderMain.php b/app/Models/ImsCjdcOrderMain.php index e9f4d63..76ad925 100644 --- a/app/Models/ImsCjdcOrderMain.php +++ b/app/Models/ImsCjdcOrderMain.php @@ -54,4 +54,6 @@ class ImsCjdcOrderMain extends Model }); } + + } diff --git a/app/Models/StoreAccount.php b/app/Models/StoreAccount.php index 23de9ae..029559b 100644 --- a/app/Models/StoreAccount.php +++ b/app/Models/StoreAccount.php @@ -9,7 +9,6 @@ namespace App\Models; use Dcat\Admin\Traits\HasDateTimeFormatter; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\DB; -use App\Models\ImsCjdcStore as storeModel; class StoreAccount extends Model { @@ -46,8 +45,4 @@ class StoreAccount extends Model return false; } } - - public function store(){ - return $this->hasMany(storeModel::class,'id','store_id'); - } } diff --git a/config/order.php b/config/order.php new file mode 100644 index 0000000..23caf29 --- /dev/null +++ b/config/order.php @@ -0,0 +1,48 @@ +[ + 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' + ], +]; diff --git a/resources/lang/zh-CN/ims-cjdc-order-main.php b/resources/lang/zh-CN/ims-cjdc-order-main.php new file mode 100644 index 0000000..3600905 --- /dev/null +++ b/resources/lang/zh-CN/ims-cjdc-order-main.php @@ -0,0 +1,16 @@ + [ + 'ImsCjdcOrderMain' => 'ImsCjdcOrderMain', + ], + 'fields' => [ + 'user_id' => '用户id', + 'order_num' => '订单号', + 'state' => '1.待付款2.待结单3.等待送达4.完成5.已评价6.取消7.拒绝8.退款中9.已退款10.退款拒绝', + 'time' => '下单时间', + 'pay_time' => '支付时间', + 'money' => '付款金额', + ], + 'options' => [ + ], +]; diff --git a/resources/views/orderdetail.php b/resources/views/orderdetail.php new file mode 100644 index 0000000..ec2878a --- /dev/null +++ b/resources/views/orderdetail.php @@ -0,0 +1,14 @@ + + + + + Laravel + + + + + + +

{{$id}}

+ +