调整产量产值往万进位
parent
29f5b2a7a9
commit
ebc9a42c92
|
|
@ -26,11 +26,11 @@ class CropYieldResource extends JsonResource
|
|||
'crop_id' => $this->crop_id,
|
||||
'time_year' => $this->time_year,
|
||||
'quarter' => $this->quarter,
|
||||
'yield' => $this->yield.$this->whenLoaded('crop', function () {
|
||||
'yield' => $this->formatNumber($this->yield).$this->whenLoaded('crop', function () {
|
||||
return $this->crop?->unit ?? '';
|
||||
}, ''),
|
||||
'output' => $this->output.'元',
|
||||
'cultivated' => $this->cultivated.'亩',
|
||||
'output' => $this->formatNumber($this->output).'元',
|
||||
'cultivated' => $this->formatNumber($this->cultivated).'亩',
|
||||
'extends' => $this->extends,
|
||||
'created_by' => $this->whenLoaded('createdBy', function () {
|
||||
return $this->createdBy?->name;
|
||||
|
|
@ -38,4 +38,12 @@ class CropYieldResource extends JsonResource
|
|||
'created_at' => strtotime($this->created_at) ?? 0, //录入时间
|
||||
];
|
||||
}
|
||||
|
||||
private function formatNumber($number){
|
||||
if($number > 10000){
|
||||
return round($number/10000).'万';
|
||||
}else{
|
||||
return $number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue