|
@@ -59,7 +59,7 @@ class Cron
|
|
|
|
|
|
public function sell_month_api()
|
|
|
{
|
|
|
- $num = Dever::input('num', 1);
|
|
|
+ $num = Dever::input('num', -1);
|
|
|
if ($num > 0) {
|
|
|
$month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
|
|
|
} else {
|
|
@@ -91,4 +91,115 @@ class Cron
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public function buy_month_api()
|
|
|
+ {
|
|
|
+ $num = Dever::input('num', -1);
|
|
|
+ if ($num > 0) {
|
|
|
+ $month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
|
|
|
+ } else {
|
|
|
+ $month = Dever::input('start', date('Y-m'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $where['status'] = '5,6';
|
|
|
+ $start = Dever::maketime($month . '-01 00:00:00');
|
|
|
+ $end = Dever::maketime($month . '-31 23:59:59');
|
|
|
+
|
|
|
+ $shop = Dever::db('shop/info')->select();
|
|
|
+
|
|
|
+ foreach ($shop as $k => $v) {
|
|
|
+ $where['type'] = 1;
|
|
|
+ $where['type_id'] = $v['id'];
|
|
|
+ $where['start'] = $start;
|
|
|
+ $where['end'] = $end;
|
|
|
+ $data = array();
|
|
|
+ $data['shop_id'] = $v['id'];
|
|
|
+ $data['month'] = $start;
|
|
|
+ $info = Dever::db('shop/buy_stat_month')->find($data);
|
|
|
+ $data['cash'] = Dever::db('shop/buy_order')->getCashNum($where);
|
|
|
+ $data['order'] = Dever::db('shop/buy_order')->getOrderNum($where);
|
|
|
+ $data['goods'] = Dever::db('shop/buy_order')->getGoodsNum($where);
|
|
|
+ if (!$info) {
|
|
|
+ Dever::db('shop/buy_stat_month')->insert($data);
|
|
|
+ } else {
|
|
|
+ $data['where_id'] = $info['id'];
|
|
|
+ Dever::db('shop/buy_stat_month')->update($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function store_month_api()
|
|
|
+ {
|
|
|
+ $num = Dever::input('num', -1);
|
|
|
+ if ($num > 0) {
|
|
|
+ $month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
|
|
|
+ } else {
|
|
|
+ $month = Dever::input('start', date('Y-m'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $where['status'] = '5,6';
|
|
|
+ $start = Dever::maketime($month . '-01 00:00:00');
|
|
|
+ $end = Dever::maketime($month . '-31 23:59:59');
|
|
|
+
|
|
|
+ $store = Dever::db('store/info')->select();
|
|
|
+
|
|
|
+ foreach ($store as $k => $v) {
|
|
|
+ $where['type'] = 2;
|
|
|
+ $where['type_id'] = $v['id'];
|
|
|
+ $where['start'] = $start;
|
|
|
+ $where['end'] = $end;
|
|
|
+ $data = array();
|
|
|
+ $data['store_id'] = $v['id'];
|
|
|
+ $data['month'] = $start;
|
|
|
+ $info = Dever::db('shop/store_stat_month')->find($data);
|
|
|
+ $data['cash'] = Dever::db('shop/buy_order')->getCashNum($where);
|
|
|
+ $data['order'] = Dever::db('shop/buy_order')->getOrderNum($where);
|
|
|
+ $data['goods'] = Dever::db('shop/buy_order')->getGoodsNum($where);
|
|
|
+ if (!$info) {
|
|
|
+ Dever::db('shop/store_stat_month')->insert($data);
|
|
|
+ } else {
|
|
|
+ $data['where_id'] = $info['id'];
|
|
|
+ Dever::db('shop/store_stat_month')->update($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function factory_month_api()
|
|
|
+ {
|
|
|
+ $num = Dever::input('num', -1);
|
|
|
+ if ($num > 0) {
|
|
|
+ $month = Dever::input('start', date('Y-m', strtotime('-'.$num.' month')));
|
|
|
+ } else {
|
|
|
+ $month = Dever::input('start', date('Y-m'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $where['status'] = '5,6';
|
|
|
+ $start = Dever::maketime($month . '-01 00:00:00');
|
|
|
+ $end = Dever::maketime($month . '-31 23:59:59');
|
|
|
+
|
|
|
+ $factory = Dever::db('factory/info')->select();
|
|
|
+
|
|
|
+ foreach ($factory as $k => $v) {
|
|
|
+ $where['source_type'] = 3;
|
|
|
+ $where['source_id'] = $v['id'];
|
|
|
+ $where['start'] = $start;
|
|
|
+ $where['end'] = $end;
|
|
|
+ $data = array();
|
|
|
+ $data['factory_id'] = $v['id'];
|
|
|
+ $data['month'] = $start;
|
|
|
+ $info = Dever::db('shop/factory_stat_month')->find($data);
|
|
|
+ $data['cash'] = Dever::db('shop/buy_order')->getCashNum($where);
|
|
|
+ $data['order'] = Dever::db('shop/buy_order')->getOrderNum($where);
|
|
|
+ $data['goods'] = Dever::db('shop/buy_order')->getGoodsNum($where);
|
|
|
+ if (!$info) {
|
|
|
+ Dever::db('shop/factory_stat_month')->insert($data);
|
|
|
+ } else {
|
|
|
+ $data['where_id'] = $info['id'];
|
|
|
+ Dever::db('shop/factory_stat_month')->update($data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|