增加系统参数配置相关接口,增加店铺订单支付链接获取接口

This commit is contained in:
谭凯凯
2024-09-27 15:55:49 +08:00
committed by Tankaikai
parent f739b3b1a6
commit 50a2773b5a

View File

@@ -31,7 +31,7 @@ import java.util.Map;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@Api(tags = "店铺支付相关接口") @Api(tags = "店铺支付相关接口")
@RequestMapping("/api/shop-pay-api") @RequestMapping(value = {"/api/shop-pay-api", "/api/shopPayApi"})
public class ShopPayApiController { public class ShopPayApiController {
private final ParamsService paramsService; private final ParamsService paramsService;
@@ -39,28 +39,28 @@ public class ShopPayApiController {
@GetMapping("getOrderPayUrl") @GetMapping("getOrderPayUrl")
@ApiOperation("获取店铺订单支付URL") @ApiOperation("获取店铺订单支付URL")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "orderId", value = "订单id", paramType = "query", required = true, dataType="String") , @ApiImplicitParam(name = "orderId", value = "订单id", paramType = "query", required = true, dataType = "String"),
@ApiImplicitParam(name = "shopId", value = "店铺id", paramType = "query",required = true, dataType="String") , @ApiImplicitParam(name = "shopId", value = "店铺id", paramType = "query", required = true, dataType = "String"),
}) })
public ResponseEntity url(@RequestParam Map<String, Object> params) { public ResponseEntity url(@RequestParam Map<String, Object> params) {
MapProxy mapProxy = MapProxy.create(params); MapProxy mapProxy = MapProxy.create(params);
String shopId = mapProxy.getStr("shopId"); String shopId = mapProxy.getStr("shopId");
String orderId = mapProxy.getStr("orderId"); String orderId = mapProxy.getStr("orderId");
try { try {
if(StrUtil.isBlank(shopId)){ if (StrUtil.isBlank(shopId)) {
throw new BadRequestException("店铺id不能为空"); throw new BadRequestException("店铺id不能为空");
} }
if(StrUtil.isBlank(orderId)){ if (StrUtil.isBlank(orderId)) {
throw new BadRequestException("订单id不能为空"); throw new BadRequestException("订单id不能为空");
} }
String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name()); String baseUrl = paramsService.getValue(ParamsEnum.SHOP_ORDER_PAY_BASE_URL.name());
String buildUrl = URLUtil.buildQuery(params, Charset.defaultCharset()); String buildUrl = URLUtil.buildQuery(params, Charset.defaultCharset());
String fullUrl = baseUrl.concat("?").concat(buildUrl); String fullUrl = baseUrl.concat("?").concat(buildUrl);
return ResponseEntity.ok().body(fullUrl); return ResponseEntity.ok().body(fullUrl);
}catch (BadRequestException e){ } catch (BadRequestException e) {
return ResponseEntity.badRequest().body(e.getMessage()); return ResponseEntity.badRequest().body(e.getMessage());
}catch (Exception e){ } catch (Exception e) {
log.error("获取店铺订单支付URL异常",e); log.error("获取店铺订单支付URL异常", e);
return ResponseEntity.ok().body("获取店铺订单支付URL异常"); return ResponseEntity.ok().body("获取店铺订单支付URL异常");
} }
} }