mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-13 14:30:08 +08:00
支付占桩订单
This commit is contained in:
@@ -312,4 +312,48 @@ public class PayController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付占桩订单
|
||||||
|
*/
|
||||||
|
@PostMapping("/payOccupyPileOrder")
|
||||||
|
public RestApiResponse<?> payOccupyPileOrder(HttpServletRequest request, @RequestBody PayOrderDTO dto) {
|
||||||
|
logger.info("wechatpay支付订单 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.payOrder(dto);
|
||||||
|
}
|
||||||
|
response = new RestApiResponse<>(map);
|
||||||
|
} catch (BusinessException e) {
|
||||||
|
logger.warn("wechatpay支付订单 warn param:{}", dto.toString(), e);
|
||||||
|
response = new RestApiResponse<>(e.getCode(), e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("wechatpay支付订单 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("wechatpay支付订单 result:{}", JSONObject.toJSONString(response));
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,11 @@ public interface OrderPileOccupyService{
|
|||||||
*/
|
*/
|
||||||
void generateOccupyPileOrder(String memberId, String pileSn, String connectorCode);
|
void generateOccupyPileOrder(String memberId, String pileSn, String connectorCode);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止并计算占桩订单
|
||||||
|
* @param pileSn
|
||||||
|
* @param connectorCode
|
||||||
|
*/
|
||||||
void stopOccupyPileOrder(String pileSn, String connectorCode);
|
void stopOccupyPileOrder(String pileSn, String connectorCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user