Example #1
0
/**
 * 发送红包邮件
 * @param   int     $bonus_type_id  红包类型id
 * @param   array   $bonus_id_list  红包id数组
 * @return  int     成功发送数量
 */
function send_bonus_mail($bonus_type_id, $bonus_id_list)
{
    /* 取得红包类型信息 */
    $bonus_type = bonus_type_info($bonus_type_id);
    if ($bonus_type['send_type'] != SEND_BY_USER) {
        return 0;
    }
    /* 取得属于该类型的红包信息 */
    $sql = "SELECT b.bonus_id, u.user_name, u.email " . "FROM " . $GLOBALS['ecs']->table('user_bonus') . " AS b, " . $GLOBALS['ecs']->table('users') . " AS u " . " WHERE b.user_id = u.user_id " . " AND b.bonus_id " . db_create_in($bonus_id_list) . " AND b.order_id = 0 " . " AND u.email <> ''";
    $bonus_list = $GLOBALS['db']->getAll($sql);
    if (empty($bonus_list)) {
        return 0;
    }
    /* 初始化成功发送数量 */
    $send_count = 0;
    /* 发送邮件 */
    $tpl = get_mail_template('send_bonus');
    $today = local_date($GLOBALS['_CFG']['date_format']);
    foreach ($bonus_list as $bonus) {
        $GLOBALS['smarty']->assign('user_name', $bonus['user_name']);
        $GLOBALS['smarty']->assign('shop_name', $GLOBALS['_CFG']['shop_name']);
        $GLOBALS['smarty']->assign('send_date', $today);
        $GLOBALS['smarty']->assign('sent_date', $today);
        $GLOBALS['smarty']->assign('count', 1);
        $GLOBALS['smarty']->assign('money', price_format($bonus_type['type_money']));
        $content = $GLOBALS['smarty']->fetch('str:' . $tpl['template_content']);
        if (add_to_maillist($bonus['user_name'], $bonus['email'], $tpl['template_subject'], $content, $tpl['is_html'], false)) {
            $sql = "UPDATE " . $GLOBALS['ecs']->table('user_bonus') . " SET emailed = '" . BONUS_MAIL_SUCCEED . "'" . " WHERE bonus_id = '{$bonus['bonus_id']}'";
            $GLOBALS['db']->query($sql);
            $send_count++;
        } else {
            $sql = "UPDATE " . $GLOBALS['ecs']->table('user_bonus') . " SET emailed = '" . BONUS_MAIL_FAIL . "'" . " WHERE bonus_id = '{$bonus['bonus_id']}'";
            $GLOBALS['db']->query($sql);
        }
    }
    return $send_count;
}
Example #2
0
    $list = get_valuecard_list();
    $smarty->assign('vc_list', $list['item']);
    $smarty->assign('filter', $list['filter']);
    $smarty->assign('record_count', $list['record_count']);
    $smarty->assign('page_count', $list['page_count']);
    $sort_flag = sort_flag($list['filter']);
    $smarty->assign($sort_flag['tag'], $sort_flag['img']);
    assign_query_info();
    $smarty->display('valuecard_list.htm');
}
/*------------------------------------------------------ */
//-- 储值卡列表翻页、排序
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'query_bonus') {
    $list = get_valuecard_list();
    $vctype = bonus_type_info(intval($_REQUEST['vc_type']));
    $smarty->assign('vctype', $vctype);
    $smarty->assign('vc_list', $list['item']);
    $smarty->assign('filter', $list['filter']);
    $smarty->assign('record_count', $list['record_count']);
    $smarty->assign('page_count', $list['page_count']);
    $sort_flag = sort_flag($list['filter']);
    $smarty->assign($sort_flag['tag'], $sort_flag['img']);
    make_json_result($smarty->fetch('valuecard_list.htm'), '', array('filter' => $list['filter'], 'page_count' => $list['page_count']));
} elseif ($_REQUEST['act'] == 'remove_bonus') {
    check_authz_json('bonus_manage');
    $id = intval($_GET['id']);
    $db->query("DELETE FROM " . $ecs->table('valuecard') . " WHERE vc_id='{$id}'");
    $url = 'valuecard.php?act=query_bonus&' . str_replace('act=remove_bonus', '', $_SERVER['QUERY_STRING']);
    ecs_header("Location: {$url}\n");
    exit;