PayUserWechat.php 1.3 KB

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