Example #1
0
function handle_jaray_submit($dao, $query_string, $para, &$error_message)
{
    if ($para['event_type'] == "opt_in") {
        //订阅, 不转发给cp
        return EC_OK;
    }
    if ($para['event_type'] == "one_off") {
        //请求量非常大,但是无法正常处理,先保留
        return EC_OK;
    }
    $mr_data = array();
    $linkid = $para['transactionid'];
    $mr_data['mr_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $mr_data['status'] = $para['status'];
    $mr_data['sp_code'] = intval($para['shortcode']);
    $mr_data['content'] = $para['momessage'];
    $mr_data['cmd'] = $para['momessage'];
    $mr_data['parter_symbol'] = INFOBIP;
    $mr_data['mo_time'] = date('Y-m-d H:i:s');
    $mr_data['mr_time'] = date('Y-m-d H:i:s');
    $mr_data['submit_flag'] = 1;
    //表示收到了MR请求
    $mr_data['mobile_num'] = $para['phone'];
    $mr_data['link_id'] = $linkid;
    if ($para['event_type'] == "opt_out") {
        //退订,直接转发
        $ret = TransmitAll($dao, $mr_data, $query_string, $error_message);
        if ($ret != 0) {
            live_log(ERROR, $ret, $error_message);
            interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
            return $ret;
        }
    }
    if ($para['event_type'] == "recurring_billing") {
        //包月计费,正常按照通道扣量
        $id = 0;
        $ret = write_original_data($dao, $mr_data, true, $id, $error_message);
        if ($ret != 0) {
            live_log(ERROR, $ret, $error_message);
            interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
            http_response_code(400);
            return $ret;
        }
        $ret = TransmitMo($dao, $id, $mr_data, true, $error_message);
        if ($ret != 0) {
            live_log(ERROR, $ret, $error_message);
            interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
            return $ret;
        }
    }
    return EC_OK;
}
Example #2
0
$mo_data = array();
$mo_data['mobile_num'] = $para['phone'];
$mo_data['content'] = $para['message'];
$mo_data['link_id'] = $para['transactionid'];
$mo_data['parter_symbol'] = INFOBIP;
$mo_data['mo_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$mo_data['submit_flag'] = 0;
$mo_data['sp_code'] = intval($para['shortcode']);
$mo_data['mo_time'] = date('Y-m-d H:i:s');
$mo_data['transmit_flag'] = Dao::TRANSMIT_FLAG_INITAL;
$linkid = $mo_data['link_id'];
$id = 0;
$ret = write_original_data($dao, $mo_data, true, $id, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$ret = TransmitMo($dao, $id, $mo_data, false, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    echo 202;
    return;
}
echo 200;
live_log(INFO, EC_OK, "linkid: {$linkid}, infobip mo success.");
interface_log(INFO, EC_OK, "linkid: {$linkid}, infobip mo success.");
return;
Example #3
0
$mo_data['mobile_num'] = $para['mobile'];
$mo_data['content'] = $para['content'];
$mo_data['link_id'] = $para['linkid'];
$mo_data['parter_symbol'] = XY;
$mo_data['mo_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$mo_data['submit_flag'] = 0;
$mo_data['mo_submit_date'] = $para['createDate'];
$mo_data['sp_code'] = intval($para['spcode']);
$mo_data['mo_time'] = date('Y-m-d H:i:s');
$mo_data['transmit_flag'] = Dao::TRANSMIT_FLAG_INITAL;
$linkid = $mo_data['link_id'];
$id = 0;
$ret = write_original_data($dao, $mo_data, true, $id, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$ret = TransmitMo($dao, $id, $mo_data, false, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    echo 202;
    return;
}
echo 200;
live_log(INFO, EC_OK, "linkid: {$linkid}, hs mo success.");
interface_log(INFO, EC_OK, "linkid: {$linkid}, hs mo success.");
return;
Example #4
0
function TransmitAll($dao, $mo_data, $query_string, &$error_message)
{
    $is_trasmit = false;
    $cp_url = "";
    $linkid = $mo_data['link_id'];
    $ret = $dao->QueryTransmitUrlForJaray($mo_data['parter_symbol'], $mo_data['sp_code'], $mo_data['cmd'], $cp_url, $cp_flag, $error_message);
    if ($ret != 0) {
        live_log(ERROR, $ret, $error_message);
        return $ret;
    }
    live_log(INFO, EC_OK, "url: {$cp_url}");
    ///TODO:根据规则进行请求转发, mo 不需要转发,只转发成功的就可以了
    if (!empty($cp_url)) {
        $component = new Component_CP_CALL();
        $bret = $component->call($cp_url, "GET", $query_string, $ret, $error_message);
        if ($bret == false) {
            live_log(ERROR, EC_SYSTEM_INTERNAL_ERROR, "tramsmit mo to cp error." . $error_message);
        } else {
            $log_send_data['op_type'] = 1;
            $log_send_data['record_type'] = 1;
            $log_send_data['url'] = $cp_url;
            $log_send_data['content'] = $query_string;
            $log_send_data['create_time'] = date('Y-m-d H:i:s');
            $dao->AddLog($log_send_data, $error_message);
            live_log(INFO, EC_OK, "TransmitAll: send opt_out data to CP success.");
        }
    } else {
        live_log(INFO, EC_OK, "TransmitAll:not need to send opt_out data to CP.");
    }
    return EC_OK;
}
Example #5
0
    return;
}
$mr_data = array();
$linkid = $para['msgid'];
$mr_data['mr_addr'] = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$mr_data['status'] = $para['status'];
$mr_data['mr_submit_date'] = $para['mrtime'];
$mr_data['mr_time'] = date('Y-m-d H:i:s');
$mr_data['submit_flag'] = 1;
//表示收到了MR请求
$mr_data['mobile_num'] = $para['mobile'];
$mr_data['link_id'] = $linkid;
$id = 0;
$ret = write_original_data($dao, $mr_data, false, $id, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    http_response_code(400);
    echo 202;
    return;
}
$ret = TransmitMr($dao, $id, $mr_data, $true, $error_message);
if ($ret != 0) {
    live_log(ERROR, $ret, $error_message);
    interface_log(ERROR, $ret, "response: {$linkid}, err_msg: " . $error_message);
    echo 200;
    return;
}
echo 200;
interface_log(INFO, EC_OK, "linkid: {$linkid}, hs mr success.");
return;
Example #6
0
 protected function _verifyInput(&$args, $rules)
 {
     $req = $args['interface']['para'];
     $result = ParamChecker::getInstance()->checkParam($rules, $req);
     if (!$result['result']) {
         $this->_retValue = EC_INVALID_INPUT;
         $this->_retMsg = $result['msg'];
         live_log(ERROR, $this->_retValue, $this->_retMsg);
         return false;
     }
     $keys = array_keys($rules);
     extract($req);
     $this->_args = compact($keys);
     if (isset($channel_id)) {
         $this->setLogAppIdAndChannelId($app_id, $channel_id);
     } else {
         $this->setLogAppIdAndChannelId($app_id);
     }
     return true;
 }
Example #7
0
function CheckInput($str_type, $para)
{
    $bret = false;
    if ($str_type === "BKK_MO") {
        $bret = CheckBBKMo($para);
    } else {
        if ($str_type === "BKK_MR") {
            $bret = CheckBBKMr($para);
        } else {
            if ($str_type === "HS_MO") {
                $bret = CheckHSMo($para);
            } else {
                if ($str_type === "HS_MR") {
                    $bret = CheckHSMr($para);
                } else {
                    if ($str_type === INFOBIP . "_MO") {
                        $bret = CheckInfobipMo($para);
                    } else {
                        if ($str_type === INFOBIP . "_MR") {
                            $bret = CheckInfobipMr($para);
                        } else {
                            if ($str_type === "XY_MO") {
                                $bret = CheckXYMo($para);
                            } else {
                                if ($str_type === "XY_MR") {
                                    $bret = CheckXYMr($para);
                                } else {
                                    live_log(ERROR, EC_SYSTEM_INTERNAL_ERROR, "invalid str_type.");
                                    $bret = false;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return $bret;
}
Example #8
0
 /**
  * 获取CP的信息,并确认是否需要转发
  *
  * @param string $sp_name
  * @param int $sp_code
  * @param bool $is_transmit, false 表示不需要转发, true 表示需要转发
  * @param string $cp_url
  * @param string $error_message
  * @return int 
  */
 public function GetTransmitInfo($sp_name, $sp_code, $cmd, &$is_transmit, &$cp_url, &$cp_flag, &$error_message)
 {
     try {
         ///TODO:更具sp_name and sp_code to check is or not to transmit, and get cp url
         $this->session_->Begin();
         $sql_1 = "select sp_id from sp_info where name = '{$sp_name}'";
         $result_rows_1 = $this->session_->ExecuteSelectSql($sql_1);
         if (count($result_rows_1) != 1) {
             $is_transmit = false;
             $error_message = "can not find sp_name. invalid sp_id.";
             return EC_DIRTY_DB_DATA_ERROR;
         }
         $sp_id = $result_rows_1[0]['sp_id'];
         $sql_2 = "select id, cp_id, day_base, day_cut, cut_day_time, day_count, over_base_flag from channel_info where channel_code = {$sp_code} and sp_id = {$sp_id} and cmd = '{$cmd}' and status = 1";
         $result_rows_2 = $this->session_->ExecuteSelectSql($sql_2);
         if (count($result_rows_2) != 1) {
             $is_transmit = false;
             $error_message = "can not find channel info for record.";
             return EC_DIRTY_DB_DATA_ERROR;
         }
         $channel_find = $result_rows_2[0];
         $id = intval($channel_find['id']);
         $cp_id = intval($channel_find['cp_id']);
         $day_base = intval($channel_find['day_base']);
         $day_cut = intval($channel_find['day_cut']);
         $cut_day_time = $channel_find['cut_day_time'];
         $day_count = intval($channel_find['day_count']);
         $over_base_flag = intval($channel_find['over_base_flag']);
         $sql_3 = "select url, flag from cp_info where cp_id = {$cp_id} and status = 1";
         $result_rows_3 = $this->session_->ExecuteSelectSql($sql_3);
         if (count($result_rows_3) != 1) {
             $is_transmit = false;
             $error_message = "can not find cp_url, invalid cp_id or status is 0";
             return EC_DIRTY_DB_DATA_ERROR;
         }
         $cp_url = $result_rows_3[0]['url'];
         $cp_flag = intval($result_rows_3[0]['flag']);
         $update_data = array();
         if (date('Y-m-d') == $cut_day_time) {
             //如果是当天就在原来的基础上进行计数
             if ($over_base_flag == 0) {
                 if ($day_count >= $day_base) {
                     $over_base_flag = 1;
                     $day_count = 1;
                     $is_transmit = true;
                     //print "<p> set over_base_flag to 1, transmit.<p>";
                     live_log(INFO, EC_OK, "set over_base_flag to 1, transmit.");
                 } else {
                     $is_transmit = true;
                     $day_count = $day_count + 1;
                     //print "<p> not over base, transmit";
                     live_log(INFO, EC_OK, "not over base, transmit.");
                 }
             } else {
                 if ($day_count >= $day_cut) {
                     $is_transmit = false;
                     $day_count = 0;
                     //print "<p> cut one, not transmit.<p>";
                     live_log(INFO, EC_OK, "cut one, not transmit.");
                 } else {
                     $is_transmit = true;
                     $day_count = $day_count + 1;
                     //print "<p> transmit.<p>";
                     live_log(INFO, EC_OK, "trasmit request, day_count add 1.");
                 }
             }
         } else {
             //如果是新的一天,需要重新开始计数
             $cut_day_time = date('Y-m-d');
             $update_data['cut_day_time'] = $cut_day_time;
             $day_count = 1;
             $over_base_flag = 0;
             $is_transmit = true;
             //print "<p> new day. transmit.<p>";
             live_log(INFO, EC_OK, "another new day, transmit request.");
         }
         $update_data['day_count'] = $day_count;
         $update_data['over_base_flag'] = $over_base_flag;
         $this->session_->UpdateObject('channel_info', array('id' => $id), $update_data);
         $this->session_->Commit();
     } catch (Exception $e) {
         $error_message = $e->getMessage();
         return EC_ACCESS_DB_ERROR;
     }
     return EC_OK;
 }