Files
zzp-server/app/adminapi/logic/withdraw/WithdrawBankLogic.php
2026-01-19 14:19:22 +08:00

135 lines
3.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\withdraw;
use app\common\model\withdraw\WithdrawBank;
use app\common\logic\BaseLogic;
use think\facade\Db;
use app\common\service\{FileService};
use app\common\enum\YesNoEnum;
/**
* 可提现银行逻辑
* Class WithdrawBankLogic
* @package app\adminapi\logic\withdraw
*/
class WithdrawBankLogic extends BaseLogic
{
/**
* @notes 添加可提现银行
* @param array $params
* @return bool
* @author BD
* @date 2024/02/25 12:19
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
WithdrawBank::create([
'lang_id' => $params['lang_id'],
'name' => $params['name'],
'code' => $params['code'],
'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '',
'is_show' => $params['is_show'],
'sort' => $params['sort']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑可提现银行
* @param array $params
* @return bool
* @author BD
* @date 2024/02/25 12:19
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
WithdrawBank::where('id', $params['id'])->update([
'lang_id' => $params['lang_id'],
'name' => $params['name'],
'code' => $params['code'],
'logo' => $params['logo'] ? FileService::setFileUrl($params['logo']) : '',
'is_show' => $params['is_show'],
'sort' => $params['sort']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除可提现银行
* @param array $params
* @return bool
* @author BD
* @date 2024/02/25 12:19
*/
public static function delete(array $params): bool
{
return WithdrawBank::destroy($params['id']);
}
/**
* @notes 获取可提现银行详情
* @param $params
* @return array
* @author BD
* @date 2024/02/25 12:19
*/
public static function detail($params): array
{
return WithdrawBank::findOrEmpty($params['id'])->toArray();
}
/**
* @notes 提现银行数据
* @param $params
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author BD
* @date 2024/02/25 12:19
*/
public static function allByLang($params)
{
return WithdrawBank::where(['is_show' => YesNoEnum::YES,'lang_id' => $params['lang_id']])
->order(['sort' => 'desc', 'id' => 'desc'])
->select()
->toArray();
}
}