update 20.10.2025
This commit is contained in:
parent
8c11130b5d
commit
a939cd51ef
616 changed files with 84821 additions and 4121 deletions
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace App\Cron;
|
||||
|
||||
use App\User;
|
||||
use stdClass;
|
||||
use App\Models\UserBusinessStructure;
|
||||
use App\Services\BusinessPlan\TreeCalcBot;
|
||||
use App\Services\BusinessPlan\TreeCalcBotOptimized;
|
||||
|
||||
class BusinessUsersStore
|
||||
{
|
||||
|
|
@ -14,7 +15,7 @@ class BusinessUsersStore
|
|||
private $user_business_structure;
|
||||
private $users_structure = [];
|
||||
|
||||
|
||||
|
||||
public function __construct($month, $year)
|
||||
{
|
||||
$this->month = $month;
|
||||
|
|
@ -22,16 +23,17 @@ class BusinessUsersStore
|
|||
}
|
||||
|
||||
|
||||
public function getStoreUserBusinessStructure(){
|
||||
public function getStoreUserBusinessStructure()
|
||||
{
|
||||
return UserBusinessStructure::where('year', $this->year)->where('month', $this->month)->first();
|
||||
}
|
||||
|
||||
public function storeUserBusinessStructure()
|
||||
{
|
||||
if($this->user_business_structure = $this->getStoreUserBusinessStructure()){
|
||||
if ($this->user_business_structure = $this->getStoreUserBusinessStructure()) {
|
||||
return $this->user_business_structure;
|
||||
}
|
||||
$treeCalcBot = new TreeCalcBot($this->month, $this->year, 'admin');
|
||||
$treeCalcBot = new TreeCalcBotOptimized($this->month, $this->year, 'admin');
|
||||
//only load, when no structur is save
|
||||
$treeCalcBot->initStructureAdmin(false);
|
||||
$this->storeStructure($treeCalcBot);
|
||||
|
|
@ -39,19 +41,19 @@ class BusinessUsersStore
|
|||
|
||||
public function storeBusinessUsersDetail()
|
||||
{
|
||||
if(!$this->user_business_structure){
|
||||
if (!$this->user_business_structure) {
|
||||
$this->user_business_structure = $this->getStoreUserBusinessStructure();
|
||||
if(!$this->user_business_structure){
|
||||
if (!$this->user_business_structure) {
|
||||
abort(403, 'not found UserBusinessStructure');
|
||||
}
|
||||
}
|
||||
foreach($this->user_business_structure->users as $user_id=>$completed){
|
||||
if($completed === 0){
|
||||
$user = User::find($user_id);
|
||||
if($user){
|
||||
$TreeCalcBot = new TreeCalcBot($this->month, $this->year, 'admin');
|
||||
foreach ($this->user_business_structure->users as $user_id => $completed) {
|
||||
if ($completed === 0) {
|
||||
$user = User::find($user_id);
|
||||
if ($user) {
|
||||
$TreeCalcBot = new TreeCalcBotOptimized($this->month, $this->year, 'admin');
|
||||
$TreeCalcBot->initBusinesslUserDetail($user);
|
||||
if(!$TreeCalcBot->business_user){
|
||||
if (!$TreeCalcBot->business_user) {
|
||||
abort(403, 'not found TreeCalcBot->business_user');
|
||||
}
|
||||
$this->storeBusinesslUser($TreeCalcBot->business_user);
|
||||
|
|
@ -60,13 +62,13 @@ class BusinessUsersStore
|
|||
$this->user_business_structure->users = $users;
|
||||
$this->user_business_structure->save();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function storeBusinesslUser($business_user){
|
||||
public function storeBusinesslUser($business_user)
|
||||
{
|
||||
$b_user = $business_user->getBUser();
|
||||
$b_user->user_items = $this->storeUserItems($business_user->businessUserItems, 1);
|
||||
$b_user->b_structure_id = $this->user_business_structure->id;
|
||||
|
|
@ -74,12 +76,13 @@ class BusinessUsersStore
|
|||
}
|
||||
|
||||
|
||||
public function storeBusinessCompleted(){
|
||||
if(!$this->user_business_structure){
|
||||
public function storeBusinessCompleted()
|
||||
{
|
||||
if (!$this->user_business_structure) {
|
||||
$this->user_business_structure = $this->getStoreUserBusinessStructure();
|
||||
}
|
||||
foreach($this->user_business_structure->users as $user_id=>$completed){
|
||||
if($completed === 0){
|
||||
foreach ($this->user_business_structure->users as $user_id => $completed) {
|
||||
if ($completed === 0) {
|
||||
return false;
|
||||
}
|
||||
$this->user_business_structure->completed = 1;
|
||||
|
|
@ -87,21 +90,22 @@ class BusinessUsersStore
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private function storeUserItems($userItems, $line){
|
||||
|
||||
private function storeUserItems($userItems, $line)
|
||||
{
|
||||
$ret = [];
|
||||
foreach($userItems as $userItem){
|
||||
foreach ($userItems as $userItem) {
|
||||
$temp = null;
|
||||
if(count($userItem->businessUserItems) > 0){
|
||||
$temp = $this->storeUserItems($userItem->businessUserItems, $line+1);
|
||||
if (count($userItem->businessUserItems) > 0) {
|
||||
$temp = $this->storeUserItems($userItem->businessUserItems, $line + 1);
|
||||
}
|
||||
$obj = new stdClass();
|
||||
$obj->user_id = $userItem->user_id;
|
||||
$obj->line = $line;
|
||||
$obj->points = $userItem->sales_volume_points_sum;
|
||||
$obj->parents = $temp;
|
||||
$ret[] = $obj;
|
||||
$ret[] = $obj;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
|
@ -114,13 +118,13 @@ class BusinessUsersStore
|
|||
}*/
|
||||
|
||||
$structure = [];
|
||||
foreach($treeCalcBot->business_users as $business_user){
|
||||
foreach ($treeCalcBot->business_users as $business_user) {
|
||||
$structure[] = $this->storeStructureItem($business_user, 0);
|
||||
}
|
||||
|
||||
$parentless = [];
|
||||
if($treeCalcBot->parentless){
|
||||
foreach($treeCalcBot->parentless as $pless){
|
||||
if ($treeCalcBot->parentless) {
|
||||
foreach ($treeCalcBot->parentless as $pless) {
|
||||
$parentless[] = $this->storeStructureItem($pless, 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -137,14 +141,15 @@ class BusinessUsersStore
|
|||
return $this->user_business_structure;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function storeStructureItem($item, $deep){
|
||||
|
||||
private function storeStructureItem($item, $deep)
|
||||
{
|
||||
$temp = null;
|
||||
if($item->businessUserItems){
|
||||
foreach($item->businessUserItems as $parent){
|
||||
$temp[] = $this->storeStructureItem($parent, $deep+1);
|
||||
}
|
||||
if ($item->businessUserItems) {
|
||||
foreach ($item->businessUserItems as $parent) {
|
||||
$temp[] = $this->storeStructureItem($parent, $deep + 1);
|
||||
}
|
||||
}
|
||||
$this->users_structure[$item->user_id] = 0;
|
||||
$obj = new stdClass();
|
||||
|
|
@ -156,7 +161,4 @@ class BusinessUsersStore
|
|||
$obj->parents = $temp;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue