如显示以下错误,或者直接提现的时候返回服务器内部错误都可以按照此方法进行修复
可以按照下面的提示进行修改代码也可以直接下载修复包,覆盖到根目录下就可以修复
修改app\services\user\UserExtractServices.php文件第168行开始修改
if ($openid) {//公众号用户
$type = Payment::WEB;
} else {//小程序用户
$openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'routine');
$type = Payment::MINI;
}
//app微信用户
if (!$openid) {
$openid = $wechatServices->getWechatOpenid((int)$userExtract['uid'], 'app');
$type = Payment::APP;
}
修改app\services\user\UserExtractServices.php文件第442行开始修改
if (sys_config('brokerage_type', 0) && $openid) {
if ($insertData['extract_price'] < 1) {
throw new ValidateException('扣除手续费后,提现金额不足1元;而企业微信付款到零钱最低金额为1元');
}
}
修改crmeb\services\wechat\v3pay\PayClient.php头部引用增加,第17行左右
use crmeb\services\wechat\Payment;
修改当前文件在第41行左右增加以下代码:
/**
* @var string
*/
protected $type = Payment::WEB;
/**
* @param string $type
* @return $this
* @author 等风来
* @email 136327134@qq.com
* @date 2022/11/18
*/
public function setType(string $type)
{
$this->type = $type;
return $this;
}
修改当前文件第229行左右
$appid = null;
if ($this->type === Payment::WEB) {
$appid = $this->app['config']['v3_payment']['other']['wechat']['appid'];
} else if ($this->type === Payment::MINI) {
$appid = $this->app['config']['v3_payment']['other']['miniprog']['appid'];
} else if ($this->type === Payment::APP) {
$appid = $this->app['config']['v3_payment']['other']['app']['appid'];
}
if (!$appid) {
throw new PayException('暂时只支持微信用户、小程序用户、APP微信登录用户提现');
}
$data = [
'appid' => $appid,
'out_batch_no' => $outBatchNo,
'batch_name' => $batchName,
'batch_remark' => $remark,
'total_amount' => $amount,
'total_num' => count($transferDetailList),
'transfer_detail_list' => $transferDetailList
];
修改crmeb\services\wechat\Payment.php的merchantPay方法
public static function merchantPay(string $openid, string $orderId, string $amount, string $desc, string $type = 'wechat')
{
$application = self::instance()->setAccessEnd($type)->application();//新修改行
$config = $application->getConfig();
if (!isset($config['cert_path'])) {
throw new PayException('企业微信支付到零钱需要支付证书,检测到您没有上传!');
}
if (!$config['cert_path']) {
throw new PayException('企业微信支付到零钱需要支付证书,检测到您没有上传!');
}
if (self::instance()->isV3PAy) {
//v3支付使用发起商家转账API
//新修改行
$res = $application->v3pay->setType($type)->batches(
$orderId,
$amount,
$desc,
$desc,
[
[
'out_detail_no' => $orderId,
'transfer_amount' => $amount,
'transfer_remark' => $desc,
'openid' => $openid
]
]
);
return $res;
} else {
$merchantPayData = [
'partner_trade_no' => $orderId, //随机字符串作为订单号,跟红包和支付一个概念。
'openid' => $openid, //收款人的openid
'check_name' => 'NO_CHECK', //文档中有三种校验实名的方法 NO_CHECK OPTION_CHECK FORCE_CHECK
'amount' => (int)bcmul($amount, '100', 0), //单位为分
'desc' => $desc,
'spbill_create_ip' => request()->ip(), //发起交易的IP地址
];
$result = $application->transfer->toBalance($merchantPayData);
self::logger('企业付款到零钱', compact('merchantPayData'), $result);
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] != 'FAIL') {
return true;
} else {
throw new PayException(($result['return_msg'] ?? '支付失败') . ':' . ($result['err_code_des'] ?? '发起企业支付到零钱失败'));
}
}
}
{{item.user_info.nickname ? item.user_info.nickname : item.user_name}}
作者 管理员 企业
{{itemf.name}}
{{itemc.user_info.nickname}}
{{itemc.user_name}}
回复 {{itemc.comment_user_info.nickname}}
{{itemf.name}}