Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Hakim assim
Twistana-Back
Commits
6cba9c71
Commit
6cba9c71
authored
5 months ago
by
Anass dabibe
Browse files
Options
Download
Email Patches
Plain Diff
add remote changes delevery fees
parent
aa9d973a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/Http/Controllers/Api/CheckoutController.php
+26
-6
app/Http/Controllers/Api/CheckoutController.php
app/Http/Controllers/Api/RootAppController.php
+6
-5
app/Http/Controllers/Api/RootAppController.php
app/Jobs/SyncCommandsToPos.php
+9
-4
app/Jobs/SyncCommandsToPos.php
app/Repositories/PriceRepository.php
+1
-1
app/Repositories/PriceRepository.php
with
42 additions
and
16 deletions
+42
-16
app/Http/Controllers/Api/CheckoutController.php
View file @
6cba9c71
...
...
@@ -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;
...
...
This diff is collapsed.
Click to expand it.
app/Http/Controllers/Api/RootAppController.php
View file @
6cba9c71
...
...
@@ -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
,
];
}
...
...
This diff is collapsed.
Click to expand it.
app/Jobs/SyncCommandsToPos.php
View file @
6cba9c71
...
...
@@ -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
]);
...
...
This diff is collapsed.
Click to expand it.
app/Repositories/PriceRepository.php
View file @
6cba9c71
...
...
@@ -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
();
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help