1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace app\service\pay_user;
- use app\common\model\User;
- class PayUserWechat extends PayUser {
- function payment($amount, User $user, $type,$memo='', $extra = [],$log=true)
- {
- $extra['no']=order_no('p');
- $result=payment($user)
- ->transfer
- ->toBalance([
- 'partner_trade_no' => $extra['no'], // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
- 'openid' => $user['openid'],
- 'check_name' => 'NO_CHECK', // NO_CHECK:不校验真实姓名, FORCE_CHECK:强校验真实姓名
- 're_user_name' => '王小帅', // 如果 check_name 设置为FORCE_CHECK,则必填用户真实姓名
- 'amount' => $amount*100, // 企业付款金额,单位为分
- 'desc' => $memo, // 企业付款操作说明信息。必填
- ]);
- if ($result['return_code']!='SUCCESS'){
- throw_user("付款失败:".$result['return_msg']);
- }
- if($result['result_code']!='SUCCESS'){
- throw_user("付款失败:".$result['err_code_des']);
- }
- $extra['deal_at']=time();
- if($log) {
- $user::money($amount, $user['id'], $type, $memo, $extra, false);
- }
- }
- }
|