mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 23:26:29 +02:00
rental freed_time and some service staff coding
This commit is contained in:
parent
9213ca6a70
commit
b92f2c6b5c
8 changed files with 91 additions and 47 deletions
|
@ -975,7 +975,8 @@ sub booking_request(){
|
|||
$dbt->update_one($dbh,$update_ctt,"start_time='$now_dt'");
|
||||
|
||||
#BVB once auto-coupon until 2023-08-31
|
||||
if($varenv->{dbname} eq "sharee_bvb"){
|
||||
#disabled
|
||||
if(1==2 && $varenv->{dbname} eq "sharee_bvb"){
|
||||
#BVB 3-Stunden-Freifahrt
|
||||
my $auto_coupon = "123";
|
||||
my $pref_co = {
|
||||
|
@ -1278,7 +1279,8 @@ sub booking_update(){
|
|||
|
||||
#return after booking_update
|
||||
#in real, we know freed accountable rentals only on rental end's
|
||||
$pri->count_freedrental($q,$varenv,$auth->{c_id},$record_pos);
|
||||
my $adjust_freedtime = 1;
|
||||
$pri->count_freedrental($q,$varenv,$auth->{c_id},$record_pos,$adjust_freedtime);
|
||||
my ($pricing,$counting) = $pri->counting_rental($varenv,$record_pos);
|
||||
|
||||
#int03 only used for tarif counting backwards compatibility
|
||||
|
@ -1782,12 +1784,16 @@ sub rentals(){
|
|||
my $pricing->{$id} = {};
|
||||
my $counting = {};
|
||||
#adjusting freed time rental by called bikes_occupied
|
||||
$pri->count_freedrental("rentals by user_bikes_occupied",\%varenv,$auth->{c_id},$record->{$id});
|
||||
#further_freedtime_available will be 0 if no further freed_time
|
||||
my $adjust_freedtime = 1;
|
||||
my $further_freedtime_available = 1;
|
||||
$further_freedtime_available = $pri->count_freedrental("rentals by user_bikes_occupied",\%varenv,$auth->{c_id},$record->{$id},$adjust_freedtime);
|
||||
$return->{$id}->{further_freedtime_available} = "$further_freedtime_available";
|
||||
($pricing->{$id}, $counting) = $pri->counting_rental(\%varenv,$record->{$id});
|
||||
|
||||
#$bw->log("rentals-rentalog",$pricing->{$id}->{rentalog},"");
|
||||
$pricing->{$id}->{rentalog} = "";#just for debuggiog, removed to reduce data in json
|
||||
my $return_feed->{$id} = $pri->fetch_rentalfeed($varenv_prim,\%varenv,$record->{$id},$pricing->{$id});
|
||||
my $return_feed->{$id} = $pri->fetch_rentalfeed($varenv_prim,\%varenv,$record->{$id},$pricing->{$id},$further_freedtime_available);
|
||||
$return->{$id} = { %{ $pricing->{$id} }, %{ $return_feed->{$id} } };
|
||||
|
||||
my $bike_id = $return->{$id}->{bike};
|
||||
|
@ -1877,6 +1883,13 @@ sub bikes_available(){
|
|||
|
||||
my $td_template = $dbt->rental_description_template($varenv_prim);
|
||||
|
||||
#return list of occupied/requested bikes
|
||||
my $rentals_record = {};
|
||||
my $rentals_response = {};
|
||||
$rentals_record = $self->user_bikes_occupied($dbh,$auth,"");
|
||||
$rentals_response = $self->rentals($varenv_prim,$rentals_record,$auth,"");#returns JSON rental values
|
||||
$rentals_response->{further_freedtime_available} = 1 if(!keys (%$rentals_response));
|
||||
|
||||
foreach my $id (sort { $record->{$a}->{barcode} <=> $record->{$b}->{barcode} } keys (%$record)){
|
||||
$return->{$id}->{authed} = "$authed";
|
||||
$return->{$id}->{station} = "$dbt->{operator}->{$varenv->{dbname}}->{oprefix}$record->{$id}->{int04}";
|
||||
|
@ -1971,9 +1984,11 @@ sub bikes_available(){
|
|||
$tariff_content->{$tid}->{int17} =~ s/\./,/ if($lang eq "de");
|
||||
$return->{$id}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{int17}","$tariff_content->{$tid}->{int17} € / 24 $varenv_prim->{cms}->{'unit-hour'}->{txt}"];
|
||||
}elsif($td_template->{$td}->{time02} && $tariff_content->{$tid}->{time02} =~ /[1-9]/){
|
||||
$time_unit = $dbt->time_format($varenv_prim,$tariff_content->{$tid}->{time02});
|
||||
$time_unit .= " / $varenv_prim->{cms}->{'unit-day'}->{txt}" if($dbt->{operator}->{$varenv->{dbname}}->{project} ne "Konstanz");
|
||||
$return->{$id}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit"];
|
||||
if($rentals_response->{further_freedtime_available} == 1 || !$auth->{c_id}){
|
||||
$time_unit = $dbt->time_format($varenv_prim,$tariff_content->{$tid}->{time02});
|
||||
$time_unit .= " / $varenv_prim->{cms}->{'unit-day'}->{txt}" if($dbt->{operator}->{$varenv->{dbname}}->{project} ne "Konstanz");
|
||||
$return->{$id}->{rental_description}->{tarif_elements}->{$td} = ["$td_template->{$td}->{time02}","$time_unit"];
|
||||
}
|
||||
}
|
||||
}#end new rental_description
|
||||
|
||||
|
@ -2172,7 +2187,7 @@ sub stations_available(){
|
|||
my $station_bike_node = "";
|
||||
$station_bike_node = $record_pos->{int12} if(ref($record_pos) eq "HASH" && $record_pos->{int12});
|
||||
|
||||
#take start station from pos
|
||||
#for AA rentals take end- from start-station.
|
||||
my $aa_station = 0;
|
||||
$aa_station = $record_pos->{int06} if(ref($record_pos) eq "HASH" && $record_pos->{int06} && $record_pos->{int42});
|
||||
|
||||
|
@ -2185,22 +2200,25 @@ sub stations_available(){
|
|||
int10 => "1",#1 = "available"
|
||||
};
|
||||
|
||||
#group_id must have 6 numbers like 300103
|
||||
my $pref_sql = "";
|
||||
|
||||
#select by bike.type_id bike-group on booking update, to get available stations on bike return by filter logic
|
||||
my $pref_sql = "";
|
||||
if(ref($record_pos) eq "HASH" && $record_pos->{int29}){
|
||||
foreach my $type_id (@{$bike_group}){
|
||||
#service user can redistribute to all
|
||||
if($auth->{int09} && !$dbt->{copri_conf}->{betau_id}->{$auth->{c_id}}){
|
||||
$pref_sql = "";
|
||||
}
|
||||
#A-A rental
|
||||
#on rental-end select only station which is the same as on start and A-A
|
||||
if($station_group && $type_id =~ /(\d+)/ && $aa_station){
|
||||
elsif($station_group && $type_id =~ /(\d+)/ && $aa_station){
|
||||
my $group_id = $1;
|
||||
if($group_id == $station_group){
|
||||
$pref_sql = " and ct.int04 = $aa_station and ct.int42=1";
|
||||
}
|
||||
}
|
||||
#A-B rental
|
||||
#on rental-end select only stations which are in ststion_group and be A-B
|
||||
}elsif($station_group && $type_id =~ /(\d+)/){
|
||||
elsif($station_group && $type_id =~ /(\d+)/){
|
||||
my $group_id = $1;
|
||||
if($group_id == $station_group){
|
||||
$pref_sql = " and ct.txt25 like '%$group_id%' and (ct.int42=0 OR ct.int42 is null)";
|
||||
|
@ -2223,7 +2241,7 @@ sub stations_available(){
|
|||
|
||||
$pref_sql = "" if($pref_sql !~ /\d/);
|
||||
|
||||
$bw->log("stations_available --> rental station_bike_node:$station_bike_node|rental aa_station:$aa_station|user has access to bike_node:@{$bike_node}|user has access to bike_group:@{$bike_group}|pref_sql:\n",$pref_sql,"");
|
||||
$bw->log("stations_available --> rental station_bike_node:$station_bike_node|rental aa_station:$aa_station|user has access to bike_node:@{$bike_node}|user has access to bike_group:@{$bike_group}|!$auth->{int09} && !$dbt->{copri_conf}->{betau_id}->{$auth->{c_id}}|pref_sql:\n",$pref_sql,"");
|
||||
|
||||
my $record = {};
|
||||
$record = $dbt->fetch_record($dbh,$pref,$pref_sql) if(ref($bike_node) eq "ARRAY" && @{$bike_node}[0]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue