|
@@ -103,7 +103,7 @@ public class MiPayService extends PayBaseService {
|
|
|
payParamMap.put("zoneId", "1");
|
|
|
payParamMap.put("offerId", config.getOfferId());
|
|
|
payParamMap.put("env", String.valueOf(this.isSand));
|
|
|
- payParamMap.put("buyQuantity", orderInfo.getAmount().intValue());
|
|
|
+ payParamMap.put("buyQuantity", this.getOrderAmount(orderInfo.getAmount()));
|
|
|
payParamMap.put("status", "1");
|
|
|
payParamMap.put("balance", String.valueOf(balance));
|
|
|
payParamMap.put("orderId", product.getOutTradeNo());
|
|
@@ -143,7 +143,7 @@ public class MiPayService extends PayBaseService {
|
|
|
return Long.valueOf(resultMap.get("balance"));
|
|
|
}
|
|
|
|
|
|
- private Tuple2<Long, String> midasPay(String openId, String sessionKey, BigDecimal amount, String orderId) {
|
|
|
+ private Tuple2<Long, String> midasPay(String openId, String sessionKey, long amount, String orderId) {
|
|
|
|
|
|
Map<String, Object> postBodyMap = new HashMap<>(7);
|
|
|
postBodyMap.put("openid", openId);
|
|
@@ -151,7 +151,7 @@ public class MiPayService extends PayBaseService {
|
|
|
postBodyMap.put("ts", System.currentTimeMillis() / 1000);
|
|
|
postBodyMap.put("zone_id", "1");
|
|
|
postBodyMap.put("env", this.isSand);
|
|
|
- postBodyMap.put("amount", amount.intValue());
|
|
|
+ postBodyMap.put("amount", amount);
|
|
|
postBodyMap.put("bill_no", orderId);
|
|
|
String postBody = JsonUtil.toString(postBodyMap);
|
|
|
|
|
@@ -210,6 +210,7 @@ public class MiPayService extends PayBaseService {
|
|
|
.offerId(miPayConfigBean.getAppId())
|
|
|
.appKey(miPayConfigBean.getAppKey())
|
|
|
.appKeyDev(miPayConfigBean.getAppKeyDev())
|
|
|
+ .scale(miPayConfigBean.getScale())
|
|
|
.build();
|
|
|
}
|
|
|
|
|
@@ -254,17 +255,19 @@ public class MiPayService extends PayBaseService {
|
|
|
this.configInit(platformOrderDTO.getGameId());
|
|
|
|
|
|
UserDTO userDTO = userService.getUserByUserId(platformOrderDTO.getUserId());
|
|
|
- String openId = userDTO.getOpenId();
|
|
|
String sessionKey = userDTO.getSessionKey();
|
|
|
+ String openId = userDTO.getOpenId();
|
|
|
|
|
|
Long balance = this.midasGetBalance(openId, sessionKey);
|
|
|
+
|
|
|
+ long orderAmount = this.getOrderAmount(platformOrderDTO.getAmount());
|
|
|
|
|
|
- if (balance < platformOrderDTO.getAmount().longValue()) {
|
|
|
+ if (balance < orderAmount) {
|
|
|
log.error("米大师游戏币不足, 无法扣除! balance : {}, orderId : {}", balance, orderId);
|
|
|
throw new BaseException("米大师游戏币不足, 无法扣除!");
|
|
|
}
|
|
|
|
|
|
- Tuple2<Long, String> tuple2 = this.midasPay(openId, sessionKey, platformOrderDTO.getAmount(), platformOrderDTO.getOrderId());
|
|
|
+ Tuple2<Long, String> tuple2 = this.midasPay(openId, sessionKey, orderAmount, platformOrderDTO.getOrderId());
|
|
|
|
|
|
this.paySuccess(platformOrderDTO.getOrderId(), platformOrderDTO.getAmount().toString(), tuple2.getT2());
|
|
|
|
|
@@ -292,13 +295,15 @@ public class MiPayService extends PayBaseService {
|
|
|
String sessionKey = userDTO.getSessionKey();
|
|
|
|
|
|
Long balance = this.midasGetBalance(openId, sessionKey);
|
|
|
+
|
|
|
+ long orderAmount = this.getOrderAmount(platformOrderDTO.getAmount());
|
|
|
|
|
|
- if (balance < platformOrderDTO.getAmount().longValue()) {
|
|
|
+ if (balance < orderAmount) {
|
|
|
log.error("米大师游戏币不足, 无法扣除! balance : {}, orderId : {}", balance, orderId);
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
|
|
|
- Tuple2<Long, String> tuple2 = this.midasPay(openId, sessionKey, platformOrderDTO.getAmount(), platformOrderDTO.getOrderId());
|
|
|
+ Tuple2<Long, String> tuple2 = this.midasPay(openId, sessionKey, orderAmount, platformOrderDTO.getOrderId());
|
|
|
log.error("米大师余额扣除返回, orderId : {}, tuple2 : {}", orderId, JsonUtil.toString(tuple2));
|
|
|
|
|
|
this.miPaySuccess(platformOrderDTO.getOrderId(), platformOrderDTO.getAmount().toString(), weChatPayInfoTuple2);
|
|
@@ -339,4 +344,9 @@ public class MiPayService extends PayBaseService {
|
|
|
.set(Order::getUpdateTime, LocalDateTime.now())
|
|
|
.eq(Order::getOrderId, orderId));
|
|
|
}
|
|
|
+
|
|
|
+ private long getOrderAmount(BigDecimal amount) {
|
|
|
+ int scale = this.config.getScale() == null ? 1 : this.config.getScale();
|
|
|
+ return amount.longValue() * scale;
|
|
|
+ }
|
|
|
}
|