|
|
@@ -11,6 +11,7 @@ use bizHd\member\classes\MemberLevelClass;
|
|
|
use bizHd\order\classes\OrderClass;
|
|
|
use bizHd\order\classes\SettleClass;
|
|
|
use bizHd\shop\classes\ShopClass;
|
|
|
+use bizHd\user\classes\UserClass;
|
|
|
use bizHd\user\classes\UserGrowthClass;
|
|
|
use common\components\dict;
|
|
|
use common\components\imgUtil;
|
|
|
@@ -25,6 +26,74 @@ class CustomClass extends BaseClass
|
|
|
|
|
|
public static $baseFile = '\bizHd\custom\models\Custom';
|
|
|
|
|
|
+ //修改客户生日 ssh 20250814
|
|
|
+ public static function modifyBirthday($customId, $shopId, $params)
|
|
|
+ {
|
|
|
+ date_default_timezone_set('PRC');
|
|
|
+
|
|
|
+ $custom = self::getById($customId, true);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('没有找到客户');
|
|
|
+ }
|
|
|
+ if ($custom->shopId != $shopId) {
|
|
|
+ util::fail('不是你的客户');
|
|
|
+ }
|
|
|
+ $lunar = $params['lunar'] ?? 0;
|
|
|
+ $birthdayMonth = $params['birthdayMonth'] ?? 1;
|
|
|
+ if ($birthdayMonth > 12 || $birthdayMonth < 1) {
|
|
|
+ util::fail('月份必须1到12月');
|
|
|
+ }
|
|
|
+ $birthdayDate = $params['birthdayDate'] ?? 1;
|
|
|
+ if ($birthdayDate > 31 || $birthdayDate < 1) {
|
|
|
+ util::fail('日期必须1到31号');
|
|
|
+ }
|
|
|
+
|
|
|
+ $userId = $custom->userId;
|
|
|
+ $user = UserClass::getById($userId, true);
|
|
|
+ if (empty($user)) {
|
|
|
+ util::fail('客户信息缺失');
|
|
|
+ }
|
|
|
+ if ($lunar == 1 && $birthdayDate == 31) {
|
|
|
+ util::fail('农历没有31号');
|
|
|
+ }
|
|
|
+
|
|
|
+ $calendar = new Calendar();
|
|
|
+ if ($lunar == 1) {
|
|
|
+ try {
|
|
|
+ $result = $calendar->lunar(date("Y"), $birthdayMonth, $birthdayDate);
|
|
|
+ } catch (\InvalidArgumentException $e) {
|
|
|
+ $msg = $e->getMessage();
|
|
|
+ util::fail($msg);
|
|
|
+ }
|
|
|
+ //农历转阳历,有多处使用,需要同步修改,关键词 change_my_birthday
|
|
|
+ $month = $result['gregorian_month'] ?? 1;
|
|
|
+ $date = $result['gregorian_day'] ?? 1;
|
|
|
+ $birthday = date("Y") . '-' . $month . '-' . $date;
|
|
|
+ } else {
|
|
|
+ $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
|
|
|
+ }
|
|
|
+ $birthdayTime = strtotime($birthday);
|
|
|
+
|
|
|
+ if (getenv('YII_ENV') != 'dev' && $user->birthdaySet == 1) {
|
|
|
+ util::fail('客户已填写,不能修改');
|
|
|
+ }
|
|
|
+ //用户自己没有设置过生日,直接改
|
|
|
+ $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();
|
|
|
+ return $custom;
|
|
|
+ }
|
|
|
+
|
|
|
//用余额支付,客户余额减少 ssh 20250410
|
|
|
public static function payToChangeBalance($order)
|
|
|
{
|
|
|
@@ -965,4 +1034,4 @@ class CustomClass extends BaseClass
|
|
|
|
|
|
return ['level'=>0, 'name'=>''];
|
|
|
}
|
|
|
-}
|
|
|
+}
|