Guthaben aufladen, löschen, Ansichten
This commit is contained in:
parent
6ac9fcc4d2
commit
3754f1c571
27 changed files with 603 additions and 89 deletions
|
|
@ -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();
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue