mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
update huifu
This commit is contained in:
@@ -134,6 +134,54 @@ public class PayController extends BaseController {
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* adapay支付订单
|
||||
* http://localhost:8080/uniapp/pay/payOrderWithAdapay
|
||||
* @param request
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@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
|
||||
|
||||
@@ -211,6 +211,36 @@ public class OrderService {
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> payOrderWithAdapay(PayOrderDTO dto) {
|
||||
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(dto.getOrderCode());
|
||||
if (orderInfo == null) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_QUERY_ORDER_NULL_ERROR);
|
||||
}
|
||||
if (!StringUtils.equals(orderInfo.getPayStatus(), "0")) {
|
||||
// 订单已支付
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_ORDER_IS_NOT_TO_BE_PAID_ERROR);
|
||||
}
|
||||
Map<String, Object> resultMap = Maps.newHashMap();
|
||||
if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_BALANCE.getValue())) {
|
||||
// 余额支付
|
||||
balancePayOrder(dto);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue())) {
|
||||
// 微信支付 使用adapay
|
||||
dto.setOrderBasicInfo(orderInfo);
|
||||
Map<String, Object> weixinMap = adapayPayOrder(dto);
|
||||
// 返回微信支付参数
|
||||
resultMap.put("weixinMap", weixinMap);
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_ALIPAY.getValue())) { // 支付宝支付
|
||||
// TODO 返回支付宝支付参数
|
||||
} else if (StringUtils.equals(dto.getPayMode(), OrderPayModeEnum.PAYMENT_OF_WHITELIST.getValue())) { // 白名单支付
|
||||
// 白名单支付可以直接调支付回调方法
|
||||
dto.setPayAmount(new BigDecimal("500"));
|
||||
whiteListPayOrder(dto);
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 白名单支付订单逻辑
|
||||
* @param dto
|
||||
@@ -1210,4 +1240,5 @@ public class OrderService {
|
||||
.list(volist)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user