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