예제 #1
0
function licai_bid($id, $money, $paypassword)
{
    $return = array("status" => 0, "info" => "");
    if (intval($GLOBALS['user_info']['id']) == 0) {
        $return['info'] = "请先登录";
        return $return;
    }
    if (intval($GLOBALS['user_info']['money']) < $money) {
        $return['info'] = "账户余额不足";
        return $return;
    }
    if ($GLOBALS['user_info']['paypassword'] != md5($paypassword)) {
        $return['info'] = "支付密码错误";
        return $return;
    }
    $licai = $GLOBALS['db']->getRow("SELECT * FROM " . DB_PREFIX . "licai where id=" . $id);
    $licai['url'] = url("licai#deal", array("id" => $licai['id']));
    if ($licai['user_id'] == $GLOBALS['user_info']['id']) {
        $return['info'] = "不能购买自己发布的理财产品";
        return $return;
    }
    if (!$licai || $licai['status'] == 0) {
        $return['info'] = "理财产品不存在";
        return $return;
    }
    if (to_timespan($licai['begin_buy_date'], "Y-m-d") > 0 && to_timespan($licai['begin_buy_date'], "Y-m-d") > NOW_TIME) {
        $return['info'] = "理财产品还未开始允许购买";
        return $return;
    }
    if (to_timespan($licai['end_buy_date'], "Y-m-d") > 0 && to_timespan($licai['end_buy_date'], "Y-m-d") < NOW_TIME) {
        $return['info'] = "理财产品已结束购买";
        return $return;
    }
    if (floatval($licai['min_money']) != 0) {
        if ($money < floatval($licai['min_money'])) {
            $return['info'] = "最小购买金额为:" . format_price($licai['min_money']);
            return $return;
        }
    }
    if (floatval($licai['max_money']) != 0) {
        if ($money > floatval($licai['max_money'])) {
            $return['info'] = "最大购买金额为:" . format_price($licai['max_money']);
            return $return;
        }
    }
    $licai_order_data = array();
    $licai_order_data['status'] = 1;
    $licai_order_data['licai_id'] = $id;
    $licai_order_data['user_id'] = intval($GLOBALS['user_info']['id']);
    $licai_order_data['user_name'] = $GLOBALS['user_info']['user_name'];
    $licai_order_data['money'] = $money;
    $licai_order_data['create_time'] = to_date(NOW_TIME);
    $licai_order_data['create_date'] = to_date(NOW_TIME);
    //算息时间
    $licai_order_data['begin_interest_type'] = $licai['begin_interest_type'];
    $licai['begin_interest_date'] = to_timespan($licai['begin_interest_date']) == 0 || to_timespan($licai['begin_interest_date']) < NOW_TIME ? to_date(NOW_TIME, "Y-m-d") : $licai['begin_interest_date'];
    //预热期
    if ($licai['type'] > 0) {
        //预热开始时间 | 购买开始时间
        $licai_order_data['before_interest_date'] = get_peizi_next_date(NOW_TIME, $licai['begin_interest_type']);
        if (to_timespan($licai_order_data['before_interest_date'], "Y-m-d") > 0 && to_timespan($licai['before_interest_date'], "Y-m-d") > to_timespan($licai['begin_interest_date'], "Y-m-d")) {
            $licai_order_data['before_interest_date'] = $licai['begin_interest_date'];
        }
        //预热结束时间
        $licai_order_data['before_interest_enddate'] = $licai['begin_interest_date'];
    }
    //起息时间
    $licai_order_data['begin_interest_date'] = get_peizi_next_date(NOW_TIME, $licai['begin_interest_type']);
    if (to_timespan($licai_order_data['begin_interest_date'], "Y-m-d") < to_timespan($licai['begin_interest_date'], "Y-m-d")) {
        $licai_order_data['begin_interest_date'] = $licai['begin_interest_date'];
    }
    //结束时间
    if ($licai['time_limit'] == 0) {
        $licai_order_data['end_interest_date'] = $licai['end_date'];
    } elseif (to_timespan($licai['end_date'], "Y-m-d") == 0 && $licai['time_limit'] > 0) {
        $licai_order_data['end_interest_date'] = to_date(next_month(NOW_TIME, $licai['time_limit']), "Y-m-d");
    } elseif (to_timespan($licai['end_date'], "Y-m-d") > 0 && $licai['time_limit'] > 0) {
        //如果项目结束时间大于周期那么使用周期时间
        $str_time = to_timespan($licai['begin_interest_date'], "Y-m-d");
        if (to_timespan($licai['end_date']) > to_timespan(to_date(next_month($str_time, $licai['time_limit']), "Y-m-d"), "Y-m-d")) {
            $licai_order_data['end_interest_date'] = to_date(next_month($str_time, $licai['time_limit']), "Y-m-d");
        } else {
            $licai_order_data['end_interest_date'] = $licai['end_date'];
        }
    }
    if ($licai['type'] > 0) {
        $interest_rs = get_licai_interest($id, $money);
        //预热利息
        $licai_order_data['before_rate'] = $interest_rs['before_rate'];
        //预热违约利息
        $licai_order_data['before_breach_rate'] = $interest_rs['before_breach_rate'];
        //正常利息
        $licai_order_data['interest_rate'] = $interest_rs['interest_rate'];
        //违约利息
        $licai_order_data['breach_rate'] = $interest_rs['breach_rate'];
        //申购手续费
        $licai_order_data['site_buy_fee_rate'] = $interest_rs['site_buy_fee_rate'];
        //赎回手续费
        $licai_order_data['redemption_fee_rate'] = $interest_rs['redemption_fee_rate'];
        //平台收益
        $licai_order_data['platform_rate'] = $interest_rs['platform_rate'];
        //用户违约平台收益
        $licai_order_data['platform_breach_rate'] = $interest_rs['platform_breach_rate'];
        //冻结保证金比例
        $licai_order_data['freeze_bond_rate'] = $interest_rs['freeze_bond_rate'];
    } else {
        $licai_order_data['before_rate'] = 0;
        $licai_order_data['before_breach_rate'] = 0;
        $licai_order_data['interest_rate'] = 0;
        $licai_order_data['breach_rate'] = 0;
        $licai_order_data['platform_breach_rate'] = 0;
        $licai_order_data['freeze_bond_rate'] = 0;
        $licai_order_data['platform_rate'] = $licai['platform_rate'];
        $licai_order_data['site_buy_fee_rate'] = $licai['site_buy_fee_rate'];
        $licai_order_data['redemption_fee_rate'] = $licai['redemption_fee_rate'];
    }
    //预热期利息
    $licai_order_data['before_interest'] = $money * floatval($licai_order_data['before_rate']) * 0.01 * ((to_timespan($licai_order_data['before_interest_enddate']) - to_timespan($licai_order_data['before_interest_date'])) / 24 / 3600) / 365;
    //余额宝时为0
    $licai_order_data['site_buy_fee'] = $money * floatval($licai_order_data['site_buy_fee_rate']) * 0.01;
    //$licai_order_data['freeze_bond_rate'] = $licai['freeze_bond_rate'];
    //冻结的保证金,扣除网站收取的手续费
    $licai_order_data['freeze_bond'] = round($licai_order_data['freeze_bond_rate'] * ($money - $licai_order_data['site_buy_fee']) * 0.01, 2);
    //余额宝时为0
    $licai_order_data['pay_money'] = $money - $licai_order_data['site_buy_fee'] - $licai_order_data['freeze_bond'];
    //成交服务费
    $licai_order_data['service_fee_rate'] = $licai['service_fee_rate'];
    $licai_order_data['service_fee'] = floatval($licai['service_fee_rate']) * 0.01 * ($money - $licai_order_data['site_buy_fee']);
    //print_r($licai_order_data);die();
    $GLOBALS['db']->autoExecute(DB_PREFIX . "licai_order", $licai_order_data, "INSERT");
    if ($GLOBALS['db']->affected_rows()) {
        require_once APP_ROOT_PATH . 'system/libs/user.php';
        //理财购买本金
        modify_account(array("money" => '-' . ($money - $licai_order_data['site_buy_fee'])), $GLOBALS['user_info']['id'], "购买理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 42);
        //理财购买手续费
        modify_account(array("money" => '-' . $licai_order_data['site_buy_fee']), $GLOBALS['user_info']['id'], "购买理财产品“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”", 43);
        //理财发放资金
        modify_account(array("money" => $licai_order_data['pay_money']), intval($licai['user_id']), $GLOBALS['user_info']['user_name'] . "对理财“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”的投资", 46);
        if ($licai_order_data['freeze_bond'] > 0) {
            //理财冻结资金
            modify_account(array("lock_money" => $licai_order_data['freeze_bond']), intval($licai['user_id']), $GLOBALS['user_info']['user_name'] . "对理财“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”的投资", 44);
        }
        if ($licai_order_data['service_fee'] != 0) {
            //理财服务费
            modify_account(array("money" => '-' . $licai_order_data['service_fee']), intval($licai['user_id']), $GLOBALS['user_info']['user_name'] . "对理财“<a href=\"" . $licai['url'] . "\">" . $licai['name'] . "</a>”的投资", 45);
        }
        if ($licai['type'] > 0) {
            syn_licai_status($id);
        } else {
            syn_licai_status($id, 0);
        }
        $return['status'] = 1;
        $return['info'] = "购买成功";
        return $return;
    }
}
예제 #2
0
			href="<?php 
$prev = prev_month($curmonth, $curyear);
print "month_view.php?month=" . $prev[month] . "&year=" . $prev[year];
?>
"
			class="calendar-link-nav"><img src="%[IMAGE_GPATH]%arrow_left.gif"
			width="16" height="16" border="0" align="absmiddle"> <?php 
echo CALENDAR_PREV_MONTH;
?>
</a>
		</td>
		<td width="2%" align="center" valign="middle"><img
			src="%[IMAGE_GPATH]%sep_02.gif" width="2" height="16"></td>
		<td width="10%" align="right" valign="middle" nowrap><a
			href="<?php 
$next = next_month($curmonth, $curyear);
print "month_view.php?month=" . $next[month] . "&year=" . $next[year];
?>
"
			class="calendar-link-nav"><?php 
echo CALENDAR_NEXT_MONTH;
?>
 <img
			src="%[IMAGE_GPATH]%arrow_right.gif" width="16" height="16"
			border="0" align="absmiddle"> </a></td>
	</tr>
</table>
</form>
<div class="toolbar-calendar-div ui-widget ui-state-default">

<table border="0" cellpadding="0" cellspacing="0"