parent
582ca8299d
commit
263cf93a1e
41 changed files with 812 additions and 288 deletions
|
|
@ -11,6 +11,7 @@ use App\Models\ShoppingOrder;
|
|||
use App\Services\MyPDFMerger;
|
||||
use App\Services\UserService;
|
||||
use App\Models\UserSalesVolume;
|
||||
use App\Services\BusinessPlan\SalesPointsVolume;
|
||||
|
||||
class InvoiceRepository extends BaseRepository {
|
||||
|
||||
|
|
@ -146,63 +147,12 @@ class InvoiceRepository extends BaseRepository {
|
|||
public function userSalesVolume()
|
||||
{
|
||||
|
||||
/*
|
||||
status
|
||||
1 => 'hinzugefügt aus Bestellung',
|
||||
2 => 'hinzugefügt aus Shop',
|
||||
3 => 'hinzugefügt aus Shop / pending',
|
||||
|
||||
*/
|
||||
$status = UserSalesVolume::getStatusByOrder($this->model);
|
||||
$user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id;
|
||||
//akuteller tag / Monat.
|
||||
$month = date('m');
|
||||
$year = date('Y');
|
||||
$date = date('d.m.Y');
|
||||
|
||||
if($status === 3){ //shop bestellung User pending
|
||||
$user_id = $this->model->auth_user_id ? $this->model->auth_user_id : $this->model->member_id;
|
||||
$month_points = 0;
|
||||
$month_total_net = 0;
|
||||
$month_shop_points = 0;
|
||||
$month_shop_total_net = 0;
|
||||
}else{
|
||||
$month_points = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 1)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
$month_shop_points = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('points');
|
||||
$month_shop_total_net = UserSalesVolume::where('user_id', $user_id)->where('status', 2)->where('month', $month)->where('year', $year)->sum('total_net');
|
||||
}
|
||||
switch ($status) {
|
||||
case 1: //Bestellung
|
||||
$month_points += $this->model->points;
|
||||
$month_total_net += $this->model->subtotal;
|
||||
break;
|
||||
case 2: //Shop
|
||||
$month_shop_points += $this->model->points;
|
||||
$month_shop_total_net += $this->model->subtotal;
|
||||
break;
|
||||
}
|
||||
|
||||
return UserSalesVolume::create([
|
||||
'user_id' => $user_id,
|
||||
'shopping_order_id' => $this->model->id,
|
||||
'month' => $month,
|
||||
'year' => $year,
|
||||
'date' => $date,
|
||||
'points' => $this->model->points,
|
||||
'month_points' => $month_points,
|
||||
'month_shop_points' => $month_shop_points,
|
||||
'total_net' => $this->model->subtotal,
|
||||
'month_total_net' => $month_total_net,
|
||||
'month_shop_total_net' => $month_shop_total_net,
|
||||
'message' => '',
|
||||
'status' => $status,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
public function createAndSalesVolume($request = [])
|
||||
{
|
||||
$this->user_sales_volume = $this->userSalesVolume();
|
||||
$this->user_sales_volume = SalesPointsVolume::addSalesPointsVolumeUser($this->model);
|
||||
$user_invoice = $this->create($request);
|
||||
$this->user_sales_volume->user_invoice_id = $user_invoice->id;
|
||||
$this->user_sales_volume->save();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue