123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use Think\Db;
- /**
- * 提现申请
- *
- * @icon fa fa-circle-o
- */
- class Takecash extends Backend
- {
-
- /**
- * Takecash模型对象
- * @var \app\admin\model\Takecash
- */
- 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();
- }
- /**
- * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
- * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
- * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
- */
-
- /**
- * 查看
- */
- public function index()
- {
- //当前是否为关联查询
- $this->relationSearch = true;
- //设置过滤方法
- $this->request->filter(['strip_tags', 'trim']);
- if ($this->request->isAjax()) {
- //如果发送的来源是Selectpage,则转发到Selectpage
- 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('审核失败');
- }
- //tag任务赠送金币
- 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();
- }
- //提现转账(新版2020-01-01)
- 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';//业务产品码,收发现金红包固定为:STD_RED_PACKET;单笔无密转账到支付宝账户固定为:TRANS_ACCOUNT_NO_PWD;单笔无密转账到银行卡固定为:TRANS_BANKCARD_NO_PWD
- $data['biz_scene'] = 'DIRECT_TRANSFER'; //描述特定的业务场景,可传的参数如下:PERSONAL_COLLECTION:C2C现金红包-领红包;DIRECT_TRANSFER:B2C现金红包、单笔无密转账到支付宝/银行卡
- $data['order_title'] = '知音佣金发放'; //转账业务的标题,用于在支付宝用户的账单里显示
- $data['payee_info']['identity'] = $info['alipay_account'];//收款方支付宝id或支付宝账户
- /*if ($info['alipay_type'] == 1) { //支付宝账户
- $data['payee_info']['identity_type'] = 'ALIPAY_LOGON_ID';
- //收款支付宝账号真实姓名, 不为空时支付宝会验证
- $data['payee_info']['name'] = $info['name'];
- } else { //支付宝id
- $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
- $data['payee_info']['name'] = '';
- }*/
- //支付宝id
- $data['payee_info']['identity_type'] = 'ALIPAY_USER_ID';
- $data['payee_info']['name'] = '';
- //转账备注(支持200个英文/100个汉字)。当付款方为企业账户,且转账金额达到(大于等于)50000元,remark不能为空。收款方可见,会展示在收款用户的收支详情中。
- $data['remark'] = '知音佣金发放';
- require_once("../extend/AliPay/AliPay.php");
- $alipay =new \AliPay();
- $result =$alipay->AliPayWithdraw($data);
- return $result;
- }
- }
|