mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-13 15:16:38 +02:00
sig copri available
This commit is contained in:
parent
7d3c293f91
commit
9026241a24
5 changed files with 75 additions and 45 deletions
|
@ -257,8 +257,7 @@ elsif($q->param('request') eq "booking_request"){
|
|||
my $sig_book = {
|
||||
bikeId => "",
|
||||
rentalId => "",
|
||||
reservationId => ""
|
||||
};
|
||||
};
|
||||
|
||||
if($ct_bike->{barcode} && $ct_tariff->{barcode}){
|
||||
#sig reservation. not mandatory, disabled because sig seems to get confused
|
||||
|
@ -291,7 +290,6 @@ elsif($q->param('request') eq "booking_request"){
|
|||
$ctpos = $dbt->fetch_tablerecord($dbh,$booking_pos);
|
||||
#sig booking
|
||||
if($ctpos->{int11} == 3){
|
||||
#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);
|
||||
#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}' &");
|
||||
|
@ -358,7 +356,6 @@ elsif($q->param('request') eq "booking_cancel" || $q->param('request') eq "booki
|
|||
my $sig_book = {
|
||||
bikeId => $ctpos->{txt22},
|
||||
rentalId => $ctpos->{txt11},
|
||||
reservationId => ""
|
||||
};
|
||||
|
||||
if($q->param('request') eq "booking_update" && $q->param('state') && $q->param('state') =~ /canceled/){
|
||||
|
|
|
@ -27,7 +27,6 @@ use Lib::Config;
|
|||
use Mod::DBtank;
|
||||
use Mod::Basework;
|
||||
use Mod::APIfunc;
|
||||
use Mod::Shareework;
|
||||
use Data::Dumper;
|
||||
|
||||
my $q = new CGI;
|
||||
|
@ -35,7 +34,6 @@ my $json = JSON->new->allow_nonref;
|
|||
my $cf = new Config;
|
||||
my $dbt = new DBtank;
|
||||
my $apif = new APIfunc;
|
||||
my $tk = new Shareework;
|
||||
my $bw = new Basework;
|
||||
|
||||
sub new {
|
||||
|
@ -83,7 +81,7 @@ sub sig_available {
|
|||
my $td_template = $dbt->rental_description_template();
|
||||
|
||||
open(FILE,">>$varenv->{logdir}/APIsigclient.log");
|
||||
print FILE "\n0. *** $now_dt 'sig_available' \n";
|
||||
print FILE "\n0. *** $now_dt 'sig_available' ctadr: $ctadr->{c_id}\n";
|
||||
|
||||
#my $endpoint = "https://sigo.dev.sigo.green/api/v1/bikes";
|
||||
my $endpoint = "$dbt->{operator}->{$varenv->{dbname}}->{endpoint}/bikes";
|
||||
|
@ -99,7 +97,7 @@ sub sig_available {
|
|||
|
||||
if(ref($response_in) eq "HASH"){
|
||||
foreach my $resp (@{ $response_in->{items} }) {
|
||||
print FILE "response_in loop\n" . Dumper($resp) . "\n";
|
||||
print FILE "response_in loop $dbt->{operator}->{$varenv->{dbname}}->{operatorApp}\n" . $q->param('request') . "\n" . Dumper($resp) . "\n";
|
||||
|
||||
if(ref($resp->{site}) eq "HASH" && $dbt->{operator}->{$varenv->{dbname}}->{operatorApp} && $q->param('request') eq "stations_available"){
|
||||
|
||||
|
@ -151,8 +149,7 @@ sub sig_available {
|
|||
$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
|
||||
|
||||
|
@ -165,6 +162,7 @@ sub sig_available {
|
|||
$bike_id =~ s/S[1-9]X/SX/;
|
||||
$bike_id = $1 if($bike_id =~ /(\d+)/);
|
||||
|
||||
print FILE "bike_group $bike_id | $resp->{site}->{id} | @{$bike_group}[0]\n";
|
||||
if($bike && looks_like_number($bike_id) && looks_like_number($resp->{site}->{id}) && ref($bike_group) eq "ARRAY" && @{$bike_group}[0]){
|
||||
print FILE "Bike: $bike\n";
|
||||
$response_out->{$bike}->{bike} = "$bike";
|
||||
|
@ -441,7 +439,6 @@ sub sig_booking {
|
|||
$sig_book = {
|
||||
bikeId => "",
|
||||
rentalId => "",
|
||||
reservationId => ""
|
||||
};
|
||||
print FILE "<--- $now_dt failure sig_booking sig_post $todo , reset sig_book hash to empty\n";
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ sub channel_map(){
|
|||
my $channel = {
|
||||
167 => "sig cmd",
|
||||
168 => "shareeio",
|
||||
169 => "sig connector",
|
||||
169 => "sigo connector",
|
||||
172 => "reserve timeout",
|
||||
#173 => "merchant fallback",#mig
|
||||
#175 => "example App",#mig
|
||||
|
@ -1375,7 +1375,7 @@ sub insert_pos(){
|
|||
my $sth;
|
||||
#Verleihräder
|
||||
if($ct->{template_id} && $ct->{template_id} == 205){#Leihrad_list
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,txt12,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int17,int15,int16,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt10,txt11,int35,int36,int37,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}','$prefix',now(),now(),'$endRental','$unit_price','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$free_hours','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$sig_book->{bikeId}','$sig_book->{reservationId}','$sig_book->{rentalId}','$unit_price1','$unit_price2','$start_price','$unit_time','$free_time') RETURNING c_id");
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt01,txt08,txt02,txt09,txt12,itime,start_time,end_time,int02,int03,int06,int04,txt05,txt06,txt07,int10,int12,int13,owner,int07,txt04,int09,int17,int15,int16,int11,int18,int19,txt17,txt18,int20,int25,int34,txt22,txt11,int35,int36,int37,time01,time02) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','$ct->{barcode}','$ct->{txt01}','$user_name','$ct->{txt02}','$ctadr->{txt09}','$prefix',now(),now(),'$endRental','$unit_price','$menge','$station','$station','$ct->{txt06}','$ct->{txt06}','$ct->{txt07}','$status','$from_main_id','$deviceId','$owner','$rabatt','$tariff_desc','$tariff_nr','$daymax_price','$abo_price','$free_hours','$ct->{int11}','$sharing_type','$bike_charge','$ct->{txt17}','$ct->{txt18}','$ct->{int20}','$trackon','$staff','$sig_book->{bikeId}','$sig_book->{rentalId}','$unit_price1','$unit_price2','$start_price','$unit_time','$free_time') RETURNING c_id");
|
||||
}else{
|
||||
$sth = $dbh->prepare("INSERT INTO contenttranspos (ct_id,cc_id,ca_id,ct_name,barcode,txt08,txt09,itime,int02,int03,txt01,txt06,txt07,int10,int12,owner) VALUES ('$ctt_id','$ct->{c_id}','$ctadr->{c_id}','$ct_name','0','$user_name','$ctadr->{txt09}',now(),'$unit_price','1','$ct->{txt01}','$ct->{txt06}','$ct->{txt07}','0','$from_main_id','$owner') RETURNING c_id");
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ use Mod::DBtank;
|
|||
use Mod::Basework;
|
||||
use Mod::APIfunc;
|
||||
use Mod::Pricing;
|
||||
use Mod::APIsigclient;
|
||||
use Data::Dumper;
|
||||
|
||||
my $cf = new Config;
|
||||
|
@ -32,6 +33,7 @@ my $dbt = new DBtank;
|
|||
my $bw = new Basework;
|
||||
my $apif = new APIfunc;
|
||||
my $pri = new Pricing;
|
||||
my $si = new APIsigclient;
|
||||
my $q = new CGI;
|
||||
|
||||
sub new {
|
||||
|
@ -113,8 +115,8 @@ sub save_contenttranspos {
|
|||
"ct.close_time" => "is::null",
|
||||
};
|
||||
|
||||
my $record_pos = {};
|
||||
$record_pos = $dbt->collect_post($dbh,$pref);
|
||||
my $ctpos = {};
|
||||
$ctpos = $dbt->collect_post($dbh,$pref);
|
||||
|
||||
my $pricing = {};
|
||||
my $counting = {};
|
||||
|
@ -125,12 +127,32 @@ sub save_contenttranspos {
|
|||
owner_end => $owner,
|
||||
mtime => "now()",
|
||||
};
|
||||
$u_rows += $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||
|
||||
#if sig
|
||||
if($ctpos->{int11} == 3 && $ctpos->{ca_id}){
|
||||
#sig booking_request
|
||||
my $sig_book = {
|
||||
bikeId => "",
|
||||
rentalId => "",
|
||||
};
|
||||
if(looks_like_number($R::int10) && $R::int10 == 1){
|
||||
my $authref = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
template_id => "202",
|
||||
c_id => "=::$ctpos->{ca_id}",
|
||||
};
|
||||
my $authraw = {};
|
||||
$authraw = $dbt->fetch_record($dbh,$authref);
|
||||
$sig_book = $si->sig_booking(\%varenv,"reserve_end",$authraw,"",$ctpos);
|
||||
}
|
||||
}else{
|
||||
$u_rows += $dbt->update_record($dbh,$update_pos,$ctpos);
|
||||
}
|
||||
#again to get setted date-times
|
||||
$record_pos = $dbt->collect_post($dbh,$pref);
|
||||
$ctpos = $dbt->collect_post($dbh,$pref);
|
||||
|
||||
($pricing,$counting) = $pri->counting_rental(\%varenv,$record_pos,"calc_price");
|
||||
($pricing,$counting) = $pri->counting_rental(\%varenv,$ctpos,"calc_price");
|
||||
$update_pos->{int38} = "$counting->{int38}" if(looks_like_number($counting->{int38}));
|
||||
$update_pos->{int39} = "$counting->{int39}" if(looks_like_number($counting->{int39}));
|
||||
$update_pos->{int40} = "$counting->{int40}" if(looks_like_number($counting->{int40}));
|
||||
|
@ -153,15 +175,15 @@ sub save_contenttranspos {
|
|||
"ct.close_time" => "is::null",
|
||||
};
|
||||
|
||||
my $record_pos2ck = { c_id => 0 };
|
||||
$record_pos2ck = $dbt->collect_post($dbh,$pref2ck);
|
||||
my $ctpos2ck = { c_id => 0 };
|
||||
$ctpos2ck = $dbt->collect_post($dbh,$pref2ck);
|
||||
|
||||
#update bike content only if there is no later rental start
|
||||
if($record_pos->{cc_id} && !$record_pos2ck->{c_id}){
|
||||
if($ctpos->{cc_id} && !$ctpos2ck->{c_id}){
|
||||
my $ctpref = {
|
||||
table => "content",
|
||||
fetch => "one",
|
||||
c_id => $record_pos->{cc_id},
|
||||
c_id => $ctpos->{cc_id},
|
||||
};
|
||||
my $ctbike = $dbt->fetch_tablerecord($dbh,$ctpref);
|
||||
|
||||
|
@ -171,19 +193,20 @@ sub save_contenttranspos {
|
|||
|
||||
$ctpref->{owner} = $owner;
|
||||
$ctpref->{mtime} = "now()";
|
||||
|
||||
$u_rows += $dbt->update_record($dbh,$ctpref,$ctbike);
|
||||
$feedb->{message} = "Mietdaten gespeichert und Mietrad Stati in Warenstamm übernommen";
|
||||
}else{
|
||||
$feedb->{message} = "Mietdaten gespeichert. Achtung, Mietrad Stati in Warenstamm NICHT übernommen, da es sich nicht um die letzte Miete handelt";
|
||||
}
|
||||
|
||||
$u_rows += $dbt->update_record($dbh,$update_pos,$record_pos);
|
||||
$u_rows += $dbt->update_record($dbh,$update_pos,$ctpos);
|
||||
|
||||
#
|
||||
if($record_pos->{ct_id}){
|
||||
if($ctpos->{ct_id}){
|
||||
my $ctpref = {
|
||||
table => "contenttrans",
|
||||
c_id => $record_pos->{ct_id},
|
||||
c_id => $ctpos->{ct_id},
|
||||
start_time => "$start_time",
|
||||
end_time => "$end_time",
|
||||
owner => $owner,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue