Commit 9c82eab7 authored by hujun's avatar hujun

释放过期的绑定关系

parent 49d6f7b8
...@@ -34,7 +34,7 @@ class PrivacyNumber ...@@ -34,7 +34,7 @@ class PrivacyNumber
$report = new SecretReport(); $report = new SecretReport();
$report->allowField(true)->save($post_data[0]); $report->allowField(true)->save($post_data[0]);
Log::write(serialize($post_data[0]),'AliYunSecretReport'); //记录日志 Log::write(json_encode($post_data[0]),'AliYunSecretReport'); //记录日志
return json_encode(['code'=>0,'msg'=>'接收成功']); return json_encode(['code'=>0,'msg'=>'接收成功']);
} }
...@@ -69,4 +69,36 @@ class PrivacyNumber ...@@ -69,4 +69,36 @@ class PrivacyNumber
return ; return ;
} }
/**
* 释放过期的绑定关系
*
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function releaseNumber() {
$bind_data = Db::table('aliYun_binding_phone')->field('id,aliYun_phone_id,create_time')->where('status',1)->select();
$time = strtotime(date('Y-m-d')); //今天0点
$binding_phone_id = [];
$phone_id = [];
foreach ($bind_data as $k=>$v) {
$date = date('Y-m-d',strtotime($bind_data['create_time']) + _EXPIRATION); //有限期
$data = strtotime($date);
//解除绑定
if ($data <= $time) {
Db::table('aliYun_binding_phone')->where('id',$v['id'])->setField('status',0);
Db::table('aliYun_phone')->where('id',$v['aliYun_phone_id'])->setField('status',0);
$binding_phone_id[$k] = $v['id'];
$phone_id[$k] = $v['aliYun_phone_id'];
}
}
$id['aliYun_binding_phone'] = implode(',',$binding_phone_id);
$id['aliYun_phone'] = implode(',',array_unique($phone_id));
Log::write(json_encode($id),'AliYunReleaseNumber'); //记录日志
return ;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment