Commit 5e609a45e94634c0aee56184ce82a927b5181611
1 parent
7587a56d
convert user card amount to yuan
Showing
3 changed files
with
12 additions
and
20 deletions
cashier-pipeline/src/main/java/com/diligrp/cashier/pipeline/client/CardPaymentHttpClient.java
| @@ -11,6 +11,7 @@ import com.diligrp.cashier.pipeline.type.PaymentState; | @@ -11,6 +11,7 @@ import com.diligrp.cashier.pipeline.type.PaymentState; | ||
| 11 | import com.diligrp.cashier.shared.ErrorCode; | 11 | import com.diligrp.cashier.shared.ErrorCode; |
| 12 | import com.diligrp.cashier.shared.service.ServiceEndpointSupport; | 12 | import com.diligrp.cashier.shared.service.ServiceEndpointSupport; |
| 13 | import com.diligrp.cashier.shared.type.SourceType; | 13 | import com.diligrp.cashier.shared.type.SourceType; |
| 14 | +import com.diligrp.cashier.shared.util.CurrencyUtils; | ||
| 14 | import com.diligrp.cashier.shared.util.JsonUtils; | 15 | import com.diligrp.cashier.shared.util.JsonUtils; |
| 15 | import com.fasterxml.jackson.core.type.TypeReference; | 16 | import com.fasterxml.jackson.core.type.TypeReference; |
| 16 | import org.slf4j.Logger; | 17 | import org.slf4j.Logger; |
| @@ -69,8 +70,7 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport { | @@ -69,8 +70,7 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport { | ||
| 69 | HttpResult result = send(uri, payload); | 70 | HttpResult result = send(uri, payload); |
| 70 | if (result.statusCode == 200) { | 71 | if (result.statusCode == 200) { |
| 71 | LOG.debug("Received from card payment pipeline: {}", result.responseText); | 72 | LOG.debug("Received from card payment pipeline: {}", result.responseText); |
| 72 | - Map<String, Object> response = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() { | ||
| 73 | - }); | 73 | + Map<String, Object> response = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 74 | if ("200".equals(response.get("code"))) { | 74 | if ("200".equals(response.get("code"))) { |
| 75 | Map<String, Object> data = (Map<String, Object>) response.get("data"); | 75 | Map<String, Object> data = (Map<String, Object>) response.get("data"); |
| 76 | String outTradeNo = (String) data.get("outTradeNo"); | 76 | String outTradeNo = (String) data.get("outTradeNo"); |
| @@ -101,8 +101,7 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport { | @@ -101,8 +101,7 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport { | ||
| 101 | HttpResult result = send(uri, payload); | 101 | HttpResult result = send(uri, payload); |
| 102 | if (result.statusCode == 200) { | 102 | if (result.statusCode == 200) { |
| 103 | LOG.debug("Received from card payment pipeline: {}", result.responseText); | 103 | LOG.debug("Received from card payment pipeline: {}", result.responseText); |
| 104 | - Map<String, Object> response = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() { | ||
| 105 | - }); | 104 | + Map<String, Object> response = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 106 | if ("200".equals(response.get("code"))) { | 105 | if ("200".equals(response.get("code"))) { |
| 107 | return new OnlineRefundResponse(request.getRefundId(), null, now, | 106 | return new OnlineRefundResponse(request.getRefundId(), null, now, |
| 108 | PaymentState.SUCCESS, "园区卡退款成功"); | 107 | PaymentState.SUCCESS, "园区卡退款成功"); |
| @@ -124,18 +123,17 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport { | @@ -124,18 +123,17 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport { | ||
| 124 | HttpResult result = send(uri, payload); | 123 | HttpResult result = send(uri, payload); |
| 125 | if (result.statusCode == 200) { | 124 | if (result.statusCode == 200) { |
| 126 | LOG.debug("Received from card payment pipeline: {}", result.responseText); | 125 | LOG.debug("Received from card payment pipeline: {}", result.responseText); |
| 127 | - Map<String, Object> response = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() { | ||
| 128 | - }); | 126 | + Map<String, Object> response = JsonUtils.fromJsonString(result.responseText, new TypeReference<>() {}); |
| 129 | if ("200".equals(response.get("code"))) { | 127 | if ("200".equals(response.get("code"))) { |
| 130 | List<UserCardDTO> userCards = new ArrayList<>(); | 128 | List<UserCardDTO> userCards = new ArrayList<>(); |
| 131 | Object data = response.get("data"); | 129 | Object data = response.get("data"); |
| 132 | if (data != null) { | 130 | if (data != null) { |
| 133 | - List<Map<String, Object>> cardList = JsonUtils.convertValue(data, new TypeReference<>() { | ||
| 134 | - }); | 131 | + List<Map<String, Object>> cardList = JsonUtils.convertValue(data, new TypeReference<>() {}); |
| 135 | for (Map<String, Object> card : cardList) { | 132 | for (Map<String, Object> card : cardList) { |
| 133 | + String amount = CurrencyUtils.toNoSymbolCurrency(convertLong(card.get("amount"))); | ||
| 136 | UserCardDTO userCard = new UserCardDTO(convertLong(card.get("customerId")), | 134 | UserCardDTO userCard = new UserCardDTO(convertLong(card.get("customerId")), |
| 137 | - convertLong(card.get("accountId")), (String) card.get("cardNo"), | ||
| 138 | - (String) card.get("customerName"), convertLong(card.get("amount"))); | 135 | + convertLong(card.get("accountId")), (String) card.get("cardNo"), |
| 136 | + (String) card.get("customerName"), amount); | ||
| 139 | userCards.add(userCard); | 137 | userCards.add(userCard); |
| 140 | } | 138 | } |
| 141 | } | 139 | } |
cashier-pipeline/src/main/java/com/diligrp/cashier/pipeline/domain/card/UserCardDTO.java
| @@ -13,12 +13,12 @@ public class UserCardDTO { | @@ -13,12 +13,12 @@ public class UserCardDTO { | ||
| 13 | // 持卡人名称 | 13 | // 持卡人名称 |
| 14 | private String name; | 14 | private String name; |
| 15 | // 卡余额 | 15 | // 卡余额 |
| 16 | - private Long amount; | 16 | + private String amount; |
| 17 | 17 | ||
| 18 | public UserCardDTO() { | 18 | public UserCardDTO() { |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | - public UserCardDTO(Long customerId, Long accountId, String cardNo, String name, Long amount) { | 21 | + public UserCardDTO(Long customerId, Long accountId, String cardNo, String name, String amount) { |
| 22 | this.customerId = customerId; | 22 | this.customerId = customerId; |
| 23 | this.accountId = accountId; | 23 | this.accountId = accountId; |
| 24 | this.cardNo = cardNo; | 24 | this.cardNo = cardNo; |
| @@ -58,11 +58,11 @@ public class UserCardDTO { | @@ -58,11 +58,11 @@ public class UserCardDTO { | ||
| 58 | this.name = name; | 58 | this.name = name; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | - public Long getAmount() { | 61 | + public String getAmount() { |
| 62 | return amount; | 62 | return amount; |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | - public void setAmount(Long amount) { | 65 | + public void setAmount(String amount) { |
| 66 | this.amount = amount; | 66 | this.amount = amount; |
| 67 | } | 67 | } |
| 68 | } | 68 | } |
cashier-shared/src/main/java/com/diligrp/cashier/shared/util/CurrencyUtils.java
| @@ -98,10 +98,4 @@ public class CurrencyUtils { | @@ -98,10 +98,4 @@ public class CurrencyUtils { | ||
| 98 | currency.setCharAt(0, currencySymbol); | 98 | currency.setCharAt(0, currencySymbol); |
| 99 | currency.setCharAt(1, negativeSymbol); | 99 | currency.setCharAt(1, negativeSymbol); |
| 100 | } | 100 | } |
| 101 | - | ||
| 102 | - public static void main(String[] args) { | ||
| 103 | - System.out.println(toNoSymbolCurrency(-1L)); | ||
| 104 | - System.out.println(toCurrency(-1L)); | ||
| 105 | - System.out.println(cent2TenNoSymbol(-1L)); | ||
| 106 | - } | ||
| 107 | } | 101 | } |