mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
汇付支付订单
This commit is contained in:
@@ -84,15 +84,14 @@ public class PayController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 会员充值余额
|
||||
* 会员充值余额 汇付
|
||||
* http://localhost:8080/uniapp/pay/rechargeBalance
|
||||
*/
|
||||
@PostMapping("/rechargeBalance")
|
||||
public RestApiResponse<?> rechargeBalance(HttpServletRequest request, @RequestBody WeixinPayDTO dto) {
|
||||
logger.info("微信支付 param:{}", dto.toString());
|
||||
logger.info("adapay会员充值余额 param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
try {
|
||||
if (StringUtils.isBlank(dto.getCode()) || StringUtils.isBlank(dto.getAmount())) {
|
||||
@@ -168,6 +167,47 @@ public class PayController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
@PostMapping("/payOrderWithAdapay")
|
||||
public RestApiResponse<?> payOrderWithAdapay(HttpServletRequest request, @RequestBody PayOrderDTO dto) {
|
||||
logger.info("adapay支付订单 param:{}", dto.toString());
|
||||
RestApiResponse<?> response;
|
||||
|
||||
// 支付订单加锁
|
||||
String lockKey = "pay_order_" + dto.getOrderCode();
|
||||
String lockValue = IdUtils.fastUUID();
|
||||
try {
|
||||
String memberId = getMemberIdByAuthorization(request);
|
||||
if (StringUtils.isBlank(memberId)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
}
|
||||
if (dto.getPayAmount() == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
|
||||
}
|
||||
dto.setMemberId(memberId);
|
||||
dto.setLockValue(lockValue);
|
||||
// redis锁
|
||||
Boolean isLock = redisCache.lock(lockKey, lockValue, 60);
|
||||
Map<String, Object> map = null;
|
||||
if (isLock) {
|
||||
map = orderService.payOrderWithAdapay(dto);
|
||||
}
|
||||
response = new RestApiResponse<>(map);
|
||||
} catch (BusinessException e) {
|
||||
logger.warn("adapay支付订单 warn param:{}", dto.toString(), e);
|
||||
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||
} catch (Exception e) {
|
||||
logger.error("adapay支付订单 error param:{}", dto.toString(), e);
|
||||
response = new RestApiResponse<>(ReturnCodeEnum.CODE_ORDER_PAY_ERROR);
|
||||
} finally {
|
||||
// 支付订单解锁
|
||||
if (lockValue.equals(redisCache.getCacheObject(lockKey).toString())) {
|
||||
redisCache.unLock(lockKey);
|
||||
}
|
||||
}
|
||||
logger.info("adapay支付订单 result:{}", JSONObject.toJSONString(response));
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 7003 获取支付方式
|
||||
* http://localhost:8080/uniapp/pay/getPayMode
|
||||
|
||||
@@ -158,12 +158,7 @@ public class OrderService {
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
|
||||
// 微信支付
|
||||
dto.setOrderBasicInfo(orderInfo);
|
||||
Map<String, Object> weixinMap = null;
|
||||
if (stationIdList.contains("all") || stationIdList.contains(orderInfo.getStationId())) {
|
||||
weixinMap = adapayPayOrder(dto);
|
||||
} else {
|
||||
weixinMap = wechatPayOrder(dto);
|
||||
}
|
||||
Map<String, Object> weixinMap = wechatPayOrder(dto);
|
||||
// 返回微信支付参数
|
||||
resultMap.put("weixinMap", weixinMap);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_ALIPAY.getValue())) { // 支付宝支付
|
||||
@@ -176,7 +171,11 @@ public class OrderService {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 使用adapay支付订单
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> payOrderWithAdapay(PayOrderDTO dto) {
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderInfo == null) {
|
||||
|
||||
Reference in New Issue
Block a user