shish преди 2 години
родител
ревизия
4ebeba95ed
променени са 1 файла, в които са добавени 27 реда и са изтрити 6 реда
  1. 27 6
      app-ghs/controllers/RenewController.php

+ 27 - 6
app-ghs/controllers/RenewController.php

@@ -23,19 +23,40 @@ class RenewController extends BaseController
     //需要续费 ssh 20240426
     public function actionNeedRemind()
     {
-        //注册满半年以上
+        $need = 1;
+        $shop = $this->shop;
+        if ($shop->needRenew == 0) {
+            $need = 0;
+        }
+        if ($shop->hasRenew == 1) {
+            $need = 0;
+        }
 
-        //标记为需要续费的批发店,并且没有续费过的
+        $date = date("Y_m_d");
+        $staff = $this->shopAdmin;
+        $staffId = $staff->id ?? 0;
+        $cacheKey = 'no_remind_' . $date . '_' . $staffId;
+        $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+        if (!empty($has)) {
+            $need = 0;
+        }
+        $deadline = $shop->deadline ?? '';
+        $newTime = bcadd(strtotime($deadline), 31536000);
+        $newDeadline = date("Y-m-d H:i:s", $newTime);
 
-        //当前员工当天没有提醒过的
-        $currentDeadline = '2024-04-27';
-        $newDeadline = '2025-04-27';
-        util::success(['need' => 1, 'currentDeadline' => $currentDeadline, 'newDeadline' => $newDeadline]);
+        $old = substr($deadline, 0, 11);
+        $new = substr($newDeadline, 0, 11);
+        util::success(['need' => $need, 'currentDeadline' => $old, 'newDeadline' => $new]);
     }
 
     //当天不需要再提醒 ssh 20240426
     public function actionNoRemind()
     {
+        $date = date("Y_m_d");
+        $staff = $this->shopAdmin;
+        $staffId = $staff->id ?? 0;
+        $cacheKey = 'no_remind_' . $date . '_' . $staffId;
+        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 86400, 'has']);
         util::complete();
     }