142 lines
5.2 KiB
PHP
142 lines
5.2 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\bid;
|
||
|
||
|
||
use app\common\model\auth\Admin;
|
||
use app\common\model\bid\BidDocumentExamination;
|
||
use app\common\model\bid\BidDocumentExaminationDetail;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\custom\Custom;
|
||
use app\common\model\material\Material;
|
||
use app\common\model\project\Project;
|
||
use think\facade\Db;
|
||
|
||
|
||
/**
|
||
* 标书审查-报价明细逻辑
|
||
* Class BidDocumentExaminationDetailLogic
|
||
* @package app\adminapi\logic\bid
|
||
*/
|
||
class BidDocumentExaminationDetailLogic extends BaseLogic
|
||
{
|
||
|
||
|
||
/**
|
||
* @notes 添加标书审查-报价明细
|
||
* @param array $params
|
||
* @return bool
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:59
|
||
*/
|
||
public static function add(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
BidDocumentExaminationDetail::create([
|
||
'bid_document_examination_id' => $params['bid_document_examination_id'],
|
||
'product_id' => $params['product_id'],
|
||
'num' => $params['num'],
|
||
'points' => $params['points'],
|
||
'cost_price' => $params['cost_price'],
|
||
'cost_amount' => $params['cost_price'] * $params['num'],
|
||
'sale_price' => $params['sale_price'],
|
||
'sale_amount' => $params['sale_price'] * $params['num'],
|
||
'add_user' => $admin_id,
|
||
'update_user' => $admin_id,
|
||
]);
|
||
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/02 09:59
|
||
*/
|
||
public static function edit(array $params,$admin_id): bool
|
||
{
|
||
Db::startTrans();
|
||
try {
|
||
BidDocumentExaminationDetail::where('id', $params['id'])->update([
|
||
'bid_document_examination_id' => $params['bid_document_examination_id'],
|
||
'product_id' => $params['product_id'],
|
||
'num' => $params['num'],
|
||
'points' => $params['points'],
|
||
'cost_price' => $params['cost_price'],
|
||
'cost_amount' => $params['cost_price'] * $params['num'],
|
||
'sale_price' => $params['sale_price'],
|
||
'sale_amount' => $params['sale_price'] * $params['num'],
|
||
'update_user' => $admin_id,
|
||
'update_time' => time(),
|
||
]);
|
||
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/02 09:59
|
||
*/
|
||
public static function delete(array $params): bool
|
||
{
|
||
return BidDocumentExaminationDetail::destroy($params['id']);
|
||
}
|
||
|
||
|
||
/**
|
||
* @notes 获取标书审查-报价明细详情
|
||
* @param $params
|
||
* @return array
|
||
* @author likeadmin
|
||
* @date 2023/12/02 09:59
|
||
*/
|
||
public static function detail($params): array
|
||
{
|
||
$data = BidDocumentExaminationDetail::field('id,bid_document_examination_id,product_id,num,points,cost_price,cost_amount,sale_price,sale_amount,add_user,update_user,create_time,update_time')->findOrEmpty($params['id']);
|
||
$bid_document_examination = BidDocumentExamination::field('project_id,code')->where('id',$data['bid_document_examination_id'])->findOrEmpty();
|
||
$project = Project::field('name,project_code,custom_id')->where('id',$bid_document_examination['project_id'])->findOrEmpty();
|
||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||
$product = Material::field('name,specs,unit')->where('id',$data['product_id'])->findOrEmpty();
|
||
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
|
||
$data['bid_document_examination_code'] = $bid_document_examination['code'];
|
||
$data['project_name'] = $project['name'];
|
||
$data['project_code'] = $project['project_code'];
|
||
$data['custom_name'] = $custom['name'];
|
||
$data['product_name'] = $product['name'];
|
||
$data['product_specs'] = $product['specs'];
|
||
$data['product_unit'] = $product['unit'];
|
||
$data['add_user_name'] = $admin[$data['add_user']];
|
||
$data['update_user_name'] = $admin[$data['update_user']];
|
||
return $data->toArray();
|
||
}
|
||
} |