mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
sig rental without reservation fix
This commit is contained in:
parent
fa6181eaa4
commit
0d034bf73b
3 changed files with 11 additions and 6 deletions
|
@ -1150,6 +1150,7 @@ sub booking_update(){
|
||||||
|
|
||||||
$update_pos->{int10} = "$state_key";
|
$update_pos->{int10} = "$state_key";
|
||||||
$update_pos->{txt11} = "$sig_book->{rentalId}" if($sig_book->{rentalId});
|
$update_pos->{txt11} = "$sig_book->{rentalId}" if($sig_book->{rentalId});
|
||||||
|
$update_pos->{txt22} = "$sig_book->{bikeId}" if($sig_book->{bikeId});
|
||||||
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
|
$rows = $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||||
|
|
||||||
if($rows > 0){
|
if($rows > 0){
|
||||||
|
|
|
@ -262,11 +262,9 @@ elsif($q->param('request') eq "booking_request"){
|
||||||
|
|
||||||
if($ct_bike->{barcode} && $ct_tariff->{barcode}){
|
if($ct_bike->{barcode} && $ct_tariff->{barcode}){
|
||||||
#sig reservation. not mandatory, disabled because sig seems to get confused
|
#sig reservation. not mandatory, disabled because sig seems to get confused
|
||||||
if(1==2 && $ct_bike->{int11} == 3){
|
if((!$q->param('state') || $q->param('state') ne "occupied") && $ct_bike->{int11} == 3){
|
||||||
$sig_book = $si->sig_booking(\%varenv,"reserve",$authraw,$ct_bike,"");
|
$sig_book = $si->sig_booking(\%varenv,"reserve",$authraw,$ct_bike,"");
|
||||||
$sig_book->{bikeId} = "$ct_bike->{txt22}";
|
$sig_book->{bikeId} = "$ct_bike->{txt22}";
|
||||||
#we only need rentalId because of reserve/end uses rentalId
|
|
||||||
#$sig_book->{reservationId} = "$R::reservationId" if($R::reservationId);#only for cmd tests
|
|
||||||
$sig_book->{rentalId} = "$R::rentalId" if($R::rentalId);#only for cmd tests
|
$sig_book->{rentalId} = "$R::rentalId" if($R::rentalId);#only for cmd tests
|
||||||
}
|
}
|
||||||
$response_book = $apif->booking_request($q,\%varenv,$authraw,$bike,$ct_bike,$ct_tariff,$aowner,$gps,$sig_book);
|
$response_book = $apif->booking_request($q,\%varenv,$authraw,$bike,$ct_bike,$ct_tariff,$aowner,$gps,$sig_book);
|
||||||
|
@ -297,6 +295,7 @@ elsif($q->param('request') eq "booking_request"){
|
||||||
#$sig_book = $si->sig_booking(\%varenv,"rental",$authraw,$ct_bike,$ctpos);
|
#$sig_book = $si->sig_booking(\%varenv,"rental",$authraw,$ct_bike,$ctpos);
|
||||||
#we have to use $ct_bike->{txt22} because we doesn't using sig reserve in this case
|
#we have to use $ct_bike->{txt22} because we doesn't using sig reserve in this case
|
||||||
system("$varenv{basedir}/src/scripts/sig_client.pl '$varenv{syshost}' 'rental' '$authraw->{c_id}' '$ct_bike->{txt22}' '$ctpos->{c_id}' &");
|
system("$varenv{basedir}/src/scripts/sig_client.pl '$varenv{syshost}' 'rental' '$authraw->{c_id}' '$ct_bike->{txt22}' '$ctpos->{c_id}' &");
|
||||||
|
$sig_book->{bikeId} = "$ct_bike->{txt22}";
|
||||||
$sig_book->{rentalId} = "$R::rentalId" if($R::rentalId);#only for cmd tests
|
$sig_book->{rentalId} = "$R::rentalId" if($R::rentalId);#only for cmd tests
|
||||||
($rows, $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$sig_book);
|
($rows, $booking_values) = $apif->booking_update($q,\%varenv,$authraw,$aowner,$sig_book);
|
||||||
$response = {%$response, %$booking_values};
|
$response = {%$response, %$booking_values};
|
||||||
|
|
|
@ -90,7 +90,8 @@ sub handler {
|
||||||
|
|
||||||
|
|
||||||
#sig booking_update
|
#sig booking_update
|
||||||
sig_booking_update($q,\%varenv,$response,$aowner);# sig json post
|
my $response_out = {};
|
||||||
|
$response_out = sig_booking_update($q,\%varenv,$response,$aowner);# sig json post
|
||||||
|
|
||||||
#sig json api
|
#sig json api
|
||||||
sub sig_booking_update {
|
sub sig_booking_update {
|
||||||
|
@ -127,6 +128,7 @@ sub sig_booking_update {
|
||||||
$POSTDATA = encode_json(\%POSTDATA_hash);
|
$POSTDATA = encode_json(\%POSTDATA_hash);
|
||||||
print FILE "<=== DUMP POSTDATA_hash:\n " . Dumper(\%POSTDATA_hash) . "\n" if($debug);
|
print FILE "<=== DUMP POSTDATA_hash:\n " . Dumper(\%POSTDATA_hash) . "\n" if($debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
eval {
|
eval {
|
||||||
my $response_in = {};
|
my $response_in = {};
|
||||||
$response_in = decode_json($POSTDATA) if($POSTDATA);
|
$response_in = decode_json($POSTDATA) if($POSTDATA);
|
||||||
|
@ -139,6 +141,8 @@ sub sig_booking_update {
|
||||||
my $rows = 0;
|
my $rows = 0;
|
||||||
my $booking_values = {};
|
my $booking_values = {};
|
||||||
|
|
||||||
|
print FILE "event: $response_in->{event}\n" if($debug);
|
||||||
|
|
||||||
if($response_in->{event} eq "RENTAL_START"){
|
if($response_in->{event} eq "RENTAL_START"){
|
||||||
$response->{response_state} = "OK: methode not implemented, because rental will started by App";
|
$response->{response_state} = "OK: methode not implemented, because rental will started by App";
|
||||||
}
|
}
|
||||||
|
@ -184,6 +188,7 @@ sub sig_booking_update {
|
||||||
delete $booking_values->{co2saving};
|
delete $booking_values->{co2saving};
|
||||||
delete $booking_values->{bike};
|
delete $booking_values->{bike};
|
||||||
delete $booking_values->{response_text};
|
delete $booking_values->{response_text};
|
||||||
|
$response->{response_state} = "OK: event matched, but something seems going wrong on booking_update" if(!$booking_values->{response_state});
|
||||||
$response = {%$response, %$booking_values};
|
$response = {%$response, %$booking_values};
|
||||||
}else{
|
}else{
|
||||||
$response->{response_state} = "Failure: there is no rental with rentalID=$rentalId";
|
$response->{response_state} = "Failure: there is no rental with rentalID=$rentalId";
|
||||||
|
@ -203,13 +208,13 @@ sub sig_booking_update {
|
||||||
print FILE "warn:" . $@ . "\n" if($debug);
|
print FILE "warn:" . $@ . "\n" if($debug);
|
||||||
$response->{response_state} = "Failure: can not decode POST json";
|
$response->{response_state} = "Failure: can not decode POST json";
|
||||||
}
|
}
|
||||||
|
return $response;
|
||||||
}#end sig json booking_update
|
}#end sig json booking_update
|
||||||
|
|
||||||
|
|
||||||
#end RESTful ------------------------------------------------------------
|
#end RESTful ------------------------------------------------------------
|
||||||
#FINAL JSON response OUTPUT ----------------------------------------------------------
|
#FINAL JSON response OUTPUT ----------------------------------------------------------
|
||||||
my $jrout = $json->pretty->encode({shareeio => $response});
|
my $jrout = $json->pretty->encode({shareeio => $response_out});
|
||||||
print $jrout;
|
print $jrout;
|
||||||
|
|
||||||
print FILE "APIshareeio jrout:\n" . Dumper($jrout) . "\n" if($debug);
|
print FILE "APIshareeio jrout:\n" . Dumper($jrout) . "\n" if($debug);
|
||||||
|
|
Loading…
Add table
Reference in a new issue