nk-lihaink-cn/app/admin/model/UserExtract.php
2023-03-15 16:26:36 +08:00

103 lines
2.7 KiB
PHP

<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
namespace app\admin\model;
use think\facade\Db;
use think\model;
class UserExtract extends Model
{
protected $connection = 'shop';
// 设置当前模型对应的完整数据表名称
protected $table = 'eb_user_extract';
/**
* 获取分页列表
* @param $where
* @param $param
*/
public function getUserExtractList($where, $param)
{
$rows = empty($param['limit']) ? get_config('app . page_size') : $param['limit'];
$order = empty($param['order']) ? 'extract_id desc' : $param['order'];
$list = self::where($where)->field('extract_id,extract_id,uid,extract_sn,real_name,extract_type,bank_code,bank_address,alipay_code,wechat,extract_pic,extract_price,balance,mark,admin_id,fail_msg,status_time,create_time,status,bank_name')->order($order)->paginate($rows, false, ['query' => $param]);
return $list;
}
/**
* 添加数据
* @param $param
*/
public function addUserExtract($param)
{
$insertId = 0;
try {
$param['create_time'] = time();
$insertId = self::strict(false)->field(true)->insertGetId($param);
add_log('add', $insertId, $param);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
return to_assign(0,'操作成功',['aid'=>$insertId]);
}
/**
* 编辑信息
* @param $param
*/
public function editUserExtract($param)
{
try {
$param['update_time'] = time();
self::where('extract_id', $param['extract_id'])->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
return to_assign();
}
/**
* 根据id获取信息
* @param $id
*/
public function getUserExtractById($id)
{
$info = self::where('extract_id', $id)->find();
return $info;
}
/**
* 删除信息
* @param $id
* @return array
*/
public function delUserExtractById($id,$type=0)
{
if($type==0){
//逻辑删除
try {
$param['delete_time'] = time();
self::where('extract_id', $id)->update(['delete_time'=>time()]);
add_log('delete', $id);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
}
else{
//物理删除
try {
self::where('extract_id', $id)->delete();
add_log('delete', $id);
} catch(\Exception $e) {
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
}
return to_assign();
}
}