125 lines
3.2 KiB
PHP
125 lines
3.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace app\adminapi\controller;
|
||
|
|
|
||
|
|
use app\admin\model\AdminLog;
|
||
|
|
use app\common\controller\adminApi;
|
||
|
|
use think\Config;
|
||
|
|
use think\Db;
|
||
|
|
use think\Hook;
|
||
|
|
use think\Session;
|
||
|
|
use think\Validate;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 可选充值金额表
|
||
|
|
* @internal
|
||
|
|
*/
|
||
|
|
class CanRecharge extends adminApi
|
||
|
|
{
|
||
|
|
|
||
|
|
protected $noNeedLogin = [];
|
||
|
|
protected $noNeedRight = [];
|
||
|
|
|
||
|
|
protected $table = 'vs_can_recharge';
|
||
|
|
|
||
|
|
public function _initialize()
|
||
|
|
{
|
||
|
|
parent::_initialize();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 列表
|
||
|
|
*/
|
||
|
|
public function recharge_lists(){
|
||
|
|
$page = input('page', 1);
|
||
|
|
$page_limit = input('page_limit', 30);
|
||
|
|
$where = [];
|
||
|
|
$where['delete_time'] = 0;
|
||
|
|
$count = db::name($this->table)->where($where)->count();
|
||
|
|
$lists = db::name($this->table)->where($where)->order('money asc')->page($page, $page_limit)->select();
|
||
|
|
foreach ($lists as &$v){
|
||
|
|
$v['createtime'] = date('Y-m-d H:i:s', $v['createtime']);
|
||
|
|
$v['admin'] = db::name('admin')->where(['id'=>$v['admin_id']])->value('nickname')??"--";
|
||
|
|
}
|
||
|
|
$return_data = [
|
||
|
|
'page' =>$page,
|
||
|
|
'page_limit' => $page_limit,
|
||
|
|
'count' => $count,
|
||
|
|
'lists' => $lists
|
||
|
|
];
|
||
|
|
return V(1,"成功", $return_data);
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 添加
|
||
|
|
*/
|
||
|
|
public function recharge_add(){
|
||
|
|
$admin_id = Session::get('admin_id');
|
||
|
|
$money = input('money', '');
|
||
|
|
$coins = input('coins', '');
|
||
|
|
$status = input('status', 1);
|
||
|
|
if(empty($money) || empty($coins)){
|
||
|
|
return V(0, "参数错误");
|
||
|
|
}
|
||
|
|
$data = [
|
||
|
|
'money' => $money,
|
||
|
|
'coins' => $coins,
|
||
|
|
'status' => $status,
|
||
|
|
'admin_id' => $admin_id,
|
||
|
|
'createtime' => time()
|
||
|
|
];
|
||
|
|
$res = db::name($this->table)->insert($data);
|
||
|
|
if(!$res){
|
||
|
|
return V(0, "添加失败");
|
||
|
|
}
|
||
|
|
return V(1, "添加成功");
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 修改
|
||
|
|
*/
|
||
|
|
public function recharge_edit(){
|
||
|
|
$money = input('money', '');
|
||
|
|
$coins = input('coins', '');
|
||
|
|
$status = input('status', 1);
|
||
|
|
$id = input('id', '');
|
||
|
|
if($money){
|
||
|
|
$data['money'] = $money;
|
||
|
|
}
|
||
|
|
if($coins){
|
||
|
|
$data['coins'] = $coins;
|
||
|
|
}
|
||
|
|
if($status){
|
||
|
|
$data['status'] = $status;
|
||
|
|
}
|
||
|
|
$data['updatetime'] = time();
|
||
|
|
$res = db::name($this->table)->where(['crid'=>$id])->update($data);
|
||
|
|
if(!$res){
|
||
|
|
return V(0, "修改失败");
|
||
|
|
}
|
||
|
|
return V(1, "修改成功");
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 删除
|
||
|
|
*/
|
||
|
|
public function recharge_del(){
|
||
|
|
$id = input('id', '');
|
||
|
|
$res = db::name($this->table)->where(['crid'=>$id])->update(['delete_time'=>time()]);
|
||
|
|
if(!$res){
|
||
|
|
return V(0, "删除失败");
|
||
|
|
}
|
||
|
|
return V(1, "删除成功");
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* 状态修改
|
||
|
|
*/
|
||
|
|
public function recharge_status(){
|
||
|
|
$id = input('id', '');
|
||
|
|
$status = input('status', '');
|
||
|
|
$res = db::name($this->table)->where(['crid'=>$id])->update(['status'=>$status]);
|
||
|
|
if(!$res){
|
||
|
|
return V(0, "修改失败");
|
||
|
|
}
|
||
|
|
return V(1, "修改成功");
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|