| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace common\services;
- use Yii;
- use common\models\xhOrderDayNum;
- use common\components\dict;
- class xhOrderDayNumService {
- /**
- * 增加一条订单数
- */
- public static function addOne($time,$sjId)
- {
- $order = self::getByIds($time, $sjId);
- if(empty($order)){
- $data = ['time'=>$time,'riseNum'=>1,'totalNum'=>1,'sjId'=>$sjId];
- self::add($data);
- }else{
- $newRiseNum = $order['riseNum'] + 1;
- $newTotalNum = $order['totalNum'] + 1;
- $data = ['riseNum'=>$newRiseNum,'totalNum'=>$newTotalNum];
- self::updateByIds($time, $sjId, $data);
- }
- return $data;
- }
- public static function updateByIds($time,$sjId,$data)
- {
- xhOrderDayNum::updateByCondition(['time'=>$time,'sjId'=>$sjId], $data);
- }
- public static function add($data)
- {
- $return = xhOrderDayNum::add($data);
- return $return;
- }
- public static function getByIds($time,$sjId)
- {
- $order = xhOrderDayNum::find()->where(['time'=>$time,'sjId'=>$sjId])->asArray()->one();
- return $order;
- }
- }
|