diff --git a/app/adminapi/controller/bid/BidSecurityRefundController.php b/app/adminapi/controller/bid/BidSecurityRefundController.php new file mode 100644 index 000000000..b05cfeab4 --- /dev/null +++ b/app/adminapi/controller/bid/BidSecurityRefundController.php @@ -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\bid; + + +use app\adminapi\controller\BaseAdminController; +use app\adminapi\lists\bid\BidSecurityRefundLists; +use app\adminapi\logic\bid\BidSecurityRefundLogic; +use app\adminapi\validate\bid\BidSecurityRefundValidate; + + +/** + * BidSecurityRefund控制器 + * Class BidSecurityRefundController + * @package app\adminapi\controller\bid + */ +class BidSecurityRefundController extends BaseAdminController +{ + + + /** + * @notes 获取列表 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function lists() + { + return $this->dataLists(new BidSecurityRefundLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function add() + { + $params = (new BidSecurityRefundValidate())->post()->goCheck('add'); + $result = BidSecurityRefundLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(BidSecurityRefundLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function edit() + { + $params = (new BidSecurityRefundValidate())->post()->goCheck('edit'); + $result = BidSecurityRefundLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(BidSecurityRefundLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function delete() + { + $params = (new BidSecurityRefundValidate())->post()->goCheck('delete'); + BidSecurityRefundLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function detail() + { + $params = (new BidSecurityRefundValidate())->goCheck('detail'); + $result = BidSecurityRefundLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/bid/BidSecurityRefundLists.php b/app/adminapi/lists/bid/BidSecurityRefundLists.php new file mode 100644 index 000000000..3ffb9a4e1 --- /dev/null +++ b/app/adminapi/lists/bid/BidSecurityRefundLists.php @@ -0,0 +1,87 @@ +<?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\bid; + + +use app\adminapi\lists\BaseAdminDataLists; +use app\common\model\bid\BidSecurityRefund; +use app\common\lists\ListsSearchInterface; +use think\facade\Db; + +/** + * BidSecurityRefund列表 + * Class BidSecurityRefundLists + * @package app\adminapi\listsbid + */ +class BidSecurityRefundLists extends BaseAdminDataLists implements ListsSearchInterface +{ + + + /** + * @notes 设置搜索条件 + * @return \string[][] + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function setSearch(): array + { + return [ + '=' => ['bidding_decision_id', 'refund_date', 'bank_account_id'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function lists(): array + { + return Db::name('BidSecurityRefund')->alias('bsr') + ->where($this->searchWhere) + ->leftJoin('bid_bidding_decision bbd','bbd.id = bsr.bidding_decision_id') + ->leftJoin('project p','p.id = bbd.project_id') + ->leftJoin('custom ct','ct.id = p.custom_id') + ->field('bsr.*, bbd.project_id, p.name as project_name, ct.name as customer_name') + ->limit($this->limitOffset, $this->limitLength) + ->order(['bsr.id' => 'desc']) + ->select()->each(function($item, $key){ + //关联数据 供应商后续添加 + $item['approve_no'] = '付款单号'; + $item['approve_step'] = '流程步骤'; + $item['approve_settle_status'] = 1; + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function count(): int + { + return BidSecurityRefund::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/bid/BidSecurityRefundLogic.php b/app/adminapi/logic/bid/BidSecurityRefundLogic.php new file mode 100644 index 000000000..ad41cd47f --- /dev/null +++ b/app/adminapi/logic/bid/BidSecurityRefundLogic.php @@ -0,0 +1,131 @@ +<?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\bid; + + +use app\common\model\bid\BidSecurityRefund; +use app\common\logic\BaseLogic; +use think\facade\Db; + + +/** + * BidSecurityRefund逻辑 + * Class BidSecurityRefundLogic + * @package app\adminapi\logic\bid + */ +class BidSecurityRefundLogic extends BaseLogic +{ + + + /** + * @notes 添加 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public static function add(array $params): bool + { + Db::startTrans(); + try { + BidSecurityRefund::create([ + 'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, + 'refund_amount' => $params['refund_amount'] ?? 0, + 'refund_amount_daxie' => $params['refund_amount_daxie'] ?? '', + 'refund_date' => $params['refund_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + 'bank_account_id' => $params['bank_account_id'] ?? 0, + 'is_calculate_interest' => $params['is_calculate_interest'] ?? 0, + 'interest_calculation_start_date' => $params['interest_calculation_start_date'] ?? '', + ]); + + 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/18 10:29 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + BidSecurityRefund::where('id', $params['id'])->update([ + 'bidding_decision_id' => $params['bidding_decision_id'] ?? 0, + 'refund_amount' => $params['refund_amount'] ?? 0, + 'refund_amount_daxie' => $params['refund_amount_daxie'] ?? '', + 'refund_date' => $params['refund_date'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + 'bank_account_id' => $params['bank_account_id'] ?? 0, + 'is_calculate_interest' => $params['is_calculate_interest'] ?? 0, + 'interest_calculation_start_date' => $params['interest_calculation_start_date'] ?? '', + ]); + + 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/18 10:29 + */ + public static function delete(array $params): bool + { + return BidSecurityRefund::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public static function detail($params): array + { + $bidSecurityRefund = BidSecurityRefund::findOrEmpty($params['id']); + $bidSecurityRefund->project = null; + $bidSecurityRefund->custom = null; + if (!empty($bidSecurityRefund->decision->project_id)) { + $bidSecurityRefund->project = Project::findOrEmpty($bidSecurityApply->decision->project_id); + } + if (!empty($bidSecurityRefund->project->custom_id)) { + $bidSecurityRefund->custom = Custom::findOrEmpty($bidSecurityApply->project->custom_id); + } + return $bidSecurityRefund->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/bid/BidSecurityRefundValidate.php b/app/adminapi/validate/bid/BidSecurityRefundValidate.php new file mode 100644 index 000000000..0cee6477d --- /dev/null +++ b/app/adminapi/validate/bid/BidSecurityRefundValidate.php @@ -0,0 +1,102 @@ +<?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\bid; + + +use app\common\validate\BaseValidate; + + +/** + * BidSecurityRefund验证器 + * Class BidSecurityRefundValidate + * @package app\adminapi\validate\bid + */ +class BidSecurityRefundValidate extends BaseValidate +{ + + /** + * 设置校验规则 + * @var string[] + */ + protected $rule = [ + 'id' => 'require', + 'bidding_decision_id' => 'require', + 'refund_amount' => 'require', + 'refund_date' => 'require', + 'bank_account_id' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'bidding_decision_id' => '投标决策id', + 'refund_amount' => '退款金额', + 'refund_date' => '退款日期', + 'bank_account_id' => '银行账号id', + ]; + + + /** + * @notes 添加场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneAdd() + { + return $this->only(['bidding_decision_id','refund_amount','refund_date','bank_account_id']); + } + + + /** + * @notes 编辑场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneEdit() + { + return $this->only(['id','bidding_decision_id','refund_amount','refund_date','bank_account_id']); + } + + + /** + * @notes 删除场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return BidSecurityRefundValidate + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/bid/BidSecurityRefund.php b/app/common/model/bid/BidSecurityRefund.php new file mode 100644 index 000000000..12804ff09 --- /dev/null +++ b/app/common/model/bid/BidSecurityRefund.php @@ -0,0 +1,45 @@ +<?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\bid; + + +use app\common\model\BaseModel; +use think\model\concern\SoftDelete; + + +/** + * BidSecurityRefund模型 + * Class BidSecurityRefund + * @package app\common\model\bid + */ +class BidSecurityRefund extends BaseModel +{ + use SoftDelete; + protected $name = 'bid_security_refund'; + protected $deleteTime = 'delete_time'; + + + /** + * @notes 关联decision + * @return \think\model\relation\HasOne + * @author likeadmin + * @date 2023/12/18 10:29 + */ + public function decision() + { + return $this->belongsTo(\app\common\model\bid\BidBiddingDecision::class, 'bidding_decision_id'); + } + +} \ No newline at end of file