|
|
|
@ -12,16 +12,16 @@ declare (strict_types=1); |
|
|
|
|
|
|
|
|
|
namespace app\store\model; |
|
|
|
|
|
|
|
|
|
use app\common\enum\user\balanceLog\Scene as SceneEnum; |
|
|
|
|
use app\common\enum\user\grade\log\ChangeType as ChangeTypeEnum; |
|
|
|
|
use app\common\library\helper; |
|
|
|
|
use app\common\model\User as UserModel; |
|
|
|
|
use app\store\model\UserOauth as UserOauthModel; |
|
|
|
|
use app\store\model\dealer\User as DealerUserModel; |
|
|
|
|
use app\store\model\user\BalanceLog as BalanceLogModel; |
|
|
|
|
use app\store\model\user\GradeLog as GradeLogModel; |
|
|
|
|
use app\store\model\user\PointsLog as PointsLogModel; |
|
|
|
|
use app\store\model\user\BalanceLog as BalanceLogModel; |
|
|
|
|
use app\store\model\UserOauth as UserOauthModel; |
|
|
|
|
use app\store\service\store\User as StoreUserService; |
|
|
|
|
use app\common\enum\user\balanceLog\Scene as SceneEnum; |
|
|
|
|
use app\common\enum\user\grade\log\ChangeType as ChangeTypeEnum; |
|
|
|
|
use app\common\library\helper; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用户模型 |
|
|
|
@ -245,8 +245,22 @@ class User extends UserModel |
|
|
|
|
// 变更前的等级id |
|
|
|
|
$oldGradeId = $this['grade_id']; |
|
|
|
|
return $this->transaction(function () use ($oldGradeId, $data) { |
|
|
|
|
$up = []; |
|
|
|
|
if (!empty($data['user_type']) && !empty($data['effective_time'])) { |
|
|
|
|
$data['user_type'] = intval($data['user_type']); |
|
|
|
|
if ($data['user_type'] == 30) { |
|
|
|
|
$up['fx_effective_time'] = $data['effective_time']; |
|
|
|
|
} elseif (in_array($data['user_type'], [10, 20])) { |
|
|
|
|
$up['effective_time'] = $data['effective_time']; |
|
|
|
|
} else { |
|
|
|
|
$up['effective_time'] = null; |
|
|
|
|
$up['fx_effective_time'] = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$up['user_type'] = !empty($data['user_type']) ? $data['user_type'] : 10; |
|
|
|
|
$up['grade_id'] = $data['grade_id']; |
|
|
|
|
// 更新用户的等级 |
|
|
|
|
$status = $this->save(['grade_id' => $data['grade_id'],'user_type' => $data['user_type'] ?? 10]); |
|
|
|
|
$status = $this->save($up); |
|
|
|
|
// 新增用户等级修改记录 |
|
|
|
|
if ($status) { |
|
|
|
|
(new GradeLogModel)->record([ |
|
|
|
|