|
|
@@ -14,8 +14,10 @@ use bizHd\order\classes\SettleClass;
|
|
|
use bizHd\shop\classes\ShopClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
+use common\components\noticeUtil;
|
|
|
use common\components\stringUtil;
|
|
|
use common\components\util;
|
|
|
+use Overtrue\ChineseCalendar\Calendar;
|
|
|
use Yii;
|
|
|
use bizHd\base\classes\BaseClass;
|
|
|
|
|
|
@@ -673,17 +675,40 @@ class CustomClass extends BaseClass
|
|
|
];
|
|
|
$birthdaySet = $user->birthdaySet ?? 0;
|
|
|
if ($birthdaySet == 1) {
|
|
|
- //如果当年的生日时间没有更新,则需要给更新
|
|
|
-
|
|
|
//如果用户自己设置过了生日,则生日给传过去
|
|
|
+ $lunar = $user->lunar ?? 0;
|
|
|
$birthday = $user->birthday ?? '';
|
|
|
$birthdayTime = $user->birthdayTime ?? 0;
|
|
|
$birthdayMonth = $user->birthdayMonth ?? 0;
|
|
|
$birthdayDate = $user->birthdayDate ?? 0;
|
|
|
+ //如果当年的生日时间没有更新,则需要给更新
|
|
|
+ $year = date("Y", strtotime($birthday));
|
|
|
+ $thisYear = date("Y");
|
|
|
+ if ($year != $thisYear) {
|
|
|
+ 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;
|
|
|
+ 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;
|
|
|
+ CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
|
|
|
+ }
|
|
|
+ }
|
|
|
$data['birthday'] = $birthday;
|
|
|
$data['birthdayTime'] = $birthdayTime;
|
|
|
$data['birthdayMonth'] = $birthdayMonth;
|
|
|
$data['birthdayDate'] = $birthdayDate;
|
|
|
+ $data['lunar'] = $lunar;
|
|
|
}
|
|
|
$custom = self::addCustom($data);
|
|
|
$isNewCustom = 1;
|