public
function
probability() {
global
$_INPUT
;
$ret
=
array
();
$time
=
$_INPUT
[
'date'
] && preg_match(
'/^\d{4}-\d{2}\-\d{2}$/'
,
$_INPUT
[
'date'
]) ?
strtotime
(
$_INPUT
[
'date'
]) :
strtotime
(
'today'
);
$today
=
$time
;
$tomorrow
=
$time
+ 86400;
$flag
= 1;
$model
= Model::getInstance(
'logs.fixedlog'
);
$paymodel
= Model::getInstance(
'main.payment'
);
$stats
=
array
();
$num
= 0;
$option
= isset(
$_INPUT
[
'app'
]) ?
intval
(
$_INPUT
[
'app'
]) : 1;
$interval
= isset(
$_INPUT
[
'period'
]) ?
intval
(
$_INPUT
[
'period'
]) : 1;
if
(
$option
== 1) {
for
(
$i
= 0;
$i
<=
$interval
;
$i
++) {
$res
=
$model
->turnround(
$today
,
$tomorrow
,
$flag
);
$temp
=
array
();
foreach
(
$res
as
$value
){
$inmatch
= isset(
$value
[
'inmatch'
]) ? json_decode(
$value
[
'inmatch'
]) :
array
();
foreach
(
$inmatch
as
$val
) {
if
(!in_array(
$val
,
$temp
)) {
array_unshift
(
$temp
,
$val
);
}
}
}
$i
==0 ?
$total
=
count
(
$temp
) :
""
;
$temp
= array_fill_keys(
$temp
,
$i
);
foreach
(
$temp
as
$k
=>
$v
) {
if
(
array_key_exists
(
$k
,
$stats
)) {
$stats
[
$k
] =
$stats
[
$k
].
","
.
$v
;
}
else
{
$stats
[
$k
] =
$v
;
}
}
$today
=
$today
- 86400;
$tomorrow
=
$tomorrow
- 86400;
}
$strlen
= (
$interval
+1)*2-1;
foreach
(
$stats
as
$v
) {
if
(isset(
$v
)) {
strlen
(trim(
$v
)) ==
$strlen
?
$num
++ :
$num
;
}
}
$ret
[
'turnround'
][
'all'
] =
$stats
;
$ret
[
'turnround'
][
'total'
] =
$total
;
$ret
[
'turnround'
][
'stats'
] =
count
(
$stats
);
$ret
[
'turnround'
][
'num'
] =
$num
;
}
else
{
$res
=
$model
->turnround(
$today
,
$tomorrow
,
$flag
);
$temp
=
array
();
foreach
(
$res
as
$value
){
$inmatch
= isset(
$value
[
'inmatch'
]) ? json_decode(
$value
[
'inmatch'
]) :
array
();
foreach
(
$inmatch
as
$val
) {
if
(!in_array(
$val
,
$temp
)) {
array_unshift
(
$temp
,
$val
);
}
}
}
foreach
(
$temp
as
$k
=>
$v
) {
$paystatus
=
$paymodel
->hasCharge(
$v
,
$tomorrow
,
$today
-1);
isset(
$paystatus
) &&
$paystatus
[
'num'
]<>0 ?
$num
++ :
""
;
}
$ret
[
'payrate'
][
'all'
] =
$temp
;
$ret
[
'payrate'
][
'total'
] =
count
(
$temp
);
$ret
[
'payrate'
][
'num'
] =
$num
;
}
return
$this
->ret(
$ret
);
}