|
|
@@ -15,6 +15,7 @@ use common\components\stringUtil;
|
|
|
use Yii;
|
|
|
use common\components\util;
|
|
|
use yii\helpers\Json;
|
|
|
+use Overtrue\ChineseCalendar\Calendar;
|
|
|
|
|
|
class UserController extends BaseController
|
|
|
{
|
|
|
@@ -48,6 +49,67 @@ class UserController extends BaseController
|
|
|
util::complete();
|
|
|
}
|
|
|
|
|
|
+ //修改生日 ssh 20250830
|
|
|
+ public function actionModifyBirthday()
|
|
|
+ {
|
|
|
+ date_default_timezone_set('PRC');
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $lunar = $get['lunar'] ?? 0;
|
|
|
+ $birthdayMonth = $get['birthdayMonth'] ?? 1;
|
|
|
+ if ($birthdayMonth > 12 || $birthdayMonth < 1) {
|
|
|
+ util::fail('月份必须1到12月');
|
|
|
+ }
|
|
|
+ $birthdayDate = $get['birthdayDate'] ?? 1;
|
|
|
+ if ($birthdayDate > 31 || $birthdayDate < 1) {
|
|
|
+ util::fail('日期必须1到31号');
|
|
|
+ }
|
|
|
+ if ($lunar == 1 && $birthdayDate == 31) {
|
|
|
+ util::fail('农历没有31号');
|
|
|
+ }
|
|
|
+ $user = $this->user;
|
|
|
+ if ($user->birthdaySet == 1) {
|
|
|
+ util::fail('你已经设置过了');
|
|
|
+ }
|
|
|
+
|
|
|
+ $calendar = new Calendar();
|
|
|
+ if ($lunar == 1) {
|
|
|
+ try {
|
|
|
+ $result = $calendar->lunar(date("Y"), $birthdayMonth, $birthdayDate);
|
|
|
+ } catch (\InvalidArgumentException $e) {
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ util::fail($msg);
|
|
|
+ }
|
|
|
+ $month = $result['gregorian_month'] ?? 1;
|
|
|
+ $date = $result['gregorian_day'] ?? 1;
|
|
|
+ $birthday = date("Y") . '-' . $month . '-' . $date;
|
|
|
+ } else {
|
|
|
+ $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
|
|
|
+ }
|
|
|
+ $birthdayTime = strtotime($birthday);
|
|
|
+
|
|
|
+
|
|
|
+ $user->lunar = $lunar;
|
|
|
+ $user->birthdayDate = $birthdayDate;
|
|
|
+ $user->birthdayMonth = $birthdayMonth;
|
|
|
+ $user->birthday = $birthday;
|
|
|
+ $user->birthdayTime = $birthdayTime;
|
|
|
+ $user->birthdaySet = 1;
|
|
|
+ $user->save();
|
|
|
+ $userId = $user->id;
|
|
|
+ $customList = \bizMall\custom\classes\CustomClass::getAllByCondition(['userId' => $userId], null, '*', null, true);
|
|
|
+ if (!empty($customList)) {
|
|
|
+ foreach ($customList as $custom) {
|
|
|
+ $custom->lunar = $lunar;
|
|
|
+ $custom->birthdayDate = $birthdayDate;
|
|
|
+ $custom->birthdayMonth = $birthdayMonth;
|
|
|
+ $custom->birthday = $birthday;
|
|
|
+ $custom->birthdayTime = $birthdayTime;
|
|
|
+ $custom->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::complete('修改成功');
|
|
|
+ }
|
|
|
+
|
|
|
//获取当前登录用户的信息 ssh 20221014
|
|
|
public function actionCurrentInfo()
|
|
|
{
|