6
0
Fork 0

移除预成长值

release
李静 2022-04-27 14:37:32 +08:00
parent 221d1bcda7
commit 6c2dd35acb
6 changed files with 0 additions and 76 deletions

View File

@ -102,7 +102,6 @@ class OrderSettleCommand extends Command
// 更新下单用户的成长值和预成长值
$order->user->userInfo()->update([
'growth_value' => DB::raw("growth_value+{$salesValue}"),
'pre_growth_value' => DB::raw("pre_growth_value-{$salesValue}"),
]);
// 下单用户的销售值日志

View File

@ -58,7 +58,6 @@ class UserInfo extends Model
'quota_v1',
'quota_v2',
'growth_value',
'pre_growth_value',
'group_sales_value',
'real_inviter_id',
];
@ -383,38 +382,6 @@ class UserInfo extends Model
]);
}
/**
* 变更预收益成长值
*
* @param float $growthValue
* @param bool $downgrade
* @return void
*/
public function incrPreGrowthValue($growthValue, $downgrade = true)
{
if (bccomp($growthValue, '0', 2) === 0) {
return;
}
// 增加预收益的成长值
$this->increment('pre_growth_value', $growthValue);
$totalGrowthValue = bcadd($this->growth_value, $this->pre_growth_value, 2);
$compared = bccomp($totalGrowthValue, config('agent.upgrade_rules.vip.sales_value'), 2);
if ($this->agent_level === static::AGENT_LEVEL_VIP && $compared < 0) {
if ($downgrade) {
$this->update([
'agent_level' => static::AGENT_LEVEL_CIVILIAN,
]);
}
} elseif ($this->agent_level === static::AGENT_LEVEL_CIVILIAN && $compared >= 0) {
$this->update([
'agent_level' => static::AGENT_LEVEL_VIP,
]);
}
}
/**
* 获取此用户的所有父级ID
*

View File

@ -423,10 +423,6 @@ class AfterSaleService
// 2.生成分销任务
// 3.生成新订单
if (bccomp($afterSale->sales_value, '0', 2) === 1) {
$order->user->userInfo->incrPreGrowthValue(bcmul($afterSale->sales_value, '-1', 2));
}
// 非赠品售后单,且售后单类型是换货、退款、退款退货
if (! $afterSaleProduct->isGift()
&& in_array($afterSale->type, [

View File

@ -1075,9 +1075,6 @@ class OrderService
'reason' => '取消订单',
]);
// 扣除用户的预成长值
$order->user->userInfo->incrPreGrowthValue(bcmul($order->sales_value, '-1', 2));
DistributionPreIncomeJob::create([
'jobable_id' => $refundLog->id,
'jobable_type' => $refundLog->getMorphClass(),

View File

@ -72,9 +72,6 @@ class PayService
'status' => Order::STATUS_PAID,
]);
// 增加用户预成长值
$payable->userInfo->incrPreGrowthValue($payable->sales_value, false);
DistributionPreIncomeJob::create([
'jobable_id' => $payable->id,
'jobable_type' => $payable->getMorphClass(),

View File

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddPreGrowthsValueToUserInfosTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('user_infos', function (Blueprint $table) {
$table->unsignedDecimal('pre_growth_value', 18, 2)->default(0)->comment('预收益成长值');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('user_infos', function (Blueprint $table) {
$table->dropColumn(['pre_growth_value']);
});
}
}