70 lines
2.8 KiB
Plaintext
70 lines
2.8 KiB
Plaintext
<?php
|
|
define('GAME',true);
|
|
setlocale(LC_CTYPE ,"ru_RU.CP1251");
|
|
include('/home/newcom1/public_html/_incl_data/__config.php');
|
|
include('/home/newcom1/public_html/_incl_data/class/__db_connect.php');
|
|
include('/home/newcom1/public_html/_incl_data/class/__user.php');
|
|
|
|
/*
|
|
|
|
CRON Êîìèññèîííîãî ìàãàçèíà
|
|
Äåéñòâèÿ:
|
|
1. Åñëè ïðåäìåò âèñèò óæå 2 è áîëåå íåäåëü, ïðîäàâàòü ïðåäìåò çà 50% îò åãî ñòîèìîñòè ñ ó÷åòîì èçíîñà
|
|
äåíüãè îòñûëàþòñÿ íà ïî÷òó.
|
|
|
|
*/
|
|
|
|
$time_last = 86400 * 6; //2 íåäåëè
|
|
|
|
$sp = mysql_query('SELECT * FROM `items_com` WHERE `delete` = 0 AND `time` < "'.(time()-$time_last).'"');
|
|
while( $pl = mysql_fetch_array($sp) ) {
|
|
$user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$pl['uid'].'" LIMIT 1'));
|
|
//
|
|
$itm_user = mysql_fetch_array(mysql_query('SELECT * FROM `items_users` WHERE `id` = "'.$pl['item_id'].'" LIMIT 1'));
|
|
$itm_main = mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = "'.$pl['items_id'].'" LIMIT 1'));
|
|
//
|
|
$shpCena = $itm_user['1price'];
|
|
$plmx = 0;
|
|
if($itm_main['iznosMAXi']!=$itm_user['iznosMAX'] && $itm_user['iznosMAX']!=0){
|
|
$plmx = $itm_main['iznosMAX'];
|
|
}else{
|
|
$plmx = $itm_main['iznosMAXi'];
|
|
}
|
|
if($itm_user['iznosNOW']>0){
|
|
$prc1 = $itm_user['iznosNOW']/$plmx*100;
|
|
}else{
|
|
$prc1 = 0;
|
|
}
|
|
$shpCena = $u->shopSaleM( $shpCena , $itm_user );
|
|
$shpCena = $shpCena/100*(100-$prc1);
|
|
if( $itm_user['iznosMAXi'] < 999999999 ) {
|
|
if($itm_user['iznosMAX']>0 && $itm_main['iznosMAXi']>0 && $itm_main['iznosMAXi']>$itm_user['iznosMAX']){
|
|
$shpCena = $shpCena/100*($itm_user['iznosMAX']/$itm_main['iznosMAXi']*100);
|
|
}
|
|
}
|
|
$shpCena = $shpCena/2 * $pl['group'];
|
|
$shpCena = $u->round2($shpCena/100*(100-$shopProcent));
|
|
if($shpCena<0){
|
|
$shpCena = 0;
|
|
}
|
|
//
|
|
$itm_user['1price'] = $shpCena;
|
|
//
|
|
if( $itm_user['1price'] < 0.01 ) {
|
|
$itm_user['1price'] = 0.01;
|
|
}
|
|
//
|
|
mysql_query('UPDATE `items_com` SET `delete` = "'.time().'" WHERE `id` = "'.$pl['id'].'" LIMIT 1');
|
|
mysql_query('INSERT INTO `items_users` (`delete`,`item_id`,`1price`,`uid`,`lastUPD`) VALUES ("0","1220","'.$itm_user['1price'].'","-51'.$user['id'].'","'.time().'")');
|
|
mysql_query('INSERT INTO `post` (`uid`,`sender_id`,`time`,`money`,`text`) VALUES (
|
|
"'.$user['id'].'","0","'.time().'","'.$itm_user['1price'].'","Êîìèññèîííûé ìàãàçèí: Ïðåäìåò "'.$itm_main['name'].''.$grp.'" (Èçíîñ: '.ceil($itm_user['iznosNOW']).'/'.ceil($itm_user['iznosMAX']).') áûë ïðîäàí çà <b>'.$itm_user['1price'].' êð</b>."
|
|
)');
|
|
//
|
|
$grp = '';
|
|
if( $pl['group'] > 1 ) {
|
|
$grp = ' (x'.$pl['group'].')';
|
|
}
|
|
$u->send('','','','<font color=#009966 >Êîìèññèîííûé ìàãàçèí</font>',$user['login'],'Ïðåäìåò "'.$itm_main['name'].''.$grp.'" (Èçíîñ: '.ceil($itm_user['iznosNOW']).'/'.ceil($itm_user['iznosMAX']).') áûë ïðîäàí â ãîñóäàðñòâåííûé ìàãàçèí çà <b>'.$itm_user['1price'].' êð.</b>. Äåíüãè äîñòàâëåíû ê âàì íà ïî÷òó.',time(),6,0,0,0,1,0);
|
|
}
|
|
|
|
?> |