getNotify(); if ($notify['result_code'] == 'SUCCESS' && $notify['return_code'] == 'SUCCESS') { if ($scene === 'order') { if ($this->setOrder($notify['out_trade_no'], $notify['cash_fee'] / 100, $notify['transaction_id'], 'wxpay')) { return $payment->getNotifySuccessReply(); } } // ... 其他支付场景 } return $payment->getNotifySuccessReply(); } /** * 订单状态更新 * @param string $code 订单单号 * @param string $amount 交易金额 * @param string $paycode 交易单号 * @param string $paytype 支付类型 * @return boolean * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ private function setOrder(string $code, string $amount, string $paycode, string $paytype = 'wxpay') { // 检查订单支付状态 $map = ['order_no' => $code, 'payment_status' => 0, 'status' => 2]; $order = $this->app->db->name('StoreOrder')->where($map)->find(); if (empty($order)) return false; // 更新订单支付状态 $this->app->db->name('StoreOrder')->where($map)->update([ 'status' => 3, 'payment_type' => $paytype, 'payment_code' => $paycode, 'payment_status' => 1, 'payment_amount' => $amount, 'payment_remark' => '微信在线支付', 'payment_datetime' => date('Y-m-d H:i:s'), ]); // 调用会员升级机制 return OrderService::instance()->syncAmount($order['order_no']); } }