174 lines
7.0 KiB
PHP
174 lines
7.0 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\finance;
|
||
|
||
|
||
use app\common\model\finance\FinanceInvoiceApply;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\project\Project;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\bid\BidBuyBiddingDocument;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* FinanceInvoiceApply逻辑
|
||
* Class FinanceInvoiceApplyLogic
|
||
* @package app\adminapi\logic\finance
|
||
*/
|
||
class FinanceInvoiceApplyLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/13 15:01
|
||
*/
|
||
public static function add(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
FinanceInvoiceApply::create([
|
||
'customer_id' => $params['customer_id'] ?? 0,
|
||
'contract_id' => $params['contract_id'] ?? 0,
|
||
'approve_id' => $params['approve_id'] ?? 0,
|
||
'invoicing_date' => $params['invoicing_date'] ?? '',
|
||
'period' => $params['period'] ?? 0,
|
||
'accumulate_amount' => $params['accumulate_amount'] ?? 0,
|
||
'accumulated_payments_received' => $params['accumulated_payments_received'] ?? 0,
|
||
'tax_rate' => $params['tax_rate'] ?? 0,
|
||
'invoice_type' => $params['invoice_type'] ?? 0,
|
||
'invoicing_amount' => $params['invoicing_amount'] ?? 0,
|
||
'invoicing_amount_daxie' => $params['invoicing_amount_daxie'] ?? '',
|
||
'tax' => $params['tax'] ?? 0,
|
||
'amount_including_tax' => $params['amount_including_tax'] ?? 0,
|
||
'content' => $params['content'] ?? '',
|
||
'invoice_no' => $params['invoice_no'] ?? '',
|
||
'remark' => $params['remark'] ?? '',
|
||
'annex' => $params['annex'] ?? '',
|
||
'invoicing_company_name' => $params['invoicing_company_name'] ?? '',
|
||
'taxpayer_identification_number' => $params['taxpayer_identification_number'] ?? '',
|
||
'deposit_bank' => $params['deposit_bank'] ?? '',
|
||
'bank_accnout' => $params['bank_accnout'] ?? '',
|
||
'address_phone' => $params['address_phone'] ?? '',
|
||
'receiving_address' => $params['receiving_address'] ?? '',
|
||
'contacts' => $params['contacts'] ?? '',
|
||
'phone' => $params['phone'] ?? '',
|
||
'mailing_time' => $params['mailing_time'] ?? '',
|
||
'mailing_type' => $params['mailing_type'] ?? '',
|
||
'mailing_no' => $params['mailing_no'] ?? '',
|
||
]);
|
||
|
||
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/13 15:01
|
||
*/
|
||
public static function edit(array $params): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
FinanceInvoiceApply::where('id', $params['id'])->update([
|
||
'customer_id' => $params['customer_id'] ?? 0,
|
||
'contract_id' => $params['contract_id'] ?? 0,
|
||
'approve_id' => $params['approve_id'] ?? 0,
|
||
'invoicing_date' => $params['invoicing_date'] ?? '',
|
||
'period' => $params['period'] ?? 0,
|
||
'accumulate_amount' => $params['accumulate_amount'] ?? 0,
|
||
'accumulated_payments_received' => $params['accumulated_payments_received'] ?? 0,
|
||
'tax_rate' => $params['tax_rate'] ?? 0,
|
||
'invoice_type' => $params['invoice_type'] ?? 0,
|
||
'invoicing_amount' => $params['invoicing_amount'] ?? 0,
|
||
'invoicing_amount_daxie' => $params['invoicing_amount_daxie'] ?? '',
|
||
'tax' => $params['tax'] ?? 0,
|
||
'amount_including_tax' => $params['amount_including_tax'] ?? 0,
|
||
'content' => $params['content'] ?? '',
|
||
'invoice_no' => $params['invoice_no'] ?? '',
|
||
'remark' => $params['remark'] ?? '',
|
||
'annex' => $params['annex'] ?? '',
|
||
'invoicing_company_name' => $params['invoicing_company_name'] ?? '',
|
||
'taxpayer_identification_number' => $params['taxpayer_identification_number'] ?? '',
|
||
'deposit_bank' => $params['deposit_bank'] ?? '',
|
||
'bank_accnout' => $params['bank_accnout'] ?? '',
|
||
'address_phone' => $params['address_phone'] ?? '',
|
||
'receiving_address' => $params['receiving_address'] ?? '',
|
||
'contacts' => $params['contacts'] ?? '',
|
||
'phone' => $params['phone'] ?? '',
|
||
'mailing_time' => $params['mailing_time'] ?? '',
|
||
'mailing_type' => $params['mailing_type'] ?? '',
|
||
'mailing_no' => $params['mailing_no'] ?? '',
|
||
]);
|
||
|
||
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/13 15:01
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return FinanceInvoiceApply::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/13 15:01
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$financeInvoiceApply = FinanceInvoiceApply::findOrEmpty($params['id']);
|
||
$financeInvoiceApply->contract;
|
||
$financeInvoiceApply->custom;
|
||
$financeInvoiceApply->document = null;
|
||
if (!empty($financeInvoiceApply->contract->buy_bidding_document_id)) {
|
||
$financeInvoiceApply->document = BidBuyBiddingDocument::findOrEmpty($financeInvoiceApply->contract->buy_bidding_document_id);
|
||
}
|
||
if (!empty($financeInvoiceApply->document->project_id)) {
|
||
$financeInvoiceApply->project = Project::findOrEmpty($financeInvoiceApply->document->project_id);
|
||
}
|
||
$financeInvoiceApply->annex = json_decode($financeInvoiceApply->annex, true);
|
||
return $financeInvoiceApply->toArray();
|
||
}
|
||
} |