zariran and delete cuseting

This commit is contained in:
Your Name 2025-09-18 14:15:34 +00:00
parent 5f77a787b7
commit 75e4485360
8 changed files with 58 additions and 32 deletions

View File

@ -116,7 +116,7 @@ class Controller extends BaseController
}
public static function trigerUrl()
{
$trigerUrl = env('wssLink','')??'https://ws.liman.gold';
$trigerUrl = env('wssLink','')??'https://zariran.org';
return $trigerUrl;
}

View File

@ -18,7 +18,6 @@ class ProductController extends Controller
public function list_product($CU_adm = null)
{
CustomersSetting::firstOrCreate(['customer_id' => null, 'group' => null, 'agent_id' => null, 'profit_sell' => 0, 'profit_buy' => 0, 'credit_sell' => 10, 'credit_buy' => 10,]);
$this->auto_close_open();
@ -60,38 +59,40 @@ class ProductController extends Controller
}
return $setting;
}
do {
$settings = (isset($agent))? $agent->customersSetting()->get()
:CustomersSetting::whereNull('customer_id')->whereNull('group')->whereNull('agent_id');
foreach ($list_product as $key => $product) {
if ($setting = $settings->where('customer_id', $customer->id)->where('product_id', $product->id)->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->where('customer_id', $customer->id)->whereNull('product_id')->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->where('group', $customer->group)->where('product_id', $product->id)->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->where('group', $customer->group)->whereNull('product_id')->first()) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->whereNull('group')->whereNull('customer_id')->where('product_id', $product->id)->first()) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->whereNull('group')->whereNull('product_id')->whereNull('customer_id')->first()) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = CustomersSetting::whereNull('customer_id')->whereNull('group')->whereNull('agent_id')->where('product_id', $product->id)->first() ) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = CustomersSetting::whereNull('customer_id')->whereNull('group')->whereNull('agent_id')->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
}else {
unset($prises[$product->id]);
unset($list_product[$key]);
}
$customerSettings[$agent->id??0][$product->id] = $setting;
$customerSettings['all_levels'][$product->id][] = $setting;
if ($customer and $customer->type != 3){
do {
$settings = (isset($agent))? $agent->customersSetting()->get()
:CustomersSetting::whereNull('customer_id')->whereNull('group')->whereNull('agent_id');
foreach ($list_product as $key => $product) {
if ($setting = $settings->where('customer_id', $customer->id)->where('product_id', $product->id)->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->where('customer_id', $customer->id)->whereNull('product_id')->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->where('group', $customer->group)->where('product_id', $product->id)->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->where('group', $customer->group)->whereNull('product_id')->first()) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->whereNull('group')->whereNull('customer_id')->where('product_id', $product->id)->first()) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = $settings->whereNull('group')->whereNull('product_id')->whereNull('customer_id')->first()) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = CustomersSetting::whereNull('customer_id')->whereNull('group')->whereNull('agent_id')->where('product_id', $product->id)->first() ) {
$setting=setAttribute($setting,$prises,$product,$agent,$list_product,$key);
} elseif ($setting = CustomersSetting::whereNull('customer_id')->whereNull('group')->whereNull('agent_id')->first()) {
$setting= setAttribute($setting,$prises,$product,$agent,$list_product,$key);
}else {
unset($prises[$product->id]);
unset($list_product[$key]);
}
// رفتن به ایجنت سطح بالاتر
$agent = $agent ? CustomerModel::find($agent->agent_id) : null;
$customerSettings[$agent->id??0][$product->id] = $setting;
$customerSettings['all_levels'][$product->id][] = $setting;
}
// رفتن به ایجنت سطح بالاتر
$agent = $agent ? CustomerModel::find($agent->agent_id) : null;
} while ($agent);
}
} while ($agent);
//return $prises;
foreach ($list_product as $product) {

0
app/Http/Controllers/PushController.php Normal file → Executable file
View File

View File

@ -184,6 +184,27 @@ class DashboardAgentController extends Controller
'd' => $result??null,
]);
}
public function delete_customer_setting($customer_setting_id)
{
// پیدا کردن تنظیم
$setting = CustomersSetting::find($customer_setting_id);
if (!$setting) {
return response()->json([
'message' => 'تنظیم موردنظر یافت نشد',
'data' => null
], 404);
}
// حذف تنظیم
$setting->delete();
return response()->json([
'message' => 'تنظیم با موفقیت حذف شد',
'data' => $setting
]);
}
public function creat_customer_setting_id(Request $request )
{
$data = $request->all();
@ -289,6 +310,7 @@ class DashboardAgentController extends Controller
'credit_sell' => $data['credit_sell'] ?? 0,
'auto_buy' => $data['auto_buy'] ?? 0,
'auto_sell' => $data['auto_sell'] ?? 0,
'is_active' => $data['is_active'] ?? true,
]);
return [

View File

@ -22,6 +22,7 @@ class CustomersSetting extends Model
"auto_buy",
"auto_sell",
"title",
"is_active",
];
protected $casts = [
"customer_id" => "integer", // or "string" depending on your needs
@ -33,6 +34,7 @@ class CustomersSetting extends Model
"credit_sell" => "integer",
"auto_buy" => "boolean",
"auto_sell" => "boolean",
"is_active" => "boolean",
];
public function customer()
{

0
app/Models/PushSubscription.php Normal file → Executable file
View File

View File

@ -48,6 +48,7 @@ Route::middleware('auth:user')->group(function (){
Route::post('get_settings',[SettingsController::class, 'edit']);
Route::post('/customer_setting/table', [PackageController::class, 'tableSettings']);
Route::delete('/customer_setting/{customer_setting_id}', [DashboardAgentController::class, 'delete_customer_setting']);
Route::post('/customer_setting/{agent_id}', [DashboardAgentController::class, 'customer_setting']);
Route::get('/customer_prices/{customer_id}', function ($customer_id) {
return json_decode(app(CustomerProductController::class)->list_product($customer_id)->getContent(), true);});