puzhibing
2023-06-14 9144acea1ad8f6222ca2db17cf8ef7ffb18e7428
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
package com.dsh.account.service.impl;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.account.feignclient.course.CoursePaymentClient;
import com.dsh.account.feignclient.course.model.StuCourseResp;
import com.dsh.account.feignclient.course.model.TCoursePackagePayment;
import com.dsh.account.mapper.TStudentMapper;
import com.dsh.account.feignclient.other.ImgConfigClient;
import com.dsh.account.feignclient.other.model.TImgConfig;
import com.dsh.account.model.vo.classDetails.RegisteredCourse;
import com.dsh.account.service.TAppUserService;
import com.dsh.account.entity.TAppUser;
import com.dsh.account.entity.TStudent;
import com.dsh.account.mapper.TAppUserMapper;
import com.dsh.account.model.vo.classDetails.classInsVo.ClassInfoVo;
 
import com.dsh.account.util.DateUtil;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dsh.account.util.ResultUtil;
import com.dsh.account.util.ToolUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
 
/**
 * <p>
 * 用户信息 服务实现类
 * </p>
 *
 * @author administrator
 * @since 2023-06-14
 */
@Service
public class TAppUserServiceImpl extends ServiceImpl<TAppUserMapper, TAppUser> implements TAppUserService {
 
 
    @Autowired
    private TStudentMapper tsmapper;
 
    @Resource
    private ImgConfigClient configClient;
 
    @Resource
    private CoursePaymentClient paymentClient;
    @Override
    public ClassInfoVo queryUserOfStus(Integer id,String longitude,String latitude) {
        TAppUser tAppUser = this.baseMapper.selectById(id);
        if (ToolUtil.isNotEmpty(tAppUser)){
            List<TStudent> tStudents = tsmapper.selectList(new QueryWrapper<TStudent>()
                    .eq("appUserId",tAppUser.getId())
                    .eq("state",1)
                    .eq("isDefault",1));
            ClassInfoVo classInfoVo = new ClassInfoVo();
            if (tStudents.size() > 0 ){
                TStudent tStudent = tStudents.get(0);
                classInfoVo.setIsThere(1);
                classInfoVo.setStuImg(tStudent.getHeadImg());
                classInfoVo.setStuSex(tStudent.getSex());
                classInfoVo.setStuAge(DateUtil.age(tStudent.getBirthday()));
                classInfoVo.setStuName(tStudent.getName());
                classInfoVo.setHeight(tStudent.getHeight());
                classInfoVo.setWeight(tStudent.getWeight());
                classInfoVo.setBmi(tStudent.getBmi());
 
                List<RegisteredCourse> courseList = new ArrayList<>();
//                总学时数
                int total = 0;
//                已扣数
                int deduct = 0;
//                剩余数
                int remain = 0;
                List<StuCourseResp> stuCoursePayment = paymentClient.getStuCoursePayment();
                if (stuCoursePayment.size() > 0){
                    for (StuCourseResp tCoursePackagePayment : stuCoursePayment) {
                        RegisteredCourse course = new RegisteredCourse();
                        course.setCourseId(tCoursePackagePayment.getCourseId());
                        course.setCourseName(tCoursePackagePayment.getCourseName());
                        total = total + (ToolUtil.isEmpty(tCoursePackagePayment.getTotalCourseNums()) ? 0 : tCoursePackagePayment.getTotalCourseNums());
                        deduct = deduct + (ToolUtil.isEmpty(tCoursePackagePayment.getDeductionNums()) ? 0 : tCoursePackagePayment.getDeductionNums());
                        remain = remain + (ToolUtil.isEmpty(tCoursePackagePayment.getResidueNums())? 0 : tCoursePackagePayment.getResidueNums());
                        courseList.add(course);
                    }
                }
                classInfoVo.setCourseList(courseList);
 
                classInfoVo.setTotalNums(total);
                classInfoVo.setDeductedNums(deduct);
                classInfoVo.setRemainingNums(remain);
 
 
//                classInfoVo.setWeekCourseList();
            }else {
                classInfoVo.setIsThere(2);
                List<TImgConfig> tImgConfigs = configClient.getNoneStuImgs();
                if (tImgConfigs.size() > 0){
                    classInfoVo.setImgs(tImgConfigs.get(0).getContent());
                }
            }
        }
        return null;
    }
 
 
 
    /**
     * 获取短信验证码
     * @param type 1:登录,2:注册,3:修改密码,4:忘记密码
     * @param phone
     * @return
     * @throws Exception
     */
    @Override
    public ResultUtil getSMSCode(Integer type, String phone) throws Exception {
        if(type == 2){
//            this.baseMapper.selectOne(new EntityWrapper<>())
        }
        return null;
    }
}