Payment.php
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
* Trait类 微信公众号
+-----------------------------------------------------------------------------------------------------------------------
*
* PHP version 7
*
* @category App\Factories\Wechat
* @package App\Factories\Wechat
* @author Richer <yangzi1028@163.com>
* @date 2021年5月6日10:44:56
* @copyright 2019-2020 Richer (http://www.umu888.com)
* @license http://www.xxxxxx.com License
* @link http://www.xxxxxx.com
*/
namespace App\Factories\Wechat;
/**
* Trait Payment
*
* @category App\Factories\Wechat
* @package App\Factories\Wechat
* @author Richer <yangzi1028@163.com>
* @date 2021年5月6日10:44:56
* @copyright 2019-2020 Richer (http://www.umu888.com)
* @license http://www.xxxxxx.com License
* @link http://www.xxxxxx.com
*/
trait Payment
{
/**
* 企业付款
*
* @param $out_trade_no
* @param $openId
* @param $amount
* @return bool
*/
public function enterprisePay($out_trade_no, $openId, $amount)
{
$result = $this->payment->transfer->toBalance([
'partner_trade_no' => $out_trade_no,
'openid' => $openId,
'check_name' => 'NO_CHECK', //不校验真实姓名
'amount' => $amount * 100,
'desc' => '提现转账',
]);
if ($result) {
if ($result['return_code'] == 'FAIL') {
$this->errMsg = $result['return_msg'];
\Log::info('用户申请提现转账失败!,申请编号:' . $out_trade_no . ',失败原因:' . $result['return_msg']);
return false;
} else {
if ($result['result_code'] == 'FAIL') {
$this->errMsg = $result['err_code_des'];
\Log::info('用户申请提现转账失败!,申请编号:' . $out_trade_no . ',失败原因:' . $result['err_code_des']);
return false;
}
}
} else {
$this->errMsg = '系统错误!';
\Log::info('用户申请提现转账失败!,申请编号:' . $out_trade_no);
return false;
}
return true;
}
}