后台

后台订单不连续,查看paypal收款账户发现000000157 订单用户已成功支付,但magento2后台没这个订单

用户开始投诉,运营很着急,开始找产品,产品说这是技术问题,转到技术这处理,技术开始排查

1.首先分析问题

用户已支付,订单没生成,以前的订单都没发现有这个问题,这段时间出现的

分析原因:说明paypal用户已支付了,支付成功后在通知系统时没有写到数据库里发生的问题

2.进后台先打开paypal调试,查看paypal支付日志

确实支付成功了,paypal支付是没有问题的,就看通知到系统有没有成功了

系统只有收到pyapal支付成功通知才会创建订单

报错日志

[2020-06-02 18:01:54] main.CRITICAL: The "000000117" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"000000117\" order ID is incorrect. Verify the ID and try again. at /www/wwwroot/www.xxxx.com/vendor/magento/module-paypal/Model/Ipn.php:143)"} []

3.查访问日志找支付成功通知

20/Jun/2020:00:05:40 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"
[20/Jun/2020:00:13:00 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"
[20/Jun/2020:00:29:49 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"
[20/Jun/2020:00:39:25 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"
[20/Jun/2020:01:02:26 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"
 [20/Jun/2020:01:27:10 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"
[20/Jun/2020:02:07:54 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"
[20/Jun/2020:02:14:13 +0800] "POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn )"

发现支付通知都是500异常,只有个别是200成功的

发现其它报错问题

网上搜了下发现

https://community.magento.com/t5/Magento-2-x-Technical-Issues/Successful-orders-dont-appear-on-the-admin-panel-after-online/td-p/390986#

https://github.com/magento/magento2/issues/25862

magento2.3.5以下版本都有这个问题

开始修改

\vendor\magento\module-checkout\Model\GuestPaymentInformationManagement.php

savePaymentInformationAndPlaceOrder() 方法替换

/*** @inheritdoc* 保存付款信息和订单*/public function savePaymentInformationAndPlaceOrder($cartId,$email,\Magento\Quote\Api\Data\PaymentInterface $paymentMethod,\Magento\Quote\Api\Data\AddressInterface $billingAddress = null) {$this->savePaymentInformation($cartId, $email, $paymentMethod, $billingAddress);try {$orderId = $this->cartManagement->placeOrder($cartId);} catch (\Magento\Framework\Exception\LocalizedException $e) {$this->getLogger()->critical('Placing an order with quote_id ' . $cartId . ' is failed: ' . $e->getMessage());throw new CouldNotSaveException(__($e->getMessage()),$e);} catch (\Exception $e) {$this->getLogger()->critical($e);throw new CouldNotSaveException(__('An error occurred on the server. Please try to place the order again.'),$e);}return $orderId;}

后台漏单问题解决

查找过程

POST /paypal/ipn/ HTTP/1.1" 500 - "-" "PayPal IPN ( https://www.paypal.com/ipn

\/paypal\/ipn\/ HTTP\/1.1\" 500
-----------------------------------
sed -n '/2019-12-28 11:26/,/2019-12-28 12:13/p' nohup.out | grep '接收到xx请求参数,开始处理' | wc -l
sed -n '/2019-12-28 11:26/,/2019-12-28 12:13/p' nohup.out | grep '接收到xx请求参数,开始处理' | wc -l
有效
查找ipn 200 成功的
\/paypal\/ipn\/ HTTP\/1.1" 200   
查找ipn 500
\ HTTP\/1.1" 500   
-------------------------
POST /paypal/ipn/ HTTP/1.1" 200
POST \/paypal\/ipn\/ HTTP\/1.1" 200 查找成功的
POST \/paypal\/ipn\/ HTTP\/1.1" 500 查找失败的

tail -f 实时查看日志文件 tail -f 日志文件log
tail - 10 f 实时查看日志文件 后10行
tail -f -n 10 payment.log linux查看日志后10行
搜寻字符串
grep ‘搜寻字符串’ filename
按ctrl+c 退出
------------------------------------------------------------------------------------------------

magento2.3.2漏单续集

12个月后又出现个别漏单问题

[2020-11-21 21:51:26] main.CRITICAL: The "000001203" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"000001203\" order ID is incorrect. Verify the ID and try again. at /www/wwwroot/www.xxx.com/vendor/magento/module-paypal/Model/Ipn.php:147)"} []
[2020-11-21 21:51:26] main.CRITICAL: The "000001203" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"000001203\" order ID is incorrect. Verify the ID and try again. at /www/wwwroot/www.xxx.com/vendor/magento/module-paypal/Model/Ipn.php:147)"} []
[2020-11-21 21:51:36] main.CRITICAL: The "000001203" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"000001203\" order ID is incorrect. Verify the ID and try again. at /www/wwwroot/www.xxx.com/vendor/magento/module-paypal/Model/Ipn.php:147)"} []
[2020-11-21 21:51:56] main.CRITICAL: The "000001203" order ID is incorrect. Verify the ID and try again. {"exception":"[object] (Exception(code: 0): The \"000001203\" order ID is incorrect. Verify the ID and try again. at /www/wwwroot/www.xxx.com/vendor/magento/module-paypal/Model/Ipn.php:147)"} []
[2020-11-21 21:52:05] main.CRITICAL: PayPal gateway has rejected request. Payment has already been made for this InvoiceID (#10412: Duplicate invoice). {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): PayPal gateway has rejected request. Payment has already been made for this InvoiceID (#10412: Duplicate invoice). at /www/wwwroot/www.xxx.com/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:116)"} []

本地断点调试(现金支付)magento2下单流程

vendor/magento/module-paypal/Model/Ipn.php

138  protected function _getOrder()

$this->_order = $this->_orderFactory->create()->loadByIncrementId($incrementId);

if (!$this->_order->getId()) {
      
            throw new Exception(sprintf('The "%s" order ID is incorrect. Verify the ID and try again.', $incrementId));
        }

下订单调试

checkout/Model/GuestPaymentInformationManagement.php savePaymentInformationAndPlaceOrder 101 cartId:
 checkout/Model/GuestPaymentInformationManagement.php savePaymentInformation 132
 checkout/Model/GuestPaymentInformationManagement.php limitShippingCarrier 183
 module-quote/Model/GuestCart/GuestCartManagement.php placeOrder 82:
 module-quote/Model/GuestCart/GuestCartManagement.php placeOrder 87:2525--NULL
 module-quote/Model/QuoteManagement.php placeOrder 358:
 checkout/Observer/SalesQuoteSaveAfterObserver.php execute 36
 module-quote/Model/QuoteManagement.php placeOrder 415 LastOrderId:709
 checkout/Model/GuestPaymentInformationManagement.php savePaymentInformationAndPlaceOrder 105:709
 checkout/Model/GuestPaymentInformationManagement.php savePaymentInformationAndPlaceOrder 109:709
 checkout/Model/GuestPaymentInformationManagement.php savePaymentInformationAndPlaceOrder 113:709
 checkout/Model/GuestPaymentInformationManagement.php savePaymentInformationAndPlaceOrder 120:709
 checkout/Model/Session.php setQuoteId 334
 checkout/Controller/Onepage.php dispatch 145:
 checkout/Controller/Onepage.php _canShowForUnregisteredUsers 270:
 checkout/Controller/Onepage.php getOnepage 260:
 checkout/Model/Type/Onepage.php getQuote 278
 checkout/Controller/Onepage/Session.php 513:
 checkout/Controller/Onepage.php getOnepage 260:
 checkout/Model/Session.php clearQuote 452
 checkout/Model/Session.php setQuoteId 334
 checkout/Model/Session.php 513:
 Model-sales/Model/Order.php loadByIncrementId
 checkout/Model/Session.php 513:
 checkout/Model/Session.php 513:

下单流程整理

1.用户添加购物车

购物车id生成quote    quote_address购物车地址   quote_item 购物车item   quote_item_option购物车中item项商品和数量

module-checkout/Model/GuestPaymentInformmationManagement.php

public function savePaymentInformationAndPlaceOrder(

$this->savePaymentInformation($cartId, $email, $paymentMethod, $billingAddress);   //保存bilin信息到表quote_address

$orderId = $this->cartManagement->placeOrder($cartId); //生成订单

module-quote/Model/GuestCart/GuestCartManagement.php

public function placeOrder( 方法中

$this->quoteManagement->placeOrder(

module-quote/Model/QuoteManagement.php 中

public function placeOrder( 方法

$order = $this->submit($quote);  返回的 $order 有问题
405行增加异常判断 //$order->getId() 不能为空
        if (null == $order || !$order->getId()) {
            throw new LocalizedException(
                __('A server error stopped your order from being placed. Please try to place your order again.')
            );
        }

在submit方法中

public function submit(QuoteEntity $quote, $orderData = [])
    {
        if (!$quote->getAllVisibleItems()) {
            $quote->setIsActive(false);
            return null;
        }

return $this->submitQuote($quote, $orderData);
     
    }

线上报错提示:

module-sales/Model/Service/OrderService.php place() save catch 224:000001432--We can't save the address: Email has a wrong format

电子邮件地址格式错误,在Paypal Express Checkout Magento 2.3.2上

FINDINGS

Error message comes from Magento\Quote\Model\SubmitQuoteValidator::validateOrder
but at validator method Magento\Sales\Model\Order\Address\Validator::validate
Address object returns null for email.

Paypal Express结帐无法正常工作,它显示“异常消息:我们无法保存地址:电子邮件格式错误”。但是付款成功,但未创建Magento订单。

Exception message: We can't save the address:
Email has a wrong format
Trace: <pre>#1 Magento\Framework\Model\ResourceModel\Db\AbstractDb->save() called at [vendor/magento/framework/Model/AbstractModel.php:655]

vendor/magento/module-sales/Model/Order/Address/Validator.php 并且$ address-> getEmail()变为NULL /空

paypal express checkout提交时漏单问题解决办法:

        /* set customer email if email is found empty (bug) */if ($this->_quote->getCustomerEmail() === null && $this->_quote->getBillingAddress()->getEmail() !== null) {$this->_quote->setCustomerEmail($this->_quote->getBillingAddress()->getEmail());}

app/code/Magento/Sales/Model/Order/Address.php 新增

/**
     * @inheritdoc
     */
    public function beforeSave()
    {
        if ($this->getEmail() === null) {
            $this->setEmail($this->getOrder()->getCustomerEmail());
        }
        return parent::beforeSave();
    }

vi /www/wwwroot/www.broadout.com/vendor/magento/module-quote/Model/QuoteManagement.php +379

public function placeOrder( 这个方法中
新增判断
//当email为空时
                        if(empty($quote->getCustomerEmail())){
                                file_put_contents("test.txt","\r\n module-quote/Model/QuoteManagement.php placeOrder 389:",FILE_APPEND);
                                $quote->setCustomerEmail($quote->getBillingAddress()->getEmail());
                        }
                        if (empty($quote->getCustomerEmail())) {
                                file_put_contents("test.txt","\r\n module-quote/Model/QuoteManagement.php placeOrder 399:",FILE_APPEND);
                                throw new LocalizedException(
                                        __('A server error stopped your order from being placed. Please try to place your order again.')
                                );
                        }

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

过了一周后发现还是有个别漏单问题出现

sql查询查询指定订单号
select * from quote where reserved_order_id='000001761';4538
查询quote_address指定用户地址中的emaill
select * from quote_address where quote_id='4538';
shipping  email为空查询quote_ite
select * from quote_item where quote_id='4538';查询quote_item_option
select * from quote_item_option where item_id='7648' or item_id='8394';链表查询
select b.* from quote_item a left join quote_item_option b on a.item_id=b.item_id where a.quote_id='4144';

000001761  quote_address下单时间和支付时间中间有3个小时差   发现shipping email为空
12361    4538    2020-12-29 03:32:03    2020-12-29 04:40:52             shipping                  
12387    4538    2020-12-29 06:11:04    2020-12-29 06:11:04           billing    zajpjmalloyads@aol.com        John

在下单中添加为空判断,当为空时,把已有billing email更新到shipping email中

修改一:
处理paypal express 支付email为空问题
vi vendor/magento/module-paypal/Model/Express/Checkout.php +810修正原来的/* set customer email if email is found empty (bug) */if (empty($this->_quote->getCustomerEmail())) {$this->_quote->setCustomerEmail($this->_quote->getBillingAddress()->getEmail()?$this->_quote->getBillingAddress()->getEmail():$this->_quote->getShippingAddress()->getEmail());}

在quote_address表中shipping列email为空所以下单失败

修改二:vi vendor/magento/module-quote/Model/QuoteManagement.php +507protected function submitQuote(QuoteEntity $quote, $orderData = [])
方法下增加//当用户email为空时if(empty($quote->getCustomerEmail())){$quote->setCustomerEmail($quote->getBillingAddress()->getEmail()?$quote->getBillingAddress()->getEmail():$quote->getShippingAddress()->getEmail()); file_put_contents("test.txt","\r\n module-quote/Model/QuoteManagement.php submitQuote email is null 516:".$quote->getBillingAddress()->getEmail()."--".$quote->getShippingAddress()->getEmail(),FILE_APPEND);}578行增加重复判断
//当用户email为空时if(empty($quote->getCustomerEmail())){$quote->setCustomerEmail($quote->getBillingAddress()->getEmail()?$quote->getBillingAddress()->getEmail():$quote->getShippingAddress()->getEmail());  file_put_contents("test.txt","\r\n module-quote/Model/QuoteManagement.php submitQuote email is null 582:".$quote->getBillingAddress()->getEmail()."--".$quote->getShippingAddress()->getEmail(),FILE_APPEND);}//上面是判断email为空时处理
---------------------------------------------$order->setQuoteId($quote->getId());$order->setCustomerEmail($quote->getCustomerEmail());

修改三:vi /www/wwwroot/www.broadout.com/vendor/magento/module-checkout/Model/GuestPaymentInformationManagement.php +162
//这里是自己添加的一行
$quote->getShippingAddress()->setEmail($email);

修改四:
最终保存sales_order表时 判断为空时给个默认值
vi /www/wwwroot/www.broadout.com/vendor/magento/module-sales/Model/Service/OrderService.php +231
//判断email为空时if(empty($order->getCustomerEmail())){$order->setCustomerEmail("yuanzelin8@gmail.com");file_put_contents("test.txt","\r\n module-sales/Model/Service/OrderService.php place() save email is null 233:".$order->getCustomerEmail()."--".$order->getQuoteId()."--".date("Y-m-d H:i:s",time()+8*60*60),FILE_APPEND);}

漏单关键点:

paypal/Model/Express/Checkout.php place 812:xx@gmail.com--xx@gmail.com

magento2.3.2 用户支付成功后台没有生成订单 丢单问题处理相关推荐

  1. luffy-16/订单表设计,立即付款接口/前端,支付成功get回调用户展示,支付成功post回调修改订单状态

    这里写目录标题 一.昨日回顾 二.今日内容 1.订单表设计 2.立即付款接口(一堆校验,登录后) 2.1视图类 2.2序列化类 2.3自定义异常类 2.4配置文件 2.5路由 3.立即付款前端 4.支 ...

  2. 微信扫码支付功能(2)---用户扫码支付成功,微信异步回调商户接口

    用户扫码支付成功,微信异步回调商户 上一篇博客完成用户扫码支付功能: https://www.cnblogs.com/qdhxhz/p/9708534.html 当用户扫码支付成功之后,微信会异步回调 ...

  3. java 实时监控微信扫码支付,支付成功跳转到成功页面

    **原文链接:https://www.blog-china.cn/liuzaiqingshan/home/39/1510305872502 欢迎访问个人博客,分享更多技术码上中国博客(CodeChin ...

  4. 【Java 实现微信支付、Native 支付流程】,从编写代码到支付成功,一步到位!

    文章目录 1. 项目环境介绍 2. 微信支付文档 2.1 业务流程说明 3. 准备信息 3.1 微信公众账号如何获取? 3.2 商户号如何获取? 3.3 API密钥如何获取? 3.4 准备工具类 4. ...

  5. 公众号支付成功后执行ajax,真香,微信公众号支付完整流程案例

    /** * 获取授权链接,首先调用此方法 * @return */ @GetMapping(value= "getOauthUrl") public void getOauthUr ...

  6. RabbitMQ实现订单超时设计思路、以及在订单过期临界点支付成功如何处理

    场景: 我们知道用 RabbitMQ 的延时队列可以实现用户下单后在 xxx 时间内未支付,需要自动关闭订单.但如果用户在订单即将过期的最后一秒支付成功.那么这笔订单算不算正常下单?要不要释放库存? ...

  7. 关于订单支付成功后一些逻辑的处理

    2019独角兽企业重金招聘Python工程师标准>>> 在实际的工作当中有可能涉及微信支付或是支付宝支付,支付成功后支付网关需要把成功支付的订单信息回调到你指定的方法上,然而有些情况 ...

  8. html5支付成功页面,订单完成页面视图《 微信支付:H5 移动端支付 》

    假设用户支付完成以后,查询订单的返回的交易状态是 SUCCESS ,我们可以把用户带到一个完成页面 .. 先去创建一个视图文件 .. 放在 resources .. views .. commerce ...

  9. 微信公众号消息推送,注册成功,支付成功,积分余额变化

    只要能拿到openid,什么都好办,很简单 趁着失业了更新一下代码,做做笔记 支付成功回调开始写,不知道怎么获取openid再看看其他博客 //支付回调接口(微信异步会通知)notify_url 配置 ...

最新文章

  1. 小程序“errcode“:41002错误问题如何解决?
  2. 全球第一所人工智能大学成立:培养硕博研究生,全员全额奖学金
  3. python selenium 三种等待方式详解
  4. Spinal Cage Fusion
  5. mac怎么合并两个容器_看苹果表演黑魔法:macOS Catalina 文件和硬盘出现两个
  6. 【深入理解JVM】JVM概述
  7. html5触摸界面设计与开发_原生APP的开发步骤主要分为哪些?
  8. luogu 1337
  9. 大数据比海量数据多了什么
  10. 文件完整性的检测与监控
  11. 企业如何应用ERP?企业应用ERP流程详解。
  12. mysql自学完整_MySQL自学篇(三)
  13. win10关机后cpu风扇还在转_电脑关机后CPU风扇还在转的原因和解决办法
  14. Python爬虫介绍
  15. 对话MVP丨腾讯崔冉的十年“技术马拉松”
  16. 【对比Java学Kotlin】协程-创建和取消
  17. Skype for Business Client 2016 聊天记录存放公共邮箱
  18. Processing 案例 | 诡异的八爪鱼
  19. 篱笆回路Fence Loops
  20. Swagger2快速入门

热门文章

  1. QQ、MSN、淘包旺旺、Skype常设对话的html链接代码
  2. 面向嵌入式开发的C++中间件库
  3. 使用SoftICE调试程序入门
  4. 如何使用身份证实名认证API接口?
  5. 什么是真正的骨传导耳机,五款真骨传导耳机推荐
  6. 如何避免网站改版造成的排名影响
  7. golang爬虫colly 抓取豆瓣前250电影
  8. 2022-2028年中国水声通信行业市场调查研究及未来趋势预测报告
  9. ORACLE 不支持 惠普小型机,不要过度迷信小型机 转载
  10. UILabel attributedText