} /* ===== */ // Проверяем платежки на оплату пополнение счета. if ($balancepays = cot_payments_getallpays('balance', 'paid')) { foreach ($balancepays as $pay) { if (cot_payments_updatestatus($pay['pay_id'], 'done')) { $urr = $db->query("SELECT * FROM {$db_users} WHERE user_id=" . $pay['pay_userid'])->fetch(); $subject = $L['payments_balance_billing_admin_subject']; $body = sprintf($L['payments_balance_billing_admin_body'], $urr['user_name'], $pay['pay_summ'] . ' ' . $cfg['payments']['valuta'], $pay['pay_id'], cot_date('d.m.Y в H:i', $pay['pay_pdate'])); cot_mail($cfg['adminemail'], $subject, $body); if (!empty($pay['pay_code'])) { $dpay = cot_payments_payinfo($pay['pay_code']); if (!empty($dpay)) { $ubalance = cot_payments_getuserbalance($dpay['pay_userid']); if ($ubalance >= $dpay['pay_summ'] && cot_payments_updatestatus($dpay['pay_id'], 'paid')) { cot_payments_updateuserbalance($dpay['pay_userid'], -$dpay['pay_summ'], $dpay['pay_id']); } } } /* === Hook === */ foreach (cot_getextplugins('payments.balance.billing.done') as $pl) { include $pl; } /* ===== */ } } } if ($cfg['payments']['clearpaymentsdays'] > 0) { $clearpaymentsdate = $sys['now'] - $cfg['payments']['clearpaymentsdays'] * 24 * 60 * 60; $db->delete($db_payments, "pay_status!='done' AND pay_cdate<" . $clearpaymentsdate); }
cot_check($sendersumm > $ubalance, 'payments_balance_transfer_error_balance'); cot_check($cfg['payments']['transfermin'] > 0 && $summ < $cfg['payments']['transfermin'], sprintf($L['payments_balance_transfer_error_min'], $cfg['payments']['transfermin'], $cfg['payments']['valuta'])); cot_check($cfg['payments']['transfermax'] > 0 && $summ > $cfg['payments']['transfermax'], sprintf($L['payments_balance_transfer_error_max'], $cfg['payments']['transfermax'], $cfg['payments']['valuta'])); if (!cot_error_found()) { $payinfo['pay_userid'] = $usr['id']; $payinfo['pay_area'] = 'transfer'; $payinfo['pay_code'] = $recipient['user_id']; $payinfo['pay_summ'] = $sendersumm; $payinfo['pay_cdate'] = $sys['now']; $payinfo['pay_pdate'] = $sys['now']; $payinfo['pay_adate'] = $sys['now']; $payinfo['pay_status'] = 'done'; $payinfo['pay_desc'] = sprintf($L['payments_balance_transfer_desc'], $usr['name'], $recipient['user_name'], $comment); $db->insert($db_payments, $payinfo); $pid = $db->lastInsertId(); cot_payments_updateuserbalance($usr['id'], -$sendersumm, $pid); $payinfo['pay_userid'] = $recipient['user_id']; $payinfo['pay_area'] = 'balance'; $payinfo['pay_code'] = $pid; $payinfo['pay_summ'] = $recipientsumm; $payinfo['pay_cdate'] = $sys['now']; $payinfo['pay_pdate'] = $sys['now']; $payinfo['pay_adate'] = $sys['now']; $payinfo['pay_status'] = 'done'; $payinfo['pay_desc'] = sprintf($L['payments_balance_transfer_desc'], $usr['name'], $recipient['user_name'], $comment); $db->insert($db_payments, $payinfo); $pid = $db->lastInsertId(); // Отправка уведомления админу о переводе между пользователями $subject = $L['payments_balance_transfer_admin_subject']; $body = sprintf($L['payments_balance_transfer_admin_body'], $usr['name'], $recipient['user_name'], $summ, $taxsumm, $sendersumm, $recipientsumm, $cfg['payments']['valuta'], cot_date('d.m.Y в H:i', $sys['now']), $comment); cot_mail($cfg['adminemail'], $subject, $body);
} /* ===== */ $pid = cot_import('pid', 'G', 'INT'); if (empty($pid)) { cot_redirect(cot_url('payments', 'm=error&msg=2', '', true)); } // Получаем информацию о заказе if ($pinfo = cot_payments_payinfo($pid)) { // Блокируем доступ к несобственным платежкам cot_block($usr['id'] == $pinfo['pay_userid']); // Если счета пользователей включены, то проверяем баланс if ($cfg['payments']['balance_enabled'] && $pinfo['pay_area'] != 'balance' && $usr['id'] > 0) { $ubalance = cot_payments_getuserbalance($usr['id']); if ($ubalance >= $pinfo['pay_summ']) { if (cot_payments_updatestatus($pid, 'paid')) { cot_payments_updateuserbalance($usr['id'], -$pinfo['pay_summ'], $pid); /* === Hook === */ foreach (cot_getextplugins('payments.billing.paid.done') as $pl) { include $pl; } /* ===== */ if (!empty($pinfo['pay_redirect'])) { $pinfo['pay_redirect'] = $pinfo['pay_redirect'] . '&' . cot_xg(); cot_redirect($pinfo['pay_redirect']); } else { cot_redirect(cot_url('index')); } } } else { $rsumm = $pinfo['pay_summ'] - $ubalance; cot_redirect(cot_url('payments', 'm=balance&n=billing&rsumm=' . $rsumm . '&pid=' . $pid, '', true));