mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-02-22 19:56:29 +01:00
sig unlock init
This commit is contained in:
parent
ec95e0db06
commit
fa6181eaa4
5 changed files with 67 additions and 15 deletions
|
@ -296,7 +296,7 @@ elsif($q->param('request') eq "booking_request"){
|
||||||
#usecase with reservationId (in ctpos) is in sig not defined, thats because using ct_bike.txt22
|
#usecase with reservationId (in ctpos) is in sig not defined, thats because using ct_bike.txt22
|
||||||
#$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->{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};
|
||||||
|
@ -379,12 +379,13 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki
|
||||||
#update on sig
|
#update on sig
|
||||||
if($ctpos->{int11} == 3){
|
if($ctpos->{int11} == 3){
|
||||||
if($q->param('state') eq "occupied"){
|
if($q->param('state') eq "occupied"){
|
||||||
system("$varenv{basedir}/src/scripts/sig_client.pl $varenv{syshost} 'rental' $authraw->{c_id} $ctpos->{txt22} $ctpos->{c_id} &");
|
system("$varenv{basedir}/src/scripts/sig_client.pl '$varenv{syshost}' 'rental' '$authraw->{c_id}' '$ctpos->{txt22}' '$ctpos->{c_id}' &");
|
||||||
}
|
}
|
||||||
#rental/end will be done by sig push-notification
|
#rental/end will be done by sig push-notification
|
||||||
#if($q->param('state') eq "available"){
|
#
|
||||||
#system("$varenv{basedir}/src/scripts/sig_client.pl $varenv{syshost} 'rental_end' $authraw->{c_id} '' $ctpos->{c_id} &");
|
if($q->param('lock_state') eq "unlocking" && !$q->param('state')){
|
||||||
#}
|
system("$varenv{basedir}/src/scripts/sig_client.pl '$varenv{syshost}' 'unlock' '$authraw->{c_id}' '$ctpos->{txt22}' '$ctpos->{c_id}' &");
|
||||||
|
}
|
||||||
|
|
||||||
#TODO, check if booking_values in both cases: push-notify and/or app trigger works
|
#TODO, check if booking_values in both cases: push-notify and/or app trigger works
|
||||||
$sig_book->{rentalId} = "$R::rentalId" if($R::rentalId);#only for cmd tests
|
$sig_book->{rentalId} = "$R::rentalId" if($R::rentalId);#only for cmd tests
|
||||||
|
|
|
@ -212,7 +212,8 @@ sub sig_booking_update {
|
||||||
my $jrout = $json->pretty->encode({shareeio => $response});
|
my $jrout = $json->pretty->encode({shareeio => $response});
|
||||||
print $jrout;
|
print $jrout;
|
||||||
|
|
||||||
$bw->log("APIjsonserver response by $user_agent mapped aowner:$aowner",$jrout,"");
|
print FILE "APIshareeio jrout:\n" . Dumper($jrout) . "\n" if($debug);
|
||||||
|
$bw->log("APIshareeio response by $user_agent mapped aowner:$aowner",$jrout,"");
|
||||||
#end JSON ----------------------------------------------------------------------------
|
#end JSON ----------------------------------------------------------------------------
|
||||||
|
|
||||||
close(FILE) if($debug);
|
close(FILE) if($debug);
|
||||||
|
|
|
@ -83,7 +83,7 @@ sub sig_available {
|
||||||
my $td_template = $dbt->rental_description_template();
|
my $td_template = $dbt->rental_description_template();
|
||||||
|
|
||||||
open(FILE,">>$varenv->{logdir}/APIsigclient.log");
|
open(FILE,">>$varenv->{logdir}/APIsigclient.log");
|
||||||
print FILE "\n*** $now_dt 'sig_available' \n";
|
print FILE "\n0. *** $now_dt 'sig_available' \n";
|
||||||
|
|
||||||
#my $endpoint = "https://sigo.dev.sigo.green/api/v1/bikes";
|
#my $endpoint = "https://sigo.dev.sigo.green/api/v1/bikes";
|
||||||
my $endpoint = "$dbt->{operator}->{$varenv->{dbname}}->{endpoint}/bikes";
|
my $endpoint = "$dbt->{operator}->{$varenv->{dbname}}->{endpoint}/bikes";
|
||||||
|
@ -151,8 +151,8 @@ sub sig_available {
|
||||||
$return2copri->{$station}->{int10} = $key;
|
$return2copri->{$station}->{int10} = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#TODO, disabled for workaround to see what happens. 22.06.2022
|
||||||
delete $response_out->{$station} if(uc($resp->{site}->{status}) ne "ACTIVE" || !$resp->{site}->{lat} || !$resp->{site}->{lon});
|
#delete $response_out->{$station} if(uc($resp->{site}->{status}) ne "ACTIVE" || !$resp->{site}->{lat} || !$resp->{site}->{lon});
|
||||||
}
|
}
|
||||||
}#end stations_available
|
}#end stations_available
|
||||||
|
|
||||||
|
@ -270,6 +270,46 @@ sub sig_available {
|
||||||
return ($response_out,$return2copri);
|
return ($response_out,$return2copri);
|
||||||
}#end sig_available
|
}#end sig_available
|
||||||
|
|
||||||
|
#bike smartlock unlocking
|
||||||
|
sub sig_unlock {
|
||||||
|
my $self = shift;
|
||||||
|
my $varenv = shift || {};
|
||||||
|
my $todo = shift || "";
|
||||||
|
my $ctadr = shift || {};
|
||||||
|
my $ct_bike = shift || {};
|
||||||
|
my $ctpos = shift || {};
|
||||||
|
my $sig_bikeId = $ctpos->{txt22} || $ct_bike->{txt22};
|
||||||
|
|
||||||
|
my $response_in = {};
|
||||||
|
my $dbh = "";
|
||||||
|
my $owner = 169;
|
||||||
|
|
||||||
|
open(FILE,">>$varenv->{logdir}/APIsigclient.log");
|
||||||
|
print FILE "\n3. *** $now_dt 'sig_unlock' \n";
|
||||||
|
|
||||||
|
my $endpoint = "$dbt->{operator}->{$varenv->{dbname}}->{endpoint}/bikes/unlock";
|
||||||
|
my $response_out = {};
|
||||||
|
my $return2copri = {};
|
||||||
|
my $rest_json = $sig_bikeId;
|
||||||
|
(my $ret_json, my $ret_status) = $self->get_sig("$endpoint",$rest_json);
|
||||||
|
eval {
|
||||||
|
$response_in = decode_json($ret_json);
|
||||||
|
$now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||||
|
print FILE "<--- $now_dt sig_unlock response_in with status_line: $ret_status:\n";
|
||||||
|
|
||||||
|
};
|
||||||
|
if ($@){
|
||||||
|
print FILE "<--- failure sig_unlock raw response_in with status_line: $ret_status\n" . Dumper($ret_json) . "\n";
|
||||||
|
#warn $@;
|
||||||
|
print FILE "warn:" . $@ . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
print FILE "sig_unlock ret_json from response_in\n" . Dumper($ret_json) . "\n";
|
||||||
|
close(FILE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#POST resverve, rental, ...
|
#POST resverve, rental, ...
|
||||||
#will be called by sig_client
|
#will be called by sig_client
|
||||||
sub sig_booking {
|
sub sig_booking {
|
||||||
|
|
|
@ -71,6 +71,12 @@ $ctpos = $dbt->fetch_tablerecord($dbh,$posref) if($user_id =~ /^\d+$/ && $user_i
|
||||||
|
|
||||||
print FILE "fetched from DB ctadr:$ctadr->{c_id}|ctpos:$ctpos->{c_id}\n";
|
print FILE "fetched from DB ctadr:$ctadr->{c_id}|ctpos:$ctpos->{c_id}\n";
|
||||||
|
|
||||||
|
#sig => copri key mapping
|
||||||
|
#bike id => txt22
|
||||||
|
#reservationId => txt10
|
||||||
|
#renatlId => txt11
|
||||||
|
|
||||||
|
|
||||||
#only for tests
|
#only for tests
|
||||||
if($todo eq "stations_available"){
|
if($todo eq "stations_available"){
|
||||||
$q->param(-name=>'request',-value=>"stations_available");
|
$q->param(-name=>'request',-value=>"stations_available");
|
||||||
|
@ -87,11 +93,6 @@ if($todo eq "bikes_available"){
|
||||||
#print $0 . Dumper($return) . "\n";
|
#print $0 . Dumper($return) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#sig => copri key mapping
|
|
||||||
#bike id => txt22
|
|
||||||
#reservationId => txt10
|
|
||||||
#renatlId => txt11
|
|
||||||
|
|
||||||
#only for tests. build in methode
|
#only for tests. build in methode
|
||||||
elsif($todo eq "reserve"){
|
elsif($todo eq "reserve"){
|
||||||
#$ctadr = { c_id => 1842 };
|
#$ctadr = { c_id => 1842 };
|
||||||
|
@ -108,6 +109,14 @@ elsif($todo eq "rental" && $ctadr->{c_id} > 0){
|
||||||
#print $0 . Dumper($return) . "\n";
|
#print $0 . Dumper($return) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#live! Fork unlock by lock_state=unlocking request with bike "id"
|
||||||
|
elsif($todo eq "unlock" && $ctadr->{c_id} > 0){
|
||||||
|
#$ctadr = { c_id => 1842 };
|
||||||
|
#$ct_bike = { txt22 => "380116b5-0522-43da-ab66-477744a731a3" };
|
||||||
|
my $return = $si->sig_unlock(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
||||||
|
#print $0 . Dumper($return) . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
#live! Fork rental_end request with "rentalId"
|
#live! Fork rental_end request with "rentalId"
|
||||||
elsif($todo eq "rental_end" && $ctadr->{c_id} > 0 && $ctpos->{txt11}){
|
elsif($todo eq "rental_end" && $ctadr->{c_id} > 0 && $ctpos->{txt11}){
|
||||||
my $return = $si->sig_booking(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
my $return = $si->sig_booking(\%varenv,$todo,$ctadr,$ct_bike,$ctpos);
|
||||||
|
|
|
@ -676,7 +676,8 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg
|
||||||
|
|
||||||
}#ende e-Mail iif
|
}#ende e-Mail iif
|
||||||
|
|
||||||
print $q->div({-class=>'content2'}, "Bei Problemen während der Registrierung bitte unsere Account-hotline <a href='mailto:hotline\@sharee.bike'>hotline\@sharee.bike</a> kontaktieren."),"\n" if($project eq "Bayern" && $path =~ /$varenv->{accounting_1}|$varenv->{accounting_3}/);
|
#print $q->div({-class=>'content2'}, "Bei Problemen während der Registrierung bitte unsere Account-hotline <a href='mailto:hotline\@sharee.bike'>hotline\@sharee.bike</a> kontaktieren."),"\n" if($project eq "Bayern" && $path =~ /$varenv->{accounting_1}|$varenv->{accounting_3}/);
|
||||||
|
print $q->div({-class=>'content2', -style=>'margin-top:2em;'}, "Bei Problemen während der Registrierung bitte unsere Account-hotline hotline\@sharee.bike kontaktieren."),"\n" if($project eq "Bayern" && $path =~ /$varenv->{accounting_1}|$varenv->{accounting_3}/);
|
||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
print $q->end_form,"\n";
|
print $q->end_form,"\n";
|
||||||
|
|
Loading…
Add table
Reference in a new issue