| 12345678910111213141516171819202122232425262728293031 |
- <?php
- namespace bizHd\stat\classes;
- use Yii;
- use bizHd\base\classes\BaseClass;
- class StatWorkCatClass extends BaseClass
- {
- public static $baseFile = '\bizHd\stat\models\StatWorkCat';
- public static function replace($main, $catId, $catName, $workNum, $num)
- {
- $time = date('Ymd');
- $mainId = $main->id ?? 0;
- $where = ['mainId' => $mainId, 'catId' => $catId, 'time' => $time];
- $model = self::getByCondition($where, true);
- if (empty($model)) {
- $data = ['mainId' => $mainId, 'time' => $time, 'catId' => $catId, 'catName' => $catName];
- $model = self::add($data, true);
- }
- $id = $model->id;
- $stat = self::getLockById($id);
- $stat->workNum = bcadd($workNum, $stat->workNum);
- $stat->num = bcadd($num, $stat->num);
- $stat->save();
- StatWorkCatMonthClass::replace($main, $catId, $catName, $workNum, $num);
- }
- }
|