diff --git a/app/Http/Controllers/Remote/Host/TaskController.php b/app/Http/Controllers/Remote/Host/TaskController.php index 031e959..55ec729 100644 --- a/app/Http/Controllers/Remote/Host/TaskController.php +++ b/app/Http/Controllers/Remote/Host/TaskController.php @@ -2,12 +2,9 @@ namespace App\Http\Controllers\Remote\Host; -use App\Models\Host; -use Ramsey\Uuid\Uuid; use App\Models\User\Task; use Illuminate\Http\Request; use App\Http\Controllers\Controller; -use Illuminate\Support\Facades\Cache; class TaskController extends Controller { @@ -63,8 +60,10 @@ public function update(Request $request, Task $task) 'status' => 'sometimes|in:pending,processing,need_operation,done,success,failed,error,canceled', ]); + $task->update($request->all()); + return $this->updated($task); } } diff --git a/app/Models/User/Task.php b/app/Models/User/Task.php index e0ef8ef..04be338 100644 --- a/app/Models/User/Task.php +++ b/app/Models/User/Task.php @@ -26,12 +26,17 @@ class Task extends Model public $incrementing = false; - public function scopeUser($query) { + // key type string + protected $keyType = 'string'; + + public function scopeUser($query) + { return $query->where('user_id', auth()->id()); } - public function host() { + public function host() + { return $this->belongsTo(Host::class); } @@ -43,6 +48,7 @@ protected static function boot() // id 为 uuid $model->id = Uuid::uuid4()->toString(); + // host_id 和 user_id 至少存在一个 if (!$model->host_id && !$model->user_id) { throw new CommonException('host_id 和 user_id 至少存在一个'); @@ -51,17 +57,22 @@ protected static function boot() // if host_id if ($model->host_id) { $model->load('host'); - // dd($model); + if ($model->host === null) { + throw new CommonException('host_id 不存在'); + } + + // dd($model); // dd($model->host_id); // $host = Host::where('id', $model->host_id)->first(); // dd($host); + + $model->user_id = $model->host->user_id; } - }); // updateing diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 10fdab6..2bbadcc 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -70,7 +70,7 @@ private function alipayOptions() // $options->alipayPublicKey = Storage::get('alipayCertPublicKey_RSA2.crt'); //可设置异步通知接收服务地址(可选) - $options->notifyUrl = "http://rcrmqishil.sharedwithexpose.com/api/pay/notify"; + $options->notifyUrl = route('balances.notify'); return $options; diff --git a/routes/remote.php b/routes/remote.php index 75eb903..8af5f51 100644 --- a/routes/remote.php +++ b/routes/remote.php @@ -31,13 +31,13 @@ $router->post('/', [ 'uses' => 'Host\TaskController@store' ]); - $router->get('/{tasks}', [ + $router->get('/{task}', [ 'uses' => 'Host\TaskController@show' ]); - $router->patch('/{tasks}', [ + $router->patch('/{task}', [ 'uses' => 'Host\TaskController@update' ]); - $router->delete('/{tasks}', [ + $router->delete('/{task}', [ 'uses' => 'Host\TaskController@destroy' ]); });