|
@@ -3,6 +3,8 @@
|
|
|
namespace bizHd\custom\observers;
|
|
namespace bizHd\custom\observers;
|
|
|
|
|
|
|
|
use bizHd\custom\classes\CustomClass;
|
|
use bizHd\custom\classes\CustomClass;
|
|
|
|
|
+use bizHd\custom\classes\HdClass;
|
|
|
|
|
+use bizHd\shop\classes\ShopClass;
|
|
|
use bizHd\user\classes\UserIntegralClass;
|
|
use bizHd\user\classes\UserIntegralClass;
|
|
|
use yii\base\Behavior;
|
|
use yii\base\Behavior;
|
|
|
use yii\db\ActiveRecord;
|
|
use yii\db\ActiveRecord;
|
|
@@ -81,17 +83,31 @@ class BuyAmountObserver extends Behavior
|
|
|
|
|
|
|
|
|
|
|
|
|
$mainId = $model->mainId;
|
|
$mainId = $model->mainId;
|
|
|
- if ($mainId > 0) {
|
|
|
|
|
- $memberData = CustomClass::getCustomExpenseLevel($newGrowth, $mainId); // 设置等级多处需要同步修改的,请搜索:getCustomExpenseLevel
|
|
|
|
|
- $model::updateAll([
|
|
|
|
|
- 'member' => (int) ($memberData['level'] ?? 0),
|
|
|
|
|
- 'memberName' => (string) ($memberData['name'] ?? ''),
|
|
|
|
|
- 'discount' => bcdiv(floatval($memberData['discount']), 10, 2)
|
|
|
|
|
- ], ['id' => $model->getPrimaryKey()]);
|
|
|
|
|
- }else{
|
|
|
|
|
- throw new \Exception('mainId is required');
|
|
|
|
|
|
|
+ //历史遗留问题,如果没有mainId的,要补mainId ssh 20260818
|
|
|
|
|
+ if (empty($mainId)) {
|
|
|
|
|
+ $shopId = $model->shopId ?? 0;
|
|
|
|
|
+ $shopInfo = ShopClass::getById($shopId);
|
|
|
|
|
+ $mainId = $shopInfo['mainId'] ?? 0;
|
|
|
|
|
+ if (empty($mainId)) {
|
|
|
|
|
+ throw new \Exception('mainId is required');
|
|
|
|
|
+ }
|
|
|
|
|
+ $model->mainId = $mainId;
|
|
|
|
|
+ $model->save();
|
|
|
|
|
+ $hdId = $model->hdId ?? 0;
|
|
|
|
|
+ $hdInfo = HdClass::getById($hdId, true);
|
|
|
|
|
+ if(!empty($hdInfo)){
|
|
|
|
|
+ $hdInfo->mainId = $mainId;
|
|
|
|
|
+ $hdInfo->save();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $memberData = CustomClass::getCustomExpenseLevel($newGrowth, $mainId); // 设置等级多处需要同步修改的,请搜索:getCustomExpenseLevel
|
|
|
|
|
+ $model::updateAll([
|
|
|
|
|
+ 'member' => (int) ($memberData['level'] ?? 0),
|
|
|
|
|
+ 'memberName' => (string) ($memberData['name'] ?? ''),
|
|
|
|
|
+ 'discount' => bcdiv(floatval($memberData['discount']), 10, 2)
|
|
|
|
|
+ ], ['id' => $model->getPrimaryKey()]);
|
|
|
|
|
+
|
|
|
if ($buyAmountDelta == 0 || $buyAmountDelta == 0.00) {
|
|
if ($buyAmountDelta == 0 || $buyAmountDelta == 0.00) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|