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.
		
		
		
		
		
			
		
			
				
					
					
						
							47 lines
						
					
					
						
							1.2 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							47 lines
						
					
					
						
							1.2 KiB
						
					
					
				
								<?php
							 | 
						|
								
							 | 
						|
								namespace App\AdminAgent\Extensions\Grid;
							 | 
						|
								use App\Common\OrderStatus;
							 | 
						|
								use App\Models\Order;
							 | 
						|
								use Dcat\Admin\Admin;
							 | 
						|
								use Dcat\Admin\Grid\RowAction;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * 改变订单状态
							 | 
						|
								 * Class ChangeOrderStatus
							 | 
						|
								 * @package App\AdminAgent\Extensions\Grid
							 | 
						|
								 */
							 | 
						|
								class ChangeOrderStatus extends RowAction
							 | 
						|
								{
							 | 
						|
									protected $title = '设为 [线下]已付款';
							 | 
						|
								
							 | 
						|
									protected function html()
							 | 
						|
									{
							 | 
						|
										$this->appendHtmlAttribute('class', 'btn btn-sm btn-success');
							 | 
						|
										$this->defaultHtmlAttribute('href', 'javascript:;');
							 | 
						|
								
							 | 
						|
										return "<a {$this->formatHtmlAttributes()}>{$this->title}</a>";
							 | 
						|
									}
							 | 
						|
								
							 | 
						|
									public function handle()
							 | 
						|
									{
							 | 
						|
										try {
							 | 
						|
											$order = Order::firstWhere(['id' => $this->getKey(), 'agent_id' => Admin::user()->id, 'status' => OrderStatus::OFFLINE_UNPAID]);
							 | 
						|
											if (!$order) {
							 | 
						|
												return $this->response()->error("订单不存在或已处理过了")->refresh();
							 | 
						|
											}
							 | 
						|
											$order->status = OrderStatus::OFFLINE_PAID;
							 | 
						|
											$order->verify_code = uniqid(); //生成核销码
							 | 
						|
											$order->save();
							 | 
						|
								
							 | 
						|
											return $this->response()->success("操作成功,已设置为“线下已付款”")->refresh();
							 | 
						|
										} catch (\Exception $e) {
							 | 
						|
											return $this->response()->error($e->getMessage());
							 | 
						|
										}
							 | 
						|
									}
							 | 
						|
								
							 | 
						|
									public function confirm()
							 | 
						|
									{
							 | 
						|
										return ['确定要设置为已付款吗?', ''];
							 | 
						|
									}
							 | 
						|
								}
							 |