testemich Promotion

This commit is contained in:
Kevin Adametz 2022-04-14 13:21:17 +02:00
parent 38e7fd504a
commit a0f4eda6ea
83 changed files with 1690 additions and 504 deletions

View file

@ -68,7 +68,7 @@ class CronController extends Controller
}
//send new remider
if ($user->confirmation_code_remider == 0) {
Mail::to($user->email)->send(new MailVerifyAccount($user->confirmation_code, $user));
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($user->confirmation_code, $user));
$user->confirmation_code_to = $next;
$user->confirmation_code_remider = 1;
$user->save();
@ -218,7 +218,7 @@ class CronController extends Controller
]);
try{
if($status >= 34){
Mail::to($user->email)->bcc(config('app.default_mail'))->send(new MailCustomMessage($user, $data, $sender, false));
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailCustomMessage($user, $data, $sender, false));
}else{
Mail::to($user->email)->send(new MailCustomMessage($user, $data, $sender, false));
}

View file

@ -122,7 +122,6 @@ class LeadController extends Controller
$data = Request::all();
$show = Request::get('show');
dd($data);
if ($data['user_id'] === "new" || $data['user_id'] == 0) {
$rules = array(
'salutation' => 'required',
@ -203,7 +202,7 @@ class LeadController extends Controller
//10 == start wizard form create Lead
$user->wizard = 10;
$user->save();
Mail::to($user->email)->send(new MailVerifyContact($confirmation_code, $user));
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyContact($confirmation_code, $user));
\Session()->flash('alert-save', true);
return redirect(route('admin_leads'));
@ -260,7 +259,7 @@ class LeadController extends Controller
//mail with code to user?
try {
Mail::to($user->email)->send(new MailAccountActive($user));
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailAccountActive($user));
}
catch(\Exception $e){
SysLog::action('released', 'admin_lead', 5)
@ -293,7 +292,7 @@ class LeadController extends Controller
'confirmation_code' => $confirmation_code,
];
try {
Mail::to($user->email)->send(new MailCustomMessage($user, $data, \Auth::user(), true));
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailCustomMessage($user, $data, \Auth::user(), true));
}
catch(\Exception $e){
SysLog::action('released_incomplete', 'admin_lead', 5)
@ -322,7 +321,7 @@ class LeadController extends Controller
$user->save();
try {
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($confirmation_code, $user));
}
catch(\Exception $e){
SysLog::action('new_mail_verified', 'admin_lead', 5)

View file

@ -186,7 +186,7 @@ class PayController extends Controller
Util::setUserHistoryValue(['status'=>5], $identifier);
switch ($payment_for) {
case 4: //promotion
case 7: //promotion
return redirect(route('web_promotion_goto', ['thanksorder', $this->shopping_order->promotion_user_id, $payt->id, $this->reference, $identifier]));
break;

View file

@ -29,7 +29,7 @@ class PayPalController extends Controller
"reference_id" => $shopping_payment->reference,
"shopping_order_id" => $shopping_payment->shopping_order_id,
"amount"=> [
"currency_code"=> "USD",
"currency_code"=> "EUR",
"value"=> ($shopping_payment->amount / 100)
],
'description' => 'test'

View file

@ -80,6 +80,9 @@ class PaymentInvoiceController extends Controller
->addColumn('txaction', function (ShoppingOrder $ShoppingOrder) {
return Payment::getShoppingOrderBadge($ShoppingOrder);
})
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
})
->addColumn('invoice', function (ShoppingOrder $ShoppingOrder) {
$ret = "";
if(Invoice::isInvoice($ShoppingOrder)){
@ -95,8 +98,9 @@ class PaymentInvoiceController extends Controller
->orderColumn('invoice_number', 'invoice_number $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('payment_for', 'payment_for $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'shipping_order', 'txaction', 'invoice'])
->rawColumns(['id', 'shipping_order', 'txaction', 'payment_for', 'invoice'])
->make(true);
}
}

View file

@ -81,17 +81,8 @@ class SalesController extends Controller
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
})
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->shopping_user->is_for === 'me'){
return '<span class="badge badge-pill badge-secondary">Vertriebspartnerbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'ot'){
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'hp'){
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
}
return '-';
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
})
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('reference');
@ -101,10 +92,11 @@ class SalesController extends Controller
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('payment_for', 'payment_for $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'txaction', 'is_for', 'shipped'])
->rawColumns(['id', 'txaction', 'payment_for', 'shipped'])
->make(true);
}
@ -217,17 +209,8 @@ class SalesController extends Controller
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
})
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->shopping_user->is_for === 'me'){
return '<span class="badge badge-pill badge-secondary">Vertriebspartnerbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'ot'){
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'pr'){
return '<span class="badge badge-pill badge-dark">Promotion</span>';
}
return '-';
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
})
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('reference');
@ -249,11 +232,11 @@ class SalesController extends Controller
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('is_for', 'is_for $1')
->orderColumn('payment_for', 'payment_for $1')
->orderColumn('member_id', 'member_id $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'is_for', 'shipped'])
->rawColumns(['id', 'member_id', 'txaction', 'user_shop_id', 'payment_for', 'shipped'])
->make(true);
}
@ -263,11 +246,13 @@ class SalesController extends Controller
abort(404);
}
if(isset($data['action'])){
if($data['action'] === 'store_shipped' && isset($data['shipped'])){
$shopping_order = ShoppingOrder::findOrFail($data['id']);
$shopping_order->shipped = $data['shipped'];
$shopping_order->save();
//handel Promotion Product and credit by storno
Payment::handelUserPromotionOrder($shopping_order);
if($shopping_order->getAPIShippedType() === 'sent' || $shopping_order->getAPIShippedType() === 'close'){
if(!$shopping_order->shipped_at){
$shopping_order->shipped_at = now();
@ -304,11 +289,16 @@ class SalesController extends Controller
}
if($data['action'] === 'store_txaction' && isset($data['txaction']) && isset($data['payment_id'])){
$shopping_order = ShoppingOrder::findOrFail($data['id']);
$shopping_payment = ShoppingPayment::findOrFail($data['payment_id']);
if($shopping_payment->txaction === $data['txaction']){
return back();
}
//shopping_order_margin Bestellung im partner Center
if($shopping_order->shopping_order_margin && $shopping_order->shopping_order_margin->from_payment_credit > 0){
$last_UserPayCredit = UserPayCredit::where('shopping_order_id', $shopping_order->id)->whereIn('status', [2, 4])->orderBy('id', 'DESC')->first();
//Status Keine Zahlung, Guthaben zurückführen, wenn status 2 / deduction from payment
@ -319,9 +309,7 @@ class SalesController extends Controller
if($last_UserPayCredit && $last_UserPayCredit->status === 4 && ($data['txaction'] === 'open' || $data['txaction'] === 'paid')){
Payment::handelUserPayCredits($shopping_order, 'deduction');
}
}
}
$payt = PaymentTransaction::create([
'shopping_payment_id' => $shopping_payment->id,
'request' => 'transaction',
@ -332,7 +320,7 @@ class SalesController extends Controller
'txaction' => $data['txaction'],
'mode' => $shopping_payment->mode,
]);
$shopping_order->txaction = $data['txaction'];
$shopping_order->paid = $payt->txaction === 'paid' ? true : false;
$shopping_order->save();
@ -342,6 +330,19 @@ class SalesController extends Controller
if($payt->status === 'vor' && $payt->txaction === 'paid'){
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
}
//handel credit loading by change when by $shopping_order_item->handl
if($shopping_order->shopping_user->is_for === 'cr'){
$last_UserPayCredit = UserPayCredit::where('shopping_order_id', $shopping_order->id)->whereIn('status', [7, 8])->orderBy('id', 'DESC')->first();
//Status Keine Zahlung, Guthaben abziehen, wenn status 7 <- wurde aufgeladen
if($data['txaction'] === 'non' && $last_UserPayCredit && $last_UserPayCredit->status === 7){
Payment::handelUserPayChargingCredits($shopping_order, 'remove');
}
//Status Zahlung, voher gab es eine Storno, Guthaben wieder aufladen, wenn bezahlt wenn status 8
if($last_UserPayCredit && $last_UserPayCredit->status === 8 && $data['txaction'] === 'paid'){
Payment::handelUserPayChargingCredits($shopping_order, 'add');
}
}
$edata = [
'mode' => $payt->mode,
@ -362,7 +363,6 @@ class SalesController extends Controller
public function invoice(){
$data = Request::all();
//$data['id'] ShoppingOrder id
if(!isset($data['id'])){
abort(404);
}
@ -370,7 +370,11 @@ class SalesController extends Controller
if($data['action'] === 'create_invoice'){
$shopping_order = ShoppingOrder::findOrFail($data['id']);
$invoice_repo = new InvoiceRepository($shopping_order);
$invoice_repo->create($data);
if(\App\Services\Invoice::isInvoice($shopping_order)){
$user_invoice = $invoice_repo->update($data);
}else{
$user_invoice = $invoice_repo->create($data);
}
return redirect(route('admin_sales_users_detail', [$shopping_order->id]));
}
}

View file

@ -24,7 +24,7 @@ class SettingController extends Controller
{
$data = [
'values' => Ingredient::all(),
'values' => [],
];
return view('admin.settings.index', $data);
}

View file

@ -35,10 +35,9 @@ class AdminToolsController extends Controller
public function index($action)
{
dd($action);
switch ($action) {
case 'pay_credits':
# code...
dd($action);
$value = $this->makeUserPayCredits();
$data = [
'values' => $value,
@ -46,9 +45,28 @@ class AdminToolsController extends Controller
];
return view('sys.admin.index', $data);
break;
case 'value':
# code...
break;
case 'export_vp':
$values = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 4)->get();
$data = [
'values' => $values,
'text' => '',
];
return view('sys.admin.export_vp', $data);
break;
case 'dbaction':
$values = [];
$data = [
'values' => $values,
//'text' => 'Add payment_for in shopping_order', //_dbOrderPaymentFor
//'text' => 'Calculate TAX for shopping_order in tax_split array ',
'text' => 'show in AdminToolsController dbaction',
];
return view('sys.admin.index', $data);
break;
}
@ -57,23 +75,76 @@ class AdminToolsController extends Controller
public function store($action)
{
dd($action);
$data = [];
switch ($action) {
case 'pay_credits':
# code...
dd($action);
return view('sys.admin.index', $data);
break;
case 'value':
# code...
case 'export_vp':
return $this->export_vp();
break;
case 'dbaction':
//return $this->_dbOrderPaymentFor();
break;
}
}
private function _dbOrderPaymentFor(){
$c = 0;
$ShoppingUsers = ShoppingUser::all();
foreach($ShoppingUsers as $ShoppingUser){
if($ShoppingUser->shopping_order){
$ShoppingUser->shopping_order->payment_for = $ShoppingUser->getOrderPaymentFor();
$ShoppingUser->shopping_order->save();
$c ++;
}
}
dd($c);
}
private function export_vp(){
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)->where('users.admin', "<", 4)->get();
$fileName = "GS-VP-export-".date("d-m-Y").".csv";
$headers = array(
"Content-type" => "text/csv",
"Content-Disposition" => "attachment; filename=$fileName",
"Pragma" => "no-cache",
"Cache-Control" => "must-revalidate, post-check=0, pre-check=0",
"Expires" => "0"
);
$columns = array('ID', 'Email', 'Firma', 'Anrede', 'Vorname', 'Nachname', 'Mitglied', 'Bis');
$callback = function() use($query, $columns) {
$file = fopen('php://output', 'w');
fputcsv($file, $columns);
$row = [];
foreach ($query as $val) {
$row['ID'] = $val->id;
$row['Email'] = $val->email;
$row['Firma'] = $val->account->company;
$row['Anrede'] = $val->account->salutation == 'mr' ? 'Herr' : 'Frau' ;
$row['Vorname'] = $val->account->first_name;
$row['Nachname'] = $val->account->last_name;
$row['Mitglied'] = $val->payment_account ? ($val->isActiveAccount() ? 'JA' : 'Abgelaufen') : "Nein";
$row['Bis'] = $val->payment_account ? $val->getPaymentAccountDateFormat(false) : "-";
fputcsv($file, $row);
}
fclose($file);
};
return response()->stream($callback, 200, $headers);
//dd("ok");
}
private function makeUserPayCredits()
{
//is the first of

View file

@ -409,7 +409,7 @@ class CheckoutController extends Controller
'shopping_user_id' => $shopping_user->id,
'auth_user_id' => $shopping_user->auth_user_id,
'country_id' => Yard::instance('shopping')->getShippingCountryId(),
'payment_for' => Util::getUserPaymentFor(),
'payment_for' => $shopping_user->getOrderPaymentFor(),
'total' => Yard::instance('shopping')->total(2, '.', ''),
'subtotal_full' => Yard::instance('shopping')->subtotal(2, '.', '', false),
'discount' => $discount,

View file

@ -76,26 +76,18 @@ class OrderController extends Controller
->addColumn('shipped', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getShippedColor().'">'.$ShoppingOrder->getShippedType().'</span>';
})
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->shopping_user->is_for === 'me'){
return '<span class="badge badge-pill badge-secondary">Vertriebspartnerbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'ot'){
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'hp'){
return '<span class="badge badge-pill badge-dark">Homepartybestellung</span>';
}
return '-';
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
})
->addColumn('reference', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->getLastShoppingPayment('reference');
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->orderColumn('payment_for', 'payment_for $1')
->orderColumn('shipped', 'shipped $1')
->orderColumn('total_shipping', 'total_shipping $1')
->rawColumns(['id', 'txaction', 'is_for', 'shipped'])
->rawColumns(['id', 'txaction', 'payment_for', 'shipped'])
->make(true);
}
@ -139,7 +131,7 @@ class OrderController extends Controller
$user = User::find(\Auth::user()->id);
$shopping_user = null;
$delivery_id = null;
if($for === 'ot'){
$shopping_user = $this->checkShoppingUser($id, $user);
$delivery_id = $shopping_user->id;
@ -149,9 +141,15 @@ class OrderController extends Controller
\Session()->flash('custom-error', __('validation.custom.shipping_not_found'));
return redirect(route('user_order_my_delivery', [$for, $delivery_id]));
}
Yard::instance('shopping')->setShippingCountryWithPrice($shipping_country_id, $for);
Yard::instance('shopping')->setShoppingUser($user, true);
if($for === 'cr'){
Yard::instance('shopping')->setGlobalTaxRate(0);
Yard::instance('shopping')->setShoppingUser($user, false);
}else{
Yard::instance('shopping')->setShoppingUser($user, true);
}
$data = [
'shopping_user' => $shopping_user,
@ -166,6 +164,7 @@ class OrderController extends Controller
}
public function payment($for, $id=null){
$data = Request::all();
$user = User::find(Auth::user()->id);
$rules = array(
@ -182,7 +181,6 @@ class OrderController extends Controller
if ($validator->fails()) {
return back()->withErrors($validator)->withInput(Request::all());
}
if(Yard::instance('shopping')->getNumComp() > 0){
if(!isset($data['switchers-comp-product'])){
$validator->errors()->add('switchers-comp-product', __('Bitte wähle ein Kompensationsprodukt aus'));
@ -236,7 +234,7 @@ class OrderController extends Controller
private function checkShoppingCountry($for, $id=null){
$country_id = null;
if($for === 'me'){
if($for === 'me' || $for === 'mp' || $for === 'cr'){
$user = User::find(\Auth::user()->id);
if($user->same_as_billing){
$country_id = $user->account->country_id;
@ -279,11 +277,22 @@ class OrderController extends Controller
public function datatable(){
$not_show_pids = ProductBuy::getNotShowProductIDs(Auth::user()->id);
if(Request::get('shipping_is_for') === 'me'){
$query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '2');
}else{
$query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '1');
switch (Request::get('shipping_is_for')) {
case 'me':
$query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '2');
break;
case 'mp':
$query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '2');
break;
case 'cr':
$query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '6');
break;
case 'ot':
$query = Product::select('products.*')->where('active', true)->whereJsonContains('show_on', '1');
break;
}
foreach($not_show_pids as $not_show_pid){
$query->where('id', '!=', $not_show_pid);

View file

@ -62,8 +62,16 @@ class PromotionController extends Controller
if(isset($data['action']) && $data['action'] === 'save-user-promotion'){
$rules = array(
'name' => 'required',
'user_promotion_url' => ' required|alpha_dash|profanity|unique:promotion_users,url,'.\Auth::user()->id.',user_id|min:4|max:20',
'user_promotion_url' => ' required|alpha_dash|profanity|'.'unique:promotion_users,url,'.$id.',id'.'|min:4|max:20|full_word_check',
);
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
$profanity = \App\Models\Setting::getContentBySlug('promotion_user_url_profanity');
$profanity = array_map('trim', explode(',', $profanity));
if(in_array($value, $profanity)){
return false;
}
return true;
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {
return redirect(route('user_promotion_detail', [$id]))->withErrors($validator)->withInput(Request::all());
@ -95,16 +103,21 @@ class PromotionController extends Controller
$data = Request::all();
if(Request::ajax()) {
if(isset($data['action']) && $data['action'] === 'validate_url'){
$unique = 'unique:promotion_users,url';
if(isset($data['puid'])){
$unique .= ','.$data['puid'].',id';
}
$rules = array(
//'user_promotion_url' => ' required|alpha_dash|profanity|unique:user_shops,name|min:4|max:20|full_word_check',
'user_promotion_url' => ' required|alpha_dash|profanity|unique:promotion_users,url,'.\Auth::user()->id.',user_id|min:4|max:20',
'user_promotion_url' => ' required|alpha_dash|profanity|'.$unique.'|min:4|max:20|full_word_check',
);
/*Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
if(in_array($value, config('profanity.full_word_check'))){
Validator::extend('full_word_check', function ($attribute, $value, $parameters, $validator) {
$profanity = \App\Models\Setting::getContentBySlug('promotion_user_url_profanity');
$profanity = array_map('trim', explode(',', $profanity));
if(in_array($value, $profanity)){
return false;
}
return true;
});*/
});
$validator = Validator::make(Request::all(), $rules);
if ($validator->fails()) {

View file

@ -61,21 +61,13 @@ class SalesController extends Controller
->addColumn('user_shop_id', function (ShoppingOrder $ShoppingOrder) {
return $ShoppingOrder->user_shop ? '<a href="'.$ShoppingOrder->user_shop->getSubdomain(false).'" target="_blank">'.$ShoppingOrder->user_shop->getSubdomain(false).'</span>' : '';
})
->addColumn('is_for', function (ShoppingOrder $ShoppingOrder) {
if($ShoppingOrder->shopping_user->is_for === 'me'){
return '<span class="badge badge-pill badge-secondary">Vertriebspartnerbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'ot'){
return '<span class="badge badge-pill badge-info">Kundenbestellung</span>';
}
if($ShoppingOrder->shopping_user->is_for === 'pr'){
return '<span class="badge badge-pill badge-dark">Promotion</span>';
}
return '-';
->addColumn('payment_for', function (ShoppingOrder $ShoppingOrder) {
return '<span class="badge badge-pill badge-'.$ShoppingOrder->getPaymentForColor().'">'.$ShoppingOrder->getPaymentForType().'</span>';
})
->orderColumn('id', 'id $1')
->orderColumn('txaction', 'txaction $1')
->rawColumns(['id', 'is_for', 'txaction', 'user_shop_id'])
->orderColumn('payment_for', 'payment_for $1')
->rawColumns(['id', 'payment_for', 'txaction', 'user_shop_id'])
->make(true);
}

View file

@ -146,7 +146,7 @@ class UserUpdateEmailController extends Controller
public function sendActivationMail($user, array $data)
{
$token = $this->createActivation($user, $data);
Mail::to($data['email'])->send(new MailActivateUser($token, $user));
Mail::to($data['email'])->bcc(config('app.info_mail'))->send(new MailActivateUser($token, $user));
}

View file

@ -31,9 +31,20 @@ class PromotionController extends Controller
public function serve($path = null)
{
if(!isset($path)){
abort(402);
$path = 'grueneseele';
//abort(402);
}
if($path === 'impressum'){
return view('web.promotion.impressum');
}
if($path === 'datenschutzerklaerung'){
return view('web.promotion.datenschutzerklaerung');
}
if($path === 'widerrufsbelehrung'){
return view('web.promotion.widerrufsbelehrung');
}
//search for promo
$PromotionUser = PromotionUser::where('url', trim($path))->whereNull('user_deleted_at')->first();
if(!$PromotionUser){
@ -137,14 +148,9 @@ class PromotionController extends Controller
UserHistory::create(['user_id' => $PromotionUser->user_id, 'action'=>'web_promotion_payment', 'status'=>1, 'product_id'=>null, 'identifier'=>$identifier]);
$checkRepo = new CheckoutRepository();
$checkRepo->setPromotion(4, $PromotionUser);
$checkRepo->setPromotion(7, $PromotionUser);
$checkRepo->init($identifier, $data);
return $checkRepo->makePayment();
//$path = str_replace('http', 'https', $path);
//return redirect()->secure($path);
// return redirect(route('user_checkout', [$identifier]));
}
}
@ -168,18 +174,23 @@ class PromotionController extends Controller
$shopping_payment->txaction = 'open';
$shopping_order->txaction = 'open';
$payt->txaction = "open";
$shopping_order->save();
}
if($payt->status === 'pp'){
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
$shopping_payment->txaction = 'paid';
$shopping_order->txaction = 'paid';
$payt->txaction = "paid";
$shopping_order->save();
}
if($payt->status === 'fnc'){
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
$shopping_payment->txaction = 'open';
$shopping_order->txaction = 'open';
$payt->txaction = "open";
$shopping_payment->txaction = 'paid';
$shopping_order->txaction = 'paid';
$payt->txaction = "paid";
$shopping_order->save();
}
if($payt->status === 'non'){
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
@ -248,7 +259,7 @@ class PromotionController extends Controller
$invoice = view("web.promotion._invoice_details")->render();
}
$checkout = view("web.promotion._checkout")->render();
$data['shipping_price_formated'] = Yard::instance('shopping')->shipping();
$data['shipping_price_formated'] = PromotionCart::getCurrentShippingPrice();
return response()->json(['response' => $data, 'cart'=>$cart, 'invoice'=>$invoice, 'checkout'=>$checkout, 'status'=>$status]);
}

View file

@ -85,7 +85,7 @@ class RegisterController extends Controller
$user = User::find($user->id);
try {
Mail::to($user->email)->send(new MailVerifyAccount($confirmation_code, $user));
Mail::to($user->email)->bcc(config('app.info_mail'))->send(new MailVerifyAccount($confirmation_code, $user));
}
catch(\Exception $e){
SysLog::action('register-user', 'auth_register', 5)

View file

@ -136,7 +136,7 @@ class Category extends Model
public function getShowOnTypes(){
$ret = [];
if(is_array($this->show_on)){
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
}

View file

@ -73,7 +73,7 @@ class PaymentMethod extends Model
public function getShowOnTypes(){
$ret = [];
if($this->show_on){
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$payShowONs[$show]) ? Type::$payShowONs[$show] : '-';
}

View file

@ -224,6 +224,7 @@ class Product extends Model
public $actions = [
0 => 'payment_for_account',
1 => 'charging_credits',
// 1 => 'payment_for_shop',
// 2 => 'payment_for_shop_upgrade',
// 4 => 'payment_for_lead_upgrade',
@ -425,8 +426,10 @@ class Product extends Model
public function getShowOnTypes(){
$ret = [];
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
}
}
return $ret;
}

View file

@ -49,8 +49,10 @@ class ProductCategory extends Model
public function getShowOnTypes(){
$ret = [];
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
if($this->show_on && is_array($this->show_on)){
foreach($this->show_on as $show){
$ret[] = isset(Type::$showONs[$show]) ? Type::$showONs[$show] : '-';
}
}
return $ret;
}

View file

@ -102,7 +102,7 @@ class PromotionAdminProduct extends Model
public function setPriceAttribute( $value ) {
$this->attributes['price'] = $value ? Util::reFormatNumber($value) : null;
$this->attributes['price'] = $value !== null ? Util::reFormatNumber($value) : null;
}
public function getFormattedPrice()
@ -112,7 +112,7 @@ class PromotionAdminProduct extends Model
public function getRealPrice()
{
if($this->own_price && $this->price){
if($this->own_price && $this->price !== null){
return $this->price;
}
if($this->product && $this->product->price){

View file

@ -121,7 +121,18 @@ class PromotionUser extends Model
return $this->hasMany(PromotionUserProduct::class)->where('active', 1);
}
public function promotion_user_orders()
{
return $this->hasMany(PromotionUserOrder::class);
}
public function getPromotionUserOrders($shopping_order_id)
{
return PromotionUserOrder::where('promotion_user_id', $this->id)->where('shopping_order_id', $shopping_order_id)->get();
}
public function getUrlPreview()
{
return $this->url ? config('app.promo_url')."/".$this->url : "";
@ -182,12 +193,15 @@ class PromotionUser extends Model
public function checkPaymentCredit()
{
if($this->promotion_user_products_active->count() > 0 && $this->getCountOpenItems() > 0){
$prices = $this->calculateCart();
if(isset($prices['price']) && $prices['price'] == 0){
return "okay";
}
$payment_credit = $this->user->payment_credit;
if($payment_credit <= 0){
return "empty";
}
$prices = $this->calculateCart();
if(isset($prices['price']) && $prices['price'] > 0){
if($payment_credit >= $prices['price']){
return "okay";
@ -211,8 +225,12 @@ class PromotionUser extends Model
return false;
}
public static function preCheckPaymentCredit($values, $user){
if($values['count_items'] > 0 && $values['sum_items'] > 0){
if(isset($values['price']) && $values['price'] == 0){
return "okay";
}
$payment_credit = $user->payment_credit;
if($payment_credit <= 0){
return "empty";
@ -227,7 +245,6 @@ class PromotionUser extends Model
return false;
}
public static function preCalculateCart($value, $by = ''){
$price = 0;
$price_net = 0;

View file

@ -71,7 +71,8 @@ class PromotionUserOrder extends Model
'price' => 'float',
'price_net' => 'float',
'tax_rate' => 'float',
'status' => 'int'
'status' => 'int',
'pick_up' => 'bool',
];
protected $fillable = [
@ -86,9 +87,15 @@ class PromotionUserOrder extends Model
'price',
'price_net',
'tax_rate',
'status'
'status',
'pick_up'
];
public static $statusTypes = [
0 => 'bestellt',
10 => 'storniert'
];
public function product()
{
return $this->belongsTo(Product::class);
@ -123,4 +130,29 @@ class PromotionUserOrder extends Model
{
return $this->belongsTo(ShoppingUser::class);
}
public function getStatusType(){
return isset(self::$statusTypes[$this->status]) ? self::$statusTypes[$this->status] : "";
}
public function setStatusTxAction($txaction){
switch ($txaction) {
case 'none':
$this->status = 10;
break;
case 'open':
$this->status = 0;
break;
case 'paid':
$this->status = 3;
break;
}
$this->save();
}
public function setStatusShipped($shipped){
$this->status = $shipped === 'cancel' ? 10 : 0;
$this->save();
}
}

View file

@ -96,4 +96,5 @@ class PromotionUserProduct extends Model
}
return false;
}
}

View file

@ -157,23 +157,49 @@ class ShoppingOrder extends Model
1 => 'in Bearbeitung',
2 => 'versendet',
3 => 'abgeschlossen',
4 => 'Abholung',
10 => 'storniert'
];
public static $paymentForTypes = [
0 => '',
1 => 'wizzard',
2 => 'user_order me',
3 => 'user_order ot',
4 => 'Promotion',
10 => ''
1 => 'Registrierung',
2 => 'Mitgliedschaft',
3 => 'Guthabenaufladung', //guthaben
4 => 'VP.Bestellung Abholung',
5 => 'VP.Bestellung Lieferung',
6 => 'VP.Kundenbestellung',
7 => 'Promotion',
8 => 'Shop',
9 => '-',
10 => 'extern',
11 => ''
];
public static $paymentForColors = [
0 => 'default',
1 => 'warning',
2 => 'warning',
3 => 'secondary',
4 => 'secondary',
5 => 'secondary',
6 => 'info',
7 => 'dark',
8 => 'info',
9 => 'default',
10 => 'info',
11 => 'default'
];
public static $apiShippedTypes = [
0 => 'open', //(Fullfilment durch Händler)',
1 => 'process', //(Fullfilment durch MIVITA: nicht Versand)
2 => 'sent', //(Fullfilment durch MIVITA: Versand erfolgt)'
3 => 'close', //(Fullfilment durch MIVITA: Versand erfolgt)',
4 => 'pick_up', //(Fullfilment durch MIVITA: Versand erfolgt)',
10 => 'cancel'
];
@ -182,6 +208,7 @@ class ShoppingOrder extends Model
1 => 'info',
2 => 'success',
3 => 'secondary',
4 => 'success',
10 => 'danger',
];
@ -272,6 +299,13 @@ class ShoppingOrder extends Model
return isset(self::$shippedColors[$this->shipped]) ? self::$shippedColors[$this->shipped] : "default";
}
public function getPaymentForType(){
return isset(self::$paymentForTypes[$this->payment_for]) ? self::$paymentForTypes[$this->payment_for] : "";
}
public function getPaymentForColor(){
return isset(self::$paymentForColors[$this->payment_for]) ? self::$paymentForColors[$this->payment_for] : "";
}
public function getFormattedTotal()
{
return formatNumber($this->attributes['total']);
@ -319,8 +353,6 @@ class ShoppingOrder extends Model
{
return formatNumber($this->attributes['payment_credit']);
}
public function getFormattedTotalShipping()
{
return formatNumber($this->attributes['total_shipping']);
@ -333,10 +365,14 @@ class ShoppingOrder extends Model
$count += $shopping_order_item->qty;
}
}
return $count;
}
public function isPickUp(){
return $this->shipping_option === 'pick_up' ? true : false;
}
public function isTax(){
return $this->tax > 0 ? true : false;
}
}

View file

@ -56,6 +56,18 @@ class ShoppingOrderItem extends Model
use SoftDeletes;
protected $dates = ['deleted_at'];
protected $casts = [
'shopping_order_id' => 'int',
'product_id' => 'int',
'comp' => 'int',
'free_product_id' => 'int',
'qty' => 'int',
'price' => 'float',
'price_net' => 'float',
'tax_rate' => 'float',
'handle' => 'bool',
];
protected $fillable = [
'shopping_order_id',
'row_id',
@ -67,6 +79,7 @@ class ShoppingOrderItem extends Model
'price_net',
'tax_rate',
'slug',
'handle',
];

View file

@ -251,4 +251,33 @@ class ShoppingUser extends Model
}
return "free";
}
public function getOrderPaymentFor() {
switch($this->is_from){
case 'wizard':
return 1;
case 'membership':
return 2;
case 'user_order':
if($this->is_for === 'cr'){
return 3;
}
if($this->is_for === 'mp'){
return 4;
}
if($this->is_for === 'me'){
return 5;
}
if($this->is_for === 'ot'){
return 6;
}
return 0;
case 'shopping':
return $this->is_for === 'pr' ? 7 : 8; //7 Promotion
case 'extern':
return 10;
}
return 0;
}
}

View file

@ -50,7 +50,10 @@ class UserPayCredit extends Model
4 => 'return from order',
5 => 'deduction from promotion',
6 => 'return from promotion',
7 => 'add credits from charging',
8 => 'remove credits from charging',
];
protected $table = 'user_pay_credits';
protected $casts = [

View file

@ -137,6 +137,7 @@ class CheckoutRepository {
'weight' => Yard::instance('shopping')->weight(),
'txaction' => 'prev',
'shipping_option' => Yard::instance('shopping')->getShippingOption(),
'shipped' => Yard::instance('shopping')->getShippingOption() === 'pick_up' ? 4 : 0,
'mode' => Util::getUserShoppingMode(),
];

View file

@ -10,6 +10,11 @@ use App\Services\MyPDFMerger;
class InvoiceRepository extends BaseRepository {
private $invoice_date;
private $invoice_number;
private $filename;
private $dir;
public function __construct(ShoppingOrder $model)
{
$this->model = $model;
@ -18,53 +23,81 @@ class InvoiceRepository extends BaseRepository {
public function create($request = [])
{
//need invoice $data
$invoice_number = isset($request['invoice_number']) ? $request['invoice_number'] : Invoice::getInvoiceNumber();
$invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y");
$number = Invoice::getInvoiceNumber();
$this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : $this->model->created_at->format("d.m.Y");
$invoice_send_mail = isset($request['invoice_send_mail']) ? true: false;
$invoice_number = Invoice::createInvoiceNumber($invoice_number, $invoice_date);
$this->invoice_number = Invoice::createInvoiceNumber($number, $this->invoice_date);
$this->dir = Invoice::getInvoiceStorageDir($this->invoice_date);
$this->filename = Invoice::makeInvoiceFilename($this->invoice_number);
$this->makePDF();
$data_file = [
'filename' => $this->filename,
'dir' => $this->dir,
'disk' => 'public',
'invoice_number' => $this->invoice_number,
'invoice_date' => $this->invoice_date,
];
$this->model->invoice = $data_file;
$this->model->invoice_number = $this->invoice_number;
$this->model->save();
Invoice::makeNextInvoiceNumber();
if($invoice_send_mail){
Invoice::sendInvoiceMail($this->model);
}
return true;
}
public function update($request = []){
if(isset($this->model->invoice['filename'])){
$this->invoice_date = isset($request['invoice_date']) ? $request['invoice_date'] : Invoice::getDate($this->model);
$invoice_send_mail = isset($request['invoice_send_mail']) ? true: false;
$this->invoice_number = Invoice::getNumber($this->model);
$this->dir = Invoice::getDir($this->model);
$this->filename = Invoice::getFilename($this->model);
$this->makePDF();
$data_file = [
'filename' => $this->filename,
'dir' => $this->dir,
'disk' => 'public',
'invoice_number' => $this->invoice_number,
'invoice_date' => $this->invoice_date,
];
$this->model->invoice = $data_file;
$this->model->invoice_number = $this->invoice_number;
$this->model->save();
if($invoice_send_mail){
Invoice::sendInvoiceMail($this->model);
}
return true;
}
return null;
}
private function makePDF(){
$data = [
'shopping_order' => $this->model,
'invoice_date' => $invoice_date,
'invoice_number' => $invoice_number,
'invoice_date' => $this->invoice_date,
'invoice_number' => $this->invoice_number,
];
$pdf = PDF::loadView('pdf.invoice', $data);
$pdf->setPaper('A4', 'portrait');
$dir = Invoice::getInvoiceStorageDir($invoice_date);
if(!Storage::disk('public')->exists( $dir )){
Storage::disk('public')->makeDirectory($dir); //creates directory
if(!Storage::disk('public')->exists( $this->dir )){
Storage::disk('public')->makeDirectory($this->dir); //creates directory
}
$path = Storage::disk('public')->getAdapter()->getPathPrefix();
$filename = Invoice::makeInvoiceFilename($invoice_number);
$pdf->save($path.$dir.$filename);
$pdf->save($path.$this->dir.$this->filename);
$pdfMerger = new MyPDFMerger();
$pdfMerger->addPDF($path.$dir.$filename);
$file = $pdfMerger->myMerge('string', $filename, 'template_invoice_de');
Storage::disk('public')->put($dir.$filename, $file);
$data_file = [
'filename' => $filename,
'dir' => $dir,
'disk' => 'public',
'invoice_number' => $invoice_number,
'invoice_date' => $invoice_date,
];
$this->model->invoice = $data_file;
$this->model->invoice_number = $invoice_number;
$this->model->save();
if($invoice_send_mail){
Invoice::sendInvoiceMail($this->model);
}
Invoice::makeNextInvoiceNumber();
return true;
//return $pdf->stream('invoice.pdf');
//return $this->output($path.$dir, $filename);
$pdfMerger->addPDF($path.$this->dir.$this->filename);
$file = $pdfMerger->myMerge('string', $this->filename, 'template_invoice_de');
Storage::disk('public')->put($this->dir.$this->filename, $file);
}
}

View file

@ -39,16 +39,24 @@ class Invoice
return isset($shopping_order->invoice['filename']) ? true : false;
}
public static function getFilename(ShoppingOrder $shopping_order){
public static function getFilename($shopping_order){
return isset($shopping_order->invoice['filename']) ? $shopping_order->invoice['filename'] : false;
}
public static function getDir(ShoppingOrder $shopping_order){
public static function getDir($shopping_order){
return isset($shopping_order->invoice['dir']) ? $shopping_order->invoice['dir'] : false;
}
public static function getDate($shopping_order){
return isset($shopping_order->invoice['invoice_date']) ? $shopping_order->invoice['invoice_date'] : false;
}
public static function getNumber($shopping_order){
return isset($shopping_order->invoice['invoice_number']) ? $shopping_order->invoice['invoice_number'] : false;
}
public static function getDownloadURL(ShoppingOrder $shopping_order, $do = false){
return route('storage_file', [$shopping_order->id, 'cms_download_file', $do]);
// return route('storage_file', [$shopping_order->id, 'cms_download_file', $do]);
}
public static function getDownloadPath(ShoppingOrder $shopping_order, $full = false){
$dir = self::getDir($shopping_order);

View file

@ -165,15 +165,24 @@ class Payment
$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'){
if($shopping_order_item->product->getActionName($do) === 'payment_for_account' && !$shopping_order_item->handle){
// $user->payment_order_id = $shopping_order_item->product->id; //34
$user->payment_account = $date;
$user->wizard = 100;
$user->save();
self::addUserPayCredits($user, $shopping_order_item->product->price, 1, 'payment_for_account', $shopping_order->id);
self::addUserPayCredits($user, $shopping_order_item->product->price, 1, 'payment_for_account', $shopping_order->id);
$shopping_order_item->handle = true;
$shopping_order_item->save();
$shopping_order->setUserHistoryValue(['status' => 9]);
}
if($shopping_order_item->product->getActionName($do) === 'charging_credits' && !$shopping_order_item->handle){
self::addUserPayCredits($user, ($shopping_order_item->product->price * $shopping_order_item->qty), 7, 'charging_credits_add', $shopping_order->id);
$shopping_order_item->handle = true;
$shopping_order_item->save();
$shopping_order->setUserHistoryValue(['status' => 9]);
}
/*if($shopping_order_item->product->getActionName($do) === 'payment_for_shop'){
$user->payment_order_id = $shopping_order_item->product->id; //35
$user->payment_shop = $date;
@ -199,7 +208,7 @@ class Payment
}
//if the order has action
if($shopping_order->shopping_user->is_from === 'user_order'){
if($shopping_order->shopping_user->is_from === 'user_order' && $shopping_order->shopping_order_margin){
//is margin -> set paid
$shopping_order->shopping_order_margin->paid = true;
$shopping_order->shopping_order_margin->save();
@ -228,23 +237,54 @@ class Payment
'price' => $promotion_admin_product->getPriceWith(false),
'price_net' => $promotion_admin_product->getPriceWith(true),
'tax_rate' => $promotion_admin_product->product->tax,
'status' => 0,
'pick_up' => $shopping_order->isPickUp()
]);
$promotion_user_product->open_items -= $PromotionUserOrder->qty;
$promotion_user_product->sell_items += $PromotionUserOrder->qty;
$promotion_user_product->used_budget_total += $PromotionUserOrder->price;
$promotion_user_product->save();
//TODO Guthaben abziehen
self::addUserPayCredits($promotion_user_product->promotion_user->user, ($PromotionUserOrder->price*-1), 5, 'promotion_order_deduction', $shopping_order->id);
//Guthaben abziehen wenn nicht abholung
if(!$shopping_order->isPickUp()){
self::addUserPayCredits($promotion_user_product->promotion_user->user, ($PromotionUserOrder->price*-1), 5, 'promotion_order_deduction', $shopping_order->id);
}
}
}
}
}
//remove or add form credit, is from Charging credits, handle is true (by paymentStatusPaidAction first action by paid)
public static function handelUserPayChargingCredits(ShoppingOrder $shopping_order, $action){
//only from cr <- credit Charging
if($shopping_order->shopping_user->is_for !== 'cr'){
return;
}
if($shopping_order->shopping_order_items && $shopping_order->auth_user_id){
foreach($shopping_order->shopping_order_items as $shopping_order_item){
if($shopping_order_item->product){
$user = User::findOrFail($shopping_order->auth_user_id);
//product action
if($shopping_order_item->product->action){
foreach ($shopping_order_item->product->action as $do){
if($shopping_order_item->product->getActionName($do) === 'charging_credits' && $shopping_order_item->handle){
if($action === 'remove'){
self::addUserPayCredits($user, ($shopping_order_item->product->price*-1), 8, 'charging_credits_remove', $shopping_order->id);
}
if($action === 'add'){
self::addUserPayCredits($user, $shopping_order_item->product->price, 7, 'charging_credits_add', $shopping_order->id);
}
}
}
}
}
}
}
}
//remove form credit, every sale fnc / vor / etc from CheckoutController
//when stone, put it back SalesController
//when done, put it back SalesController
public static function handelUserPayCredits(ShoppingOrder $shopping_order, $do){
//is payment credit, deduction or return
if(!$shopping_order->shopping_order_margin){
@ -261,8 +301,51 @@ class Payment
$credit = $shopping_order->shopping_order_margin->from_payment_credit;
self::addUserPayCredits($shopping_order->auth_user, $credit, 4, 'user_order_return', $shopping_order->id);
}
}
}
public static function handelUserPromotionOrder(ShoppingOrder $shopping_order){
//no user promotion
if($shopping_order->payment_for !== 7 || !$shopping_order->promotion_user){
return;
}
if($shopping_order->promotion_user->promotion_user_orders){
foreach($shopping_order->promotion_user->getPromotionUserOrders($shopping_order->id) as $promotion_user_order){
$promotion_user_order->setStatusShipped($shopping_order->getAPIShippedType());
if(!$promotion_user_order->pick_up){ // keine abholung handel credit
$last_UserPayCredit = UserPayCredit::where('shopping_order_id', $shopping_order->id)->whereIn('status', [5, 6])->orderBy('id', 'DESC')->first();
if($last_UserPayCredit && $promotion_user_order->status === 10 && $last_UserPayCredit->status === 5){
Payment::handelUserPayCreditsPromotion($promotion_user_order, 'return');
}
//Status Zahlung, voher gab es eine Storno, Guthaben abziehen wenn status 6 / return from order
if($last_UserPayCredit && $promotion_user_order->status === 0 && $last_UserPayCredit->status === 6){
Payment::handelUserPayCreditsPromotion($promotion_user_order, 'deduction');
}
}
}
}
}
//add or remove form credit,
//when done, put it back SalesController
public static function handelUserPayCreditsPromotion(PromotionUserOrder $promotion_user_order, $do){
//is promotion pick up, dont
if($promotion_user_order->pick_up){
return;
}
if($do === 'deduction'){
if($promotion_user_order->price > 0){
$credit = $promotion_user_order->price * -1;
self::addUserPayCredits($promotion_user_order->promotion_user->user, $credit, 5, 'promotion_order_deduction', $promotion_user_order->shopping_order->id);
}
}
if($do === 'return'){
if($promotion_user_order->price > 0){
$credit = $promotion_user_order->price;
self::addUserPayCredits($promotion_user_order->promotion_user->user, $credit, 6, 'promotion_order_return', $promotion_user_order->shopping_order->id);
}
}
}
public static function paymentStatusSendMail(ShoppingOrder $shopping_order, $shopping_payment, $data){
@ -284,6 +367,7 @@ class Payment
if(!$shopping_order->shopping_user->is_like && $shopping_order->shopping_user->member){
$bcc[] = $shopping_order->shopping_user->member->email;
}
Mail::to($billing_email)->bcc($bcc)->send(new MailCheckout($data['txaction'], $shopping_order, $shopping_payment, $data['send_link'], $data['mode']));
}
}

View file

@ -24,8 +24,16 @@ class PromotionCart
Yard::instance('shopping')->setShippingCountryWithPrice($id, 'shop');
}
public static function getLowestShippingPrice($shipping_for = 2)
public static function getCurrentShippingPrice($shipping_for = 2) //shipping_for === microsite
{
$shipping = Yard::instance('shopping')->shipping();
if($shipping > 0){
return $shipping;
}
$shipping = Yard::instance('shopping')->preCalcuShippingPrice();
if($shipping > 0){
return formatNumber($shipping);
}
if($ShippingCountry = ShippingCountry::all()->first()){
if($ShippingCountry->shipping){
if($ShippingPrices = $ShippingCountry->shipping->getShippingPricesFirstBy($shipping_for)){
@ -85,7 +93,6 @@ class PromotionCart
Yard::instance('shopping')->remove($cartItem->rowId);
}
}
Yard::instance('shopping')->reCalculate();
return $cartItem->qty;
}
@ -118,6 +125,8 @@ class PromotionCart
'product_id' => $product->id
]);
Yard::setTax($cartItem->rowId, 0);
Yard::instance('shopping')->reCalculate();
}
}
}

View file

@ -13,7 +13,7 @@ class Type
3 => 'Registrierung / Mitgliedschaft Vertriebspartner',
4 => 'Nur Mitgliedschaft Vertriebspartner',
//5 => 'Onboarding Vertriebspartner',
//6 => 'Onboarding Vertriebspartner + Vertriebspartner Shop',
6 => 'Guthaben aufladen',
7 => 'zur internen Berechnung',
];
@ -24,7 +24,7 @@ class Type
3 => 'Microsite',
4 => 'Registrierung Vertriebspartner',
5 => 'Mitgliedschaft Vertriebspartner',
//6 => 'Onboarding Berater',
6 => 'Guthaben aufladen',
10 => 'zur internen Berechnung',
];
@ -45,7 +45,7 @@ class Type
3 => 'Microsite',
4 => 'Registrierung Vertriebspartner',
5 => 'Mitgliedschaft Vertriebspartner',
//6 => 'Onboarding Berater',
6 => 'Guthaben aufladen',
10 => 'überall',
];

View file

@ -8,8 +8,6 @@ use Yard;
class Util
{
private static $postRoute = 'base.';
public static function getToken()

View file

@ -121,6 +121,11 @@ class Yard extends Cart
$this->putYardExtra('global_tax_rate', $this->global_tax_rate);
}
public function getGlobalTaxRate(){
$this->global_tax_rate;
}
public function setShippingOption($value){
$this->shipping_option = $value;
$this->putYardExtra('shipping_option', $this->shipping_option);
@ -199,6 +204,10 @@ class Yard extends Cart
/* * ***** */
public function calculateMargins(){
if($this->shipping_is_for === 'cr'){
return;
}
//get user monthy amount
$monthy_amount = UserMarign::getMontlyAmount($this->user);
@ -288,7 +297,6 @@ class Yard extends Cart
$margin->setCommission($this->yard_commission);
$margin->calculate();
$this->yard_margin = $margin;
$this->putYardExtra('yard_margin', $this->yard_margin);
@ -319,18 +327,17 @@ class Yard extends Cart
$this->payment_credit = $payment_credit;
$this->putYardExtra('user', $user);
$this->putYardExtra('payment_credit', $payment_credit);
}
public function getPaymentCredit(){
if($this->payment_credit && $this->user->payment_credit > 0){
return $this->user->payment_credit;
}
return 0;
return false;
}
private function calculateShippingPrice(){
//keine Verandkosten
if($this->shipping_option && $this->shipping_option === 'pick_up'){
$this->shipping_price = 0;
$this->shipping_tax_rate = 0;
@ -339,6 +346,15 @@ class Yard extends Cart
$this->putShippingPrices();
return;
}
//keine Verandkosten
if($this->shipping_is_for === 'cr' || $this->shipping_is_for === 'mp'){
$this->shipping_price = 0;
$this->shipping_tax_rate = 0;
$this->shipping_price_net = 0;
$this->shipping_tax = 0;
$this->putShippingPrices();
return;
}
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
if(!$shippingCountry){
@ -396,6 +412,42 @@ class Yard extends Cart
}
}
public function preCalcuShippingPrice(){
$shippingCountry = ShippingCountry::find($this->shipping_country_id);
if(!$shippingCountry){
return false;
}
$shipping = $shippingCountry->shipping;
$shipping_price_for = 1;
if($this->shipping_is_for === 'shop'){
$shipping_price_for = 2;
}
if($this->weight() == 0){
$shipping_price = $shipping->getShippingPricesBy($shipping_price_for)->first();
if(!$shipping_price){
$shipping_price = new \App\Models\ShippingPrice();
}
$shipping_price->price = 0;
}else{
//first by price
$shipping_price = $this->shippingPriceBySubTotal($shipping->getShippingPricesBy($shipping_price_for), $this->subtotal(2, '.', ''));
//sec by weight
if(!$shipping_price){
$shipping_price = $this->shippingPriceByWeight($shipping->getShippingPricesBy($shipping_price_for), $this->weight());
}
//default
if(!$shipping_price){
$shipping_price = $shipping->getShippingPricesBy($shipping_price_for)->first();
}
}
if($shipping_price){
return $shipping_price->price;
}
return false;
}
private function putShippingPrices(){
$this->putYardExtra('num_comp', $this->num_comp);
$this->putYardExtra('shipping_price', $this->shipping_price);

View file

@ -479,7 +479,7 @@ class User extends Authenticatable
*/
public function sendPasswordResetNotification($token)
{
Mail::to($this->email)->send(new MailResetPassword($token, $this));
Mail::to($this->email)->bcc(config('app.info_mail'))->send(new MailResetPassword($token, $this));
// $this->notify(new ResetPasswordNotification($token));
}
}