From f7d39aa28dc37b96d08e165b18a6d5837e4d5355 Mon Sep 17 00:00:00 2001 From: manghe Date: Thu, 20 Mar 2025 18:52:46 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Goods.php | 1 - app/admin/controller/User.php | 196 +++++++++++++++++++++++- app/admin/route/app.php | 4 + app/admin/view/Public/menu.html | 2 +- app/admin/view/User/index.html | 100 ++++++++---- app/admin/view/User/user_box.html | 228 ++++++++++++++++++++++++++++ app/admin/view/User/user_order.html | 185 ++++++++++++++++++++++ 7 files changed, 682 insertions(+), 34 deletions(-) create mode 100644 app/admin/view/User/user_box.html create mode 100644 app/admin/view/User/user_order.html diff --git a/app/admin/controller/Goods.php b/app/admin/controller/Goods.php index 98cde88..66520c8 100755 --- a/app/admin/controller/Goods.php +++ b/app/admin/controller/Goods.php @@ -42,7 +42,6 @@ class Goods extends Base View::assign('count', $data['count']); View::assign('page', $data['page']); return View::fetch("Goods/goods"); - } /** diff --git a/app/admin/controller/User.php b/app/admin/controller/User.php index 6dd9cbe..af7ff5a 100755 --- a/app/admin/controller/User.php +++ b/app/admin/controller/User.php @@ -66,7 +66,7 @@ class User extends Base $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 xinglanmh_shequt_test.order_list where user_id=4490 and status=0 and goodslist_type=1 + // 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'); @@ -80,6 +80,8 @@ class User extends Base $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']) { @@ -92,8 +94,8 @@ class User extends Base } } - if(empty($value['mobile'])){ - $value['mobile'] ='未绑定'; + if (empty($value['mobile'])) { + $value['mobile'] = '未绑定'; } $value['user_hegui'] = $user_hegui; $value['user_all_total'] = $user_all_total; @@ -102,6 +104,7 @@ class User extends Base $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']; @@ -121,6 +124,8 @@ class User extends Base 'data' => $list ]); } + + /** * 资金变动 @@ -794,4 +799,189 @@ class User extends Base View::assign('count', $count); return View::fetch("User/user_invite"); } + + /** + * //用户列表页面表格操作一列增加查询用户盒柜,传入用户的id,点击显示一个弹出层,弹出层中有一个表格,这个弹出层有有查询条件(奖品状态(下拉框),奖品名称(输入框),盒子名称(输入框)),下面的sql语句是查询盒柜列表 + * goodslist_title 奖品名称,goodslist_money 回收价格,goodslist_price 售价,shang_id 奖品等级,order_id 订单id,order_num 订单编号,goods_id 盒子id,good_title 盒子名称,status奖品状态 0盒柜中 1回收 2选择发货 + *SELECT goodslist_title,goodslist_money, goodslist_price,goodslist_imgurl,shang_id,addtime,order_id,(select order_num from `order` where id=order_list.order_id) order_num,goods_id,(select title from goods where id=order_list.goods_id ) good_title,`status` FROM order_list where user_id=6153 order by`status` + * 获取用户盒柜列表 + */ + public function user_box_list() + { + $param = $this->request->param(); + $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['status'])) { + $where[] = ['status', '=', $param['status']]; + } + + if(!empty($param['goodslist_title'])) { + $where[] = ['goodslist_title', 'like', "%{$param['goodslist_title']}%"]; + } + + if(!empty($param['good_title'])) { + // 通过goods表查询包含该名称的盒子ID + $goods_ids = Db::name('goods')->where('title', 'like', "%{$param['good_title']}%")->column('id'); + if(!empty($goods_ids)) { + $where[] = ['goods_id', 'in', $goods_ids]; + } else { + // 如果没有找到匹配的盒子,返回空结果 + return json(['code' => 0, 'msg' => '未找到匹配的盒子', 'count' => 0, 'data' => []]); + } + } + + // 添加获取时间查询条件 + if(!empty($param['addtime'])) { + $times = explode(' - ', $param['addtime']); + $where[] = ['addtime', 'between', [strtotime($times[0]), strtotime($times[1])]]; + } + + // 构建查询 - 添加了shang_title字段和发货状态字段 + $query = Db::name('order_list') + ->where($where) + ->field('goodslist_title, goodslist_money, goodslist_price, goodslist_imgurl, shang_id, addtime, order_id, goods_id, status, fh_status, fh_remarks'); + + // 获取总数 + $count = $query->count(); + + // 分页查询 + $page = isset($param['page']) ? intval($param['page']) : 1; + $limit = isset($param['limit']) ? intval($param['limit']) : 20; + + $list = $query->page($page, $limit) + ->order('status, addtime desc') + ->select() + ->toArray(); + + // 处理订单编号、盒子名称和奖品类型 + foreach($list as &$item) { + // 获取订单编号 + $order = Db::name('order')->where('id', $item['order_id'])->value('order_num'); + $item['order_num'] = $order ?: '无订单号'; + + // 获取盒子名称 + $good = Db::name('goods')->where('id', $item['goods_id'])->value('title'); + $item['good_title'] = $good ?: '未知盒子'; + + // 获取奖品类型名称 + $shang = Db::name('shang')->where('id', $item['shang_id'])->value('title'); + $item['shang_title'] = $shang ?: '未知类型'; + + // 处理发货状态,确保数据存在 + if ($item['status'] == 2) { + $item['fh_status'] = isset($item['fh_status']) ? intval($item['fh_status']) : 0; + } else { + $item['fh_status'] = null; + $item['fh_remarks'] = null; + } + } + + return json([ + 'code' => 0, + 'msg' => '', + 'count' => $count, + 'data' => $list + ]); + } + + /** + * 用户盒柜页面 + */ + public function user_box() + { + $user_id = request()->param('id', 0); + $nickname = request()->param('nickname', ''); + + // 验证参数 + if (empty($user_id)) { + $this->renderError('参数错误'); + } + + // 传递用户ID和昵称到模板 + View::assign('user_id', $user_id); + View::assign('nickname', $nickname); + + return View::fetch('User/user_box'); + } + + /** + * 用户订单页面 + */ + public function user_order() + { + $user_id = request()->param('id', 0); + $nickname = request()->param('nickname', ''); + + // 验证参数 + if (empty($user_id)) { + $this->renderError('参数错误'); + } + + // 传递用户ID和昵称到模板 + View::assign('user_id', $user_id); + View::assign('nickname', $nickname); + + return View::fetch('User/user_order'); + } + + /** + * 获取用户订单列表 + */ + public function user_order_list() + { + $param = $this->request->param(); + $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(isset($param['status']) && $param['status'] !== '') { + $where[] = ['status', '=', $param['status']]; + } + + if(!empty($param['goods_title'])) { + $where[] = ['goods_title', 'like', "%{$param['goods_title']}%"]; + } + + // 添加支付时间查询条件 + if(!empty($param['pay_time'])) { + $times = explode(' - ', $param['pay_time']); + $where[] = ['pay_time', 'between', [strtotime($times[0]), strtotime($times[1])]]; + } + + // 构建查询 + $query = Db::name('order') + ->where($where) + ->field('id, order_num, order_total, order_zhe_total, price, use_money, use_integral, use_score, goods_id, goods_title, num, goods_price, addtime, pay_time, status'); + + // 获取总数 + $count = $query->count(); + + // 分页查询 + $page = isset($param['page']) ? intval($param['page']) : 1; + $limit = isset($param['limit']) ? intval($param['limit']) : 20; + + $list = $query->page($page, $limit) + ->order('id desc') + ->select() + ->toArray(); + + return json([ + 'code' => 0, + 'msg' => '', + 'count' => $count, + 'data' => $list + ]); + } } diff --git a/app/admin/route/app.php b/app/admin/route/app.php index cb98a84..81615c5 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -292,3 +292,7 @@ Route::rule('user_statistics', 'Statistics/UserStatistics', 'GET'); Route::rule('user_list', 'User/list', 'GET'); +Route::rule('user_box', 'User/user_box', 'GET'); +Route::rule('user_box_list', 'User/user_box_list', 'GET'); +Route::rule('user_order', 'User/user_order', 'GET'); +Route::rule('user_order_list', 'User/user_order_list', 'GET'); \ No newline at end of file diff --git a/app/admin/view/Public/menu.html b/app/admin/view/Public/menu.html index 91c3026..11f2bf9 100755 --- a/app/admin/view/Public/menu.html +++ b/app/admin/view/Public/menu.html @@ -1,5 +1,5 @@ -
+