Guthaben aufladen, löschen, Ansichten
This commit is contained in:
parent
6ac9fcc4d2
commit
3754f1c571
27 changed files with 603 additions and 89 deletions
|
|
@ -64,7 +64,7 @@ class MembershipController extends Controller
|
|||
|
||||
$data = Request::all();
|
||||
|
||||
|
||||
|
||||
|
||||
//#### remove_abo
|
||||
/*if($action === "remove_abo"){
|
||||
|
|
@ -83,17 +83,17 @@ class MembershipController extends Controller
|
|||
}*/
|
||||
//#### payment order
|
||||
//#### shop upgrade
|
||||
/*if($action === "upgrade_order" || $action === "payment_order"){
|
||||
if($action === "upgrade_order" || $action === "payment_order"){
|
||||
if(Request::get('switchers-package-wizard')){
|
||||
$user = User::find(Auth::user()->id);
|
||||
Yard::instance('shopping')->destroy();
|
||||
$product = Product::find(Request::get('switchers-package-wizard'));
|
||||
$showAboOptions = false;
|
||||
if(Request::get('abo_options')){
|
||||
// $showAboOptions = false;
|
||||
/* if(Request::get('abo_options')){
|
||||
$showAboOptions = true;
|
||||
$user->abo_options = true;
|
||||
$user->save();
|
||||
}
|
||||
}*/
|
||||
if($product && $product->active && $product->show_at >= 3){
|
||||
$image = "";
|
||||
if($product->images->count()){
|
||||
|
|
@ -102,15 +102,17 @@ class MembershipController extends Controller
|
|||
$qty = Request::get('qty') ? Request::get('qty') : 1;
|
||||
Yard::instance('shopping')->add($product->id, $product->getLang('name'), $qty, $product->price, ['image' => $image, 'slug' => $product->slug, 'weight' => $product->weight]);
|
||||
|
||||
/*
|
||||
do {
|
||||
$identifier = Util::getToken();
|
||||
} while( ShoppingInstance::where('identifier', $identifier)->count() );
|
||||
|
||||
*/
|
||||
$identifier = Util::getToken();
|
||||
$data = [];
|
||||
$data['is_from'] = 'membership';
|
||||
$data['is_for'] = 'me';
|
||||
|
||||
ShoppingInstance::create([
|
||||
/* ShoppingInstance::create([
|
||||
'identifier' => $identifier,
|
||||
'user_shop_id' => 1, //is first faker shop for nuy intern
|
||||
'auth_user_id' => Auth::user()->id,
|
||||
|
|
@ -120,16 +122,21 @@ class MembershipController extends Controller
|
|||
'shopping_data' => $data,
|
||||
'back' => url()->previous(),
|
||||
|
||||
]);
|
||||
Yard::instance('shopping')->store($identifier);
|
||||
]);*/
|
||||
Yard::instance('shopping')->putYardExtra('shopping_data', $data);
|
||||
|
||||
//Yard::instance('shopping')->store($identifier);
|
||||
//add to DB
|
||||
$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier, 'abo_options'=>$showAboOptions]);
|
||||
UserHistory::create(['user_id' => $user->id, 'action'=>$action, 'status'=>1, 'product_id'=>$product->id, 'identifier'=>$identifier]);
|
||||
|
||||
//$path = route('checkout.checkout_card', ['identifier'=>$identifier]);
|
||||
//$path = str_replace('http', 'https', $path);
|
||||
return redirect()->secure($path);
|
||||
// return redirect()->secure($path);
|
||||
return redirect(route('user_checkout', [$identifier]));
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/*
|
||||
if($action === "change_order"){
|
||||
|
|
|
|||
|
|
@ -49,15 +49,12 @@ class ModalController extends Controller
|
|||
$product = Product::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.show_product", compact('product', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-order-my-delivery-show'){
|
||||
$user = \Auth::user();
|
||||
$ret = view("admin.modal.show_user_customers", compact('user', 'data'))->render();
|
||||
}
|
||||
|
||||
if($data['action'] === 'user-order-my-delivery-add'){
|
||||
$user = \Auth::user();
|
||||
|
||||
/* $product = Product::find($data['id']); //current user form order
|
||||
$ret = view("admin.modal.show_product", compact('product', 'data'))->render(); */
|
||||
}
|
||||
|
|
@ -67,17 +64,22 @@ class ModalController extends Controller
|
|||
$user = User::find($data['id']);
|
||||
$ret = view("admin.modal.user_level_margin", compact('user', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'show-user-pay-credits'){
|
||||
$user = User::find($data['id']);
|
||||
$ret = view("admin.modal.user_pay_credits", compact('user', 'data'))->render();
|
||||
}
|
||||
if($data['action'] === 'add-user-pay-credit'){
|
||||
$value = [];
|
||||
$ret = view("admin.modal.add_pay_credit", compact('value', 'data'))->render();
|
||||
}
|
||||
|
||||
|
||||
if($data['action'] === 'homeparty-add-product') {
|
||||
/*if($data['action'] === 'homeparty-add-product') {
|
||||
$homeparty = Homeparty::find($data['id']);
|
||||
$homeparty_user = HomepartyUser::find($data['user_id']);
|
||||
$data['homeparty'] = $homeparty;
|
||||
$ret = view("user.homeparty.modal_show_products", compact( 'data', 'homeparty', 'homeparty_user'))->render();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ class PayController extends Controller
|
|||
'userid' => 0,
|
||||
'status' => $this->shopping_payment->clearingtype,
|
||||
'transmitted_data' => $request,
|
||||
'txaction' => 'open',
|
||||
'txaction' => 'prev',
|
||||
'mode' => $this->shopping_payment->mode,
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Carbon;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Services\Invoice;
|
||||
use Validator;
|
||||
use App\Services\Util;
|
||||
use App\Models\UserPayCredit;
|
||||
use App\Services\Payment;
|
||||
use App\Models\ShoppingOrder;
|
||||
|
||||
|
||||
class PaymentPayCreditController extends Controller
|
||||
{
|
||||
|
|
@ -37,15 +38,66 @@ class PaymentPayCreditController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
public function store(){
|
||||
$data = Request::all();
|
||||
|
||||
if(isset($data['action']) && $data['action'] === 'add-user-pay-credit'){
|
||||
|
||||
$validator = Validator::make(Request::all(), []);
|
||||
$add_credit_error = false;
|
||||
if(!isset($data['member_id']) || !$user = User::find($data['member_id'])){
|
||||
$add_credit_error = 'Vertriebspartner nicht gefunden';
|
||||
}
|
||||
if(!isset($data['credit'])){
|
||||
$add_credit_error = 'Bitte Betrag eingeben';
|
||||
}
|
||||
if(!isset($data['message'])){
|
||||
$add_credit_error = 'Bitte Mitteilung eingeben';
|
||||
}
|
||||
if($add_credit_error){
|
||||
$this->setActiveFilter();
|
||||
$data = [
|
||||
'filter_user_status' => $this->filter_user_status,
|
||||
'add_credit_error' => $add_credit_error,
|
||||
];
|
||||
return view('admin.payment.pay_credit.index', $data);
|
||||
}
|
||||
|
||||
$credit = Util::reFormatNumber($data['credit']);
|
||||
$credit = number_format($credit, 2, '.', '');
|
||||
|
||||
Payment::addUserPayCredits($user, $credit, 3, $data['message']);
|
||||
\Session()->flash('alert-success', "Guthaben aufgeladen");
|
||||
}
|
||||
|
||||
return redirect(route('admin_payments_paycredit'));
|
||||
}
|
||||
|
||||
|
||||
public function delete($id){
|
||||
|
||||
$UserPayCredit = UserPayCredit::findOrFail($id);
|
||||
if($UserPayCredit->status === 3 && $deleteTime = $UserPayCredit->deleteTime()){
|
||||
$user = $UserPayCredit->user;
|
||||
$credit = $UserPayCredit->credit;
|
||||
$user->payment_credit = $user->payment_credit - $credit;
|
||||
$user->save();
|
||||
$UserPayCredit->delete();
|
||||
\Session()->flash('alert-success', "Guthaben ist gelöscht");
|
||||
}else{
|
||||
\Session()->flash('alert-error', "Guthaben kann nicht gelöscht werden");
|
||||
}
|
||||
|
||||
return redirect(route('admin_payments_paycredit'));
|
||||
}
|
||||
|
||||
public function datatable(){
|
||||
|
||||
$this->setActiveFilter();
|
||||
|
||||
|
||||
$query = User::with('account')->select('users.*')->where('users.deleted_at', '=', null)
|
||||
->where('active', true);
|
||||
|
||||
|
||||
//->orderBy('created_at', 'DESC');
|
||||
|
||||
return \DataTables::eloquent($query)
|
||||
|
|
@ -71,10 +123,10 @@ class PaymentPayCreditController extends Controller
|
|||
return '<span class="badge badge-pill badge-danger"><i class="fa fa-times"></i></span></a>';
|
||||
})
|
||||
->addColumn('action', function (User $user) {
|
||||
$ret = '<a href="#" target="_blank" class="btn btn-warning btn-xs"><i class="fa fa-eye"></i></a>';
|
||||
return $ret;
|
||||
return '<button class="btn btn-warning btn-sm icon-btn md-btn-flat" title="details" data-modal="modal-xl"
|
||||
data-toggle="modal" data-target="#modals-load-content" data-id="'.$user->id.'" data-route="'.route('modal_load').'"
|
||||
data-action="show-user-pay-credits" data-view="customer"><i class="ion ion-md-eye"></i></button>';
|
||||
})
|
||||
|
||||
->orderColumn('id', 'id $1')
|
||||
->orderColumn('txaction', 'txaction $1')
|
||||
->orderColumn('payment_credit', 'payment_credit $1')
|
||||
|
|
|
|||
|
|
@ -319,13 +319,13 @@ class SalesController extends Controller
|
|||
]);
|
||||
|
||||
$shopping_order->txaction = $data['txaction'];
|
||||
$shopping_order->paid = true;
|
||||
$shopping_order->paid = $payt->txaction === 'paid' ? true : false;
|
||||
$shopping_order->save();
|
||||
$shopping_payment->txaction = $data['txaction'];
|
||||
$shopping_payment->save();
|
||||
|
||||
if($payt->status === 'vor' && $payt->txaction === 'paid'){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
}
|
||||
$edata = [
|
||||
'mode' => $payt->mode,
|
||||
|
|
|
|||
|
|
@ -3,20 +3,23 @@
|
|||
namespace App\Http\Controllers\SyS;
|
||||
|
||||
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\UserShop;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Services\Shop;
|
||||
use App\User;
|
||||
use Auth;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Request;
|
||||
use App\User;
|
||||
use App\Mail\MailInfo;
|
||||
use App\Services\Shop;
|
||||
use App\Models\UserShop;
|
||||
use App\Services\Payment;
|
||||
use App\Models\ShoppingUser;
|
||||
use App\Models\PaymentMethod;
|
||||
use App\Models\ShoppingOrder;
|
||||
use App\Models\UserPayCredit;
|
||||
use App\Services\CustomerPriority;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Http\Controllers\Api\KasController;
|
||||
use App\Repositories\ContractPDFRepository;
|
||||
use App\Http\Controllers\Api\KasSLLController;
|
||||
|
||||
|
||||
class AdminToolsController extends Controller
|
||||
|
|
@ -29,15 +32,104 @@ class AdminToolsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function index()
|
||||
public function index($action)
|
||||
{
|
||||
dd('index');
|
||||
|
||||
switch ($action) {
|
||||
case 'pay_credits':
|
||||
# code...
|
||||
$value = $this->makeUserPayCredits();
|
||||
$data = [
|
||||
'values' => $value,
|
||||
'text' => '',
|
||||
];
|
||||
return view('sys.admin.index', $data);
|
||||
break;
|
||||
case 'value':
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function customers()
|
||||
public function store($action)
|
||||
{
|
||||
dd($action);
|
||||
$data = [];
|
||||
switch ($action) {
|
||||
case 'pay_credits':
|
||||
# code...
|
||||
return view('sys.admin.index', $data);
|
||||
|
||||
break;
|
||||
case 'value':
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function makeUserPayCredits()
|
||||
{
|
||||
//is the first of
|
||||
$shopping_orders = ShoppingOrder::whereHas('shopping_order_items', function($q) {
|
||||
$q->where('product_id', 1);
|
||||
})->where('paid', 1)->where('total_shipping', '>', 0)->get();
|
||||
|
||||
|
||||
foreach ($shopping_orders as $shopping_order) {
|
||||
$payment_credit = $shopping_order->total_shipping;
|
||||
$c = UserPayCredit::where('shopping_order_id', $shopping_order->id)->first();
|
||||
if(!$c){
|
||||
$uP = UserPayCredit::create([
|
||||
'user_id' => $shopping_order->auth_user->id,
|
||||
'credit' => $payment_credit,
|
||||
'old_credit_total' => 0,
|
||||
'new_credit_total' => $payment_credit,
|
||||
'message' => 'payment_for_account',
|
||||
'status' => 1,
|
||||
'shopping_order_id' => $shopping_order->id
|
||||
]);
|
||||
|
||||
$uP->created_at = $shopping_order->created_at;
|
||||
$uP->updated_at = $shopping_order->created_at;
|
||||
$uP->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$shopping_orders = ShoppingOrder::where('payment_credit', '>', 0)->where('paid', 1)->get();
|
||||
foreach ($shopping_orders as $shopping_order) {
|
||||
$payment_credit = $shopping_order->payment_credit;
|
||||
$c = UserPayCredit::where('shopping_order_id', $shopping_order->id)->first();
|
||||
if(!$c){
|
||||
//find last
|
||||
$UserPayCredit = UserPayCredit::where('user_id', $shopping_order->auth_user->id)->orderBy('created_at', 'desc')->first();
|
||||
$old_credit = 0;
|
||||
$credit = $shopping_order->payment_credit*-1;
|
||||
if($UserPayCredit){
|
||||
$old_credit = $UserPayCredit->new_credit_total;
|
||||
}
|
||||
$uP = UserPayCredit::create([
|
||||
'user_id' => $shopping_order->auth_user->id,
|
||||
'credit' => $credit,
|
||||
'old_credit_total' => $old_credit,
|
||||
'new_credit_total' => $old_credit + $credit,
|
||||
'message' => 'user_order_deduction',
|
||||
'status' => 2,
|
||||
'shopping_order_id' => $shopping_order->id
|
||||
]);
|
||||
$uP->created_at = $shopping_order->created_at;
|
||||
$uP->updated_at = $shopping_order->created_at;
|
||||
$uP->save();
|
||||
|
||||
}
|
||||
}
|
||||
return $shopping_orders;
|
||||
}
|
||||
|
||||
/*public function customers()
|
||||
{
|
||||
|
||||
$shopping_users = ShoppingUser::where('member_id', '=', NULL)->where('auth_user_id', '=', NULL)->get();
|
||||
|
|
@ -90,9 +182,6 @@ class AdminToolsController extends Controller
|
|||
return back();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function cronjobs()
|
||||
{
|
||||
//$user_shops = UserShop::all();
|
||||
|
|
@ -199,6 +288,7 @@ class AdminToolsController extends Controller
|
|||
return back();
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ class CheckoutController extends Controller
|
|||
Yard::instance('shopping')->destroy();
|
||||
$this->destroy();
|
||||
|
||||
if($payt->status === 'fnc' || $payt->status === 'vor'){
|
||||
if(($payt->status === 'fnc' || $payt->status === 'vor') && $payt->txaction === 'prev'){
|
||||
$this->directPaymentStatus($payt, $identifier);
|
||||
}
|
||||
|
||||
|
|
@ -558,20 +558,17 @@ class CheckoutController extends Controller
|
|||
$shopping_payment->txaction = 'open';
|
||||
$shopping_order->txaction = 'open';
|
||||
|
||||
|
||||
}
|
||||
if($payt->status === 'fnc'){
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, false);
|
||||
$send_link = Payment::paymentStatusPaidAction($shopping_order, true);
|
||||
$shopping_payment->txaction = 'open';
|
||||
$shopping_order->txaction = 'open';
|
||||
|
||||
|
||||
}
|
||||
$shopping_payment->save();
|
||||
}
|
||||
|
||||
//$payt->request = "approved";
|
||||
//$payt->save();
|
||||
$payt->txaction = "open";
|
||||
$payt->save();
|
||||
$data = [
|
||||
'mode' => $payt->transmitted_data['mode'],
|
||||
'txaction' => $payt->txaction,
|
||||
|
|
|
|||
|
|
@ -374,8 +374,6 @@ class OrderController extends Controller
|
|||
data-toggle="modal" data-target="#modals-load-content" data-id="'.Auth::user()->id.'" data-route="'.route('modal_load').'"
|
||||
data-action="user-order-show-user-level-margin" data-view="customer"><i class="ion ion-md-eye"></i></button>';
|
||||
})
|
||||
|
||||
|
||||
->addColumn('action', function (Product $product) {
|
||||
return '<button class="btn btn-default btn-sm icon-btn md-btn-flat product-tooltip" title="details" data-modal="modal-lg"
|
||||
data-toggle="modal" data-target="#modals-load-content" data-id="'.$product->id.'" data-route="'.route('modal_load').'"
|
||||
|
|
|
|||
62
app/Http/Controllers/User/PaymentController.php
Normal file
62
app/Http/Controllers/User/PaymentController.php
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
|
||||
namespace App\Http\Controllers\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
use Request;
|
||||
use Carbon;
|
||||
use App\Models\ShoppingOrder;
|
||||
|
||||
|
||||
class PaymentController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function paycredit()
|
||||
{
|
||||
$data = [
|
||||
'user' => \Auth::user()
|
||||
];
|
||||
return view('user.payment.paycredit', $data);
|
||||
}
|
||||
|
||||
/*public function index()
|
||||
{
|
||||
$start = 2021;
|
||||
$end = date('Y');
|
||||
$years = range($start, $end);
|
||||
|
||||
if(Request::get('filter_sales_year')){
|
||||
$active_year = Request::get('filter_sales_year');
|
||||
}else{
|
||||
$active_year = $end;
|
||||
}
|
||||
|
||||
$date1 = Carbon::parse('01.01.'.$active_year." 00:00:00")->format('Y-m-d H:i:s');
|
||||
$date2 = Carbon::parse('31.12.'.$active_year." 23:59:59")->toDateString();
|
||||
|
||||
|
||||
$values = ShoppingOrder::where('shopping_orders.auth_user_id', '!=', NULL) //::with('shopping_user', )->select('shopping_orders.*')
|
||||
->where('mode', '=', 'live')
|
||||
->where('paid', '=', 1)
|
||||
->whereHas('shopping_order_items', function($q) {
|
||||
|
||||
$q->where('product_id', 34)->OrWhere('product_id', 35)->OrWhere('product_id', 36)->OrWhere('product_id', 67)->OrWhere('product_id', 69);
|
||||
})
|
||||
->whereBetween('created_at', [$date1, $date2])
|
||||
->get();
|
||||
|
||||
$data = [
|
||||
'years' => $years,
|
||||
'active_year' => $active_year,
|
||||
'values' => $values,
|
||||
];
|
||||
return view('user.revenue.index', $data);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
@ -63,6 +63,15 @@ class UserPayCredit extends Model
|
|||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
return $this->belongsTo('App\User','user_id');
|
||||
}
|
||||
|
||||
public function deleteTime(){
|
||||
$time = '+30 min';
|
||||
if(Carbon::parse($this->created_at)->modify($time)->gt(Carbon::now())){
|
||||
return Carbon::now()->diffInMinutes(Carbon::parse($this->created_at)->modify($time));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*getFormattedPriceFrom */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ class HTMLHelper
|
|||
if($value->account){
|
||||
$to = $value->account->first_name." ".$value->account->last_name." | ";
|
||||
}
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.$value->email.' #'.$value->number.'</option>\n';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.$value->email.' #'.$value->account->m_account.'</option>\n';
|
||||
|
||||
}
|
||||
return $ret;
|
||||
|
|
@ -386,10 +386,9 @@ class HTMLHelper
|
|||
$ret .= '<option value="">'.__('please select').'</option>\n';
|
||||
}
|
||||
foreach ($values as $value){
|
||||
dump($value);
|
||||
$attr = ($value->id == $id) ? 'selected="selected"' : '';
|
||||
$to = $value->billing_firstname." ".$value->billing_lastname." | ".$value->billing_email;
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.' #'.$value->number.'</option>\n';
|
||||
$ret .= '<option value="'.$value->id.'" '.$attr.'>'.$to.' #'.$value->account->m_account.'</option>\n';
|
||||
|
||||
}
|
||||
return $ret;
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ class Payment
|
|||
|
||||
public static function addUserPayCredits(User $user, $credit, $status, $message, $shopping_order_id = null){
|
||||
|
||||
$new_credit_total = $user->payment_credit;
|
||||
UserPayCredit::create([
|
||||
'user_id' => $user->id,
|
||||
'credit' => $credit,
|
||||
|
|
@ -108,6 +107,7 @@ class Payment
|
|||
$user->save();
|
||||
|
||||
}
|
||||
|
||||
public static function paymentStatusPaidAction(ShoppingOrder $shopping_order, $paid){
|
||||
$send_link = false;
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ class Payment
|
|||
$user->payment_account = $date;
|
||||
$user->wizard = 100;
|
||||
$user->save();
|
||||
self::addUserPayCredits($user, $shopping_order_item->product->price, 1, 'payment_for_account');
|
||||
self::addUserPayCredits($user, $shopping_order_item->product->price, 1, 'payment_for_account', $shopping_order->id);
|
||||
$shopping_order->setUserHistoryValue(['status' => 9]);
|
||||
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ class Payment
|
|||
//is payment credit, reduce
|
||||
if($shopping_order->shopping_order_margin->from_payment_credit > 0){
|
||||
$credit = $shopping_order->shopping_order_margin->from_payment_credit * -1;
|
||||
self::addUserPayCredits($shopping_order->auth_user, $credit, 2, 'user_order_deduction');
|
||||
self::addUserPayCredits($shopping_order->auth_user, $credit, 2, 'user_order_deduction', $shopping_order->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class Util
|
|||
}
|
||||
|
||||
public static function _format_number($value){
|
||||
return preg_replace("/[^0-9,]/", "", $value);
|
||||
return preg_replace("/[^0-9,-]/", "", $value);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,6 +167,12 @@ class User extends Authenticatable
|
|||
return $this->hasMany('App\Models\UserUpdateEmail', 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function user_pay_credits()
|
||||
{
|
||||
return $this->hasMany('App\Models\UserPayCredit', 'user_id', 'id')->orderBy('created_at', 'DESC');
|
||||
}
|
||||
|
||||
|
||||
public function getMUserSponsor(){
|
||||
if($this->user_sponsor && $this->user_sponsor->account){
|
||||
return $this->user_sponsor->account->first_name." ".$this->user_sponsor->account->last_name." | ".$this->user_sponsor->email;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,13 @@ if (! function_exists('get_active_badge')) {
|
|||
}
|
||||
}
|
||||
|
||||
if (! function_exists('formatDate')) {
|
||||
function formatDate($date)
|
||||
{
|
||||
return Carbon::parse($date)->format(\Util::formatDateDB());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (! function_exists('formatNumber')) {
|
||||
function formatNumber($number, $dec=2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue