getPrices($mchid,$amount); $match = false; foreach ($items as $item) { $types = $item['card_types']; $types = explode(',',$types); if(in_array($card_type,$types)) { $this->mPrice = round($item['price'],2); $match = true; break; } } if($match === false) { throw new Exception("没有协商商品购买价格."); } } public function calc_vgoods_price($goods_info) { return round($this->mPrice,2); } public function calc_vorder_amount($order_info) { $num = $order_info['quantity']; return round($this->mPrice * $num,2); } public function calc_tips() { Log::record("没有实现该接口" . __FUNCTION__ ,Log::ERR); return []; } } class ZeroMerchantPrice implements ICalc { public function __construct($mchid,$amount,$card_type) { } public function calc_vgoods_price($goods_info) { return round(0,2); } public function calc_vorder_amount($order_info) { return round(0,2); } public function calc_tips() { Log::record("没有实现该接口" . __FUNCTION__ ,Log::ERR); return []; } }