123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- <?php
- namespace app\data\controller\user;
- use app\data\model\DataUser;
- use app\data\model\DataUserTransfer;
- use app\data\model\DataUserWithdraw;
- use app\data\service\UserAdminService;
- use app\data\service\UserTransferService;
- use think\admin\Controller;
- use think\admin\extend\CodeExtend;
- use think\admin\service\AdminService;
- /**
- * 用户提现管理
- * Class Transfer
- * @package app\data\controller\user
- */
- class Transfer extends Controller
- {
- /**
- * 提现转账方案
- * @var array
- */
- protected $types = [];
- protected function initialize()
- {
- $this->types = UserTransferService::instance()->types();
- }
- /**
- * 用户提现配置
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function config()
- {
- $this->skey = 'TransferRule';
- $this->title = '用户提现配置';
- $this->_sysdata();
- }
- /**
- * 微信转账配置
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function payment()
- {
- $this->skey = 'TransferWxpay';
- $this->title = '微信提现配置';
- $this->_sysdata();
- }
- /**
- * 配置数据处理
- * @param string $tpl 模板文件
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- private function _sysdata(string $tpl = '')
- {
- if ($this->request->isGet()) {
- $this->data = sysdata($this->skey);
- $this->fetch($tpl);
- } else {
- sysdata($this->skey, $this->request->post());
- $this->success('配置修改成功');
- }
- }
- /**
- * 用户提现管理
- * @menu true
- * @auth true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function index()
- {
- $this->title = '用户提现管理';
- $this->transfer = UserTransferService::amount(0);
- // 创建查询对象
- $query = DataUserWithdraw::mQuery()->order('id desc');
- // 用户条件搜索
- $db = DataUser::mQuery()->like('phone,username|nickname#nickname')->db();
- if ($db->getOptions('where')) $query->whereRaw("uuid in {$db->field('id')->buildSql()}");
- // 数据列表处理
- $query->equal('paid')->dateBetween('create_at')->page();
- }
- /**
- * 数据列表处理
- * @param array $data
- */
- protected function _page_filter(array &$data)
- {
- UserAdminService::buildByUid($data);
- //dump($data);
- // foreach ($data as &$vo) {
- // $vo['type_name'] = UserTransferService::instance()->types($vo['type']);
- // }
- }
- /**
- * 提现审核通过
- * @auth true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function auditStatus()
- {
- $this->_audit();
- }
- /**
- * 提现审核拒绝
- * @auth true
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function auditStatusfail()
- {
- $this->_auditfail();
- }
- /**
- * 提现打款操作
- * @auth false
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function auditPayment()
- {
- $this->_audit();
- }
- /**
- * 提现审核打款
- * @auth false
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- private function _audit()
- {
- if ($this->request->isGet()) {
- DataUserWithdraw::mForm('audit', 'order_no');
- } else {
- $data = $this->_vali([
- 'order_no.require' => '打款单号不能为空!',
- 'paid.default'=>3,
- 'pay_time.default'=>date('Y-m-d H:i:s'),
- 'remark.default'=>''
- ]);
- $map = ['order_no' => $data['order_no']];
- $find = DataUserWithdraw::mk()->where($map)->find();
- if (empty($find)) $this->error('不允许操作审核!');
- if (DataUserWithdraw::mk()->strict(false)->where($map)->update($data) !== false) {
- $this->success('操作成功');
- } else {
- $this->error('操作失败!');
- }
- }
- }
- /**
- * 提现审核打款
- * @auth false
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- private function _auditfail()
- {
- if ($this->request->isGet()) {
- DataUserWithdraw::mForm('audit_fail', 'order_no');
- } else {
- $data = $this->_vali([
- 'order_no.require' => '打款单号不能为空!',
- 'paid.default'=>2,
- 'pay_time.default'=>date('Y-m-d H:i:s'),
- 'remark.default'=>''
- ]);
- $map = ['order_no' => $data['order_no']];
- $find = DataUserWithdraw::mk()->where($map)->find();
- if (empty($find)) $this->error('不允许操作审核!');
- if (DataUserWithdraw::mk()->strict(false)->where($map)->update($data) !== false) {
- userMoneyChange($find['price'],1,$find['uuid'],'提现审核拒绝',1,$find['id']);
- $this->success('操作成功');
- } else {
- $this->error('操作失败!');
- }
- }
- }
- /**
- * 后台打款服务
- * @auth false
- */
- public function sync()
- {
- $this->_queue('提现到微信余额定时处理', 'xdata:UserTransfer', 0, [], 0, 50);
- }
- }
|