mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-10 14:06:26 +02:00
payment check and boni by file
This commit is contained in:
parent
fd3e14ba7b
commit
f7c3ed7b05
5 changed files with 101 additions and 62 deletions
|
@ -140,7 +140,7 @@ sub create_account(){
|
|||
sub save_account(){
|
||||
my $self = shift;
|
||||
my $c_id = shift;
|
||||
my $coo = shift || "";
|
||||
my $varmerch = shift || "";
|
||||
my $owner = shift || 0;
|
||||
|
||||
my $table = "contentadr";
|
||||
|
@ -150,7 +150,8 @@ sub save_account(){
|
|||
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||
my %varenv = $cf->envonline();
|
||||
$bw->log("save_account",$q,"");
|
||||
|
||||
$bw->log("save_account by varmerchant_id $varmerch->{merchant_id} on dbname $varenv{dbname}",$q,"");
|
||||
|
||||
my $debug=1;
|
||||
my $dbh = "";#keep in mind, empty dbh defaults to local copri-instance dbname
|
||||
|
@ -160,10 +161,10 @@ sub save_account(){
|
|||
#Always on sharee_primary
|
||||
if($varenv{dbname} ne "sharee_primary"){
|
||||
$dbh = $dbt->dbconnect_extern("sharee_primary");
|
||||
print FILE "\n*-->If no-primary connect DB sharee_primary $now_dt| c_id: $c_id \n" if($debug);
|
||||
print FILE "\n*-->If no-primary connect DB sharee_primary (mvar: $varmerch->{merchant_id}|$varmerch->{dbname}|$varenv{dbname}) $now_dt| c_id: $c_id| owner: $owner\n" if($debug);
|
||||
}else{
|
||||
#keep in mind, should be only done by web-app user Formular (primary)
|
||||
print FILE "\n*-->Else take local copri-Instance DB $varenv{dbname} $now_dt| c_id: $c_id \n" if($debug);
|
||||
print FILE "\n*-->Else take local copri-Instance DB $varenv{dbname} (mvar: $varmerch->{merchant_id}|$varmerch->{dbname}) $now_dt| c_id: $c_id| owner: $owner\n" if($debug);
|
||||
}
|
||||
|
||||
my $authref = {
|
||||
|
@ -215,11 +216,6 @@ sub save_account(){
|
|||
}
|
||||
#operators, only if saved by operator DMS
|
||||
elsif($_ eq "txt17"){
|
||||
#2021-07-29 post input disabled, because it fails
|
||||
#my @txt17 = $q->param('txt17');
|
||||
#@txt17 = grep {!/null/g} @txt17;
|
||||
#push(@txt17,$varenv{dbname}) if($varenv{dbname} ne "sharee_primary");
|
||||
#my %txt17 = map {$_ => 1} @txt17;
|
||||
my %txt17 = ();
|
||||
if($ctadr->{txt17} =~ /\w\s\w/){
|
||||
%txt17 = map { $_ => 1 } split(/\s+/,$ctadr->{txt17});
|
||||
|
@ -239,26 +235,17 @@ sub save_account(){
|
|||
#Web-Login|Rabatt|Vde|payone cron-intervall|Ilockit-Admin
|
||||
#elsif($_ =~ /int05|int07|int12|int16|int19/){
|
||||
elsif($_ =~ /int05|int07|int16|int19/){
|
||||
#if($varenv{dbname} ne "sharee_primary"){
|
||||
#on all $keys which on delete on loop sync
|
||||
$u_rows = $dbt->update_one("",$update_primary,"$_=$valxx");
|
||||
# }
|
||||
}
|
||||
#user_tour
|
||||
elsif($_ =~ /txt18/){
|
||||
#if($varenv{dbname} ne "sharee_primary"){
|
||||
#on all $keys which on delete on loop sync
|
||||
my @txt18 = $q->param('txt18');
|
||||
@txt18 = grep {!/null/} @txt18;
|
||||
$u_rows = $dbt->update_one("",$update_primary,"$_='@txt18'");
|
||||
# }
|
||||
}
|
||||
#Text Sonstiges
|
||||
elsif($_ =~ /txt29/){
|
||||
# if($varenv{dbname} ne "sharee_primary"){
|
||||
#on all $keys which on delete on loop sync
|
||||
$u_rows = $dbt->update_one("",$update_primary,"$_='$valxx'");
|
||||
# }
|
||||
}
|
||||
|
||||
#txt15=Bonus- oder Antragsnummer (falls vorhanden)=15
|
||||
|
@ -276,12 +263,18 @@ sub save_account(){
|
|||
$txt17{$ctadr->{txt17}} = 1;
|
||||
}
|
||||
|
||||
#TODO, check if merchant_id for KN and set $bonus_prefix
|
||||
if($valxx && ($valxx =~ /^(\w{2,3})-(\w+)/ || $valxx =~ /^(\w{2,3})(\d+)/)){
|
||||
#accept SWK codes without prefix
|
||||
if($valxx && $owner && ($owner == 195 || $owner == 185 || $owner == 176 || $varenv{dbname} eq "sharee_kn")){
|
||||
my $valappend = $valxx;
|
||||
$valxx = "KN-$valappend";
|
||||
print FILE "Prepare SWK Bonusnr by prefix $valxx" . "\n" if($debug);
|
||||
}
|
||||
if($valxx && ($valxx =~ /^(\w{2,3})-(\w+)/ || $valxx =~ /^(\w{2,3})(\d+)/)){
|
||||
$valxx =~ s/\s//g;
|
||||
my $bonus_prefix = uc($1),
|
||||
my $bonusnr = $2;
|
||||
my $operator_conf = $dbt->get_operator_conf($bonus_prefix);
|
||||
my @txt30_op = ();
|
||||
|
||||
if(ref($operator_conf) eq "HASH" && $operator_conf->{oprefix} && $operator_conf->{database}->{dbname}){
|
||||
print FILE "Bonus- oder Antragsnummer $valxx : " . $operator_conf->{oprefix} . " " . $operator_conf->{database}->{dbname} . "\n" if($debug);
|
||||
|
@ -295,13 +288,28 @@ sub save_account(){
|
|||
ct_name => "$bonusnr",
|
||||
};
|
||||
my $bonus_record = $dbt->fetch_record($dbh_operator,$pref_bo);
|
||||
my $bonus_collect = {};#will be hash on matchin SWK bonus
|
||||
#also if SWK file matches
|
||||
if(!$bonus_record->{c_id} && $operator_conf->{database}->{dbname} eq "sharee_kn"){
|
||||
my $swk_code = "";
|
||||
$swk_code = $lb->grep_filecontent("$varenv{basedir}/ftp/SWK_codes/got_last.csv","$bonusnr");
|
||||
$bonus_record->{ct_name} = $lb->grep_filecontent("$dbt->{copri_conf}->{basedir}/$operator_conf->{dir_app}/ftp/SWK_codes/got_last.csv","$bonusnr");
|
||||
if($bonus_record->{ct_name}){
|
||||
$bonus_record->{c_id} = 1;
|
||||
$bonus_record->{int21} = 3429;#Stadtrad source Tarif
|
||||
$bonus_record->{int22} = 3430;#Stadtrad target Tarif
|
||||
$bonus_collect->{1}->{ct_name} = $bonus_record->{ct_name};
|
||||
$bonus_collect->{1}->{int21} = 3429;
|
||||
$bonus_collect->{1}->{int22} = 3430;
|
||||
$bonus_collect->{2}->{ct_name} = $bonus_record->{ct_name};
|
||||
$bonus_collect->{2}->{int21} = 3428;
|
||||
$bonus_collect->{2}->{int22} = 3432;
|
||||
@txt30_op = ("$bonus_collect->{1}->{int22}","$bonus_collect->{2}->{int22}");
|
||||
}
|
||||
print FILE "SWK bonus_collect:\n" . Dumper($bonus_collect) . "\n";
|
||||
}
|
||||
|
||||
#add operators dbname only if Bonusnr matches
|
||||
print FILE "txt15=$bonusnr requested on web Bonustarif on: $operator_conf->{database}->{dbname} --> barcode:$bonus_record->{barcode} --> txt21:$bonus_record->{int21} --> txt22:$bonus_record->{int22}\n" if($debug);
|
||||
print FILE "txt15=$bonusnr requested on web Bonustarif on: $operator_conf->{database}->{dbname} --> Bonusnt:$bonus_record->{ct_name} --> int21:$bonus_record->{int21} --> int22:$bonus_record->{int22}\n" if($debug);
|
||||
|
||||
if($bonus_record->{c_id}){
|
||||
$txt17{$operator_conf->{database}->{dbname}} = 1;
|
||||
my @operators = ();
|
||||
|
@ -311,12 +319,13 @@ sub save_account(){
|
|||
print FILE "txt17 saving operators on primary: @operators\n" if($debug);
|
||||
$u_rows = $dbt->update_one($dbh,$update_primary,"txt17='@operators'");
|
||||
|
||||
#insert adr to operator if it doesn't exist before set operator bonustarif
|
||||
#collect operator addr with existing tariff setting
|
||||
my $ctadr_operator = $dbt->fetch_record($dbh_operator,$authref);
|
||||
my @txt30_op = ();
|
||||
#multiple select sharee Tarif
|
||||
@txt30_op = ("$ctadr_operator->{txt30}") if($ctadr_operator->{txt30});
|
||||
@txt30_op = split(/\s+/,$ctadr_operator->{txt30}) if($ctadr_operator->{txt30} =~ /\w\s+\w/);
|
||||
|
||||
#operator request by Bonusnr.
|
||||
#insert adr to operator if it doesn't exist before set operator bonustarif
|
||||
if(!$ctadr_operator->{c_id}){
|
||||
print FILE "Bonus oprefix address INSERT adr from record_primary to operator $operator_conf->{database}->{dbname} , c_id:$ctadr->{c_id}\n";
|
||||
my $insert_op = {
|
||||
|
@ -326,10 +335,12 @@ sub save_account(){
|
|||
owner => "198",
|
||||
};
|
||||
my $c_id_op = $dbt->insert_contentoid($dbh_operator,$insert_op,"reset_adropkeys");
|
||||
$dbt->update_content4comp($dbh_operator,$bonus_record->{c_id},"-","1");
|
||||
|
||||
if($bonus_record->{c_id} > 3){#means if not file greped with static c_id <= 3
|
||||
$dbt->update_content4comp($dbh_operator,$bonus_record->{c_id},"-","1");
|
||||
}
|
||||
@txt30_op = ("$bonus_record->{int22}") if($bonus_record->{int22});
|
||||
}
|
||||
#address hash wit bonusnr
|
||||
my $adr_bonus = {
|
||||
table => "contentadr",
|
||||
mtime => "now()",
|
||||
|
@ -339,8 +350,8 @@ sub save_account(){
|
|||
owner => $owner,
|
||||
ret => $ret,
|
||||
};
|
||||
print FILE "adr_bonus preview which will be set if matches\n" . Dumper($adr_bonus) . "\n";
|
||||
$ret = $pl->set_usertarif($dbh,$operator_conf->{database}->{dbname},$adr_bonus);
|
||||
print FILE "operator adr update preview with bonusnr:\n" . Dumper($adr_bonus) . "\n";
|
||||
$ret = $pl->set_usertarif($dbh,$operator_conf->{database}->{dbname},$adr_bonus,$bonus_collect);
|
||||
}
|
||||
}else{
|
||||
$ret = "failure::txt15#top5";
|
||||
|
@ -486,11 +497,18 @@ sub save_account(){
|
|||
reference => "$ctadr->{c_id}_$epoche",
|
||||
renewed => ''
|
||||
};
|
||||
|
||||
my $payone_txid = "";
|
||||
$payone_txid = $payone->preauthorizationSEPA_main(\%varenv,$ctadr,$ctt,$owner);
|
||||
if($payone_txid){
|
||||
##preauthorization and/or capture needs to much time, must be done async!
|
||||
#$payone_txid = $payone->preauthorizationSEPA_main(\%varenv,$ctadr,$ctt,$owner);
|
||||
#if($payone_txid)
|
||||
if(1==1){
|
||||
|
||||
$ctt->{txt16} = "$payone_txid";
|
||||
$payone_txid = $payone->captureSEPA_main(\%varenv,$ctadr,$ctt,$owner);
|
||||
$u_rows = $dbt->update_one($dbh,$update_primary,"int12=0");#Vde
|
||||
#$payone_txid = $payone->captureSEPA_main(\%varenv,$ctadr,$ctt,$owner);
|
||||
#int12=0 should be set after capture success in payment module
|
||||
|
||||
}else{
|
||||
$u_rows = $dbt->update_one($dbh,$update_primary,"int12=$vde_on_fail");#Vde
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue