UserTransferService.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace app\data\service;
  3. use app\data\model\DataUserTransfer;
  4. use app\data\model\DataUserWithdraw;
  5. use think\admin\Service;
  6. /**
  7. * 用户提现数据服务
  8. * Class UserTransferService
  9. * @package app\data\service
  10. */
  11. class UserTransferService extends Service
  12. {
  13. /**
  14. * 提现方式配置
  15. * @var array
  16. */
  17. protected $types = [
  18. 'wechat_wallet' => '转账到我的微信零钱',
  19. 'wechat_banks' => '转账到我的银行卡账户',
  20. 'wechat_qrcode' => '线下转账到微信收款码',
  21. 'alipay_qrcode' => '线下转账到支付宝收款码',
  22. 'alipay_account' => '线下转账到支付宝账户',
  23. 'transfer_banks' => '线下转账到银行卡账户',
  24. ];
  25. /**
  26. * 微信提现银行
  27. * @var array
  28. */
  29. protected $banks = [
  30. ['wseq' => '1002', 'name' => '工商银行'],
  31. ['wseq' => '1005', 'name' => '农业银行'],
  32. ['wseq' => '1003', 'name' => '建设银行'],
  33. ['wseq' => '1026', 'name' => '中国银行'],
  34. ['wseq' => '1020', 'name' => '交通银行'],
  35. ['wseq' => '1001', 'name' => '招商银行'],
  36. ['wseq' => '1066', 'name' => '邮储银行'],
  37. ['wseq' => '1006', 'name' => '民生银行'],
  38. ['wseq' => '1010', 'name' => '平安银行'],
  39. ['wseq' => '1021', 'name' => '中信银行'],
  40. ['wseq' => '1004', 'name' => '浦发银行'],
  41. ['wseq' => '1009', 'name' => '兴业银行'],
  42. ['wseq' => '1022', 'name' => '光大银行'],
  43. ['wseq' => '1027', 'name' => '广发银行'],
  44. ['wseq' => '1025', 'name' => '华夏银行'],
  45. ['wseq' => '1056', 'name' => '宁波银行'],
  46. ['wseq' => '4836', 'name' => '北京银行'],
  47. ['wseq' => '1024', 'name' => '上海银行'],
  48. ['wseq' => '1054', 'name' => '南京银行'],
  49. // '4755' => '长子县融汇村镇银行',
  50. // '4216' => '长沙银行',
  51. // '4051' => '浙江泰隆商业银行',
  52. // '4753' => '中原银行',
  53. // '4761' => '企业银行(中国)',
  54. // '4036' => '顺德农商银行',
  55. // '4752' => '衡水银行',
  56. // '4756' => '长治银行',
  57. // '4767' => '大同银行',
  58. // '4115' => '河南省农村信用社',
  59. // '4150' => '宁夏黄河农村商业银行',
  60. // '4156' => '山西省农村信用社',
  61. // '4166' => '安徽省农村信用社',
  62. // '4157' => '甘肃省农村信用社',
  63. // '4153' => '天津农村商业银行',
  64. // '4113' => '广西壮族自治区农村信用社',
  65. // '4108' => '陕西省农村信用社',
  66. // '4076' => '深圳农村商业银行',
  67. // '4052' => '宁波鄞州农村商业银行',
  68. // '4764' => '浙江省农村信用社联合社',
  69. // '4217' => '江苏省农村信用社联合社',
  70. // '4072' => '江苏紫金农村商业银行股份有限公司',
  71. // '4769' => '北京中关村银行股份有限公司',
  72. // '4778' => '星展银行(中国)有限公司',
  73. // '4766' => '枣庄银行股份有限公司',
  74. // '4758' => '海口联合农村商业银行股份有限公司',
  75. // '4763' => '南洋商业银行(中国)有限公司',
  76. ];
  77. /**
  78. * 获取微信提现银行
  79. * @param string|null $wsea
  80. * @return array|string
  81. */
  82. public function banks(?string $wsea = null)
  83. {
  84. if (is_null($wsea)) return $this->banks;
  85. foreach ($this->banks as $bank) if ($bank['wseq'] === $wsea) {
  86. return $bank['name'];
  87. }
  88. return $wsea;
  89. }
  90. /**
  91. * 获取转账类型
  92. * @param string|null $name
  93. * @return array|string
  94. */
  95. public function types(?string $name = null)
  96. {
  97. return is_null($name) ? $this->types : ($this->types[$name] ?? $name);
  98. }
  99. /**
  100. * 同步刷新用户返利
  101. * @param integer $uuid
  102. * @return array [total, count, audit, locks]
  103. */
  104. public static function amount(int $uuid): array
  105. {
  106. if ($uuid > 0) {
  107. $total = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}'")->sum('price'));
  108. $audit = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}' and paid=0")->sum('price'));
  109. $success = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}' and paid=3")->sum('price'));
  110. $refuse = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}' and paid=2")->sum('price'));
  111. } else {
  112. $total = abs(DataUserWithdraw::mk()->sum('price'));
  113. $audit = abs(DataUserWithdraw::mk()->whereRaw("paid=0")->sum('price'));
  114. $success = abs(DataUserWithdraw::mk()->whereRaw("paid=3")->sum('price'));
  115. $refuse = abs(DataUserWithdraw::mk()->whereRaw("paid=2")->sum('price'));
  116. }
  117. return [$total, $success, $audit, $refuse];
  118. }
  119. /**
  120. * 获取提现配置
  121. * @param ?string $name
  122. * @return array|string
  123. * @throws \think\db\exception\DataNotFoundException
  124. * @throws \think\db\exception\DbException
  125. * @throws \think\db\exception\ModelNotFoundException
  126. */
  127. public static function config(?string $name = null)
  128. {
  129. static $data = [];
  130. if (empty($data)) $data = sysdata('TransferRule');
  131. return is_null($name) ? $data : ($data[$name] ?? '');
  132. }
  133. /**
  134. * 获取转账配置
  135. * @param ?string $name
  136. * @return array|string
  137. * @throws \think\db\exception\DataNotFoundException
  138. * @throws \think\db\exception\DbException
  139. * @throws \think\db\exception\ModelNotFoundException
  140. */
  141. public static function payment(?string $name = null)
  142. {
  143. static $data = [];
  144. if (empty($data)) $data = sysdata('TransferWxpay');
  145. return is_null($name) ? $data : ($data[$name] ?? '');
  146. }
  147. }