shish 10 hónapja
szülő
commit
32a5a86bbe

+ 36 - 0
app-mall/controllers/UserController.php

@@ -11,6 +11,7 @@ use bizMall\user\services\UserService;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\jwt;
+use common\components\noticeUtil;
 use common\components\stringUtil;
 use Yii;
 use common\components\util;
@@ -124,6 +125,41 @@ class UserController extends BaseController
             $user['smallAvatar'] = $smallAvatar;
             $user['shortAvatar'] = $shortAvatar;
         }
+
+        $birthday = $user->birthday ?? '';
+        //如果当年的生日时间没有更新,则需要给更新
+        $year = date("Y", strtotime($birthday));
+        $thisYear = date("Y");
+        if ($year != $thisYear) {
+            $lunar = $user->lunar ?? 0;
+            $userId = $this->userId;
+            $birthdayMonth = $user->birthdayMonth ?? 0;
+            $birthdayDate = $user->birthdayDate ?? 0;
+            if ($lunar == 1) {
+                try {
+                    //农历转阳历,有多处使用,需要同步修改,关键词change_my_birthday
+                    $calendar = new Calendar();
+                    $result = $calendar->lunar(date("Y"), $birthdayMonth, $birthdayDate);
+                    $month = $result['gregorian_month'] ?? 1;
+                    $date = $result['gregorian_day'] ?? 1;
+                    $birthday = date("Y") . '-' . $month . '-' . $date;
+                    $user->birthday = $birthday;
+                    $user->save();
+                    CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
+                } catch (\InvalidArgumentException $e) {
+                    $msg = $e->getMessage();
+                    noticeUtil::push("更新生日出错了呢,userId:" . $userId . ' ' . $msg, '15280215347');
+                    $birthday = '0000-00-00 00:00:00';
+                }
+            } else {
+                $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
+                $user->birthday = $birthday;
+                $user->save();
+                CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
+            }
+        }
+
+
         $hasMap = dict::getDict('hasMap');
         $user['hasMap'] = $hasMap;
         util::success(['info' => $user]);

+ 4 - 0
biz-hd/custom/classes/CustomClass.php

@@ -693,6 +693,8 @@ class CustomClass extends BaseClass
                             $month = $result['gregorian_month'] ?? 1;
                             $date = $result['gregorian_day'] ?? 1;
                             $birthday = date("Y") . '-' . $month . '-' . $date;
+                            $user->birthday = $birthday;
+                            $user->save();
                             CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
                         } catch (\InvalidArgumentException $e) {
                             $msg = $e->getMessage();
@@ -701,6 +703,8 @@ class CustomClass extends BaseClass
                         }
                     } else {
                         $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
+                        $user->birthday = $birthday;
+                        $user->save();
                         CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
                     }
                 }