| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace common\services;
- use Yii;
- use common\models\xhOrderMonthNum;
- use common\components\dict;
- class xhOrderMonthNumService {
-
- /**
- * 增加一条订单数
- */
- public static function addOne($year,$month,$sjId)
- {
- $order = self::getByIds($year,$month,$sjId);
- if(empty($order)){
- $data = ['year'=>date("Y"),'month'=>date("m"),'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($year,$month,$sjId, $data);
- }
- return $data;
- }
- public static function updateByIds($year,$month,$sjId,$data)
- {
- xhOrderMonthNum::updateByCondition(['year'=>$year,'month'=>$month,'sjId'=>$sjId], $data);
- }
-
- public static function add($data)
- {
- $return = xhOrderMonthNum::add($data);
- return $return;
- }
-
- public static function getByIds($year,$month,$sjId)
- {
- $order = xhOrderMonthNum::find()->where(['year'=>$year,'month'=>$month,'sjId'=>$sjId])->asArray()->one();
- return $order;
- }
- }
|