Esempio n. 1
0
function xt_ajax_unorder()
{
    $result = array('code' => 0, 'msg' => '', 'result' => array());
    if (!isset($_POST['id']) || empty($_POST['id'])) {
        $result['code'] = 500;
        $result['msg'] = '未指定要找回的订单';
        exit(json_encode($result));
    }
    if (!isset($_POST['platform']) || empty($_POST['platform'])) {
        $result['code'] = 500;
        $result['msg'] = '未指定要找回的订单的类型';
        exit(json_encode($result));
    }
    if (!isset($_POST['tradeId']) || empty($_POST['tradeId'])) {
        $result['code'] = 500;
        $result['msg'] = '未指定要找回的订单的订单号';
        exit(json_encode($result));
    }
    $table = '';
    $field_tradeId = '';
    $field_commission = '';
    $field_payTime = '';
    $field_outer = 'outInfo';
    switch ($_POST['platform']) {
        case 'taobao':
            $table = XT_TABLE_TAOBAO_REPORT;
            $field_tradeId = 'trade_id';
            $field_commission = 'commission';
            $field_payTime = 'pay_time';
            $field_outer = 'outer_code';
            break;
        case 'paipai':
            $table = XT_TABLE_PAIPAI_REPORT;
            $field_tradeId = 'dealId';
            $field_commission = 'brokeragePrice';
            $field_payTime = 'chargeTime';
            $field_outer = 'outInfo';
            break;
        case 'yiqifa':
            $table = XT_TABLE_YIQIFA_REPORT;
            $field_tradeId = 'orderNo';
            $field_commission = 'commission';
            $field_payTime = 'orderTime';
            $field_outer = 'outerCode';
            break;
    }
    if (empty($table)) {
        $result['code'] = 500;
        $result['msg'] = '订单类型不正确';
        exit(json_encode($result));
    }
    $user = wp_get_current_user();
    if ($user->exists()) {
        global $wpdb;
        $order = $wpdb->get_row('SELECT * FROM ' . $table . ' WHERE id=' . intval($_POST['id']));
        if (empty($order)) {
            $result['code'] = 500;
            $result['msg'] = '未找到指定的订单';
            exit(json_encode($result));
        }
        if ($order->user_id > 0) {
            $result['code'] = 500;
            $result['msg'] = '该订单已被[' . $order->user_name . ']找回';
            exit(json_encode($result));
        }
        if ($order->{$field_tradeId} == $_POST['tradeId']) {
            if ($wpdb->update($table, array('user_id' => $user->ID, 'user_name' => $user->user_login), array('id' => intval($_POST['id'])))) {
                $needFanxian = false;
                $commission = $order->{$field_commission};
                if ($_POST['platform'] == 'paipai') {
                    $commission = round($commission / 100, 2);
                    $needFanxian = $order->bargainState == 0 && xt_is_fanxian();
                } elseif ($_POST['platform'] == 'yiqifa') {
                    $needFanxian = $order->orderStatus == 'A' && xt_is_fanxian();
                } elseif ($_POST['platform'] == 'taobao') {
                    $needFanxian = true;
                }
                if ($needFanxian) {
                    if (!empty($order->{$field_outer}) && preg_match("/^([a-zA-Z]{4})8\$/", str_replace(XT_FANXIAN_PRE, '', $order->{$field_outer}), $guids)) {
                        $users = xt_report_fanxian_member($_POST['platform'], $order->{$field_outer} . xt_user_guid($user->ID));
                        $buyer = $users['buyer'];
                        $sharer = $users['sharer'];
                        $adser = $users['adser'];
                        xt_report_fanxian_save($_POST['platform'], $buyer, $sharer, $adser, $_POST['tradeId'], $commission, $order->{$field_payTime});
                    } else {
                        $users = xt_report_fanxian_member($_POST['platform'], XT_FANXIAN_PRE . $user->ID);
                        $buyer = $users['buyer'];
                        $sharer = $users['sharer'];
                        $adser = $users['adser'];
                        xt_report_fanxian_save($_POST['platform'], $buyer, $sharer, $adser, $_POST['tradeId'], $commission, $order->{$field_payTime});
                    }
                }
            }
        } else {
            $result['code'] = 500;
            $result['msg'] = '订单号不正确';
        }
    } else {
        $result['code'] = 500;
        $result['msg'] = '未登录';
    }
    exit(json_encode($result));
}
Esempio n. 2
0
function xt_meta_box_post()
{
    global $post;
    wp_nonce_field(plugin_basename(__FILE__), 'xt_meta_box_post');
    ?>
    <style type="text/css">
        .xt-items li{padding:0px;margin:0px;display: inline;float: left;margin-right: 17px;width: 152px;position: relative;cursor: default;}
        .xt-items li b{display:none;width:5px;height:5px;}
        .xt-items li div>a{color: #6C6C6C;width: 150px;height: 150px;display: block;overflow: hidden;border: 1px solid #E5E5E5;line-height: 150px;_font-size: 110px;text-align: center;}
        .xt-items li h4{line-height: 18px;text-align: center;font-weight: normal;margin: 4px 0;height: 20px;overflow: hidden;width: 152px;font-size: 100%;}
        .xt-items li p{text-align:center;color:#6C6C6C;font-family:'\5fae\8f6f\96c5\9ed1';}
        .xt-items li.xt-current b,.xt-items li.xt-hover b{display: block;width: 88px;height: 25px;color: white;text-align: center;line-height: 24px;position: absolute;top: 126px;right: 1px;z-index: 2;font-weight: normal;background: black;opacity: 0.5;filter: alpha(opacity=50);cursor: pointer;}
        .xt-items li.xt-current span,.xt-items li.xt-hover span{width: 150px;height: 150px;display: block;position: absolute;border: 3px solid #BAD4AF;top: -2px;left: -2px;z-index: 1;}
        #X_Items_Box_Url_Prompt_Text{color: #BBB;position: absolute;font-size: 1.7em;padding: 8px 10px;cursor: text;vertical-align: middle;margin-top:15px;}
    </style>
    <?php 
    $xt_items = get_post_meta($post->ID, 'xt_items', true);
    if (empty($xt_items)) {
        $xt_items = array();
        for ($i = 0; $i < 4; $i++) {
            $xt_items[$i] = array('title' => '', 'url' => '', 'pic' => '', 'price' => '', 'type' => '', 'key' => '', 'guid' => xt_user_guid());
        }
    }
    $xt_count = 0;
    ?>
    <ul id="X_Items" class="xt-items clear">
        <?php 
    foreach ($xt_items as $xt_item) {
        ?>
            <li id="X_Items_<?php 
        echo $xt_count;
        ?>
">
                <b>编辑商品信息</b><div><span></span><a href="javascript:;"><?php 
        echo !empty($xt_item['pic']) ? '<img src="' . $xt_item['pic'] . '"' : '';
        ?>
</a><h4><a href="javascript:;"><?php 
        echo $xt_item['title'];
        ?>
</a></h4><p><?php 
        echo $xt_item['price'];
        ?>
</p></div>
                <input type="hidden" class="xt-item-title" name="items[<?php 
        echo $xt_count;
        ?>
][title]" value="<?php 
        echo esc_html($xt_item['title']);
        ?>
" />
                <input type="hidden" class="xt-item-url" name="items[<?php 
        echo $xt_count;
        ?>
][url]" value="<?php 
        echo $xt_item['url'];
        ?>
" />
                <input type="hidden" class="xt-item-pic" name="items[<?php 
        echo $xt_count;
        ?>
][pic]" value="<?php 
        echo $xt_item['pic'];
        ?>
" />
                <input type="hidden" class="xt-item-price" name="items[<?php 
        echo $xt_count;
        ?>
][price]" value="<?php 
        echo $xt_item['price'];
        ?>
" />
                <input type="hidden" class="xt-item-type" name="items[<?php 
        echo $xt_count;
        ?>
][type]" value="<?php 
        echo $xt_item['type'];
        ?>
" />
                <input type="hidden" class="xt-item-key" name="items[<?php 
        echo $xt_count;
        ?>
][key]" value="<?php 
        echo $xt_item['key'];
        ?>
" />
                <input type="hidden" class="xt-item-guid" name="items[<?php 
        echo $xt_count;
        ?>
][guid]" value="<?php 
        echo $xt_item['guid'];
        ?>
" />
            </li>
            <?php 
        $xt_count++;
    }
    ?>
        <br class="clear">
    </ul>
    <div id="X_Items_Box" style="display:none;">
        <label class="hide-if-no-js" style="" id="X_Items_Box_Url_Prompt_Text" for="X_Items_Box_Url">在此输入商品链接</label>
        <input type="text" id="X_Items_Box_Url" style="background-color: white;border-color: #CCC;padding: 3px 8px;font-size: 1.7em;line-height: 100%;width: 100%;outline: none;margin-top:15px;" value="" autocomplete="off">
        <p class="submit" style="margin:20px auto;text-align:center;">
            <input type="submit" id="X_Items_Box_Submit" class="button-primary" value="确定">
            <span><img src="<?php 
    echo esc_url(admin_url('images/wpspin_light.gif'));
    ?>
" class="ajax-feedback"></span>
            <a class="button" id="X_Items_Box_Clear" href="javascript:;" >清空</a>
        </p>
    </div>
    <?php 
    global $xt;
    $_global = get_option(XT_OPTION_GLOBAL);
    echo '<script type="text/javascript">var XT = ' . json_encode(array('siteurl' => site_url(), 'pluginurl' => XT_PLUGIN_URL, 'ajaxurl' => admin_url('admin-ajax.php'), 'loginurl' => site_url('wp-login.php'), 'searchshareurl' => xt_get_shares_search_url(array('s' => 'SEARCH')), 'userId' => get_current_user_id(), 'token' => wp_create_nonce('token'), 'option' => $_global)) . ';</script>';
    ?>
    <script type="text/javascript" src="<?php 
    echo XT_CORE_JS_URL . '/xt-post.min.js';
    ?>
"></script>
    <?php 
}
Esempio n. 3
0
function xt_outercode()
{
    global $xt_share_guid;
    $user = wp_get_current_user();
    $outercode = '';
    if (!empty($xt_share_guid) && strlen($xt_share_guid) == 4) {
        //share and buy
        if (xt_is_fanxian()) {
            $outercode = XT_FANXIAN_PRE . $xt_share_guid . '8';
            if ($user->exists()) {
                $_guid = xt_user_guid();
                $outercode .= $_guid;
            }
            return $outercode;
        } else {
            return XT_NOFANXIAN_PRE . $user->ID;
        }
    } else {
        // buy
        if ($user->exists()) {
            if (xt_is_fanxian()) {
                return XT_FANXIAN_PRE . $user->ID;
            } else {
                return XT_NOFANXIAN_PRE . $user->ID;
            }
        }
    }
    return 'xintaoke';
}
Esempio n. 4
0
function xt_insert_share($sharedata)
{
    global $wpdb;
    extract(stripslashes_deep($sharedata), EXTR_SKIP);
    $guid = xt_user_guid($user_id);
    $data = compact('title', 'share_key', 'pic_url', 'price', 'cid', 'guid', 'user_id', 'user_name', 'tags', 'cache_data', 'content', 'from_type', 'data_type', 'create_date', 'create_date_gmt', 'update_date', 'update_date_gmt');
    if ($wpdb->insert(XT_TABLE_SHARE, $data)) {
        $id = $wpdb->insert_id;
        //match
        xt_insert_share_match(array('share_id' => $id, 'content_match' => xt_segment_unicode($title)));
        if ($cid > 0) {
            $cids = array();
            //Auto Catalog(By cid)
            if (in_array($from_type, array('taobao', 'paipai'))) {
                $cids = xt_get_catalogs_by_cid($cid, $from_type);
                if (!empty($cids)) {
                    if (!empty($tags)) {
                        xt_update_share_tags(explode(' ', $tags), $cids);
                    }
                }
            }
            //Auto Catalog(By Tags)
            //            if (empty($cids)) {
            //                if (!empty($tags)) {
            //                    $cids = xt_get_catalogs_by_tags(explode(' ', $tags));
            //                }
            //            }
            if (!empty($cids)) {
                foreach ($cids as $_cid) {
                    xt_new_share_catalog(array('id' => absint($id), 'cid' => absint($_cid)));
                }
            }
        } else {
            if (!empty($tags)) {
                xt_update_share_tags(explode(' ', $tags));
            }
        }
        $count = xt_update_user_share_count($user_id);
        return $id;
    }
    return 0;
}