diff --git a/app/Http/Controllers/Admin/AdminController.php b/app/Http/Controllers/Admin/AdminController.php new file mode 100644 index 0000000..2729c9e --- /dev/null +++ b/app/Http/Controllers/Admin/AdminController.php @@ -0,0 +1,113 @@ +orderBy('listorder','desc')->get()); + + return view('admin.admin.add', $data); + } + + public function doadd() + { + unset($_POST["_token"]); + $_POST['pwd'] = md5($_POST['pwd']); + if(DB::table('admin')->insert($_POST)) + { + success_jump('添加成功!', route('admin_admin')); + } + else + { + error_jump('添加失败!请修改后重新添加'); + } + } + + public function edit() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";} + if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['id'] = $id; + $data['post'] = object_to_array(DB::table('admin')->where('id', $id)->first(), 1); + $data['rolelist'] = object_to_array(DB::table('admin_role')->orderBy('listorder','desc')->get()); + + return view('admin.admin.edit', $data); + } + + public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + + unset($_POST["_token"]); + $_POST['pwd'] = md5($_POST['pwd']); + if(DB::table('admin')->where('id', $id)->update($_POST)) + { + success_jump('修改成功!', route('admin_admin')); + } + else + { + error_jump('修改失败!'); + } + } + + //修改密码 + /* public function doedit() + { + if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} + unset($_POST["_token"]); + + if(!empty($_POST["username"])){$data['username'] = $map['username'] = $_POST["username"];}else{error_jump('用户名不能为空');exit;}//用户名 + if(!empty($_POST["oldpwd"])){$map['pwd'] = md5($_POST["oldpwd"]);}else{error_jump('旧密码错误');exit;} + if($_POST["newpwd"]==$_POST["newpwd2"]){$data['pwd'] = md5($_POST["newpwd"]);}else{error_jump('密码错误');exit;} + if($_POST["oldpwd"]==$_POST["newpwd"]){error_jump('新旧密码不能一致!');exit;} + + $User = object_to_array(DB::table("admin")->where($map)->first(), 1); + + if($User) + { + if(DB::table('admin')->where('id', $id)->update($data)) + { + session_unset(); + session_destroy(); + success_jump('修改成功,请重新登录', route('admin_login'), 3); + } + } + else + { + error_jump('修改失败!旧用户名或密码错误'); + } + } */ + + public function del() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} + + if(DB::table('admin')->whereIn("id", explode(',', $id))->delete()) + { + success_jump('删除成功'); + } + else + { + error_jump('删除失败!请重新提交'); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/UserRoleController.php b/app/Http/Controllers/Admin/AdminRoleController.php similarity index 76% rename from app/Http/Controllers/Admin/UserRoleController.php rename to app/Http/Controllers/Admin/AdminRoleController.php index 94eba00..b82911e 100644 --- a/app/Http/Controllers/Admin/UserRoleController.php +++ b/app/Http/Controllers/Admin/AdminRoleController.php @@ -4,7 +4,7 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Admin\CommonController; use DB; -class UserRoleController extends CommonController +class AdminRoleController extends CommonController { public function __construct() { @@ -13,24 +13,24 @@ class UserRoleController extends CommonController public function index() { - $posts = parent::pageList('admin_user_role', '', ['listorder','desc']); + $posts = parent::pageList('admin_role', '', ['listorder','desc']); $data['posts'] = $posts; - return view('admin.userrole.index', $data); + return view('admin.adminrole.index', $data); } public function add() { - return view('admin.userrole.add'); + return view('admin.adminrole.add'); } public function doadd() { unset($_POST["_token"]); - if(DB::table('admin_user_role')->insert($_POST)) + if(DB::table('admin_role')->insert($_POST)) { - success_jump('添加成功!', route('admin_userrole')); + success_jump('添加成功!', route('admin_adminrole')); } else { @@ -44,9 +44,9 @@ class UserRoleController extends CommonController if(preg_match('/[0-9]*/',$id)){}else{exit;} $data['id'] = $id; - $data['post'] = object_to_array(DB::table('admin_user_role')->where('id', $id)->first(), 1); + $data['post'] = object_to_array(DB::table('admin_role')->where('id', $id)->first(), 1); - return view('admin.userrole.edit', $data); + return view('admin.adminrole.edit', $data); } public function doedit() @@ -54,9 +54,9 @@ class UserRoleController extends CommonController if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} unset($_POST["_token"]); - if(DB::table('admin_user_role')->where('id', $id)->update($_POST)) + if(DB::table('admin_role')->where('id', $id)->update($_POST)) { - success_jump('修改成功!', route('admin_userrole')); + success_jump('修改成功!', route('admin_adminrole')); } else { @@ -68,7 +68,7 @@ class UserRoleController extends CommonController { if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} - if(DB::table('admin_user_role')->whereIn("id", explode(',', $id))->delete()) + if(DB::table('admin_role')->whereIn("id", explode(',', $id))->delete()) { success_jump('删除成功'); } @@ -104,7 +104,7 @@ class UserRoleController extends CommonController } } - return view('admin.userrole.permissions', $data); + return view('admin.adminrole.permissions', $data); } //角色权限设置 @@ -139,4 +139,4 @@ class UserRoleController extends CommonController error_jump('操作失败!'); } } -} +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/GoodsController.php b/app/Http/Controllers/Admin/GoodsController.php index 2317521..21972ec 100644 --- a/app/Http/Controllers/Admin/GoodsController.php +++ b/app/Http/Controllers/Admin/GoodsController.php @@ -153,7 +153,7 @@ class GoodsController extends CommonController { if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} - if(DB::table('goods')->whereIn("id", explode(',', $id))->delete()) + if(DB::table('goods')->whereIn("id", explode(',', $id))->update(['status' => 1])) { success_jump("$id ,删除成功"); } diff --git a/app/Http/Controllers/Admin/LoginController.php b/app/Http/Controllers/Admin/LoginController.php index 77b44b4..41e8a87 100644 --- a/app/Http/Controllers/Admin/LoginController.php +++ b/app/Http/Controllers/Admin/LoginController.php @@ -36,16 +36,16 @@ class LoginController extends BaseController if(!empty($_POST["username"])){$username = $_POST["username"];}else{$username='';exit;}//用户名 if(!empty($_POST["pwd"])){$pwd = md5($_POST["pwd"]);}else{$pwd='';exit;}//密码 - $admin_user = DB::table('admin_user')->where(array('username' => $username, 'pwd' => $pwd))->orWhere(array('email' => $username, 'pwd' => $pwd))->first(); + $admin_user = DB::table('admin')->where(array('username' => $username, 'pwd' => $pwd))->orWhere(array('email' => $username, 'pwd' => $pwd))->first(); if($admin_user) { $admin_user_info = object_to_array($admin_user, 1); - $admin_user_info['rolename'] = DB::table('admin_user_role')->where(array('id'=>$admin_user->role_id))->value('name'); + $admin_user_info['rolename'] = DB::table('admin_role')->where(array('id'=>$admin_user->role_id))->value('name'); $_SESSION['admin_user_info'] = $admin_user_info; - DB::table('admin_user')->where(array('id'=>$admin_user->role_id))->update(array('logintime' => time())); + DB::table('admin')->where(array('id'=>$admin_user->role_id))->update(array('logintime' => time())); return redirect()->route('admin'); } @@ -69,7 +69,7 @@ class LoginController extends BaseController $data["username"] = "admin888"; $data["pwd"] = "21232f297a57a5a743894a0e4a801fc3"; - if(DB::table('admin_user')->where('id', 1)->update($data)) + if(DB::table('admin')->where('id', 1)->update($data)) { success_jump('密码恢复成功!', route('admin_login')); } @@ -94,7 +94,7 @@ class LoginController extends BaseController return 0; } - return DB::table("admin_user")->where($map)->count(); + return DB::table("admin")->where($map)->count(); } //测试 diff --git a/app/Http/Controllers/Admin/OrderController.php b/app/Http/Controllers/Admin/OrderController.php index bd4d798..496abb7 100644 --- a/app/Http/Controllers/Admin/OrderController.php +++ b/app/Http/Controllers/Admin/OrderController.php @@ -3,6 +3,9 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\Admin\CommonController; use App\Http\Model\Order; +use App\Http\Model\OrderGoods; +use App\Http\Model\User; +use App\Http\Model\Region; use DB; class OrderController extends CommonController @@ -18,9 +21,24 @@ class OrderController extends CommonController $where = function ($query) use ($res) { if(isset($_REQUEST["keyword"])) { - $query->where('order_sn', 'like', '%'.$_REQUEST['keyword'].'%')->orWhere("name", "like", '%'.$_REQUEST['keyword'].'%'); + $query->where('order_sn', 'like', '%'.$_REQUEST['keyword'].'%')->orWhere("name", "like", '%'.$_REQUEST['keyword'].'%')->orWhere("mobile", "like", '%'.$_REQUEST['keyword'].'%'); + } + + if(isset($_REQUEST["mobile"])) + { + $query->where('mobile', 'like', '%'.$_REQUEST['mobile'].'%'); + } + + if(isset($_REQUEST["order_sn"])) + { + $query->where('order_sn', 'like', '%'.$_REQUEST['order_sn'].'%'); } + if(isset($_REQUEST["name"])) + { + $query->where("name", "like", '%'.$_REQUEST['name'].'%'); + } + //0或者不传表示全部,1待付款,2待发货,3待收货,4待评价(确认收货,交易成功),5退款/售后 if(isset($_REQUEST["status"])) { @@ -55,6 +73,10 @@ class OrderController extends CommonController $order_status_arr = Order::getOrderStatusText(object_to_array($value, 1)); $posts[$key]->order_status_text = $order_status_arr?$order_status_arr['text']:''; $posts[$key]->order_status_num = $order_status_arr?$order_status_arr['num']:''; + + $posts[$key]->province_name = Region::getRegionName($value->province); + $posts[$key]->city_name = Region::getRegionName($value->city); + $posts[$key]->district_name = Region::getRegionName($value->district); } $data['posts'] = $posts; @@ -62,6 +84,42 @@ class OrderController extends CommonController return view('admin.order.index', $data); } + public function detail() + { + if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";} + if(preg_match('/[0-9]*/',$id)){}else{exit;} + + $data['id'] = $id; + $data['post'] = Order::where('id', $id)->first(); + + if($data['post']) + { + $order_status_arr = Order::getOrderStatusText($data['post']); + $data['post']['order_status_text'] = $order_status_arr?$order_status_arr['text']:''; + $data['post']['order_status_num'] = $order_status_arr?$order_status_arr['num']:''; + + $data['post']['province_name'] = Region::getRegionName($data['post']['province']); + $data['post']['city_name'] = Region::getRegionName($data['post']['city']); + $data['post']['district_name'] = Region::getRegionName($data['post']['district']); + + $data['post']['invoice_text'] = Order::getInvoiceText($data['post']); + $data['post']['place_type_text'] = Order::getPlaceTypeText($data['post']); + + $data['post']['user'] = User::where(array('id'=>$data['post']['user_id']))->first(); //下单人信息 + + $order_goods = OrderGoods::where(array('order_id'=>$data['post']['id']))->get(); //订单商品列表 + + foreach($order_goods as $k=>$v) + { + $order_goods[$k]['refund_status_text'] = OrderGoods::getRefundStatusText($v); + } + + $data['post']['goodslist'] = $order_goods; + } + //echo '
';print_r($data['post']);exit; + return view('admin.order.detail', $data); + } + public function doadd() { $_POST['add_time'] = time();//更新时间 diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index d7fce34..39e5bf2 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -13,7 +13,7 @@ class UserController extends CommonController public function index() { - $posts = parent::pageList('admin_user'); + $posts = parent::pageList('user'); $data['posts'] = $posts; @@ -22,16 +22,13 @@ class UserController extends CommonController public function add() { - $data['rolelist'] = object_to_array(DB::table('admin_user_role')->orderBy('listorder','desc')->get()); - - return view('admin.user.add', $data); + return view('admin.user.add'); } public function doadd() { unset($_POST["_token"]); - $_POST['pwd'] = md5($_POST['pwd']); - if(DB::table('admin_user')->insert($_POST)) + if(DB::table('user')->insert($_POST)) { success_jump('添加成功!', route('admin_user')); } @@ -43,13 +40,12 @@ class UserController extends CommonController public function edit() { - if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";} + if(!empty($_GET["id"])){$id = $_GET["id"];}else{$id="";} if(preg_match('/[0-9]*/',$id)){}else{exit;} $data['id'] = $id; - $data['post'] = object_to_array(DB::table('admin_user')->where('id', $id)->first(), 1); - $data['rolelist'] = object_to_array(DB::table('admin_user_role')->orderBy('listorder','desc')->get()); - + $data['post'] = object_to_array(DB::table('user')->where('id', $id)->first(), 1); + return view('admin.user.edit', $data); } @@ -58,8 +54,7 @@ class UserController extends CommonController if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} unset($_POST["_token"]); - $_POST['pwd'] = md5($_POST['pwd']); - if(DB::table('admin_user')->where('id', $id)->update($_POST)) + if(DB::table('user')->where('id', $id)->update($_POST)) { success_jump('修改成功!', route('admin_user')); } @@ -69,39 +64,11 @@ class UserController extends CommonController } } - //修改密码 - /* public function doedit() - { - if(!empty($_POST["id"])){$id = $_POST["id"];unset($_POST["id"]);}else {$id="";exit;} - unset($_POST["_token"]); - - if(!empty($_POST["username"])){$data['username'] = $map['username'] = $_POST["username"];}else{error_jump('用户名不能为空');exit;}//用户名 - if(!empty($_POST["oldpwd"])){$map['pwd'] = md5($_POST["oldpwd"]);}else{error_jump('旧密码错误');exit;} - if($_POST["newpwd"]==$_POST["newpwd2"]){$data['pwd'] = md5($_POST["newpwd"]);}else{error_jump('密码错误');exit;} - if($_POST["oldpwd"]==$_POST["newpwd"]){error_jump('新旧密码不能一致!');exit;} - - $User = object_to_array(DB::table("user")->where($map)->first(), 1); - - if($User) - { - if(DB::table('user')->where('id', $id)->update($data)) - { - session_unset(); - session_destroy(); - success_jump('修改成功,请重新登录', route('admin_login'), 3); - } - } - else - { - error_jump('修改失败!旧用户名或密码错误'); - } - } */ - public function del() { - if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} + if(!empty($_GET["id"])){$id = $_GET["id"];}else{error_jump('删除失败!请重新提交');} - if(DB::table('admin_user')->whereIn("id", explode(',', $id))->delete()) + if(DB::table('user')->whereIn("id", explode(',', $id))->delete()) { success_jump('删除成功'); } diff --git a/app/Http/Model/Order.php b/app/Http/Model/Order.php index 5cf3634..0c2a135 100644 --- a/app/Http/Model/Order.php +++ b/app/Http/Model/Order.php @@ -24,7 +24,7 @@ class Order extends BaseModel $limit = isset($limit) ? $limit : 10; $offset = isset($offset) ? $offset : 0; - $where['user_id'] = $user_id; + if(isset($user_id)){$where['user_id'] = $user_id;} $where['is_delete'] = 0; //0或者不传表示全部,1待付款,2待发货,3待收货,4待评价(确认收货,交易成功),5退款/售后 @@ -76,6 +76,10 @@ class Order extends BaseModel $order_list[$k]['order_status_text'] = $order_status_arr?$order_status_arr['text']:''; $order_list[$k]['order_status_num'] = $order_status_arr?$order_status_arr['num']:''; + $order_list[$k]['province_name'] = Region::getRegionName($v['province']); + $order_list[$k]['city_name'] = Region::getRegionName($v['city']); + $order_list[$k]['district_name'] = Region::getRegionName($v['district']); + $order_goods = OrderGoods::where(array('order_id'=>$v['id']))->get(); $order_list[$k]['goods_list'] = $order_goods; } @@ -278,4 +282,48 @@ class Order extends BaseModel return $res; } + + //获取发票类型文字:0不索要发票,1个人,2企业 + public static function getInvoiceText($where) + { + $res = ''; + if($where['invoice'] == 0) + { + $res = '不索要发票'; + } + elseif($where['invoice'] == 1) + { + $res = '个人'; + } + elseif($where['invoice'] == 2) + { + $res = '企业'; + } + + return $res; + } + + //获取订单来源文字:1pc,2weixin,3app,4wap + public static function getPlaceTypeText($where) + { + $res = ''; + if($where['place_type'] === 1) + { + $res = 'pc'; + } + elseif($where['place_type'] === 2) + { + $res = 'weixin'; + } + elseif($where['place_type'] === 3) + { + $res = 'app'; + } + elseif($where['place_type'] === 4) + { + $res = 'wap'; + } + + return $res; + } } \ No newline at end of file diff --git a/app/Http/Model/OrderGoods.php b/app/Http/Model/OrderGoods.php index c46f6d7..7641ecc 100644 --- a/app/Http/Model/OrderGoods.php +++ b/app/Http/Model/OrderGoods.php @@ -20,4 +20,28 @@ class OrderGoods extends BaseModel * @var bool */ public $timestamps = false; + + //获取退货状态文字:0无退货,1退款中,2退款成功,3不同意退款 + public static function getRefundStatusText($where) + { + $res = ''; + if($where['refund_status'] == 0) + { + $res = '无退货'; + } + elseif($where['refund_status'] == 1) + { + $res = '退款中'; + } + elseif($where['refund_status'] == 2) + { + $res = '退款成功'; + } + elseif($where['refund_status'] == 3) + { + $res = '不同意退款'; + } + + return $res; + } } \ No newline at end of file diff --git a/resources/views/admin/admin/add.blade.php b/resources/views/admin/admin/add.blade.php new file mode 100644 index 0000000..772a67f --- /dev/null +++ b/resources/views/admin/admin/add.blade.php @@ -0,0 +1,64 @@ +@extends('admin.layouts.app') +@section('title', '管理员添加') + +@section('content') ++ +@endsection \ No newline at end of file diff --git a/resources/views/admin/admin/edit.blade.php b/resources/views/admin/admin/edit.blade.php new file mode 100644 index 0000000..65b5341 --- /dev/null +++ b/resources/views/admin/admin/edit.blade.php @@ -0,0 +1,67 @@ +@extends('admin.layouts.app') +@section('title', '管理员修改') + +@section('content') +管理员列表 > 管理员添加
+ +