request->post(); if(!isset($post['pay_way'])) { return JsonServer::error('请选择支付方式'); } if ($post['from'] == 'order') { // 更新支付方式 $order = Order::findOrEmpty($post['order_id']); $order->pay_way = $post['pay_way']; $order->save(); $pay_way = $order['pay_way']; } if ($post['from'] == 'trade') { $order = Order::where('trade_id', $post['order_id'])->findOrEmpty(); // 更新支付方式 Order::where('trade_id', $post['order_id'])->update(['pay_way' => $post['pay_way']]); $pay_way = $post['pay_way']; } if ($post['from'] == 'recharge') { $pay_way = isset($post['pay_way']) ? $post['pay_way'] : PayEnum::WECHAT_PAY; } // 积分订单 if ($post['from'] == 'integral') { $order = IntegralOrder::findOrEmpty($post['order_id']); IntegralOrder::where('id', $post['order_id'])->update(['pay_way' => $post['pay_way']]); $pay_way = $post['pay_way']; } // order,trade方式金额为0直接走余额支付 if (isset($order) && $order['order_amount'] == 0) { $result = PayLogic::balancePay($post['order_id'], $post['from']); return $result; } switch ($pay_way) { case OrderEnum::PAY_WAY_BALANCE://余额支付 $result = PayLogic::balancePay($post['order_id'], $post['from']); break; case OrderEnum::PAY_WAY_WECHAT://微信支付 if (empty($post['openid'])) { //微信支付时必须传openid过来 return JsonServer::error('缺少openid'); } $result = PayLogic::wechatPay($post['order_id'], $post['from'], $this->client, $post['openid']); break; case OrderEnum::PAY_WAY_ALIPAY://支付宝支付 $result = PayLogic::aliPay($post['order_id'], $post['from'],$this->client); $data = [ 'code' => 10001, 'msg' => '发起成功', 'data' => $result, 'show' => 0, ]; return json($data); break; } return $result; } /** * @notes 小程序回调 * @throws \EasyWeChat\Kernel\Exceptions\Exception * @author suny * @date 2021/7/13 6:13 下午 */ public function notifyMnp() { $config = WeChatServer::getPayConfig(Client_::mnp); return WeChatPayServer::notify($config); } /** * @notes 公众号回调 * @throws \EasyWeChat\Kernel\Exceptions\Exception * @author suny * @date 2021/7/13 6:13 下午 */ public function notifyOa() { $config = WeChatServer::getPayConfig(Client_::oa); return WeChatPayServer::notify($config); } /** * @notes APP回调 * @throws \EasyWeChat\Kernel\Exceptions\Exception * @author suny * @date 2021/7/13 6:14 下午 */ public function notifyApp() { $config = WeChatServer::getPayConfig(Client_::ios); return WeChatPayServer::notify($config); } /** * @notes 支付宝回调 * @return bool * @author suny * @date 2021/7/13 6:14 下午 */ public function aliNotify() { $data = $this->request->post(); $result = (new AliPayServer())->verifyNotify($data); if (true === $result) { echo 'success'; } else { echo 'fail'; } } }