<?php
|
|
namespace app\operations\model\plus\vip;
|
|
use app\common\model\plus\vip\Capital;
|
use app\common\model\plus\vip\Cash as CashModel;
|
use app\common\service\message\MessageService;
|
|
/**
|
* VIP专区提现明细模型
|
*/
|
class Cash extends CashModel
|
{
|
/**
|
* 获取列表
|
*/
|
public function getList($search)
|
{
|
$model = $this->with(['user'])
|
->order(['create_time' => 'desc']);
|
|
if (!empty($search['nick_name'])) {
|
$model = $model->where('user.nickName', 'like', '%' . $search['nick_name'] . '%');
|
}
|
|
if (isset($search['apply_status']) && $search['apply_status'] > -1) {
|
$model = $model->where('apply_status', '=', $search['apply_status']);
|
}
|
|
return $model->paginate($search);
|
}
|
/**
|
* 提现审核
|
*/
|
public function submit($param)
|
{
|
$data = ['apply_status' => $param['apply_status']];
|
if ($param['apply_status'] == 30) {
|
$data['reject_reason'] = $param['reject_reason'];
|
}
|
// 更新申请记录
|
$data['audit_time'] = time();
|
self::update($data, ['id' => $param['id']]);
|
// 提现驳回:解冻分销商资金
|
if ($param['apply_status'] == 30) {
|
User::backFreezeMoney($param['user_id'], $param['money']);
|
}
|
|
// 发送模板消息
|
(new MessageService)->cash($this);
|
return true;
|
}
|
/**
|
* 确认已打款
|
*/
|
public function money()
|
{
|
$this->startTrans();
|
try {
|
// 更新申请状态
|
$data = ['apply_status' => 40, 'audit_time' => time()];
|
self::update($data, ['id' => $this['id']]);
|
|
// 更新分销商累积提现佣金
|
User::totalMoney($this['user_id'], $this['money']);
|
|
// 记录分销商资金明细
|
Capital::add([
|
'user_id' => $this['user_id'],
|
'flow_type' => 20,
|
'money' => -$this['money'],
|
'describe' => '申请提现',
|
]);
|
// 发送模板消息
|
//(new Message)->withdraw($this);
|
// 事务提交
|
$this->commit();
|
return true;
|
} catch (\Exception $e) {
|
$this->error = $e->getMessage();
|
$this->rollback();
|
return false;
|
}
|
}
|
}
|