diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index f202524..753fe4a 100755 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -27,52 +27,57 @@ class User extends Base */ public function index() { - $user_id = trim(input('get.user_id')); - $mobile = trim(input('get.mobile')); - $nickname = trim(input('get.nickname')); - $addtime = trim(input('get.addtime')); - $last_login_ip = trim(input('get.last_login_ip')); - $whe = []; - if ($user_id) { - $user_id = $user_id - 1260; - $whe[] = ['id', '=', $user_id]; - } - if ($nickname) { - $whe[] = ['nickname', 'like', '%' . $nickname . '%']; - } - if ($mobile) { - $whe[] = ['mobile', '=', $mobile]; - } - if ($addtime) { - $time = explode(' - ', $addtime); - $start_time = strtotime($time[0]); - $end_time = strtotime($time[1]) - 1; - if ($start_time > $end_time) { - $this->err('开始时间不能大于结束时间'); - } - $whe[] = ['addtime', 'BETWEEN', array($start_time, $end_time)]; - } - if ($last_login_ip) { - $last_login_ip = ip2long($last_login_ip); - $user_id_arr = UserAccount::where(['last_login_ip' => $last_login_ip])->column('user_id'); - if ($user_id_arr) { + return View::fetch('User/index'); + } - $whe[] = ['id', 'in', $user_id_arr]; - } else { - $whe[] = ['id', '=', 0]; - } + /** + * 获取用户列表 + */ + public function list() + { + $param = $this->request->param(); + + // 构建查询条件 + $where = []; + if (!empty($param['user_id'])) { + $where[] = ['id', '=', intval($param['user_id']) - 1260]; + } + if (!empty($param['mobile'])) { + $where[] = ['mobile', 'like', "%{$param['mobile']}%"]; + } + if (!empty($param['nickname'])) { + $where[] = ['nickname', 'like', "%{$param['nickname']}%"]; + } + if (!empty($param['last_login_ip'])) { + $where[] = ['last_login_ip', '=', $param['last_login_ip']]; + } + if (!empty($param['addtime'])) { + $times = explode(' - ', $param['addtime']); + $where[] = ['addtime', 'between', [strtotime($times[0]), strtotime($times[1])]]; } $field = '*'; $order = 'id desc'; - $data = UserModel::getList($whe, $field, $order, $this->page); + $data = UserModel::getList($where, $field, $order, $this->page); foreach ($data['list'] as &$value) { $pid_info = UserModel::field('id,nickname,headimg')->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(); - $user_hegui = OrderList::where('user_id', '=', $value['id'])->where('status', '=', 0)->sum('goodslist_money'); // SELECT sum(goodslist_money) FROM xinglanmh_shequt_test.order_list where user_id=4490 and status=0 and goodslist_type=1 + $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'); $last_login_ip = 0; if ($user_account) { if ($user_account['last_login_ip']) { @@ -87,15 +92,45 @@ class User extends Base } $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['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']; } - View::assign('list', $data['list']); - View::assign('count', $data['count']); - View::assign('page', $data['page']); - return View::fetch('User/index'); + + // 获取数据 + $list = $data['list']; + + $count = $data['count']; + + // 处理数据 + foreach ($list as &$item) { + $item['headimg'] = imageUrl($item['headimg']); + // 格式化余额为两位小数 + $item['money'] = number_format($item['money'], 2, '.', ''); + + // 格式化吧唧币为两位小数 + $item['integral'] = number_format($item['integral'], 2, '.', ''); + + // 格式化积分为两位小数 + $item['score'] = number_format($item['score'], 2, '.', ''); + + // 格式化盒柜价值为两位小数 + $item['user_hegui'] = number_format($item['user_hegui'], 2, '.', ''); + } + + return json([ + 'code' => 0, + 'msg' => '', + 'count' => $count, + 'data' => $list + ]); } /** @@ -210,7 +245,7 @@ class User extends Base { // \think\facade\Filesystem::disk('public')-/ - + $id = request()->post('id/d', 0); $type = request()->post('type/d', 0); if ($type != 1 && $type != 0 && $type != 2) { diff --git a/app/admin/route/app.php b/app/admin/route/app.php index d70c445..cb98a84 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -291,4 +291,4 @@ Route::rule('user_invite', 'user/user_invite', 'GET'); Route::rule('user_statistics', 'Statistics/UserStatistics', 'GET'); - +Route::rule('user_list', 'User/list', 'GET'); diff --git a/app/admin/view/User/chongzhi.html b/app/admin/view/User/chongzhi.html index 7e2c731..9ccc5ad 100755 --- a/app/admin/view/User/chongzhi.html +++ b/app/admin/view/User/chongzhi.html @@ -1,69 +1,76 @@ {include file="Public:header2"/} +
-