1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354 |
- <?php
- namespace app\api\controller;
- use AlibabaCloud\Client\AlibabaCloud;
- use AlibabaCloud\Client\Exception\ClientException;
- use AlibabaCloud\Client\Exception\ServerException;
- use app\common\library\AliPay2;
- use app\common\library\HuijuKjPay;
- use think\cache\driver\Redis;
- use think\Db;
- use think\facade\Validate;
- /**
- * @title 会员个人中心
- * @controller UserCenter
- * @group base
- */
- class UserCenter extends Base
- {
- public function initialize()
- {
- parent::initialize();
- // parent::check_login();
- }
- /**
- * @title 获取个人信息
- * @desc 个人信息
- * @author Gavin
- * @url /api/User_center/getUserInfo
- * @method POST
- * @tag 个人信息
- * @header name:Authorization require:1 desc:Token
- * @return name:id type:int default:-- desc:ID(邀请ID)
- * @return name:phone type:string default:-- desc:手机号
- * @return name:name type:string default:-- desc:昵称
- * @return name:headimg type:string default:-- desc:头像地址
- * @return name:integral type:int default:-- desc:积分
- * @return name:snap_card type:int default:-- desc:抢购卡
- * @return name:wallet_address type:int default:-- desc:钱包地址
- * @return name:true_name type:string default:-- desc:真实姓名
- * @return name:id_card type:string default:-- desc:身份证号
- * @return name:is_auth type:int default:-- desc:是否认证(0否1是)
- * @return name:auth_at type:string default:-- desc:认证时间
- * @return name:vip_name type:int default:-- desc:身份
- * @return name:is_order_no_paid type:string default:-- desc:是否有未支付订单true:有false:没有
- * @return name:is_sign type:string default:-- desc:今日是否已经签到true:已签到false:未签到
- * @return name:invite_img type:string default:-- desc:邀请二维码
- * @return name:invite_address type:string default:-- desc:邀请地址
- * @return name:lucky_number type:int default:-- desc:剩余抽奖次数
- * @return name:money type:string default:-- desc:余额
- */
- public function getUserInfo()
- {
- parent::check_login();
- $uid = $this->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;
- //获取每日免费次数
- $free_number = getConfigValue('free_lucky_number');
- //获取当日免费抽奖记录
- $date = date('Y-m-d');
- $now_date_count = Db::name('store_blind_box_log')->where('m_id',$this->uid)->where('date',$date)->where('is_free',0)->count();
- $lucky_number = $user_info['lottery_number'] + ($free_number-$now_date_count);
- $user_info['lucky_number'] =$lucky_number<=0 ? 0 : $lucky_number;
- $user_info['id'] = (string)$user_info['id'];
- //生成邀请码
- if (!$user_info['invite_img'] || !$user_info['invite_address']){
- $code = $user_info['invite_code'];
- $invite_img = setintivecode($code);
- $invite_address = getintiveaddress($code);
- Db::name('store_member')->where('id',$this->uid)->update(['invite_img'=>$invite_img,'invite_address'=>$invite_address]);
- }
- $user_info['invite_img'] = str_replace('http:','https:',$user_info['invite_img']);
- $this->success('获取成功',$user_info);
- }
- /**
- * @title 绑定opendid
- * @desc 绑定opendid
- * @author Gavin
- * @url /api/User_center/bindOpenid
- * @method POST
- * @tag 编辑信息
- * @header name:Authorization require:1 desc:Token
- *
- * @param name:code type:string require:0 default:-- desc:code
- */
- public function bindOpenid()
- {
- parent::check_login();
- $code = input('code');
- if(empty($code)) $this->error('参数错误');
- $appid = getConfigValue('wechat_appid');
- $secret = getConfigValue('wechat_appsecret');
- $res = http_get('https://api.weixin.qq.com/sns/oauth2/access_token?appid='.$appid.'&secret='.$secret.'&code='.$code.'&grant_type=authorization_code');
- $res = json_decode($res,true);
- if (isset($res['openid'])){
- $update_data['openid'] = $res['openid'];
- $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('绑定失败');
- }else{
- $this->error('获取openid失败');
- }
- }
- /**
- * @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()
- {
- parent::check_login();
- $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
- * @url /api/User_center/bind_zfb
- * @method POST
- * @tag 编辑信息
- * @header name:Authorization require:1 desc:Token
- *
- * @param name:account type:string require:0 default:-- desc:支付宝账号
- * @param name:zfb_real_name type:string require:0 default:-- desc:真实姓名
- */
- public function bind_zfb(){
- parent::check_login();
- $this->check_login();
- $account = input('account'); //账号
- $real_name = input('real_name'); //真实姓名
- if (!$account) $this->error('支付宝账号为空');
- if (!$real_name) $this->error('真实姓名为空');
- $update_data['zfb_account'] = $account;
- $update_data['zfb_real_name'] = $real_name;
- $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:身份证号
- * @param name:bank_card type:string require:1 default:-- desc:银行卡号
- * @param name:bank_mobile type:string require:0 default:-- desc:银行卡预留手机号
- */
- public function userCertification(){
- parent::check_login();
- //redis原子锁
- if (redisSetNx('userCertification'.$this->uid,2)){
- $true_name = input('post.true_name');
- $id_card = input('post.id_card');
- $bank_card = input('post.bank_card');
- $bank_mobile = input('post.bank_mobile');
- if (!$true_name || !$id_card || !$bank_card) $this->error('参数错误');
- $check_id_card = isCreditNo($id_card);
- //获取年龄
- $age = getAge($id_card);
- // if (!$check_id_card) $this->error('身份证号格式错误');
- // if (!checkbank($bank_card)) $this->error('银行卡号格式错误');
- if ($age<18 || $age>65) $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('身份证号已经认证过');
- $bank_check = Db::name('store_member')->where('bank_card',$bank_card)->count();
- if ($bank_check) $this->error('银行卡号已经使用过');
- //二要素
- //if (!idcardlingyu($id_card,$true_name)) $this->error('身份证与姓名验证失败');
- //四要素
- $res = idcardlingyufour($id_card,$true_name,$bank_card,$bank_mobile);
- if (!$res['success']) $this->error($res['remark']);
- if (Db::table('store_member')->where('id',$this->uid)
- ->update(['is_auth'=>1,'true_name'=>$true_name,'id_card'=>$id_card,'bank_card'=>$bank_card,'bank_mobile'=>$bank_mobile,'auth_at'=>date('Y-m-d H:i:s')])){
- setMemberInfoHash($this->uid);
- $user1 = getMemberInfoHash($this->uid); //获取用户信息
- if ($user1['pid']){
- $data = [
- 'mid'=>$user1['pid'],
- 'to_mid'=>$this->uid,
- 'create_at'=>date('Y-m-d H:i:s')
- ];
- Db::name('store_activities_invite_log')->insert($data);
- }
- pull_new($this->uid);
- DelRedisSetNx('userCertification'.$this->uid);
- $this->success('认证成功');
- }
- DelRedisSetNx('userCertification'.$this->uid);
- $this->error('认证失败');
- }else{
- $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()
- {
- parent::check_login();
- $old_password = input('post.old_password');
- $new_password = input('post.new_password');
- $confirm_password = input('post.confirm_password');
- // $yzm = input('post.yzm');
- 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();
- //验证短信验证码
- // $time = time()-60;
- // $sms = Db::name('store_sms')->where(['mobile' => $member['phone'], 'event' => 'forgetpwd'])
- // ->where('createtime','>',$time)
- // ->order('id', 'DESC')
- // ->find();
- // if (!$sms || $sms['code'] != $yzm) $this->error('短信验证码不正确!');
- 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()
- {
- parent::check_login();
- $second_password = input('post.second_password');
- $confirm_second_password = input('post.confirm_second_password');
- $yzm = input('post.yzm');
- 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位纯数字');
- $member = getMemberInfoHash($this->uid); //获取用户信息
- //验证短信验证码
- $time = time()-60;
- $sms = Db::name('store_sms')->where(['mobile' => $member['phone'], 'event' => 'forgetpwd'])
- ->where('createtime','>',$time)
- ->order('id', 'DESC')
- ->find();
- if (!$sms || $sms['code'] != $yzm) $this->error('短信验证码不正确!');
- $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(){
- parent::check_login();
- $type = input('type');
- $where = [
- 'mid'=>$this->uid,
- 'is_destruction'=>1,
- 'resale_status'=>1
- ];
- $cids = Db::name('store_order_info')->where($where)
- ->where('status','neq','2')
- ->when($type,function ($query) use ($type){
- if ($type==1){
- $query->where('type','neq',3);
- }else{
- $query->where('type',3);
- }
- })
- ->group('c_id')
- ->column('c_id');
- $arr = [];
- foreach ($cids as &$v){
- $array['c_id'] = $v;
- $array['count'] = Db::name('store_order_info')
- ->where($where)
- ->when($type,function ($query) use ($type){
- if ($type==1){
- $query->where('type','neq',3);
- }else{
- $query->where('type',3);
- }
- })
- ->where('c_id',$v)
- ->where('status','neq','2')
- ->count();
- $info = Db::name('store_order_info')
- ->where($where)->where('c_id',$v)
- ->limit(1)
- ->field('id,name,cover,tag,pro_info')
- ->find();
- $array['cover'] = $info['cover'];
- $array['name'] = $info['name'];
- $pro_info = json_decode($info['pro_info'],true);
- $array['auth_img'] = $pro_info['auth_img'];
- $array['auth_name'] = $pro_info['auth_name'];
- $tag = explode('#',$info['tag']);
- $tag2 = explode('/',$tag[1]);
- $array['tag'] = $tag[0].'#???'.'/'.$tag2[1];
- array_push($arr,$array);
- }
- $this->success('成功',$arr);
- $list = Db::name('store_order_info')
- ->where('mid',$this->uid)
- ->when($type,function ($query) use ($type){
- if ($type==1){
- $query->where('type','neq',3);
- }else{
- $query->where('type',3);
- }
- })
- ->where('status','neq','2')
- ->where('is_destruction',1)
- ->where('resale_status',1)
- ->field('id,tag,pro_info,c_id')
- ->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']? $pro_info['auth_img'] : Db::name('store_collection')->where('id',$v['c_id'])->value('auth_img');
- $v['auth_name'] = $pro_info['auth_name'] ? $pro_info['auth_name'] : Db::name('store_collection')->where('id',$v['c_id'])->value('auth_name');
- if ($v['tag']){
- $tag = explode('#',$v['tag']);
- $tag1 = substr($tag[0],0,6);
- $v['tag'] = $tag1.'#'.$tag[1];
- }
- unset($v['pro_info']);
- }
- $this->success('成功',$list);
- }
- /**
- * @title 藏品列表
- * @desc 藏品列表
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/myCollectionList
- * @header name:Authorization require:1 desc:Token
- *
- * @param name:c_id type:string 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: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 myCollectionList(){
- parent::check_login();
- $c_id = input('c_id');
- if (!$c_id) $this->error('参数错误');
- $list = Db::name('store_order_info')
- ->where('mid',$this->uid)
- ->where('status','neq','2')
- ->whereIn('type','1,3')
- ->where('c_id',$c_id)
- ->where('is_destruction',1)
- ->where('resale_status',1)
- ->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/myBoxCollection
- * @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 myBoxCollection(){
- parent::check_login();
- $list = Db::name('store_order_info')
- ->where('mid',$this->uid)
- ->where('status','neq','2')
- ->where('type',3)
- ->where('is_destruction',1)
- ->where('resale_status',1)
- ->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(){
- parent::check_login();
- $id = input('id');
- if (!$id) $this->error('参数错误');
- $info = Db::name('store_order_info')
- ->where('mid',$this->uid)
- ->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');
- }
- $issuer = Db::name('store_collection')->where('id',$info['c_id'])->value('issuer');
- if (!empty($issuer)){
- $info['company'] = $issuer;
- }
- $info['detail_img'] = $info['pro_info']['detail_img'];
- $info['format'] = $info['pro_info']['format'];
- $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');
- $info['c_id'] = (string)$info['c_id'];
- if (!empty($info['tag'])){
- $tag = explode('#',$info['tag']);
- $tag1 = substr($tag[0],0,6);
- $info['tag'] = $tag1.'#'.$tag[1];
- }
- $info['pro_info']['auth_name'] = $info['pro_info']['auth_name'] ? $info['pro_info']['auth_name'] : Db::name('store_collection')->where('id',$info['c_id'])->value('auth_name');
- $info['pro_info']['auth_img'] = $info['pro_info']['auth_img'] ? $info['pro_info']['auth_name'] : Db::name('store_collection')->where('id',$info['c_id'])->value('auth_img');
- if ($info['collectors_hash_time']!='0000-00-00 00:00:00'){
- $info['create_at'] = $info['collectors_hash_time'];
- }
- $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(){
- parent::check_login();
- //redis原子锁
- if (redisSetNx('examples'.$this->uid,2)){
- $v = getConfigValue('examples_switch');
- if (!$v) $this->error('维护中,暂时关闭');
- $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)->where('mid',$this->uid)->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('转赠用户不存在');
- if ($member['id']==$this->uid) $this->error('不能转赠给自己');
- if (!$info['collectors_hash']) $this->error('发放中,无法转赠');
- $mem = getMemberInfoHash($this->uid);
- if ($mem['second_password']!=md5($second_password)) $this->error('密码错误');
- $pro_info = Db::name('store_collection')->where('id',$info['c_id'])->find();
- $log = Db::name('store_collect_examples_log')
- ->where('order_info_id',$id)
- ->find();
- 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($log['create_at'])+($pro_info['other_given_day']*24*60*60);
- if ($exam_time>time()) $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'],
- 'c_id'=>$info['c_id'],
- 'name'=>$pro_info['name'],
- 'cover'=>$pro_info['cover'],
- 'pro_info'=>$info['pro_info'],
- 'type'=>$pro_info['type'],
- 'status'=>3,
- 'to_mid'=>$this->uid,
- 'over_time'=>date('Y-m-d H:i:s'),
- 'tokenid'=>$info['tokenid'],
- 'nfttype'=>$info['nfttype'],
- 'nftid'=>$info['nftid'],
- 'collectors_hash'=>'',
- 'collectors_hash_time'=>date('Y-m-d H:i:s')
- ];
- $new_id = Db::name('store_order_info')->insertGetId($to_date);
- $log_date = [
- 'order_info_id'=>$new_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){
- DelRedisSetNx('examples'.$this->uid);
- $this->success('转赠成功');
- }
- DelRedisSetNx('examples'.$this->uid);
- $this->error('转赠失败');
- }else{
- $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(){
- parent::check_login();
- $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(){
- parent::check_login();
- $count = Db::name('store_member')
- ->where('is_auth',1)
- ->where('pid',$this->uid)->count();
- $list = Db::name('store_member')
- ->field('id,headimg,name,create_at,phone,is_auth')
- ->where('pid',$this->uid)
- //->where('is_auth',1)
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select();
- foreach ($list as &$v){
- $v['phone'] = substr_replace($v['phone'],'****',3,4);
- $v['name'] = substr($v['name'],0,16);
- $v['create_at'] = date('Y-m-d',strtotime($v['create_at']));
- }
- $this->success('成功',compact('count','list'));
- }
- /**
- * @title 邀请排行榜
- * @desc 邀请排行榜
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/invitedList
- * @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:phone type:string require:0 default:0 desc:手机号
- * @return name:create_at type:string require:0 default:0 desc:时间
- */
- public function invitedList(){
- $count = Db::name('store_member as a')
- ->field('a.id,a.name,a.headimg,a.phone,a.pid,(select count(b.id) from store_member as b where b.pid=a.id) as count')
- ->group('a.id')
- ->having('count>0')
- ->count();
- $list = Db::name('store_member as a')
- ->field('a.id,a.name,a.headimg,a.phone,a.pid,(select count(b.id) from store_member as b where b.pid=a.id) as count')
- ->group('a.id')
- ->having('count>0')
- ->order('count 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(){
- parent::check_login();
- $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(){
- parent::check_login();
- $where = [
- 'm_id'=>$this->uid,
- 'type'=>1
- ];
- $status = input('status');
- $count = Db::name('store_member_log')
- ->where($where)
- ->when($status,function ($query) use ($status){
- $pm = $status==1 ? 1 : 0;
- $query->where('pm',$pm);
- })
- ->count();
- $list = Db::name('store_member_log')
- ->field('id,pm,change,title,create_at')
- ->where($where)
- ->when($status,function ($query) use ($status){
- $pm = $status==1 ? 1 : 0;
- $query->where('pm',$pm);
- })
- ->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'));
- }
- /**
- * @title 余额记录
- * @desc 余额记录
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/moneyLog
- * @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 moneyLog(){
- parent::check_login();
- $where = [
- 'm_id'=>$this->uid,
- 'type'=>3
- ];
- $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'));
- }
- /**
- * @title 提现
- * @desc 提现
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/withdraw
- * @header name:Authorization require:1 desc:Token
- *
- * @param name:money type:int : default: desc:提现金额
- * @param name:withdraw_type type:int : default: desc:提现方式
- *
- */
- public function withdraw(){
- parent::check_login();
- //redis原子锁
- if (redisSetNx('withdraw'.$this->uid,3)){
- $v = getConfigValue('withdraw_switch');
- if (!$v) $this->error('维护中,暂时关闭');
- $money = input('money');
- $withdraw_type = input('withdraw_type','bank');
- if (!$money) $this->error('参数错误');
- $user = Db::name('store_member')->where('id',$this->uid)->find();
- if ($user['money']<$money) $this->error('余额不足');
- $withdraw_min_price = getConfigValue('withdraw_min_price'); //最小提现金额
- $withdraw_max_price = getConfigValue('withdraw_max_price'); //最大提现金额
- $poundage_proportion = getConfigValue('poundage_proportion'); //手续费百分比
- if ($money < $withdraw_min_price)
- $this->error('最低提现'.$withdraw_min_price.'元');
- if ($money > $withdraw_max_price)
- $this->error('最大提现'.$withdraw_min_price.'元');
- if ($withdraw_type=='zfb'){
- if (!$user['zfb_account'] || !$user['zfb_real_name']) $this->error('请先绑定支付宝');
- }
- if ($withdraw_type=='bank'){
- if (!$user['withdraw_name'] || !$user['withdraw_bank_card']) $this->error('请先绑定提现银行卡');
- }
- $data['mid'] = $this->uid;
- $order_no = get_order_sn();
- $data['order_no'] = $order_no;
- $data['price'] = $money;
- $data['name'] = $user['withdraw_name'];
- $data['bank_id_card'] = $user['withdraw_bank_card'];
- $data['poundage_proportion'] = $poundage_proportion;
- $proportion = sprintf("%.2f", $money*($poundage_proportion/100)); //四舍五入保留两位小数点
- $data['proportion'] = $proportion;
- $real_money = $money-$proportion;
- $data['real_money'] = $real_money;
- $data['withdraw_type'] = $withdraw_type;
- $id =Db::name('store_member_withdraw')->insertGetId($data);
- if ($id){
- Db::startTrans();
- try {
- //减少用户余额
- $res = memberMoneyChange($money,3,$this->uid,'余额提现',0,$id);
- if ($res){
- Db::commit();
- DelRedisSetNx('withdraw'.$this->uid);
- $this->success('提交成功,等待审核');
- }else{
- Db::rollback();
- DelRedisSetNx('withdraw'.$this->uid);
- $this->error('提现失败,请稍后重试');
- }
- }catch (Exception $e) {
- Db::rollback();
- DelRedisSetNx('withdraw'.$this->uid);
- $this->error('提现失败,请稍后重试1');
- }
- }else{
- DelRedisSetNx('withdraw'.$this->uid);
- $this->error('提现失败,请稍后重试2');
- }
- }else{
- $this->error('请求过快,请稍后重试');
- }
- }
- /**
- * @title 打开盲盒
- * @desc 打开盲盒
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/openBoxCollection
- * @header name:Authorization require:1 desc:Token
- *
- * @param name:id type:int : default: desc:藏品ID
- *
- */
- public function openBoxCollection(){
- parent::check_login();
- //redis原子锁
- if (redisSetNx('openBox'.$this->uid,3)){
- $id = input('id');
- if (!$id) $this->error('参数错误');
- $info = Db::name('store_order_info')
- ->where('id',$id)
- ->where('status','neq',2)
- ->where('mid',$this->uid)
- ->where('is_destruction',1)
- ->find();
- if (!$info) $this->error('盲盒不存在');
- if ($info['resale_status']!=1) $this->error('盲盒挂售中或已出售');
- $com = true;
- Db::startTrans();
- try {
- //销毁
- Db::name('store_order_info')->where('id',$id)->update(['is_destruction'=>0]);
- checkBoxCollection($info['c_id']);
- $prize_arr = Db::name('store_box')
- ->where('status',1)
- ->where('coll_id',$info['c_id'])
- ->where('is_del',1)
- ->field('id,rate')
- ->select();
- foreach ($prize_arr as $key => $val) {
- $arr[$val['id']] = $val['rate'];//概率数组
- }
- $rid = get_rand($arr); //根据概率获取奖项id
- $pr_info = Db::name('store_box')->where('id',$rid)->field('id,title,prize,is_prize')->find();
- $return = [
- 'is_prize'=>$pr_info['is_prize']
- ];
- $coll_info = getCollectionInfoHash($pr_info['prize']);
- if ($pr_info['is_prize']==1){
- $json_info = json_encode($coll_info,true);
- $return['name'] = $pr_info['title'];
- $return['cover'] = $coll_info['cover'];
- }else{
- $json_info = '';
- $return['name'] = '未中奖';
- $return['cover'] = '';
- }
- $data = [
- 'm_id'=>$this->uid,
- 'b_id'=>$rid,
- 'is_prize'=>$pr_info['is_prize'],
- 'name'=>$return['name'],
- 'cover'=>$return['cover'],
- 'info'=>$json_info,
- 'date'=>date('Y-m-d'),
- 'is_free'=>1
- ];
- Db::name('store_blind_box_log')->insert($data);
- if ($pr_info['is_prize']==1){
- //获取排名
- $rank = getRanking($pr_info['prize'])+1;
- $tag = getTag($pr_info['prize'],$rank,$coll_info['inventory']);
- saveRanking($pr_info['prize']);
- $is_nft = Db::name('hash2')->where('goods_id',$pr_info['prize'])->where('success',1)->find();
- $collectors_hash = '';
- $date = [
- 'order_id'=>0,
- 'order_no'=>get_order_sn(),
- 'tag'=>$tag,
- 'mid'=>$this->uid,
- 'c_id'=>$pr_info['prize'],
- 'name'=>$coll_info['name'],
- 'cover'=>$coll_info['cover'],
- 'pro_info'=>$json_info,
- 'tokenid'=>$is_nft['class_id'],
- 'nfttype'=>$is_nft['operationId'],
- 'collectors_hash'=>$collectors_hash,
- 'collectors_hash_time'=>'',
- 'status'=>4
- ];
- Db::name('store_order_info')->insert($date);
- }
- Db::commit();
- }catch (Exception $e) {
- $com = false;
- Db::rollback();
- }
- if ($com){
- setMemberInfoHash($this->uid);
- if ($pr_info['is_prize']==1){
- //减掉库存
- loseCollectionInventory($pr_info['prize'],1);
- }
- DelRedisSetNx('openBox'.$this->uid);
- $this->success('成功',$return);
- }else{
- DelRedisSetNx('openBox'.$this->uid);
- $this->error('开启失败,请稍后重试');
- }
- }else{
- $this->error('请求过快');
- }
- }
- /**
- * @title 抢购卡列表
- * @desc 抢购卡列表
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/snapLog
- * @header name:Authorization require:1 desc:Token
- *
- * @param name:page type:int : default:1 desc:页数
- * @param name:page_num type:int : default:20 desc:每页数
- *
- */
- public function snapLog(){
- parent::check_login();
- checksnapcard($this->uid);
- $status = input('status',1);
- $list = Db::name('store_snap_card_log')
- ->where('m_id',$this->uid)
- ->where('is_use',$status)
- ->select();
- foreach ($list as &$v){
- if ($v['type']==2){
- $v['collection_name'] = Db::name('store_collection')->where('id',$v['collection_id'])->value('name');
- }
- }
- $this->success('成功',$list);
- }
- /**
- * @title 签约银行卡发送短信
- * @desc 签约银行卡发送短信
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/bindCardsms
- * @header name:Authorization require:1 desc:Token
- */
- public function bindCardsms(){
- parent::check_login();
- $name = input('name');
- $id_card_no = input('id_card_no');
- $bank_card_no = input('bank_card_no');
- $mobile = input('mobile');
- if (!$name || !$id_card_no || !$bank_card_no || !$mobile) $this->error('参数错误');
- $check_id_card = isCreditNo($id_card_no);
- if (!$check_id_card) $this->error('身份证号格式错误');
- if (!checkbank($bank_card_no)) $this->error('银行卡号格式错误');
- if (!Validate::regex($mobile, "^1\d{10}$")) $this->error('手机号格式错误');
- $huiju = new HuijuKjPay();
- $result = $huiju->sms($name,$id_card_no,$bank_card_no,$mobile);
- if ($result['resp_codo']=='SUCCESS'){
- if ($result['biz_code']=='JS000000'){
- $data = json_decode($result['data'],true);
- if ($data['order_status']=='P3000'){
- $this->success('发送成功',$result);
- }else{
- $this->error($data['err_msg']);
- }
- }else{
- $this->error($result['biz_msg']);
- }
- }else{
- $this->error('发送失败');
- }
- }
- /**
- * @title 签约银行卡
- * @desc 签约银行卡
- * @author Gavin
- * @method POST
- * @tag 编辑信息
- * @url /api/User_center/bindCard
- * @header name:Authorization require:1 desc:Token
- */
- public function bindCard(){
- parent::check_login();
- $name = input('name');
- $id_card_no = input('id_card_no');
- $bank_card_no = input('bank_card_no');
- $mobile = input('mobile');
- $seckey = input('seckey');
- $mch_order_no = input('mch_order_no');
- $sms_code = input('sms_code');
- if (!$name || !$id_card_no || !$bank_card_no || !$mobile || !$seckey || !$mch_order_no || !$sms_code) $this->error('参数错误');
- $check_id_card = isCreditNo($id_card_no);
- if (!$check_id_card) $this->error('身份证号格式错误');
- if (!checkbank($bank_card_no)) $this->error('银行卡号格式错误');
- if (!Validate::regex($mobile, "^1\d{10}$")) $this->error('手机号格式错误');
- $huiju = new HuijuKjPay();
- $result = $huiju->signing($seckey,$mch_order_no,$sms_code);
- if ($result['resp_codo']=='SUCCESS'){
- if ($result['biz_code']=='JS000000'){
- $data = json_decode($result['data'],true);
- if ($data['order_status']=='P1000'){
- $date = [
- 'hj_pay_name'=>$name,
- 'hj_pay_id_card'=>$id_card_no,
- 'hj_pay_bank_card'=>$bank_card_no,
- 'hj_pay_mobile'=>$mobile,
- 'hj_pay_status'=>1,
- 'hj_pay_time'=>date('Y-m-d H:i:s')
- ];
- if (Db::name('store_member')->where('id',$this->uid)->update($date)){
- setMemberInfoHash($this->uid);
- $this->success('签约成功',$result);
- }else{
- $this->error('签约失败');
- }
- }else{
- $this->error($data['err_msg']);
- }
- }else{
- $this->error($result['biz_msg']);
- }
- }else{
- $this->error('签约失败');
- }
- }
- /**
- * @title 绑定提现银行卡
- * @desc 绑定提现银行卡
- * @author Gavin
- * @url /api/User_center/bind_withdraw_card
- * @method POST
- * @tag 编辑信息
- * @header name:Authorization require:1 desc:Token
- *
- * @param name:withdraw_name type:string require:0 default:-- desc:姓名
- * @param name:withdraw_bank_card type:string require:0 default:-- desc:卡号
- */
- public function bind_withdraw_card(){
- parent::check_login();
- $this->check_login();
- $withdraw_name = input('withdraw_name');
- $withdraw_bank_card = input('withdraw_bank_card');
- if (!$withdraw_name) $this->error('姓名为空');
- if (!$withdraw_bank_card) $this->error('卡号为空');
- if (!checkbank($withdraw_bank_card)) $this->error('银行卡号格式错误');
- $update_data['withdraw_name'] = $withdraw_name;
- $update_data['withdraw_bank_card'] = $withdraw_bank_card;
- $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('绑定失败');
- }
- }
|