StatYjMonthClass.php 1014 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace bizGhs\stat\classes;
  3. use bizGhs\shop\classes\ShopAdminClass;
  4. use common\components\arrayUtil;
  5. use Yii;
  6. use bizGhs\base\classes\BaseClass;
  7. class StatYjMonthClass extends BaseClass
  8. {
  9. public static $baseFile = '\bizGhs\stat\models\StatYjMonth';
  10. //增加业绩 ssh 2021.3.15
  11. public static function addYj($main, $shop, $shopAdminId, $amount, $month = null)
  12. {
  13. $sjId = $shop->sjId ?? 0;
  14. $mainId = $main->id ?? 0;
  15. $month = isset($month) ? $month : date("Ym");
  16. $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'time' => $month], true);
  17. if (empty($stat)) {
  18. $stat = self::add(['sjId' => $sjId, 'time' => $month, 'mainId' => $mainId, 'shopAdminId' => $shopAdminId], true);
  19. }
  20. $stat->num += 1;
  21. $stat->totalNum += 1;
  22. $stat->amount = bcadd($amount, $stat->amount, 2);
  23. $stat->totalAmount = bcadd($amount, $stat->totalAmount, 2);
  24. $stat->save();
  25. $stat->save();
  26. }
  27. }