where("user_id", $user['user_id'])->find(); session('user',$user); //覆盖session 中的 user $this->user = $user; $this->user_id = $user['user_id']; $this->assign('user',$user); //存储用户信息 $this->assign('user_id',$this->user_id); }else{ $nologin = array( 'login','pop_login','do_login','logout','verify','set_pwd','finished', 'verifyHandle','reg','send_sms_reg_code','identity','check_validate_code', 'forget_pwd','check_captcha','check_username','send_validate_code', ); if(!in_array(ACTION_NAME,$nologin)){ $this->redirect('Home/User/login'); exit; } } //用户中心面包屑导航 $navigate_user = navigate_user(); $this->assign('navigate_user',$navigate_user); } /* * 用户中心首页 */ public function index(){ $logic = new UsersLogic(); $user = $logic->get_info($this->user_id); $user = $user['result']; $level = M('user_level')->select(); $level = convert_arr_key($level,'level_id'); $this->assign('level',$level); $this->assign('user',$user); return $this->fetch(); } public function logout(){ setcookie('uname','',time()-3600,'/'); setcookie('cn','',time()-3600,'/'); setcookie('user_id','',time()-3600,'/'); session_unset(); session_destroy(); //$this->success("退出成功",U('Home/Index/index')); $this->redirect('Home/Index/index'); exit; } /* * 账户资金 */ public function account(){ $user = session('user'); //获取账户资金记录 $logic = new UsersLogic(); $data = $logic->get_account_log($this->user_id,I('get.type')); $account_log = $data['result']; $this->assign('user',$user); $this->assign('account_log',$account_log); $this->assign('page',$data['show']); $this->assign('active','account'); return $this->fetch(); } /* * 优惠券列表 */ public function coupon(){ $logic = new UsersLogic(); $data = $logic->get_coupon($this->user_id,I('type')); $coupon_list = $data['result']; $this->assign('coupon_list',$coupon_list); $this->assign('page',$data['show']); $this->assign('active','coupon'); return $this->fetch(); } /** * 登录 */ public function login(){ if($this->user_id > 0){ $this->redirect('Home/User/index'); } $referurl = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : U("Home/User/index"); $this->assign('referurl',$referurl); return $this->fetch(); } public function pop_login(){ if($this->user_id > 0){ $this->redirect('Home/User/index'); } $referurl = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : U("Home/User/index"); $this->assign('referurl',$referurl); return $this->fetch(); } public function do_login(){ $username = I('post.username'); $password = I('post.password'); $username = trim($username); $password = trim($password); $verify_code = I('post.verify_code'); $verify = new Verify(); if (!$verify->check($verify_code,'user_login')) { $res = array('status'=>0,'msg'=>'验证码错误'); exit(json_encode($res)); } $logic = new UsersLogic(); $res = $logic->login($username,$password); if($res['status'] == 1){ $res['url'] = urldecode(I('post.referurl')); session('user',$res['result']); setcookie('user_id',$res['result']['user_id'],null,'/'); setcookie('is_distribut',$res['result']['is_distribut'],null,'/'); $nickname = empty($res['result']['nickname']) ? $username : $res['result']['nickname']; setcookie('uname',urlencode($nickname),null,'/'); setcookie('cn',0,time()-3600,'/'); $cartLogic = new CartLogic(); $cartLogic->login_cart_handle($this->session_id,$res['result']['user_id']); //用户登录后 需要对购物车 一些操作 } exit(json_encode($res)); } /** * 注册 */ public function reg(){ if($this->user_id > 0){ $this->redirect('Home/User/index'); } if(IS_POST){ $logic = new UsersLogic(); //验证码检验 // $this->verifyHandle('user_reg'); $username = I('post.username',''); $password = I('post.password',''); $password2 = I('post.password2',''); $code = I('post.code',''); $session_id = session_id(); //是否开启注册验证码机制 if(check_mobile($username)){ $reg_sms_enable = tpCache('sms.regis_sms_enable'); if(!$reg_sms_enable){ //邮件功能关闭 $this->verifyHandle('user_reg'); } $check_code = $logic->check_validate_code($code, $username, $session_id); if($check_code['status'] != 1){ $this->error($check_code['msg']); } } //是否开启注册邮箱验证码机制 if(check_email($username)){ $reg_smtp_enable = tpCache('smtp.regis_smtp_enable'); if(!$reg_smtp_enable){ //邮件功能关闭 $this->verifyHandle('user_reg'); } $check_code = $logic->check_validate_code($code, $username, $session_id, 'email'); if($check_code['status'] != 1){ $this->error($check_code['msg']); } } $data = $logic->reg($username,$password,$password2); if($data['status'] != 1){ $this->error($data['msg']); } session('user',$data['result']); setcookie('user_id',$data['result']['user_id'],null,'/'); setcookie('is_distribut',$data['result']['is_distribut'],null,'/'); $nickname = empty($data['result']['nickname']) ? $username : $data['result']['nickname']; setcookie('uname',$nickname,null,'/'); $cartLogic = new CartLogic(); $cartLogic->login_cart_handle($this->session_id,$data['result']['user_id']); //用户登录后 需要对购物车 一些操作 $this->success($data['msg'],U('Home/User/index')); exit; } $this->assign('regis_sms_enable',tpCache('sms.regis_sms_enable')); // 注册启用短信: $this->assign('regis_smtp_enable',tpCache('smtp.regis_smtp_enable')); // 注册启用邮箱: $sms_time_out = tpCache('sms.sms_time_out')>0 ? tpCache('sms.sms_time_out') : 120; $this->assign('sms_time_out', $sms_time_out); // 手机短信超时时间 return $this->fetch(); } /* * 订单列表 */ public function order_list(){ $where = ' user_id=:user_id'; $bind['user_id'] = $this->user_id; //条件搜索 if(I('get.type')){ $where .= C(strtoupper(I('get.type'))); } // 搜索订单 根据商品名称 或者 订单编号 $search_key = trim(I('search_key')); if($search_key) { $where .= " and (order_sn like :search_key1 or order_id in (select order_id from `".C('database.prefix')."order_goods` where goods_name like :search_key2) ) "; $bind['search_key1'] = "%$search_key%"; $bind['search_key2'] = "%$search_key%"; } $count = M('order')->where($where)->bind($bind)->count(); $Page = new Page($count,10); $show = $Page->show(); $order_str = "order_id DESC"; $order_list = M('order')->order($order_str)->where($where)->bind($bind)->limit($Page->firstRow.','.$Page->listRows)->select(); //获取订单商品 $model = new UsersLogic(); foreach($order_list as $k=>$v) { $order_list[$k] = set_btn_order_status($v); // 添加属性 包括按钮显示属性 和 订单状态显示属性 //$order_list[$k]['total_fee'] = $v['goods_amount'] + $v['shipping_fee'] - $v['integral_money'] -$v['bonus'] - $v['discount']; //订单总额 $data = $model->get_order_goods($v['order_id']); $order_list[$k]['goods_list'] = $data['result']; } $this->assign('order_status',C('ORDER_STATUS')); $this->assign('shipping_status',C('SHIPPING_STATUS')); $this->assign('pay_status',C('PAY_STATUS')); $this->assign('page',$show); $this->assign('lists',$order_list); $this->assign('active','order_list'); $this->assign('active_status',I('get.type')); return $this->fetch(); } /* * 订单详情 */ public function order_detail(){ $id = I('get.id/d'); $map['order_id'] = $id; $map['user_id'] = $this->user_id; $order_info = M('order')->where($map)->find(); $order_info = set_btn_order_status($order_info); // 添加属性 包括按钮显示属性 和 订单状态显示属性 if(!$order_info){ $this->error('没有获取到订单信息'); exit; } //获取订单商品 $model = new UsersLogic(); $data = $model->get_order_goods($order_info['order_id']); $order_info['goods_list'] = $data['result']; //$order_info['total_fee'] = $order_info['goods_price'] + $order_info['shipping_price'] - $order_info['integral_money'] -$order_info['coupon_price'] - $order_info['discount']; //获取订单进度条 $sql = "SELECT action_id,log_time,status_desc,order_status FROM ((SELECT * FROM __PREFIX__order_action WHERE order_id = :id AND status_desc <>'' ORDER BY action_id) AS a) GROUP BY status_desc ORDER BY action_id"; $bind['id'] = $id; $items = DB::query($sql,$bind); $items_count = count($items); $region_list = get_region_list(); $invoice_no = M('DeliveryDoc')->where("order_id", $id)->getField('invoice_no',true); $order_info[invoice_no] = implode(' , ', $invoice_no); //获取订单操作记录 $order_action = M('order_action')->where(array('order_id'=>$id))->select(); $this->assign('order_status',C('ORDER_STATUS')); $this->assign('shipping_status',C('SHIPPING_STATUS')); $this->assign('pay_status',C('PAY_STATUS')); $this->assign('region_list',$region_list); $this->assign('order_info',$order_info); $this->assign('order_action',$order_action); $this->assign('active','order_list'); return $this->fetch(); } /* * 取消订单 */ public function cancel_order(){ $id = I('get.id/d'); //检查是否有积分,余额支付 $logic = new UsersLogic(); $data = $logic->cancel_order($this->user_id,$id); if($data['status'] < 0) $this->error($data['msg']); $this->success($data['msg']); } /* * 用户地址列表 */ public function address_list(){ $address_lists = get_user_address_list($this->user_id); $region_list = get_region_list(); $this->assign('region_list',$region_list); $this->assign('lists',$address_lists); $this->assign('active','address_list'); return $this->fetch(); } /* * 添加地址 */ public function add_address(){ header("Content-type:text/html;charset=utf-8"); if(IS_POST){ $logic = new UsersLogic(); $data = $logic->add_address($this->user_id,0,I('post.')); if($data['status'] != 1) exit(''); $call_back = $_REQUEST['call_back']; echo ""; exit(); // 成功 回调closeWindow方法 并返回新增的id } $p = M('region')->where(array('parent_id'=>0,'level'=> 1))->select(); $this->assign('province',$p); return $this->fetch('edit_address'); } /* * 地址编辑 */ public function edit_address(){ header("Content-type:text/html;charset=utf-8"); $id = I('get.id/d'); $address = M('user_address')->where(array('address_id'=>$id,'user_id'=> $this->user_id))->find(); if(IS_POST){ $logic = new UsersLogic(); $data = $logic->add_address($this->user_id,$id,I('post.')); if($data['status'] != 1) exit(''); $call_back = $_REQUEST['call_back']; echo ""; exit(); // 成功 回调closeWindow方法 并返回新增的id } //获取省份 $p = M('region')->where(array('parent_id'=>0,'level'=> 1))->select(); $c = M('region')->where(array('parent_id'=>$address['province'],'level'=> 2))->select(); $d = M('region')->where(array('parent_id'=>$address['city'],'level'=> 3))->select(); if($address['twon']){ $e = M('region')->where(array('parent_id'=>$address['district'],'level'=>4))->select(); $this->assign('twon',$e); } $this->assign('province',$p); $this->assign('city',$c); $this->assign('district',$d); $this->assign('address',$address); return $this->fetch(); } /* * 设置默认收货地址 */ public function set_default(){ $id = I('get.id/d'); M('user_address')->where(array('user_id'=>$this->user_id))->save(array('is_default'=>0)); $row = M('user_address')->where(array('user_id'=>$this->user_id,'address_id'=>$id))->save(array('is_default'=>1)); if(!$row) $this->error('操作失败'); $this->success("操作成功"); } /* * 地址删除 */ public function del_address(){ $id = I('get.id/d'); $address = M('user_address')->where("address_id", $id)->find(); $row = M('user_address')->where(array('user_id'=>$this->user_id,'address_id'=>$id))->delete(); // 如果删除的是默认收货地址 则要把第一个地址设置为默认收货地址 if($address['is_default'] == 1) { $address2 = M('user_address')->where("user_id", $this->user_id)->find(); $address2 && M('user_address')->where("address_id", $address2['address_id'])->save(array('is_default'=>1)); } if(!$row) $this->error('操作失败',U('User/address_list')); else $this->success("操作成功",U('User/address_list')); } public function save_pickup() { $post = I('post.'); if (empty($post['consignee'])) { return array('status' => -1, 'msg' => '收货人不能为空', 'result' => ''); } if (!$post['province'] || !$post['city'] || !$post['district']) { return array('status' => -1, 'msg' => '所在地区不能为空', 'result' => ''); } if(!check_mobile($post['mobile'])){ return array('status'=>-1,'msg'=>'手机号码格式有误','result'=>''); } if(!$post['pickup_id']){ return array('status'=>-1,'msg'=>'请选择自提点','result'=>''); } $user_logic = new UsersLogic(); $res = $user_logic->add_pick_up($this->user_id, $post); if($res['status'] != 1){ exit(''); } $call_back = $_REQUEST['call_back']; echo ""; exit(); // 成功 回调closeWindow方法 并返回新增的id } /* * 评论晒单 */ public function comment(){ $user_id = $this->user_id; $status = I('get.status',-1); $logic = new UsersLogic(); $data = $logic->get_comment($user_id,$status); //获取评论列表 $this->assign('page',$data['show']);// 赋值分页输出 $this->assign('comment_list',$data['result']); $this->assign('active','comment'); return $this->fetch(); } /** * @time 2017/2/9 * @author lxl * 订单商品评价列表 */ public function comment_list() { $order_id = I('get.order_id'); $good_id = I('get.good_id'); if (empty($order_id) || empty($good_id)) { $this->error("参数错误"); } else { //查找订单 $order_comment_where['order_id'] = $order_id; $order_info = M('order')->field('order_sn,order_id,add_time') ->where($order_comment_where)->find(); //查找评价商品 $order_comment_where['goods_id'] = $good_id; $order_goods = M('order_goods') ->field('goods_id,is_comment,goods_name,goods_num,goods_price,spec_key_name') ->where($order_comment_where) ->find(); $order_info = array_merge($order_info,$order_goods); $this->assign('order_info', $order_info); return $this->fetch(); } } /* *添加评论 */ public function add_comment() { $user_info = session('user'); $comment_img = serialize(I('comment_img/a')); // 上传的图片文件 $add['goods_id'] = I('goods_id/d'); $add['email'] = $user_info['email']; //$add['nick'] = $user_info['nickname']; $add['username'] = $user_info['nickname']; $add['order_id'] = I('order_id/d'); $add['service_rank'] = I('service_rank'); $add['deliver_rank'] = I('deliver_rank'); $add['goods_rank'] = I('goods_rank'); //$add['content'] = htmlspecialchars(I('post.content')); $add['content'] = I('content'); $add['img'] = $comment_img; $add['add_time'] = time(); $add['ip_address'] = $_SERVER['REMOTE_ADDR']; $add['user_id'] = $this->user_id; $logic = new UsersLogic(); //添加评论 $row = $logic->add_comment($add); exit(json_encode($row)); } /* * 个人信息 */ public function info(){ $userLogic = new UsersLogic(); $user_info = $userLogic->get_info($this->user_id); // 获取用户信息 $user_info = $user_info['result']; if(IS_POST){ I('post.nickname') ? $post['nickname'] = I('post.nickname') : false; //昵称 I('post.qq') ? $post['qq'] = I('post.qq') : false; //QQ号码 I('post.head_pic') ? $post['head_pic'] = I('post.head_pic') : false; //头像地址 I('post.sex') ? $post['sex'] = I('post.sex') : $post['sex'] = 0; // 性别 I('post.birthday') ? $post['birthday'] = strtotime(I('post.birthday')) : false; // 生日 I('post.province') ? $post['province'] = I('post.province') : false; //省份 I('post.city') ? $post['city'] = I('post.city') : false; // 城市 I('post.district') ? $post['district'] = I('post.district') : false; //地区 if(!$userLogic->update_info($this->user_id,$post)) $this->error("保存失败"); $this->success("操作成功"); exit; } // 获取省份 $province = M('region')->where(array('parent_id'=>0,'level'=>1))->select(); // 获取订单城市 $city = M('region')->where(array('parent_id'=>$user_info['province'],'level'=>2))->select(); //获取订单地区 $area = M('region')->where(array('parent_id'=>$user_info['city'],'level'=>3))->select(); $this->assign('province',$province); $this->assign('city',$city); $this->assign('area',$area); $this->assign('user',$user_info); $this->assign('sex',C('SEX')); $this->assign('active','info'); return $this->fetch(); } /* * 邮箱验证 */ public function email_validate(){ $userLogic = new UsersLogic(); $user_info = $userLogic->get_info($this->user_id); // 获取用户信息 $user_info = $user_info['result']; $step = I('get.step',1); if(IS_POST){ $email = I('post.email'); $old_email = I('post.old_email',''); //旧邮箱 $code = I('post.code'); $info = session('validate_code'); if(!$info) $this->error('非法操作'); if($info['time']error('验证超时,请重新验证'); } //检查原邮箱是否正确 if($user_info['email_validated'] == 1 && $old_email != $user_info['email']) $this->error('原邮箱匹配错误'); //验证邮箱和验证码 if($info['sender'] == $email && $info['code'] == $code){ session('validate_code',null); if(!$userLogic->update_email_mobile($email,$this->user_id)) $this->error('邮箱已存在'); $this->success('绑定成功',U('Home/User/index')); exit; } $this->error('邮箱验证码不匹配'); } $this->assign('user_info',$user_info); $this->assign('step',$step); return $this->fetch(); } /* * 手机验证 */ public function mobile_validate(){ $userLogic = new UsersLogic(); $user_info = $userLogic->get_info($this->user_id); //获取用户信息 $user_info = $user_info['result']; $config = F('sms','',TEMP_PATH); $sms_time_out = $config['sms_time_out']; $step = I('get.step',1); if(IS_POST){ $mobile = I('post.mobile'); $old_mobile = I('post.old_mobile',''); $code = I('post.code'); $info = session('validate_code'); if(!$info) $this->error('非法操作'); if($info['time']error('验证超时,请重新验证'); } //检查原手机是否正确 if($user_info['mobile_validated'] == 1 && $old_mobile != $user_info['mobile']) $this->error('原手机号码错误'); //验证手机和验证码 if($info['sender'] == $mobile && $info['code'] == $code){ session('validate_code',null); //验证有效期 if($info['time'] < time()) $this->error('验证码已失效'); if(!$userLogic->update_email_mobile($mobile,$this->user_id,2)) $this->error('手机已存在'); $this->success('绑定成功',U('Home/User/index')); exit; } $this->error('手机验证码不匹配'); } $this->assign('user_info',$user_info); $this->assign('time',$sms_time_out); $this->assign('step',$step); return $this->fetch(); } /** * 发送手机注册验证码 */ public function send_sms_reg_code(){ $mobile = I('mobile'); $userLogic = new UsersLogic(); if(!check_mobile($mobile)) exit(json_encode(array('status'=>-1,'msg'=>'手机号码格式有误'))); $code = rand(1000,9999); $send = $userLogic->sms_log($mobile,$code,$this->session_id); if($send['status'] != 1) exit(json_encode(array('status'=>-1,'msg'=>$send['msg']))); exit(json_encode(array('status'=>1,'msg'=>'验证码已发送,请注意查收'))); } /* *商品收藏 */ public function goods_collect(){ $userLogic = new UsersLogic(); $data = $userLogic->get_goods_collect($this->user_id); $this->assign('page',$data['show']);// 赋值分页输出 $this->assign('lists',$data['result']); $this->assign('active','goods_collect'); return $this->fetch(); } /* * 删除一个收藏商品 */ public function del_goods_collect(){ $id = I('get.id'); if(!$id) $this->error("缺少ID参数"); $row = M('goods_collect')->where(array('collect_id'=>$id,'user_id'=>$this->user_id))->delete(); if(!$row) $this->error("删除失败"); $this->success('删除成功'); } /* * 密码修改 */ public function password(){ //检查是否第三方登录用户 $logic = new UsersLogic(); $data = $logic->get_info($this->user_id); $user = $data['result']; if($user['mobile'] == ''&& $user['email'] == '') $this->error('请先绑定手机或邮箱',U('Home/User/info')); if(IS_POST){ $userLogic = new UsersLogic(); $data = $userLogic->password($this->user_id,I('post.old_password'),I('post.new_password'),I('post.confirm_password')); // 获取用户信息 if($data['status'] == -1) $this->error($data['msg']); $this->success($data['msg']); exit; } return $this->fetch(); } public function forget_pwd(){ if($this->user_id > 0){ $this->redirect('Home/User/index'); } if(IS_POST){ $logic = new UsersLogic(); $username = I('post.username'); $code = I('post.code'); $new_password = I('post.new_password'); $confirm_password = I('post.confirm_password'); $pass = false; //检查是否手机找回 if(check_mobile($username)){ if(!$user = get_user_info($username,2)) $this->error('账号不存在'); $check_code = $logic->sms_code_verify($username,$code,$this->session_id); if($check_code['status'] != 1) $this->error($check_code['msg']); $pass = true; } //检查是否邮箱 if(check_email($username)){ if(!$user = get_user_info($username,1)) $this->error('账号不存在'); $check = session('forget_code'); if(empty($check)) $this->error('非法操作'); if(!$username || !$code || $check['email'] != $username || $check['code'] != $code) $this->error('邮箱验证码不匹配'); $pass = true; } if($user['user_id'] > 0 && $pass) $data = $logic->password($user['user_id'],'',$new_password,$confirm_password,false); // 获取用户信息 if($data['status'] != 1) $this->error($data['msg'] ? $data['msg'] : '操作失败'); $this->success($data['msg'],U('Home/User/login')); exit; } return $this->fetch(); } public function set_pwd(){ if($this->user_id > 0){ $this->redirect('Home/User/Index'); } $check = session('validate_code'); $logic = new UsersLogic(); if(empty($check)){ $this->redirect('Home/User/forget_pwd'); }elseif($check['is_check']==0){ $this->error('验证码还未验证通过',U('Home/User/forget_pwd')); } if(IS_POST){ $password = I('post.password'); $password2 = I('post.password2'); if($password2 != $password){ $this->error('两次密码不一致',U('Home/User/forget_pwd')); } if($check['is_check']==1){ //$user = get_user_info($check['sender'],1); $user = M('users')->where("mobile|email", '=', $check['sender'])->find(); M('users')->where("user_id", $user['user_id'])->save(array('password'=>encrypt($password))); session('validate_code',null); $this->redirect('Home/User/finished'); }else{ $this->error('验证码还未验证通过',U('Home/User/forget_pwd')); } } return $this->fetch(); } public function finished(){ if($this->user_id > 0){ $this->redirect('Home/User/Index'); } return $this->fetch(); } public function check_captcha(){ $verify = new Verify(); $type = I('post.type','user_login'); if (!$verify->check(I('post.verify_code'), $type)) { exit(json_encode(0)); }else{ exit(json_encode(1)); } } public function check_username(){ $username = I('post.username'); if(!empty($username)){ $count = M('users')->where("email", $username)->whereOr('mobile', $username)->count(); exit(json_encode(intval($count))); }else{ exit(json_encode(0)); } } public function identity(){ if($this->user_id > 0){ $this->redirect('Home/User/Index'); } $username = I('post.username'); $userinfo = array(); if($username){ $userinfo = M('users')->where("email", $username)->whereOr('mobile', $username)->find(); $userinfo['username'] = $username; session('userinfo',$userinfo); }else{ $this->error('参数有误!!!'); } if(empty($userinfo)){ $this->error('非法请求!!!'); } unset($user_info['password']); $this->assign('userinfo',$userinfo); return $this->fetch(); } /** * 验证码验证 * $id 验证码标示 */ private function verifyHandle($id) { $verify = new Verify(); $result = $verify->check(I('post.verify_code'), $id ? $id : 'user_login'); if (!$result) { $this->error("图像验证码错误"); } } /** * 验证码获取 */ public function verify() { //验证码类型 $type = I('get.type') ? I('get.type') : 'user_login'; $config = array( 'fontSize' => 40, 'length' => 4, 'useCurve' => true, 'useNoise' => false, ); $Verify = new Verify($config); $Verify->entry($type); } public function order_confirm(){ $id = I('get.id/d',0); $data = confirm_order($id,$this->user_id); if(!$data['status']) $this->error($data['msg']); else $this->success($data['msg']); } /** * 申请退货 */ public function return_goods() { $order_id = I('order_id/d',0); $order_sn = I('order_sn',0); $goods_id = I('goods_id/d',0); $spec_key = I('spec_key'); $c = M('order')->where("order_id", $order_id)->where('user_id', $this->user_id)->count(); if($c == 0) { $this->error('非法操作'); exit; } $return_goods = M('return_goods')->where(['order_id'=>$order_id,'goods_id'=>$goods_id,'spec_key'=>$spec_key])->find(); if(!empty($return_goods)) { $this->success('已经提交过退货申请!',U('Home/User/return_goods_info',array('id'=>$return_goods['id']))); exit; } if(IS_POST) { $data['order_id'] = $order_id; $data['order_sn'] = $order_sn; $data['goods_id'] = $goods_id; $data['addtime'] = time(); $data['user_id'] = $this->user_id; $data['type'] = I('type'); // 服务类型 退货 或者 换货 $data['reason'] = I('reason'); // 问题描述 $data['imgs'] = I('imgs'); // 用户拍照的相片 $data['spec_key'] = I('spec_key'); // 商品规格 M('return_goods')->add($data); $this->success('申请成功,客服第一时间会帮你处理',U('Home/User/order_list')); exit; } $goods = M('goods')->where("goods_id", $goods_id)->find(); $this->assign('goods',$goods); $this->assign('order_id',$order_id); $this->assign('order_sn',$order_sn); $this->assign('goods_id',$goods_id); return $this->fetch(); } /** * 退换货列表 */ public function return_goods_list() { $count = M('return_goods')->where("user_id", $this->user_id)->count(); $page = new Page($count,10); $list = M('return_goods')->where("user_id", $this->user_id)->order("id desc")->limit("{$page->firstRow},{$page->listRows}")->select(); $goods_id_arr = get_arr_column($list, 'goods_id'); if(!empty($goods_id_arr)) $goodsList = M('goods')->where("goods_id","in", implode(',',$goods_id_arr))->getField('goods_id,goods_name'); $this->assign('goodsList', $goodsList); $this->assign('list', $list); $this->assign('page', $page->show());// 赋值分页输出 return $this->fetch(); } /** * 退货详情 */ public function return_goods_info() { $id = I('id/d',0); $return_goods = M('return_goods')->where("id", $id)->find(); if($return_goods['imgs']) $return_goods['imgs'] = explode(',', $return_goods['imgs']); $goods = M('goods')->where("goods_id", $return_goods['goods_id'])->find(); $this->assign('goods',$goods); $this->assign('return_goods',$return_goods); return $this->fetch(); } /** * 安全设置 */ public function safety_settings() { $userLogic = new UsersLogic(); $user_info = $userLogic->get_info($this->user_id); // 获取用户信息 $user_info = $user_info['result']; $this->assign('user',$user_info); return $this->fetch(); } /** * 申请提现记录 */ public function withdrawals(){ //C('TOKEN_ON',true); if(IS_POST) { $this->verifyHandle('withdrawals'); $data = I('post.'); $data['user_id'] = $this->user_id; $data['create_time'] = time(); $distribut_min = tpCache('basic.min'); // 最少提现额度 if($data['money'] < $distribut_min) { $this->error('每次最少提现额度'.$distribut_min); exit; } if($data['money'] > $this->user['user_money']) { $this->error("你最多可提现{$this->user['user_money']}账户余额."); exit; } if(M('withdrawals')->add($data)){ $this->success("已提交申请"); exit; }else{ $this->error('提交失败,联系客服!'); exit; } } $where['user_id'] = $this->user_id; $count = M('withdrawals')->where($where)->count(); $page = new Page($count,10); $show = $page->show(); $list = M('withdrawals')->where($where)->order("id desc")->limit("{$page->firstRow},{$page->listRows}")->select(); $this->assign('show',$show);// 赋值分页输出 $this->assign('list',$list); // 下线 return $this->fetch(); } public function recharge(){ if(IS_POST){ $user = session('user'); $data['user_id'] = $this->user_id; $data['nickname'] = $user['nickname']; $data['account'] = I('account'); $data['order_sn'] = 'recharge'.get_rand_str(10,0,1); $data['ctime'] = time(); $order_id = M('recharge')->add($data); if($order_id){ $url = U('Payment/getPay',array('pay_radio'=>$_REQUEST['pay_radio'],'order_id'=>$order_id)); redirect($url); }else{ $this->error('提交失败,参数有误!'); } } $paymentList = M('Plugin')->where("`type`='payment' and code!='cod' and status = 1 and scene in(0,2)")->select(); $paymentList = convert_arr_key($paymentList, 'code'); foreach($paymentList as $key => $val) { $val['config_value'] = unserialize($val['config_value']); if($val['config_value']['is_bank'] == 2) { $bankCodeList[$val['code']] = unserialize($val['bank_code']); } } $bank_img = include APP_PATH.'home/bank.php'; // 银行对应图片 $this->assign('paymentList',$paymentList); $this->assign('bank_img',$bank_img); $this->assign('bankCodeList',$bankCodeList); $count = M('recharge')->where(array('user_id'=>$this->user_id))->count(); $Page = new Page($count,10); $show = $Page->show(); $recharge_list = M('recharge')->where(array('user_id'=>$this->user_id))->limit($Page->firstRow.','.$Page->listRows)->select(); $this->assign('page',$show); $this->assign('recharge_list',$recharge_list);//充值记录 $count2 = M('account_log')->where(array('user_id'=>$this->user_id,'user_money'=>array('gt',0)))->count(); $Page2 = new Page($count2,10); $consume_list = M('account_log')->where(array('user_id'=>$this->user_id,'user_money'=>array('gt',0)))->limit($Page2->firstRow.','.$Page2->listRows)->select(); $this->assign('point_rate', tpCache('shopping.point_rate')); $this->assign('consume_list',$consume_list);//消费记录 $this->assign('page2',$Page2->show()); return $this->fetch(); } /** * 用户消息通知 * @author dyr * @time 2016/09/01 */ public function message_notice() { return $this->fetch('user/message_notice'); } /** * ajax用户消息通知请求 * @author dyr * @time 2016/09/01 */ public function ajax_message_notice() { $type = I('type',0); $user_logic = new UsersLogic(); $message_model = new Message(); if ($type == 1) { //系统消息 $user_sys_message = $message_model->getUserMessageNotice(); $user_logic->setSysMessageForRead(); } else if ($type == 2) { //活动消息:后续开发 $user_sys_message = array(); } else { //全部消息:后续完善 $user_sys_message = $message_model->getUserMessageNotice(); } $this->assign('messages', $user_sys_message); return $this->fetch('user/ajax_message_notice'); } public function get_user_info(){ echo $rs[0];exit; } }