ecshop

ECSHOP会员注册自动发送红包插件

ECSHOP教程 来源: ECSHOP教程网www.ecshop119.com 时间:2013-11-22 ECSHOP教程分类:ECSHOP二次开发教程

一、我们在ecshop后台增加一种红包类型
请把新增加的红包类型的名称设置为注册送红包

二、修改includes/lib_common.php,在其文件最后?>前加一个函数
function send_register_bonus($user_id,$bid=0)
{
        if($bid ==0)
        {
           $bid = $GLOBALS['db']->getOne("select type_id from " . $GLOBALS['ecs']->table('bonus_type') . "where type_name ='注册送红包' order by type_id desc limit 1 " );
        }
        if(! $bid)
        {
          return  false;
        }
        $user_info = $GLOBALS['db']->getRow("select user_name, email from " . $GLOBALS['ecs']->table('users') . "where user_id ='$user_id' " );
        $bonus_type = $GLOBALS['db']->getRow("SELECT * FROM " . $GLOBALS['ecs']->table('bonus_type') .
            " WHERE type_id = '$bid'");
        if(! $bonus_type) return false;
           

        /* 向会员红包表录入数据 */
        $sql = "INSERT INTO " . $GLOBALS['ecs']->table('user_bonus') .
                "(bonus_type_id, bonus_sn, user_id, used_time, order_id, emailed) " .
                "VALUES ('$bid', 0, '$user_id', 0, 0, " .BONUS_MAIL_SUCCEED. ")";
        $GLOBALS['db']->query($sql);

        $tpl = get_mail_template('send_bonus');
        if(! $tpl) return false;
        $today = local_date($_CFG['date_format']);
        /* 发送邮件通知 */
        $GLOBALS['smarty']->assign('user_name',    $user_info['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']);   

        send_mail($user_info['user_name'], $user_info['email'], '注册送红包', $content, $tpl['is_html']);
}

?>

三、修改lib_passport.php的register函数

/* 注册送积分 */
if (!empty($GLOBALS['_CFG']['register_points']))
{
    log_account_change($_SESSION['user_id'], 0, 0, $GLOBALS['_CFG']['register_points'], $GLOBALS['_CFG']['register_points'], $GLOBALS['_LANG']['register_points']);
}


    /***注册送红包**/
    send_register_bonus($_SESSION['user_id']);

/*推荐处理*/
$affiliate  = unserialize($GLOBALS['_CFG']['affiliate']);


其中
/***注册送红包**/
send_register_bonus($_SESSION['user_id']);
是新增加的

转载请注明:ECSHOP模板屋-ECshop教程网http://www.ecshop119.com/ecshopjc-300.html

ECSHOP
ecshop下载 ecshop安装教程 ecshop在线演示 ecshop后台测试
ECSHOP二次开发手册
ecshop教程 ecshop二次开发 ecshop模板教程 ecshop微信配置
ECSHOP商城网站建设
ecshop空间域名 ecshop商城建设 ecshop模板修改 ecshop开发定制
ECSHOP模板屋
ecshop开发团队 ecshop开发中心 ecshop模板制作 模板屋简介
服务支持:7X24小时 151 059 55077
ECShop二次开发
ecshop搭建
qqtelcodeback_top
温馨提示

确定取消
温馨提示

关闭