|
|
@@ -6,6 +6,7 @@ use biz\wx\classes\WxMessageClass;
|
|
|
use bizHd\balance\classes\BalanceChangeClass;
|
|
|
use bizHd\balance\classes\BalanceGiveChangeClass;
|
|
|
use bizHd\balance\classes\BalancePayChangeClass;
|
|
|
+use bizHd\birthday\classes\BirthdayGiftClass;
|
|
|
use bizHd\member\classes\MemberChangeClass;
|
|
|
use bizHd\member\classes\MemberLevelClass;
|
|
|
use bizHd\order\classes\OrderClass;
|
|
|
@@ -77,7 +78,7 @@ class CustomClass extends BaseClass
|
|
|
if (getenv('YII_ENV') != 'dev' && $user->birthdaySet == 1) {
|
|
|
util::fail('客户已填写,不能修改');
|
|
|
}
|
|
|
- //用户自己没有设置过生日,直接改
|
|
|
+
|
|
|
$custom->lunar = $lunar;
|
|
|
$custom->birthdayDate = $birthdayDate;
|
|
|
$custom->birthdayMonth = $birthdayMonth;
|
|
|
@@ -91,6 +92,22 @@ class CustomClass extends BaseClass
|
|
|
$user->birthday = $birthday;
|
|
|
$user->birthdayTime = $birthdayTime;
|
|
|
$user->save();
|
|
|
+
|
|
|
+ // 同步变更生日赠礼记录表(xhBirthdayGift)中的数据(只更新当年年份的,往年的不去修改)
|
|
|
+ $birthdayGift = BirthdayGiftClass::getByCondition(['userId'=>$user->id, 'shopId'=>$shopId, 'year'=>date("Y")], true);
|
|
|
+ if (!empty($birthdayGift)) {
|
|
|
+ list($giftBirthdayMonth, $giftBirthdayDate) = BirthdayGiftClass::convertBirthdayMonthDay(
|
|
|
+ $lunar,
|
|
|
+ $birthdayMonth,
|
|
|
+ $birthdayDate
|
|
|
+ );
|
|
|
+ $birthdayGift->lunar = $lunar;
|
|
|
+ $birthdayGift->birthdayMonth = $giftBirthdayMonth;
|
|
|
+ $birthdayGift->birthdayDate = $giftBirthdayDate;
|
|
|
+ $birthdayGift->birthdayDisplay = BirthdayGiftClass::formatBirthdayDisplay($custom, $giftBirthdayMonth, $giftBirthdayDate);
|
|
|
+ $birthdayGift->save();
|
|
|
+ }
|
|
|
+
|
|
|
return $custom;
|
|
|
}
|
|
|
|
|
|
@@ -266,7 +283,7 @@ class CustomClass extends BaseClass
|
|
|
$current = $levelData[$newLevel] ?? [];
|
|
|
$before = $levelData[$oldLevel] ?? [];
|
|
|
$beforeName = $before['name'] ?? '普通客户';
|
|
|
- $discount = $current['discount'] ?? 1;
|
|
|
+ $discount = $current['discount'] ?? 10;
|
|
|
$memberName = $current['name'] ?? '';
|
|
|
$oldGrowth = $custom->growth;
|
|
|
|
|
|
@@ -963,8 +980,8 @@ class CustomClass extends BaseClass
|
|
|
{
|
|
|
$shopId = $data['shopId'];
|
|
|
$mainId = $data['mainId'];
|
|
|
- $customs = self::getAllByCondition(['shopId' => $shopId], null, 'id, name, hdId, userId, buyAmount, growth, member, memberName', null, true);
|
|
|
- $levelDatas = MemberLevelClass::getAllByCondition(['mainId' => $mainId], 'amount DESC', 'id, name, level, amount');
|
|
|
+ $customs = self::getAllByCondition(['shopId' => $shopId], null, 'id, name, hdId, userId, buyAmount, growth, member, memberName, discount', null, true);
|
|
|
+ $levelDatas = MemberLevelClass::getAllByCondition(['mainId' => $mainId], 'amount DESC', 'id, name, level, amount, discount');
|
|
|
if (!empty($customs) && !empty($levelDatas)) {
|
|
|
foreach ($customs as $c) {
|
|
|
// $buyAmount = 0;
|
|
|
@@ -979,9 +996,7 @@ class CustomClass extends BaseClass
|
|
|
|
|
|
// 根据 growth 设置等级
|
|
|
$memberData = self::getCustomExpenseLevel($c->growth, $mainId, $levelDatas); // 设置等级多处需要同步修改的,请搜索:getCustomExpenseLevel
|
|
|
- $newMember = intval($memberData['level']);
|
|
|
- $customMember = $c->member;
|
|
|
- if ($customMember != $newMember) {
|
|
|
+ if ($c->member != $memberData['level'] || $c->memberName != $memberData['name']) {
|
|
|
$hdId = $c->hdId;
|
|
|
$hd = HdClass::getById($hdId, true);
|
|
|
|
|
|
@@ -1007,10 +1022,20 @@ class CustomClass extends BaseClass
|
|
|
'staffName' => '',
|
|
|
];
|
|
|
MemberChangeClass::add($change);
|
|
|
+ }
|
|
|
+ $c->member = $memberData['level'];
|
|
|
+ $c->memberName = $memberData['name'];
|
|
|
+ $c->discount = bcdiv(floatval($memberData['discount']), 10, 1);
|
|
|
+ $c->save();
|
|
|
|
|
|
- $c->member = $memberData['level'];
|
|
|
- $c->memberName = $memberData['name'];
|
|
|
- $c->save();
|
|
|
+ if (!empty($c->hdId)) {
|
|
|
+ $hd = HdClass::getById($c->hdId, true);
|
|
|
+ if (!empty($hd)) {
|
|
|
+ $hd->member = $memberData['level'];
|
|
|
+ $hd->memberName = $memberData['name'];
|
|
|
+ $hd->discount = $newDiscount;
|
|
|
+ $hd->save();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 更新客户所对应花店的消费金额
|
|
|
@@ -1024,7 +1049,7 @@ class CustomClass extends BaseClass
|
|
|
public static function getCustomExpenseLevel($growth, $mainId, $levelDatas=[])
|
|
|
{
|
|
|
if (empty($levelDatas)) {
|
|
|
- $levelDatas = MemberLevelClass::getAllByCondition(['mainId' => $mainId], 'amount DESC', 'id, name, level, amount');
|
|
|
+ $levelDatas = MemberLevelClass::getAllByCondition(['mainId' => $mainId], 'amount DESC', 'id, name, level, amount, discount');
|
|
|
}
|
|
|
foreach ($levelDatas as $data) {
|
|
|
if ($growth >= $data['amount']) {
|
|
|
@@ -1032,6 +1057,6 @@ class CustomClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return ['level'=>0, 'name'=>''];
|
|
|
+ return ['level'=>0, 'name'=>'', 'discount'=>10];
|
|
|
}
|
|
|
}
|