public function actionSale()
 {
     $params = $this->getParams();
     $accountId = $this->getAccountId();
     if (empty($params['status']) || empty($params['storeGoodsIds'])) {
         throw new BadRequestHttpException(Yii::t('common', 'parameters_missing'));
     }
     $storeGoodsIds = [];
     foreach ($params['storeGoodsIds'] as $id) {
         $storeGoodsIds[] = new \MongoId($id);
     }
     $storeGoods = StoreGoods::getByIds($storeGoodsIds);
     if (count($storeGoods) != count($params['storeGoodsIds'])) {
         throw new InvalidParameterException(Yii::t('store', 'invalid_goods_id'));
     }
     if ($params['status'] == StoreGoods::STATUS_ON) {
         //check the store goods are not on shelves
         if (!empty(StoreGoods::getOnSaleByIds($storeGoodsIds, $accountId))) {
             throw new InvalidParameterException(Yii::t('store', 'sale_on_shelves'));
         }
         StoreGoods::updateStatusByIds($storeGoodsIds, StoreGoods::STATUS_ON, new \MongoDate());
     } else {
         if ($params['status'] == StoreGoods::STATUS_OFF && isset($params['onSaleTime']) && $params['onSaleTime'] !== '') {
             //check the store goods are not on shelves
             if (!empty(StoreGoods::getOnSaleByIds($storeGoodsIds, $accountId))) {
                 throw new InvalidParameterException(Yii::t('store', 'sale_on_shelves'));
             }
             $onSaleTime = TimeUtil::ms2sTime($params['onSaleTime']);
             if (time() > $onSaleTime) {
                 throw new InvalidParameterException(['onSaleTime' => \Yii::t('product', 'not_less_than_current')]);
             } else {
                 StoreGoods::updateStatusByIds($storeGoodsIds, StoreGoods::STATUS_OFF, new \MongoDate($onSaleTime));
             }
         } else {
             if ($params['status'] == StoreGoods::STATUS_OFF && (!isset($params['onSaleTime']) || $params['onSaleTime'] === '')) {
                 StoreGoods::updateStatusByIds($storeGoodsIds, StoreGoods::STATUS_OFF, null, new \MongoDate());
             } else {
                 throw new BadRequestHttpException(Yii::t('common', 'data_error'));
             }
         }
     }
     return ['message' => 'OK', 'data' => null];
 }