1.首先在后台添加红包。如图:
 

修改ecshop让用户注册就发红包

2.修改文件。user.php

找到:228 行左右

if (register($username, $password, $email, $other) !== false) 
   {

添加:

        if (register($username, $password, $email, $other) !== false)
        {
                      /* 用户注册就发红包 */
            $bonus = $db->getRow(‘SELECT * FROM ‘ . $ecs->table(“bonus_type”) . ‘ WHERE send_type = 0’, true);
            if($bonus){
                                if(time()<$bonus[use_start_date]) {
                               $sql = “INSERT INTO ” . $ecs->table(‘user_bonus’) .
“(bonus_type_id, bonus_sn, user_id, used_time, order_id, emailed) ” .   “VALUES (‘$bonus[type_id]’, 0, ‘$_SESSION[user_id]’, 0, 0, 0)”;
$db->query($sql);    
                            }  
                     }
       }