Decimal point problem

    /**
     * 保留2位小数
     * @param $num
     * @return float
     */
    public function keep2DecimalPlaces($num){
    
    
        return sprintf("%.2f",substr(sprintf("%.3f", $num), 0, -1));
    }

    $money = round($money ,2);
$amount = floatval($input['payment_money'])*100;
$amount= (intval(strval($amount)));
$final_price_fen=intval(round(($amount*10-$coupon_fen_cheng10)/10,0));
$final_price_yuan=$final_price_fen/100; //单元:元 |  商品金额 + 邮费 - 优惠券

Note that when exporting excle, the amount needs to be converted to a string type
Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/minihuabei/article/details/110648055