Commit 5e609a45e94634c0aee56184ce82a927b5181611

Authored by huanggang
1 parent 7587a56d

convert user card amount to yuan

cashier-pipeline/src/main/java/com/diligrp/cashier/pipeline/client/CardPaymentHttpClient.java
... ... @@ -11,6 +11,7 @@ import com.diligrp.cashier.pipeline.type.PaymentState;
11 11 import com.diligrp.cashier.shared.ErrorCode;
12 12 import com.diligrp.cashier.shared.service.ServiceEndpointSupport;
13 13 import com.diligrp.cashier.shared.type.SourceType;
  14 +import com.diligrp.cashier.shared.util.CurrencyUtils;
14 15 import com.diligrp.cashier.shared.util.JsonUtils;
15 16 import com.fasterxml.jackson.core.type.TypeReference;
16 17 import org.slf4j.Logger;
... ... @@ -69,8 +70,7 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport {
69 70 HttpResult result = send(uri, payload);
70 71 if (result.statusCode == 200) {
71 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 74 if ("200".equals(response.get("code"))) {
75 75 Map<String, Object> data = (Map<String, Object>) response.get("data");
76 76 String outTradeNo = (String) data.get("outTradeNo");
... ... @@ -101,8 +101,7 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport {
101 101 HttpResult result = send(uri, payload);
102 102 if (result.statusCode == 200) {
103 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 105 if ("200".equals(response.get("code"))) {
107 106 return new OnlineRefundResponse(request.getRefundId(), null, now,
108 107 PaymentState.SUCCESS, "园区卡退款成功");
... ... @@ -124,18 +123,17 @@ public class CardPaymentHttpClient extends ServiceEndpointSupport {
124 123 HttpResult result = send(uri, payload);
125 124 if (result.statusCode == 200) {
126 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 127 if ("200".equals(response.get("code"))) {
130 128 List<UserCardDTO> userCards = new ArrayList<>();
131 129 Object data = response.get("data");
132 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 132 for (Map<String, Object> card : cardList) {
  133 + String amount = CurrencyUtils.toNoSymbolCurrency(convertLong(card.get("amount")));
136 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 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 13 // 持卡人名称
14 14 private String name;
15 15 // 卡余额
16   - private Long amount;
  16 + private String amount;
17 17  
18 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 22 this.customerId = customerId;
23 23 this.accountId = accountId;
24 24 this.cardNo = cardNo;
... ... @@ -58,11 +58,11 @@ public class UserCardDTO {
58 58 this.name = name;
59 59 }
60 60  
61   - public Long getAmount() {
  61 + public String getAmount() {
62 62 return amount;
63 63 }
64 64  
65   - public void setAmount(Long amount) {
  65 + public void setAmount(String amount) {
66 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 98 currency.setCharAt(0, currencySymbol);
99 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 }
... ...