添加异常
This commit is contained in:
parent
9bd5d0b7d7
commit
9579f994f7
|
|
@ -39,7 +39,7 @@ class User extends Base
|
|||
{
|
||||
$param = $this->request->param();
|
||||
$limit = request()->param('limit', '');
|
||||
|
||||
|
||||
// 构建查询条件
|
||||
$where = [];
|
||||
if (!empty($param['user_id'])) {
|
||||
|
|
@ -65,56 +65,61 @@ class User extends Base
|
|||
$field = '*';
|
||||
$order = 'id desc';
|
||||
$data = UserModel::getList($where, $field, $order, $limit);
|
||||
foreach ($data['list'] as &$value) {
|
||||
$pid_info = UserModel::field('id,nickname,headimg,uid')->where(['id' => $value['pid']])->find();
|
||||
$value['pid_info'] = $pid_info;
|
||||
#关联user_account
|
||||
$user_account = UserAccount::where(['user_id' => $value['id']])->field('last_login_ip1,last_login_ip,ip_adcode,ip_province,ip_city')->find();
|
||||
// SELECT sum(goodslist_money) FROM order_list where user_id=4490 and status=0
|
||||
$user_hegui = OrderList::where('user_id', '=', $value['id'])->where('status', '=', 0)->sum('goodslist_money');
|
||||
//SELECT SUM(order_zhe_total) FROM `order` where `status`=1 and user_id=6153
|
||||
$user_all_total = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('order_zhe_total');
|
||||
//SELECT *FROM `order` where `status`=1 and user_id=6153 and price>1 #微信支付
|
||||
$user_weixin_total = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->where('price', '>', 1)->sum('price');
|
||||
// SELECT sum(use_money) FROM `order` where `status`=1 and user_id=6153 # 余额支付
|
||||
$user_use_money = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('use_money');
|
||||
//SELECT sum(use_integral) FROM `order` where `status`=1 and user_id=6153 #吧唧币抵扣
|
||||
$user_use_integral = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('use_integral');
|
||||
// SELECT sum(goodslist_money) FROM `order_list` where `status`=1 and user_id=6153 # 回收货币
|
||||
$user_goodslist_money = OrderList::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('goodslist_money');
|
||||
// SELECT sum(goodslist_money) FROM `order_list` where `status`=2 and user_id=6153 # 发货价值
|
||||
$user_goodslist_money2 = OrderList::where('user_id', '=', $value['id'])->where('status', '=', 2)->sum('goodslist_money');
|
||||
//SELECT sum(goodslist_money) FROM order_list where user_id=4490 # 总出货价值
|
||||
$user_goodslist_money3 = OrderList::where('user_id', '=', $value['id'])->sum('goodslist_money');
|
||||
$last_login_ip = 0;
|
||||
if ($user_account) {
|
||||
if ($user_account['last_login_ip']) {
|
||||
if ($user_account['last_login_ip1']) {
|
||||
$last_login_ip = $user_account['last_login_ip1'];
|
||||
} else {
|
||||
$last_login_ip = long2ip($user_account['last_login_ip']);
|
||||
if ($data && $data['list']) {
|
||||
foreach ($data['list'] as &$value) {
|
||||
try {
|
||||
$pid_info = UserModel::field('id,nickname,headimg,uid')->where(['id' => $value['pid']])->find();
|
||||
$value['pid_info'] = $pid_info;
|
||||
#关联user_account
|
||||
$user_account = UserAccount::where(['user_id' => $value['id']])->field('last_login_ip1,last_login_ip,ip_adcode,ip_province,ip_city')->find();
|
||||
// SELECT sum(goodslist_money) FROM order_list where user_id=4490 and status=0
|
||||
$user_hegui = OrderList::where('user_id', '=', $value['id'])->where('status', '=', 0)->sum('goodslist_money');
|
||||
//SELECT SUM(order_zhe_total) FROM `order` where `status`=1 and user_id=6153
|
||||
$user_all_total = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('order_zhe_total');
|
||||
//SELECT *FROM `order` where `status`=1 and user_id=6153 and price>1 #微信支付
|
||||
$user_weixin_total = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->where('price', '>', 1)->sum('price');
|
||||
// SELECT sum(use_money) FROM `order` where `status`=1 and user_id=6153 # 余额支付
|
||||
$user_use_money = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('use_money');
|
||||
//SELECT sum(use_integral) FROM `order` where `status`=1 and user_id=6153 #吧唧币抵扣
|
||||
$user_use_integral = Order::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('use_integral');
|
||||
// SELECT sum(goodslist_money) FROM `order_list` where `status`=1 and user_id=6153 # 回收货币
|
||||
$user_goodslist_money = OrderList::where('user_id', '=', $value['id'])->where('status', '=', 1)->sum('goodslist_money');
|
||||
// SELECT sum(goodslist_money) FROM `order_list` where `status`=2 and user_id=6153 # 发货价值
|
||||
$user_goodslist_money2 = OrderList::where('user_id', '=', $value['id'])->where('status', '=', 2)->sum('goodslist_money');
|
||||
//SELECT sum(goodslist_money) FROM order_list where user_id=4490 # 总出货价值
|
||||
$user_goodslist_money3 = OrderList::where('user_id', '=', $value['id'])->sum('goodslist_money');
|
||||
$last_login_ip = 0;
|
||||
if ($user_account) {
|
||||
if ($user_account['last_login_ip']) {
|
||||
if ($user_account['last_login_ip1']) {
|
||||
$last_login_ip = $user_account['last_login_ip1'];
|
||||
} else {
|
||||
$last_login_ip = long2ip($user_account['last_login_ip']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($value['mobile'])) {
|
||||
$value['mobile'] = '未绑定';
|
||||
}
|
||||
$value['user_hegui'] = $user_hegui;
|
||||
$value['user_all_total'] = $user_all_total;
|
||||
$value['user_weixin_total'] = $user_weixin_total;
|
||||
$value['user_use_money'] = $user_use_money;
|
||||
$value['user_use_integral'] = $user_use_integral;
|
||||
$value['user_goodslist_money'] = $user_goodslist_money;
|
||||
$value['user_goodslist_money2'] = $user_goodslist_money2;
|
||||
$value['user_goodslist_money3'] = $user_goodslist_money3;
|
||||
$value['last_login_ip'] = $last_login_ip;
|
||||
$value['ip_adcode'] = $user_account['ip_adcode'];
|
||||
$value['ip_province'] = $user_account['ip_province'];
|
||||
$value['ip_city'] = $user_account['ip_city'];
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
}
|
||||
|
||||
}
|
||||
if (empty($value['mobile'])) {
|
||||
$value['mobile'] = '未绑定';
|
||||
}
|
||||
$value['user_hegui'] = $user_hegui;
|
||||
$value['user_all_total'] = $user_all_total;
|
||||
$value['user_weixin_total'] = $user_weixin_total;
|
||||
$value['user_use_money'] = $user_use_money;
|
||||
$value['user_use_integral'] = $user_use_integral;
|
||||
$value['user_goodslist_money'] = $user_goodslist_money;
|
||||
$value['user_goodslist_money2'] = $user_goodslist_money2;
|
||||
$value['user_goodslist_money3'] = $user_goodslist_money3;
|
||||
$value['last_login_ip'] = $last_login_ip;
|
||||
$value['ip_adcode'] = $user_account['ip_adcode'];
|
||||
$value['ip_province'] = $user_account['ip_province'];
|
||||
$value['ip_city'] = $user_account['ip_city'];
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
$list = $data['list'];
|
||||
|
||||
|
|
@ -747,15 +752,15 @@ class User extends Base
|
|||
$data['list'] = $list->toArray()['data'];
|
||||
$data['count'] = $list->total();
|
||||
$data['page'] = $page;
|
||||
|
||||
|
||||
// 获取用户UID
|
||||
$user = UserModel::where('id', $id)->find();
|
||||
$uid = $user ? $user['uid'] : '';
|
||||
|
||||
|
||||
foreach ($data['list'] as &$item) {
|
||||
$item['uid'] = $uid ?: $item['user_id'];
|
||||
}
|
||||
|
||||
|
||||
View::assign('list', $data['list']);
|
||||
View::assign('count', $data['count']);
|
||||
View::assign('page', $data['page']);
|
||||
|
|
@ -853,11 +858,11 @@ class User extends Base
|
|||
{
|
||||
$param = $this->request->param();
|
||||
$user_id = isset($param['user_id']) ? intval($param['user_id']) : 0;
|
||||
|
||||
|
||||
// 将UID转换为用户ID
|
||||
$user_id = $this->convertUidToUserId($user_id);
|
||||
|
||||
if(empty($user_id)) {
|
||||
|
||||
if (empty($user_id)) {
|
||||
return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]);
|
||||
}
|
||||
|
||||
|
|
@ -944,10 +949,10 @@ class User extends Base
|
|||
{
|
||||
$user_id = request()->param('id', 0);
|
||||
$nickname = request()->param('nickname', '');
|
||||
|
||||
|
||||
// 将UID转换为用户ID
|
||||
$user_id = $this->convertUidToUserId($user_id);
|
||||
|
||||
|
||||
// 验证参数
|
||||
if (empty($user_id)) {
|
||||
$this->renderError('参数错误');
|
||||
|
|
@ -966,10 +971,10 @@ class User extends Base
|
|||
public function user_order()
|
||||
{
|
||||
$id = input('id');
|
||||
View::assign('id',$id);
|
||||
View::assign('user_id',$id);
|
||||
View::assign('id', $id);
|
||||
View::assign('user_id', $id);
|
||||
$nickname = input('nickname');
|
||||
View::assign('nickname',$nickname);
|
||||
View::assign('nickname', $nickname);
|
||||
return View::fetch('User/user_order');
|
||||
}
|
||||
|
||||
|
|
@ -980,11 +985,11 @@ class User extends Base
|
|||
{
|
||||
$param = $this->request->param();
|
||||
$user_id = isset($param['user_id']) ? intval($param['user_id']) : 0;
|
||||
|
||||
|
||||
// 将UID转换为用户ID
|
||||
$user_id = $this->convertUidToUserId($user_id);
|
||||
|
||||
if(empty($user_id)) {
|
||||
|
||||
if (empty($user_id)) {
|
||||
return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]);
|
||||
}
|
||||
|
||||
|
|
@ -1037,7 +1042,7 @@ class User extends Base
|
|||
{
|
||||
$user_id = input('user_id');
|
||||
$nickname = input('nickname', '');
|
||||
|
||||
|
||||
View::assign('user_id', $user_id);
|
||||
View::assign('nickname', $nickname);
|
||||
return View::fetch('User/user_money_detail');
|
||||
|
|
@ -1050,27 +1055,27 @@ class User extends Base
|
|||
{
|
||||
$param = input();
|
||||
$user_id = isset($param['user_id']) ? intval($param['user_id']) : 0;
|
||||
|
||||
|
||||
if (empty($user_id)) {
|
||||
return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]);
|
||||
}
|
||||
|
||||
|
||||
$where = [
|
||||
['user_id', '=', $user_id]
|
||||
];
|
||||
|
||||
|
||||
// 时间范围
|
||||
if (!empty($param['start_time']) && !empty($param['end_time'])) {
|
||||
$start_time = strtotime($param['start_time']);
|
||||
$end_time = strtotime($param['end_time']);
|
||||
$where[] = ['addtime', 'between', [$start_time, $end_time]];
|
||||
}
|
||||
|
||||
|
||||
// 类型筛选
|
||||
if (isset($param['type']) && $param['type'] !== '') {
|
||||
$where[] = ['type', '=', intval($param['type'])];
|
||||
}
|
||||
|
||||
|
||||
// 变化类型(收入/消耗)
|
||||
if (isset($param['change_type']) && $param['change_type'] !== '') {
|
||||
if ($param['change_type'] === 'add') {
|
||||
|
|
@ -1079,28 +1084,28 @@ class User extends Base
|
|||
$where[] = ['change_money', '<', 0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 备注搜索
|
||||
if (isset($param['content']) && $param['content'] !== '') {
|
||||
$where[] = ['content|other', 'like', '%' . $param['content'] . '%'];
|
||||
}
|
||||
|
||||
|
||||
// 获取数据
|
||||
$model = new \app\common\model\ProfitMoney();
|
||||
|
||||
|
||||
// 获取总数
|
||||
$count = $model->where($where)->count();
|
||||
|
||||
|
||||
// 分页
|
||||
$page = isset($param['page']) ? max(1, intval($param['page'])) : 1;
|
||||
$limit = isset($param['limit']) ? max(1, intval($param['limit'])) : 50;
|
||||
|
||||
|
||||
$list = $model->where($where)
|
||||
->order('id desc')
|
||||
->page($page, $limit)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
|
|
@ -1116,13 +1121,13 @@ class User extends Base
|
|||
{
|
||||
$user_id = input('user_id');
|
||||
$nickname = input('nickname', '');
|
||||
|
||||
|
||||
View::assign('user_id', $user_id);
|
||||
View::assign('nickname', $nickname);
|
||||
View::assign('currency_name', getConfig('app_setting')['currency1_name'] ?? '货币2');
|
||||
return View::fetch('User/user_integral_detail');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户货币2流水明细数据
|
||||
*/
|
||||
|
|
@ -1130,27 +1135,27 @@ class User extends Base
|
|||
{
|
||||
$param = input();
|
||||
$user_id = isset($param['user_id']) ? intval($param['user_id']) : 0;
|
||||
|
||||
|
||||
if (empty($user_id)) {
|
||||
return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]);
|
||||
}
|
||||
|
||||
|
||||
$where = [
|
||||
['user_id', '=', $user_id]
|
||||
];
|
||||
|
||||
|
||||
// 时间范围
|
||||
if (!empty($param['start_time']) && !empty($param['end_time'])) {
|
||||
$start_time = strtotime($param['start_time']);
|
||||
$end_time = strtotime($param['end_time']);
|
||||
$where[] = ['addtime', 'between', [$start_time, $end_time]];
|
||||
}
|
||||
|
||||
|
||||
// 类型筛选
|
||||
if (isset($param['type']) && $param['type'] !== '') {
|
||||
$where[] = ['type', '=', intval($param['type'])];
|
||||
}
|
||||
|
||||
|
||||
// 变化类型(收入/消耗)
|
||||
if (isset($param['change_type']) && $param['change_type'] !== '') {
|
||||
if ($param['change_type'] === 'add') {
|
||||
|
|
@ -1159,13 +1164,13 @@ class User extends Base
|
|||
$where[] = ['change_money', '<', 0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 备注搜索
|
||||
if (isset($param['content']) && $param['content'] !== '') {
|
||||
// 使用content字段进行搜索
|
||||
$where[] = ['content', 'like', '%' . $param['content'] . '%'];
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// 使用DB类进行查询,避免使用模型方法
|
||||
$list = Db::name('profit_integral')
|
||||
|
|
@ -1174,11 +1179,11 @@ class User extends Base
|
|||
->page(isset($param['page']) ? max(1, intval($param['page'])) : 1, isset($param['limit']) ? max(1, intval($param['limit'])) : 50)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
$count = Db::name('profit_integral')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
|
|
@ -1189,7 +1194,7 @@ class User extends Base
|
|||
return json(['code' => 1, 'msg' => '数据查询出错: ' . $e->getMessage(), 'count' => 0, 'data' => []]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户货币3流水明细
|
||||
*/
|
||||
|
|
@ -1197,13 +1202,13 @@ class User extends Base
|
|||
{
|
||||
$user_id = input('user_id');
|
||||
$nickname = input('nickname', '');
|
||||
|
||||
|
||||
View::assign('user_id', $user_id);
|
||||
View::assign('nickname', $nickname);
|
||||
View::assign('currency_name', getConfig('app_setting')['currency2_name'] ?? '货币3');
|
||||
return View::fetch('User/user_score_detail');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户货币3流水明细数据
|
||||
*/
|
||||
|
|
@ -1211,27 +1216,27 @@ class User extends Base
|
|||
{
|
||||
$param = input();
|
||||
$user_id = isset($param['user_id']) ? intval($param['user_id']) : 0;
|
||||
|
||||
|
||||
if (empty($user_id)) {
|
||||
return json(['code' => 1, 'msg' => '参数错误', 'count' => 0, 'data' => []]);
|
||||
}
|
||||
|
||||
|
||||
$where = [
|
||||
['user_id', '=', $user_id]
|
||||
];
|
||||
|
||||
|
||||
// 时间范围
|
||||
if (!empty($param['start_time']) && !empty($param['end_time'])) {
|
||||
$start_time = strtotime($param['start_time']);
|
||||
$end_time = strtotime($param['end_time']);
|
||||
$where[] = ['addtime', 'between', [$start_time, $end_time]];
|
||||
}
|
||||
|
||||
|
||||
// 类型筛选
|
||||
if (isset($param['type']) && $param['type'] !== '') {
|
||||
$where[] = ['type', '=', intval($param['type'])];
|
||||
}
|
||||
|
||||
|
||||
// 变化类型(收入/消耗)
|
||||
if (isset($param['change_type']) && $param['change_type'] !== '') {
|
||||
if ($param['change_type'] === 'add') {
|
||||
|
|
@ -1240,13 +1245,13 @@ class User extends Base
|
|||
$where[] = ['change_money', '<', 0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 备注搜索
|
||||
if (isset($param['content']) && $param['content'] !== '') {
|
||||
// 使用content字段进行搜索
|
||||
$where[] = ['content', 'like', '%' . $param['content'] . '%'];
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// 使用DB类进行查询,避免使用模型方法
|
||||
$list = Db::name('profit_money2')
|
||||
|
|
@ -1255,11 +1260,11 @@ class User extends Base
|
|||
->page(isset($param['page']) ? max(1, intval($param['page'])) : 1, isset($param['limit']) ? max(1, intval($param['limit'])) : 50)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
$count = Db::name('profit_money2')
|
||||
->where($where)
|
||||
->count();
|
||||
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => '',
|
||||
|
|
@ -1283,7 +1288,7 @@ class User extends Base
|
|||
$month = input('month', date('m'));
|
||||
$start_date = input('start_date', date('Y-m-d', strtotime('-30 days')));
|
||||
$end_date = input('end_date', date('Y-m-d'));
|
||||
|
||||
|
||||
switch ($type) {
|
||||
case 'day':
|
||||
// 日登录统计
|
||||
|
|
@ -1291,73 +1296,85 @@ class User extends Base
|
|||
$chart_data = [];
|
||||
$labels = [];
|
||||
$values = [];
|
||||
|
||||
|
||||
foreach ($data as $item) {
|
||||
$labels[] = $item['login_date'];
|
||||
$values[] = $item['count'];
|
||||
}
|
||||
|
||||
|
||||
$chart_data = [
|
||||
'labels' => $labels,
|
||||
'values' => $values,
|
||||
];
|
||||
|
||||
|
||||
// 计算活跃用户数
|
||||
$active_user_count = \app\common\model\UserLoginLog::getActiveUserCount($start_date, $end_date);
|
||||
|
||||
return json(['code' => 0, 'msg' => 'ok', 'data' => [
|
||||
'chart' => $chart_data,
|
||||
'active_users' => $active_user_count,
|
||||
'total_logins' => array_sum($values),
|
||||
]]);
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => 'ok',
|
||||
'data' => [
|
||||
'chart' => $chart_data,
|
||||
'active_users' => $active_user_count,
|
||||
'total_logins' => array_sum($values),
|
||||
]
|
||||
]);
|
||||
break;
|
||||
|
||||
|
||||
case 'week':
|
||||
// 周登录统计
|
||||
$data = \app\common\model\UserLoginLog::getWeeklyLoginCount($year);
|
||||
$chart_data = [];
|
||||
$labels = [];
|
||||
$values = [];
|
||||
|
||||
|
||||
foreach ($data as $item) {
|
||||
$labels[] = $item['year'] . '年第' . $item['week'] . '周';
|
||||
$values[] = $item['count'];
|
||||
}
|
||||
|
||||
|
||||
$chart_data = [
|
||||
'labels' => $labels,
|
||||
'values' => $values,
|
||||
];
|
||||
|
||||
return json(['code' => 0, 'msg' => 'ok', 'data' => [
|
||||
'chart' => $chart_data,
|
||||
'total_logins' => array_sum($values),
|
||||
]]);
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => 'ok',
|
||||
'data' => [
|
||||
'chart' => $chart_data,
|
||||
'total_logins' => array_sum($values),
|
||||
]
|
||||
]);
|
||||
break;
|
||||
|
||||
|
||||
case 'month':
|
||||
// 月登录统计
|
||||
$data = \app\common\model\UserLoginLog::getMonthlyLoginCount($year);
|
||||
$chart_data = [];
|
||||
$labels = [];
|
||||
$values = [];
|
||||
|
||||
|
||||
foreach ($data as $item) {
|
||||
$labels[] = $item['year'] . '年' . $item['month'] . '月';
|
||||
$values[] = $item['count'];
|
||||
}
|
||||
|
||||
|
||||
$chart_data = [
|
||||
'labels' => $labels,
|
||||
'values' => $values,
|
||||
];
|
||||
|
||||
return json(['code' => 0, 'msg' => 'ok', 'data' => [
|
||||
'chart' => $chart_data,
|
||||
'total_logins' => array_sum($values),
|
||||
]]);
|
||||
|
||||
return json([
|
||||
'code' => 0,
|
||||
'msg' => 'ok',
|
||||
'data' => [
|
||||
'chart' => $chart_data,
|
||||
'total_logins' => array_sum($values),
|
||||
]
|
||||
]);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
return json(['code' => 1, 'msg' => '统计类型错误']);
|
||||
}
|
||||
|
|
@ -1365,7 +1382,7 @@ class User extends Base
|
|||
return json(['code' => 1, 'msg' => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return view('User/login_stat', [
|
||||
'year' => date('Y'),
|
||||
'month' => date('m'),
|
||||
|
|
@ -1384,10 +1401,10 @@ class User extends Base
|
|||
if (!$user) {
|
||||
return json(['status' => 0, 'msg' => '用户不存在']);
|
||||
}
|
||||
|
||||
|
||||
// 计算上一天的日期
|
||||
$yesterday = date('Y-m-d', strtotime('-1 day'));
|
||||
|
||||
|
||||
try {
|
||||
// 更新用户的签到数据
|
||||
$result = \app\common\model\UserSign::where('user_id', $id)
|
||||
|
|
@ -1396,7 +1413,7 @@ class User extends Base
|
|||
'sign_date' => $yesterday,
|
||||
'update_time' => time()
|
||||
]);
|
||||
|
||||
|
||||
if ($result) {
|
||||
return json(['status' => 1, 'msg' => '签到数据重置成功']);
|
||||
} else {
|
||||
|
|
@ -1415,17 +1432,17 @@ class User extends Base
|
|||
{
|
||||
$id = $request->post('id/d', 0);
|
||||
$mobile = $request->post('mobile', '');
|
||||
|
||||
|
||||
// 验证手机号格式
|
||||
if (!preg_match('/^1\d{10}$/', $mobile)) {
|
||||
return json(['status' => 0, 'msg' => '手机号格式不正确']);
|
||||
}
|
||||
|
||||
|
||||
$user = UserModel::getInfo(['id' => $id]);
|
||||
if (!$user) {
|
||||
return json(['status' => 0, 'msg' => '用户不存在']);
|
||||
}
|
||||
|
||||
|
||||
// 检查手机号是否已被其他用户使用
|
||||
$existUser = UserModel::where('mobile', $mobile)
|
||||
->where('id', '<>', $id)
|
||||
|
|
@ -1433,10 +1450,10 @@ class User extends Base
|
|||
if ($existUser) {
|
||||
return json(['status' => 0, 'msg' => '该手机号已被其他用户使用']);
|
||||
}
|
||||
|
||||
|
||||
// 更新用户手机号
|
||||
$result = $user->save(['mobile' => $mobile]);
|
||||
|
||||
|
||||
if ($result) {
|
||||
return json(['status' => 1, 'msg' => '手机号绑定成功']);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user