Withdraw.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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\shopwithdraw\model;
  13. use app\model\BaseModel;
  14. use app\model\member\Member;
  15. use app\model\shop\ShopAccount;
  16. /**
  17. * 店铺提现
  18. */
  19. class Withdraw extends BaseModel
  20. {
  21. /**
  22. * 转账
  23. * @param $condition
  24. */
  25. public function transfer($id){
  26. $shop_account_model = new ShopAccount();
  27. $info_result = $shop_account_model->getShopWithdrawInfo([["id", "=", $id]]);
  28. if(empty($info_result["data"]))
  29. return $this->error();
  30. $info = $info_result["data"];
  31. $transfer_type = $this->getBankType()[$info["bank_type"]];
  32. $pay_data = array(
  33. "out_trade_no" => $info["withdraw_no"],
  34. "real_name" => $info["settlement_bank_account_name"],
  35. "amount" => $info["money"],
  36. "desc" => "店铺提现".$info["memo"],
  37. "transfer_type" => $transfer_type,
  38. "account_number" => $info["settlement_bank_account_number"]
  39. );
  40. //调用在线转账借口
  41. $pay_result = event("PayTransfer", $pay_data, true);
  42. if(empty($pay_result)){
  43. $pay_result = $this->error();
  44. }
  45. if($pay_result["code"] < 0 ){
  46. return $pay_result;
  47. }
  48. //调用完成转账
  49. $result = $shop_account_model->shopWithdrawPass($id, []);
  50. return $result;
  51. }
  52. /**
  53. * 转账方式
  54. */
  55. public function getTransferType(){
  56. $data = array(
  57. "bank" => "银行卡"
  58. );
  59. $temp_array = event("TransferType", []);
  60. if(!empty($temp_array)){
  61. foreach($temp_array as $k => $v){
  62. $data[$v["type"]] = $v["type_name"];
  63. }
  64. }
  65. return $data;
  66. }
  67. /**
  68. * 无意义函数
  69. */
  70. public function getBankType(){
  71. $bank_type = array(
  72. 1 => "bank",
  73. 2 => "alipay",
  74. 3 => "wechatpay",
  75. );
  76. return $bank_type;
  77. }
  78. }