--- a/application/model/DateMenu.php +++ b/application/model/DateMenu.php @@ -123,7 +123,7 @@ ]) ->select() ->toArray(); - return $info; + return $this->normalizeProteinRawFlagWeight($info); } //膳食纤维 @@ -247,7 +247,7 @@ ->where($where) ->select() ->toArray(); - return $info; + return $this->normalizeProteinRawFlagWeight($info); } //蛋白质来源部分团体 @@ -519,4 +519,21 @@ { return $this->where($where)->group($group)->select()->toArray(); } + + /** Only b.raw_flag_weight physical DECIMAL(10,2) in the two protein projections. */ + private function normalizeProteinRawFlagWeight(array $rows): array + { + if (ltrim((string)config('database.type'), '\\') !== \app\cores\database\Dm::class) { + return $rows; + } + foreach ($rows as $index => $row) { + if (array_key_exists('raw_flag_weight', $row)) { + $physical = \app\common\service\DecimalResponseFormatter::dishes([ + 'raw_flag_weight' => $row['raw_flag_weight'], + ]); + $rows[$index]['raw_flag_weight'] = $physical['raw_flag_weight']; + } + } + return $rows; + } }