Groovy web console

subscribe to the feed Subscribe
to this
site

Công thức tính phí Shippo CN

Published 3 weeks ago by Định Nguyễn
Actions Execute script  ▶ Edit in console Back to console Show/hide line numbers View recent scripts
def actualWeight = 2
def deliveryWarehouse = 'HN'

def r1 = (
actualWeight == 0 || actualWeight == null ? 0 :
    (
        deliveryWarehouse == 'HN' ? (actualWeight < 0.25 ? 6.7 :
            (actualWeight < 0.5 ? 7.8 :
                (actualWeight < 0.75 ? 8.8 :
                    (actualWeight < 1 ? 9.8 :
                        (actualWeight < 1.25 ? 11 :
                            (actualWeight < 1.5 ? 12 :
                                (actualWeight < 1.75 ? 13 :
                                    (actualWeight < 2 ? 14 :
                                        (actualWeight < 2.5 ? 16.2 :
                                            (actualWeight < 3 ? 18.3 :
                                                ((
                                                    ((actualWeight - 3) / 0.5).intValue()
                                                ) * 4 + 18.3)
                                            )
                                        )
                                    )

                                )
                            )
                        )
                    )
                )
            )
        ) :
        (deliveryWarehouse == 'HCM' ?
            (
                actualWeight < 0.25 ? 9.15 :
                (actualWeight < 0.5 ? 10.25 :
                    (actualWeight < 0.75 ? 11.25 :
                        (actualWeight < 1 ? 12.25 :
                            (actualWeight < 1.25 ? 13.35 :
                                (actualWeight < 1.5 ? 14.35 :
                                    (actualWeight < 1.75 ? 15.45 :
                                        (actualWeight < 2 ? 16.55 :
                                            (actualWeight < 2.5 ? 19.55 :
                                                (actualWeight < 3 ? 21.75 :
                                                    ((
                                                        ((actualWeight - 3) / 0.5).intValue()
                                                    ) * 4 + 21.75)
                                                )
                                            )
                                        )

                                    )
                                )
                            )
                        )
                    )
                )
            ) :
            (
                actualWeight < 0.25 ? 9.4 :
                (actualWeight < 0.5 ? 10.5 :
                    (actualWeight < 0.75 ? 11.5 :
                        (actualWeight < 1 ? 12.5 :
                            (actualWeight < 1.25 ? 14.6 :
                                (actualWeight < 1.5 ? 15.6 :
                                    (actualWeight < 1.75 ? 16.7 :
                                        (actualWeight < 2 ? 18.3 :
                                            (actualWeight < 2.5 ? 21.8 :
                                                (actualWeight < 3 ? 24 :
                                                    ((
                                                        ((actualWeight - 3) / 0.5).intValue()
                                                    ) * 4 + 24)
                                                )
                                            )
                                        )

                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )
)
print(r1)