| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace bizHd\stat\services;
- use bizHd\base\services\BaseService;
- use common\components\business;
- use Yii;
- class StatIncomeUsageMonthService extends BaseService
- {
-
- public static $baseFile = '\bizHd\stat\classes\StatIncomeUsageMonthClass';
-
- //添加更新记录 ssh 2019.9.16
- public static function replaceData($data)
- {
- $sjId = $data['sjId'];
- $usageId = $data['usageId'];
- $amount = $data['amount'];
- $data['year'] = isset($data['year']) ? $data['year'] : date("Y");
- $data['month'] = isset($data['month']) ? $data['month'] : date("n");
- $income = self::getByCondition(['sjId' => $sjId, 'year' => $data['year'], 'month' => $data['month'], 'usageId' => $usageId], true);
- if (empty($income)) {
- $income = self::add($data, true);
- } else {
- $income->amount += $amount;
- }
- $income = business::savePayWayAmount($income, $amount, $data['payWay']);
- $income->save();
- return true;
- }
-
- }
|