checkTradeBySn($sn); $response = null; if ($trade->channel == TradeModel::CHANNEL_ALIPAY) { $alipay = new Alipay(); $response = $alipay->wap($trade); } elseif ($trade->channel == TradeModel::CHANNEL_WXPAY) { $wxpay = new Wxpay(); $response = $wxpay->wap($trade); } return $response; } public function createH5Trade() { $post = $this->request->getPost(); $validator = new ClientValidator(); $platform = $this->getPlatform(); $validator->checkH5Platform($platform); $order = $this->checkOrderBySn($post['order_sn']); $user = $this->getLoginUser(); $validator = new TradeValidator(); $channel = $validator->checkChannel($post['channel']); $trade = new TradeModel(); $trade->subject = $order->subject; $trade->amount = $order->amount; $trade->channel = $channel; $trade->order_id = $order->id; $trade->owner_id = $user->id; $trade->create(); return $trade; } public function createMpTrade() { $post = $this->request->getPost(); $validator = new ClientValidator(); $platform = $this->getPlatform(); $platform = $validator->checkMpPlatform($platform); $order = $this->checkOrderBySn($post['order_sn']); $user = $this->getLoginUser(); $channel = TradeModel::CHANNEL_WXPAY; if ($platform == ClientModel::TYPE_MP_ALIPAY) { $channel = TradeModel::CHANNEL_ALIPAY; } elseif ($platform == ClientModel::TYPE_MP_WEIXIN) { $channel = TradeModel::CHANNEL_WXPAY; } $trade = new TradeModel(); $trade->subject = $order->subject; $trade->amount = $order->amount; $trade->channel = $channel; $trade->order_id = $order->id; $trade->owner_id = $user->id; $trade->create(); $response = null; if ($post['channel'] == TradeModel::CHANNEL_ALIPAY) { $alipay = new Alipay(); $buyerId = ''; $response = $alipay->mini($trade, $buyerId); } elseif ($post['channel'] == TradeModel::CHANNEL_WXPAY) { $wxpay = new Wxpay(); $openId = ''; $response = $wxpay->mini($trade, $openId); } return $response; } public function createAppTrade() { } protected function getPlatform() { return $this->request->getHeader('X-Platform'); } }