mirror of
https://gitlab.com/t6353/sharee.bike.git
synced 2025-05-10 05:56:27 +02:00
Extend operator dms-account management
This commit is contained in:
parent
b2dce25de8
commit
6212b1aefb
18 changed files with 840 additions and 552 deletions
|
@ -22,7 +22,6 @@ use Digest::MD5 qw(md5 md5_hex);
|
|||
use Digest::SHA qw(sha1_base64 sha256_base64);
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use URI::Encode;
|
||||
use Mod::Prelib;
|
||||
use Mod::Basework;
|
||||
use Mod::Payment;
|
||||
#use Mod::MailTransport;
|
||||
|
@ -34,7 +33,6 @@ my $but = new Buttons;
|
|||
my $lb = new Libenz;
|
||||
my $dbt = new DBtank;
|
||||
my $apif = new APIfunc;
|
||||
my $pl = new Prelib;
|
||||
my $bw = new Basework;
|
||||
my $payone = new Payment;
|
||||
#my $mailtrans = new MailTransport;
|
||||
|
@ -115,8 +113,8 @@ sub delete_account {
|
|||
#create_account is alwas done on primary first
|
||||
sub create_account(){
|
||||
my $self = shift;
|
||||
my $dbh = shift || "";
|
||||
my $owner = shift;
|
||||
my $dbh = "";
|
||||
|
||||
my $insert_adr = {
|
||||
table => "contentadr",
|
||||
|
@ -139,6 +137,7 @@ sub create_account(){
|
|||
#sharee save_account is always done on primary first
|
||||
sub save_account(){
|
||||
my $self = shift;
|
||||
my $dbh = shift || "";
|
||||
my $q = shift;
|
||||
my $c_id = shift;
|
||||
my $varmerch = shift || "";
|
||||
|
@ -146,7 +145,7 @@ sub save_account(){
|
|||
my $table = "contentadr";
|
||||
$q->import_names('R');
|
||||
my @keywords = $q->param;
|
||||
|
||||
my $debug=1;
|
||||
my $feedb = {
|
||||
u_rows => 0,
|
||||
prepaid_id => 0,
|
||||
|
@ -157,9 +156,6 @@ sub save_account(){
|
|||
|
||||
$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
|
||||
|
||||
open(FILE,">>$varenv{logdir}/save_account.log") if($debug);
|
||||
|
||||
#Always on sharee_primary
|
||||
|
@ -224,6 +220,7 @@ sub save_account(){
|
|||
my $pwmd5 = md5_hex($valxx) || "";
|
||||
my $pwsha256=sha256_base64($pwmd5) || "";
|
||||
$update_adr->{txt04} = "$pwsha256" if(length($pwsha256) > 20);
|
||||
$update_adr->{int06} = "null";#pw renewd
|
||||
}
|
||||
}
|
||||
#operators, only if saved by operator DMS
|
||||
|
@ -382,7 +379,7 @@ sub save_account(){
|
|||
$ctadr_operator = $dbt->fetch_record($dbh_operator,$authref);
|
||||
|
||||
print FILE "Bonusnr set_usertarif done by primary:\n" . Dumper($adr_bonus) . "\n";
|
||||
$ret = $pl->set_usertarif($dbh,$operator_conf->{database}->{dbname},$adr_bonus,$bonus_collect);
|
||||
$ret = $self->set_usertarif($dbh,$operator_conf->{database}->{dbname},$adr_bonus,$bonus_collect);
|
||||
|
||||
#count down only if not file greped with static kn c_id and not still used
|
||||
print FILE "bonus_record update_content4comp by: $bonus_record->{c_id} > 3 && $bonus_record->{int03} > 0 && (!$ctadr_operator->{txt15} || $bonus_record->{ct_name} !~ /$ctadr_operator->{txt15}/i)\n";
|
||||
|
@ -420,7 +417,7 @@ sub save_account(){
|
|||
ret => $ret,
|
||||
};
|
||||
print FILE "Bonusnr set_usertarif done by operator:\n" . Dumper($adr_bonus) . "\n";
|
||||
$ret = $pl->set_usertarif($dbh,$varenv{dbname},$adr_bonus,"");
|
||||
$ret = $self->set_usertarif($dbh,$varenv{dbname},$adr_bonus,"");
|
||||
}
|
||||
#phonenr
|
||||
}elsif($_ eq "txt07"){
|
||||
|
@ -567,12 +564,13 @@ sub save_account(){
|
|||
if($payone_mival && $payone_mival =~ /\w{2}-\w+/){
|
||||
|
||||
#payment_ack
|
||||
system("$dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/payment_ack.pl '$varenv{syshost}' 'payment_ackSEPA' '$ctadr->{c_id}' '$owner'");
|
||||
system("$dbt->{copri_conf}->{basedir}/$varenv{syshost}/src/scripts/payment_ack.pl '$varenv{syshost}' 'payment_ackSEPA' '$ctadr->{c_id}' '$owner' &");
|
||||
|
||||
$vde_on_fail = 0 if($vde_on_fail != 2);
|
||||
$u_rows = $dbt->update_one($dbh,$update_adr,"int12=$vde_on_fail");#Vde
|
||||
}else{
|
||||
$u_rows = $dbt->update_one($dbh,$update_adr,"int12=$vde_on_fail");#Vde
|
||||
$ret = "failure::txt22#top";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -611,6 +609,149 @@ sub save_account(){
|
|||
return ($ret,$feedb);
|
||||
}#end save_account
|
||||
|
||||
#sharee Bonusnummer with Tarif automatic
|
||||
sub set_usertarif {
|
||||
my $self = shift;
|
||||
my $dbh = shift;
|
||||
my $dbname = shift;
|
||||
my $adr_bonus = shift;
|
||||
my $bonus_collect = shift || {};
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||
my %varenv = $cf->envonline();
|
||||
my $debug=1;
|
||||
open(FILE,">>$varenv{logdir}/save_account.log") if($debug);
|
||||
print FILE "\n*set_usertarif --> $now_dt| dbname: $dbname | c_id: $adr_bonus->{c_id} | txt15: $adr_bonus->{txt15}\n" if($debug);
|
||||
|
||||
my $oprefix = $dbt->{operator}->{$dbname}->{oprefix};
|
||||
my $ret = $adr_bonus->{ret};
|
||||
my $i = 0;
|
||||
my $dbh_operator = $dbt->dbconnect_extern($dbname);#operator connect
|
||||
|
||||
my $tariff_all = { barcode => 0, int18 => 0};
|
||||
my $tariff = {
|
||||
table => "content",
|
||||
fetch => "all",
|
||||
keyfield => "barcode",
|
||||
template_id => "210",#Tariff tpl_id
|
||||
};
|
||||
$tariff_all = $dbt->fetch_record($dbh_operator,$tariff);
|
||||
|
||||
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
|
||||
my $adref = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
template_id => "202",
|
||||
c_id => "$adr_bonus->{c_id}",
|
||||
};
|
||||
|
||||
my $adr_primary = { c_id => 0 };
|
||||
$adr_primary = $dbt->fetch_record($dbh_primary,$adref) if($adr_bonus->{c_id});
|
||||
|
||||
#collect Tarif with prefix saving on primary
|
||||
my %prim_tarif_hash = ();
|
||||
if($adr_primary->{txt30} && $adr_primary->{txt30} =~ /\w\s\w/){
|
||||
%prim_tarif_hash = map { $_ => 1 } split(/\s+/,$adr_primary->{txt30});
|
||||
}elsif($adr_primary->{txt30}){
|
||||
$prim_tarif_hash{$adr_primary->{txt30}} = 1;
|
||||
}
|
||||
#first delete operator tarif in prim_tarif_hash. we will fill up downunder
|
||||
foreach my $rid (sort { $tariff_all->{$a}->{barcode} <=> $tariff_all->{$b}->{barcode} } keys (%$tariff_all)){
|
||||
print FILE "--> Cleanup operator specific prim_tarif_hash: $tariff_all->{$rid}->{barcode}\n";
|
||||
delete $prim_tarif_hash{$oprefix . $tariff_all->{$rid}->{barcode}};
|
||||
}
|
||||
|
||||
if($adr_bonus->{txt15} =~ /\w+/){
|
||||
if(1==1){
|
||||
my %tarif_hash = ();
|
||||
my @new_txt30 = ();
|
||||
|
||||
#collect multiple tarif by bonusnr
|
||||
my $pref_cc = {
|
||||
table => "content",
|
||||
keyfield => "c_id",
|
||||
fetch => "all",
|
||||
template_id => "228",
|
||||
int03 => ">::0",
|
||||
ct_name => "ilike::$adr_bonus->{txt15}",
|
||||
};
|
||||
|
||||
$bonus_collect = $dbt->fetch_record($dbh_operator,$pref_cc) if(ref($bonus_collect->{1}) ne "HASH");
|
||||
|
||||
foreach my $sourcetarif (@{$adr_bonus->{txt30_array}}){
|
||||
$tarif_hash{$sourcetarif} = 1;
|
||||
#additional and only! save privat or hidden tarif to primary to get caching
|
||||
if($tariff_all->{$sourcetarif}->{int18} == 3 || $tariff_all->{$sourcetarif}->{int18} == 4){
|
||||
$prim_tarif_hash{$oprefix . $sourcetarif} = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
print FILE "set_usertarif bonus_collect by request txt15: $adr_bonus->{txt15}\n";
|
||||
foreach my $id (keys (%$bonus_collect)){
|
||||
$i++;
|
||||
print FILE "$i)-1-> loop bonus_collect and find $bonus_collect->{$id}->{ct_name} = $adr_bonus->{txt15}\n|==>Take and insert Tarif $bonus_collect->{$id}->{int22}\n" if($debug);
|
||||
$tarif_hash{$bonus_collect->{$id}->{int22}} = 1;
|
||||
|
||||
#additional and only! save privat or hidden tarif to primary to get caching
|
||||
if($tariff_all->{$bonus_collect->{$id}->{int22}}->{int18} == 3 || $tariff_all->{$bonus_collect->{$id}->{int22}}->{int18} == 4){
|
||||
$prim_tarif_hash{$oprefix . $bonus_collect->{$id}->{int22}} = 1;
|
||||
}
|
||||
|
||||
if($bonus_collect->{$id}->{int21} && $bonus_collect->{$id}->{int21} != $bonus_collect->{$id}->{int22}){
|
||||
print FILE "$i)-2-> delete if($bonus_collect->{$id}->{int21} && $bonus_collect->{$id}->{int21} != $bonus_collect->{$id}->{int22})\n" if($debug);
|
||||
delete $tarif_hash{$bonus_collect->{$id}->{int21}};
|
||||
delete $prim_tarif_hash{$oprefix . $bonus_collect->{$id}->{int21}};
|
||||
print FILE "$i)-3-> delete done $bonus_collect->{$id}->{int21}\n" if($debug);
|
||||
}
|
||||
|
||||
}
|
||||
@new_txt30 = keys %tarif_hash;
|
||||
if(@new_txt30){
|
||||
print FILE "Final -3-> txt30: @new_txt30\n" if($debug);
|
||||
$u_rows = $dbt->update_one($dbh_operator,$adr_bonus,"txt30='@new_txt30'");
|
||||
$u_rows = $dbt->update_one($dbh_operator,$adr_bonus,"txt15='$adr_bonus->{txt15}'");
|
||||
|
||||
#collect Tarif with prefix saving on primary
|
||||
my @prim_txt30 = keys %prim_tarif_hash;
|
||||
$u_rows = $dbt->update_one($dbh_primary,$adr_bonus,"txt30='@prim_txt30'");
|
||||
|
||||
}
|
||||
$ret = "failure::txt30#top2" if(!$adr_bonus->{txt30_array} || $adr_bonus->{txt30_array} !~ /\d/);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
print FILE "-4-> update Tarif txt30: @{$adr_bonus->{txt30_array}}\n" if($debug);
|
||||
$u_rows = $dbt->update_one($dbh_operator,$adr_bonus,"txt30='@{$adr_bonus->{txt30_array}}'");
|
||||
$u_rows = $dbt->update_one($dbh_operator,$adr_bonus,"txt15=''");
|
||||
|
||||
#collect Tarif with prefix saving on primary
|
||||
#delete bonus tarif on primary if not defined by operator
|
||||
#additional and only! save privat or hidden tarif to primary to get caching
|
||||
foreach my $rid (sort { $tariff_all->{$a}->{barcode} <=> $tariff_all->{$b}->{barcode} } keys (%$tariff_all)){
|
||||
foreach(@{$adr_bonus->{txt30_array}}){
|
||||
if($tariff_all->{$rid}->{barcode} == $_ && ($tariff_all->{$_}->{int18} == 3 || $tariff_all->{$_}->{int18} == 4)){
|
||||
print FILE "--> Adding private/hidden key on operator to primary: $_\n";
|
||||
$prim_tarif_hash{$oprefix . $_} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my @prim_txt30 = keys %prim_tarif_hash;
|
||||
$u_rows = $dbt->update_one($dbh_primary,$adr_bonus,"txt30='@prim_txt30'");
|
||||
|
||||
$ret = "failure::txt30#top3" if(!$adr_bonus->{txt30_array} || $adr_bonus->{txt30_array} !~ /\d/);
|
||||
}
|
||||
#if bonus value doesn't match
|
||||
if($adr_bonus->{txt15} && $i == 0){
|
||||
print FILE "-5-> failure txt15: ''\n" if($debug);
|
||||
$ret = "failure::txt15#top4";
|
||||
}
|
||||
close(FILE) if($debug);
|
||||
return $ret;
|
||||
}#end set_usertarif
|
||||
|
||||
|
||||
#coupon alias Gutschein
|
||||
sub save_transact(){
|
||||
my $self = shift;
|
||||
|
@ -795,6 +936,89 @@ sub emailack {
|
|||
return;
|
||||
}
|
||||
|
||||
#email and sms acknowledgments, check and save confirm code states
|
||||
sub code_confirmation {
|
||||
my $self = shift;
|
||||
my $q = shift;
|
||||
my $varenv = shift;
|
||||
my $aowner = shift;
|
||||
$q->import_names('R');
|
||||
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
|
||||
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
|
||||
|
||||
my $update_adr = {
|
||||
table => "contentadr",
|
||||
mtime => "now()",
|
||||
owner => $aowner,
|
||||
};
|
||||
|
||||
#keep in mind, for now and just for testing confirm codes are just c_id
|
||||
open(FILE,">>$varenv->{logdir}/confirm.log");
|
||||
print FILE "\n\n*--> $now_dt done by code_confirmation\n";
|
||||
print FILE "confirm_userid:$R::confirm_userid\nconfirm_code:$R::confirm_code\nconfirm_smscode:$R::confirm_smscode\n";
|
||||
$R::confirm_code =~ s/\s//g;
|
||||
$R::confirm_smscode =~ s/\s//g;
|
||||
my $confirm_code = $q->escapeHTML($R::confirm_code);
|
||||
my $confirm_smscode = $q->escapeHTML($R::confirm_smscode);
|
||||
|
||||
#confirm email
|
||||
if($confirm_code){
|
||||
my $authref = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
c_id => $R::confirm_userid,
|
||||
txt34 => "ilike::$confirm_code%",
|
||||
};
|
||||
my $confirmed_email = { c_id => 0 };
|
||||
$confirmed_email = $dbt->fetch_tablerecord($dbh_primary,$authref);
|
||||
|
||||
if($confirmed_email->{c_id}){
|
||||
$update_adr->{c_id} = $confirmed_email->{c_id};
|
||||
$dbt->update_one($dbh_primary,$update_adr,"int04=1");
|
||||
#save verified emailcode
|
||||
$dbt->update_one($dbh_primary,$update_adr,"txt32='$confirmed_email->{txt08}'");
|
||||
print FILE "confirmed_email: $confirmed_email->{c_id} update because confirm_code:$confirm_code\n";
|
||||
|
||||
#after mailAck, delete all douple adr with no mailAck
|
||||
my $authref = {
|
||||
table => "contentadr",
|
||||
fetch => "all",
|
||||
keyfield => "c_id",
|
||||
txt08 => "ilike::" . $q->escapeHTML($confirmed_email->{txt08}),
|
||||
};
|
||||
my $ctadr = $dbt->fetch_tablerecord($dbh_primary,$authref);
|
||||
foreach my $aid (keys(%$ctadr)){
|
||||
if(!$ctadr->{$aid}->{int04}){
|
||||
$dbt->delete_content("contentadr",$ctadr->{$aid}->{c_id});
|
||||
print FILE "c_id $ctadr->{$aid}->{c_id} $confirmed_email->{txt08} delete because of dopplel\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#confirm sms
|
||||
if($confirm_smscode){
|
||||
my $authref = {
|
||||
table => "contentadr",
|
||||
fetch => "one",
|
||||
c_id => $R::confirm_userid,
|
||||
txt34 => "ilike::%$confirm_smscode",
|
||||
};
|
||||
my $confirmed_sms = { c_id => 0 };
|
||||
$confirmed_sms = $dbt->fetch_tablerecord($dbh_primary,$authref);
|
||||
|
||||
if($confirmed_sms->{c_id}){
|
||||
$update_adr->{c_id} = $confirmed_sms->{c_id};
|
||||
$dbt->update_one($dbh_primary,$update_adr,"int13=1");
|
||||
#save verified smscode
|
||||
$dbt->update_one($dbh_primary,$update_adr,"txt33='$confirmed_sms->{txt07}'");
|
||||
print FILE "confirmed_sms: $confirmed_sms->{c_id} update because confirm_smscode:$confirm_smscode\n";
|
||||
}
|
||||
}
|
||||
close(FILE);
|
||||
return;
|
||||
}#end code_confirmation
|
||||
|
||||
|
||||
#Password forgotten send email
|
||||
sub send_password {
|
||||
my $self = shift;
|
||||
|
@ -826,9 +1050,14 @@ sub send_password {
|
|||
mtime => "now()",
|
||||
owner => "$owner",
|
||||
txt04 => "$pwsha256",
|
||||
int06 => 1,
|
||||
};
|
||||
$dbt->update_record($dbh,$update_primary,$ctadr) if($c_id > 0);
|
||||
system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_password' '$c_id' '' '$coo'");
|
||||
if($c_id > 0){
|
||||
my $dbh_primary = $dbt->dbconnect_extern($dbt->{primary}->{sharee_primary}->{database}->{dbname});
|
||||
$dbt->update_record($dbh_primary,$update_primary,$ctadr);
|
||||
$dbt->update_operatorsloop($varenv->{dbname},$c_id,"update");
|
||||
system("$dbt->{copri_conf}->{basedir}/$varenv->{syshost}/src/scripts/mailTransportcms.pl '$varenv->{syshost}' 'send_password' '$c_id' '' '$coo'");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -896,3 +1125,4 @@ sub sigstation_cupdate {
|
|||
|
||||
1;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue