|
|
@@ -12,6 +12,7 @@ use common\components\noticeUtil;
|
|
|
use common\components\printUtil;
|
|
|
use common\components\ChuanglanSmsApi;
|
|
|
use common\components\util;
|
|
|
+use Overtrue\ChineseCalendar\Calendar;
|
|
|
use PhpAmqpLib\Wire\AMQPTable;
|
|
|
use Yii;
|
|
|
use yii\db\IntegrityException;
|
|
|
@@ -114,15 +115,35 @@ class BirthdayGiftClass extends BaseClass
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public static function formatBirthdayDisplay($custom)
|
|
|
+ public static function convertBirthdayMonthDay($lunar, $birthdayMonth, $birthdayDate, $year = null)
|
|
|
+ {
|
|
|
+ $birthdayMonth = intval($birthdayMonth);
|
|
|
+ $birthdayDate = intval($birthdayDate);
|
|
|
+ if (intval($lunar) != 1) {
|
|
|
+ return [$birthdayMonth, $birthdayDate];
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ $calendar = new Calendar();
|
|
|
+ $result = $calendar->lunar($year ?: date('Y'), $birthdayMonth, $birthdayDate);
|
|
|
+ } catch (\InvalidArgumentException $e) {
|
|
|
+ util::fail($e->getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return [intval($result['gregorian_month']), intval($result['gregorian_day'])];
|
|
|
+ }
|
|
|
+
|
|
|
+ public static function formatBirthdayDisplay($custom, $birthdayMonth, $birthdayDate)
|
|
|
{
|
|
|
$m = intval($custom->birthdayMonth ?? 0);
|
|
|
$d = intval($custom->birthdayDate ?? 0);
|
|
|
if ($m <= 0 || $d <= 0) {
|
|
|
return '';
|
|
|
}
|
|
|
- $prefix = intval($custom->lunar ?? 0) == 1 ? '农历 ' : '';
|
|
|
- return $prefix . $m . '月' . $d . '日';
|
|
|
+ if (intval($custom->lunar ?? 0) == 1) {
|
|
|
+ return $birthdayMonth . '月' . $birthdayDate . '日' . ' (农历 ' . $m . '月' . $d . '日)';
|
|
|
+ }
|
|
|
+ return $m . '月' . $d . '日';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -281,6 +302,12 @@ class BirthdayGiftClass extends BaseClass
|
|
|
$hdId = $hd->id ?? 0;
|
|
|
$birthdayTime = intval($custom->birthdayTime);
|
|
|
$status = $birthdayTime > 0 ? self::STATUS_PENDING_NOTIFY : self::STATUS_NO_BIRTHDAY;
|
|
|
+ list($birthdayMonth, $birthdayDate) = self::convertBirthdayMonthDay(
|
|
|
+ $custom->lunar,
|
|
|
+ $custom->birthdayMonth,
|
|
|
+ $custom->birthdayDate,
|
|
|
+ $year
|
|
|
+ );
|
|
|
$data = [
|
|
|
'mainId' => $mainId,
|
|
|
'shopId' => $shopId,
|
|
|
@@ -291,10 +318,10 @@ class BirthdayGiftClass extends BaseClass
|
|
|
'member' => $member,
|
|
|
'memberName' => $custom->memberName ?? '',
|
|
|
'giftName' => $giftName,
|
|
|
- 'birthdayMonth' => intval($custom->birthdayMonth),
|
|
|
- 'birthdayDate' => intval($custom->birthdayDate),
|
|
|
+ 'birthdayMonth' => $birthdayMonth,
|
|
|
+ 'birthdayDate' => $birthdayDate,
|
|
|
'lunar' => intval($custom->lunar),
|
|
|
- 'birthdayDisplay' => self::formatBirthdayDisplay($custom),
|
|
|
+ 'birthdayDisplay' => self::formatBirthdayDisplay($custom, birthdayMonth, birthdayDate),
|
|
|
];
|
|
|
if (empty($gift)) {
|
|
|
$data['status'] = $status;
|