41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
||
|
||
|
||
|
||
|
||
namespace crmeb\jobs;
|
||
|
||
|
||
use app\common\repositories\user\UserBrokerageRepository;
|
||
use app\common\repositories\user\UserRepository;
|
||
use crmeb\interfaces\JobInterface;
|
||
use think\facade\Log;
|
||
|
||
class UserBrokerageLevelJob implements JobInterface
|
||
{
|
||
public function fire($job, $data)
|
||
{
|
||
try {
|
||
$user = app()->make(UserRepository::class)->get($data['uid']);
|
||
if ($user) {
|
||
// 修改用户信息
|
||
$flag = true;
|
||
if ($data['type'] == 'spread_money') $user->spread_pay_price = bcadd($user->spread_pay_price, $data['inc'], 2);
|
||
else if ($data['type'] == 'spread_pay_num') $user->spread_pay_count = bcadd($user->spread_pay_count, $data['inc'], 0);
|
||
else $flag = false;
|
||
if ($flag) $user->save();
|
||
// todo: 2023-12-25 分销商升级重构 旧版本弃用,改为使用v2版本升级流程
|
||
// app()->make(UserBrokerageRepository::class)->inc($user, $data);
|
||
app()->make(UserBrokerageRepository::class)->incV2($user, $data);
|
||
}
|
||
} catch (\Exception $e) {
|
||
Log::info('分销等级同步失败: ' . var_export($data, 1) . $e->getMessage());
|
||
}
|
||
$job->delete();
|
||
}
|
||
|
||
public function failed($data)
|
||
{
|
||
}
|
||
}
|