mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-14 15:46:28 +02:00
api sigo_available get
This commit is contained in:
parent
2a9099acd2
commit
381943be42
8 changed files with 166 additions and 96 deletions
|
@ -1394,7 +1394,7 @@ sub rentals(){
|
|||
$return->{$id} = $pri->sharee_pricing($record->{$id},"readonly");
|
||||
my $bike_id = $return->{$id}->{bike};
|
||||
$bike_id = $1 if($bike_id =~ /(\d+)/);
|
||||
#generate always new keys. keep in mind, keys saved in contenttranspos are overwritten
|
||||
#generate always new ilockit keys.
|
||||
if($withkey && $record->{$id}->{int11} && $record->{$id}->{int11} == 2){
|
||||
my @K_select = ();
|
||||
@K_select = `cd /var/www/copri4/main/src/scripts && export CLASSPATH='.:/usr/share/java:/usr/share/java/postgresql.jar' && java Ilockauth $varenv{dbname} $bike_id`;
|
||||
|
@ -1432,15 +1432,11 @@ sub bikes_available(){
|
|||
int10 => "1",#1 = "available"
|
||||
};
|
||||
my $tariff_content = {};
|
||||
#have to be also used without auth!, because of public bikes and stations
|
||||
#if(ref($auth) eq "HASH" && $auth->{c_id} > 0){
|
||||
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id} > 0);
|
||||
(my $bike_group,my $user_group,$tariff_content,my $user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
|
||||
my $main_ids = join(",",@{$bike_group});
|
||||
$main_ids =~ s/[a-z_-]+//ig;#should work also without Trenner
|
||||
$pref = { %$pref, main_id => "IN::($main_ids)" };
|
||||
#}
|
||||
#print Dumper($tariff_content);
|
||||
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id} > 0);
|
||||
(my $bike_group,my $user_group,$tariff_content,my $user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
|
||||
my $main_ids = join(",",@{$bike_group});
|
||||
$main_ids =~ s/[a-z_-]+//ig;#should work also without Trenner
|
||||
$pref = { %$pref, main_id => "IN::($main_ids)" };
|
||||
|
||||
if($q->param('station')){
|
||||
my $station_id = $1 if($q->param('station') =~ /(\d+)/);
|
||||
|
@ -1508,7 +1504,7 @@ sub bikes_available(){
|
|||
$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} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262);
|
||||
$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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1536,7 +1532,7 @@ sub bikes_all(){
|
|||
int10 => "!=::3",
|
||||
};
|
||||
|
||||
my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
|
||||
my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
|
||||
my $main_ids = join(",",@{$bike_group});
|
||||
$main_ids =~ s/[a-z_]+//ig;
|
||||
$pref = { %$pref, main_id => "IN::($main_ids)" };
|
||||
|
@ -1617,7 +1613,7 @@ sub stations_available(){
|
|||
|
||||
my $authed = 0;
|
||||
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
|
||||
my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
|
||||
my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
|
||||
|
||||
my $return = {};
|
||||
my $pref = {
|
||||
|
@ -1699,7 +1695,7 @@ sub stations_all(){
|
|||
|
||||
my $authed = 0;
|
||||
$authed = 1 if(ref($auth) eq "HASH" && $auth->{c_id});
|
||||
my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($auth,$q->param('authcookie'));
|
||||
my ($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv->{dbname},$auth,$q->param('authcookie'));
|
||||
|
||||
my $return={};
|
||||
my $pref = {
|
||||
|
@ -1842,6 +1838,7 @@ sub bikes_soll(){
|
|||
#Collect Tariff to get user_group----------------------
|
||||
sub fetch_tariff(){
|
||||
my $self = shift;
|
||||
my $dbname = shift;
|
||||
my $adr = shift || {};
|
||||
my $authcookie = shift || "";
|
||||
|
||||
|
@ -1849,7 +1846,6 @@ sub fetch_tariff(){
|
|||
$merchant_id = $1 if($authcookie && $authcookie =~ /\w+_(\w+)$/);
|
||||
my $tariff_content = {};
|
||||
my @user_tour = ();
|
||||
my %varenv = $cf->envonline();
|
||||
my $auth_operator = {};
|
||||
|
||||
#int18
|
||||
|
@ -1867,10 +1863,10 @@ sub fetch_tariff(){
|
|||
};
|
||||
|
||||
#if no primary address then only 2=public
|
||||
if((ref($adr) ne "HASH" || !$adr->{c_id}) && ($varenv{dbname} ne "sharee_lv")){
|
||||
if((ref($adr) ne "HASH" || !$adr->{c_id}) && ($dbname ne "sharee_lv")){
|
||||
$tariff->{int18} = 2;
|
||||
$tariff_content = $dbt->fetch_record($dbh,$tariff);
|
||||
$bw->log("1. Tariff type $tariff->{int18} select on",$varenv{dbname},"");
|
||||
$bw->log("1. Tariff type $tariff->{int18} select on",$dbname,"");
|
||||
}elsif(ref($adr) eq "HASH" && $adr->{c_id}){
|
||||
#select operators address to get users tarifnr array in txt30
|
||||
delete $tariff->{int18} if($tariff->{int18});
|
||||
|
@ -1886,25 +1882,25 @@ sub fetch_tariff(){
|
|||
if($merchant_id && $dbt->{merchant_ids}->{$merchant_id}->{id} && $dbt->{merchant_ids}->{$merchant_id}->{id} == 187){
|
||||
my $users_serviceapp = $dbt->select_users($dbh,$auth_operator->{c_id},"and int09=1");
|
||||
if($users_serviceapp->{int09}){
|
||||
$auth_operator->{txt18} =~ s/(\d+)/$dbt->{operator}->{$varenv{dbname}}->{oprefix}$1/g;
|
||||
$auth_operator->{txt18} =~ s/(\d+)/$dbt->{operator}->{$dbname}->{oprefix}$1/g;
|
||||
@user_tour = ($auth_operator->{txt18});
|
||||
@user_tour = split(/\s/,$auth_operator->{txt18}) if($auth_operator->{txt18} =~ /\s/);
|
||||
}
|
||||
}
|
||||
#$tariff->{int18} = 2;#disabled because wee need all
|
||||
$tariff->{int18} = 4 if($varenv{dbname} eq "sharee_lv");
|
||||
$tariff->{int18} = 4 if($dbname eq "sharee_lv");
|
||||
|
||||
#FIXME user tarif select have to be fetched like in net_booking
|
||||
#$tariff_content must contain tariff_description in App bikes_available listing
|
||||
$tariff_content = $dbt->fetch_record($dbh,$tariff);
|
||||
$bw->log("2. Tariff type $tariff->{int18} select on",$varenv{dbname},"");
|
||||
$bw->log("2. Tariff type $tariff->{int18} select on",$dbname,"");
|
||||
#
|
||||
}else{
|
||||
$bw->log("3. NO tariff_content on",$varenv{dbname},"");
|
||||
$bw->log("3. NO tariff_content on",$dbname,"");
|
||||
}
|
||||
|
||||
my $oprefix = "";
|
||||
$oprefix = "$dbt->{operator}->{$varenv{dbname}}->{oprefix}" if($dbt->{operator}->{$varenv{dbname}}->{oprefix});
|
||||
$oprefix = "$dbt->{operator}->{$dbname}->{oprefix}" if($dbt->{operator}->{$dbname}->{oprefix});
|
||||
|
||||
my @tarifnr = ();
|
||||
my @user_group = ();
|
||||
|
@ -1932,15 +1928,14 @@ sub fetch_tariff(){
|
|||
if(!@tarifnr && (!$dbt->{merchant_ids}->{$merchant_id}->{id} || $dbt->{merchant_ids}->{$merchant_id}->{id} != 187)){
|
||||
foreach my $id (keys (%$tariff_content)){
|
||||
if($tariff_content->{$id}->{int18} eq 2){
|
||||
$bw->log("Tarif FOUND FALLBACK for No Tarif users with merchant $merchant_id if($tariff_content->{$id}->{int12} && $varenv{dbname}) (s-type:$tariff_content->{$id}->{int18})",$id,"");
|
||||
$bw->log("Tarif FOUND FALLBACK for No Tarif users with merchant $merchant_id if($tariff_content->{$id}->{int12} && $dbname) (s-type:$tariff_content->{$id}->{int18})",$id,"");
|
||||
push(@tarifnr, "$tariff_content->{$id}->{barcode}");
|
||||
push(@user_group, "$oprefix$tariff_content->{$id}->{int12}");#sharee bike_node.main_id
|
||||
push(@bike_group, "$oprefix$tariff_content->{$id}->{int12}");#sharee bike_node.main_id
|
||||
}
|
||||
}
|
||||
}
|
||||
#$bw->log("FETCHED_Tarif by dbname:$varenv{dbname} | user_group:@user_group | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",$tariff_content,"");
|
||||
$bw->log("FETCHED_Tarif by dbname:$varenv{dbname} with merchant $merchant_id | user_group:@user_group | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",\@tarifnr,"");
|
||||
$bw->log("FETCHED_Tarif by dbname:$dbname with merchant $merchant_id | user_group:@user_group | bike_group:@bike_group | user_tour:@user_tour | tarifnr: @tarifnr",\@tarifnr,"");
|
||||
return (\@bike_group,\@user_group,$tariff_content,\@user_tour);
|
||||
}
|
||||
|
||||
|
@ -2181,7 +2176,7 @@ sub auth_verify(){
|
|||
}#end if($varenv{dbname} ne "sharee_primary")
|
||||
|
||||
if($varenv{dbname} ne "sharee_primary"){
|
||||
($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($record,$q->param('authcookie'));
|
||||
($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv{dbname},$record,$q->param('authcookie'));
|
||||
}
|
||||
|
||||
if($auth_primary->{c_id} > 0 && length($auth_primary->{txt05}) > 30){
|
||||
|
@ -2207,7 +2202,7 @@ sub auth_verify(){
|
|||
|
||||
$record = $dbt->fetch_record($dbh,$authref);
|
||||
|
||||
($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($record,$q->param('authcookie'));
|
||||
($bike_group,$user_group,$tariff_content,$user_tour) = $self->fetch_tariff($varenv{dbname},$record,$q->param('authcookie'));
|
||||
#maybe there isnt't any authcookie still available on confirm
|
||||
if ($record->{c_id} > 0){
|
||||
$return->{user_id} = $record->{txt08};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue