| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace biz\stat\services;
- use biz\base\services\BaseService;
- use common\components\business;
- use Yii;
- class StatIncomeUsageMonthService extends BaseService
- {
-
- public static $baseFile = '\biz\stat\classes\StatIncomeUsageMonthClass';
-
- //添加更新记录 shish 2019.9.16
- public static function replaceData($data)
- {
- $merchantId = $data['merchantId'];
- $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(['merchantId' => $merchantId, '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;
- }
-
- }
|