SystemUserTask.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. <?php
  2. namespace app\models\system;
  3. use app\models\mining\UserMiningMachine;
  4. use app\models\store\StoreOrder;
  5. use app\models\user\User;
  6. use app\models\user\UserBill;
  7. use app\models\user\UserLevel;
  8. use app\models\user\UserTaskFinish;
  9. use app\models\vote\UserVote;
  10. use crmeb\traits\ModelTrait;
  11. use crmeb\basic\BaseModel;
  12. use think\db\exception\DataNotFoundException;
  13. use think\db\exception\DbException;
  14. use think\db\exception\ModelNotFoundException;
  15. /**
  16. * TODO 设置等级任务Model
  17. * Class SystemUserTask
  18. * @package app\models\system
  19. */
  20. class SystemUserTask extends BaseModel
  21. {
  22. /**
  23. * 数据表主键
  24. * @var string
  25. */
  26. protected $pk = 'id';
  27. /**
  28. * 模型名称
  29. * @var string
  30. */
  31. protected $name = 'system_user_task';
  32. use ModelTrait;
  33. /**
  34. * 任务类型
  35. * type 记录在数据库中用来区分任务
  36. * name 任务名 (任务名中的{$num}会自动替换成设置的数字 + 单位)
  37. * max_number 最大设定数值 0为不限定
  38. * min_number 最小设定数值
  39. * unit 单位
  40. * */
  41. protected static $TaskType = [
  42. [
  43. 'type' => 'SatisfactionIntegral',
  44. 'name' => '满足积分{$num}',
  45. 'real_name' => '积分数',
  46. 'max_number' => 0,
  47. 'min_number' => 0,
  48. 'unit' => '分'
  49. ],
  50. [
  51. 'type' => 'ConsumptionAmount',
  52. 'name' => '消费满{$num}',
  53. 'real_name' => '消费金额',
  54. 'max_number' => 0,
  55. 'min_number' => 0,
  56. 'unit' => '元'
  57. ],
  58. [
  59. 'type' => 'ConsumptionFrequency',
  60. 'name' => '消费{$num}',
  61. 'real_name' => '消费次数',
  62. 'max_number' => 0,
  63. 'min_number' => 0,
  64. 'unit' => '次'
  65. ],
  66. [
  67. 'type' => 'CumulativeAttendance',
  68. 'name' => '累计签到{$num}',
  69. 'real_name' => '累计签到',
  70. 'max_number' => 365,
  71. 'min_number' => 1,
  72. 'unit' => '天'
  73. ],
  74. [
  75. 'type' => 'SharingTimes',
  76. 'name' => '分享给朋友{$num}',
  77. 'real_name' => '分享给朋友',
  78. 'max_number' => 1000,
  79. 'min_number' => 1,
  80. 'unit' => '次'
  81. ],
  82. [
  83. 'type' => 'InviteGoodFriends',
  84. 'name' => '邀请好友{$num}成为下线',
  85. 'real_name' => '邀请好友成为下线',
  86. 'max_number' => 1000,
  87. 'min_number' => 1,
  88. 'unit' => '人'
  89. ],
  90. [
  91. 'type' => 'InviteGoodFriendsLevel',
  92. 'name' => '邀请好友{$num}成为会员',
  93. 'real_name' => '邀请好友成为会员',
  94. 'max_number' => 1000,
  95. 'min_number' => 1,
  96. 'unit' => '人'
  97. ],
  98. [
  99. 'type' => 'OutBiggestSumAchievement',
  100. 'name' => '小区累计业绩达到{$num}',
  101. 'real_name' => '小区累计业绩',
  102. 'max_number' => 0,
  103. 'min_number' => 0,
  104. 'unit' => 'USDT'
  105. ],
  106. [
  107. 'type' => 'SelfHashRate',
  108. 'name' => '自己算力达到{$num}',
  109. 'real_name' => '自己算力',
  110. 'max_number' => 0,
  111. 'min_number' => 0,
  112. 'unit' => 'T'
  113. ],
  114. [
  115. 'type' => 'GroupHashRate',
  116. 'name' => '团队算力达到{$num}',
  117. 'real_name' => '团队算力',
  118. 'max_number' => 0,
  119. 'min_number' => 0,
  120. 'unit' => 'T'
  121. ],
  122. [
  123. 'type' => 'SmallGroupHashRate',
  124. 'name' => '团队小区算力达到{$num}',
  125. 'real_name' => '团队小区算力',
  126. 'max_number' => 0,
  127. 'min_number' => 0,
  128. 'unit' => 'T'
  129. ],
  130. ];
  131. public function profile()
  132. {
  133. return $this->hasOne('SystemUserLevel', 'level_id', 'id')->field('name');
  134. }
  135. public static function getTaskTypeAll()
  136. {
  137. return self::$TaskType;
  138. }
  139. /**
  140. * 获取某个任务
  141. * @param string $type 任务类型
  142. * @return array
  143. * */
  144. public static function getTaskType($type)
  145. {
  146. foreach (self::$TaskType as $item) {
  147. if ($item['type'] == $type) return $item;
  148. }
  149. }
  150. /**
  151. * 设置任务名
  152. * @param string $type 任务类型
  153. * @param int $num 预设值
  154. * @return string
  155. * */
  156. public static function setTaskName($type, $num)
  157. {
  158. $systemType = self::getTaskType($type);
  159. return str_replace('{$num}', $num . $systemType['unit'], $systemType['name']);
  160. }
  161. /**
  162. * 个人算力
  163. * @param int $task_id 任务id
  164. * @param int $uid 用户id
  165. * @param int $start_time 开始时间
  166. * @param int $number 限定时间
  167. * @return boolean
  168. * */
  169. public static function GroupHashRate($task_id, $uid = 0, $start_time = 0, $number = 0)
  170. {
  171. $isComplete = false;
  172. //包括自己在内合计三层用户uid
  173. $uids = [$uid];
  174. $children_uids = [$uid];
  175. $layer = 1;
  176. while ($layer <= sys_config('group_rate_layer', 2) && count($children_uids)) {
  177. $children_uids = User::where('spread_uid', 'in', $children_uids)->column('uid');
  178. if (count($children_uids)) {
  179. $uids = array_merge($uids, $children_uids);
  180. }
  181. $layer++;
  182. }
  183. $countPay = UserMiningMachine::where('paid', 1)->where('status', 'in', [0, 1])->where('mining_end_time', '>', time())->where('uid', 'in', $uids)->sum('num');
  184. if ($countPay >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  185. return ['还需团队算力{$num}T', $countPay, $isComplete];
  186. }
  187. /**
  188. * 个人算力
  189. * @param int $task_id 任务id
  190. * @param int $uid 用户id
  191. * @param int $start_time 开始时间
  192. * @param int $number 限定时间
  193. * @return boolean
  194. * */
  195. public static function SmallGroupHashRate($task_id, $uid = 0, $start_time = 0, $number = 0)
  196. {
  197. $isComplete = false;
  198. //包括自己在内合计三层用户uid
  199. // $uids = [$uid];
  200. $children_uids = User::where('spread_uid', $uid)->column('uid');
  201. $countPay = [];
  202. $max = -1000;
  203. foreach ($children_uids as $v) {
  204. $uids = [$v];
  205. $children_uids_sub = [$v];
  206. while (count($children_uids_sub)) {
  207. $children_uids_sub = User::where('spread_uid', 'in', $children_uids_sub)->column('uid');
  208. if (count($children_uids_sub)) {
  209. $uids = array_merge($uids, $children_uids_sub);
  210. }
  211. }
  212. $all = UserMiningMachine::where('paid', 1)->where('status', 'in', [0, 1])->where('mining_end_time', '>', time())->where('uid', 'in', $uids)->sum('num');
  213. if ($max < $all) $max = $all;
  214. $countPay[] = $all;
  215. }
  216. $sum = array_sum($countPay) - $max;
  217. // var_dump($max);
  218. // var_dump($sum);
  219. // exit;
  220. if ($sum >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  221. return ['还需团队小区算力{$num}T', $sum, $isComplete];
  222. }
  223. /**
  224. * 团队算力
  225. * @param int $task_id 任务id
  226. * @param int $uid 用户id
  227. * @param int $start_time 开始时间
  228. * @param int $number 限定时间
  229. * @return boolean
  230. * */
  231. public static function SelfHashRate($task_id, $uid = 0, $start_time = 0, $number = 0)
  232. {
  233. $isComplete = false;
  234. $countPay = UserMiningMachine::where('paid', 1)->where('status', 'in', [0, 1])->where('mining_end_time', '>', time())->where('uid', $uid)->sum('num');
  235. if ($countPay >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  236. return ['还需个人算力{$num}T', $countPay, $isComplete];
  237. }
  238. /**
  239. * 累计消费金额
  240. * @param int $task_id 任务id
  241. * @param int $uid 用户id
  242. * @param int $start_time 开始时间
  243. * @param int $number 限定时间
  244. * @return boolean
  245. * */
  246. public static function ConsumptionAmount($task_id, $uid = 0, $start_time = 0, $number = 0)
  247. {
  248. $isComplete = false;
  249. $SumPayPrice = StoreOrder::where('paid', 1)->where('refund_status', 0)->where('is_del', 0)->where('uid', $uid)->where('add_time', '>', $start_time)->sum('pay_price');
  250. if ($SumPayPrice >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  251. return ['还需消费{$num}元', $SumPayPrice, $isComplete];
  252. }
  253. /**
  254. * 累计消费次数
  255. * @param int $task_id 任务id
  256. * @param int $uid 用户id
  257. * @param int $start_time 开始时间
  258. * @param int $number 限定时间
  259. * @return boolean
  260. * */
  261. public static function ConsumptionFrequency($task_id, $uid = 0, $start_time = 0, $number = 0)
  262. {
  263. $isComplete = false;
  264. $countPay = StoreOrder::where('paid', 1)->where('refund_status', 0)->where('is_del', 0)->where('uid', $uid)->where('add_time', '>', $start_time)->count();
  265. if ($countPay >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  266. return ['还需消费{$num}次', $countPay, $isComplete];
  267. }
  268. /**
  269. * 邀请好友成为会员
  270. * @param int $task_id 任务id
  271. * @param int $uid 用户id
  272. * @param int $start_time 开始时间
  273. * @param int $number 限定时间
  274. * @return boolean
  275. * */
  276. public static function InviteGoodFriendsLevel($task_id, $uid = 0, $start_time = 0, $number = 0)
  277. {
  278. $isComplete = false;
  279. $uids = User::where('spread_uid', $uid)->where('spread_time', '>', $start_time)->column('uid', 'uid');
  280. $levelCount = count($uids) ? UserLevel::setUserLevelCount($uids) : 0;
  281. if ($levelCount >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  282. return ['还需邀请{$num}人成为会员', $levelCount, $isComplete];
  283. }
  284. /**
  285. * 邀请好友成为下线
  286. * @param int $task_id 任务id
  287. * @param int $uid 用户id
  288. * @param int $start_time 查询开始时间
  289. * @param int $number 限定数量
  290. * */
  291. public static function InviteGoodFriends($task_id, $uid = 0, $start_time = 0, $number = 0)
  292. {
  293. $isComplete = false;
  294. $spreadCount = User::where('spread_uid', $uid)->where('spread_time', '>', $start_time)->count();
  295. if ($spreadCount >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  296. return ['还需邀请{$num}人成为下线', $spreadCount, $isComplete];
  297. }
  298. /**
  299. * 满足积分
  300. * @param int $task_id 任务id
  301. * @param int $uid 用户id
  302. * @param int $start_time 查询开始时间
  303. * @param int $number 限定数量
  304. * @return Boolean
  305. * */
  306. public static function SatisfactionIntegral($task_id, $uid = 0, $start_time = 0, $number = 0)
  307. {
  308. $isComplete = false;
  309. $sumNumber = UserBill::where('uid', $uid)->where('category', 'integral')->where('pm', 1)->where('add_time', '>', $start_time)->where('type', 'in', ['system_add', 'sign', 'gain'])->sum('number');
  310. if ($sumNumber >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  311. return ['还需要{$num}经验', $sumNumber, $isComplete];
  312. }
  313. /**
  314. * 分享给朋友次数完成情况
  315. * @param int $task_id 任务id
  316. * @param int $uid 用户id
  317. * @param int $start_time 查询开始时间
  318. * @param int $number 限定数量
  319. * @return Boolean
  320. * */
  321. public static function SharingTimes($task_id, $uid = 0, $start_time = 0, $number = 0)
  322. {
  323. $isComplete = false;
  324. $sumCount = UserBill::where('uid', $uid)->where('category', 'share')->where('pm', 1)->where('add_time', '>', $start_time)->where('type', 'share')->count();
  325. if ($sumCount >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  326. return ['还需分享{$num}次', $sumCount, $isComplete];
  327. }
  328. /**
  329. * 累计签到
  330. * @param int $task_id 任务id
  331. * @param int $uid 用户id
  332. * @param int $start_time 查询开始时间
  333. * @param int $number 限定数量
  334. * @return Boolean
  335. * */
  336. public static function CumulativeAttendance($task_id, $uid = 0, $start_time = 0, $number = 0)
  337. {
  338. $isComplete = false;
  339. $sumCount = UserBill::where('uid', $uid)->where('category', 'integral')->where('pm', 1)->where('add_time', '>', $start_time)->where('type', 'sign')->count();
  340. if ($sumCount >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  341. return ['还需签到{$num}天', $sumCount, $isComplete];
  342. }
  343. /**
  344. * 大区外累计业绩
  345. * @param $task_id
  346. * @param int $uid
  347. * @param int $start_time
  348. * @param int $number
  349. * @return array
  350. */
  351. public static function OutBiggestSumAchievement($task_id, $uid = 0, $start_time = 0, $number = 0)
  352. {
  353. $isComplete = false;
  354. $uids = User::getAllLowUid($uid);
  355. $SumPayPrice = UserVote::where('uid', 'in', $uids)
  356. ->sum('vote_num');
  357. $SumPayPrice = bcsub($SumPayPrice, User::getBigAreaAchievement($uid), 2);
  358. if ($SumPayPrice >= $number) $isComplete = UserTaskFinish::setFinish($uid, $task_id) ? true : false;
  359. return ['还需累计{$num}', $SumPayPrice, $isComplete];
  360. }
  361. /**
  362. * 设置任务完成情况
  363. * @param int $task_id 任务id
  364. * @param int $uid 用户uid
  365. * @param int $start_time 查询开始时间
  366. * @return Boolean
  367. * */
  368. public static function setTaskFinish($task_id = 0, $uid = 0, $start_time = 0)
  369. {
  370. if (!$task_id) return self::setErrorInfo('缺少任务id参数');
  371. if (!$uid) return self::setErrorInfo('缺少用户uid');
  372. $task = self::where('id', $task_id)->where('is_show', 1)->find();
  373. if (!$task) return self::setErrorInfo('任务不存在');
  374. $task_type = $task->task_type;
  375. if ($task_type && method_exists(self::class, $task_type)) {
  376. try {
  377. $start_time = User::getCleanTime($uid);
  378. return self::$task_type($task_id, $uid, $start_time, $task->number);
  379. } catch (\Exception $e) {
  380. return self::setErrorInfo($e->getMessage());
  381. }
  382. }
  383. return self::setErrorInfo('没有此任务');
  384. }
  385. /**
  386. * 设置任务显示条件
  387. * @param string $alert 表别名
  388. * @param object $model 模型实例
  389. * @return object
  390. * */
  391. public static function visibleWhere($alert = '', $model = null)
  392. {
  393. $model = $model === null ? new self() : $model;
  394. if ($alert) $model = $model->alias($alert);
  395. $alert = $alert ? $alert . '.' : '';
  396. return $model->where("{$alert}is_show", 1);
  397. }
  398. /**
  399. * 获取等级会员任务列表
  400. * @param int $level_id 会员等级id
  401. * @param int $uid 用户id
  402. * @param null $level
  403. * @param int $expire
  404. * @return array
  405. * @throws DataNotFoundException
  406. * @throws DbException
  407. * @throws ModelNotFoundException
  408. */
  409. public static function getTashList($level_id, $uid = 0, $level = null, $expire = 1400)
  410. {
  411. $level_id = is_string($level_id) ? (int)$level_id : $level_id;
  412. $list = self::visibleWhere()->where('level_id', $level_id)->field('name,real_name,task_type,illustrate,number,id')->order('sort desc')->select();
  413. $list = count($list) ? $list->toArray() : [];
  414. if ($uid == 0) return $list;
  415. if ($level === null) $level = SystemUserLevel::getLevelInfo($uid);
  416. //获取下一个vip的id
  417. $LeveId = SystemUserLevel::getNextLevelId($level['id'], SystemUserLevel::setWhere()->where('grade', '>', isset($level['grade']) ? $level['grade'] : 0)->min('grade'));
  418. $is_clear = SystemUserLevel::getClear($level['id']);
  419. if ($is_clear == false && $LeveId == $level_id) $is_clear = true;
  420. $reach_count = self::getTaskComplete($level_id, $uid, true);
  421. return [
  422. 'list' => $list,
  423. 'reach_count' => $reach_count,
  424. 'task' => self::tidyTask($list, $uid, $is_clear, User::getCleanTime($uid)),
  425. ];
  426. }
  427. /**
  428. * 获取未完成任务的详细值
  429. * @param array $item 任务
  430. * @param int $uid 用户id
  431. * @param int $startTime 开始时间
  432. * @return array
  433. * */
  434. protected static function set_task_type($item, $uid, $startTime = 0)
  435. {
  436. $task = ['task_type_title' => '', 'new_number' => 0, 'speed' => 0, 'finish' => 0];
  437. $task_type = $item['task_type'];
  438. switch ($task_type) {
  439. case 'SatisfactionIntegral':
  440. case 'ConsumptionAmount':
  441. case 'ConsumptionFrequency':
  442. case 'CumulativeAttendance':
  443. case 'SharingTimes':
  444. case 'InviteGoodFriends':
  445. case 'InviteGoodFriendsLevel':
  446. try {
  447. list($task_type_title, $num, $isComplete) = self::$task_type($item['id'], $uid, $startTime, $item['number']);
  448. if ($isComplete) {
  449. $task['finish'] = 1;
  450. $task['speed'] = 100;
  451. $task['speed'] = $item['number'];
  452. $task['new_number'] = $item['number'];
  453. } else {
  454. $numdata = bcsub($item['number'], $num, 0);
  455. $task['task_type_title'] = str_replace('{$num}', $numdata, $task_type_title);
  456. $task['speed'] = bcdiv($num, $item['number'], 2);
  457. $task['speed'] = bcmul($task['speed'], 100, 0);
  458. $task['new_number'] = $num;
  459. }
  460. } catch (\Exception $e) {
  461. }
  462. break;
  463. }
  464. return [$task['new_number'], $task['speed'], $task['task_type_title'], $task['finish']];
  465. }
  466. /**
  467. * 设置任务完成状态,已被使用
  468. * @param int $level_id 会员id
  469. * @param int $uid 用户id
  470. * @return Boolean
  471. * */
  472. public static function setTarkStatus($level_id, $uid)
  473. {
  474. $taskIds = self::visibleWhere()->where('level_id', $level_id)->column('id', 'id');
  475. // if (!count($taskIds)) return true;
  476. // return UserTaskFinish::where('uid', $uid)->where('task_id', 'in', $taskIds)->update(['status' => 1]);
  477. $orderIds = UserTaskFinish::where('task_id', 'in', $taskIds)->where('uid', $uid)->where('order_id', '<>', 0)->column('order_id', 'id');
  478. if (!count($taskIds)) return true;
  479. $res = UserTaskFinish::where('uid', $uid)->where('task_id', 'in', $taskIds)->update(['status' => 1]);
  480. if (not_empty_check($orderIds)) {
  481. $update = ['can_refund' => 0];
  482. $res = $res && StoreOrder::where('uid', $uid)->where('id', 'in', $orderIds)->update($update);
  483. }
  484. return $res;
  485. }
  486. /**
  487. * 检查当前等级是否完成全部任务
  488. * @param int $level_id 会员id
  489. * @param int $uid 用户uid
  490. * @return boolean
  491. * */
  492. public static function getTaskComplete($level_id, $uid, $isCount = false)
  493. {
  494. $taskIds = self::visibleWhere()->where('level_id', $level_id)->column('id', 'id');
  495. $taskIdsCount = count($taskIds);
  496. //如果当前会员没有任务默认为直接升级为下一等级
  497. if ($taskIdsCount) {
  498. if ($isCount) {
  499. return UserTaskFinish::group('task_id')->where('uid', $uid)->where('task_id', 'in', $taskIds)->count();
  500. } else {
  501. $finishCount = UserTaskFinish::group('task_id')->where('status', $isCount ? 1 : 0)->where('uid', $uid)->where('task_id', 'in', implode(',', $taskIds))->count();
  502. }
  503. //如果当前任务有完成其一的,查询当前完成的任务数量,如果有任务完成则达成当前vip
  504. if (self::visibleWhere()->where('id', 'in', implode(',', $taskIds))->where('is_must', 0)->count() && $finishCount) {
  505. return true;
  506. }
  507. return $finishCount >= $taskIdsCount;
  508. }
  509. if ($isCount) return 0;
  510. //如果没有设置任务当前等级无需购买则返回false
  511. if (SystemUserLevel::be(['id' => $level_id, 'is_pay' => 0])) return false;
  512. return true;
  513. }
  514. /**
  515. * 设置任务内容完成情况
  516. * @param array $task 任务列表
  517. * @param int $uid 用户id
  518. * @热图图呢 array
  519. * */
  520. public static function tidyTask($task, $uid, $is_clear, $startTime)
  521. {
  522. if (!is_array($task)) return $task;
  523. foreach ($task as &$item) {
  524. //如果已完成该任务进度直接为100
  525. if (UserTaskFinish::where('uid', $uid)->where('task_id', $item['id'])->count()) {
  526. $item['new_number'] = $item['number'];
  527. $item['speed'] = 100;
  528. $item['finish'] = 1;
  529. $item['task_type_title'] = '';
  530. } else {
  531. // if($is_clear){
  532. list($new_number, $speed, $task_type_title, $finish) = self::set_task_type($item, $uid, $startTime);
  533. $item['new_number'] = $new_number;
  534. $item['speed'] = $speed;
  535. $item['task_type_title'] = $task_type_title;
  536. $item['finish'] = $finish;
  537. // }else {
  538. // list($new_number, $speed, $task_type_title, $finish) = self::set_task_type($item,-1,time()+86400);
  539. // $item['new_number'] = $new_number;
  540. // $item['speed'] = $speed;
  541. // $item['task_type_title'] = $task_type_title;
  542. // $item['finish'] = $finish;
  543. // }
  544. }
  545. }
  546. return $task;
  547. }
  548. }