<?php

namespace app\common\model\hu;

use think\Model;
use traits\model\SoftDelete;

class Goods extends Model
{

    use SoftDelete;



    // 表名
    protected $name = 'hu_goods';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
//        'status_text',
//        'pay_time_text',
//        'send_time_text',
//        'receive_time_text'
    ];

    /**
     * 计算订单商品总价
     * @param $goods_id  商品ID
     * @param $num  数量
     * @return int|mixed|string
     */
    public function computePrice($goods_id,$num){

        $price = self::where('id',$goods_id)->value('price');

        return bcmul((string)$price,(string)$num,2);

    }

}
