123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- <?php
- namespace app\data\service;
- use app\data\model\DataUserTransfer;
- use app\data\model\DataUserWithdraw;
- use think\admin\Service;
- /**
- * 用户提现数据服务
- * Class UserTransferService
- * @package app\data\service
- */
- class UserTransferService extends Service
- {
- /**
- * 提现方式配置
- * @var array
- */
- protected $types = [
- 'wechat_wallet' => '转账到我的微信零钱',
- 'wechat_banks' => '转账到我的银行卡账户',
- 'wechat_qrcode' => '线下转账到微信收款码',
- 'alipay_qrcode' => '线下转账到支付宝收款码',
- 'alipay_account' => '线下转账到支付宝账户',
- 'transfer_banks' => '线下转账到银行卡账户',
- ];
- /**
- * 微信提现银行
- * @var array
- */
- protected $banks = [
- ['wseq' => '1002', 'name' => '工商银行'],
- ['wseq' => '1005', 'name' => '农业银行'],
- ['wseq' => '1003', 'name' => '建设银行'],
- ['wseq' => '1026', 'name' => '中国银行'],
- ['wseq' => '1020', 'name' => '交通银行'],
- ['wseq' => '1001', 'name' => '招商银行'],
- ['wseq' => '1066', 'name' => '邮储银行'],
- ['wseq' => '1006', 'name' => '民生银行'],
- ['wseq' => '1010', 'name' => '平安银行'],
- ['wseq' => '1021', 'name' => '中信银行'],
- ['wseq' => '1004', 'name' => '浦发银行'],
- ['wseq' => '1009', 'name' => '兴业银行'],
- ['wseq' => '1022', 'name' => '光大银行'],
- ['wseq' => '1027', 'name' => '广发银行'],
- ['wseq' => '1025', 'name' => '华夏银行'],
- ['wseq' => '1056', 'name' => '宁波银行'],
- ['wseq' => '4836', 'name' => '北京银行'],
- ['wseq' => '1024', 'name' => '上海银行'],
- ['wseq' => '1054', 'name' => '南京银行'],
- // '4755' => '长子县融汇村镇银行',
- // '4216' => '长沙银行',
- // '4051' => '浙江泰隆商业银行',
- // '4753' => '中原银行',
- // '4761' => '企业银行(中国)',
- // '4036' => '顺德农商银行',
- // '4752' => '衡水银行',
- // '4756' => '长治银行',
- // '4767' => '大同银行',
- // '4115' => '河南省农村信用社',
- // '4150' => '宁夏黄河农村商业银行',
- // '4156' => '山西省农村信用社',
- // '4166' => '安徽省农村信用社',
- // '4157' => '甘肃省农村信用社',
- // '4153' => '天津农村商业银行',
- // '4113' => '广西壮族自治区农村信用社',
- // '4108' => '陕西省农村信用社',
- // '4076' => '深圳农村商业银行',
- // '4052' => '宁波鄞州农村商业银行',
- // '4764' => '浙江省农村信用社联合社',
- // '4217' => '江苏省农村信用社联合社',
- // '4072' => '江苏紫金农村商业银行股份有限公司',
- // '4769' => '北京中关村银行股份有限公司',
- // '4778' => '星展银行(中国)有限公司',
- // '4766' => '枣庄银行股份有限公司',
- // '4758' => '海口联合农村商业银行股份有限公司',
- // '4763' => '南洋商业银行(中国)有限公司',
- ];
- /**
- * 获取微信提现银行
- * @param string|null $wsea
- * @return array|string
- */
- public function banks(?string $wsea = null)
- {
- if (is_null($wsea)) return $this->banks;
- foreach ($this->banks as $bank) if ($bank['wseq'] === $wsea) {
- return $bank['name'];
- }
- return $wsea;
- }
- /**
- * 获取转账类型
- * @param string|null $name
- * @return array|string
- */
- public function types(?string $name = null)
- {
- return is_null($name) ? $this->types : ($this->types[$name] ?? $name);
- }
- /**
- * 同步刷新用户返利
- * @param integer $uuid
- * @return array [total, count, audit, locks]
- */
- public static function amount(int $uuid): array
- {
- if ($uuid > 0) {
- $total = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}'")->sum('price'));
- $audit = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}' and paid=0")->sum('price'));
- $success = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}' and paid=3")->sum('price'));
- $refuse = abs(DataUserWithdraw::mk()->whereRaw("uuid='{$uuid}' and paid=2")->sum('price'));
- } else {
- $total = abs(DataUserWithdraw::mk()->sum('price'));
- $audit = abs(DataUserWithdraw::mk()->whereRaw("paid=0")->sum('price'));
- $success = abs(DataUserWithdraw::mk()->whereRaw("paid=3")->sum('price'));
- $refuse = abs(DataUserWithdraw::mk()->whereRaw("paid=2")->sum('price'));
- }
- return [$total, $success, $audit, $refuse];
- }
- /**
- * 获取提现配置
- * @param ?string $name
- * @return array|string
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function config(?string $name = null)
- {
- static $data = [];
- if (empty($data)) $data = sysdata('TransferRule');
- return is_null($name) ? $data : ($data[$name] ?? '');
- }
- /**
- * 获取转账配置
- * @param ?string $name
- * @return array|string
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function payment(?string $name = null)
- {
- static $data = [];
- if (empty($data)) $data = sysdata('TransferWxpay');
- return is_null($name) ? $data : ($data[$name] ?? '');
- }
- }
|