| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace bizGhs\stat\classes;
- use bizGhs\shop\classes\ShopAdminClass;
- use common\components\arrayUtil;
- use Yii;
- use bizGhs\base\classes\BaseClass;
- class StatYjMonthClass extends BaseClass
- {
- public static $baseFile = '\bizGhs\stat\models\StatYjMonth';
- //增加业绩 ssh 2021.3.15
- public static function addYj($main, $shop, $shopAdminId, $amount, $month = null)
- {
- $sjId = $shop->sjId ?? 0;
- $mainId = $main->id ?? 0;
- $month = isset($month) ? $month : date("Ym");
- $stat = self::getByCondition(['sjId' => $sjId, 'mainId' => $mainId, 'time' => $month], true);
- if (empty($stat)) {
- $stat = self::add(['sjId' => $sjId, 'time' => $month, 'mainId' => $mainId, 'shopAdminId' => $shopAdminId], true);
- }
- $stat->num += 1;
- $stat->totalNum += 1;
- $stat->amount = bcadd($amount, $stat->amount, 2);
- $stat->totalAmount = bcadd($amount, $stat->totalAmount, 2);
- $stat->save();
- $stat->save();
- }
- }
|