function xt_new_tixian($tixiandata) { $tixiandata['user_id'] = (int) $tixiandata['user_id']; $user = new WP_User($tixiandata['user_id']); $account_field = XT_USER_ALIPAY; $account = $user->{$account_field}; $account_name_field = XT_USER_ALIPAY_NAME; $account_name = $user->{$account_name_field}; if ($user->exists() && !empty($account) && !empty($account_name)) { global $wpdb; $old = $wpdb->get_row('SELECT * FROM ' . XT_TABLE_TIXIAN . ' WHERE user_id=' . $user->ID . ' AND status=0'); //审核中 if (!empty($old)) { //累加到未审核的 return $wpdb->update(XT_TABLE_TIXIAN, array('cash' => (double) $old->cash + (double) $tixiandata['cash'], 'jifen' => intval($old->jifen) + intval($tixiandata['jifen'])), array('id' => $old->id)); } else { $cashback = (int) xt_fanxian_cashback(); if ((double) $tixiandata['cash'] + intval($tixiandata['jifen']) * 100 < $cashback) { return 0; } $tixiandata['status'] = 0; $tixiandata['cash'] = (double) $tixiandata['cash']; $tixiandata['jifen'] = intval($tixiandata['jifen']); $tixiandata['freeze'] = 0; $tixiandata['freeze_jifen'] = 0; $tixiandata['account'] = $account; $tixiandata['account_name'] = $account_name; $tixiandata['content'] = isset($tixiandata['content']) ? $tixiandata['content'] : ''; $tixiandata['create_time'] = current_time('mysql'); $tixiandata['update_time'] = current_time('mysql'); return xt_insert_tixian($tixiandata); } } }
$_tixians = xt_total_tixian_jifen($user->ID); $_tixian = $_tixians[0] + $_tixians[1]; //未审核,已完成 $_cash = $_fanxian - $_tixian; //余额 } ?> <form class="xt-form-tixian"> <?php $account_field = XT_USER_ALIPAY; $account = $user->{$account_field}; $account_name_field = XT_USER_ALIPAY_NAME; $account_name = $user->{$account_name_field}; if (!empty($account) && !empty($account_name)) { $cashback = (int) xt_fanxian_cashback(); if ($type == 'jifenbao') { $cashback = $cashback * 100; } ?> <div class="form-horizontal"> <div class="control-group"> <label class="control-label">可提现:</label> <div class="controls"> <div class="input-append"> <span class="input-small uneditable-input"><?php echo round($_cash, 2); ?> </span><span class="add-on"><?php echo $_cash_text; ?>
function xt_ajax_tixian_save() { $result = array('code' => 0, 'msg' => '', 'result' => array()); if (!xt_is_fanxian()) { $result['code'] = 500; $result['msg'] = '已关闭返利通道'; exit(json_encode($result)); } $_amount = $_POST['amount']; if (!isset($_POST['type']) || empty($_POST['type'])) { $result['code'] = 500; $result['msg'] = '未指定要提现的类型'; exit(json_encode($result)); } $_type = $_POST['type']; if (!in_array($_type, array('cash', 'jifenbao'))) { $result['code'] = 500; $result['msg'] = '指定的提现类型不正确'; exit(json_encode($result)); } if (empty($_amount)) { $result['code'] = 500; $result['msg'] = '未填写提现数额'; } if (!is_numeric($_amount)) { $result['code'] = 500; $result['msg'] = '提现数额格式不正确'; } else { $cashback = (int) xt_fanxian_cashback(); if ($_type == 'jifenbao') { $cashback = $cashback * 100; } if ($_amount < $cashback) { $result['code'] = 500; $result['msg'] = '提现数额必须大于:' . $cashback; } } if ($result['code'] == 0) { $user = wp_get_current_user(); if ($user->exists()) { $_fanxian = 0; $_tixian = 0; $_cash = 0; if ($_type == 'cash') { $_fanxian = xt_user_total_fanxian($user->ID); $_tixians = xt_total_tixian($user->ID); $_tixian = $_tixians[0] + $_tixians[1]; //未审核,已完成 $_cash = $_fanxian - $_tixian; //余额 } else { $_fanxian = xt_user_total_jifen($user->ID); $_tixians = xt_total_tixian_jifen($user->ID); $_tixian = $_tixians[0] + $_tixians[1]; //未审核,已完成 $_cash = $_fanxian - $_tixian; //余额 } if ($_amount > $_cash) { $result['code'] = 500; $result['msg'] = '提现数额超过余额'; } else { $__cash = $__jifen = 0; if ($_type == 'jifenbao') { $__jifen = $_amount; } else { $__cash = $_amount; } xt_new_tixian(array('user_id' => $user->ID, 'cash' => $__cash, 'jifen' => $__jifen)); } } else { $result['code'] = 500; $result['msg'] = '未登录'; } } exit(json_encode($result)); }
?> " class="small-text">% 启用推广返现后,会员推广其他人注册购买后可以获得的返现比例(返现=佣金x推广返现比例) </label> </td> </tr> <tr valign="top"> <th scope="row">提现(现金或<?php echo xt_jifenbao_text(); ?> )</th> <td> <label for="cashback"> 最低<input name="cashback" type="number" step="1" min="0" max="100" id="cashback" value="<?php echo xt_fanxian_cashback(); ?> " class="small-text"> 元(RMB)或同价值的<?php echo xt_jifenbao_text(); ?> </label> </td> </tr> <tr valign="top"> <th scope="row">注册</th> <td> <fieldset> <label for="registe_cash"> 赠送<input name="registe_cash" type="number" step="1" min="0" max="50" id="registe_cash" value="<?php