cleaning the house

This commit is contained in:
mynah
2020-01-20 14:49:59 -06:00
parent 252ec865b3
commit 7dfd107c04
81 changed files with 426 additions and 958 deletions

View File

@@ -0,0 +1,19 @@
insert into caja_evento
(
cliente_nombre,
cliente_correo,
cliente_comentario,
tienda_evento_id,
talla_id,
cantidad,
monto,
etapa_id,
entrega_id,
pago_clave,
plazo,
fecha_pago
)
values (?,?,?,?,?,?,?,?,?,?,?,now())
;

View File

@@ -0,0 +1,10 @@
select
t.precio as precio,
c.nombre as nombre
from
tienda_evento as t
inner join
curso as c on t.curso_id=c.id
where
t.id = ?
;

View File

@@ -1,30 +0,0 @@
select
t.id as tid,
c.nombre as nombre,
c.subnombre as subnombre,
c.descripcion as descripcion,
c.maestro as maestro,
c.imagen_a as cimga,
c.imagen_b as cimgb,
c.imagen_c as cimgc,
day(t.fecha_inicio) as dini,
month(t.fecha_inicio) as mini,
day(t.fecha_fin) as dfin,
month(t.fecha_fin) as mfin,
t.precio as precio,
t.promocion as promo,
t.promo_estado as promo_estado,
t.playera_estado as playera_estado,
t.cupo as cupo,
l.nombre as lnombre,
l.federativa as federativa,
l.pais as pais,
l.municipio as municipio
from tienda_evento as t
join curso as c on c.id = t.curso_id
join lugar as l on l.id = t.lugar_id
where t.id=? and t.estado =1
;

View File

@@ -1,10 +0,0 @@
select
id,
objeto as "objeto",
nombre as "nombre",
precio as "precio",
subnombre as "subnombre",
promocion as "promocion",
imagen as "imagen"
from tienda where activo =1;

View File

@@ -1,9 +1,10 @@
package Dojo::Model::Vdgproc; use Mojo::File 'path';
use Mojo::JSON qw(decode_json encode_json);
use Dojo::Support qw{month_num2txt log dmph} ;
use Dojo::Support qw{ mtxt month_num2txt log dmph} ;
use Mojo::Base 'Mojolicious::Controller';
use Email::Valid;
use Data::Dumper;
use File::Basename;
use Encode qw(decode_utf8 encode_utf8);
use Text::Markdown qw{ markdown };
@@ -15,24 +16,13 @@ my $data_path = path('lib/Dojo/Model/Data')->make_path;
#just for fun
# Tienda de eventos ===========================================================
sub calendar_monthblock {
my $r = _read ($data_path->child("cal/q1Block.q")->slurp);
map { $_->{fecha}=month_num2txt($_->{month})." ".$_->{year} } @$r;
return $r;
}
sub mtxt {
my ($di, $mi, $df, $mf)=@_; # dini,mini,dfin,mfin
my $txt;
if ($mi == $mf){
if ($di == $df){ $txt = "$di de ".month_num2txt($mi);}
else{ $txt = "Del $di al $df de ".month_num2txt($mi);}
}
else{
$txt = "Del $di de ".month_num2txt($mi)." al $df de ".month_num2txt($mf);
}
return $txt;
}
sub calendar_events {
my $r = _read ($data_path->child("cal/q3Event.q")->slurp);
foreach (@$r) { $_->{fecha} = mtxt( $_->{dini},$_->{mini},$_->{dfin},$_->{mfin}) }
@@ -48,29 +38,103 @@ sub event{
sub spay {
my ($c,$class,$id) = @_;
return _read ($data_path->child("/store/qIdStore.q")->slurp,$id)->[0];
return _read ($data_path->child("spay/qIdStore.q")->slurp,$id)->[0];
}
# 4000004840000008 3, 6, 9, 12, and 18 month installment plans available
# "*p4000004840000008
# 4242424242424242 No installment plans available.
#==============================================================================
sub store_id {
my ($c,$class,$id) = @_;
my $r = _read ($data_path->child("/store/qEstore.q")->slurp,$id)->[0];
my $r = _read ($data_path->child("store/qEstore.q")->slurp,$id)->[0];
$r->{fecha} = mtxt( $r->{dini},$r->{mini},$r->{dfin},$r->{mfin});
return $r;
}
# Stripe payment process ==============================================================
# ======================
# 4000004840000008 3, 6, 9, 12, and 18 month installment plans available
# "*p4000004840000008
# 4242424242424242 No installment plans available.
# ======================
sub intentCreate{
my ($c,$id) = @_;
my $q="select t.precio as precio, c.nombre as nombre from tienda_evento as t inner join curso as c on t.curso_id=c.id where t.id = ? ;";
return _read ($q,$id)->[0];
return _read ($data_path->child("spay/qIntentCreate.q")->slurp,$id)->[0];
}
sub intentConfirm{
my ($c,$id) = @_;
my $q="select t.precio as precio, c.nombre as nombre from tienda_evento as t inner join curso as c on t.curso_id=c.id where t.id = ? ;";
return _read ($q,$id)->[0];
my ($c,$data,$r) = @_;
# cliente_nombre,cliente_correo,cliente_comentario,tienda_evento_id,talla_id,cantidad(1),monto,etapa_id(4),entrega(3),pago_clave,plazo,fecha_pago
my $mq = $data->{'mq'};
my $students = $data->{'students'};
my $plan = 0;
if (defined $data->{'selected_plan'}){
$plan = $data->{'selected_plan'}->{'count'};
}
for (1..$mq){
_write (
$data_path->child("/spay/qIntentConfirm.q")->slurp,
$$students[$_ -1][0],
$$students[$_ -1][1],
$$students[$_ -1][2],
$data->{'tid'},
$$students[$_ -1][3],
$data->{'mq'},
$r->{'amount'},
4,
3,
$r->{'id'},
$plan
);
} # falta plazo
return ;
}
# Check payment user info ==============
# data:
# ===============
#'selected_plan' => { 'type' => 'fixed_count', 'count' => 6, 'interval' => 'month' },
#'mq' => '2', # cantidad de alumnas
#'req' => 'check',
#'payment_intent_id' => 'pi_1G1luSFBHoXN2vhnkl3PIiL1',
#'tid' => 80, #tienda id
#'students' => [ [ 'User', 'me@me.com', 'obs', 'M' ], [ 'usr2', 'mail2', 'obs', 'G' ], undef, undef, undef, undef, undef, undef, undef, undef ] #arr(10)
# ===============
sub intentSanity{
my ($c,$d)=@_;
if (defined $d->{'selected_plan'} ){
return -1 unless defined ($d->{'selected_plan'}{'type'});
return -1 unless defined ($d->{'selected_plan'}{'count'});
return -1 unless defined ($d->{'selected_plan'}{'interval'});
}
return -1 unless defined ($d->{'tid'}) && $d->{'tid'} =~ /^\d+$/ ;
return -1 unless defined ($d->{'req'}) && $d->{'req'} eq 'check';
return -1 unless defined ($d->{'payment_intent_id'});
return userDataSanity($c,$d) ;
}
sub userDataSanity{
my ($c,$d) = @_;
return -1 unless (
defined ($d->{'students'}) && # (nombre,mail,observaciones, talla)
defined ($d->{'mq'}) &&
$d->{'mq'} =~/^\d+$/ &&
$d->{'mq'} < 10
);
my %h=qw(n 0 CH 1 M 2 G 3);
my $mq = $d->{'mq'};
my $students = $d->{'students'};
for (1..$mq){
return $_ unless defined( $$students[$_ -1][0] );
return $_ unless defined( $$students[$_ -1][1] ) &&
is_mail($$students[$_ -1][1] );
$$students[$_ -1][3] = $h{$$students[$_ -1][3] // 'n'};
}
return 0;
}
sub is_mail{
return Email::Valid->address(shift);
}
#==============================================================================
@@ -107,16 +171,7 @@ sub place_ch{
#==============================================================================
#ayudas =====================================
sub tst{
my $c=shift;
my $d=$c->param('n');
log("------log-------");
log("$d");
log("------log-------");
return 0;
}
# lower level read =====================================
sub _read{
my ($q,@bind)=@_;