wang hou sheng 9 months ago
parent d4b4797e4e
commit 28ebfe0c63
  1. 28
      app/store/model/User.php

@ -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;
/**
* 用户模型
@ -111,7 +111,7 @@ class User extends UserModel
$filter = [];
// 会员昵称
!empty($params['search']) && $filter[] = ['nick_name|mobile', 'like', "%{$params['search']}%"];
isset($params['user_type']) && ($params['user_type'] != "") && $filter[] = ['user_type', 'in', explode(",", $params['user_type'])];
isset($params['user_type']) && ($params['user_type'] != "") && $filter[] = ['user_type', 'in', explode(",", $params['user_type'])];
// 用户性别
$params['gender'] > -1 && $filter[] = ['gender', '=', (int)$params['gender']];
// 用户等级
@ -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([

Loading…
Cancel
Save