BVB activation-code and auto-coupon

This commit is contained in:
ragu 2023-04-27 15:09:16 +02:00
parent bf83052322
commit d264925ad5
4 changed files with 72 additions and 12 deletions

View file

@ -973,6 +973,37 @@ sub booking_request(){
c_id => $ctt->{c_id},
};
$dbt->update_one($dbh,$update_ctt,"start_time='$now_dt'");
#BVB once auto-coupon until 2023-08-31
if($varenv->{dbname} eq "sharee_bvb"){
#BVB 3-Stunden-Freifahrt
my $auto_coupon = "123";
my $pref_co = {
table => "content",
fetch => "one",
template_id => "224",
int03 => ">::0",
barcode => "$auto_coupon",
};
my $ct_co = { c_id => 0 };
$ct_co = $dbt->fetch_record($dbh,$pref_co);
$ct_co->{int02} *= -1 if($ct_co->{int02} > 0);#coupon price must be negate
my $pos_co = {
table => "contenttranspos",
fetch => "one",
ca_id => "$auth->{c_id}",
barcode => "$auto_coupon",
};
my $co_pos = { c_id => 0 };
$co_pos = $dbt->fetch_tablerecord($dbh,$pos_co);
if($ct_co->{c_id} && !$co_pos->{c_id}){
$pos_id = $dbt->insert_pos($dbh,$ctt->{c_id},$ct_co,"",$auth,"","","","0",$owner);
$dbt->update_content4comp($dbh,$ct_co->{c_id},"-","1");
}
}#end BVB auto-coupon
}else{
$response_state="Failure 1007: booking request fails";
$response_text="Entschuldigung, es ist ein Fehler aufgetreten. Bitte kontaktieren Sie unsere hotline damit wir das Problem lösen können";

View file

@ -115,9 +115,15 @@ sub handler {
print $q->header(-charset=>"$html_charset", -cookie=>$cookie);
}
(my $aowner,my $return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$R::merchant_id);
my $aowner = "";
my $return_merchant = {
merchant_id => "",
project_id => "",
};
($aowner,$return_merchant) = $apif->fetch_merchant($q,\%varenv,$coo,$R::merchant_id);
$varenv{merchant_id} = $return_merchant->{merchant_id};
$bw->log("Indexsharee merchant select used with access_owner $aowner",$varenv{merchant_id},"");
$varenv{project_id} = $return_merchant->{project_id};
$bw->log("Indexsharee merchant select used with merchant_id $varenv{merchant_id}, project_id $varenv{project_id}, access_owner $aowner",$varenv{merchant_id},"");
($api_return,$users_sharee) = $apif->auth_verify($q,$coo,"");

View file

@ -151,7 +151,7 @@ sub save_account(){
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my %varenv = $cf->envonline();
$bw->log("save_account by varmerchant_id $varmerch->{merchant_id} on dbname $varenv{dbname}",$q,"");
$bw->log("save_account by merchant_id $varmerch->{merchant_id}, project_id $varmerch->{project_id} on dbname $varenv{dbname}",$q,"");
my $debug=1;
my $dbh = "";#keep in mind, empty dbh defaults to local copri-instance dbname
@ -210,7 +210,7 @@ sub save_account(){
$valxx = "null"
}
}
if($_ =~ /^txt[\d+]|^int[\d+]|^uri[\d+]|ct_name/){
if($_ =~ /^txt\d+|^int\d+|ct_name/){
#PW
if($_ =~ /^txt04/){
if($valxx eq "xxxxxxxx"){
@ -248,7 +248,7 @@ sub save_account(){
$u_rows = $dbt->update_one("",$update_primary,"$_='$valxx'");
}
#txt15=Bonus- oder Antragsnummer (falls vorhanden)=15
#txt15=Bonus- oder Freischalcode (falls vorhanden)=15
#only check bonusnr and add operators dbname.
#bonustarif will be set after operator insert
elsif($_ eq "txt15"){
@ -262,12 +262,27 @@ sub save_account(){
$txt17{$ctadr->{txt17}} = 1;
}
#accept SWK codes without prefix
if($valxx && $owner && ($owner == 195 || $owner == 176)){
#accept KN codes without prefix
if($valxx && $varmerch->{project_id} && $varmerch->{project_id} eq "Konstanz"){
my $valappend = $valxx;
$valxx = "KN-$valappend";
print FILE "Prepare SWK Bonusnr by prefix $valxx" . "\n" if($debug);
print FILE "Prepare KN Bonusnr by prefix $valxx" . "\n" if($debug);
}
#accept BVB codes also without prefix
elsif($valxx && $valxx !~ /-/ && $varmerch->{project_id} && $varmerch->{project_id} eq "Freiburg"){
my $operator_conf = "";
$operator_conf = $dbt->get_operator_conf("BVB");
if(ref($operator_conf) eq "HASH" && ref($operator_conf->{subproject}) eq "HASH" && $R::txt06 =~ /$varmerch->{project_id}/i){
my $valappend = $valxx;
foreach my $sub (keys %{ $operator_conf->{subproject} }){
if($operator_conf->{subproject}->{$sub} && $R::txt03 =~ /$operator_conf->{subproject}->{$sub}/i){
$valxx = "BVB-$sub-$valappend";
}
}
print FILE "Prepare BVB Bonusnr by prefix $valxx" . "\n" if($debug);
}
}
#Freischaltcode format can be "CA-Li-hsze789k" or "CA1234567"
if($valxx && ($valxx =~ /^(\w{2,3})-([\w\-]+)/i || $valxx =~ /^(\w{2,3})(\d+)/i)){
$valxx =~ s/\s//g;
@ -711,7 +726,7 @@ sub save_transact(){
}else{
my $ct_id = {c_id => 0};
$ct_id = $dbt->insert_contenttrans($dbh_operator,$ctadr_operator,"300008","218","----",$owner);
$pos_id = $dbt->insert_pos($dbh_operator,$ct_id,$ct,$ctadr_operator,"","",$valxx,"0",$owner);
$pos_id = $dbt->insert_pos($dbh_operator,$ct_id,$ct,"",$ctadr_operator,"","",$valxx,"0",$owner);
}
}else{
$ret = "failure::conflict_txt16#top";

View file

@ -87,7 +87,7 @@ Weitere Personen aus Ihrem Haushalt profitieren jedoch ebenfalls, falls Sie weit
if($aowner == 186 || $aowner == 197){
$bonus_desc = "Freischaltcode (falls vorhanden)";
$bonus_ak = "Ihr Freischaltcode wurde angenommen. Bitte beachten sie dass der Freischaltcode mit einem Mietradtarif verbunden ist. Der Tarif wird bei der Mietrad Reservierung angezeigt.";
$bonus_avail = "Der Freischaltcode ist nicht vorhanden.";
$bonus_avail = "Der Freischaltcode wurde nicht akzeptiert.";
$bonus_conflict = "Der Freischaltcode kann nur einmal verwendet werden.";
$bonus_saved = "Aktiviert:";
@ -552,12 +552,20 @@ Nach Abschluss der Registrierung erhalten Sie sowohl auf die von Ihnen hinterleg
}
my $saved_coupon = "";
$saved_coupon = "$ctadrcoupon->{sharee_kn}->{txt15}" if($ctadrcoupon->{sharee_kn}->{txt15});
if($project eq "Konstanz" && $ctadrcoupon->{sharee_kn}->{txt15}){
$bonus_desc = "Bonusnummer gespeichert";
$saved_coupon = "$ctadrcoupon->{sharee_kn}->{txt15}";
}
if($project eq "Freiburg" && $ctadrcoupon->{sharee_bvb}->{txt15} && $ctadrcoupon->{sharee_bvb}->{txt15} !~ /-/){
$bonus_desc = "Freischaltcode gespeichert";
$saved_coupon = "$ctadrcoupon->{sharee_bvb}->{txt15}";
}
print $q->label({-for=>"$key", -style=>'padding-top:1.5em;'},"$bonus_desc"),"\n";
print "<input id='$key' type='text' class='form-control' name='$key' value='$saved_coupon' override $autofocus />\n";
print $q->div("&nbsp");
foreach my $opid (keys(%$ctadrcoupon)){
if($ctadrcoupon->{$opid}->{txt15} && ($aowner != 195 && $aowner != 185 && $aowner != 176)){
if($ctadrcoupon->{$opid}->{txt15}){
print $q->div("$bonus_saved $ctadrcoupon->{$opid}->{oprefix}-$ctadrcoupon->{$opid}->{txt15}"),"\n";
}
}