shish 11 miesięcy temu
rodzic
commit
4760d5a02e

+ 30 - 13
app-hd/controllers/CustomController.php

@@ -83,19 +83,36 @@ class CustomController extends BaseController
         }
         $birthdayTime = strtotime($birthday);
 
-        $custom->lunar = $lunar;
-        $custom->birthdayDate = $birthdayDate;
-        $custom->birthdayMonth = $birthdayMonth;
-        $custom->birthday = $birthday;
-        $custom->birthdayTime = $birthdayTime;
-        $custom->save();
-
-        $user->lunar = $lunar;
-        $user->birthdayDate = $birthdayDate;
-        $user->birthdayMonth = $birthdayMonth;
-        $user->birthday = $birthday;
-        $user->birthdayTime = $birthdayTime;
-        $user->save();
+        if ($user->birthdaySet == 0) {
+            //用户自己没有设置过生日,直接改
+            $custom->lunar = $lunar;
+            $custom->birthdayDate = $birthdayDate;
+            $custom->birthdayMonth = $birthdayMonth;
+            $custom->birthday = $birthday;
+            $custom->birthdayTime = $birthdayTime;
+            $custom->save();
+
+            $user->lunar = $lunar;
+            $user->birthdayDate = $birthdayDate;
+            $user->birthdayMonth = $birthdayMonth;
+            $user->birthday = $birthday;
+            $user->birthdayTime = $birthdayTime;
+            $user->save();
+        } else {
+            //用户设置过,按用户设置的生日来走
+            $lunar = $user->lunar;
+            $birthdayDate = $user->birthdayDate;
+            $birthdayMonth = $user->birthdayMonth;
+            $birthday = $user->birthday;
+            $birthdayTime = $user->birthdayTime;
+
+            $custom->lunar = $lunar;
+            $custom->birthdayDate = $birthdayDate;
+            $custom->birthdayMonth = $birthdayMonth;
+            $custom->birthday = $birthday;
+            $custom->birthdayTime = $birthdayTime;
+            $custom->save();
+        }
         util::complete('修改成功');
     }
 

+ 14 - 6
app-mall/controllers/UserController.php

@@ -9,6 +9,7 @@ use bizMall\user\classes\UserClass;
 use bizMall\user\services\UserAssetService;
 use bizMall\user\services\UserService;
 use common\components\dict;
+use common\components\imgUtil;
 use common\components\jwt;
 use common\components\stringUtil;
 use Yii;
@@ -19,7 +20,7 @@ class UserController extends BaseController
 {
 
     //二维码收款使用
-    public $guestAccess = ['discount', 'mini-mobile', 'create','account-login'];
+    public $guestAccess = ['discount', 'mini-mobile', 'create', 'account-login'];
 
     //清空登录信息 ssh 20250215
     public function actionClearLogin()
@@ -51,10 +52,17 @@ class UserController extends BaseController
     public function actionCurrentInfo()
     {
         $user = $this->user;
-        // 将 $user 转换为数组,然后添加 hasMap 属性(字典中的 hasMap)
-        $user = $user->toArray();
-        $user['hasMap'] = dict::getDict('hasMap');
-        
+        if (!empty($user)) {
+            // 将 $user 转换为数组,然后添加 hasMap 属性(字典中的 hasMap)
+            $user = $user->toArray();
+            $user['hasMap'] = dict::getDict('hasMap');
+            $shortAvatar = $user['avatar'] ?? '';
+            $smallAvatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
+            $avatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
+            $user['avatar'] = $avatar;
+            $user['smallAvatar'] = $smallAvatar;
+            $user['shortAvatar'] = $shortAvatar;
+        }
         util::success(['info' => $user]);
     }
 
@@ -95,7 +103,7 @@ class UserController extends BaseController
         $fullUser = UserClass::getById($userId, true);
 
         // 将 $fullUser 转换为数组,然后添加 hasMap 属性(字典中的 hasMap)
-        $fullUser =$fullUser->toArray();
+        $fullUser = $fullUser->toArray();
         $fullUser['hasMap'] = dict::getDict('hasMap');
 
         util::success(['user' => $fullUser, 'token' => $token]);