This commit is contained in:
weiz 2024-05-08 11:26:51 +08:00
parent 4bff210147
commit 7379a51637
10 changed files with 321 additions and 104 deletions

View File

@ -59,6 +59,15 @@
return $this->fail(FinancialInvoiceLogic::getError());
}
public function upload()
{
$params = (new FinancialInvoiceValidate())->post()->goCheck('upload');
$result = FinancialInvoiceLogic::upload($params);
if (true === $result) {
return $this->success('上传成功', [], 1, 1);
}
return $this->fail(FinancialInvoiceLogic::getError());
}
/**
* @notes 编辑财务管理--开票台账
@ -76,7 +85,6 @@
return $this->fail(FinancialInvoiceLogic::getError());
}
/**
* @notes 删除财务管理--开票台账
* @return \think\response\Json

View File

@ -11,98 +11,108 @@
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller\financial;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\financial\FinancialRefundLists;
use app\adminapi\logic\financial\FinancialRefundLogic;
use app\adminapi\validate\financial\FinancialRefundValidate;
/**
* 财务管理--到账台账控制器
* Class FinancialRefundController
* @package app\adminapi\controller\financial
*/
class FinancialRefundController extends BaseAdminController
{
/**
* @notes 获取财务管理--到账台账列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function lists()
{
return $this->dataLists(new FinancialRefundLists());
}
/**
* @notes 添加财务管理--到账台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function add()
{
$params = (new FinancialRefundValidate())->post()->goCheck('add');
$result = FinancialRefundLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FinancialRefundLogic::getError());
}
/**
* @notes 编辑财务管理--到账台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function edit()
{
$params = (new FinancialRefundValidate())->post()->goCheck('edit');
$result = FinancialRefundLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FinancialRefundLogic::getError());
}
/**
* @notes 删除财务管理--到账台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function delete()
{
$params = (new FinancialRefundValidate())->post()->goCheck('delete');
FinancialRefundLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取财务管理--到账台账详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function detail()
{
$params = (new FinancialRefundValidate())->goCheck('detail');
$result = FinancialRefundLogic::detail($params);
return $this->data($result);
}
}
namespace app\adminapi\controller\financial;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\financial\FinancialRefundLists;
use app\adminapi\logic\financial\FinancialRefundLogic;
use app\adminapi\validate\financial\FinancialRefundValidate;
/**
* 财务管理--到账台账控制器
* Class FinancialRefundController
* @package app\adminapi\controller\financial
*/
class FinancialRefundController extends BaseAdminController
{
/**
* @notes 获取财务管理--到账台账列表
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function lists()
{
return $this->dataLists(new FinancialRefundLists());
}
/**
* @notes 添加财务管理--到账台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function add()
{
$params = (new FinancialRefundValidate())->post()->goCheck('add');
$result = FinancialRefundLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(FinancialRefundLogic::getError());
}
/**
* @notes 编辑财务管理--到账台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function edit()
{
$params = (new FinancialRefundValidate())->post()->goCheck('edit');
$result = FinancialRefundLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(FinancialRefundLogic::getError());
}
public function upload()
{
$params = (new FinancialRefundValidate())->post()->goCheck('upload');
$result = FinancialRefundLogic::upload($params);
if (true === $result) {
return $this->success('上传成功', [], 1, 1);
}
return $this->fail(FinancialRefundLogic::getError());
}
/**
* @notes 删除财务管理--到账台账
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function delete()
{
$params = (new FinancialRefundValidate())->post()->goCheck('delete');
FinancialRefundLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取财务管理--到账台账详情
* @return \think\response\Json
* @author likeadmin
* @date 2024/03/25 14:46
*/
public function detail()
{
$params = (new FinancialRefundValidate())->goCheck('detail');
$result = FinancialRefundLogic::detail($params);
return $this->data($result);
}
}

View File

@ -32,7 +32,6 @@
class MarketingContractController extends BaseAdminController
{
/**
* @notes 获取市场经营--合同信息列表
* @return \think\response\Json
@ -106,6 +105,26 @@
return $this->data($result);
}
public function info()
{
$params = (new MarketingContractValidate())->goCheck('detail');
$result = MarketingContractLogic::info($params);
if (false === $result) {
return $this->fail(MarketingContractLogic::getError());
}
return $this->data($result);
}
public function download()
{
$params = (new MarketingContractValidate())->goCheck('detail');
$result = MarketingContractLogic::download($params);
if (false === $result) {
return $this->fail(MarketingContractLogic::getError());
}
return $this->success('下载成功', ['url' => $result], 1, 1);
}
public function datas(): \think\response\Json
{
return $this->data(MarketingContractLogic::datas());

View File

@ -76,9 +76,14 @@
$data['sign_money'] = $contract['signed_amount'];
$data['sign_time'] = $contract['create_time'];
$data['invoice_type_text'] = $data->invoice_type_text;
$refund = FinancialRefund::where('invoice_id', $data['id'])->findOrEmpty();
$data['is_refund'] = !$refund->isEmpty() ? '已到账' : '未到账';
$data['refund_amount'] = !$refund->isEmpty() ? FinancialRefund::where('invoice_id', $data['id'])->sum('amount') : 0.00;
$data['refund_amount'] = FinancialRefund::where('invoice_id', $data['id'])->sum('amount') ?? 0.00;
if ($data['refund_amount'] <= 0) {
$data['is_refund'] = '未到账';
} elseif ($data['refund_amount'] < $data['apply_amount']) {
$data['is_refund'] = '部分到账';
} else {
$data['is_refund'] = '已到账';
}
})
->toArray();
}

View File

@ -16,9 +16,13 @@
use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsExcelInterface;
use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\dept\Dept;
use app\common\model\financial\FinancialInvoice;
use app\common\model\financial\FinancialRefund;
use app\common\model\financial\FinancialSettlement;
use app\common\model\marketing\MarketingContract;
use app\common\model\marketing\MarketingCustom;
@ -28,9 +32,40 @@
* Class MarketingContractLists
* @package app\adminapi\listsmarketing
*/
class MarketingContractLists extends BaseAdminDataLists implements ListsSearchInterface
class MarketingContractLists extends BaseAdminDataLists implements ListsSearchInterface, ListsExcelInterface
{
public function setExcelFields(): array
{
return [
'contract_name' => '合同名称',
'contract_code' => '合同编号',
'contract_type_text' => '合同类型',
'business_nature_text' => '业务性质',
'part_a_name' => '签约单位',
'signed_dept_name' => '签订部门',
'total_invoice_amount' => '已开票金额',
'not_total_invoice_amount' => '未开票金额',
'total_refund_amount' => '已到账金额',
'not_total_refund_amount' => '未到账金额',
'invoice_not_refund_amount' => '开票未回款金额',
'refund_not_invoice_amount' => '回款未开票金额',
'total_settlement_amount' => '结算金额',
'create_time' => '签订日期',
];
}
/**
* @notes 设置导出文件名
* @return string
* @author 段誉
* @date 2021/12/29 10:08
*/
public function setFileName(): string
{
return '管理员列表';
}
/**
* @notes 设置搜索条件
@ -88,6 +123,22 @@
$data['status_text'] = $data->status_text;
$data['reflux_status_text'] = $data->reflux_status_text;
$data['approve_check_status_text'] = $data->approve_check_status_text;
$invoice_ids = FinancialInvoice::where('contract_id', $data['id'])->column('id');
//开票金额
$data['total_invoice_amount'] = FinancialInvoice::where('contract_id', $data['id'])->sum('apply_amount');
//未开票金额
$data['not_total_invoice_amount'] = bcsub($data['signed_amount'], $data['total_invoice_amount'], 2);
//到账金额
$data['total_refund_amount'] = FinancialRefund::where('contract_id', $data['id'])->sum('amount');
//未到账金额
$data['not_total_refund_amount'] = bcsub($data['signed_amount'], $data['total_refund_amount'], 2);
//开票未回款金额
$invoice_has_refund_amount = FinancialRefund::where('contract_id', $data['id'])->where('invoice_id', 'in', $invoice_ids)->sum('amount');
$data['invoice_not_refund_amount'] = bcsub($data['total_invoice_amount'], $invoice_has_refund_amount, 2);
//回款未开票金额
$data['refund_not_invoice_amount'] = bcsub($data['total_refund_amount'], $invoice_has_refund_amount, 2);
//结算金额
$data['total_settlement_amount'] = FinancialSettlement::where('contract_id', $data['id'])->sum('amount');
})
->toArray();
}

View File

@ -59,6 +59,7 @@
'apply_email' => $params['apply_email'] ?? '',
'pay_type' => $params['pay_type'] ?? '',
'invoice_content' => $params['invoice_content'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $params['create_user'],
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time()
]);
@ -98,6 +99,7 @@
'apply_email' => $params['apply_email'] ?? '',
'pay_type' => $params['pay_type'] ?? '',
'invoice_content' => $params['invoice_content'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $params['create_user'],
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
'update_time' => time()
@ -112,6 +114,23 @@
}
}
public static function upload(array $params): bool
{
Db::startTrans();
try {
FinancialInvoice::where('id', $params['id'])->update([
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除财务管理--开票台账

View File

@ -49,6 +49,7 @@
'amount' => $params['amount'],
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $params['create_user'],
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
]);
@ -80,6 +81,7 @@
'amount' => $params['amount'],
'date' => !empty($params['date']) ? strtotime($params['date']) : 0,
'remark' => $params['remark'] ?? '',
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'create_user' => $params['create_user'],
'create_time' => !empty($params['create_time']) ? strtotime($params['create_time']) : time(),
'update_time' => time()
@ -94,6 +96,23 @@
}
}
public static function upload(array $params): bool
{
Db::startTrans();
try {
FinancialRefund::where('id', $params['id'])->update([
'annex' => $params['annex'] ? json_encode($params['annex']) : null,
'update_time' => time()
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除财务管理--到账台账

View File

@ -15,9 +15,16 @@
namespace app\adminapi\logic\marketing;
use app\adminapi\lists\marketing\MarketingContractLists;
use app\common\logic\BaseLogic;
use app\common\model\auth\Admin;
use app\common\model\cost_project\CostProject;
use app\common\model\dept\Dept;
use app\common\model\financial\FinancialInvoice;
use app\common\model\financial\FinancialRefund;
use app\common\model\financial\FinancialSettlement;
use app\common\model\GeoCity;
use app\common\model\GeoProvince;
use app\common\model\marketing\MarketingContract;
use app\common\model\marketing\MarketingCustom;
use app\common\model\oa\FlowApprove;
@ -179,6 +186,35 @@
return MarketingContract::destroy($params['id']);
}
public static function download(array $params): bool
{
$lists = new MarketingContractLists();
$data = MarketingContract::field('id,contract_type,contract_name,contract_code,part_a,business_nature,signed_amount,signed_dept,create_time')->findOrEmpty($params['id']);
$custom = MarketingCustom::field('name')->where('id', $data['part_a'])->findOrEmpty();
$dept = Dept::where('id', 'in', [$data['signed_dept'], $data['supervise_dept']])->column('name', 'id');
$data['part_a_name'] = $custom['name'];
$data['signed_dept_name'] = $dept[$data['signed_dept']] ?? '';
$data['contract_type_text'] = $data->contract_type_text;
$data['business_nature_text'] = $data->business_nature_text;
$invoice_ids = FinancialInvoice::where('contract_id', $data['id'])->column('id');
//开票金额
$data['total_invoice_amount'] = FinancialInvoice::where('contract_id', $data['id'])->sum('apply_amount');
//未开票金额
$data['not_total_invoice_amount'] = bcsub($data['signed_amount'], $data['total_invoice_amount'], 2);
//到账金额
$data['total_refund_amount'] = FinancialRefund::where('contract_id', $data['id'])->sum('amount');
//未到账金额
$data['not_total_refund_amount'] = bcsub($data['signed_amount'], $data['total_refund_amount'], 2);
//开票未回款金额
$invoice_has_refund_amount = FinancialRefund::where('contract_id', $data['id'])->where('invoice_id', 'in', $invoice_ids)->sum('amount');
$data['invoice_not_refund_amount'] = bcsub($data['total_invoice_amount'], $invoice_has_refund_amount, 2);
//回款未开票金额
$data['refund_not_invoice_amount'] = bcsub($data['total_refund_amount'], $invoice_has_refund_amount, 2);
//结算金额
$data['total_settlement_amount'] = FinancialSettlement::where('contract_id', $data['id'])->sum('amount');
return $lists->createExcel($lists->setExcelFields(), [$data->toArray()]);
}
/**
* @notes 获取市场经营--合同信息详情
@ -213,9 +249,49 @@
$data['plance_seal_text'] = $data->plance_seal_text;
$data['contract_type_text'] = $data->contract_type_text;
$data['review_status_text'] = $data->review_status_text;
$invoice_ids = FinancialInvoice::where('contract_id', $data['id'])->column('id');
//开票金额
$data['total_invoice_amount'] = FinancialInvoice::where('contract_id', $data['id'])->sum('apply_amount');
//未开票金额
$data['not_total_invoice_amount'] = bcsub($data['signed_amount'], $data['total_invoice_amount'], 2);
//到账金额
$data['total_refund_amount'] = FinancialRefund::where('contract_id', $data['id'])->sum('amount');
//未到账金额
$data['not_total_refund_amount'] = bcsub($data['signed_amount'], $data['total_refund_amount'], 2);
//开票未回款金额
$invoice_has_refund_amount = FinancialRefund::where('contract_id', $data['id'])->where('invoice_id', 'in', $invoice_ids)->sum('amount');
$data['invoice_not_refund_amount'] = bcsub($data['total_invoice_amount'], $invoice_has_refund_amount, 2);
//回款未开票金额
$data['refund_not_invoice_amount'] = bcsub($data['total_refund_amount'], $invoice_has_refund_amount, 2);
//结算金额
$data['total_settlement_amount'] = FinancialSettlement::where('contract_id', $data['id'])->sum('amount');
return $data->toArray();
}
public static function info($params): array
{
$data = MarketingContract::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
if ($data['status'] != 1) {
self::setError('当前合同未立项');
return false;
}
$pro = CostProject::withoutField('update_time,delete_time')->where('contract_id', $params['id'])->findOrEmpty();
$province = GeoProvince::field('province_name')->where('province_code', $pro['province'])->findOrEmpty();
$city = GeoCity::field('city_name')->where('city_code', $pro['city'])->findOrEmpty();
$dept = Dept::field('name')->where('id', $pro['depar'])->findOrEmpty();
$admin = Admin::field('name')->where('id', $pro['principal'])->findOrEmpty();
$custom = MarketingCustom::field('name')->where('id', $pro['aunit'])->findOrEmpty();
$pro['types_text'] = $pro->types_text;
$pro['industry_text'] = $pro->industry_text;
$pro['province_name'] = $province?->province_name;
$pro['city_name'] = $city?->city_name;
$pro['dept_name'] = $dept?->name;
$pro['principal_name'] = $admin?->name;
$pro['person_text'] = $pro->person_text;
$pro['aunit_name'] = $custom?->name;
return $pro->toArray();
}
public static function datas(): array
{
return MarketingCustom::field(['id', 'contract_name'])->where('contract_type', 0)->order(['id' => 'desc'])->select()->each(function ($data) {

View File

@ -42,7 +42,8 @@
'apply_company_number' => 'require',
'apply_email' => 'email',
'create_user' => 'require',
'create_time' => 'require|dateFormat:Y-m-d H:i:s'
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
'annex' => 'checkAnnex'
];
@ -68,7 +69,6 @@
'apply_email' => '发票接收邮箱',
'create_user' => '开票申请人',
'create_time' => '开票申请时间'
];
@ -83,6 +83,11 @@
return $this->remove('id', true);
}
public function sceneUpload()
{
return $this->only(['id', 'annex']);
}
/**
* @notes 编辑场景

View File

@ -41,7 +41,7 @@
'date' => 'require|dateFormat:Y-m-d',
'create_user' => 'require',
'create_time' => 'require|dateFormat:Y-m-d H:i:s',
'annex' => 'checkAnnex'
];
@ -72,6 +72,11 @@
return $this->remove('id', true);
}
public function sceneUpload()
{
return $this->only(['id', 'annex']);
}
/**
* @notes 编辑场景