mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 15:16:38 +02:00
fetch_merchant on primary API request
This commit is contained in:
parent
67dda28bb6
commit
20048865c0
3 changed files with 119 additions and 57 deletions
|
@ -52,87 +52,61 @@ my $dbh = "";
|
|||
#fetch merchant_id by request or hostname
|
||||
sub fetch_merchant {
|
||||
my $self = shift;
|
||||
my $q = shift;
|
||||
my $varenv = shift;
|
||||
my $req_sessionid = shift || "";
|
||||
my $req_authcookie = shift || "";
|
||||
my $req_coo = shift || "";
|
||||
my $req_merchant_id = shift || "";
|
||||
|
||||
my $response = {
|
||||
user_id => "",
|
||||
authcookie => "",
|
||||
new_authcoo => "0",
|
||||
clearing_cache => "0",
|
||||
agb_checked => "0",
|
||||
user_group => [],
|
||||
user_tour => [],
|
||||
response_state => "OK, nothing todo",
|
||||
privacy_html => "site/privacy_1.html",
|
||||
agb_html => "site/agb.html",
|
||||
impress_html => "site/impress.html",
|
||||
tariff_info_html => "site/tariff_info_1.html",
|
||||
bike_info_html => "site/bike_info.html",
|
||||
lang => "DE",
|
||||
last_used_operator => {
|
||||
operator_name => "sharee.bike | TeilRad GmbH",
|
||||
operator_color => "#009699",
|
||||
operator_email => "hotline\@sharee.bike",
|
||||
operator_phone => "+49 761 45370097",
|
||||
operator_hours => "Bürozeiten: Montag, Mittwoch, Freitag 9-12 Uhr",
|
||||
},
|
||||
init_map => {
|
||||
center => { latitude => "", longitude => "" },
|
||||
radius => ""
|
||||
}
|
||||
};
|
||||
|
||||
my $return = { merchant_id => "" };
|
||||
my $merchanized = 0;
|
||||
my $aowner = 0;
|
||||
my $merchant_id = "";
|
||||
|
||||
|
||||
while ((my $merchant_conf, my $value) = each %{ $dbt->{merchant_ids}}) {
|
||||
if($merchant_conf && (($req_sessionid && $req_sessionid =~ /$merchant_conf$/) || ($req_authcookie && $req_authcookie =~ /$merchant_conf$/) || ($req_merchant_id && $req_merchant_id eq $merchant_conf))){
|
||||
$bw->log("---> trying merchant select by session-cookie OR authcookie OR merchant_id: if($merchant_conf && (($req_coo && $req_coo =~ /$merchant_conf/) || ($req_merchant_id && $req_merchant_id eq $merchant_conf))){",$merchant_conf,"");
|
||||
|
||||
if($merchant_conf && (($req_coo && $req_coo =~ /$merchant_conf$/) || ($req_merchant_id && $req_merchant_id eq $merchant_conf))){
|
||||
$aowner = $value->{id};
|
||||
$merchant_id = $merchant_conf;
|
||||
$merchanized = 1;
|
||||
$return->{merchant_id} = $merchant_conf;
|
||||
my $lat = "";
|
||||
my $lng = "";
|
||||
$value->{initMap} =~ s/\s//g;
|
||||
($lat,$lng) = split(/,/,$value->{initMap}) if($value->{initMap} && $value->{initMap} =~ /\d+,\d+/);
|
||||
if($lat && $lng){
|
||||
$response->{init_map}->{center}->{latitude} = $lat;
|
||||
$response->{init_map}->{center}->{longitude} = $lng;
|
||||
$response->{init_map}->{radius} = "2.9";
|
||||
$return->{init_map}->{center}->{latitude} = $lat;
|
||||
$return->{init_map}->{center}->{longitude} = $lng;
|
||||
$return->{init_map}->{radius} = "2.9";
|
||||
}
|
||||
$bw->log("merchant select by session-cookie OR authcookie OR merchant_id: if($merchant_conf && (($req_sessionid && $req_sessionid =~ /$merchant_conf$/) || ($req_authcookie && $req_authcookie =~ /$merchant_conf$/) || ($req_merchant_id && $req_merchant_id eq $merchant_conf))){",$merchant_conf,"");
|
||||
last;
|
||||
$bw->log("===> merchant select by session-cookie OR authcookie OR merchant_id: if($merchant_conf && (($req_coo && $req_coo =~ /$merchant_conf/) || ($req_merchant_id && $req_merchant_id eq $merchant_conf))){",$return->{merchant_id},"");
|
||||
#last;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$merchanized){
|
||||
if($varenv->{syshost} eq "shareeapp-primary" || $varenv->{syshost} eq "shareedms-primary"){
|
||||
$aowner = $dbt->{primary}->{sharee_primary}->{owner};
|
||||
$merchant_id = $dbt->{primary}->{sharee_primary}->{merchant_id};
|
||||
$return->{merchant_id} = $dbt->{primary}->{sharee_primary}->{merchant_id};
|
||||
$merchanized = 1;
|
||||
$bw->log("merchant select by primary dbname: sharee_primary:",$merchant_id,"");
|
||||
$bw->log("merchant select by primary dbname: sharee_primary:",$return->{merchant_id},"");
|
||||
}
|
||||
elsif($varenv->{syshost} =~ /shareeapp-(\w+)/ || $varenv->{syshost} =~ /shareedms-(\w+)/){
|
||||
$aowner = $dbt->{operator}->{$varenv->{dbname}}->{owner};
|
||||
$merchant_id = $dbt->{operator}->{$varenv->{dbname}}->{merchant_id};
|
||||
$return->{merchant_id} = $dbt->{operator}->{$varenv->{dbname}}->{merchant_id};
|
||||
$merchanized = 1;
|
||||
$bw->log("merchant select by operator dbname=$varenv->{dbname}:",$merchant_id,"");
|
||||
$bw->log("merchant select by operator dbname=$varenv->{dbname}:",$return->{merchant_id},"");
|
||||
}
|
||||
elsif($varenv->{syshost} =~ /shareeweb-/){
|
||||
$aowner = $dbt->{website}->{$varenv->{syshost}}->{owner};
|
||||
$merchant_id = $dbt->{website}->{$varenv->{syshost}}->{merchant_id};
|
||||
$return->{merchant_id} = $dbt->{website}->{$varenv->{syshost}}->{merchant_id};
|
||||
$merchanized = 1;
|
||||
$bw->log("merchant select by website syshost=$varenv->{syshost}:",$merchant_id,"");
|
||||
$bw->log("===> merchant select by website syshost=$varenv->{syshost}:",$return->{merchant_id},"");
|
||||
}
|
||||
}
|
||||
|
||||
return ($aowner,$merchant_id,$response);
|
||||
return ($aowner,$return);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#helper to get template
|
||||
sub get_node_meta {
|
||||
my $self = shift;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue