CloudStockLevelService.php 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace addons\CloudStock\common\services;
  3. use addons\CloudStock\common\models\CloudStockLevel;
  4. use common\enums\StatusEnum;
  5. class CloudStockLevelService extends BaseService
  6. {
  7. /**
  8. * @param int $number
  9. * @param bool $isCheckMin
  10. *
  11. * @return bool
  12. */
  13. public function checkFillOnceMinAndMax(int $number, bool $isCheckMin = true): bool
  14. {
  15. $cloud_stock_level = CloudStockLevel::findOne(['mall_id'=>$this->mall_id,'status'=>StatusEnum::ENABLED,'level'=>$this->stock_agent->level]);
  16. if(!empty($cloud_stock_level) && !empty($cloud_stock_level['is_open_fill_min_once'])){
  17. if($number > $cloud_stock_level['fill_max_once']){
  18. $this->setError('提货数量超过了一次性最高提货数量');
  19. return false;
  20. }
  21. if($isCheckMin && $number < $cloud_stock_level['fill_min_once']){
  22. $this->setError('提货数量未达到一次性最低提货数量');
  23. return false;
  24. }
  25. }
  26. return true;
  27. }
  28. }