|
|
@ -0,0 +1,36 @@ |
|
|
|
<?php |
|
|
|
namespace backend\modules\shop\logic; |
|
|
|
|
|
|
|
use Yii; |
|
|
|
use yii\base\Exception; |
|
|
|
|
|
|
|
class CommonManager |
|
|
|
{ |
|
|
|
//单位类型
|
|
|
|
const UNIT_TYPE_WEIGHT = 1; //重量
|
|
|
|
const UNIT_TYPE_MONEY = 2; //金额
|
|
|
|
const UNIT_TYPE_ITEM = 3; //件
|
|
|
|
|
|
|
|
/** |
|
|
|
* @param $type |
|
|
|
* @param $value |
|
|
|
* @return int |
|
|
|
* 比例转换 |
|
|
|
*/ |
|
|
|
public static function proportionalConversion($type, $value) |
|
|
|
{ |
|
|
|
switch ($type) { |
|
|
|
case self::UNIT_TYPE_WEIGHT: |
|
|
|
return 1000; |
|
|
|
break; |
|
|
|
case self::UNIT_TYPE_MONEY: |
|
|
|
return 100; |
|
|
|
break; |
|
|
|
case self::UNIT_TYPE_ITEM: |
|
|
|
return 1; |
|
|
|
break; |
|
|
|
default: |
|
|
|
return 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |