137 lines
4.7 KiB
PHP
137 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\administrative;
|
||
|
||
|
||
use app\common\model\administrative\AdministrativeTicketCollection;
|
||
use app\common\logic\BaseLogic;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* AdministrativeTicketCollection逻辑
|
||
* Class AdministrativeTicketCollectionLogic
|
||
* @package app\adminapi\logic\administrative
|
||
*/
|
||
class AdministrativeTicketCollectionLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/19 14:00
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
AdministrativeTicketCollection::create([
|
||
'org_id' => $params['org_id'] ?? 0,
|
||
'dept_id' => $params['dept_id'] ?? 0,
|
||
'administrative_contract_id' => $params['administrative_contract_id'] ?? 0,
|
||
'invoicing_date' => $params['invoicing_date'] ?? '',
|
||
'commitor' => $params['commitor'] ?? '',
|
||
'invoice_type' => $params['invoice_type'] ?? 0,
|
||
'invoice_sn' => $params['invoice_sn'] ?? '',
|
||
'invoice_amount' => $params['invoice_amount'] ?? 0,
|
||
'invoice_tax_rate' => $params['invoice_tax_rate'] ?? 0,
|
||
'tax' => $params['tax'] ?? 0,
|
||
'amount_excluding_tax' => $params['amount_excluding_tax'] ?? 0,
|
||
'receipt_date' => $params['receipt_date'] ?? '',
|
||
'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 14:00
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
AdministrativeTicketCollection::where('id', $params['id'])->update([
|
||
'org_id' => $params['org_id'],
|
||
'dept_id' => $params['dept_id'],
|
||
'administrative_contract_id' => $params['administrative_contract_id'],
|
||
'invoicing_date' => $params['invoicing_date'],
|
||
'commitor' => $params['commitor'],
|
||
'invoice_type' => $params['invoice_type'],
|
||
'invoice_sn' => $params['invoice_sn'],
|
||
'invoice_amount' => $params['invoice_amount'],
|
||
'invoice_tax_rate' => $params['invoice_tax_rate'],
|
||
'tax' => $params['tax'],
|
||
'amount_excluding_tax' => $params['amount_excluding_tax'],
|
||
'receipt_date' => $params['receipt_date'],
|
||
'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 14:00
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return AdministrativeTicketCollection::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/19 14:00
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$administrativeTicketCollection = AdministrativeTicketCollection::findOrEmpty($params['id']);
|
||
$administrativeTicketCollection->contract;
|
||
$administrativeTicketCollection->org;
|
||
$administrativeTicketCollection->dept;
|
||
$administrativeTicketCollection->annex = json_decode($administrativeTicketCollection->annex, true);
|
||
return $administrativeTicketCollection->toArray();
|
||
}
|
||
} |