记一次生产环境,微信回调不能更改订单状态事件。
不知道新版fecshop 1.6会不会。大家自己对应下
环境说明
fecshop 1.4.6.1
步骤说明
找到文件路径:
vendor\fancyecommerce\fecshop\services\payment\Wxpay.php
代码片段:
// 127行
\Yii::info('check order totla amouont['.($order_total_amount * 100).' == '.$total_fee.']', 'fecshop_debug');
// 微信支付的人民币单位为分
if(($order_total_amount * 100) != $total_fee){
return false;
}
改为
注:前提安装PHP BC高精确度函数库
// 微信支付的人民币单位为分
if(bccomp($order_total_amount * 100, $total_fee) !== 0){
return false;
}
继...
中午修改好,晚上又出现十几单订单状态未改变问题,跟踪日志:
日志如下
2018-12-18 17:27:28 Array[info][fecshop_debug] check order totla amouont[3221 == 3220]
检查代码
// 还是浮点数运算问题
文件位置:vendor\fancyecommerce\fecshop\services\page\Currency.php
// 行144
return ceil($price * $rate * 100) / 100;
改为
return bcmul($price, $rate, 2);
错误示例:
$increment_id = '201812181612631100000982';
$this->_order = Yii::$service->order->getByIncrementId($increment_id);
$base_grand_total = $this->_order['base_grand_total'];
var_dump($base_grand_total);//string(5) "32.20"
$order_total_amount = Yii::$service->page->currency->getCurrencyPrice($base_grand_total, 'CNY');
var_dump($order_total_amount);//float(32.21)
其他位置的运算,都要看下。
本文由 Axin 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。
可自由转载、引用,但需署名作者且注明文章出处。