SystemUserTask.php 22 KB

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