| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace bizHd\stat\classes;
- use bizHd\stat\models\StatOrderMonth;
- use Yii;
- use bizHd\base\classes\BaseClass;
- class StatOrderMonthClass extends BaseClass
- {
- public static $baseFile = '\bizHd\stat\models\StatOrderMonth';
- //月订单数增加 ssh 2020.5.25
- public static function addOrder($sjId, $asset, $month = null)
- {
- $month = isset($month) ? $month : date("Ym");
- $stat = self::getByCondition(['sjId' => $sjId, 'time' => $month], true);
- if (empty($stat)) {
- $stat = self::add(['sjId' => $sjId, 'time' => $month], true);
- }
- $stat->riseNum += 1;
- $stat->save();
- }
- //月订单+1
- public static function updateOrInsert($main, $shop)
- {
- $time = date('Ym');
- $mainId = $shop->mainId ?? 0;
- $where = ['mainId' => $mainId, 'time' => $time];
- $model = self::getByCondition($where, true);
- if (empty($model)) {
- $model = self::add(['mainId' => $mainId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $main->totalOrderNum], true);
- }
- $id = $model->id;
- //查id行级锁
- $stat = StatOrderMonthClass::getLockById($id);
- $stat->riseNum += 1;
- $stat->totalNum += 1;
- $stat->save();
- }
- }
|