From bc8bc25d9cc04168d52e3110d12e9c36b9e0cd27 Mon Sep 17 00:00:00 2001
From: goupan <goupan@chinapopin.com>
Date: 星期五, 26 四月 2024 16:27:57 +0800
Subject: [PATCH] 代码提交

---
 rest/src/main/java/cn/stylefeng/rest/modular/order/controller/MentalTestOrderController.java                 |   23 +++++++----------------
 common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/OrderMentalTestServiceImpl.java |   13 +++++++++++++
 common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestTopicDTO.java            |    8 ++++++--
 common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestOrderDTO.java            |    2 +-
 4 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestOrderDTO.java b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestOrderDTO.java
index 90f863c..c529dd6 100644
--- a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestOrderDTO.java
+++ b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestOrderDTO.java
@@ -54,7 +54,7 @@
 
     @ApiModelProperty(value = "是否购买")
     @ChineseDescription("是否购买")
-    private boolean payFlag;
+    private Boolean payFlag;
 
     @ApiModelProperty(value = "测试人数")
     @ChineseDescription("测试人数")
diff --git a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestTopicDTO.java b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestTopicDTO.java
index 8a9e124..9e24d47 100644
--- a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestTopicDTO.java
+++ b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/dto/MentalTestMyTestTopicDTO.java
@@ -12,6 +12,10 @@
 @ApiModel(value = "我的测试-响应参数")
 public class MentalTestMyTestTopicDTO extends MentalTestRecord {
 
+    @ApiModelProperty(value = "题库ID")
+    @ChineseDescription("题库ID")
+    private Long topicId;
+
     @ApiModelProperty(value = "状态:1正常,2冻结")
     @ChineseDescription("状态:1正常,2冻结")
     private Integer topicStatus;
@@ -54,11 +58,11 @@
 
     @ApiModelProperty(value = "是否测试")
     @ChineseDescription("是否测试")
-    private boolean testFlag;
+    private Boolean testFlag;
 
     @ApiModelProperty(value = "是否购买")
     @ChineseDescription("是否购买")
-    private boolean payFlag;
+    private Boolean payFlag;
 
     @ApiModelProperty(value = "测试人数")
     @ChineseDescription("测试人数")
diff --git a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/OrderMentalTestServiceImpl.java b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/OrderMentalTestServiceImpl.java
index 662c215..1fe17ab 100644
--- a/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/OrderMentalTestServiceImpl.java
+++ b/common-buiness/src/main/java/cn/stylefeng/guns/modular/business/service/impl/OrderMentalTestServiceImpl.java
@@ -73,6 +73,19 @@
 
     @Override
     public OrderMentalTest createOrderMentalTest(Long userId, Long topicId, Boolean isNeedPay, Boolean isBack) {
+        // 获取用户已支付订单(以后每次都只有1个订单号)
+        OrderMentalTest doneOrder = this.baseMapper.selectOne(
+                Wrappers.<OrderMentalTest>lambdaQuery()
+                        .eq(OrderMentalTest::getUserId, userId)
+                        .eq(OrderMentalTest::getGoodsId, topicId)
+                        .eq(OrderMentalTest::getStatusFlag, OrderStatusFlagEnum.PAY_SUCCESS.getCode())
+                        .orderByDesc(OrderMentalTest::getCreateTime)
+                        .last("LIMIT 1")
+        );
+        if (doneOrder != null) {
+            return doneOrder;
+        }
+
         // 题库信息
         MentalTestTopic topic = mentalTestTopicService.getById(topicId);
         Assert.notNull(topic, "题库不存在");
diff --git a/rest/src/main/java/cn/stylefeng/rest/modular/order/controller/MentalTestOrderController.java b/rest/src/main/java/cn/stylefeng/rest/modular/order/controller/MentalTestOrderController.java
index d824503..f1ccc50 100644
--- a/rest/src/main/java/cn/stylefeng/rest/modular/order/controller/MentalTestOrderController.java
+++ b/rest/src/main/java/cn/stylefeng/rest/modular/order/controller/MentalTestOrderController.java
@@ -1,17 +1,15 @@
 package cn.stylefeng.rest.modular.order.controller;
 
-import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.lang.Assert;
 import cn.hutool.core.util.StrUtil;
 import cn.stylefeng.guns.modular.business.dto.request.CreateOrderConsultOneRequest;
 import cn.stylefeng.guns.modular.business.dto.request.CreateOrderMentalTestRequest;
-import cn.stylefeng.guns.modular.business.entity.*;
+import cn.stylefeng.guns.modular.business.entity.MentalAnalysisTime;
+import cn.stylefeng.guns.modular.business.entity.MentalAppointment;
+import cn.stylefeng.guns.modular.business.entity.OrderConsultOne;
+import cn.stylefeng.guns.modular.business.entity.OrderMentalTest;
 import cn.stylefeng.guns.modular.business.service.*;
 import cn.stylefeng.rest.modular.order.service.MentalTestOrderBizService;
-import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
-import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
-import cn.stylefeng.roses.kernel.customer.modular.entity.Customer;
-import cn.stylefeng.roses.kernel.customer.modular.service.CustomerService;
 import cn.stylefeng.roses.kernel.rule.pojo.request.BaseIdRequest;
 import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
 import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
@@ -27,11 +25,7 @@
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
-import java.util.stream.Collectors;
 
 @Slf4j
 @Api(tags = "心理测试接口")
@@ -55,15 +49,15 @@
     @Resource
     private IMentalAnalysisTimeService mentalAnalysisTimeService;
 
+    @Resource
+    private IMentalAnalysisTimeConfigService mentalAnalysisTimeConfigService;
+
     @ApiOperation(value = "心理测试下单", notes = "订单状态,为0需支付(为1无需支付),开始心理测试答题")
     @PostResource(name = "心理测试下单", path = "/createOrderMentalTest")
     public ResponseData<OrderMentalTest> createOrderMentalTest(@RequestBody CreateOrderMentalTestRequest req) {
         OrderMentalTest o = orderMentalTestService.createOrderMentalTest(req.getUserId(), req.getTopicId(), true, false);
         return new SuccessResponseData(o);
     }
-
-    @Resource
-    private IMentalAnalysisTimeConfigService mentalAnalysisTimeConfigService;
 
     @ApiOperation(value = "1V1咨询可预约时间")
     @GetResource(name = "1V1咨询可预约时间", path = "/mentalAnalysisTime")
@@ -88,9 +82,6 @@
 //            return new SuccessResponseData(values);
 //        }
     }
-
-    @Resource
-    private CustomerService customerService;
 
     @ApiOperation(value = "1V1咨询预约性格分析下单")
     @PostResource(name = "1V1咨询预约性格分析下单", path = "/createOrderConsultOne")

--
Gitblit v1.7.1