如何在yii2中为单独计算计算gridview

how to calculate gridview for separate calculations in yii2

我想在gridview上分开计算陆运和空运。例如 service_id 陆运 = D2D 和 service_id 空运 = P2P。陆运P x P x P / 4000和空运P x P x P / 6000的计算。我想找到始发地到目的地的城市,它会根据计算在gridview上显示陆运和空运费率在网格视图中。我不知道怎么。谢谢

    [
    'label' => 'Tarif',
    'format' => 'Currency',
    'value' => function ($model) {
        $volume = $model->rate * Yii::$app->request->get('TarifCargoSearch')['panjang'] * Yii::$app->request->get('TarifCargoSearch')['lebar'] * Yii::$app->request->get('TarifCargoSearch')['tinggi'] /4000 + $model->admin_fee; //$model->service_id=>['D2D']
        $volume = $model->rate * Yii::$app->request->get('TarifCargoSearch')['panjang'] * Yii::$app->request->get('TarifCargoSearch')['lebar'] * Yii::$app->request->get('TarifCargoSearch')['tinggi'] /6000 + $model->admin_fee; //$model->service_id=>['P2P']
        $mass = $model->rate * Yii::$app->request->get('TarifCargoSearch')['massa'] + $model->admin_fee;

        return $mass > $volume? $mass : $volume;
        }
    ],
[
    'label' => 'Tarif',
    'format' => 'Currency',
    'value' => function ($model) {
       $volume = 0;
       if($model->service_id == 'D2D') {
           $volume = $model->rate * Yii::$app->request->get('TarifCargoSearch')['panjang'] * Yii::$app->request->get('TarifCargoSearch')['lebar'] * Yii::$app->request->get('TarifCargoSearch')['tinggi'] /4000 + $model->admin_fee;
        } else if($model->service_id == 'P2P')
           $volume = $model->rate * Yii::$app->request->get('TarifCargoSearch')['panjang'] * Yii::$app->request->get('TarifCargoSearch')['lebar'] * Yii::$app->request->get('TarifCargoSearch')['tinggi'] /6000 + $model->admin_fee;
        }
       $mass = $model->rate * Yii::$app->request->get('TarifCargoSearch')['massa'] + $model->admin_fee;

       return $mass > $volume? $mass : $volume;
       }
],