12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- namespace App\Modules\UserTask\Services;
- use App\Modules\UserTask\Models\UserTask;
- use Exception;
- /**
- * 单次任务
- */
- class SingleTask extends BaseTask
- {
- public function checkUserTask()
- {
- return UserTask::where('task_id', $this->task->id)->where('uid', $this->uid)->exists();
- }
- public function addUserTask()
- {
- try {
- UserTask::create([
- 'uid' => $this->uid,
- 'task_id' => $this->task->id,
- 'status' => self::up_status,
- 'type' => $this->task->reward_type,
- 'value' => $this->task->value,
- ]);
- } catch (Exception $e) {
- myLog('add_task')->error($e->getMessage());
- }
- }
- public function findUserTask(int $status)
- {
- return UserTask::where('task_id', $this->task->id)
- ->where('uid', $this->uid)
- ->where('status', $status)
- ->first();
- }
- }
|