新增退款申请

This commit is contained in:
yaooo 2023-12-14 17:17:54 +08:00
parent e63b0934d0
commit fee76a88b7
5 changed files with 458 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?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\controller\finance;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\finance\FinanceRefundApplyLists;
use app\adminapi\logic\finance\FinanceRefundApplyLogic;
use app\adminapi\validate\finance\FinanceRefundApplyValidate;
/**
* FinanceRefundApply控制器
* Class FinanceRefundApplyController
* @package app\adminapi\controller\finance
*/
class FinanceRefundApplyController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function lists()
{
return $this->dataLists(new FinanceRefundApplyLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function add()
{
$params = (new FinanceRefundApplyValidate())->post()->goCheck('add');
$result = FinanceRefundApplyLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FinanceRefundApplyLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function edit()
{
$params = (new FinanceRefundApplyValidate())->post()->goCheck('edit');
$result = FinanceRefundApplyLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FinanceRefundApplyLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function delete()
{
$params = (new FinanceRefundApplyValidate())->post()->goCheck('delete');
FinanceRefundApplyLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function detail()
{
$params = (new FinanceRefundApplyValidate())->goCheck('detail');
$result = FinanceRefundApplyLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,77 @@
<?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\lists\finance;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\finance\FinanceRefundApply;
use app\common\lists\ListsSearchInterface;
/**
* FinanceRefundApply列表
* Class FinanceRefundApplyLists
* @package app\adminapi\listsfinance
*/
class FinanceRefundApplyLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function setSearch(): array
{
return [
'=' => ['customer_id', 'contract_id', 'collection_acccount'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function lists(): array
{
return FinanceRefundApply::where($this->searchWhere)
->field(['*'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function count(): int
{
return FinanceRefundApply::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,133 @@
<?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\finance;
use app\common\model\finance\FinanceRefundApply;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* FinanceRefundApply逻辑
* Class FinanceRefundApplyLogic
* @package app\adminapi\logic\finance
*/
class FinanceRefundApplyLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/14 16:58
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
FinanceRefundApply::create([
'customer_id' => $params['customer_id'] ?? 0,
'contract_id' => $params['contract_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'refund_date' => $params['refund_date'] ?? '',
'reason' => $params['reason'] ?? '',
'amount' => $params['amount'] ?? 0,
'amount_daxie' => $params['amount_daxie'] ?? '',
'refund_type' => $params['refund_type'] ?? 0,
'refunder' => $params['refunder'] ?? '',
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '',
'collection_bank' => $params['collection_bank'] ?? '',
'collection_acccount' => $params['collection_acccount'] ?? ''
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/14 16:58
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
FinanceRefundApply::create([
'customer_id' => $params['customer_id'] ?? 0,
'contract_id' => $params['contract_id'] ?? 0,
'approve_id' => $params['approve_id'] ?? 0,
'refund_date' => $params['refund_date'] ?? '',
'reason' => $params['reason'] ?? '',
'amount' => $params['amount'] ?? 0,
'amount_daxie' => $params['amount_daxie'] ?? '',
'refund_type' => $params['refund_type'] ?? 0,
'refunder' => $params['refunder'] ?? '',
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ?? '',
'collection_bank' => $params['collection_bank'] ?? '',
'collection_acccount' => $params['collection_acccount'] ?? ''
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/12/14 16:58
*/
public static function delete(array $params): bool
{
return FinanceRefundApply::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/12/14 16:58
*/
public static function detail($params): array
{
$financeRefundApply = FinanceRefundApply::findOrEmpty($params['id']);
$financeRefundApply->contract;
$financeRefundApply->custom;
return $financeRefundApply->toArray();
}
}

View File

@ -0,0 +1,97 @@
<?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\validate\finance;
use app\common\validate\BaseValidate;
/**
* FinanceRefundApply验证器
* Class FinanceRefundApplyValidate
* @package app\adminapi\validate\finance
*/
class FinanceRefundApplyValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'customer_id' => 'require',
'contract_id' => 'require',
'approve_id' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
];
/**
* @notes 添加场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneAdd()
{
return $this->remove('id', true);
}
/**
* @notes 编辑场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneEdit()
{
return $this->only(['id', 'customer_id', 'contract_id', 'approve_id']);
}
/**
* @notes 删除场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return FinanceRefundApplyValidate
* @author likeadmin
* @date 2023/12/14 16:58
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,43 @@
<?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\common\model\finance;
use app\common\model\BaseModel;
use think\model\concern\SoftDelete;
/**
* FinanceRefundApply模型
* Class FinanceRefundApply
* @package app\common\model\finance
*/
class FinanceRefundApply extends BaseModel
{
use SoftDelete;
protected $name = 'finance_refund_apply';
protected $deleteTime = 'delete_time';
public function custom()
{
return $this->belongsTo(\app\common\model\custom\Custom::class, 'customer_id');
}
public function contract()
{
return $this->belongsTo(\app\common\model\contract\Contract::class, 'contract_id');
}
}