mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 23:26:29 +02:00
rental end json and once miniquery
This commit is contained in:
parent
57515256a5
commit
95d890e188
17 changed files with 224 additions and 91 deletions
|
@ -1002,7 +1002,6 @@ sub booking_update(){
|
|||
|
||||
my $state = $q->escapeHTML($q->param('state')) || "";
|
||||
my $lock_state = $q->escapeHTML($q->param('lock_state')) || "";
|
||||
my $station_state = $q->escapeHTML($q->param('station_state')) || "";
|
||||
my %varenv = $cf->envonline();
|
||||
my $rows = 0;
|
||||
my $user_agent = $q->user_agent();
|
||||
|
@ -1030,7 +1029,7 @@ sub booking_update(){
|
|||
bike => "$bike",
|
||||
state => "",
|
||||
lock_state => "",
|
||||
#station_state => "",
|
||||
station_lock_state => "",
|
||||
co2saving => "",
|
||||
response_state => "OK 1017: No update",
|
||||
response_text => "Der Mietstatus wurde nicht geändert.",
|
||||
|
@ -1104,7 +1103,7 @@ sub booking_update(){
|
|||
|
||||
#2020-09-24 requested will be all done by net_booking
|
||||
#6 = "canceled"|3 = "occupied"|1 = "available"
|
||||
#if($state && $state =~ /$dbt->{copri_conf}->{bike_state}->{6}|$dbt->{copri_conf}->{bike_state}->{3}|$dbt->{copri_conf}->{bike_state}->{1}/ && $record_pos->{cc_id} && $record_pos->{cc_id} > 0){
|
||||
#if($state && $state =~ /$dbt->{copri_conf}->{bike_state}->{6}|$dbt->{copri_conf}->{bike_state}->{3}|$dbt->{copri_conf}->{bike_state}->{1}/ && $record_pos->{cc_id} && $record_pos->{cc_id} > 0)
|
||||
if($state_key && ($state_key == 6 || $state_key == 3 || $state_key == 1) && $record_pos->{cc_id} && $record_pos->{cc_id} > 0){
|
||||
|
||||
#set rent state if lock_system 2=Ilockit || 3=sigo
|
||||
|
@ -1204,7 +1203,7 @@ sub booking_update(){
|
|||
|
||||
$geo_distance = $lb->geo_fencing($latitude,$longitude,$latitude_station,$longitude_station);
|
||||
#$station_next = $stations_raw->{$id}->{int04};
|
||||
#if($geo_distance <= $stations_raw->{$id}->{int06}){
|
||||
#if($geo_distance <= $stations_raw->{$id}->{int06})
|
||||
#sigo development workaround without geofence
|
||||
if(($geo_distance <= $stations_raw->{$id}->{int06}) || ($record_pos->{int11} == 3)){
|
||||
$geo_distance_next = $geo_distance;
|
||||
|
@ -1219,6 +1218,8 @@ sub booking_update(){
|
|||
$update_pos->{int21} = "$gps_age_minutes";
|
||||
$update_pos->{int22} = "$gps_accuracy";
|
||||
$update_pos->{int23} = "$geo_distance";
|
||||
$update_pos->{int26} = "$sig_book->{distance}" if($sig_book->{distance});
|
||||
$update_pos->{int28} = "$sig_book->{station_lock_state}" if($sig_book->{station_lock_state});
|
||||
#end-Station prefix
|
||||
$update_pos->{txt13} = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}";
|
||||
#end-Station prefix
|
||||
|
@ -1508,10 +1509,10 @@ sub booking_update(){
|
|||
|
||||
#fetch tracking distance on Ilockit cloud by summary trip if(tracking && deviceId && available)
|
||||
if($booking->{int25} == 1 && $booking->{int10} == 1){
|
||||
sleep 2;#hopefully get distance in 2 sec.
|
||||
$bw->log("$varenv{basedir}/src/scripts/Ilockit_trackingcloud.pl $varenv{syshost} get_tripsum $booking->{c_id}",$booking->{c_id},"");
|
||||
#if ilockit clouid
|
||||
if($booking->{int13}){
|
||||
$bw->log("get co2saving",$booking->{c_id},"");
|
||||
#if system=ilockit && clouid
|
||||
if($record_pos->{int11} == 2 && $booking->{int13}){
|
||||
sleep 2;#hopefully get distance in 2 sec.
|
||||
system("$varenv{basedir}/src/scripts/Ilockit_trackingcloud.pl $varenv{syshost} get_tripsum $booking->{c_id}");
|
||||
$booking = $dbt->fetch_tablerecord($dbh,$booking_pos);
|
||||
#try it again with 20sec sleep
|
||||
|
@ -1528,8 +1529,8 @@ sub booking_update(){
|
|||
$co2saving = "Einsparung: ";
|
||||
my $co2diff = $pri->co2calc($booking);
|
||||
my $sprit_price = $pri->sprit2calc($booking);
|
||||
$co2saving .= "$co2diff kg CO2 und ";
|
||||
$co2saving .= "$sprit_price EUR ";
|
||||
$co2saving .= "$co2diff kg CO2, ";
|
||||
$co2saving .= "$sprit_price EUR " if($sprit_price > 0);
|
||||
$booking->{int26} =~ s/\./,/;
|
||||
$co2saving .= "bei einer Strecke von $booking->{int26} KM";
|
||||
$booking_values->{co2saving} = $co2saving;
|
||||
|
@ -1676,9 +1677,6 @@ sub rentals(){
|
|||
|
||||
foreach my $id (sort { $record->{$a}->{end_time} cmp $record->{$b}->{end_time} } keys (%$record)){
|
||||
|
||||
#last
|
||||
#$return->{$id} = $pri->sharee_pricing($record->{$id},"readonly");
|
||||
|
||||
#new sharee_pricing
|
||||
(my $return_counting->{$id}, my $counting) = $pri->counting_rental(\%varenv,$record->{$id},"");
|
||||
my $return_feed->{$id} = $pri->fetch_rentalfeed(\%varenv,$record->{$id},$return_counting->{$id});
|
||||
|
@ -1700,6 +1698,39 @@ sub rentals(){
|
|||
$return->{$id}->{K_u} = "$K_val" if($K_key eq "K_u");
|
||||
}
|
||||
}
|
||||
#sig update station_lock_state=locked to cancel once miniquery
|
||||
elsif($record->{$id}->{int11} && $record->{$id}->{int11} == 3 && $record->{$id}->{int28} && $record->{$id}->{int28} == 3){
|
||||
|
||||
#only for project=Bayern and developer enabled
|
||||
if(($dbt->{operator}->{$varenv{dbname}}->{project} eq "Bayern" && $auth->{int23} < 4) || ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 11765 || $auth->{c_id} == 1843 || $auth->{c_id} == 38883)){
|
||||
|
||||
$bw->log("user_miniquery via $varenv{dbname} user ID $auth->{c_id} exist count:",$auth->{int23},"");
|
||||
$return->{user_miniquery} = $dbt->evaluationsfragen($dbh);
|
||||
|
||||
#user_miniquest_count
|
||||
my $user_miniquest_count = $auth->{int23} || 0;
|
||||
if($user_miniquest_count <= 4){
|
||||
$user_miniquest_count++;
|
||||
my $update_op = {
|
||||
table => "contentadr",
|
||||
int23 => $user_miniquest_count,
|
||||
atime => "now()",
|
||||
};
|
||||
my $rows = $dbt->update_record($dbh,$update_op,$auth);
|
||||
}
|
||||
}#end mini_quest
|
||||
|
||||
#there seems some methodes which needs state, thats because disabled
|
||||
#$return->{state} = "requested";#used once in App after sig rental-end push-notify
|
||||
|
||||
my $update_pos = {
|
||||
table => "contenttranspos",
|
||||
int28 => "1",
|
||||
c_id => "$id",
|
||||
};
|
||||
$dbt->update_record($dbh,$update_pos,$update_pos);
|
||||
$bw->log("sig update int28 station_lock_state=locked to cancel once miniquery",$update_pos,"");
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -1804,14 +1835,12 @@ sub bikes_available(){
|
|||
$return->{$id}->{tariff_description}->{max_eur_per_day} = "$tariff_content->{$tid}->{int17}" if($tariff_content->{$tid}->{int17});
|
||||
$return->{$id}->{tariff_description}->{free_hours} = "$tariff_content->{$tid}->{int16}" if($tariff_content->{$tid}->{int16});
|
||||
$return->{$id}->{tariff_description}->{abo_eur_per_month} = "$tariff_content->{$tid}->{int15}" if($tariff_content->{$tid}->{int15});
|
||||
#TODO, have to be set on Tarif table
|
||||
$return->{$id}->{tariff_description}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
|
||||
|
||||
#new rental_description
|
||||
$return->{$id}->{rental_description}->{name} = "$tariff_content->{$tid}->{ct_name}";
|
||||
$return->{$id}->{rental_description}->{id} = "$tariff_content->{$tid}->{barcode}";
|
||||
$return->{$id}->{rental_description}->{rental_info}->{1} = ["Tracking","Ich stimme der Speicherung (Tracking) meiner Fahrstrecke zwecks wissenschaftlicher Auswertung und Berechnung der CO2-Einsparung zu!"] if($record->{$id}->{int25});
|
||||
$return->{$id}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)."] if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
|
||||
$return->{$id}->{rental_description}->{rental_info}->{2} = ["AGB","Mit der Mietrad Anmietung wird folgender Betreiber <a href='$varenv->{wwwhost}/site/agb.html' target='_blank'>AGB</a> zugestimmt (als Demo sharee AGB)."] if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262 || $auth->{c_id} == 38883));
|
||||
|
||||
my $i = 0;
|
||||
foreach my $td (sort keys (%$td_template)){
|
||||
|
@ -2461,7 +2490,7 @@ sub auth_verify(){
|
|||
print FILE "auth_verified on operator anchor 3 by dbname $varenv{dbname} | op3 $auth_operator3->{c_id}\n" if($debug);
|
||||
|
||||
#if user on operator available by userid c_id, then update authcookie
|
||||
if($auth_operator3->{c_id} > 0){
|
||||
if($auth_operator3->{c_id} && $auth_operator3->{c_id} > 0){
|
||||
my $authcookies = $auth_operator3->{txt05} . "|" . $cgi_authcookie;
|
||||
$bw->log("UPDATE adr on operator by dbname $varenv{dbname}",$auth_operator3->{c_id},"");
|
||||
print FILE "UPDATE adr on operator by dbname $varenv{dbname} | op3 $auth_operator3->{c_id}\n" if($debug);
|
||||
|
@ -2496,7 +2525,7 @@ sub auth_verify(){
|
|||
}
|
||||
}
|
||||
$auth_operator = $dbt->fetch_record($dbh,$authref);
|
||||
if($auth_operator->{c_id} > 0){
|
||||
if($auth_operator->{c_id} && $auth_operator->{c_id} > 0){
|
||||
$record = $auth_operator;#At first try using operator to get Tarif
|
||||
$bw->log("auth_verified on operator anchor 2.2 by dbname $varenv{dbname}",$auth_operator->{c_id},"");
|
||||
print FILE "auth_verified on operator anchor 2.2 by dbname $varenv{dbname} | op $auth_operator->{c_id}\n" if($debug);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue