| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace biz\stat\classes;
- use biz\stat\models\StatOrderCount;
- use bizHd\base\classes\BaseClass;
- class StatOrderCountClass extends BaseClass
- {
- public static $baseFile = '\biz\stat\models\StatOrderCount';
- //每天订单
- public static function addOrder($shop, $main)
- {
- $time = date('Ymd');
- $shopId = $shop->id;
- $sjId = $shop->sjId;
- $where = [
- 'shopId' => $shopId,
- 'time' => $time,
- ];
- $model = self::getByCondition($where, true);
- if (empty($model)) {
- $model = self::add(['sjId' => $sjId, 'shopId' => $shopId, 'time' => $time, 'riseNum' => 0, 'totalNum' => $main->totalOrder], true);
- }
- $id = $model->id;
- //查id行级锁
- $stat = StatOrderCount::findBySql('select * from ' . StatOrderCount::tableName() . ' where id = :id for update', ['id' => $id])->one();
- $stat->riseNum += 1;
- $stat->totalNum += 1;
- $stat->save();
- return $stat->riseNum;
- }
- }
|