Update
parent
d765c076d2
commit
60bc53f772
|
|
@ -13,5 +13,6 @@ class AgentUpgradeLog extends Model
|
||||||
'user_id',
|
'user_id',
|
||||||
'before_agent_level',
|
'before_agent_level',
|
||||||
'change_agent_level',
|
'change_agent_level',
|
||||||
|
'remark',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -354,8 +354,7 @@ class Dealer extends Model
|
||||||
$mapAgentLvl = $this->lvl->agentLvl();
|
$mapAgentLvl = $this->lvl->agentLvl();
|
||||||
|
|
||||||
if ($this->userInfo->agent_level < $mapAgentLvl) {
|
if ($this->userInfo->agent_level < $mapAgentLvl) {
|
||||||
$this->userInfo->agent_level = $mapAgentLvl;
|
$this->userInfo->changeAgentLvl($mapAgentLvl, '经销商享商城权益');
|
||||||
$this->userInfo->save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -349,18 +349,33 @@ class UserInfo extends Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->agent_level !== $lvl) {
|
$this->changeAgentLvl($lvl, '达到升级条件');
|
||||||
$beforeAgentLevel = $this->agent_level;
|
}
|
||||||
|
|
||||||
$this->update([
|
/**
|
||||||
'agent_level' => $lvl,
|
* 变更代理等级
|
||||||
]);
|
*
|
||||||
|
* @param int $lvl
|
||||||
$this->agentUpgradeLogs()->create([
|
* @param string|null $remark
|
||||||
'before_agent_level' => $beforeAgentLevel,
|
* @return void
|
||||||
'change_agent_level' => $lvl,
|
*/
|
||||||
]);
|
public function changeAgentLvl(int $lvl, ?string $remark = null)
|
||||||
|
{
|
||||||
|
if ($this->agent_level === $lvl) {
|
||||||
|
return $lvl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$beforeAgentLevel = $this->agent_level;
|
||||||
|
|
||||||
|
$this->update([
|
||||||
|
'agent_level' => $lvl,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->agentUpgradeLogs()->create([
|
||||||
|
'before_agent_level' => $beforeAgentLevel,
|
||||||
|
'change_agent_level' => $lvl,
|
||||||
|
'remark' => $remark,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
class AddRemarkToAgentUpgradeLogsTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('agent_upgrade_logs', function (Blueprint $table) {
|
||||||
|
$table->string('remark')->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('agent_upgrade_logs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn(['remark']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue