price($mchid,$spec,$card_type,$quality,$pcode); if ($price === false or $price <= 0.01) { throw new Exception("没有协商商品购买价格."); } else { $this->mPrice = $price; } } public function calc_vgoods_price($goods_info) { return round($this->mPrice,4); } public function calc_vorder_amount($order_info) { $num = $order_info['quantity']; return round($this->mPrice * $num,4); } public function calc_tips() { Log::record("没有实现该接口" . __FUNCTION__, Log::ERR); return []; } } class ZeroMerchantPrice implements ICalc { public function __construct($mchid,$amount,$card_type,$quality) { } public function calc_vgoods_price($goods_info) { return round(0,4); } public function calc_vorder_amount($order_info) { return round(0,4); } public function calc_tips() { Log::record("没有实现该接口" . __FUNCTION__ ,Log::ERR); return []; } }