Kirin 1 год назад
Родитель
Сommit
c1d3b347e9

+ 2 - 1
app/controller/admin/v1/system/SystemTimer.php

@@ -60,7 +60,8 @@ class SystemTimer extends AuthController
             'rebate_points_orders' => '未支付积分订单退积分',
             'code_not_operating' => '桌码长期未操作取消桌码记录',
             'collate_not_operating' => '拼单长期未操作取消拼单记录',
-            'reminder_unverified_remind' => '次卡商品未核销短信提醒'
+            'reminder_unverified_remind' => '次卡商品未核销短信提醒',
+            'area_award' => '定时发放分红'
         ];
         return $this->success($data);
     }

+ 32 - 18
app/listener/system/timer/SystemTimer.php

@@ -56,29 +56,29 @@ class SystemTimer extends Cron implements ListenerInterface
             }
             $list = $timerServices->cacheList();
             foreach ($list as $item) {
-				$mark = (string)($item['mark'] ?? '');
+                $mark = (string)($item['mark'] ?? '');
                 if (!$mark || !isset($item['is_open'])) {
-					\think\facade\Log::error('定时任务数据异常,数据:' . json_encode($item));
-					continue;
-				}
-				if ($item['is_open'] == 1) {
-					$data = $timerServices->getTimerCycleTime($item['type'], $item['cycle'], $time, $item['update_execution_time']);
-					if ($time == $data['cycle_time']) {
-						$this->after(1000, function () use ($timerServices, $mark, $time) {
-							$timerServices->cacheTag()->set($mark, $time);//上次执行时间保存
-							$this->implement_timer($mark);
-						});
-					}
-				}
+                    \think\facade\Log::error('定时任务数据异常,数据:' . json_encode($item));
+                    continue;
+                }
+                if ($item['is_open'] == 1) {
+                    $data = $timerServices->getTimerCycleTime($item['type'], $item['cycle'], $time, $item['update_execution_time']);
+                    if ($time == $data['cycle_time']) {
+                        $this->after(1000, function () use ($timerServices, $mark, $time) {
+                            $timerServices->cacheTag()->set($mark, $time);//上次执行时间保存
+                            $this->implement_timer($mark);
+                        });
+                    }
+                }
             }
         });
     }
 
-	/**
-	 * 执行定时任务
-	 * @param string $mark
-	 * @return bool|void
-	 */
+    /**
+     * 执行定时任务
+     * @param string $mark
+     * @return bool|void
+     */
     public function implement_timer(string $mark)
     {
         switch ($mark) {
@@ -345,6 +345,20 @@ class SystemTimer extends Cron implements ListenerInterface
                     ]);
                 }
                 break;
+            case 'area_award' : // 定时发放分红失败
+                /** @var StoreOrderServices $service */
+                $service = app()->make(StoreOrderServices::class);
+                try {
+                    return $service->backAreaBrokerage();
+                } catch (\Throwable $e) {
+                    response_log_write([
+                        'message' => '定时发放分红失败:' . $e->getMessage(),
+                        'file' => $e->getFile(),
+                        'line' => $e->getLine()
+                    ]);
+                }
+                break;
+
         }
     }
 }