<?php
/**
 * @package merchant
 * @Author: Qinii
 * @Date: 2020/5/8
 */

namespace app\common\model\store\product;

use app\common\model\BaseModel;

class ProductAttrValue extends BaseModel
{


    /**
     * @Author:Qinii
     * @Date: 2020/5/8
     * @return string
     */
    public static function tablePk(): string
    {
        return '';
    }


    /**
     * @Author:Qinii
     * @Date: 2020/5/8
     * @return string
     */
    public static function tableName(): string
    {
        return 'store_product_attr_value';
    }

    public function getDetailAttr($value)
    {
        return json_decode($value);
    }

    public function getBcExtensionOneAttr($value)
    {
        $status = intval(systemConfig('extension_status'));
        if (!$value && $status)
            return floatval(bcmul(systemConfig('extension_one_rate'), $this->price, 2));
        return $status ? $value : 0;
    }

    public function getBcExtensionTwoAttr($value)
    {
        $status = intval(systemConfig('extension_status'));
        if (!$value && $status)
            return floatval(bcmul(systemConfig('extension_two_rate'), $this->price, 2));
        return $status ? $value : 0;
    }
    public function getPriceAttr($value)
    {
        return set_price_rtrim($value);
    }
}
