user_id; $post = $this->request->post(); if(!isset($post['pay_way'])) { return JsonServer::error('请选择支付方式'); } // 信用支付 if ($post['from'] == 'repayment') { $pay_way = $post['pay_way']; $order['order_id'] = $user_id; $post['order_id'] = $user_id; } 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']; } if( $pay_way != 5){ if($post['from'] != 'repayment'){ // order,trade方式金额为0直接走余额支付 if (isset($order) && $order['order_amount'] == 0) { $result = PayLogic::balancePay($post['order_id'], $post['from']); return $result; } } } if(isset($post['payment_method'])){ $payment_method = $post['payment_method']; }else{ $payment_method = ""; } switch ($pay_way) { case OrderEnum::PAY_WAY_BALANCE://余额支付 $result = PayLogic::balancePay($post['order_id'], $post['from']); break; case OrderEnum::PAY_WAY_WECHAT://微信支付 $result = PayLogic::wechatPay($post['order_id'], $post['from'],$payment_method, $this->client); break; case OrderEnum::PAY_WAY_XINY://信用支付 $result = PayLogic::xinyPay($post['order_id'], $post['from']); 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; } public function localPay() { $post = $this->request->post(); $user_id = $this->user_id; if(!isset($user_id)){ $user_id = $post['user_id']; } if(isset($this->client)){ $client = $this->client; }else{ $client = 1; } if($post['lid'] != 138){ return JsonServer::error('因银行及第三方系统维护中,该功能暂时无法适用,请等待通知'); } $result = PayLogic::localWxPay($user_id,$post, $client); return $result; } // 本地生活余额支付 public function localBalance() { $user_id = $this->user_id; $post = $this->request->post(); if($post['lid'] != 138){ return JsonServer::error('因银行及第三方系统维护中,该功能暂时无法适用,请等待通知'); } $result = PayLogic::localBalance($user_id,$post); return $result; } /** * @notes 小程序回调 * @throws \EasyWeChat\Kernel\Exceptions\Exception * @author suny * @date 2021/7/13 6:13 下午 */ public function notifyMnp() { $user_id = $this->user_id; $config = WeChatServer::getPayConfig(Client_::mnp); return WeChatPayServer::notify($config); } public function notifyMnp1() { //$user_id = $this->user_id; $config = WeChatServer::getPayConfig(Client_::mnp); return WeChatPayServer::notify1($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'; } } }