新增汇款转出
This commit is contained in:
parent
25302e14f8
commit
f1ceb7051f
app
adminapi
controller/bill
lists/bill
logic/bill
validate/bill
common/model
108
app/adminapi/controller/bill/TransferBillController.php
Normal file
108
app/adminapi/controller/bill/TransferBillController.php
Normal 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\bill;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\bill\TransferBillLists;
|
||||
use app\adminapi\logic\bill\TransferBillLogic;
|
||||
use app\adminapi\validate\bill\TransferBillValidate;
|
||||
|
||||
|
||||
/**
|
||||
* TransferBill控制器
|
||||
* Class TransferBillController
|
||||
* @package app\adminapi\controller\bill
|
||||
*/
|
||||
class TransferBillController extends BaseAdminController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new TransferBillLists());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new TransferBillValidate())->post()->goCheck('add');
|
||||
$result = TransferBillLogic::add($params);
|
||||
if (true === $result) {
|
||||
return $this->success('添加成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(TransferBillLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new TransferBillValidate())->post()->goCheck('edit');
|
||||
$result = TransferBillLogic::edit($params);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(TransferBillLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new TransferBillValidate())->post()->goCheck('delete');
|
||||
TransferBillLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new TransferBillValidate())->goCheck('detail');
|
||||
$result = TransferBillLogic::detail($params);
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
}
|
95
app/adminapi/lists/bill/TransferBillLists.php
Normal file
95
app/adminapi/lists/bill/TransferBillLists.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?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\bill;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\bill\TransferBill;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* TransferBill列表
|
||||
* Class TransferBillLists
|
||||
* @package app\adminapi\listsbill
|
||||
*/
|
||||
class TransferBillLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
* @return \string[][]
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['tb.org_id', 'tb.dept_id', 'tb.supplier_id', 'tb.procurement_contract_id', 'tb.acceptance_bill_id'],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Db::name('TransferBill')->alias('tb')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('tb.delete_time')
|
||||
->leftJoin('orgs o','o.id = tb.org_id')
|
||||
->leftJoin('dept d','d.id = tb.dept_id')
|
||||
->leftJoin('procurement_contract pc','pc.id = tb.procurement_contract_id')
|
||||
->leftJoin('project p','p.id = pc.project_id')
|
||||
->leftJoin('acceptance_bill ab','ab.id = tb.acceptance_bill_id')
|
||||
->field('tb.*, d.name as dept_name, o.name as org_name, , p.name as project_name, pc.contract_no, pc.contract_name, ab.receipt_date, ab.bill_sn, ab.bill_type, ab.draft_acceptance_bank, ab.bill_due_date')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['tb.id' => 'desc'])
|
||||
->select()->each(function($item, $key){
|
||||
//关联数据后续添加
|
||||
$item['supplier_name'] = '供应商名称';
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Db::name('TransferBill')->alias('tb')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('tb.delete_time')
|
||||
->leftJoin('orgs o','o.id = tb.org_id')
|
||||
->leftJoin('dept d','d.id = tb.dept_id')
|
||||
->leftJoin('procurement_contract pc','pc.id = tb.procurement_contract_id')
|
||||
->leftJoin('project p','p.id = pc.project_id')
|
||||
->leftJoin('acceptance_bill ab','ab.id = tb.acceptance_bill_id')->count();
|
||||
}
|
||||
|
||||
}
|
133
app/adminapi/logic/bill/TransferBillLogic.php
Normal file
133
app/adminapi/logic/bill/TransferBillLogic.php
Normal 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\bill;
|
||||
|
||||
|
||||
use app\common\model\bill\TransferBill;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* TransferBill逻辑
|
||||
* Class TransferBillLogic
|
||||
* @package app\adminapi\logic\bill
|
||||
*/
|
||||
class TransferBillLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
TransferBill::create([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'supplier_id' => $params['supplier_id'] ?? 0,
|
||||
'procurement_contract_id' => $params['procurement_contract_id'] ?? 0,
|
||||
'acceptance_bill_id' => $params['acceptance_bill_id'] ?? 0,
|
||||
'payment_date' => $params['payment_date'] ?? '',
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'amount_daxie' => $params['amount_daxie'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
]);
|
||||
|
||||
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/20 10:14
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
TransferBill::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'supplier_id' => $params['supplier_id'] ?? 0,
|
||||
'procurement_contract_id' => $params['procurement_contract_id'] ?? 0,
|
||||
'acceptance_bill_id' => $params['acceptance_bill_id'] ?? 0,
|
||||
'payment_date' => $params['payment_date'] ?? '',
|
||||
'amount' => $params['amount'] ?? 0,
|
||||
'amount_daxie' => $params['amount_daxie'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex'] ?? '',
|
||||
]);
|
||||
|
||||
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/20 10:14
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return TransferBill::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
return TransferBill::findOrEmpty($params['id'])->toArray();
|
||||
$transferBill = TransferBill::findOrEmpty($params['id']);
|
||||
$transferBill->org;
|
||||
$transferBill->dept;
|
||||
$transferBill->contract;
|
||||
$transferBill->acceptance;
|
||||
$transferBill->project = $transferBill->contract->project;
|
||||
$transferBill->custom = $transferBill->project->custom;
|
||||
unset($transferBill->contract->project, $transferBill->project->custom);
|
||||
return $transferBill->toArray();
|
||||
}
|
||||
}
|
104
app/adminapi/validate/bill/TransferBillValidate.php
Normal file
104
app/adminapi/validate/bill/TransferBillValidate.php
Normal file
@ -0,0 +1,104 @@
|
||||
<?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\bill;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* TransferBill验证器
|
||||
* Class TransferBillValidate
|
||||
* @package app\adminapi\validate\bill
|
||||
*/
|
||||
class TransferBillValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'org_id' => 'require',
|
||||
'dept_id' => 'require',
|
||||
'supplier_id' => 'require',
|
||||
'procurement_contract_id' => 'require',
|
||||
'amount' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
'org_id' => '组织id',
|
||||
'dept_id' => '部门id',
|
||||
'supplier_id' => '客户id',
|
||||
'procurement_contract_id' => '采购/分包合同id',
|
||||
'amount' => '金额',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return TransferBillValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['org_id','dept_id','supplier_id','procurement_contract_id','amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return TransferBillValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','org_id','dept_id','supplier_id','procurement_contract_id','amount']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return TransferBillValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return TransferBillValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
60
app/common/model/bill/TransferBill.php
Normal file
60
app/common/model/bill/TransferBill.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?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\bill;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
/**
|
||||
* TransferBill模型
|
||||
* Class TransferBill
|
||||
* @package app\common\model\bill
|
||||
*/
|
||||
class TransferBill extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
protected $name = 'transfer_bill';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
/**
|
||||
* @notes 关联contract
|
||||
* @return \think\model\relation\HasOne
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 10:14
|
||||
*/
|
||||
public function contract()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\contract\ProcurementContract::class, 'id', 'procurement_contract_id');
|
||||
}
|
||||
|
||||
public function org()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Orgs::class, 'id', 'org_id');
|
||||
}
|
||||
|
||||
public function dept()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Dept::class, 'id', 'dept_id');
|
||||
}
|
||||
|
||||
public function acceptance()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\bill\AcceptanceBill::class, 'id', 'acceptance_bill_id');
|
||||
}
|
||||
|
||||
}
|
@ -51,4 +51,9 @@ class Project extends BaseModel
|
||||
return empty($value) ? '' : date('Y-m-d H:i:s', $value);
|
||||
}
|
||||
|
||||
public function custom()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\custom\Custom::class, 'custom_id');
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user