|
|
@@ -78,18 +78,18 @@ class UserRepository extends BaseRepository
|
|
|
{
|
|
|
// 定义用户筛选条件的列表,每个条件包括标签和对应的值
|
|
|
$data = [
|
|
|
- ['label' => 'UID', 'value' => 'uid'],
|
|
|
- ['label' => '用户昵称', 'value' => 'nickname'],
|
|
|
- ['label' => '手机号', 'value' => 'phone'],
|
|
|
- ['label' => '性别', 'value' => 'sex'],
|
|
|
- ['label' => '身份', 'value' => 'is_promoter'],
|
|
|
- ['label' => '用户分组', 'value' => 'group_id'],
|
|
|
- ['label' => '用户标签', 'value' => 'label_id'],
|
|
|
- ['label' => '用户类别', 'value' => 'is_svip'],
|
|
|
- ['label' => '生日', 'value' => 'birthday'],
|
|
|
- ['label' => '消费次数', 'value' => 'pay_count'],
|
|
|
- ['label' => '会员等级', 'value' => 'member_level'],
|
|
|
- ['label' => '余额', 'value' => 'now_money'],
|
|
|
+ ['label' => 'UID', 'value' => 'uid'],
|
|
|
+ ['label' => '用户昵称', 'value' => 'nickname'],
|
|
|
+ ['label' => '手机号', 'value' => 'phone'],
|
|
|
+ ['label' => '性别', 'value' => 'sex'],
|
|
|
+ ['label' => '身份', 'value' => 'is_promoter'],
|
|
|
+ ['label' => '用户分组', 'value' => 'group_id'],
|
|
|
+ ['label' => '用户标签', 'value' => 'label_id'],
|
|
|
+ ['label' => '用户类别', 'value' => 'is_svip'],
|
|
|
+ ['label' => '生日', 'value' => 'birthday'],
|
|
|
+ ['label' => '消费次数', 'value' => 'pay_count'],
|
|
|
+ ['label' => '会员等级', 'value' => 'member_level'],
|
|
|
+ ['label' => '余额', 'value' => 'now_money'],
|
|
|
['label' => '首次访问时间', 'value' => 'create_time'],
|
|
|
['label' => '最近访问时间', 'value' => 'last_time'],
|
|
|
];
|
|
|
@@ -127,14 +127,14 @@ class UserRepository extends BaseRepository
|
|
|
public function meetWithPromoter($uid)
|
|
|
{
|
|
|
$user = $this->dao->get($uid);
|
|
|
- if (!$user->is_promoter && $user->promoter_switch && systemConfig('promoter_type') == 3){
|
|
|
+ if (!$user->is_promoter && $user->promoter_switch && systemConfig('promoter_type') == 3) {
|
|
|
$storeOrderRepository = app()->make(StoreOrderRepository::class);
|
|
|
$pay_price = $storeOrderRepository->getSearch([])
|
|
|
- ->where(['uid' => $uid,'paid' => 1])
|
|
|
+ ->where(['uid' => $uid, 'paid' => 1])
|
|
|
->whereNotNull('pay_time')
|
|
|
->sum('pay_price');
|
|
|
$promoter_low_money = systemConfig('promoter_low_money');
|
|
|
- if (bccomp($pay_price,$promoter_low_money,2) !== -1) $this->promoter($uid);
|
|
|
+ if (bccomp($pay_price, $promoter_low_money, 2) !== -1) $this->promoter($uid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -187,10 +187,10 @@ class UserRepository extends BaseRepository
|
|
|
['value' => 1, 'label' => '开启'],
|
|
|
])->requiredNum()
|
|
|
])
|
|
|
- // 设置表单标题
|
|
|
- ->setTitle('添加用户')
|
|
|
- // 设置表单初始数据
|
|
|
- ->formData([]);
|
|
|
+ // 设置表单标题
|
|
|
+ ->setTitle('添加用户')
|
|
|
+ // 设置表单初始数据
|
|
|
+ ->formData([]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -305,8 +305,8 @@ class UserRepository extends BaseRepository
|
|
|
['value' => 1, 'label' => '开启'],
|
|
|
])->requiredNum()
|
|
|
])
|
|
|
- // 设置表单标题和预填充数据
|
|
|
- ->setTitle('编辑')->formData($user->toArray());
|
|
|
+ // 设置表单标题和预填充数据
|
|
|
+ ->setTitle('编辑')->formData($user->toArray());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -323,7 +323,7 @@ class UserRepository extends BaseRepository
|
|
|
*/
|
|
|
public function getList(array $where, int $page, int $limit, array $viewSearch = [])
|
|
|
{
|
|
|
- $query = $this->dao->search($where,$viewSearch);
|
|
|
+ $query = $this->dao->search($where, $viewSearch);
|
|
|
$query->with([
|
|
|
'spread' => function ($query) {
|
|
|
$query->field('uid,nickname,spread_uid');
|
|
|
@@ -389,7 +389,7 @@ class UserRepository extends BaseRepository
|
|
|
$where['is_promoter'] = 1;
|
|
|
$where['promoter_switch'] = 1;
|
|
|
} else {
|
|
|
- $where['is_promoter'] = [0,1];
|
|
|
+ $where['is_promoter'] = [0, 1];
|
|
|
}
|
|
|
// 查询并计算各种统计数据
|
|
|
$total = $this->dao->search($where)
|
|
|
@@ -454,7 +454,7 @@ class UserRepository extends BaseRepository
|
|
|
$where['is_promoter'] = 1;
|
|
|
$where['promoter_switch'] = 1;
|
|
|
} else {
|
|
|
- $where['is_promoter'] = [0,1];
|
|
|
+ $where['is_promoter'] = [0, 1];
|
|
|
}
|
|
|
|
|
|
// 构建查询,包括推广员的传播信息和佣金信息
|
|
|
@@ -498,7 +498,7 @@ class UserRepository extends BaseRepository
|
|
|
}
|
|
|
|
|
|
// 返回推广员列表和总数
|
|
|
- return compact('count','list');
|
|
|
+ return compact('count', 'list');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -925,7 +925,7 @@ class UserRepository extends BaseRepository
|
|
|
// 初始化扩展信息数组
|
|
|
$extend_info = [];
|
|
|
// 检查并提取userInfo中的扩展信息,然后从userInfo中移除
|
|
|
- if(isset($userInfo['extend_info'])){
|
|
|
+ if (isset($userInfo['extend_info'])) {
|
|
|
$extend_info = $userInfo['extend_info'];
|
|
|
unset($userInfo['extend_info']);
|
|
|
}
|
|
|
@@ -988,7 +988,10 @@ class UserRepository extends BaseRepository
|
|
|
|
|
|
}
|
|
|
$user->save();
|
|
|
- try {Queue::push(SendNewPeopleCouponJob::class, $user->uid);} catch (\Exception $e) {}
|
|
|
+ try {
|
|
|
+ Queue::push(SendNewPeopleCouponJob::class, $user->uid);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -1033,7 +1036,7 @@ class UserRepository extends BaseRepository
|
|
|
$isPromoter = $user->is_promoter;
|
|
|
//如果人人分销不想改变用户本来的分销状态,就将if 中的代码注释代码注释,并修改 get_extension_info 方法中的注释部分
|
|
|
if (!$isPromoter && systemConfig('extension_status')) {
|
|
|
- $isPromoter = systemConfig('promoter_type') == 2 ? 1 : 0;
|
|
|
+ $isPromoter = systemConfig('promoter_type') == 2 ? 1 : 0;
|
|
|
$user->is_promoter = $isPromoter;
|
|
|
}
|
|
|
$user->save();
|
|
|
@@ -1073,7 +1076,7 @@ class UserRepository extends BaseRepository
|
|
|
// 检查缓存中是否存在以'user_'前缀加上令牌值为键的记录
|
|
|
$has = Cache::has('user_' . $token);
|
|
|
// 如果令牌不存在于缓存中,则抛出授权异常
|
|
|
- if (!$has)throw new AuthException('无效的token');
|
|
|
+ if (!$has) throw new AuthException('无效的token');
|
|
|
// 从缓存中获取令牌的最后更新时间
|
|
|
$lastTime = Cache::get('user_' . $token);
|
|
|
// 检查令牌是否过期,如果过期,则抛出授权异常
|
|
|
@@ -1184,7 +1187,7 @@ class UserRepository extends BaseRepository
|
|
|
'phone' => $phone,
|
|
|
'last_ip' => app('request')->ip()
|
|
|
];
|
|
|
- env('registr.before',compact('data'));
|
|
|
+ env('registr.before', compact('data'));
|
|
|
// 调用create方法,根据用户类型创建新用户
|
|
|
return $this->create($user_type, $data);
|
|
|
}
|
|
|
@@ -1560,7 +1563,7 @@ class UserRepository extends BaseRepository
|
|
|
public function bindSpread(User $user, $spreadUid)
|
|
|
{
|
|
|
if ($spreadUid && !$user->spread_uid && $user->uid != $spreadUid && ($spread = $this->dao->get($spreadUid)) && $spread->spread_uid != $user->uid && !$spread->cancel_time) {
|
|
|
- $config = systemConfig(['extension_limit', 'extension_limit_day', 'integral_user_give','integral_status']);
|
|
|
+ $config = systemConfig(['extension_limit', 'extension_limit_day', 'integral_user_give', 'integral_status']);
|
|
|
event('user.spread.before', compact('user', 'spreadUid'));
|
|
|
Db::transaction(function () use ($spread, $spreadUid, $user, $config) {
|
|
|
$user->spread_uid = $spreadUid;
|
|
|
@@ -1908,8 +1911,8 @@ class UserRepository extends BaseRepository
|
|
|
*
|
|
|
* @param object $user 用户对象,包含用户详细信息。
|
|
|
* @param array $tokenInfo 令牌信息数组,包含令牌字符串和过期时间。
|
|
|
- * @throws ValidateException 如果用户状态为禁用,则抛出异常。
|
|
|
* @return array 返回包含令牌、过期时间及用户信息的数组。
|
|
|
+ * @throws ValidateException 如果用户状态为禁用,则抛出异常。
|
|
|
*/
|
|
|
public function returnToken($user, $tokenInfo)
|
|
|
{
|
|
|
@@ -2192,7 +2195,7 @@ class UserRepository extends BaseRepository
|
|
|
Elm::select($field, '级别:', $data->$field)
|
|
|
->options(function () use ($type) {
|
|
|
$options = app()->make(UserBrokerageRepository::class)->options(['type' => $type])->toArray();
|
|
|
- $options = array_merge([['value' => 0 , 'label' => '请选择']],$options);
|
|
|
+ $options = array_merge([['value' => 0, 'label' => '请选择']], $options);
|
|
|
return $options;
|
|
|
})
|
|
|
->placeholder('请选择级别'),
|
|
|
@@ -2213,8 +2216,8 @@ class UserRepository extends BaseRepository
|
|
|
* @param int $id 用户ID
|
|
|
* @param array $data 包含新级别数据的数组
|
|
|
* @param int $type 类型标志,1表示更新会员级别,0表示更新代理级别
|
|
|
- * @throws ValidateException 如果新级别不存在,则抛出此异常
|
|
|
* @return bool 如果级别未更新则返回true,否则返回false
|
|
|
+ * @throws ValidateException 如果新级别不存在,则抛出此异常
|
|
|
*/
|
|
|
public function updateLevel(int $id, array $data, int $type)
|
|
|
{
|
|
|
@@ -2612,21 +2615,21 @@ class UserRepository extends BaseRepository
|
|
|
{
|
|
|
$isPromoter = false;//是否分销员
|
|
|
$isSelfBuy = false;//是否内购
|
|
|
- if(systemConfig('extension_status') && !$user){
|
|
|
+ if (systemConfig('extension_status') && !$user) {
|
|
|
$isPromoter = systemConfig('extension_all') || $user->is_promoter ? true : false;
|
|
|
$isSelfBuy = $isPromoter && systemConfig('extension_self') ? 1 : 0;//是否内购
|
|
|
}
|
|
|
- return ['isPromoter'=>$isPromoter,'isSelfBuy'=>$isSelfBuy];
|
|
|
+ return ['isPromoter' => $isPromoter, 'isSelfBuy' => $isSelfBuy];
|
|
|
}
|
|
|
|
|
|
- public function queryCustomer(array $where, int $page, int $size) : array
|
|
|
+ public function queryCustomer(array $where, int $page, int $size): array
|
|
|
{
|
|
|
$search = $where['search'] ?? null;
|
|
|
unset($where['search']);
|
|
|
|
|
|
// 根据条件初始化查询
|
|
|
$query = $this->dao->search($where);
|
|
|
- if(isset($search)) {
|
|
|
+ if (isset($search)) {
|
|
|
$query->where('User.uid|User.nickname|User.phone', 'LIKE', '%' . $search . '%');
|
|
|
}
|
|
|
|
|
|
@@ -2638,13 +2641,14 @@ class UserRepository extends BaseRepository
|
|
|
|
|
|
return compact('count', 'list');
|
|
|
}
|
|
|
- /**
|
|
|
- * 商户添加新用户
|
|
|
- * 代客下单时,商户可以为用户添加新用户。商户需要提供用户的电话号码,系统会自动生成一个默认密码
|
|
|
- *
|
|
|
- * @param array $params
|
|
|
- * @return mixed 具体类型取决于create方法的返回值
|
|
|
- */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商户添加新用户
|
|
|
+ * 代客下单时,商户可以为用户添加新用户。商户需要提供用户的电话号码,系统会自动生成一个默认密码
|
|
|
+ *
|
|
|
+ * @param array $params
|
|
|
+ * @return mixed 具体类型取决于create方法的返回值
|
|
|
+ */
|
|
|
public function merchantRegistrs(array $params)
|
|
|
{
|
|
|
$phone = $params['phone'];
|
|
|
@@ -2657,7 +2661,7 @@ class UserRepository extends BaseRepository
|
|
|
'is_svip' => -1,
|
|
|
'last_ip' => app('request')->ip()
|
|
|
];
|
|
|
- env('registr.before',compact('data'));
|
|
|
+ env('registr.before', compact('data'));
|
|
|
|
|
|
return $this->create('h5', $data);
|
|
|
}
|
|
|
@@ -2666,4 +2670,20 @@ class UserRepository extends BaseRepository
|
|
|
{
|
|
|
return $this->dao->get($uid);
|
|
|
}
|
|
|
+
|
|
|
+ public function awardIntegralPrice()
|
|
|
+ {
|
|
|
+ $basePrice = systemConfig('award_integral_price', 0.1);
|
|
|
+ //业绩
|
|
|
+ $achievement = 0;
|
|
|
+ /** @var UserExtractRepository $extractRepositories */
|
|
|
+ $extractRepositories = app()->make(UserExtractRepository::class);
|
|
|
+ $extractCommission = $extractRepositories->search(['status' => 1])->whereTime('check_time', 'today')->sum('commission');
|
|
|
+ $sumAwardIntegral = $this->dao->search(['status' => 1])->sum('award_integral');
|
|
|
+ $achievement = $extractCommission + $achievement;
|
|
|
+
|
|
|
+ $rise = bcdiv($achievement, $sumAwardIntegral, 3);
|
|
|
+ $price = bcadd($rise, $basePrice, 3);
|
|
|
+ return compact('basePrice', 'price', 'rise');
|
|
|
+ }
|
|
|
}
|