Files
douba_shop/app/common/controller/Recharge.php
Karlcarlo c9a98f342c chore: 添加静态资源文件和版本配置文件
添加大量图片、字体、音频等静态资源文件,包括用户界面图片、模板文件和安装界面素材
添加系统版本配置文件(.version)和常量定义文件(.constant)
更新供应商依赖文件,包括Symfony VarDumper组件和相关许可证文件
添加验证码配置文件(captcha.php)和.gitignore规则
2026-03-06 20:14:23 +08:00

102 lines
2.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
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\controller;
use think\Response;
/**
* 退款
* Trait Recharge
* @package app\common\controller
*/
trait Recharge
{
/**
* 显示资源列表
*
* @return Response
*/
public function index(): Response
{
$where = $this->request->getMore([
['data', ''],
['paid', ''],
['nickname', ''],
]);
return $this->success($this->services->getRechargeList($where));
}
/**
* 删除指定资源
*
* @param int $id
* @return Response
*/
public function delete($id)
{
if (!$id || !is_numeric($id)) return $this->fail('缺少参数或参数类型错误');
return $this->success($this->services->delRecharge((int)$id) ? '删除成功' : '删除失败');
}
/**
* 获取用户充值数据
* @return Response
*/
public function user_recharge()
{
$where = $this->request->getMore([
['data', ''],
['paid', ''],
['nickname', ''],
]);
return $this->success($this->services->user_recharge($where));
}
/**
* 退款表单
* @param $id
* @return mixed
*/
public function refund_edit($id)
{
if (!$id || !is_numeric($id)) return $this->fail('数据不存在或参数类型错误');
return $this->success($this->services->refund_edit((int)$id));
}
/**
* 退款操作
* @param $id
* @return Response
*/
public function refund_update($id): Response
{
$data = $this->request->postMore([
'refund_price',
]);
// 类型验证
if (!$id || !is_numeric($id)) return $this->fail('数据不存在或参数类型错误');
if (!is_numeric($data['refund_price'])) return $this->fail('退款金额类型错误');
// 边界条件处理
if ($data['refund_price'] <= 0) return $this->fail('退款金额必须大于0');
try {
return $this->success($this->services->refund_update((int)$id, $data['refund_price']) ? '退款成功' : '退款失败');
} catch (\Exception $e) {
return $this->fail('退款处理异常: ' . $e->getMessage());
}
}
}