PackagePurchaseController.java 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package com.etotem.cfc.controller.guide;
  2. import javax.annotation.Resource;
  3. import com.etotem.cfc.common.Result;
  4. import com.etotem.cfc.dto.PackagePurchaseDTO;
  5. import com.etotem.cfc.entity.PackageOrder;
  6. import com.etotem.cfc.service.PackagePurchaseService;
  7. import io.swagger.v3.oas.annotations.Operation;
  8. import io.swagger.v3.oas.annotations.tags.Tag;
  9. import org.springframework.web.bind.annotation.*;
  10. import java.util.List;
  11. import java.util.Map;
  12. /**
  13. * 套餐购买控制器
  14. */
  15. @Tag(name = "套餐购买", description = "套餐购买、价格查询等接口")
  16. @RestController
  17. @RequestMapping("/api/package")
  18. public class PackagePurchaseController {
  19. @Resource
  20. private PackagePurchaseService packagePurchaseService;
  21. /**
  22. * 获取套餐价格
  23. */
  24. @Operation(summary = "获取套餐价格")
  25. @PostMapping("/price")
  26. public Result<Map<String, Object>> getPackagePrice(@RequestParam Long packageId,
  27. @RequestParam(required = false) Long guideId,
  28. @RequestParam(required = false) String inviteCode) {
  29. Map<String, Object> priceInfo = packagePurchaseService.getPackagePrice(packageId, guideId, inviteCode);
  30. if (priceInfo == null) {
  31. return Result.error("套餐不存在");
  32. }
  33. return Result.success(priceInfo);
  34. }
  35. /**
  36. * 获取可用的指导师列表
  37. */
  38. @Operation(summary = "获取可用的指导师列表")
  39. @PostMapping("/available-guides")
  40. public Result<List<Map<String, Object>>> getAvailableGuides(@RequestParam Long packageId) {
  41. List<Map<String, Object>> guides = packagePurchaseService.getAvailableGuides(packageId);
  42. return Result.success(guides);
  43. }
  44. /**
  45. * 创建套餐订单
  46. */
  47. @Operation(summary = "创建套餐订单")
  48. @PostMapping("/order/create")
  49. public Result<PackageOrder> createOrder(@RequestBody PackagePurchaseDTO dto) {
  50. PackageOrder order = packagePurchaseService.createOrder(dto);
  51. if (order == null) {
  52. return Result.error("创建订单失败");
  53. }
  54. return Result.success(order);
  55. }
  56. /**
  57. * 获取订单详情
  58. */
  59. @Operation(summary = "获取订单详情")
  60. @PostMapping("/order/{orderNo}")
  61. public Result<PackageOrder> getOrder(@PathVariable String orderNo) {
  62. PackageOrder order = packagePurchaseService.getOrder(orderNo);
  63. if (order == null) {
  64. return Result.error("订单不存在");
  65. }
  66. return Result.success(order);
  67. }
  68. }