Answer the question
In order to leave comments, you need to log in
How to fix the price calculation algorithm?
Game price + game duoq price = price
win price + win duoq price = price
duoq price works separately.
The screenshot clearly shows
public function actionPrice()
{
$divform = new DivisionForm();
if ($divform->load(Yii::$app->request->post()) && $divform->proc) {
$models = Devision::find()->all();
$k = 1;
if ($divform->minus != 1) {
$k = $k * ($divform->proc/100);
} else {
$k = $k * ($divform->proc/100);
$k = 0 - $k;
}
foreach ($models as $model) {
foreach ($model->devisionPrices as $price) {
$price_game = $price->price_game + $price->price_game * $k;
$price_win = $price->price_win + $price->price_win * $k;
$price_duoq_game = $price->price_duoq_game + $price->price_duoq_game * $k;
$price_duoq = $price->price_duoq + $price->price_duoq * $k;
$price->price_game = number_format($price_game, 2, '.', '');
$price->price_win = number_format($price_win, 2, '.', '');
$price->price_duoq_game = number_format($price_duoq_game, 2, '.', '');
$price->price_duoq = number_format($price_duoq, 2, '.', '');
$price->save();
//var_dump($model->errors);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question