|
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -71,39 +72,6 @@ public class MiPayService extends PayBaseService {
|
|
|
*/
|
|
|
private MiPayConfigDTO config;
|
|
|
|
|
|
- public Map<String, Object> paySynNotify(String orderId) {
|
|
|
-
|
|
|
- log.error("米大师支付回调 orderId : {}", orderId);
|
|
|
-
|
|
|
- //查询订单
|
|
|
- PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(orderId);
|
|
|
- if (platformOrderDTO == null) {
|
|
|
- log.error("参数错误, 订单信息不存在! orderId : {}", orderId);
|
|
|
- throw new BaseException("参数错误, 订单信息不存在");
|
|
|
- }
|
|
|
- this.configInit(platformOrderDTO.getGameId());
|
|
|
- //获取用户openId
|
|
|
- UserDTO userDTO = userService.getUserByUserId(platformOrderDTO.getUserId());
|
|
|
- String openId = userDTO.getOpenId();
|
|
|
- String sessionKey = userDTO.getSessionKey();
|
|
|
- //获取米大师钱包余额
|
|
|
- Long balance = this.midasGetBalance(openId, sessionKey);
|
|
|
- //余额不足, 无法扣除
|
|
|
- if (balance < platformOrderDTO.getAmount().longValue()) {
|
|
|
- log.error("米大师游戏币不足, 无法扣除! balance : {}, orderId : {}", balance, orderId);
|
|
|
- throw new BaseException("米大师游戏币不足, 无法扣除!");
|
|
|
- }
|
|
|
- //余额充足, 直接扣除
|
|
|
- String billNo = this.midasPay(openId, sessionKey, platformOrderDTO.getAmount(), platformOrderDTO.getOrderId());
|
|
|
- //支付成功
|
|
|
- this.paySuccess(platformOrderDTO.getOrderId(), platformOrderDTO.getAmount().toString(), config.getAppId());
|
|
|
- //返回参数
|
|
|
- Map<String, Object> payParamMap = new HashMap<>(2);
|
|
|
- payParamMap.put("status", "0");
|
|
|
- payParamMap.put("billNo", billNo);
|
|
|
- return payParamMap;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Map<String, Object> create(ProductPayParamBO product, GamePayWayDTO gamePayWayDTO) {
|
|
|
//查询订单
|
|
@@ -272,13 +240,49 @@ public class MiPayService extends PayBaseService {
|
|
|
return hexString.toString();
|
|
|
}
|
|
|
|
|
|
+ public Map<String, Object> notify(String orderId) {
|
|
|
+ log.error("米大师支付回调 orderId : {}", orderId);
|
|
|
+ //查询订单
|
|
|
+ PlatformOrderDTO platformOrderDTO = orderService.getByOrderId(orderId);
|
|
|
+ if (platformOrderDTO == null) {
|
|
|
+ log.error("参数错误, 订单信息不存在! orderId : {}", orderId);
|
|
|
+ throw new BaseException("参数错误, 订单信息不存在");
|
|
|
+ }
|
|
|
+ this.configInit(platformOrderDTO.getGameId());
|
|
|
+ //获取用户openId
|
|
|
+ UserDTO userDTO = userService.getUserByUserId(platformOrderDTO.getUserId());
|
|
|
+ String openId = userDTO.getOpenId();
|
|
|
+ String sessionKey = userDTO.getSessionKey();
|
|
|
+ //获取米大师钱包余额
|
|
|
+ Long balance = this.midasGetBalance(openId, sessionKey);
|
|
|
+ //余额不足, 无法扣除
|
|
|
+ if (balance < platformOrderDTO.getAmount().longValue()) {
|
|
|
+ log.error("米大师游戏币不足, 无法扣除! balance : {}, orderId : {}", balance, orderId);
|
|
|
+ throw new BaseException("米大师游戏币不足, 无法扣除!");
|
|
|
+ }
|
|
|
+ //余额充足, 直接扣除
|
|
|
+ String billNo = this.midasPay(openId, sessionKey, platformOrderDTO.getAmount(), platformOrderDTO.getOrderId());
|
|
|
+ //支付成功
|
|
|
+ this.paySuccess(platformOrderDTO.getOrderId(), platformOrderDTO.getAmount().toString(), config.getAppId());
|
|
|
+ //返回参数
|
|
|
+ Map<String, Object> payParamMap = new HashMap<>(2);
|
|
|
+ payParamMap.put("status", "0");
|
|
|
+ payParamMap.put("billNo", billNo);
|
|
|
+ return payParamMap;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public String notify(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- throw new BaseException("米大师支付不存在异步回调");
|
|
|
+ throw new BaseException("米大师支付不存在通用异步回调");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void closeOrder(PlatformOrderDTO platformOrderDTO) {
|
|
|
- log.error("米大师支付不存在取消订单");
|
|
|
+ String orderId = platformOrderDTO.getOrderId();
|
|
|
+ log.error("米大师超时未支付, 订单取消, orderId : {}", orderId);
|
|
|
+ orderService.update(new LambdaUpdateWrapper<Order>()
|
|
|
+ .set(Order::getStatus, OrderStateEnum.CANCEL_PAY.getCode())
|
|
|
+ .set(Order::getUpdateTime, LocalDateTime.now())
|
|
|
+ .eq(Order::getOrderId, orderId));
|
|
|
}
|
|
|
}
|