mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-11 06:17:27 +02:00
shareeweb-ren, Mlogic and sigo_cupdate
This commit is contained in:
parent
fd29218991
commit
d06556bd60
11 changed files with 125 additions and 79 deletions
|
@ -805,7 +805,7 @@ sub booking_update(){
|
|||
station_state => "",
|
||||
co2saving => "",
|
||||
response_state => "OK 1017: No update",
|
||||
response_text => "Es wurden keine Daten aktualisiert",
|
||||
response_text => "Der Mietstatus wurde nicht geändert.",
|
||||
};
|
||||
|
||||
my $pref = {
|
||||
|
@ -945,7 +945,9 @@ sub booking_update(){
|
|||
$ct_state = $state_key;
|
||||
|
||||
|
||||
}elsif($gps && $gps_age_minutes <= 3){#client GPS must have
|
||||
}
|
||||
#client GPS must have. sigo ist done without client gps
|
||||
elsif(($gps && $gps_age_minutes <= 3) || ($record_pos->{int11} == 3)){
|
||||
#geofencing for Ilockit
|
||||
my $geo_distance_next = 100000;
|
||||
my $station_next = 0;
|
||||
|
@ -954,9 +956,9 @@ sub booking_update(){
|
|||
foreach my $id (sort { $stations_raw->{$a}->{barcode} <=> $stations_raw->{$b}->{barcode} } keys (%$stations_raw)){
|
||||
my $latitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /^(\d+\.\d+)/);
|
||||
my $longitude_station = $1 if($stations_raw->{$id}->{txt06} =~ /(\d+\.\d+)$/);
|
||||
if(!looks_like_number($latitude) || !looks_like_number($longitude)){
|
||||
if((!looks_like_number($latitude) || !looks_like_number($longitude)) && ($record_pos->{int11} != 3)){
|
||||
$geo_debug .= "ERROR no user GPS: $stations_raw->{$id}->{barcode}|$latitude,$longitude,$latitude_station,$longitude_station --> $geo_distance Meter\n";
|
||||
}elsif(looks_like_number($latitude) && looks_like_number($longitude) && looks_like_number($latitude_station) && looks_like_number($longitude_station)){
|
||||
}elsif((looks_like_number($latitude) && looks_like_number($longitude) && looks_like_number($latitude_station) && looks_like_number($longitude_station)) || ($record_pos->{int11} == 3)){
|
||||
$update_pos->{owner_end} = "$owner";
|
||||
$update_pos->{end_time} = "now()";
|
||||
|
||||
|
@ -1025,8 +1027,8 @@ sub booking_update(){
|
|||
#print "$geo_debug\n";
|
||||
$bw->log("GEOfencing geo_debug:$geo_debug",$q,"");
|
||||
|
||||
#end if gps && gps_age <= 3
|
||||
}else{
|
||||
#end if gps && gps_age <= 3 and not sigo
|
||||
}elsif($record_pos->{int11} != 3){
|
||||
if(!$gps){
|
||||
$booking_values->{response_state} = "Failure 2245: No GPS data, state change forbidden.";
|
||||
$booking_values->{response_text} = "Fehler! Keine GPS Standortdaten, Die Miete Fahrrad Nr. " . $q->param('bike') . " kann wegen fehlendem GPS nicht $state_text werden. Bitte aktivieren Sie das GPS.";
|
||||
|
|
|
@ -435,7 +435,8 @@ elsif($q->param('request') eq "bikes_available"){
|
|||
$bw->log("Y bikes_available by c_id $authraw->{c_id}, Tarif:",$authraw->{txt30},"");
|
||||
|
||||
if($varenv{syshost} eq "shareeapp-sx"){
|
||||
$response->{bikes} = $si->sigo_available($q,\%varenv,$authraw);
|
||||
($response->{bikes},my $return2copri->{bikes}) = $si->sigo_available($q,\%varenv,$authraw);
|
||||
$tk->sigobike_cupdate($return2copri->{bikes});
|
||||
}else{
|
||||
$response->{bikes} = $apif->bikes_available($q,\%varenv,$authraw);
|
||||
}
|
||||
|
|
|
@ -77,7 +77,8 @@ sub sigo_available {
|
|||
my $endpoint = "$dbt->{operator}->{$varenv->{dbname}}->{endpoint}/bikes";
|
||||
|
||||
|
||||
my $return = {};
|
||||
my $response_out = {};
|
||||
my $return2copri = {};
|
||||
my $rest_json = "";
|
||||
my $ret_json = get_sigo("$endpoint",$rest_json);
|
||||
eval {
|
||||
|
@ -95,23 +96,23 @@ sub sigo_available {
|
|||
my $station = "SX$resp->{site}->{id}";
|
||||
if($station && looks_like_number($resp->{site}->{id}) && $resp->{site}->{status} eq "ACTIVE" && $resp->{site}->{lat} && $resp->{site}->{lon}){
|
||||
print FILE "Station: $station\n";
|
||||
$return->{$station}->{station} = "$station";
|
||||
$return->{$station}->{authed} = "$authed";
|
||||
$return->{$station}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
$return->{$station}->{description} = "$resp->{site}->{address}" || "";
|
||||
$return->{$station}->{station_group} = ["SX300102"];#E-Lastenrad
|
||||
$return->{$station}->{gps}->{latitude} = "$resp->{site}->{lat}" || "";
|
||||
$return->{$station}->{gps}->{longitude} = "$resp->{site}->{lon}" || "";
|
||||
$return->{$station}->{gps_radius} = "75";
|
||||
$return->{$station}->{state} = "defect";
|
||||
$response_out->{$station}->{station} = "$station";
|
||||
$response_out->{$station}->{authed} = "$authed";
|
||||
$response_out->{$station}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
$response_out->{$station}->{description} = "$resp->{site}->{address}" || "";
|
||||
$response_out->{$station}->{station_group} = ["SX300102"];#E-Lastenrad
|
||||
$response_out->{$station}->{gps}->{latitude} = "$resp->{site}->{lat}" || "";
|
||||
$response_out->{$station}->{gps}->{longitude} = "$resp->{site}->{lon}" || "";
|
||||
$response_out->{$station}->{gps_radius} = "75";
|
||||
$response_out->{$station}->{state} = "defect";
|
||||
if($resp->{site}->{status} eq "ACTIVE"){#?
|
||||
$return->{$station}->{state} = "available";
|
||||
$response_out->{$station}->{state} = "available";
|
||||
}elsif($resp->{site}->{status} eq "MAINTANANCE"){
|
||||
$return->{$station}->{state} = "maintanance";
|
||||
$response_out->{$station}->{state} = "maintanance";
|
||||
}elsif($resp->{site}->{status} eq "OFFLINE"){
|
||||
$return->{$station}->{state} = "defect";
|
||||
$response_out->{$station}->{state} = "defect";
|
||||
}
|
||||
$return->{$station}->{operator_data} = {};
|
||||
$response_out->{$station}->{operator_data} = {};
|
||||
|
||||
}
|
||||
}#end stations_available
|
||||
|
@ -122,45 +123,45 @@ sub sigo_available {
|
|||
my $bike = "SX$resp->{mobile_bike_id}";
|
||||
if($bike && looks_like_number($resp->{mobile_bike_id}) && $resp->{status} eq "ACTIVE"){
|
||||
print FILE "Bike: $bike\n";
|
||||
$return->{$bike}->{bike} = "$bike";
|
||||
$return->{$bike}->{authed} = "$authed";
|
||||
$return->{$bike}->{station} = "SX$resp->{site}->{id}" || "";
|
||||
$return->{$bike}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
$return->{$bike}->{description} = "E-Lastenrad";
|
||||
$return->{$bike}->{gps}->{latitude} = "$resp->{state}->{lat}" || "";
|
||||
$return->{$bike}->{gps}->{longitude} = "$resp->{state}->{lon}" || "";
|
||||
$return->{$bike}->{bike_charge} = "$resp->{energy_level}" || "0";
|
||||
$return->{$bike}->{state} = "defect";
|
||||
$response_out->{$bike}->{bike} = "$bike";
|
||||
$response_out->{$bike}->{authed} = "$authed";
|
||||
$response_out->{$bike}->{station} = "SX$resp->{site}->{id}" || "";
|
||||
$response_out->{$bike}->{uri_operator} = "$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}";
|
||||
$response_out->{$bike}->{description} = "E-Lastenrad";
|
||||
$response_out->{$bike}->{gps}->{latitude} = "$resp->{state}->{lat}" || "";
|
||||
$response_out->{$bike}->{gps}->{longitude} = "$resp->{state}->{lon}" || "";
|
||||
$response_out->{$bike}->{bike_charge} = "$resp->{energy_level}" || "0";
|
||||
$response_out->{$bike}->{state} = "defect";
|
||||
if($resp->{status} eq "ACTIVE"){#?
|
||||
$return->{$bike}->{state} = "available";
|
||||
$response_out->{$bike}->{state} = "available";
|
||||
}elsif($resp->{status} eq "MAINTANANCE"){
|
||||
$return->{$bike}->{state} = "maintanance";
|
||||
$response_out->{$bike}->{state} = "maintanance";
|
||||
}elsif($resp->{status} eq "OFFLINE"){
|
||||
$return->{$bike}->{state} = "defect";
|
||||
$response_out->{$bike}->{state} = "defect";
|
||||
}elsif($resp->{status} eq "OPERATION"){#?
|
||||
$return->{$bike}->{state} = "occupied";
|
||||
$response_out->{$bike}->{state} = "occupied";
|
||||
}
|
||||
|
||||
#$return->{$bike}->{lock_state} = "undefined";#?
|
||||
#$return->{$bike}->{lock_state} = "unlocked";# I think default should be unlocked
|
||||
$return->{$bike}->{lock_state} = "locked";
|
||||
#$response_out->{$bike}->{lock_state} = "undefined";#?
|
||||
#$response_out->{$bike}->{lock_state} = "unlocked";# I think default should be unlocked
|
||||
$response_out->{$bike}->{lock_state} = "locked";
|
||||
if($resp->{state}->{locked}){
|
||||
$return->{$bike}->{lock_state} = "locked";
|
||||
$response_out->{$bike}->{lock_state} = "locked";
|
||||
}
|
||||
$return->{$bike}->{system} = "sigo";
|
||||
$return->{$bike}->{bike_group} = ["SX300102"];#E-Lastenrad
|
||||
$return->{$bike}->{unlock_allowed} = "1";
|
||||
$return->{$bike}->{tariff_description} = {};
|
||||
$response_out->{$bike}->{system} = "sigo";
|
||||
$response_out->{$bike}->{bike_group} = ["SX300102"];#E-Lastenrad
|
||||
$response_out->{$bike}->{unlock_allowed} = "1";
|
||||
$response_out->{$bike}->{tariff_description} = {};
|
||||
if(ref($tariff_content) eq "HASH"){
|
||||
foreach my $tid (sort { $tariff_content->{$a}->{barcode} <=> $tariff_content->{$b}->{barcode} } keys (%$tariff_content)){
|
||||
$return->{$bike}->{tariff_description}->{name} = "$tariff_content->{$tid}->{ct_name}";
|
||||
$return->{$bike}->{tariff_description}->{number} = "$tariff_content->{$tid}->{barcode}";
|
||||
$return->{$bike}->{tariff_description}->{eur_per_hour} = "$tariff_content->{$tid}->{int02}" || "0";
|
||||
$return->{$bike}->{tariff_description}->{max_eur_per_day} = "$tariff_content->{$tid}->{int17}" if($tariff_content->{$tid}->{int17});
|
||||
$return->{$bike}->{tariff_description}->{free_hours} = "$tariff_content->{$tid}->{int16}" if($tariff_content->{$tid}->{int16});
|
||||
$return->{$bike}->{tariff_description}->{abo_eur_per_month} = "$tariff_content->{$tid}->{int15}" if($tariff_content->{$tid}->{int15});
|
||||
$response_out->{$bike}->{tariff_description}->{name} = "$tariff_content->{$tid}->{ct_name}";
|
||||
$response_out->{$bike}->{tariff_description}->{number} = "$tariff_content->{$tid}->{barcode}";
|
||||
$response_out->{$bike}->{tariff_description}->{eur_per_hour} = "$tariff_content->{$tid}->{int02}" || "0";
|
||||
$response_out->{$bike}->{tariff_description}->{max_eur_per_day} = "$tariff_content->{$tid}->{int17}" if($tariff_content->{$tid}->{int17});
|
||||
$response_out->{$bike}->{tariff_description}->{free_hours} = "$tariff_content->{$tid}->{int16}" if($tariff_content->{$tid}->{int16});
|
||||
$response_out->{$bike}->{tariff_description}->{abo_eur_per_month} = "$tariff_content->{$tid}->{int15}" if($tariff_content->{$tid}->{int15});
|
||||
#TODO, have to be set on Tarif table
|
||||
$return->{$bike}->{tariff_description}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber <a href='$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}/site/agb.html' target='_blank'>AGB</a> zugestimmt (Demo)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
|
||||
$response_out->{$bike}->{tariff_description}->{operator_agb} = "Mit der Mietrad Anmietung wird folgender Betreiber <a href='$dbt->{operator}->{$varenv->{dbname}}->{operatorApp}/site/agb.html' target='_blank'>AGB</a> zugestimmt (Demo)." if($auth->{c_id} && ($auth->{c_id} == 1842 || $auth->{c_id} == 5781 || $auth->{c_id} == 22262));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,10 +175,10 @@ sub sigo_available {
|
|||
warn $@;
|
||||
}
|
||||
|
||||
print FILE "response_in return\n" . Dumper($return) . "\n";
|
||||
print FILE "response_out from response_in\n" . Dumper($response_out) . "\n";
|
||||
close(FILE);
|
||||
|
||||
return $return;
|
||||
return ($response_out,$return2copri);
|
||||
}
|
||||
|
||||
#main GET
|
||||
|
|
|
@ -203,7 +203,8 @@ sub update_operatorsloop {
|
|||
#}
|
||||
}
|
||||
}
|
||||
}
|
||||
}#end of reminder
|
||||
|
||||
}
|
||||
}elsif($todo eq "delete"){
|
||||
$bw->log("DELETE adr from operators and at last primary $sharee_operator",$record_primary,"");
|
||||
|
@ -847,15 +848,17 @@ sub update_record(){
|
|||
my $rows = 0;
|
||||
|
||||
#print Dumper($update);
|
||||
if(looks_like_number($record->{c_id})){
|
||||
$where = "where c_id = $record->{c_id}";
|
||||
if(looks_like_number($record->{c_id}) || (looks_like_number($record->{barcode}) && $record->{barcode} > 0)){
|
||||
if($record->{c_id}){
|
||||
$where = "where c_id = $record->{c_id}";
|
||||
}else{
|
||||
$where = "where barcode = $record->{barcode}";
|
||||
}
|
||||
foreach my $key (keys %$update){
|
||||
$update->{$key} =~ s/^\s//g if($update->{$key});
|
||||
$update->{$key} =~ s/\s$//g if($update->{$key});
|
||||
my $value = $update->{$key} || "";
|
||||
$value = "$update->{$key}" if(looks_like_number($update->{$key}));
|
||||
#my $value = $q->escapeHTML($update->{$key});#In DB context will always done by API
|
||||
#print "$key=$value|$update->{$key}<br />\n";
|
||||
if($key =~ /^(ct_name$|txt\d+|state|start_time|end_time|byte)/){
|
||||
if($value && $value eq "null"){
|
||||
$set .= " $key=$value,";
|
||||
|
|
|
@ -203,9 +203,9 @@ sub new_relation {
|
|||
if($template_id == 205){
|
||||
$prefix_id++;
|
||||
my $new_submain_id = $dbt->get_freenode($dbh,$prefix_id);
|
||||
my $new_subtemplate_id = $dbt->get_freetpl($dbh,"400","499");
|
||||
my $new_subtemplate_id = $dbt->get_freetpl($dbh,"401","499");
|
||||
|
||||
my $ret_tpl_id = $dbt->copy_template($dbh,"400",$new_subtemplate_id,$owner);
|
||||
my $ret_tpl_id = $dbt->copy_template($dbh,"401",$new_subtemplate_id,$owner);
|
||||
|
||||
my $insert_sub = {
|
||||
main_id => $new_submain_id,
|
||||
|
|
|
@ -1034,6 +1034,34 @@ sub send_password(){
|
|||
|
||||
}
|
||||
|
||||
#TODO, not ready!
|
||||
sub sigobike_cupdate {
|
||||
my $self = shift;
|
||||
my $record_sigo = shift;
|
||||
my $dbh = "";
|
||||
|
||||
my $rows = 0;
|
||||
foreach my $bid (keys (%$record_sigo)){
|
||||
my $update = {
|
||||
%{$record_sigo->{$bid}},
|
||||
table => "content",
|
||||
template_id => "205",
|
||||
main_id => "300102",
|
||||
mtime => "now()",
|
||||
owner => "169",
|
||||
};
|
||||
|
||||
$bw->log("UPDATE content from record_sigo with bike nr:",$record_sigo->{$bid}->{barcode},"");
|
||||
#$rows = $self->update_record($dbh,$update,$record_sigo->{$bid}->{barcode});
|
||||
if($rows != 1){
|
||||
my $c_id = "";
|
||||
$bw->log("INSERT content from record_sigo with bike nr:",$record_sigo->{$bid}->{barcode},"");
|
||||
#$c_id = $self->insert_contentoid($dbh,$update,"");
|
||||
$rows = 1 if($c_id);
|
||||
}
|
||||
}
|
||||
return $rows;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
@ -87,13 +87,16 @@ sub tpl(){
|
|||
($cttpos,$rows) = $db->collect_contentpos("contenttrans",$rel4tpl->{content_id});
|
||||
|
||||
foreach my $id (keys(%$cttpos)){
|
||||
if(ref($cttpos->{$id}) eq "HASH"){
|
||||
if($cttpos->{$id}->{int26}){
|
||||
@tpl_order = ("txt01=Beschreibung","ct_name=Nummer","date_time=Mietzeit","int26=Einsparung","int03=Menge","int02=Preis","int07=Rabatt","int04=Gesamt");
|
||||
}
|
||||
}else{
|
||||
$lb->failure3("Der selekt einer Verkaufsposition ist fehlgeschlagen, errocode ($rel4tpl->{content_id} | $users_dms->{c_id4trans} | $node_meta->{tpl_id}). Bitte admin kontaktieren");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($varenv{orga} eq "dms"){#obsolete after migrating lx-rad and mobile ...
|
||||
print<<EOF
|
||||
<style>
|
||||
.ui-autocomplete {
|
||||
|
@ -118,7 +121,6 @@ print<<EOF
|
|||
</script>
|
||||
EOF
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
print $q->start_table({-class=>'list', -border=>'0', -width=>'100%',-align=>'left', -cellpadding=>'3', -cellspacing=>'0'});
|
||||
|
|
|
@ -175,7 +175,11 @@ if($operator_key eq "sharee_kn"){
|
|||
$latitude = "47.66267";
|
||||
$longitude = "9.17262";
|
||||
}
|
||||
|
||||
if($operator_key eq "sharee_wue"){
|
||||
$bike = "WUE5529";
|
||||
$latitude = "47.997930";
|
||||
$longitude = "7.785428";
|
||||
}
|
||||
print $q->div({-style=>'margin:15px;'},"-------------- $uriop --------------------"),"\n";
|
||||
my $booking_request = "$uriop?request=booking_request&bike=$bike&authcookie=$coo";
|
||||
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_request"},"[ booking_request ]---> $booking_request")),"\n";
|
||||
|
@ -199,6 +203,9 @@ print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$bookin
|
|||
my $booking_update_av_lo = "$uriop?request=booking_update&bike=$bike&state=available&lock_state=locked$and_station_state_locked&latitude=$latitude&longitude=$longitude&gps_age=300&user_device_manufaturer=samsung)&user_device_model=SM-G398FN&user_device_platform=Android&user_device_version=10&user_device_id=90af86831c10374d&authcookie=$coo";
|
||||
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_av_lo"},"[ booking_update_av_lo ]---> $booking_update_av_lo")),"\n";
|
||||
|
||||
my $booking_update_av_lo_nogps = "$uriop?request=booking_update&bike=$bike&state=available&lock_state=locked$and_station_state_locked&user_device_manufaturer=samsung)&user_device_model=SM-G398FN&user_device_platform=Android&user_device_version=10&user_device_id=90af86831c10374d&authcookie=$coo";
|
||||
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$booking_update_av_lo_nogps"},"[ booking_update_av_lo_nogps ]---> $booking_update_av_lo_nogps")),"\n";
|
||||
|
||||
my $user_feedback = "$uriop?request=user_feedback&bike=$bike&bike_broken=1&message=testnachricht äöü&authcookie=$coo";
|
||||
print $q->div({-style=>'margin:15px;'},$q->a({-target=>'_blank', -href=>"$user_feedback"},"[ user_feedback ]---> $user_feedback")),"\n";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue