This commit is contained in:
weiz 2024-04-10 11:40:17 +08:00
parent 08c250b8d8
commit 05e9226d7a
6 changed files with 122 additions and 73 deletions

View File

@ -18,7 +18,13 @@
use app\adminapi\lists\BaseAdminDataLists; use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsExcelInterface; use app\common\lists\ListsExcelInterface;
use app\common\lists\ListsSearchInterface; use app\common\lists\ListsSearchInterface;
use app\common\model\auth\Admin;
use app\common\model\cost_project\CostProject; use app\common\model\cost_project\CostProject;
use app\common\model\dept\Dept;
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\ProjectCommission; use app\common\model\ProjectCommission;
use app\common\model\zjzx_finance\ZjzxInvoice; use app\common\model\zjzx_finance\ZjzxInvoice;
use app\common\model\zjzx_finance\ZjzxRefund; use app\common\model\zjzx_finance\ZjzxRefund;
@ -66,27 +72,53 @@
->where($this->searchWhere) ->where($this->searchWhere)
->field('p.*') ->field('p.*')
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->with(['contract'])
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select() ->select()
->each(function ($item) { ->each(function ($res) {
$item['person_text'] = $item->person_text; $contract = MarketingContract::field('contract_name')->where('id', $res['contract_id'])->findOrEmpty();
$item['total_invoice_amount'] = ZjzxInvoice::where('project_id', $item['id'])->sum('apply_amount'); $province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty();
$item['total_refund_amount'] = ZjzxRefund::where('project_id', $item['id'])->sum('amount'); $city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty();
$item['total_pay_amount'] = ProjectCommission::where('project_id', $item['id'])->sum('bczfze'); $dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty();
$admin = Admin::field('name')->where('id', $res['principal'])->findOrEmpty();
$custom = MarketingCustom::field('name')->where('id', $res['aunit'])->findOrEmpty();
$res['contract_name'] = $contract?->contract_name;
$res['types_text'] = $res->types_text;
$res['industry_text'] = $res->industry_text;
$res['province_name'] = $province?->province_name;
$res['city_name'] = $city?->city_name;
$res['dept_name'] = $dept?->name;
$res['principal_name'] = $admin?->name;
$res['person_text'] = $res->person_text;
$res['aunit_name'] = $custom?->name;
$res['total_invoice_amount'] = ZjzxInvoice::where('project_id', $res['id'])->sum('apply_amount');
$res['total_refund_amount'] = ZjzxRefund::where('project_id', $res['id'])->sum('amount');
$res['total_pay_amount'] = ProjectCommission::where('project_id', $res['id'])->sum('bczfze');
}) })
->toArray(); ->toArray();
} }
return CostProject::where($this->searchWhere) return CostProject::where($this->searchWhere)
->limit($this->limitOffset, $this->limitLength) ->limit($this->limitOffset, $this->limitLength)
->with(['contract'])
->order(['id' => 'desc']) ->order(['id' => 'desc'])
->select() ->select()
->each(function ($item) { ->each(function ($res) {
$item['person_text'] = $item->person_text; $contract = MarketingContract::field('contract_name')->where('id', $res['contract_id'])->findOrEmpty();
$item['total_invoice_amount'] = ZjzxInvoice::where('project_id', $item['id'])->sum('apply_amount'); $province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty();
$item['total_refund_amount'] = ZjzxRefund::where('project_id', $item['id'])->sum('amount'); $city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty();
$item['total_pay_amount'] = ProjectCommission::where('project_id', $item['id'])->sum('bczfze'); $dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty();
$admin = Admin::field('name')->where('id', $res['principal'])->findOrEmpty();
$custom = MarketingCustom::field('name')->where('id', $res['aunit'])->findOrEmpty();
$res['contract_name'] = $contract?->contract_name;
$res['types_text'] = $res->types_text;
$res['industry_text'] = $res->industry_text;
$res['province_name'] = $province?->province_name;
$res['city_name'] = $city?->city_name;
$res['dept_name'] = $dept?->name;
$res['principal_name'] = $admin?->name;
$res['person_text'] = $res->person_text;
$res['aunit_name'] = $custom?->name;
$res['total_invoice_amount'] = ZjzxInvoice::where('project_id', $res['id'])->sum('apply_amount');
$res['total_refund_amount'] = ZjzxRefund::where('project_id', $res['id'])->sum('amount');
$res['total_pay_amount'] = ProjectCommission::where('project_id', $res['id'])->sum('bczfze');
}) })
->toArray(); ->toArray();

View File

@ -67,7 +67,9 @@
$data['contract_code'] = $contract['contract_code']; $data['contract_code'] = $contract['contract_code'];
$data['const_area'] = $contract->const_area_text; $data['const_area'] = $contract->const_area_text;
$data['business_nature'] = $contract->business_nature_text; $data['business_nature'] = $contract->business_nature_text;
$data['filing_role'] = (string)$data['filing_role'];
$data['filing_role_text'] = $data->filing_role_text; $data['filing_role_text'] = $data->filing_role_text;
$data['status'] = (string)$data['status'];
$data['status_text'] = $data->status_text; $data['status_text'] = $data->status_text;
}) })
->toArray(); ->toArray();

View File

@ -17,13 +17,14 @@
use app\common\logic\BaseLogic; use app\common\logic\BaseLogic;
use app\common\model\ApprovalIssuanceAchievementDocuments; use app\common\model\ApprovalIssuanceAchievementDocuments;
use app\common\model\auth\Admin;
use app\common\model\cost_project\CostProject; use app\common\model\cost_project\CostProject;
use app\common\model\cost_project\CostProjectPerson;
use app\common\model\DataReception; use app\common\model\DataReception;
use app\common\model\dept\Dept; use app\common\model\dept\Dept;
use app\common\model\GeoCity; use app\common\model\GeoCity;
use app\common\model\GeoProvince; use app\common\model\GeoProvince;
use app\common\model\marketing\MarketingContract; use app\common\model\marketing\MarketingContract;
use app\common\model\marketing\MarketingCustom;
use app\common\model\project_process_management\ApplyWithSeal; use app\common\model\project_process_management\ApplyWithSeal;
use app\common\model\project_process_management\JianliProjectProgressReport; use app\common\model\project_process_management\JianliProjectProgressReport;
use app\common\model\project_process_management\ProjectChangeVisa; use app\common\model\project_process_management\ProjectChangeVisa;
@ -157,16 +158,22 @@
*/ */
public static function detail($params): array public static function detail($params): array
{ {
$res = CostProject::with(['contract'])->findOrEmpty($params['id']); $res = CostProject::withoutField('update_time,delete_time')->findOrEmpty($params['id']);
$res['person_text'] = $res->person_text; $contract = MarketingContract::field('contract_name')->where('id', $res['contract_id'])->findOrEmpty();
$res['types_text'] = $res->types_text;
$res['industry_nature_text'] = $res['contract']->industry_nature_text;
$province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty(); $province = GeoProvince::field('province_name')->where('province_code', $res['province'])->findOrEmpty();
$city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty(); $city = GeoCity::field('city_name')->where('city_code', $res['city'])->findOrEmpty();
$dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty(); $dept = Dept::field('name')->where('id', $res['depar'])->findOrEmpty();
$res['province_name'] = $province['province_name']; $admin = Admin::field('name')->where('id', $res['principal'])->findOrEmpty();
$res['city_name'] = $city['city_name']; $custom = MarketingCustom::field('name')->where('id', $res['aunit'])->findOrEmpty();
$res['dept_name'] = $dept['name']; $res['contract_name'] = $contract?->contract_name;
$res['types_text'] = $res->types_text;
$res['industry_text'] = $res->industry_text;
$res['province_name'] = $province?->province_name;
$res['city_name'] = $city?->city_name;
$res['dept_name'] = $dept?->name;
$res['principal_name'] = $admin?->name;
$res['person_text'] = $res->person_text;
$res['aunit_name'] = $custom?->name;
return $res->toArray(); return $res->toArray();
} }
@ -187,51 +194,51 @@
return $datas; return $datas;
} }
public static function createProject($data) // public static function createProject($data)
{ // {
Db::startTrans(); // Db::startTrans();
try { // try {
$res = CostProject::create([ // $res = CostProject::create([
'project_num' => generate_sn(CostProject::class, 'project_num'), // 'project_num' => generate_sn(CostProject::class, 'project_num'),
'project_name' => $data['project_name'], // 'project_name' => $data['project_name'],
'contract_id' => $data['contract_id'], // 'contract_id' => $data['contract_id'],
'types' => $data['types'], // 'types' => $data['types'],
'industry' => $data['industry'], // 'industry' => $data['industry'],
'province' => $data['province'], // 'province' => $data['province'],
'city' => $data['city'], // 'city' => $data['city'],
'address' => $data['address'], // 'address' => $data['address'],
'starting' => $data['starting'], // 'starting' => $data['starting'],
'endtime' => $data['endtime'], // 'endtime' => $data['endtime'],
'jhgq' => $data['jhgq'], // 'jhgq' => $data['jhgq'],
'depar' => $data['depar'], // 'depar' => $data['depar'],
'principal' => $data['principal'], // 'principal' => $data['principal'],
'invest' => $data['invest'], // 'invest' => $data['invest'],
'budget' => $data['budget'], // 'budget' => $data['budget'],
'cost' => $data['cost'], // 'cost' => $data['cost'],
'approval' => $data['approval'], // 'approval' => $data['approval'],
'aunit' => $data['aunit'], // 'aunit' => $data['aunit'],
'Acontact' => $data['Acontact'], // 'Acontact' => $data['Acontact'],
'acontactnum' => $data['acontactnum'], // 'acontactnum' => $data['acontactnum'],
'date' => $data['date'], // 'date' => $data['date'],
'generalize' => $data['generalize'], // 'generalize' => $data['generalize'],
'note' => $data['note'], // 'note' => $data['note'],
'remark' => $data['remark'], // 'remark' => $data['remark'],
'annex' => $data['annex'] // 'annex' => $data['annex']
]); // ]);
if ($data['person_id']) { // if ($data['person_id']) {
$arr = []; // $arr = [];
$person_id = explode(',', $data['person_id']); // $person_id = explode(',', $data['person_id']);
(new CostProjectPerson)->delete($person_id); // (new CostProjectPerson)->delete($person_id);
foreach ($person_id as $k => $v) { // foreach ($person_id as $k => $v) {
$arr[] = ['cost_project_id' => $data->id, $v]; // $arr[] = ['cost_project_id' => $data->id, $v];
} // }
$arr ?? (new CostProjectPerson)->saveAll($arr); // $arr ?? (new CostProjectPerson)->saveAll($arr);
} // }
return $res; // return $res;
} catch (\Exception $e) { // } catch (\Exception $e) {
return false; // return false;
} // }
} // }
/** /**
* @notes 删除造价项目台账 * @notes 删除造价项目台账

View File

@ -116,7 +116,9 @@
$data['contract_code'] = $contract['contract_code']; $data['contract_code'] = $contract['contract_code'];
$data['const_area'] = $contract->const_area_text; $data['const_area'] = $contract->const_area_text;
$data['business_nature'] = $contract->business_nature_text; $data['business_nature'] = $contract->business_nature_text;
$data['filing_role'] = (string)$data['filing_role'];
$data['filing_role_text'] = $data->filing_role_text; $data['filing_role_text'] = $data->filing_role_text;
$data['status'] = (string)$data['status'];
$data['status_text'] = $data->status_text; $data['status_text'] = $data->status_text;
return $data->toArray(); return $data->toArray();
} }

View File

@ -74,7 +74,7 @@
*/ */
public function sceneAdd() public function sceneAdd()
{ {
return $this->only(['project_num', 'project_name', 'contract_id', 'starting', 'endtime', 'jhgq', 'principal', 'invest', 'aunit', 'annex']); return $this->remove('id', true);
} }
@ -86,7 +86,6 @@
*/ */
public function sceneEdit() public function sceneEdit()
{ {
return $this->only(['id', 'project_num', 'project_name', 'contract_id', 'starting', 'endtime', 'jhgq', 'principal', 'invest', 'aunit', 'annex']);
} }
@ -127,4 +126,10 @@
return !in_array($value, $dict) ? '咨询类型数据值无效' : true; return !in_array($value, $dict) ? '咨询类型数据值无效' : true;
} }
public function checkIndustry($value): bool|string
{
$dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('value');
return !in_array($value, $dict) ? '行业数据值无效' : true;
}
} }

View File

@ -39,17 +39,18 @@
return $this->hasOne(MarketingContract::class, 'id', 'contract_id'); return $this->hasOne(MarketingContract::class, 'id', 'contract_id');
} }
public function CostProjectContract()
{
return $this->hasOne(MarketingContract::class, 'id', 'contract_id');
}
public function getTypesTextAttr($value, $data) public function getTypesTextAttr($value, $data)
{ {
$dict = DictData::where('type_value', 'consultation_type')->column('name', 'value'); $dict = DictData::where('type_value', 'consultation_type')->column('name', 'value');
return !empty($data['types']) ? $dict[$data['types']] : ''; return !empty($data['types']) ? $dict[$data['types']] : '';
} }
public function getIndustryTextAttr($value, $data)
{
$dict = DictData::where('type_value', 'cost_consultation_industry_nature')->column('name', 'value');
return !empty($data['industry']) ? $dict[$data['industry']] : '';
}
public function getPersonAttr($value) public function getPersonAttr($value)
{ {
return !empty($value) ? json_decode($value, true) : ''; return !empty($value) ? json_decode($value, true) : '';