142 lines
4.7 KiB
PHP
142 lines
4.7 KiB
PHP
<?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\AcceptanceBill;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* AcceptanceBill逻辑
|
||
* Class AcceptanceBillLogic
|
||
* @package app\adminapi\logic\bill
|
||
*/
|
||
class AcceptanceBillLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/19 15:18
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
AcceptanceBill::create([
|
||
'org_id' => $params['org_id'] ?? 0,
|
||
'dept_id' => $params['dept_id'] ?? 0,
|
||
'customer_id' => $params['customer_id'] ?? 0,
|
||
'project_id' => $params['project_id'] ?? 0,
|
||
'contract_id' => $params['contract_id'] ?? 0,
|
||
'receipt_date' => $params['receipt_date'] ?? '',
|
||
'bill_sn' => $params['bill_sn'] ?? '',
|
||
'bank_account_id' => $params['bank_account_id'] ?? 0,
|
||
'bill_type' => $params['bill_type'] ?? 0,
|
||
'draft_acceptance_bank' => $params['draft_acceptance_bank'] ?? '',
|
||
'bill_due_date' => $params['bill_due_date'] ?? '',
|
||
'receipt_amount' => $params['receipt_amount'] ?? 0,
|
||
'receipt_amount_daxie' => $params['receipt_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/19 15:18
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
AcceptanceBill::where('id', $params['id'])->update([
|
||
'org_id' => $params['org_id'] ?? 0,
|
||
'dept_id' => $params['dept_id'] ?? 0,
|
||
'customer_id' => $params['customer_id'] ?? 0,
|
||
'project_id' => $params['project_id'] ?? 0,
|
||
'contract_id' => $params['contract_id'] ?? 0,
|
||
'receipt_date' => $params['receipt_date'] ?? '',
|
||
'bill_sn' => $params['bill_sn'] ?? '',
|
||
'bank_account_id' => $params['bank_account_id'] ?? 0,
|
||
'bill_type' => $params['bill_type'] ?? 0,
|
||
'draft_acceptance_bank' => $params['draft_acceptance_bank'] ?? '',
|
||
'bill_due_date' => $params['bill_due_date'] ?? '',
|
||
'receipt_amount' => $params['receipt_amount'] ?? 0,
|
||
'receipt_amount_daxie' => $params['receipt_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/19 15:18
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return AcceptanceBill::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/19 15:18
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$acceptanceBill = AcceptanceBill::findOrEmpty($params['id']);
|
||
$acceptanceBill->custom;
|
||
$acceptanceBill->project;
|
||
$acceptanceBill->org;
|
||
$acceptanceBill->dept;
|
||
$acceptanceBill->contract;
|
||
$acceptanceBill->bankAccount;
|
||
$acceptanceBill->annex = json_decode($acceptanceBill->annex, true);
|
||
return $acceptanceBill->toArray();
|
||
}
|
||
} |