register, Grundpreis
This commit is contained in:
parent
f06d2d15a5
commit
8e4bb0c2f6
32 changed files with 965 additions and 216 deletions
|
|
@ -141,11 +141,16 @@ class PayoneController extends Controller
|
|||
foreach($shopping_order->shopping_order_items as $shopping_order_item){
|
||||
if($shopping_order_item->product){
|
||||
if($shopping_order_item->product->action){
|
||||
|
||||
$user = User::findOrFail($shopping_order->auth_user_id);
|
||||
$user->save();
|
||||
$send_link = true;
|
||||
$date = date("Y-m-d H:i:s", strtotime("+1 years"));
|
||||
|
||||
//new date
|
||||
$date = \Carbon::now()->modify('1 year');
|
||||
if($user->payment_account && $user->daysActiveAccount()>0){
|
||||
$date = \Carbon::parse($user->payment_account)->modify('1 year');
|
||||
}
|
||||
|
||||
foreach ($shopping_order_item->product->action as $do){
|
||||
if($shopping_order_item->product->getActionName($do) === 'payment_for_account'){
|
||||
$user->payment_order_id = $shopping_order_item->product->id; //34
|
||||
|
|
@ -167,7 +172,6 @@ class PayoneController extends Controller
|
|||
}
|
||||
$user->payment_shop = $user->payment_account; //same Date, is upgrade
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
|
||||
}
|
||||
$user->save();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,13 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Mail\MailCustomMessage;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Models\UserHistory;
|
||||
use App\Models\UserMessage;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\User;
|
||||
use Carbon;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
|
||||
|
|
@ -34,6 +38,15 @@ class CronController extends Controller
|
|||
//Mail reminder
|
||||
}
|
||||
|
||||
public function action($action = false, $key = false){
|
||||
|
||||
if($key !== 'key'){
|
||||
abort(404);
|
||||
}
|
||||
if($action === 'check_payments_account'){
|
||||
$this->checkPaymentsAccounts();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
|
|
@ -61,10 +74,180 @@ class CronController extends Controller
|
|||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
die("okay");
|
||||
|
||||
}
|
||||
|
||||
public function checkPaymentsAccounts(){
|
||||
|
||||
/*RULES
|
||||
reminders
|
||||
> 21 remind_first_days = 31 reminder_first
|
||||
> 21 remind_first_days + sepa = 32 reminder_first_sepa
|
||||
> 14 remind_sec_days = 33 reminder_sec
|
||||
> 2 remind_last_days = 34 reminder_last
|
||||
> 0 deaktiv = 35 reminder_deaktiv
|
||||
> 0 deaktiv + sepa = 36 reminder_deaktiv_sepa
|
||||
== 7 abo_booking_days + sepa + cron = 37 reminder_collect_sepa
|
||||
*/
|
||||
//max Date for reminder
|
||||
$renewalDate = Carbon::now()->modify('+'.(config('mivita.remind_first_days')+1).' days');
|
||||
dump($renewalDate);
|
||||
$users = User::where('payment_account', '!=', NULL)
|
||||
->where('active', '=', 1)
|
||||
->where('blocked', '!=', 1)
|
||||
->where('payment_account', '<', $renewalDate)
|
||||
->get();
|
||||
|
||||
|
||||
$user = User::find(2);
|
||||
|
||||
/* $this->checkReminderPayments($user);
|
||||
dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
die();*/
|
||||
foreach ($users as $user){
|
||||
|
||||
|
||||
//$this->checkReminderPayments($user);
|
||||
|
||||
|
||||
// dump($user->nextRenewalAccount());
|
||||
//$userHistoryWizardPayment = UserHistory::whereUserId($user->id)->whereAction('wizard_payment')->get()->last();
|
||||
|
||||
//UserHistory::create(['user_id' => $user->id, 'action'=>'released_completed', 'status'=>0]);
|
||||
|
||||
dump($user->daysActiveAccount());
|
||||
dump($user->email." | ".$user->getPaymentAccountDateFormat());
|
||||
|
||||
}
|
||||
die("");
|
||||
}
|
||||
|
||||
|
||||
private function checkReminderPayments(User $user){
|
||||
|
||||
|
||||
$isSend = $this->checkIsReminderSend($user, 31);
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
|
||||
return ;
|
||||
|
||||
|
||||
//35 reminder_deaktiv, 36 reminder_deaktiv_sepa
|
||||
if(!$user->isActiveAccount()){
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 35);
|
||||
return $isSend;
|
||||
}
|
||||
$isSend = $this->checkIsReminderSend($user, 36);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//34 reminder_last
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_last_days')){
|
||||
$isSend = $this->checkIsReminderSend($user, 34);
|
||||
return $isSend;
|
||||
}
|
||||
|
||||
//33 reminder_sec
|
||||
if($user->daysActiveAccount() <= config('mivita.remind_sec_days')){
|
||||
if(!$user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 33);
|
||||
return $isSend;
|
||||
}
|
||||
}
|
||||
|
||||
//31 reminder_first, 32 reminder_first_sepa
|
||||
if($user->daysActiveAccount() > config('mivita.remind_sec_days')){
|
||||
if($user->isAboOption()){
|
||||
$isSend = $this->checkIsReminderSend($user, 32);
|
||||
return $isSend;
|
||||
}
|
||||
$isSend = $this->checkIsReminderSend($user, 31);
|
||||
return $isSend;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function checkIsReminderSend(User $user, $status){
|
||||
|
||||
$isSend = UserHistory::whereUserId($user->id)
|
||||
->whereAction('reminder_payments')
|
||||
->whereIdentifier($user->payment_account)
|
||||
->whereStatus($status)
|
||||
->get()->last();
|
||||
|
||||
if($isSend){
|
||||
// return true;
|
||||
}
|
||||
$referenz = $this->sendReminderMail($user, $status);
|
||||
//is not sent create
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'reminder_payments', 'referenz'=>$referenz, 'identifier'=>$user->payment_account, 'status'=>$status]);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private function sendReminderMail(User $user, $status){
|
||||
|
||||
$days = $user->daysActiveAccount();
|
||||
if($days < 0){
|
||||
$days = $days*-1;
|
||||
}
|
||||
|
||||
$pay_date = Carbon::parse($user->payment_account)->modify('- '.config('mivita.abo_booking_days').' days')->format('d.m.Y');
|
||||
$datetime = $user->getPaymentAccountDateFormat();
|
||||
|
||||
$price = "";
|
||||
if($user->payment_order_id && isset($user->payment_order_product->price)){
|
||||
$price = 'von '.$user->payment_order_product->getFormattedPrice().' EUR';
|
||||
}
|
||||
|
||||
$message = __('reminder.copy_first_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$message_last = __('reminder.copy_last_'.$status, ['days'=>$days, 'datetime'=>$datetime, 'price' =>$price, 'pay_date'=>$pay_date]);
|
||||
$button = __('reminder.button_'.$status);
|
||||
|
||||
$message = preg_replace("/[\n\r]/","",$message);
|
||||
$message_last = preg_replace("/[\n\r]/","",$message_last);
|
||||
|
||||
$data = [
|
||||
'subject' => __('reminder.subject')." | ID: ".$status,
|
||||
'message' => $message,
|
||||
'message_last' => $message_last,
|
||||
'url' => route('user_membership'),
|
||||
'button' => $button,
|
||||
];
|
||||
dump($data);
|
||||
$sender = User::find(1);
|
||||
|
||||
$customer_mail = UserMessage::create([
|
||||
'user_id' => $user->id,
|
||||
'send_user_id' => $sender->id,
|
||||
'email' => $user->email,
|
||||
'subject' => $data['subject'],
|
||||
'message' => $data['message']." ".$data['message_last'],
|
||||
]);
|
||||
|
||||
try{
|
||||
Mail::to($user->email)->send(new MailCustomMessage($user, $data, $sender, false));
|
||||
}
|
||||
catch(\Exception $e){
|
||||
\Log::channel('cron')->error('Mail Error: '.$e->getMessage());
|
||||
// Never reached
|
||||
$customer_mail->fail = true;
|
||||
$customer_mail->error = $e->getMessage();
|
||||
$customer_mail->save();
|
||||
return 0;
|
||||
}
|
||||
$customer_mail->send = true;
|
||||
$customer_mail->sent_at = now();
|
||||
$customer_mail->save();
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -277,7 +277,7 @@ class LeadController extends Controller
|
|||
'message' => $input['account_incomplete_message'],
|
||||
'confirmation_code' => $confirmation_code,
|
||||
];
|
||||
Mail::to($user->email)->send(new MailCustomMessage($user, $data, \Auth::user()));
|
||||
Mail::to($user->email)->send(new MailCustomMessage($user, $data, \Auth::user(), true));
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>'released_incomplete', 'status'=>0]);
|
||||
\Session()->flash('alert-success', "E-Mail an Berater gesendet.");
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class PayoneController extends Controller
|
|||
public function init($shopping_user, $shopping_order){
|
||||
$this->shopping_user = $shopping_user;
|
||||
$this->shopping_order = $shopping_order;
|
||||
$this->default['mode'] = $this->shopping_order->mode;
|
||||
}
|
||||
|
||||
public function getShoppingPayment(){
|
||||
|
|
@ -328,7 +329,6 @@ class PayoneController extends Controller
|
|||
];
|
||||
$request = array_merge($this->default, $this->prepayment);
|
||||
return Payone::sendRequest($request);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -348,9 +348,8 @@ class PayoneController extends Controller
|
|||
|
||||
// "language" => 'de',
|
||||
];
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
|
||||
|
||||
// dd($request);
|
||||
$request = array_merge($this->default, $this->personalData, $this->deliveryData, $this->method, $this->prepayment, $this->urls);
|
||||
return Payone::sendRequest($request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,38 @@ class AdminToolsController extends Controller
|
|||
dd('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function cronjobs()
|
||||
{
|
||||
//$user_shops = UserShop::all();
|
||||
$text = "";
|
||||
$values = [
|
||||
'check_payments_account' => route('cron_jobs_action', ['check_payments_account', 'key'])
|
||||
];
|
||||
$data = [
|
||||
'values' => $values,
|
||||
'text' => $text,
|
||||
];
|
||||
|
||||
return view('sys.admin.cronjobs', $data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function cronjobsStore()
|
||||
{
|
||||
$data = Input::all();
|
||||
\Session()->flash('alert-save', true);
|
||||
return back();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
|
|
@ -75,10 +107,8 @@ class AdminToolsController extends Controller
|
|||
public function domainSSLStore()
|
||||
{
|
||||
$data = Input::all();
|
||||
|
||||
\Session()->flash('alert-save', true);
|
||||
return back();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ class CheckoutController extends Controller
|
|||
//need precheck the card
|
||||
if(Input::get('payment_method') === 'cc'){
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$ret['cc'] = $pay->checkCreditCard($data);
|
||||
if($ret['cc']['status'] === 'ERROR' || $ret['cc']['status'] === 'INVALID'){
|
||||
/* PaymentTransaction::create([
|
||||
|
|
@ -163,6 +164,7 @@ class CheckoutController extends Controller
|
|||
//need precheck the card
|
||||
if(Input::get('payment_method') === 'elv' && is_null(Input::get('mandate_identification'))){
|
||||
$pay = new PayoneController();
|
||||
$pay->init($shopping_user, $shopping_order);
|
||||
$amount = (int) (float) Yard::instance('shopping')->totalWithShipping(2, '.', ',') *100;
|
||||
$ret['elv'] = $pay->checkBankAccount($data, $amount, 'EUR', $shopping_user);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
|
|||
use App\Mail\MailContact;
|
||||
use App\Mail\MailVerifyAccount;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\UserService;
|
||||
use App\User;
|
||||
use GuzzleHttp\Client;
|
||||
use Input;
|
||||
|
|
|
|||
|
|
@ -400,7 +400,6 @@ class WizardController extends Controller
|
|||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Input::get('switchers-package-wizard'));
|
||||
$showAboOptions = false;
|
||||
|
||||
if(Input::get('abo_options')){
|
||||
$showAboOptions = true;
|
||||
$user->abo_options = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue