Update
parent
d765c076d2
commit
60bc53f772
|
|
@ -13,5 +13,6 @@ class AgentUpgradeLog extends Model
|
|||
'user_id',
|
||||
'before_agent_level',
|
||||
'change_agent_level',
|
||||
'remark',
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,8 +354,7 @@ class Dealer extends Model
|
|||
$mapAgentLvl = $this->lvl->agentLvl();
|
||||
|
||||
if ($this->userInfo->agent_level < $mapAgentLvl) {
|
||||
$this->userInfo->agent_level = $mapAgentLvl;
|
||||
$this->userInfo->save();
|
||||
$this->userInfo->changeAgentLvl($mapAgentLvl, '经销商享商城权益');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -349,18 +349,33 @@ class UserInfo extends Model
|
|||
}
|
||||
}
|
||||
|
||||
if ($this->agent_level !== $lvl) {
|
||||
$beforeAgentLevel = $this->agent_level;
|
||||
$this->changeAgentLvl($lvl, '达到升级条件');
|
||||
}
|
||||
|
||||
$this->update([
|
||||
'agent_level' => $lvl,
|
||||
]);
|
||||
|
||||
$this->agentUpgradeLogs()->create([
|
||||
'before_agent_level' => $beforeAgentLevel,
|
||||
'change_agent_level' => $lvl,
|
||||
]);
|
||||
/**
|
||||
* 变更代理等级
|
||||
*
|
||||
* @param int $lvl
|
||||
* @param string|null $remark
|
||||
* @return void
|
||||
*/
|
||||
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