StatIncomeUsageMonthService.php 916 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace bizHd\stat\services;
  3. use bizHd\base\services\BaseService;
  4. use common\components\business;
  5. use Yii;
  6. class StatIncomeUsageMonthService extends BaseService
  7. {
  8. public static $baseFile = '\bizHd\stat\classes\StatIncomeUsageMonthClass';
  9. //添加更新记录 ssh 2019.9.16
  10. public static function replaceData($data)
  11. {
  12. $sjId = $data['sjId'];
  13. $usageId = $data['usageId'];
  14. $amount = $data['amount'];
  15. $data['year'] = isset($data['year']) ? $data['year'] : date("Y");
  16. $data['month'] = isset($data['month']) ? $data['month'] : date("n");
  17. $income = self::getByCondition(['sjId' => $sjId, 'year' => $data['year'], 'month' => $data['month'], 'usageId' => $usageId], true);
  18. if (empty($income)) {
  19. $income = self::add($data, true);
  20. } else {
  21. $income->amount += $amount;
  22. }
  23. $income = business::savePayWayAmount($income, $amount, $data['payWay']);
  24. $income->save();
  25. return true;
  26. }
  27. }