engineering/app/common/model/marketing/MarketingContract.php

174 lines
5.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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\common\model\marketing;
use app\common\model\BaseModel;
use app\common\model\dict\DictData;
use think\model\concern\SoftDelete;
/**
* 市场经营--合同信息模型
* Class MarketingContract
* @package app\common\model\marketing
*/
class MarketingContract extends BaseModel
{
use SoftDelete;
protected $name = 'marketing_contract';
protected $deleteTime = 'delete_time';
public function getContractTypeTextAttr($value, $data): string
{
$arr = [0 => '主合同', 1 => '框架协议', 2 => '补充协议'];
return $arr[$data['contract_type']];
}
public function getBusinessNatureTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_business_nature')->column('name', 'value');
return !empty($data['business_nature']) ? $dict[$data['business_nature']] : '';
}
public function getIndustryNatureTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('name', 'value');
return !empty($data['industry_nature']) ? $dict[$data['industry_nature']] : '';
}
public function getFundSourcesTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'money_source')->column('name', 'value');
return !empty($data['fund_sources']) ? $dict[$data['fund_sources']] : '';
}
public function getConstAreaTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_const_area')->column('name', 'value');
return !empty($data['const_area']) ? $dict[$data['const_area']] : '';
}
public function getAgreementNatureTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'agreement_nature')->column('name', 'value');
return !empty($data['agreement_nature']) ? $dict[$data['agreement_nature']] : '';
}
public function getImplementMethodTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_way')->column('name', 'value');
return !empty($data['implement_method']) ? $dict[$data['implement_method']] : '';
}
public function getFileTypeTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_file_type')->column('name', 'value');
return !empty($data['file_type']) ? $dict[$data['file_type']] : '';
}
public function getSealNameTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_seal_name')->column('name', 'value');
return !empty($data['seal_name']) ? $dict[$data['seal_name']] : '';
}
public function getApproveCheckStatusTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_seal_name')->column('name', 'value');
return !empty($data['approve_check_status']) ? $dict[$data['approve_check_status']] : '';
}
public function getIsLimitTextAttr($value, $data): string
{
$arr = [0 => '否', 1 => '是'];
return $arr[$data['is_limit']];
}
public function getPlanceSealTextAttr($value, $data): string
{
$arr = [0 => '否', 1 => '是'];
return $arr[$data['plance_seal']];
}
public function getReviewStatusTextAttr($value, $data): string
{
if ($data['contract_type'] == 0) {
$arr = [0 => '待移交', 1 => '已移交'];
return $arr[$data['review_status']];
} else {
return '不可移交';
}
}
public function getStatusTextAttr($value, $data): string
{
$arr = [0 => '待立项', 1 => '已立项'];
return $arr[$data['reflux_status']];
}
public function getRefluxStatusTextAttr($value, $data): string
{
$arr = [0 => '未回流', 1 => '已回流'];
return $arr[$data['reflux_status']];
}
public function getStartDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getEndDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getPerformanceMoneyExpirationTimeAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
public function getSendDateAttr($value): string
{
return !empty($value) ? date('Y-m-d', $value) : '';
}
/**
* 统计合同类型
*/
public function ContractTypeStatistics($where, $time, string $selectType, string $group = "")
{
switch ($selectType) {
case "sum":
$totalMoney = $this->where($where)->when(isset($time), function ($query) use ($time) {
$query->whereBetweenTime('create_time', strtotime($time['start_time']), strtotime($time['end_time']));
})->count();
break;
case "group":
$totalMoney = $this->getCurveData($where, $time, 'count(id)', $group);
break;
default:
throw new \Exception('getOrderTotalMoney:selectType参数错误');
}
if ($group) {
$totalMoney = $this->trendYdata((array)$totalMoney, $time);
}
return $totalMoney;
}
}