活动说明:客户累计充值1万送1个蛋蛋碎片,当天累计充值10万送1个蛋蛋精灵
PC地址:https://www.huijindaicn.com/i...
WAP地址:https://www.huijindaicn.com/w...php
/** * @param $user_id 用户id * @param $amount 充值金额 */ function modify_egg_chip($user_id,$amount) { $base_money = 10000; // 送碎片基数 $base_money_2 = 100000; // 送精灵基数 $lock_money = lock_money = $GLOBALS['db']->getOne("SELECT SUM(amount) FROM ".DB_PREFIX."reapal_recharge WHERE user_id = ".$user_id." and is_lock = 1 and code = '0000' and is_callback = 1"); // 获取上次未赠送余额 $lock_money = $lock_money - $amount; $balance_money = $lock_money - intval($lock_money/$base_money)*$base_money; // 获取赠送碎片数量 $egg_num = intval(($balance_money + $amount)/$base_money); // 更新用户蛋蛋碎片数量 if($egg_num >= 1) { $count = $GLOBALS['db']->getOne("SELECT count(*) FROM ".DB_PREFIX."user_egg WHERE user_id= ".$user_id." AND type=0"); if($count) { $update_time = TIME_UTC; $GLOBALS['db']->query("update ".DB_PREFIX."user_egg set num = num+".$egg_num.",update_time= ".$update_time." where user_id = ".$user_id." AND type=0"); } else { $ueggs['user_id'] = $user_id; $ueggs['name'] = ''; $ueggs['type'] = 0; $ueggs['is_effect'] = 1; $ueggs['num'] = $egg_num; $ueggs['update_time'] = TIME_UTC; $GLOBALS['db']->autoExecute(DB_PREFIX."user_egg", $ueggs, "INSERT"); } } // 获取当天累计充值 $today_start = to_timespan(to_date(TIME_UTC,"Y-m-d"),"Y-m-d"); $today_lock_money = $GLOBALS['db']->getOne("SELECT SUM(amount) FROM ".DB_PREFIX."reapal_recharge WHERE user_id = ".$user_id." and succ_time >= ".$today_start." and is_lock = 1 and code = '0000' and is_callback = 1"); $today_lock_money = $today_lock_money - $amount; $today_balance_money = $today_lock_money - intval($today_lock_money/$base_money_2)*$base_money_2; $egg_num_2 = intval(($today_balance_money + $amount)/$base_money_2); if($egg_num_2 >= 1) { $count = $GLOBALS['db']->getOne("SELECT count(*) FROM ".DB_PREFIX."user_egg WHERE user_id= ".$user_id." AND type=1"); if($count) { $update_time = TIME_UTC; $GLOBALS['db']->query("update ".DB_PREFIX."user_egg set num = num+".$egg_num_2.", update_time = ".$update_time." where user_id = ".$user_id." AND type = 1"); } else { $ueggs['user_id'] = $user_id; $ueggs['name'] = ''; $ueggs['type'] = 1; $ueggs['is_effect'] = 1; $ueggs['num'] = $egg_num_2; $ueggs['update_time'] = TIME_UTC; $GLOBALS['db']->autoExecute(DB_PREFIX."user_egg", $ueggs, "INSERT"); } } }