修改调整
parent
acc814fa6a
commit
b9696820c1
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Admin\Actions\RowActions;
|
||||
|
||||
use Dcat\Admin\Grid\RowAction;
|
||||
use App\Models\Order;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Services\OrderService;
|
||||
|
||||
class OrderCancle extends RowAction
|
||||
{
|
||||
/**
|
||||
* 标题
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function title()
|
||||
{
|
||||
return '取消订单';
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置确认弹窗信息,如果返回空值,则不会弹出弹窗
|
||||
*
|
||||
* 允许返回字符串或数组类型
|
||||
*
|
||||
* @return array|string|void
|
||||
*/
|
||||
public function confirm()
|
||||
{
|
||||
return [
|
||||
// 确认弹窗 title
|
||||
$this->row->order_number,
|
||||
// 确认弹窗 content
|
||||
"您确定要取消该订单吗?",
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理请求
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Dcat\Admin\Actions\Response
|
||||
*/
|
||||
public function handle(Request $request)
|
||||
{
|
||||
// 获取当前行ID
|
||||
$id = $this->getKey();
|
||||
|
||||
$order = Order::findOrFail($id);
|
||||
(new OrderService())->cancleOrder($order);
|
||||
// 返回响应结果并刷新页面
|
||||
return $this->response()->success("取消成功")->refresh();
|
||||
}
|
||||
}
|
||||
|
|
@ -83,19 +83,19 @@ class GoodController extends AdminController
|
|||
$builder = Good::with('goods_attrs');
|
||||
return Form::make($builder, function (Form $form) {
|
||||
$form->display('id');
|
||||
$form->text('goods_name');
|
||||
$form->text('goods_name')->required();
|
||||
$form->textarea('goods_des');
|
||||
// $form->text('goods_spu');
|
||||
$form->image('goods_cover')
|
||||
->accept('jpg,png,gif,jpeg', 'image/*')
|
||||
->move('milk-tea/goods/'.Carbon::now()->toDateString())
|
||||
->saveFullUrl()->removable(false)->autoUpload()
|
||||
->required()->help('建议图片尺寸:150*150');
|
||||
$form->image('goods_image')
|
||||
->accept('jpg,png,gif,jpeg', 'image/*')
|
||||
->move('milk-tea/goods/'.Carbon::now()->toDateString())
|
||||
->saveFullUrl()->removable(false)->autoUpload()
|
||||
->required()->help('建议图片尺寸:750*580');
|
||||
->help('建议图片尺寸:150*150');
|
||||
// $form->image('goods_image')
|
||||
// ->accept('jpg,png,gif,jpeg', 'image/*')
|
||||
// ->move('milk-tea/goods/'.Carbon::now()->toDateString())
|
||||
// ->saveFullUrl()->removable(false)->autoUpload()
|
||||
// ->required()->help('建议图片尺寸:750*580');
|
||||
$form->select('category_id')->options(admin_route('goods_categories.api'))->required();
|
||||
$form->select('type_id')->options(admin_route('goods_types.api'))->required();
|
||||
$form->currency('goods_price')->symbol('¥')->default(0)->required();
|
||||
|
|
|
|||
|
|
@ -26,15 +26,11 @@ class HomeController extends Controller
|
|||
// })
|
||||
->body(function (Row $row){
|
||||
// 订单总数 3
|
||||
$row->column(4, new TotalOrders());//订单总数
|
||||
// 每日订单数量趋势,按天,按周,按月 6
|
||||
$row->column(7, new NewOrders());
|
||||
$row->column(12, new NewOrders());//订单总数
|
||||
})->body(function (Row $row){
|
||||
// 线上线下订单比例 6
|
||||
// 小程序订单完成比例 6
|
||||
$row->column(7, new ProductOrders());
|
||||
// $row->column(4, new OrderDevices());
|
||||
|
||||
$row->column(6, new ProductOrders());
|
||||
$row->column(6, new TotalOrders());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Dcat\Admin\Layout\Content;
|
|||
use App\Admin\Pages\{CreateOrder,PickupOrder};
|
||||
use App\Models\{Order as OrderModel};
|
||||
use App\Services\OrderService;
|
||||
use App\Admin\Actions\RowActions\OrderPickUpNotice;
|
||||
use App\Admin\Actions\RowActions\{OrderPickUpNotice, OrderCancle};
|
||||
use Dcat\Admin\Http\JsonResponse;
|
||||
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ class OrderController extends AdminController
|
|||
3 => Admin::color()->info(),
|
||||
]);
|
||||
$grid->column('order_status')->bool(['1' => true, '-1' => false]);
|
||||
$grid->column('pay_status')->bool(['1' => true, '0' => false]);
|
||||
// $grid->column('pay_status')->bool(['1' => true, '0' => false]);
|
||||
// $grid->column('shipping_status')->bool(['1' => true, '0' => false]);
|
||||
// $grid->column('pay_time');
|
||||
// $grid->column('shipping_time');
|
||||
|
|
@ -61,14 +61,15 @@ class OrderController extends AdminController
|
|||
$filter->expand(false);
|
||||
// $filter->equal('id');
|
||||
$filter->equal('order_sn');
|
||||
$filter->equal('pay_status')->select([0 => '未支付', 1 => '已支付'])->default(1);
|
||||
$filter->equal('order_phone', '手机号');
|
||||
// $filter->equal('pay_status')->select([0 => '未支付', 1 => '已支付'])->default(1);
|
||||
// $filter->equal('order_phone', '手机号');
|
||||
$filter->between('created_at', '下单时间')->date();
|
||||
});
|
||||
|
||||
$grid->actions(function (Grid\Displayers\Actions $actions) {
|
||||
$actions->disableDelete();
|
||||
if($actions->row->order_status == 1){
|
||||
$actions->disableDelete();
|
||||
$actions->append(new OrderCancle());
|
||||
}
|
||||
if( $actions->row->pay_type == 1 &&
|
||||
$actions->row->order_status == 1 &&
|
||||
|
|
@ -114,34 +115,38 @@ class OrderController extends AdminController
|
|||
return Show::make($id, Order::with(['ticket','ticket.quanTicket']), function (Show $show) {
|
||||
$show->row(function(Show\Row $show){
|
||||
$show->width(4)->field('order_sn');
|
||||
$show->width(4)->field('is_reserve', '是否预约')->using(['0' => '普通订单', '1'=>'预约订单'])->label()->append(function($info){
|
||||
return $this->is_reserve? Carbon::parse($this->reserve_time)->toDateString():'';
|
||||
});
|
||||
$show->width(4)->field('order_number');
|
||||
$show->width(4)->field('created_at', '下单时间');
|
||||
// $show->width(4)->field('is_reserve', '是否预约')->using(['0' => '普通订单', '1'=>'预约订单'])->label()->append(function($info){
|
||||
// return $this->is_reserve? Carbon::parse($this->reserve_time)->toDateString():'';
|
||||
// });
|
||||
// $show->width(4)->field('is_niu','是否吹牛')->using(['0' => '普通订单', '1'=>'吹牛订单'])->label();
|
||||
});
|
||||
$show->row(function(Show\Row $show){
|
||||
$show->width(4)->field('order_number');
|
||||
$show->width(4)->field('order_phone', '手机号');
|
||||
// $show->width(4)->field('order_phone', '手机号');
|
||||
$show->width(4)->field('order_status', '订单状态')->using(['0'=>'未确认', '1' => '已确认', '-1'=>'已取消']);
|
||||
$show->width(4)->field('order_price')->prepend('¥');
|
||||
});
|
||||
//优惠券信息
|
||||
$show->row(function(Show\Row $show){
|
||||
$show->width(4)->field('ticket_id', '优惠券')->as(function(){
|
||||
return $this->ticket->quanTicket->quan_name??'';
|
||||
})->label();
|
||||
$show->width(4)->field('ticket_value', '优惠金额')->prepend('¥');
|
||||
$show->width(4)->field('pay_price', '支付价格')->prepend('¥');
|
||||
});
|
||||
//优惠券信息
|
||||
// $show->row(function(Show\Row $show){
|
||||
// $show->width(4)->field('ticket_id', '优惠券')->as(function(){
|
||||
// return $this->ticket->quanTicket->quan_name??'';
|
||||
// })->label();
|
||||
// $show->width(4)->field('ticket_value', '优惠金额')->prepend('¥');
|
||||
// $show->width(4)->field('pay_price', '支付价格')->prepend('¥');
|
||||
// });
|
||||
$show->row(function(Show\Row $show){
|
||||
$show->width(4)->field('order_status', '订单状态')->using(['0'=>'未确认', '1' => '已确认', '-1'=>'已取消']);
|
||||
$show->width(4)->field('pay_status', '支付状态')->using(['0'=>'未支付', '1' => '已支付']);
|
||||
$show->width(4)->field('shipping_status', '取餐状态')->using(['0'=>'未取餐', '1' => '已取餐']);
|
||||
});
|
||||
$show->row(function(Show\Row $show){
|
||||
$show->width(4)->field('created_at', '下单时间');
|
||||
$show->width(4)->field('pay_time', '支付时间');
|
||||
$show->width(4)->field('shipping_time', '取餐时间');
|
||||
|
||||
|
||||
// $show->width(4)->field('pay_status', '支付状态')->using(['0'=>'未支付', '1' => '已支付']);
|
||||
// $show->width(4)->field('shipping_status', '取餐状态')->using(['0'=>'未取餐', '1' => '已取餐']);
|
||||
});
|
||||
// $show->row(function(Show\Row $show){
|
||||
|
||||
// // $show->width(4)->field('pay_time', '支付时间');
|
||||
// // $show->width(4)->field('shipping_time', '取餐时间');
|
||||
// });
|
||||
|
||||
// $show->row(function(Show\Row $show){
|
||||
$show->goods(function ($model) {
|
||||
|
|
|
|||
|
|
@ -590,9 +590,9 @@ class OrderService
|
|||
* 取消订单
|
||||
*/
|
||||
public function cancleOrder(Order $order){
|
||||
if($order->pay_status == 1){//已支付订单无法取消
|
||||
return false;
|
||||
}
|
||||
// if($order->pay_status == 1){//已支付订单无法取消
|
||||
// return false;
|
||||
// }
|
||||
$order->order_status = -1;
|
||||
$order->closed_time = null;
|
||||
PayLog::where([
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ class CreateGoodsTable extends Migration
|
|||
$table->string('goods_name')->comment("商品名称");
|
||||
$table->string('goods_des')->nullable()->comment('商品描述');
|
||||
$table->string('goods_spu')->nullable()->comment("商品货号");
|
||||
$table->string('goods_cover')->comment("商品封面");
|
||||
$table->string('goods_image')->comment("商品详情图");
|
||||
$table->string('goods_cover')->nullable()->comment("商品封面");
|
||||
$table->string('goods_image')->nullable()->comment("商品详情图");
|
||||
$table->bigInteger('category_id')->unsigned()->comment("商品分类");
|
||||
$table->bigInteger('type_id')->unsigned()->comment("商品类型");
|
||||
$table->decimal('goods_price', 8, 2)->default(0.00)->comment("商品价格");
|
||||
|
|
|
|||
Loading…
Reference in New Issue