guohongjin
2024-05-01 1901fceb6ddaa56a57f3131191454554c3e77e68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package cn.stylefeng.rest.modular.order.controller;
 
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.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.IMentalAnalysisTimeService;
import cn.stylefeng.guns.modular.business.service.IMentalAppointmentService;
import cn.stylefeng.guns.modular.business.service.IOrderConsultOneService;
import cn.stylefeng.guns.modular.business.service.IOrderMentalTestService;
import cn.stylefeng.rest.modular.order.service.MentalTestOrderBizService;
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;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
import java.util.List;
 
@Slf4j
@Api(tags = "心理测试接口")
@RestController
@ApiResource(name = "心理测试接口")
@RequestMapping("/mentalTest")
public class MentalTestOrderController {
 
    @Resource
    private IOrderMentalTestService orderMentalTestService;
 
    @Resource
    private IOrderConsultOneService orderConsultOneService;
 
    @Resource
    private IMentalAppointmentService mentalAppointmentService;
 
    @Resource
    private MentalTestOrderBizService mentalTestOrderBizService;
 
    @Resource
    private IMentalAnalysisTimeService mentalAnalysisTimeService;
 
    @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);
    }
 
    @ApiOperation(value = "心理测试订单详情")
    @PostResource(name = "心理测试订单详情", path = "/orderMentalTestDetail")
    public ResponseData<OrderMentalTest> orderMentalTestDetail(Long id, String orderNo) {
        OrderMentalTest o = orderMentalTestService.getOne(
                Wrappers.<OrderMentalTest>lambdaQuery()
                        .eq(id != null, OrderMentalTest::getId, id)
                        .eq(StrUtil.isNotEmpty(orderNo), OrderMentalTest::getOrderNo, orderNo)
        );
        return new SuccessResponseData(o);
    }
 
    @ApiOperation(value = "1V1咨询可预约时间")
    @GetResource(name = "1V1咨询可预约时间", path = "/mentalAnalysisTime")
    public ResponseData<List<MentalAnalysisTime>> mentalAnalysisTime() {
//        List<Customer> filteredCustomers = customerService.list(Wrappers.lambdaQuery(Customer.class).eq(Customer::getMentalAnalysisStatus,1)
//                .like(Customer::getPostIds, "31"));
 
//        if (filteredCustomers.isEmpty()) {
            List<MentalAnalysisTime> list = mentalAnalysisTimeService.list(
                    Wrappers.<MentalAnalysisTime>lambdaQuery()
                            .orderByAsc(MentalAnalysisTime::getModuleNo, MentalAnalysisTime::getWeekDay, MentalAnalysisTime::getBeginTimePoint, MentalAnalysisTime::getEndTimePoint)
            );
            return new SuccessResponseData(list);
//        }else {
//            List<Long> collect = filteredCustomers.stream().map(Customer::getCustomerId).collect(Collectors.toList());
//            List<MentalAnalysisTimeConfig> list = mentalAnalysisTimeConfigService.list(Wrappers.lambdaQuery(MentalAnalysisTimeConfig.class).in(MentalAnalysisTimeConfig::getCounsellingInfoId, collect));
//            HashMap<String,MentalAnalysisTimeConfig> hashMap =new HashMap<>();
//            for (MentalAnalysisTimeConfig mentalAnalysisTimeConfig : list) {
//                hashMap.put(mentalAnalysisTimeConfig.getWeekDay()+mentalAnalysisTimeConfig.getBeginTimePoint()+mentalAnalysisTimeConfig.getEndTimePoint(),mentalAnalysisTimeConfig);
//            }
//            Collection<MentalAnalysisTimeConfig> values = hashMap.values();
//            return new SuccessResponseData(values);
//        }
    }
 
    @ApiOperation(value = "1V1咨询预约性格分析下单")
    @PostResource(name = "1V1咨询预约性格分析下单", path = "/createOrderConsultOne")
    public synchronized ResponseData<OrderConsultOne> createOrderConsultOne(@RequestBody CreateOrderConsultOneRequest req) {
        Assert.isTrue(StrUtil.isNotBlank(req.getRealName()), "姓名不能为空");
        Assert.isTrue(StrUtil.isNotBlank(req.getLinkPhone()), "联系电话不能为空");
        OrderConsultOne o = mentalTestOrderBizService.createOrderConsultOne(req);
        return new SuccessResponseData(o);
    }
 
    @ApiOperation(value = "1V1咨询预约(ID)取消")
    @PostResource(name = "1V1咨询预约(ID)取消", path = "/mentalAppointmentCancel")
    public ResponseData<OrderConsultOne> mentalAppointmentCancel(@RequestBody BaseIdRequest req) {
        boolean o = mentalAppointmentService.mentalAppointmentCancel(req.getId());
        return new SuccessResponseData(o);
    }
 
    @ApiOperation(value = "1V1咨询订单详情")
    @GetResource(name = "1V1咨询订单详情", path = "/orderConsultOneDetail")
    public ResponseData<OrderConsultOne> orderConsultOneDetail(Long id) {
        OrderConsultOne o = orderConsultOneService.getById(id);
        return new SuccessResponseData(o);
    }
 
    @ApiOperation(value = "1V1咨询预约详情")
    @GetResource(name = "1V1咨询预约详情", path = "/mentalAppointmentDetail")
    public ResponseData<MentalAppointment> mentalAppointmentDetail(Long id) {
        MentalAppointment o = mentalAppointmentService.getById(id);
        return new SuccessResponseData(o);
    }
 
}