向多个用户发送通知功能

时间:2016-06-07 15:53:36

标签: php mysql

我有两个不同的数据库,其中包含表Phpfox_user,manual_userid和移动表。可以有3个用户具有相同的user_id但不同的移动号码存储在phpfox_user表和manual_userid中,并且表移动中有GCM ID。(移动无列以及)。现在我想向具有相同用户ID的所有手机号码发送通知。 目前通知仅发送给单个经理

function request_block($data){

//print_r($data);
$tower=new Tower;
$project=new Project;
$note=new Notification;
$fields=array('user_id', 'pay_opt', 'sale_type', 'hold_status', 'cost', 'is_manager_blocked', 'is_action_taken');
$params=array(
    ':user_id' => $data['user_id'],
    ':pay_opt' => $data['buy_opt'],
    ':sale_type' => $data['sale_type'],
    ':hold_status' => '1',
    ':cost' => $data['cost'],
    ':is_manager_blocked' => '0',
    ':is_action_taken' => '0',
    ':id' => $data['flat_id']
);
$where = 'where id= :id';
$tower->block_flat($fields, $params, $where);
$user_details=$tower->get_user_details($data['user_id']);
$flat_details=$tower->get_flat_details_cost($data['flat_id']);
$tower_main=$tower->get_tower_main_details($flat_details['tower_id']);
$project_details=$project->get_project_details($tower_main['project_id']);
$manager_details=$tower->get_user_details($project_details['manager_id']);
$manager_details=$tower->get_manualuser_details($project_details['manager_id']) ;
$mob_details=$tower->get_gcmid($manager_details['cf_mobile']);
$par['mobile']=$manager_details['cf_mobile'] ;

//print_r($flat_details); print_r($tower_main); print_r($project_details);
//$manager_details=$tower->get_user_details($project_details['manager_']);
$data['send_by']='user';
$data['user_id']=$data['user_id'];
$data['manager_id']=$project_details['manager_id'];
$data['message']='You have received a Booking request - by '.$user_details['full_name'].' '.$user_details['cf_mobile'].' for Flat no. '.$flat_details['flat_no'].' in '.$tower_main['tower_name'].' tower of '.$project_details['project_name'].' Project';
$data['msg_details']=$data['message'];
$data['notification_type']='user-to-manager';
$note->insert_notification($data);
$par['msg']=$data['message'];
if(count($mob_details)>=1 && $mob_details['gcmid']!='')
{
    $fuck['notification_type']='user-to-manager';
    $fuck['notification_text']=$par['msg'];
    $fuck['user_id']=$data['user_id'];
    $tt['message']=$fuck;
    $tt['gcmid']=$mob_details['gcmid'];
    send_notification($tt);
}
if(count($tower_images)>=1)
{
    $result['data']=$tower_images;
} else {
    $result['message']='No result found';
}
$result['message']='Flat block requested';
//print_array($par);
$result['status']='success';
send_sms($par);
$res=json_encode(array($result));
echo $res;}

这是获取用户手机号码的两个功能

public function get_user_details($user_id)
{
    $params = array( ':user_id' => $user_id);
    $sql = "SELECT * FROM phpfox_user, phpfox_user_custom where phpfox_user.user_id=phpfox_user_custom.user_id AND phpfox_user.user_id=:user_id";
    $stmt = parent::query($sql, $params, '', 'main');
    while($row = $stmt->fetch(PDO::FETCH_ASSOC)) :
        return $result[]=$row;
    endwhile;
    return $result;
}
public function get_manualuser_details($user_id)
{
    $params = array( ':user_id' => $user_id);
    $sql = "SELECT * FROM manual_userid where user_id=:user_id";
    $stmt = parent::query($sql, $params);
    while($row = $stmt->fetch(PDO::FETCH_ASSOC)) :
        return $res=$row;
    endwhile;
    return $result;}
public function get_gcmid($data)
{
    $mobile=str_replace('+','0',$data);
    $params = array( ':mobile' => $mobile);
    $sql = "SELECT * FROM mobile where mobile=:mobile";
    $stmt = parent::query($sql, $params);
    while($row = $stmt->fetch(PDO::FETCH_ASSOC)) :
        return $res=$row;
    endwhile;
}

0 个答案:

没有答案