Commit: 690c1f6
Commit Details
| SHA | 690c1f6ce426c62c29e87ac132dda0f8125192ff |
|---|---|
| Tree | 5a67fd55b56735ab4e469c7d06c1c73c4c2b4c20 |
| Author | <f69e50@finnacloud.com> 1766368110 +0300 |
| Committer | <f69e50@finnacloud.com> 1766368110 +0300 |
| Message | initialize backend structure with controllers, DTOs, and configuration files |
| GPG Signature | -----BEGIN PGP SIGNATURE----- iQJSBAABCAA8FiEEWJb139mJI+vZ81KkoAIVSUsXI0oFAmlIo24eHHNvcGhpYS5l cmFzbGFuQGZpbm5hY2xvdWQuY29tAAoJEKACFUlLFyNKwXYP/RvWx8mxXoZbKEVA wQFC9UnzcoL/lElB5QMr9opKzRv4uGgFkKMDhbSnqE6NoET5H5VanOFQ9u5a4Khi 9PBTLIEBjbEqA1trC+aTDk3EplVtQYYbSn19CdMSCW7FXJNSg0IiyWKA44iH8Ts0 Xcxh59m6WcwvRDhxQDy6hCXqUa9ISNNk75KRnJS/qRGIEy94DwUYxVfCJpAfzyVu VmdinE6kZM2GDj8MBTPQTzi6hMf/e9CcAg51tf4oNtd9tnW8QKpTsPsFy434VUDh Vxtv/oAJ5tuTIprs2BSnyZ6Kb8RDwDdmQyuKjZMUIwZTH/TCE85SZFf5sa5tpYOH 2KekT52ffZgKw/DUtpNosW6qeHgCJlSvwY7BW7M90X5xJuahrKS04lEDBO04cIRn bg0ayPFTp7Idhl1OuTRhWS6e344g44mJ/9sZK1sXd/0U8OKBbytk35AnCIPCEdSX 8vgjqBR9Wt3A/Kel5j2VcUFDhrAR72a9lJiQHNBicvcVu9Nd41vDnEwUDdNQv6Uc 6omEz3pkVkq+89/eW1KQM8LvrIuGQ/wIUgykvCNSCQ5oba2fjtAXzI+SmxpeCWOz jTKZOEJyhIQE7uvaUj6/0D2JwlxbMG27fcUN7N3aKv6mSVP7hYnHaUbRLQ+f8/xU VfU776FkUXS+4CfSooHtu+ioul9O =ZuqE -----END PGP SIGNATURE----- ✓ Verified |
File: src/main/java/com/paymentlink/service/ShippingService.java
| 1 | package com.paymentlink.service; |
| 2 | |
| 3 | import org.springframework.stereotype.Service; |
| 4 | |
| 5 | |
| 6 | public class ShippingService { |
| 7 | |
| 8 | /** |
| 9 | * Calculate shipping cost based on method and country |
| 10 | */ |
| 11 | public long calculateShippingCost(String method, String country) { |
| 12 | if (method == null || method.isEmpty()) { |
| 13 | method = "standard"; |
| 14 | } |
| 15 | |
| 16 | // Base rates in cents |
| 17 | long baseRate = switch (method.toLowerCase()) { |
| 18 | case "express" -> 2000; // $20 |
| 19 | case "overnight" -> 3500; // $35 |
| 20 | default -> 1000; // $10 for standard |
| 21 | }; |
| 22 | |
| 23 | // International shipping surcharge |
| 24 | if (country != null && !country.equals("US")) { |
| 25 | baseRate += 1500; // $15 surcharge |
| 26 | } |
| 27 | |
| 28 | return baseRate; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Get available shipping methods |
| 33 | */ |
| 34 | public String[] getAvailableShippingMethods() { |
| 35 | return new String[]{"standard", "express", "overnight"}; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Validate shipping method |
| 40 | */ |
| 41 | public boolean isValidShippingMethod(String method) { |
| 42 | if (method == null) return false; |
| 43 | String lower = method.toLowerCase(); |
| 44 | return lower.equals("standard") || lower.equals("express") || lower.equals("overnight"); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 |