uid; $user_info = Db::name('store_member') ->field('password,second_password',true) ->where('id',$uid) ->find(); if(empty($user_info)) $this->error('用户信息不正确'); $user_info['vip_name'] = $user_info['vip']==1 ? "藏友" : "创世勋章"; //是否有待支付订单 $order = Db::name('store_order')->where('status',0)->where('is_deleted',0)->where('mid',$uid)->count(); $user_info['is_order_no_paid'] = $order ? true : false; //今日是否签到 $date = date('Y-m-d'); $sign = Db::name('store_member_sign')->where('mid',$uid)->where('date',$date)->count(); $user_info['is_sign'] = $sign ? true : false; $this->success('获取成功',$user_info); } /** * @title 编辑个人信息 * @desc 编辑个人信息 * @author Gavin * @url /api/User_center/updateUserInfo * @method POST * @tag 编辑信息 * @header name:Authorization require:1 desc:Token * * @param name:name type:string require:0 default:-- desc:姓名 * @param name:headimg type:string require:0 default:-- desc:头像地址 */ public function updateUserInfo() { $headimg = input('post.headimg'); $name = trim(input('post.name','')); if(!$headimg && !$name) $this->error('参数错误'); $update_data= []; if($name) $update_data['name'] = $name; if ($headimg) $update_data['headimg'] = $headimg; if($name){ $check_member = Db::name('store_member') ->where('name',$name) ->where('id','<>',$this->uid) ->count(); if($check_member) $this->error('该用户名已被占用'); } $update_data['update_at'] = date('Y-m-d H:i:s'); if (Db::name('store_member')->where('id',$this->uid)->update($update_data)){ setMemberInfoHash($this->uid); $this->success('编辑成功'); } $this->error('编辑失败'); } /** * @title 实名认证 * @desc 实名认证 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/userCertification * @header name:Authorization require:1 desc:Token * @param name:true_name type:string require:1 default:-- desc:真实姓名 * @param name:id_card type:string require:1 default:-- desc:身份证号 */ public function userCertification() { $true_name = input('post.true_name'); $id_card = input('post.id_card'); if (!$true_name || !$id_card) $this->error('参数错误'); $check_id_card = isCreditNo($id_card); if (!$check_id_card) $this->error('身份证号格式错误'); $is_auth = Db::table('store_member')->where('id',$this->uid)->value('is_auth'); if($is_auth) $this->error('已认证'); $check = Db::name('store_member')->where('id_card',$id_card)->count(); if ($check) $this->error('身份证号已经认证过'); if (Db::table('store_member')->where('id',$this->uid)->update(['is_auth'=>1,'true_name'=>$true_name,'id_card'=>$id_card,'auth_at'=>date('Y-m-d H:i:s')])){ setMemberInfoHash($this->uid); $this->success('认证成功'); } $this->error('认证失败'); } /** * @title 修改密码 * @desc 修改密码 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/updatePass * @header name:Authorization require:1 desc:Token * @param name:old_password type:string require:1 default:-- desc:旧密码 * @param name:new_password type:string require:1 default:-- desc:新密码 * @param name:confirm_password type:string require:1 default:-- desc:确认密码 */ public function updatePass() { $old_password = input('post.old_password'); $new_password = input('post.new_password'); $confirm_password = input('post.confirm_password'); if (!$old_password || !$new_password || !$confirm_password) $this->error('参数错误'); if ($new_password!=$confirm_password) $this->error('密码与确认密码不一致'); if (!preg_match('/^[0-9a-z]{6,12}$/i',$new_password)) $this->error('密码格式错误,请输入6-12位数字+字母'); $member = Db::name('store_member')->where('id',$this->uid)->find(); if ($member['password']!=md5($old_password)) $this->error('旧密码错误'); $data['password'] = md5($new_password); $data['update_at'] = date('Y-m-d H:i:s'); if (Db::name('store_member')->where('id',$this->uid)->update($data)){ setMemberInfoHash($this->uid); $this->success('修改成功'); } $this->error('修改失败'); } /** * @title 修改二级密码 * @desc 修改二级密码 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/updateSecondPass * @header name:Authorization require:1 desc:Token * @param name:second_password type:string require:1 default:-- desc:二级密码 * @param name:confirm_second_password type:string require:1 default:-- desc:确认密码 */ public function updateSecondPass() { $second_password = input('post.second_password'); $confirm_second_password = input('post.confirm_second_password'); if (!$second_password || !$confirm_second_password) $this->error('参数错误'); if ($second_password!=$confirm_second_password) $this->error('密码与确认密码不一致'); if (!preg_match('/^[0-9]{6}$/i',$second_password)) $this->error('二级密码格式错误,请输入6位纯数字'); $data['second_password'] = md5($second_password); $data['update_at'] = date('Y-m-d H:i:s'); if (Db::name('store_member')->where('id',$this->uid)->update($data)){ setMemberInfoHash($this->uid); $this->success('修改成功'); } $this->error('修改失败'); } /** * @title 我的藏品 * @desc 我的藏品 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/myCollection * @header name:Authorization require:1 desc:Token * * @return name:id type:int require:0 default:0 desc:藏品ID * @return name:tag type:string require:0 default:0 desc:唯一标签 * @return name:name type:string require:0 default:0 desc:藏品名称 * @return name:cover type:string require:0 default:0 desc:藏品图片 * @return name:auth_img type:string require:0 default:0 desc:作者头像 * @return name:auth_name type:string require:0 default:0 desc:作者名称 */ public function myCollection(){ $list = Db::name('store_order_info') ->where('mid',$this->uid) ->whereIn('status','1,3') ->field('id,tag,pro_info') ->order('id desc') ->select(); foreach ($list as &$v){ $pro_info = json_decode($v['pro_info'],true); $v['name'] = $pro_info['name']; $v['cover'] = $pro_info['cover']; $v['auth_img'] = $pro_info['auth_img']; $v['auth_name'] = $pro_info['auth_name']; unset($v['pro_info']); } $this->success('成功',$list); } /** * @title 藏品详情 * @desc 藏品详情 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/myCollectionDetail * @header name:Authorization require:1 desc:Token * @param name:id type:int require:1 default:-- desc:藏品ID * * @return name:id type:int require:0 default:0 desc:藏品ID * @return name:tag type:string require:0 default:0 desc:唯一标签 * @return name:collectors_name type:string require:0 default:0 desc:收藏者 * @return name:collectors_hash type:string require:0 default:0 desc:收藏者hash * @return name:create_at type:string require:0 default:0 desc:收藏时间 * @return name:company type:string require:0 default:0 desc:流转公司 * @return name:company_hash type:string require:0 default:0 desc:流转公司hash * @return name:examples_illustrate type:string require:0 default:0 desc:转赠说明 * @return name:pro_info@name type:string require:0 default:0 desc:藏品名称 * @return name:pro_info@price type:string require:0 default:0 desc:藏品价格 * @return name:pro_info@label type:string require:0 default:0 desc:藏品标签 * @return name:pro_info@cover type:string require:0 default:0 desc:藏品图片 * @return name:pro_info@auth_img type:string require:0 default:0 desc:作者头像 * @return name:pro_info@auth_name type:string require:0 default:0 desc:作者姓名 * @return name:pro_info@warm_prompt type:string require:0 default:0 desc:温馨提示 * @return name:pro_info@share_img type:string require:0 default:0 desc:分享二维码 */ public function myCollectionDetail(){ $id = input('id'); if (!$id) $this->error('参数错误'); $info = Db::name('store_order_info')->where('id',$id)->find(); if (!$info) $this->error('藏品不存在'); $info['pro_info'] = json_decode($info['pro_info'],true); if (!isset($info['pro_info']['share_img'])){ $info['pro_info']['share_img'] = Db::name('store_collection')->where('id',$info['pro_info']['id'])->value('share_img'); } $info['collectors_name'] = Db::name('store_member')->where('id',$this->uid)->value('name'); $info['collectors_hash'] = $info['collectors_hash']=='' ? "发放中" : $info['collectors_hash']; $info['collectors_hash_time'] = $info['collectors_hash_time']=='' ? "发放中" : $info['collectors_hash_time']; $info['examples_illustrate'] = Db::table('system_config')->where('name','examples_illustrate')->value('value'); $this->success('成功',$info); } /** * @title 转赠 * @desc 转赠 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/examples * @header name:Authorization require:1 desc:Token * @param name:id type:int require:1 default:-- desc:藏品ID * @param name:phone type:string require:1 default:-- desc:手机号 * @param name:wallet_address type:int require:1 default:-- desc:钱包地址 * @param name:second_password type:int require:1 default:-- desc:二级密码 * */ public function examples(){ $id = input('id'); $phone = input('phone'); $wallet_address = input('wallet_address'); $second_password = input('second_password'); if (!$id || !$phone || !$wallet_address) $this->error('参数错误'); $info = Db::name('store_order_info')->where('id',$id)->find(); if (!$info) $this->error('藏品不存在'); if ($info['status']==2) $this->error('藏品已转赠'); $member = Db::name('store_member')->where('phone',$phone)->where('wallet_address',$wallet_address)->find(); if (!$member) $this->error('转赠用户不存在'); $examples_number = Db::name('store_member')->where('id',$this->uid)->value('examples_number'); $date = date('Y-m'); $number = Db::name('store_collect_examples_log') ->where('mid',$this->uid) ->where('date',$date) ->count(); //if ($number>=$examples_number) $this->error('转赠次数不足,无法转赠'); if (!$info['collectors_hash']) $this->error('发放中,无法转赠'); $mem = getMemberInfoHash($this->uid); if ($mem['second_password']!=md5($second_password)) $this->error('密码错误'); $pro_info = json_decode($info['pro_info'],true); $log = Db::name('store_collect_examples_log') ->where('order_info_id',$id) ->count(); if (!$log){ if ($pro_info['one_given_day']!=0){ $exam_time = strtotime($info['create_at'])+($pro_info['one_given_day']*24*60*60); if ($exam_time>time()) $this->error('持有时间限制,无法转赠'); } }else{ if ($pro_info['other_given_day']!=0){ $exam_time = strtotime($info['create_at'])+($pro_info['other_given_day']*24*60*60); if ($exam_time>time()) $this->error('持有时间限制,无法转赠'); } } if ($info['is_business']==0 || $info['is_gas']==0) $this->error('能量值/业务费不足,不能转赠'); $com = true; Db::startTrans(); try { Db::name('store_order_info') ->where('id',$id) ->update(['status'=>2,'over_time'=>date('Y-m-d H:i:s'),'to_mid'=>$member['id']]); $to_date = [ 'order_id'=>$info['order_id'], 'order_no'=>get_order_sn(), 'tag'=>$info['tag'], 'mid'=>$member['id'], 'pro_info'=>$info['pro_info'], 'status'=>3, 'to_mid'=>$this->uid, 'over_time'=>date('Y-m-d H:i:s'), 'company'=>'象寻数字科技(上海)有限公司', 'company_hash'=>$info['company_hash'], 'company_hash_time'=>$info['company_hash_time'], 'ddcid'=>$info['ddcid'], 'collectors_hash'=>'', 'collectors_hash_time'=>date('Y-m-d H:i:s') ]; Db::name('store_order_info')->insert($to_date); $log_date = [ 'order_info_id'=>$id, 'mid'=>$this->uid, 'to_mid'=>$member['id'], 'date'=>date('Y-m') ]; Db::name('store_collect_examples_log')->insert($log_date); Db::commit(); }catch (\Exception $e){ $com = false; Db::rollback(); } if ($com){ $this->success('转赠成功'); } $this->error('转赠失败'); } /** * @title 消息列表 * @desc 消息列表 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/messageList * @header name:Authorization require:1 desc:Token * * @param name:page type:int : default:1 desc:页数 * @param name:page_num type:int : default:20 desc:每页数 * * @return name:id type:int require:0 default:0 desc:消息ID * @return name:title type:string require:0 default:0 desc:标题 * @return name:content type:string require:0 default:0 desc:内容 * @return name:create_at type:string require:0 default:0 desc:发布时间 * @return name:is_read type:string require:0 default:0 desc:是否查看true:已查看false:未查看 */ public function messageList(){ $count = Db::name('store_message')->where('is_deleted',0)->count(); $list = Db::name('store_message') ->field('is_deleted,update_at',true) ->where('is_deleted',0) ->order('id desc') ->limit($this->off_set,$this->page_num) ->select(); // echo Db::name('store_message')->getLastSql();die; foreach ($list as &$v){ $is_read = Db::name('store_message_read_log')->where('mid',$this->uid)->where('message_id',$v['id'])->count(); $v['is_read'] = $is_read ? true : false; } $this->success('成功',compact('count','list')); } /** * @title 点击消息 * @desc 点击消息,查看消息 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/readMessage * @header name:Authorization require:1 desc:Token * * @param name:id type:int : default:1 desc:消息ID * */ public function readMessage(){ $id = input('id'); if (!$id) $this->error('参数错误'); $log = Db::name('store_message_read_log')->where('message_id',$id)->where('mid',$this->uid)->count(); if (!$log){ $data = [ 'mid'=>$this->uid, 'message_id'=>$id ]; Db::name('store_message_read_log')->insert($data); } $this->success('成功'); } /** * @title 人脸认证sign * @desc 人脸认证sign * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/getFaceSign * @header name:Authorization require:1 desc:Token * * * @param name:name type:string default:1 desc:姓名 * @param name:idNo type:string default:1 desc:身份证号 * * @return name:sign type:string require: default:-- desc:签名 * */ public function getFaceSign(){ $name = input('name'); $idNo = input('idNo'); if (!$name || !$idNo) $this->error('参数错误'); $userId = $this->uid; //$userId = get32Str(); $data = getfaceid($name,$idNo,$userId); $this->success('成功',$data); } /** * @title 邀请记录 * @desc 邀请记录 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/invitedRecord * @header name:Authorization require:1 desc:Token * * @param name:page type:int : default:1 desc:页数 * @param name:page_num type:int : default:20 desc:每页数 * * @return name:id type:int require:0 default:0 desc:用户ID * @return name:headimg type:string require:0 default:0 desc:头像 * @return name:name type:string require:0 default:0 desc:名称 * @return name:create_at type:string require:0 default:0 desc:时间 */ public function invitedRecord(){ $count = Db::name('store_member')->where('pid',$this->uid)->count(); $list = Db::name('store_member') ->field('id,headimg,name,create_at') ->where('pid',$this->uid) ->order('id desc') ->limit($this->off_set,$this->page_num) ->select(); $this->success('成功',compact('count','list')); } /** * @title 签到 * @desc 签到 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/sign * @header name:Authorization require:1 desc:Token * */ public function sign(){ $date = date('Y-m-d'); $log = Db::name('store_member_sign')->where('mid',$this->uid)->where('date',$date)->count(); if ($log) $this->error('今日已签到'); $data = [ 'mid'=>$this->uid, 'date'=>$date ]; $com = true; Db::startTrans(); try { $id = Db::name('store_member_sign')->insertGetId($data); $sign_integral = getConfigValue('sign_integral'); if ($sign_integral>0){ //memberMoneyChange($sign_integral,1,$this->uid,'签到',1,$id); } Db::commit(); }catch (\Exception $e){ $com=false; Db::rollback(); } if ($com){ $this->success('签到成功'); } $this->error('签到失败'); } /** * @title 积分记录 * @desc 积分记录 * @author Gavin * @method POST * @tag 编辑信息 * @url /api/User_center/integralLog * @header name:Authorization require:1 desc:Token * * @param name:page type:int : default:1 desc:页数 * @param name:page_num type:int : default:20 desc:每页数 * * @return name:id type:int require:0 default:0 desc:id * @return name:change type:string require:0 default:0 desc:变动数值 * @return name:title type:string require:0 default:0 desc:标题 * @return name:create_at type:string require:0 default:0 desc:时间 */ public function integralLog(){ $where = [ 'm_id'=>$this->uid, 'type'=>1 ]; $count = Db::name('store_member_log')->where($where)->count(); $list = Db::name('store_member_log') ->field('id,pm,change,title,create_at') ->where($where) ->order('id desc') ->limit($this->off_set,$this->page_num) ->select(); foreach ($list as &$v){ if ($v['pm']==1){ $v['change'] = '+'.$v['change']; }else{ $v['change'] = '-'.$v['change']; } } $this->success('成功',compact('count','list')); } }