Withdraw.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace addon\memberwithdraw\model;
  13. use app\model\BaseModel;
  14. use app\model\member\Withdraw as MemberWithdraw;
  15. /**
  16. * 会员提现
  17. */
  18. class Withdraw extends BaseModel
  19. {
  20. /**
  21. * 转账
  22. * @param $condition
  23. */
  24. public function transfer($id)
  25. {
  26. $withdraw_model = new MemberWithdraw();
  27. $info_result = $withdraw_model->getMemberWithdrawInfo([ [ "id", "=", $id ] ], "withdraw_no,account_number,realname,money,memo,transfer_type");
  28. if (empty($info_result["data"]))
  29. return $this->error();
  30. $info = $info_result["data"];
  31. if(!in_array($info["transfer_type"], ["wechatpay","alipay"]))
  32. return $this->error('', "当前提现方式不支持在线转账");
  33. $pay_data = array(
  34. "out_trade_no" => $info["withdraw_no"],
  35. "real_name" => $info["realname"],
  36. "amount" => $info["money"],
  37. "desc" => "会员提现".$info["memo"],
  38. "transfer_type" => $info["transfer_type"],
  39. "account_number" => $info["account_number"]
  40. );
  41. //调用在线转账借口
  42. $pay_result = event("PayTransfer", $pay_data, true);
  43. if (empty($pay_result)) {
  44. $pay_result = $this->error();
  45. }
  46. if ($pay_result["code"] < 0) {
  47. return $pay_result;
  48. }
  49. //调用完成转账
  50. $result = $withdraw_model->transferFinish([ [ "id", "=", $id ] ]);
  51. return $result;
  52. }
  53. }