|
@@ -6,11 +6,34 @@ use Dever;
|
|
|
|
|
|
class Cron
|
|
|
{
|
|
|
+ private function check($info)
|
|
|
+ {
|
|
|
+ if (!$info['stat_day']) {
|
|
|
+ $info['stat_day'] = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($info['stat_type'] == 1) {
|
|
|
+ $day = intval(date('d'));
|
|
|
+ if ($day != $info['stat_day']) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } elseif ($info['stat_type'] == 2) {
|
|
|
+ $day = intval(date('w'));
|
|
|
+ if (!$day || $day == 0) {
|
|
|
+ $day = 7;
|
|
|
+ }
|
|
|
+ if ($day != $info['stat_day']) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public function shop_api(){}
|
|
|
public function shop()
|
|
|
{
|
|
|
- $num = Dever::input('num', -1);
|
|
|
+ $num = Dever::input('num', 1);
|
|
|
|
|
|
$where['status'] = 2;
|
|
|
|
|
@@ -26,7 +49,7 @@ class Cron
|
|
|
public function store_api(){}
|
|
|
public function store()
|
|
|
{
|
|
|
- $num = Dever::input('num', -1);
|
|
|
+ $num = Dever::input('num', 1);
|
|
|
|
|
|
$where['status'] = 2;
|
|
|
|
|
@@ -36,13 +59,17 @@ class Cron
|
|
|
$where['type'] = 2;
|
|
|
$where['type_id'] = $v['id'];
|
|
|
$this->up($where, $v, 'store', $num);
|
|
|
+
|
|
|
+ $where['source_type'] = 2;
|
|
|
+ $where['source_id'] = $v['id'];
|
|
|
+ $this->up($where, $v, 'store', $num);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function factory_api(){}
|
|
|
public function factory()
|
|
|
{
|
|
|
- $num = Dever::input('num', -1);
|
|
|
+ $num = Dever::input('num', 1);
|
|
|
|
|
|
$where['status'] = 2;
|
|
|
|
|
@@ -57,11 +84,17 @@ class Cron
|
|
|
|
|
|
private function up($where, $info, $type, $num)
|
|
|
{
|
|
|
- if ($info['stat_type'] == 2) {
|
|
|
+ $state = $this->check($info);
|
|
|
+ if (!$state) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($info['stat_type'] == 1) {
|
|
|
+ $method = 'month';
|
|
|
+ } elseif ($info['stat_type'] == 2) {
|
|
|
$method = 'week';
|
|
|
} else {
|
|
|
- $method = 'month';
|
|
|
- }
|
|
|
+ $method = 'day';
|
|
|
+ }
|
|
|
|
|
|
list($start, $end) = Dever::$method($num);
|
|
|
|
|
@@ -88,7 +121,6 @@ class Cron
|
|
|
$data['num'] = $num['total'] ? $num['total'] : 0;
|
|
|
$data['start'] = $start;
|
|
|
$data['end'] = $end;
|
|
|
-
|
|
|
if (!$find) {
|
|
|
$id = Dever::db('cash/' . $type)->insert($data);
|
|
|
} else {
|