update
This commit is contained in:
parent
d29c9705c8
commit
391d1bbe40
@ -59,6 +59,26 @@ class QuotationController extends BaseAdminController
|
||||
return $this->fail(QuotationLogic::getError());
|
||||
}
|
||||
|
||||
public function edit()
|
||||
{
|
||||
$params = (new QuotationValidate())->post()->goCheck('edit');
|
||||
$result = QuotationLogic::edit($params,$this->adminId);
|
||||
if (true === $result) {
|
||||
return $this->success('编辑成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(QuotationLogic::getError());
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$params = (new QuotationValidate())->post()->goCheck('delete');
|
||||
$result = QuotationLogic::delete($params);
|
||||
if (true === $result) {
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(QuotationLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -42,4 +42,11 @@ class QuotationDetailController extends BaseAdminController
|
||||
return $this->dataLists(new QuotationDetailLists());
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$params = (new QuotationDetailValidate())->post()->goCheck('delete');
|
||||
QuotationDetailLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
}
|
@ -20,8 +20,6 @@ use app\common\model\custom\Custom;
|
||||
use app\common\model\custom\CustomerDemand;
|
||||
use app\common\model\custom\CustomerDemandSolution;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\project\Project;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -47,8 +45,6 @@ class CustomerDemandSolutionLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
CustomerDemandSolution::create([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'project_id' => $params['project_id'],
|
||||
'customer_demand_id' => $params['customer_demand_id'],
|
||||
'theme' => $params['theme'],
|
||||
@ -81,8 +77,6 @@ class CustomerDemandSolutionLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
CustomerDemandSolution::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'project_id' => $params['project_id'],
|
||||
'customer_demand_id' => $params['customer_demand_id'],
|
||||
'theme' => $params['theme'],
|
||||
@ -126,14 +120,10 @@ class CustomerDemandSolutionLogic extends BaseLogic
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = CustomerDemandSolution::field('id,org_id,dept_id,project_id,customer_demand_id,theme,submission_time,solution_content,customer_feedback,annex,add_user,update_user,create_time,update_time')->findOrEmpty($params['id'])->toArray();
|
||||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
||||
$project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$demand = CustomerDemand::field('theme')->where('id',$data['customer_demand_id'])->findOrEmpty();
|
||||
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
|
||||
$data['org_name'] = $org['name'];
|
||||
$data['dept_name'] = $dept['name'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
|
@ -18,8 +18,6 @@ namespace app\adminapi\logic\project;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\custom\CustomerDemand;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\project\Competitor;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\project\Project;
|
||||
@ -44,8 +42,6 @@ class CompetitorLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
Competitor::create([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'project_id' => $params['project_id'],
|
||||
'customer_demand_id' => $params['customer_demand_id'],
|
||||
'competitor_name' => $params['competitor_name'],
|
||||
@ -81,8 +77,6 @@ class CompetitorLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
Competitor::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'project_id' => $params['project_id'],
|
||||
'customer_demand_id' => $params['customer_demand_id'],
|
||||
'competitor_name' => $params['competitor_name'],
|
||||
@ -130,14 +124,10 @@ class CompetitorLogic extends BaseLogic
|
||||
{
|
||||
$field = 'id,org_id,dept_id,project_id,customer_demand_id,competitor_name,competitor_contacts,competitor_contacts_phone,competitive_power,competitor_advantages,competitor_disadvantages,remark,annex,add_user,update_user,create_time,update_time';
|
||||
$data = Competitor::field($field)->findOrEmpty($params['id'])->toArray();
|
||||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
||||
$project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$demand = CustomerDemand::field('theme')->where('id',$data['customer_demand_id'])->findOrEmpty();
|
||||
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
|
||||
$data['org_name'] = $org['name'];
|
||||
$data['dept_name'] = $dept['name'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
|
@ -19,8 +19,6 @@ use app\common\model\auth\Admin;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\custom\CustomContacts;
|
||||
use app\common\model\custom\CustomerDemand;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectEstimate;
|
||||
use app\common\logic\BaseLogic;
|
||||
@ -48,8 +46,6 @@ class ProjectEstimateLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectEstimate::create([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'project_id' => $params['project_id'],
|
||||
'customer_demand_id' => $params['customer_demand_id'],
|
||||
'estimate_source' => $params['estimate_source'],
|
||||
@ -86,8 +82,6 @@ class ProjectEstimateLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
ProjectEstimate::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'project_id' => $params['project_id'],
|
||||
'customer_demand_id' => $params['customer_demand_id'],
|
||||
'estimate_source' => $params['estimate_source'],
|
||||
@ -138,16 +132,12 @@ class ProjectEstimateLogic extends BaseLogic
|
||||
$data = ProjectEstimate::field($field)->findOrEmpty($params['id']);
|
||||
$data['estimate_source_text'] = $data->estimate_source_text;
|
||||
$data['invoice_type_text'] = $data->invoice_type_text;
|
||||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
||||
$project = Project::field('name,project_code,custom_id')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$project['custom_id'])->findOrEmpty();
|
||||
$demand = CustomerDemand::field('theme')->where('id',$data['customer_demand_id'])->findOrEmpty();
|
||||
$contract = CustomContacts::field('name,phone')->where('id',$data['contact_id'])->findOrEmpty();
|
||||
$technician = Admin::field('name')->where('id',$data['technician'])->findOrEmpty();
|
||||
$admin = Admin::where('id','in',[$data['add_user'],$data['update_user']])->column('name','id');
|
||||
$data['org_name'] = $org['name'];
|
||||
$data['dept_name'] = $dept['name'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
|
@ -15,7 +15,6 @@
|
||||
namespace app\adminapi\logic\project;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\model\project\ProjectFollowUp;
|
||||
|
@ -16,8 +16,6 @@ namespace app\adminapi\logic\quotation;
|
||||
|
||||
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\quotation\Quotation;
|
||||
use app\common\model\quotation\QuotationDetail;
|
||||
@ -52,8 +50,6 @@ class QuotationLogic extends BaseLogic
|
||||
Db::startTrans();
|
||||
try {
|
||||
$quotation = Quotation::create([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'custom_id' => $params['custom_id'],
|
||||
'code' => data_unique_code('报价单'),
|
||||
'quotation_date' => !empty($params['quotation_date']) ? strtotime($params['quotation_date']) : 0,
|
||||
@ -87,6 +83,73 @@ class QuotationLogic extends BaseLogic
|
||||
}
|
||||
}
|
||||
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
$quotation_detail = $params['quotation_detail'];
|
||||
$tax_rate_dict = DictData::where('type_value','tax_rate')->column('name','value');
|
||||
foreach($quotation_detail as &$v){
|
||||
$v['tax_inclusive_amount'] = $v['num'] * $v['tax_inclusive_price'];
|
||||
$v['tax_exclusive_amount'] = $v['num'] * $v['tax_inclusive_price'] * (1- $tax_rate_dict[$v['tax_rate']] / 100);
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
$quotation = Quotation::where('id',$params['id'])->update([
|
||||
'custom_id' => $params['custom_id'],
|
||||
'quotation_date' => !empty($params['quotation_date']) ? strtotime($params['quotation_date']) : 0,
|
||||
'create_user' => $params['create_user'] ?? '',
|
||||
'invoice_type' => $params['invoice_type'] ?? 0,
|
||||
'freight' => $params['freight'],
|
||||
'other_fee' => $params['other_fee'],
|
||||
'customer_require' => $params['customer_require'] ?? '',
|
||||
'remark' => $params['remark'] ?? '',
|
||||
'annex' => $params['annex']? json_encode($params['annex']) : null,
|
||||
'update_time' => time(),
|
||||
]);
|
||||
foreach ($quotation_detail as $item)
|
||||
{
|
||||
if(!empty($item['id'])){
|
||||
QuotationDetail::where('id',$item['id'])->update([
|
||||
'quotation_id' => $params['id'],
|
||||
'product_id' => $item['product_id'],
|
||||
'num' => $item['num'],
|
||||
'tax_rate' => $item['tax_rate'],
|
||||
'tax_inclusive_price' => $item['tax_inclusive_price'],
|
||||
'tax_inclusive_amount' => $item['tax_inclusive_price'] * $item['num'],
|
||||
'tax_exclusive_amount' => $item['tax_inclusive_price'] * $item['num'] * (1- $tax_rate_dict[$item['tax_rate']] / 100),
|
||||
'remark' => $item['remark'] ?? ''
|
||||
]);
|
||||
}else{
|
||||
QuotationDetail::create([
|
||||
'quotation_id' => $params['id'],
|
||||
'product_id' => $item['product_id'],
|
||||
'num' => $item['num'],
|
||||
'tax_rate' => $item['tax_rate'],
|
||||
'tax_inclusive_price' => $item['tax_inclusive_price'],
|
||||
'tax_inclusive_amount' => $item['tax_inclusive_price'] * $item['num'],
|
||||
'tax_exclusive_amount' => $item['tax_inclusive_price'] * $item['num'] * (1- $tax_rate_dict[$item['tax_rate']] / 100),
|
||||
'remark' => $item['remark'] ?? ''
|
||||
]);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
$detail = QuotationDetail::where('quotation_id','in',$params['id'])->findOrEmpty();
|
||||
if(!$detail->isEmpty()){
|
||||
self::setError('此数据关联了报价明细信息,须删除报价明细信息');
|
||||
return false;
|
||||
}
|
||||
return Quotation::destroy($params['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取报价单详情
|
||||
* @param $params
|
||||
@ -96,12 +159,8 @@ class QuotationLogic extends BaseLogic
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$data = Quotation::field('id,org_id,dept_id,custom_id,quotation_date,create_user,invoice_type,freight,other_fee,customer_require,remark,annex')->findOrEmpty($params['id']);
|
||||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
||||
$data = Quotation::field('id,custom_id,quotation_date,create_user,invoice_type,freight,other_fee,customer_require,remark,annex')->findOrEmpty($params['id']);
|
||||
$custom = Custom::field('name,master_name,master_phone')->where('id',$data['custom_id'])->findOrEmpty();
|
||||
$data['org_name'] = $org['name'];
|
||||
$data['dept_name'] = $dept['name'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
$data['custom_master_name'] = $custom['master_name'];
|
||||
$data['custom_master_phone'] = $custom['master_phone'];
|
||||
|
@ -126,6 +126,7 @@ class SupervisionProjectInfoReportLogic extends BaseLogic
|
||||
$data['project_name'] = $project['project_name'];
|
||||
$data['project_manager'] = $project['project_manager'];
|
||||
$data['severity_text'] = $data->severity_text;
|
||||
$data['info_cate_text'] = $data->info_cate_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -16,8 +16,6 @@ namespace app\adminapi\validate\custom;
|
||||
|
||||
|
||||
use app\common\model\custom\CustomerDemand;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
@ -36,8 +34,6 @@ class CustomerDemandSolutionValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'org_id' => 'require|checkOrg',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'project_id' => 'require|checkProject',
|
||||
'customer_demand_id' => 'require|checkCustomerDemand',
|
||||
'theme' => 'require',
|
||||
@ -47,8 +43,6 @@ class CustomerDemandSolutionValidate extends BaseValidate
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'org_id.require' => '请选择组织',
|
||||
'dept_id.require' => '请选择部门',
|
||||
'project_id.require' => '请选择项目',
|
||||
'customer_demand_id.require' => '请选择客户需求',
|
||||
'theme.require' => '请填写需求主题',
|
||||
@ -102,27 +96,6 @@ class CustomerDemandSolutionValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkOrg($value): bool|string
|
||||
{
|
||||
$org = Orgs::where('id',$value)->findOrEmpty();
|
||||
if($org->isEmpty()) {
|
||||
return '组织不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDept($value,$rule,$data): bool|string
|
||||
{
|
||||
$dept = Dept::where('id',$value)->findOrEmpty();
|
||||
if($dept->isEmpty()){
|
||||
return '部门不存在';
|
||||
}
|
||||
if($dept['org_id'] != $data['org_id']){
|
||||
return '当前部门不属于所选择的组织';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$project = Project::where('id',$value)->findOrEmpty();
|
||||
@ -143,15 +116,5 @@ class CustomerDemandSolutionValidate extends BaseValidate
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
if(!is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -111,15 +111,4 @@ class CustomerDemandValidate extends BaseValidate
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
if(!is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -16,8 +16,6 @@ namespace app\adminapi\validate\project;
|
||||
|
||||
|
||||
use app\common\model\custom\CustomerDemand;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
@ -36,8 +34,6 @@ class CompetitorValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'org_id' => 'require|checkOrg',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'project_id' => 'require|checkProject',
|
||||
'customer_demand_id' => 'require|checkCustomerDemand',
|
||||
'competitor_name' => 'require',
|
||||
@ -47,8 +43,6 @@ class CompetitorValidate extends BaseValidate
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'org_id.require' => '请选择组织',
|
||||
'dept_id.require' => '请选择部门',
|
||||
'project_id.require' => '请选择项目',
|
||||
'customer_demand_id.require' => '请选择客户需求',
|
||||
'competitor_name.require' => '请填写竞争对手名称',
|
||||
@ -101,27 +95,6 @@ class CompetitorValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkOrg($value): bool|string
|
||||
{
|
||||
$org = Orgs::where('id',$value)->findOrEmpty();
|
||||
if($org->isEmpty()) {
|
||||
return '组织不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDept($value,$rule,$data): bool|string
|
||||
{
|
||||
$dept = Dept::where('id',$value)->findOrEmpty();
|
||||
if($dept->isEmpty()){
|
||||
return '部门不存在';
|
||||
}
|
||||
if($dept['org_id'] != $data['org_id']){
|
||||
return '当前部门不属于所选择的组织';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$project = Project::where('id',$value)->findOrEmpty();
|
||||
@ -143,14 +116,4 @@ class CompetitorValidate extends BaseValidate
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
if(!is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -16,11 +16,8 @@ namespace app\adminapi\validate\project;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\custom\CustomContacts;
|
||||
use app\common\model\custom\CustomerDemand;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\validate\BaseValidate;
|
||||
@ -40,8 +37,6 @@ class ProjectEstimateValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'org_id' => 'require|checkOrg',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'project_id' => 'require|checkProject',
|
||||
'customer_demand_id' => 'require|checkCustomerDemand',
|
||||
'estimate_source' => 'require|checkEstimateSource',
|
||||
@ -55,8 +50,6 @@ class ProjectEstimateValidate extends BaseValidate
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'org_id.require' => '请选择组织',
|
||||
'dept_id.require' => '请选择部门',
|
||||
'project_id.require' => '请选择项目',
|
||||
'customer_demand_id.require' => '请选择客户需求',
|
||||
'contact_id.require' => '请选择联系人',
|
||||
@ -113,27 +106,6 @@ class ProjectEstimateValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkOrg($value): bool|string
|
||||
{
|
||||
$org = Orgs::where('id',$value)->findOrEmpty();
|
||||
if($org->isEmpty()) {
|
||||
return '组织不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDept($value,$rule,$data): bool|string
|
||||
{
|
||||
$dept = Dept::where('id',$value)->findOrEmpty();
|
||||
if($dept->isEmpty()){
|
||||
return '部门不存在';
|
||||
}
|
||||
if($dept['org_id'] != $data['org_id']){
|
||||
return '当前部门不属于所选择的组织';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$project = Project::where('id',$value)->findOrEmpty();
|
||||
@ -194,15 +166,5 @@ class ProjectEstimateValidate extends BaseValidate
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
if(!is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -154,15 +154,5 @@ class ProjectFollowUpValidate extends BaseValidate
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
if(!is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -222,22 +222,11 @@ class ProjectValidate extends BaseValidate
|
||||
|
||||
public function checkUnitNature($value): bool|string
|
||||
{
|
||||
$dictData = DictData::where('type_value','unit_nature')->column('value');
|
||||
if(!in_array($value,$dictData)){
|
||||
$dictData = DictData::where('type_value', 'unit_nature')->column('value');
|
||||
if (!in_array($value, $dictData)) {
|
||||
return '单位性质无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
$annex =$value;//json_decode($value,true);
|
||||
if(empty($annex) || !is_array($annex)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -16,10 +16,9 @@ namespace app\adminapi\validate\quotation;
|
||||
|
||||
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\material\Material;
|
||||
use app\common\model\quotation\QuotationDetail;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
@ -37,8 +36,6 @@ class QuotationValidate extends BaseValidate
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'org_id' => 'require|checkOrg',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'custom_id' => 'require|checkCustom',
|
||||
'quotation_date' => 'dateFormat:Y-m-d',
|
||||
'invoice_type' => 'checkInvoiceType',
|
||||
@ -50,8 +47,6 @@ class QuotationValidate extends BaseValidate
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'org_id.require' => '请选择组织',
|
||||
'dept_id.require' => '请选择部门',
|
||||
'custom_id.require' => '请选择客户',
|
||||
'quotation_date.dateFormat' => '报价日期格式错误',
|
||||
'freight.require' => '运费不能为空',
|
||||
@ -108,27 +103,6 @@ class QuotationValidate extends BaseValidate
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkOrg($value): bool|string
|
||||
{
|
||||
$org = Orgs::where('id',$value)->findOrEmpty();
|
||||
if($org->isEmpty()){
|
||||
return '组织不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDept($value,$rule,$data): bool|string
|
||||
{
|
||||
$dept = Dept::where('id',$value)->findOrEmpty();
|
||||
if($dept->isEmpty()){
|
||||
return '部门不存在';
|
||||
}
|
||||
if($dept['org_id'] != $data['org_id']){
|
||||
return '部门无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkCustom($value): bool|string
|
||||
{
|
||||
$custom = Custom::where('id',$value)->findOrEmpty();
|
||||
@ -147,13 +121,16 @@ class QuotationValidate extends BaseValidate
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkQuotationDetail($value,$rule,$data): bool|string
|
||||
public function checkQuotationDetail($value): bool|string
|
||||
{
|
||||
$quotation_detail = $value;
|
||||
if(empty($quotation_detail) || !is_array($quotation_detail)){
|
||||
if(empty($value) || !is_array($value)){
|
||||
return '报价明细数据格式错误';
|
||||
}
|
||||
foreach($quotation_detail as $v) {
|
||||
foreach($value as $k=>$v) {
|
||||
if(!empty($v['id'])){
|
||||
$quotation_detail = QuotationDetail::where('id',$v['id'])->findOrEmpty();
|
||||
if($quotation_detail->isEmpty()) return '报价明细列表第'.($k+1).'行报价明细数据不存在';
|
||||
}
|
||||
if(empty($v['product_id'])){
|
||||
return '请选择产品';
|
||||
}else{
|
||||
@ -163,39 +140,30 @@ class QuotationValidate extends BaseValidate
|
||||
}
|
||||
}
|
||||
if(empty($v['num'])){
|
||||
return '数量不能为空';
|
||||
return '报价明细列表第'.($k+1).'行数量不能为空';
|
||||
}else{
|
||||
if(!is_numeric($v['num']) || $v['num'] < 0){
|
||||
return '数量必须是大于0的数字';
|
||||
return '报价明细列表第'.($k+1).'行数量必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
if(empty($v['tax_rate'])){
|
||||
return '税率不能为空';
|
||||
return '报价明细列表第'.($k+1).'行税率不能为空';
|
||||
}else{
|
||||
$tax_rate_dict_data = DictData::where('type_value','tax_rate')->column('value');
|
||||
if(!in_array($v['tax_rate'],$tax_rate_dict_data)){
|
||||
return '税率无效';
|
||||
return '报价明细列表第'.($k+1).'行税率无效';
|
||||
}
|
||||
}
|
||||
if(empty($v['tax_inclusive_price'])){
|
||||
return '含税单价不能为空';
|
||||
return '报价明细列表第'.($k+1).'行含税单价不能为空';
|
||||
}else{
|
||||
if(!is_numeric($v['tax_inclusive_price']) || $v['tax_inclusive_price'] < 0){
|
||||
return '含税单价必须是大于0的数字';
|
||||
return '报价明细列表第'.($k+1).'行含税单价必须是大于0的数字';
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
if(!is_array($value)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -30,11 +30,6 @@ class CustomerDemandSolution extends BaseModel
|
||||
protected $name = 'customer_demand_solution';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getSubmissionTimeAttr($value): string
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
|
@ -29,9 +29,4 @@ class Competitor extends BaseModel
|
||||
use SoftDelete;
|
||||
protected $name = 'competitor';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
}
|
@ -121,9 +121,4 @@ class Project extends BaseModel
|
||||
{
|
||||
return empty($value) ? '' : date('Y-m-d', $value);
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
}
|
@ -43,11 +43,6 @@ class ProjectEstimate extends BaseModel
|
||||
return $dictData[$data['invoice_type']];
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
|
||||
public function getQuotationDateAttr($value): string
|
||||
{
|
||||
return empty($value) ? '' : date('Y-m-d', $value);
|
||||
|
@ -64,9 +64,4 @@ class ProjectFollowUp extends BaseModel
|
||||
{
|
||||
return !empty($value) ? date('Y-m-d',$value) : '';
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return !empty($value) ? json_decode($value) : '';
|
||||
}
|
||||
}
|
@ -41,8 +41,4 @@ class Quotation extends BaseModel
|
||||
$dictData[0]='';
|
||||
return $dictData[$data['invoice_type']];
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value){
|
||||
return !empty($value) ? json_decode($value,true) : '';
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user