public function createUnifiedOrder($out_trade_no, $subject, $total_fee, $open_id = null) { //②、统一下单 $input = new \WxPayUnifiedOrder(); $input->setWxPayApi($this->wxPayApi); $input->SetBody($subject); $input->SetOut_trade_no($out_trade_no); // $input->SetTotal_fee($total_fee); $input->SetTotal_fee(intval($total_fee * 100)); $input->SetTime_start(date("YmdHis")); $input->SetTime_expire(date("YmdHis", time() + 600)); $input->SetTrade_type($this->trade_type); if ($open_id) { $input->SetOpenid($open_id); } $order = $this->wxPayApi->unifiedOrder($input); return $order; }