| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace bizHd\stat\services;
- use bizHd\base\services\BaseService;
- use bizHd\stat\classes\StatIncomeClass;
- use common\components\dateUtil;
- use common\components\util;
- use Yii;
- class StatIncomeService extends BaseService
- {
- public static $baseFile = '\bizHd\stat\classes\StatIncomeClass';
- //取今天的数据 ssh 2019.9.8
- public static function getTodayNum($mainId)
- {
- $today = date("Ymd");
- return StatIncomeClass::getByCondition(['time' => $today, 'mainId' => $mainId]);
- }
- 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, $shopId)
- {
- $list = self::getAllList('*', ['shopId' => $shopId, 'time' => ['between', [$start, $end]]], 'time asc');
- return $list;
- }
- //最近7天收入情况 ssh 2020.2.2
- public static function getLatestSevenDay($shopId)
- {
- $return = dateUtil::getDate(2);
- $start = $return[0];
- $end = $return[1];
- $list = self::getLatestIncome($start, $end, $shopId);
- $data = [];
- if (!empty($list)) {
- foreach ($list as $key => $val) {
- $date = date('n-j', strtotime($val['time']));
- $income = $val['amount'];
- $data[$date] = $income;
- }
- }
- return $data;
- }
- }
|