| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace bizMall\stat\services;
- use bizMall\base\services\BaseService;
- use bizMall\stat\classes\StatIncomeClass;
- use common\components\dateUtil;
- use common\components\util;
- use Yii;
- class StatIncomeService extends BaseService
- {
-
- public static $baseFile = '\bizMall\stat\classes\StatIncomeClass';
-
- //取今天的数据 ssh 2019.9.8
- public static function getTodayNum($sjId)
- {
- $today = date("Ymd");
- return StatIncomeClass::getByCondition(['sjId' => $sjId, 'time' => $today]);
- }
-
- public static function checkUp($id, $sjId)
- {
- $stat = self::getById($id, true);
- if ($stat->sjId != $sjId) {
- util::fail('你没有权限');
- }
- if ($stat->checkUp == 1) {
- util::fail('你已经对过帐了');
- }
- $stat->checkUp = 1;
- $stat->save();
- return true;
- }
-
- //获取最近的收入情况 ssh 2019.9.21
- public static function getLatestIncome($start, $end, $sjId)
- {
- $list = self::getAllList('*', ['sjId' => $sjId, 'time' => ['between', [$start, $end]]], 'time asc');
- return $list;
- }
-
- //最近7天收入情况 ssh 2020.2.2
- public static function getLatestSevenDay($sjId)
- {
- $return = dateUtil::getDate(1);
- $start = $return[0];
- $end = $return[1];
- $list = self::getLatestIncome($start, $end, $sjId);
- $data = [];
- if (!empty($list)) {
- foreach ($list as $key => $val) {
- $date = $val['time'];
- $income = $val['amount'];
- $data[$date] = $income;
- }
- }
- return $data;
- }
- }
|