You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
769 B

  1. <?php
  2. namespace backend\modules\shop\logic;
  3. use Yii;
  4. use yii\base\Exception;
  5. class CommonManager
  6. {
  7. //单位类型
  8. const UNIT_TYPE_WEIGHT = 1; //重量
  9. const UNIT_TYPE_MONEY = 2; //金额
  10. const UNIT_TYPE_ITEM = 3; //件
  11. /**
  12. * @param $type
  13. * @param $value
  14. * @return int
  15. * 比例转换
  16. */
  17. public static function proportionalConversion($type, $value)
  18. {
  19. switch ($type) {
  20. case self::UNIT_TYPE_WEIGHT:
  21. return 1000;
  22. break;
  23. case self::UNIT_TYPE_MONEY:
  24. return 100;
  25. break;
  26. case self::UNIT_TYPE_ITEM:
  27. return 1;
  28. break;
  29. default:
  30. return 1;
  31. }
  32. }
  33. }