Commit 6cba9c71 authored by Anass dabibe's avatar Anass dabibe
Browse files

add remote changes delevery fees

parent aa9d973a
Showing with 42 additions and 16 deletions
+42 -16
......@@ -217,14 +217,34 @@ class CheckoutController extends AppBaseController
public function addClient(Request $request) {
$default_password = '123456';
$withCheckout = $request->query('withCheckout');
//$request->validate([
// 'name' => 'required',
// 'phone' => ['nullable', 'string', Rule::unique('users', 'phone')->whereNotNull('verified')],
// 'email' => ['nullable', 'email', Rule::unique('users', 'email')->whereNotNull('verified')],
// 'password' => 'sometimes|nullable',
// 'verified' => 'nullable'
//]);
$request->validate([
// Set validation rules
$validationRules = [
'name' => 'required',
'phone' => ['nullable', 'string', Rule::unique('users', 'phone')->whereNotNull('verified')],
'email' => ['nullable', 'email', Rule::unique('users', 'email')->whereNotNull('verified')],
'phone' => ['nullable', 'string'],
'email' => ['nullable', 'email'],
'password' => 'sometimes|nullable',
'verified' => 'nullable'
]);
];
// Add unique validation only if 'withCheckout' is not present
if (!$withCheckout) {
$validationRules['phone'][] = Rule::unique('users', 'phone')->whereNotNull('verified');
$validationRules['email'][] = Rule::unique('users', 'email')->whereNotNull('verified');
}
// Validate the request
$request->validate($validationRules);
$role = $this->roleRepository->getByTag("client");
......@@ -359,7 +379,7 @@ class CheckoutController extends AppBaseController
foreach ($commands as $line) {
$product = Price::find($line['price_id'])->products->first();
$product = Price::withTrashed()->find($line['price_id'])->products->first();
$product_stock = $product->stock->quantity;
if($product_stock < $line['quantity']) {
......@@ -523,8 +543,8 @@ class CheckoutController extends AppBaseController
// dd("step-remise-mail-passed");
\Log::info("cmdClient_id : ".$command->id);
$command = $this->commandRepository->find($command->id);
// $setting_stock_in = \DB::table('settings')->where('key', 'site.magasin_client_id_in')->first();
// $setting_stock_out = \DB::table('settings')->where('key', 'site.magasin_client_id_out')->first();
// $condition = $setting_stock_in && $setting_stock_out && $setting_stock_in->value == $setting_stock_out->value;
......
......@@ -72,11 +72,11 @@ class RootAppController extends AppBaseController
$response = [];
$enableCashDelevry = [
'LIVRAISON CASABLANCA 20 DHS',
'MOHMADIA / BOUSKOURA / BERRCHID 39 DHS',
'RABAT KENITRA SALÉ ET RÉGIONS',
'LIVRAISON RAHMA /DEROUA/TITT MELIL ...30 DHS',
'RABAT//KENITRA//SALE//TEMARA//ET REGIONS 35 DHS'
'LIVRAISON CASABLANCA 20 DHS',
'MOHMADIA / BOUSKOURA / BERRCHID 39 DHS',
'RABAT KENITRA SALÉ ET RÉGIONS',
'LIVRAISON RAHMA /DEROUA/TITT MELIL ...30 DHS',
'RABAT//KENITRA//SALE//TEMARA//ET REGIONS 35 DHS'
];
foreach($prices as $price) {
......@@ -88,6 +88,7 @@ class RootAppController extends AppBaseController
'price' => $price->price > $price->promoPrice ? $price->promoPrice : $price->price,
'price_id' => $price->id,
'cashDelevry' => in_array($detail->value, $enableCashDelevry),
// 'cashDelevry' => true,
'bankTransfer' => true,
];
}
......
......@@ -153,7 +153,11 @@ class SyncCommandsToPos implements ShouldQueue
$unique_remise_local_key = Str::uuid()->toString();
\Log::info("test_log_xs");
if($this->command && $this->command->pos_command_id == 18133){
\Log::info($this->command->pos_command_id);
}
$cmdClients = [[
'id' => $this->validating ? $this->command->pos_command_id : 0,
'etat_cmd_id' => $selectedCommandId,
......@@ -197,7 +201,8 @@ class SyncCommandsToPos implements ShouldQueue
$command = \App\Models\Command::find($this->command->id);
$const_remise_valeur = intval(($command->total - $livraisonPrice) * $cmdRemise->valeur / 100);
//$const_remise_valeur = intval(($command->total - $livraisonPrice) * $cmdRemise->valeur / 100);
$const_remise_valeur=number_format(($command->total - $livraisonPrice) * $cmdRemise->valeur / 100, 2, '.', '');
$addRemiseUrl = "/commandeAP/Remise/addV2";
try{
......@@ -267,14 +272,14 @@ class SyncCommandsToPos implements ShouldQueue
if(!$this->validating) {
\Log::info("[INFO]-Push Command");
$response = $client->post(config('urls.sync-command.subUrl1'). $calendarDayEntityId . config('urls.sync-command.subUrl2'), [
'json' => $data
]);
}
else {
try {
\Log::info("[INFO]-Update commande");
$response = $client->patch(config('urls.sync-command.subUrl1'). $calendarDayEntityId . config('urls.sync-command.subUrl2'), [
'json' => $data
]);
......
......@@ -243,7 +243,7 @@ class PriceRepository extends BaseRepository
public function getPricesByIds($list)
{
return $this->model->whereIn('id', $list)
return $this->model->withTrashed()->whereIn('id', $list)
->with("products.description.products.detailKeys.detailKey", "products.detailKeys.detailKey", "commandPrice")
->get();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment