Пример #1
0
//预先判断ebaytoken文件
$__token_file = WEB_PATH_CONF_SCRIPTS_KEYS_EBAY . 'keys_' . $__ebayaccount . '.php';
if (!file_exists($__token_file)) {
    exit($__token_file . " does not exists!!!");
}
/*$_SESSION['user']	= '******';
	$user	= $_SESSION['user'];*/
//require_once "ebay_order_cron_config.php";
require_once WEB_PATH_LIB_SDK_EBAY . "GetOrdersID.php";
#############类或API 实例化##############
$api_goi = new GetOrdersIDAPI($__ebayaccount);
#########加载lost_order_id########
$relost_order_ids = '';
$push_order_ids = '';
$lost_orderid_path = EBAY_RAW_DATA_PATH . 'lost_ebay_orderid/' . $__ebayaccount . '/lost_sql.txt';
$orderid_content = read_and_empty_lost_sql($lost_orderid_path);
$orderid_lists = sql_str2array($orderid_content);
if (!empty($orderid_lists)) {
    foreach ($orderid_lists as $orderid_sql) {
        if (!$dbConn->execute($orderid_sql)) {
            $relost_order_ids .= $orderid_sql . "\n";
        } else {
            $push_order_ids .= $orderid_sql . "\n";
        }
    }
    if (!empty($relost_order_ids)) {
        write_lost_sql($lost_orderid_path, $relost_order_ids);
    }
    if (!empty($push_order_ids)) {
        write_lost_sql(str_replace('lost_sql.txt', 'push_success_sql.txt', $lost_orderid_path), $push_order_ids);
    }
Пример #2
0
function GetFeedback_change($account)
{
    global $dbcon, $api_feedback, $user;
    $verb = 'GetFeedback';
    $cc = date("Y-m-d H:i:s");
    $start = date('Y-m-d H:i:s', strtotime("{$cc} - 61 days"));
    $start = strtotime($start);
    $end = strtotime($cc);
    $file = EBAY_RAW_DATA_PATH . 'feedback_lost_sql/lost_sql.txt';
    $file2 = EBAY_RAW_DATA_PATH . 'feedback_lost_sql/success_sql.txt';
    $get = "select FeedbackID,CommentText,CommentingUser,ItemID,TransactionID,CommentType from ebay_feedback where account='{$account}' and (CommentType='Neutral' or CommentType='Negative') and feedbacktime between {$start} and {$end}";
    $get = $dbcon->execute($get);
    $get = $dbcon->getResultArray($get);
    for ($ii = 0; $ii < count($get); $ii++) {
        $status = "";
        $feedbackID = $get[$ii]['FeedbackID'];
        $commentingUser = $get[$ii]['CommentingUser'];
        $itemID = $get[$ii]['ItemID'];
        $transactionID = $get[$ii]['TransactionID'];
        $commentType = $get[$ii]['CommentType'];
        $commentText = $get[$ii]['CommentText'];
        $responseXml = $api_feedback->request_change($itemID, $transactionID, $commentingUser);
        if (stristr($responseXml, 'HTTP 404') || $responseXml == '') {
            return 'id not found';
        }
        $data = XML_unserialize($responseXml);
        $ack = $data['GetFeedbackResponse']['Ack'];
        $feedbackRevised = $data['GetFeedbackResponse']['FeedbackDetailArray']['FeedbackDetail'];
        $feedbackRevised = $feedbackRevised[0]['FeedbackRevised'];
        if ($ack != "Success") {
            echo '同步失败' . "\n";
        } else {
            if ($feedbackRevised == "true") {
                $feedback = $data['GetFeedbackResponse']['FeedbackDetailArray']['FeedbackDetail'];
                $feedbackType = $feedback[0]['CommentType'];
                $feedbackUser = $feedback[0]['CommentingUser'];
                if ($commentingUser == $feedbackUser) {
                    $feedbackText = addslashes(str_rep($feedback[0]['CommentText']));
                } else {
                    $feedbackText = addslashes(str_rep($commentText));
                }
                if ($commentType != $feedbackType) {
                    if ($commentType == "Neutral") {
                        if ($feedbackType == "Positive") {
                            $status = "21";
                            //中评改好评
                        } else {
                            if ($feedbackType == "Negative") {
                                $status = "23";
                                //中评改差评
                            } else {
                                $status = "22";
                                //中评改中评
                            }
                        }
                    } else {
                        if ($commentType == "Negative") {
                            if ($feedbackType == "Positive") {
                                $status = "31";
                                //差评改好评
                            } else {
                                if ($feedbackType == "Neutral") {
                                    $status = "32";
                                    //差评改中评
                                } else {
                                    $status = "33";
                                    //差评改差评
                                }
                            }
                        } else {
                        }
                    }
                    //过滤好评
                    if ($status != "") {
                        $update_type = "update ebay_feedback set status='{$status}',CommentType='{$feedbackType}',CommentText='{$feedbackText}' where FeedbackID={$feedbackID}";
                        $sql = $update_type;
                        echo $sql . "\n";
                        if ($dbcon->execute($update_type)) {
                            echo 'Success ' . "\n";
                            write_a_file($file2, $sql);
                        } else {
                            echo 'Failure ' . "\n";
                            echo mysql_errno() . ": " . mysql_error() . "\n";
                            write_a_file($file, $sql);
                        }
                        echo 'userID :' . $commentingUser . ":" . $commentType . "------------>" . $feedbackType . "\n";
                    }
                }
            }
        }
    }
    #########加载feedback_lost_sql########
    $relost_feedback_ids = '';
    $push_feedback_ids = '';
    $lost_feedback_path = $file;
    $feedback_content = read_and_empty_lost_sql($lost_feedback_path);
    $feedback_lists = sql_str2array($feedback_content);
    if (!empty($feedback_lists)) {
        foreach ($feedback_lists as $feedback_sql) {
            if (!$dbcon->execute($feedback_sql)) {
                $relost_feedback_ids .= $feedback_sql . "\n";
                //获取失败语句
            } else {
                $push_feedback_ids .= $feedback_sql . "\n";
                //获取成功语句
            }
        }
        if (!empty($relost_feedback_ids)) {
            write_a_file($lost_feedback_path, $relost_feedback_ids);
            //执行失败再次写入
        }
        if (!empty($push_feedback_ids)) {
            write_a_file(str_replace('lost_sql.txt', 'push_success_sql.txt', $lost_feedback_path), $push_feedback_ids);
        }
    }
}