123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use Think\Db;
- class Takecash extends Backend
- {
-
-
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\Takecash;
- $this->view->assign("statusList", $this->model->getStatusList());
- $this->view->assign("typeList", $this->model->getTypeList());
- }
- public function import()
- {
- parent::import();
- }
-
-
-
- public function index()
- {
-
- $this->relationSearch = true;
-
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
-
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $list = $this->model
- ->with(['user','withdrawalconfig','userto'])
- ->where($where)
- ->order($sort, $order)
- ->paginate($limit);
- foreach ($list as $row) {
-
- $row->getRelation('user')->visible(['nickname','mobile']);
- $row->getRelation('withdrawalconfig')->visible(['money']);
- $row->getRelation('userto')->visible(['nickname','mobile']);
- }
- $result = array("total" => $list->total(), "rows" => $list->items());
- return json($result);
- }
- return $this->view->fetch();
- }
-
- public function audit(){
- $id = input('id');
- $info = Db::name('take_cash')
- ->where('id',$id)
- ->find();
- if ($this->request->isPost()) {
- if (!isset($info) || $info['status'] != 0) {
- $this->error('已经审核过了');
- }
- $status = input('status',0);
- $data = [
- 'status' => $status,
- 'auditremark' => input('auditremark'),
- 'audittime' => time(),
- 'updatetime' => time(),
- ];
- Db::startTrans();
- $rs = Db::name('take_cash')->where('id',$id)->update($data);
- if($rs === false){
- Db::rollback();
- $this->error('审核失败');
- }
-
- if($status == 1){
- $remark = '提现(成功)';
- Db::name('user_money_log')->where('table','take_cash')->where('table_id',$id)->update(['remark'=>$remark]);
-
- $msg_id = \app\common\model\Message::addMessage($info['user_id'],'提现审核','提现审核已经审核通过');
- }elseif($status == 2){
- $remark = '提现(驳回)';
- Db::name('user_money_log')->where('table','take_cash')->where('table_id',$id)->update(['remark'=>$remark]);
-
- $wallet_rs = model('wallet')->lockChangeAccountRemain($info['user_id'],0,'money',$info['number'],115,'提现被拒返回:'.$info['number'],'take_cash',$info['id']);
- if($wallet_rs['status'] === false){
- Db::rollback();
- $this->error($wallet_rs['msg']);
- }
-
- $msg_id = \app\common\model\Message::addMessage($info['user_id'],'提现审核','提现审核审核不通过');
- }
- Db::commit();
- $this->success('审核完成');
- }
- $this->assign('row',$info);
- return $this->view->fetch();
- }
-
- public function withdraw($info) {
- $data['out_biz_no'] = getMillisecond() . mt_rand(1, 1000);
- $data['trans_amount'] = $info['money'];
- $data['product_code'] = 'TRANS_ACCOUNT_NO_PWD';
- $data['biz_scene'] = 'DIRECT_TRANSFER';
- $data['order_title'] = '知音佣金发放';
- $data['payee_info']['identity'] = $info['alipay_account'];
-
-
- $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
- $data['payee_info']['name'] = '';
-
- $data['remark'] = '知音佣金发放';
- require_once("../extend/AliPay/AliPay.php");
- $alipay =new \AliPay();
- $result =$alipay->AliPayWithdraw($data);
- return $result;
- }
- }
|