Withdraw.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\memberwithdraw\model;
  11. use app\model\BaseModel;
  12. use app\model\member\Withdraw as MemberWithdraw;
  13. /**
  14. * 会员提现
  15. */
  16. class Withdraw extends BaseModel
  17. {
  18. /**
  19. * 转账
  20. * @param $condition
  21. */
  22. public function transfer($id)
  23. {
  24. $withdraw_model = new MemberWithdraw();
  25. $info_result = $withdraw_model->getMemberWithdrawInfo([ [ "id", "=", $id ] ], "withdraw_no,account_number,realname,money,memo,transfer_type,site_id,applet_type,member_id");
  26. if (empty($info_result[ "data" ]))
  27. return $this->error();
  28. $info = $info_result[ "data" ];
  29. if (!in_array($info[ "transfer_type" ], [ "wechatpay", "alipay" ]))
  30. return $this->error('', "当前提现方式不支持在线转账");
  31. $pay_data = array (
  32. "id" => $id,
  33. "out_trade_no" => $info[ "withdraw_no" ],
  34. "real_name" => $info[ "realname" ],
  35. "amount" => $info[ "money" ],
  36. "desc" => "会员提现" . $info[ "memo" ],
  37. "transfer_type" => $info[ "transfer_type" ],
  38. "account_number" => $info[ "account_number" ],
  39. "site_id" => $info[ "site_id" ],
  40. "is_weapp" => $info[ "applet_type" ],
  41. "member_id" => $info[ 'member_id' ]
  42. );
  43. //调用在线转账借口
  44. $pay_result = event("PayTransfer", $pay_data, true);
  45. if (empty($pay_result)) {
  46. $pay_result = $this->error();
  47. }
  48. if ($pay_result[ "code" ] < 0) {
  49. return $pay_result;
  50. }
  51. //调用完成转账
  52. $result = $withdraw_model->transferFinish([ "id" => $id, "site_id" => $info[ "site_id" ] ]);
  53. return $result;
  54. }
  55. }