lisy
2023-07-21 c37acfa5fd70c1d658295f5635b630d3beef7ce0
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
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.entity.Coach;
import com.dsh.account.entity.TAppUser;
import com.dsh.account.entity.TStudent;
import com.dsh.account.feignclient.activity.IntroduceRewardsClient;
import com.dsh.account.feignclient.activity.UserConponClient;
import com.dsh.account.feignclient.activity.model.IntrduceOfUserRequest;
import com.dsh.account.feignclient.competition.DeductionCompetitionsClient;
import com.dsh.account.feignclient.competition.ParticipantClient;
import com.dsh.account.feignclient.competition.model.GetStuSourseList;
import com.dsh.account.feignclient.competition.model.PurchaseRecordVo;
import com.dsh.account.feignclient.competition.model.SaveParticipant;
import com.dsh.account.feignclient.course.*;
import com.dsh.account.feignclient.course.model.*;
import com.dsh.account.feignclient.other.NoticeClient;
import com.dsh.account.feignclient.other.QuestionClient;
import com.dsh.account.feignclient.other.SiteClient;
import com.dsh.account.feignclient.other.StoreClient;
import com.dsh.account.feignclient.other.model.*;
import com.dsh.account.mapper.CoachMapper;
import com.dsh.account.mapper.TAppUserMapper;
import com.dsh.account.mapper.TStudentMapper;
import com.dsh.account.model.vo.classDetails.AppointmentRecordVo;
import com.dsh.account.model.vo.classDetails.ClasspaymentRequest;
import com.dsh.account.model.vo.classDetails.classInsVo.ClassDetailsInsVo;
import com.dsh.account.model.vo.classDetails.classInsVo.StuDetailsReq;
import com.dsh.account.model.vo.classDetails.classInsVo.StuListVo;
import com.dsh.account.model.vo.exploreDetail.LonLatRequest;
import com.dsh.account.model.vo.exploreDetail.QuestionIns;
import com.dsh.account.model.vo.exploreDetail.StoreDetailsVo;
import com.dsh.account.model.vo.sourceDetail.CouponStuAvailableVo;
import com.dsh.account.model.vo.sourceDetail.CourseDetailsOfContinuationResp;
import com.dsh.account.model.vo.sourceDetail.RecordTimeRequest;
import com.dsh.account.service.TStudentService;
import com.dsh.account.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 学员信息 服务实现类
 * </p>
 *
 * @author administrator
 * @since 2023-06-14
 */
@Service
public class TStudentServiceImpl extends ServiceImpl<TStudentMapper, TStudent> implements TStudentService {
 
    @Resource
    private CourseSessionNameClient sessionNameClient;
 
    @Resource
    private DeductionCompetitionsClient dcttClient;
 
    @Resource
    private CancelListClient cancelcClient;
 
    @Resource
    private IntroduceRewardsClient idrClient;
 
    @Resource
    private CourseRecordClient crClient;
 
    @Resource
    private CoursePaymentClient couPayClient;
 
    @Resource
    private UserConponClient userCClient;
 
    @Resource
    private StoreClient storeClient;
 
    @Resource
    private NoticeClient noClient;
 
    @Resource
    private QuestionClient quesClient;
 
    @Resource
    private TAppUserMapper tauMapper;
 
    @Resource
    private CoachMapper coachMapper;
 
    @Resource
    private ParticipantClient participantClient;
 
 
    @Autowired
    private PayMoneyUtil payMoneyUtil;
 
 
    @Resource
    private SiteClient steClient;
 
    @Resource
    private CourseListClient culisClient;
 
 
 
    @Override
    public ResultUtil addStuOfAppUser(StuDetailsReq stu,Integer appUserId) throws Exception {
        TStudent student = new TStudent();
        if(ToolUtil.isNotEmpty(stu.getName()) && ToolUtil.isNotEmpty(stu.getIdCard())){
            Boolean aBoolean = JuHeUtil.idcardAuthentication(stu.getIdCard(), stu.getName());
            if(!aBoolean){
                return ResultUtil.error("身份证和姓名不匹配");
            }
        }
        student.setAppUserId(appUserId);
        student.setName(stu.getName());
        student.setHeadImg(stu.getHeadImg());
        student.setPhone(ToolUtil.isNotEmpty(stu.getPhone()) ? stu.getPhone() : "");
        student.setSex(stu.getSex());
        student.setIdCard(ToolUtil.isNotEmpty(stu.getIdCard())?stu.getIdCard() : "");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        student.setBirthday(sdf.parse(stu.getBirthday()));
        student.setHeight(stu.getHeight());
        student.setWeight(stu.getWeight());
        BigDecimal bigDecimal = BigDecimal.valueOf(stu.getWeight());
        BigDecimal multiply = bigDecimal.subtract(BigDecimal.valueOf(stu.getHeight())).multiply(bigDecimal.subtract(BigDecimal.valueOf(stu.getHeight())));
        multiply.setScale(2);
        student.setBmi(multiply.doubleValue());
        student.setInsertTime(new Date());
        student.setState(1);
        this.baseMapper.insert(student);
 
        //同步信息到参赛人员信息中
        SaveParticipant saveParticipant = new SaveParticipant();
        saveParticipant.setAppUserId(appUserId);
        saveParticipant.setName(student.getName());
        saveParticipant.setBirthday(student.getBirthday());
        saveParticipant.setGender(student.getSex());
        saveParticipant.setHeight(student.getHeight().intValue());
        saveParticipant.setWeight(student.getWeight());
        saveParticipant.setPhone(student.getPhone());
        saveParticipant.setIdcard(student.getIdCard());
        participantClient.saveParticipant(saveParticipant);
        return ResultUtil.success();
    }
 
    @Override
    public ClassDetailsInsVo querySessionDetailsDt(Integer userIdFormRedis, Integer lessonId, Integer stuId) {
        ClassDetailsInsVo insVo = new ClassDetailsInsVo();
        Date localMonthStart = DateTimeHelper.getCurrentMouthStart();
        Date localMonthEnd = DateTimeHelper.getCurrentMouthEnd();
        GetStuSessionList getStuSessionList = new GetStuSessionList();
        getStuSessionList.setStartTime(localMonthStart);
        getStuSessionList.setEndTime(localMonthEnd);
        getStuSessionList.setStuId(stuId);
        getStuSessionList.setAppUserId(userIdFormRedis);
        List<StuSessionDetailsVo> stuSessionList = sessionNameClient.getStuSessionList(getStuSessionList);
        TStudent tStudent = this.baseMapper.selectById(stuId);
        if (ToolUtil.isNotEmpty(tStudent)){
            insVo.setStuId(tStudent.getId());
            insVo.setStuName(tStudent.getName());
            insVo.setStuImage(tStudent.getHeadImg());
 
            List<PurchaseRecordVo> purchaseRecordVoList = new ArrayList<>();
            GetStuSourseList getStuSourseList = new GetStuSourseList();
            getStuSourseList.setStartTime(localMonthStart);
            getStuSourseList.setEndTime(localMonthEnd);
            getStuSourseList.setAppUserId(userIdFormRedis);
            List<PurchaseRecordVo> stuSourseList = dcttClient.getStuSourseList(getStuSourseList);
            purchaseRecordVoList.addAll(stuSourseList);
 
            GetStuSessionList sessionList = new GetStuSessionList();
            sessionList.setStartTime(localMonthStart);
            sessionList.setEndTime(localMonthEnd);
            sessionList.setStuId(stuId);
            sessionList.setAppUserId(userIdFormRedis);
            List<PurchaseRecordVo> cancelCourseList = cancelcClient.getCancelCourseList(sessionList);
 
            purchaseRecordVoList.addAll(cancelCourseList);
            List<PurchaseRecordVo> purchaseRecordVos = sessionNameClient.queryCourseDetails(getStuSessionList);
            purchaseRecordVoList.addAll(purchaseRecordVos);
            List<TAppUser> tAppUsers = tauMapper.selectList(new QueryWrapper<TAppUser>()
                    .eq("referralUserId",userIdFormRedis )
                    .between("insertTime",localMonthStart ,localMonthEnd));
            List<Integer> userIds = tAppUsers.stream().map(TAppUser::getId).collect(Collectors.toList());
            IntrduceOfUserRequest request  = new IntrduceOfUserRequest();
            request.setStartTime(localMonthStart);
            request.setEndTime(localMonthEnd);
            request.setUserIds(userIds);
            List<PurchaseRecordVo> purchaseRecordVos1 = idrClient.queryAppUsersofIntroduce(request);
            purchaseRecordVoList.addAll(purchaseRecordVos1);
            insVo.setSessionNames(stuSessionList);
            insVo.setDetails(dealDataOfTime(purchaseRecordVoList));
            GetStuOfCoursesDetails getStuOfCoursesDetails = new GetStuOfCoursesDetails();
            getStuOfCoursesDetails.setStuId(stuId);
            getStuOfCoursesDetails.setAppUserId(userIdFormRedis);
            StuWithCoursesListVo stuOfCoursesDetails = couPayClient.getStuOfCoursesDetails(getStuOfCoursesDetails);
            insVo.setTotalNums(stuOfCoursesDetails.getTotalNums());
            insVo.setDeductedNums(stuOfCoursesDetails.getDeductedNums());
            insVo.setRemainingNums(stuOfCoursesDetails.getRemainingNums());
            GetStudentCourse course = new GetStudentCourse();
            course.setCourseId(lessonId);
            course.setStuId(stuId);
            course.setAppUserId(userIdFormRedis);
            Integer deductionClassHour = crClient.getDeductionClassHour(course);
            insVo.setDeductionClassHours(deductionClassHour);
        }
 
        return insVo;
    }
 
    @Override
    public List<PurchaseRecordVo> queryDeduRecordDetails(RecordTimeRequest timeRequest,Integer appUserId) {
        List<PurchaseRecordVo> purchaseRecordVoList = new ArrayList<>();
        Date startTime = DateTimeHelper.getCurrentIdetMouthStart(timeRequest.getStartTime());
        Date endTime = DateTimeHelper.getCurrentIdeaMouthEnd(timeRequest.getEndTime());
        GetStuSourseList getStuSourseList = new GetStuSourseList();
        getStuSourseList.setStartTime(startTime);
        getStuSourseList.setEndTime(endTime);
        getStuSourseList.setAppUserId(appUserId);
        List<PurchaseRecordVo> stuSourseList = dcttClient.getStuSourseList(getStuSourseList);
        purchaseRecordVoList.addAll(stuSourseList);
 
        GetStuSessionList sessionList = new GetStuSessionList();
        sessionList.setStartTime(startTime);
        sessionList.setEndTime(endTime);
        sessionList.setStuId(timeRequest.getStuId());
        sessionList.setAppUserId(appUserId);
        List<PurchaseRecordVo> cancelCourseList = cancelcClient.getCancelCourseList(sessionList);
 
        purchaseRecordVoList.addAll(cancelCourseList);
        GetStuSessionList getStuSessionList = new GetStuSessionList();
        getStuSessionList.setStartTime(startTime);
        getStuSessionList.setEndTime(endTime);
        getStuSessionList.setStuId(timeRequest.getStuId());
        getStuSessionList.setAppUserId(appUserId);
        List<PurchaseRecordVo> purchaseRecordVos = sessionNameClient.queryCourseDetails(getStuSessionList);
        purchaseRecordVoList.addAll(purchaseRecordVos);
        List<TAppUser> tAppUsers = tauMapper.selectList(new QueryWrapper<TAppUser>()
                .eq("referralUserId",appUserId )
                .between("insertTime",startTime ,endTime));
        List<Integer> userIds = tAppUsers.stream().map(TAppUser::getId).collect(Collectors.toList());
        IntrduceOfUserRequest request  = new IntrduceOfUserRequest();
        request.setStartTime(startTime);
        request.setEndTime(endTime);
        request.setUserIds(userIds);
        List<PurchaseRecordVo> purchaseRecordVos1 = idrClient.queryAppUsersofIntroduce(request);
        purchaseRecordVoList.addAll(purchaseRecordVos1);
 
        purchaseRecordVoList = dealDataOfTime(purchaseRecordVoList);
        return purchaseRecordVoList;
    }
 
    @Override
    public List<CouponStuAvailableVo> queryStuOfConponDetails(Integer appUserId) {
        List<CouponStuAvailableVo> availableVos = new ArrayList<>();
        availableVos = userCClient.queryUserWithConponList(appUserId);
        return availableVos;
    }
 
    @Override
    public CourseDetailsOfContinuationResp queryStuOfCourseDetails(Integer lessonId, Integer stuId, Integer appUserId) {
        CourseDetailsOfContinuationResp resp = new CourseDetailsOfContinuationResp();
 
        GetStudentCourse getStudentCourse = new GetStudentCourse();
        getStudentCourse.setCourseId(lessonId);
        getStudentCourse.setStuId(stuId);
        getStudentCourse.setAppUserId(appUserId);
        StudentOfCourseVo studentCourse = couPayClient.getStudentCourse(getStudentCourse);
        resp.setCoursePackageId(studentCourse.getCoursePackageId());
        resp.setStuId(stuId);
        resp.setPackageImg(studentCourse.getPackageImg());
        resp.setCourseName(studentCourse.getCourseName());
        Coach coach = coachMapper.selectById(studentCourse.getCoachId());
        resp.setTeacherName(coach.getName());
        resp.setCourseWeek(studentCourse.getCourseWeek());
        resp.setCourseTime(studentCourse.getCourseTime());
 
        StoreDetailOfCourse courseOfStore = storeClient.getCourseOfStore(studentCourse.getStoreId());
        resp.setStoreName(courseOfStore.getStoreName());
        resp.setStoreAddr(courseOfStore.getStoreAddr());
 
        resp.setTypeList(studentCourse.getTypeList());
        TStudent tStudent = this.baseMapper.selectById(stuId);
        resp.setStuName(tStudent.getName());
        resp.setStuPhone(tStudent.getPhone());
        resp.setStuAge(DateUtil.age(tStudent.getBirthday()));
        resp.setAmount(studentCourse.getAmount());
        resp.setVipAmount(studentCourse.getVipAmount());
        resp.setWpGold(studentCourse.getWpGold());
        return resp;
    }
 
    @Override
    public List<SysNotice> querySystemNoticeDetails() {
        return noClient.getSysNoticeDetails();
    }
 
    @Override
    public SysNotice queryNoticeData(Integer noId) {
        return noClient.getSysNoticeBuId(noId);
    }
 
    @Override
    public List<QuestionIns> queryQuestionData() {
        return quesClient.getSysQuestionDetails();
    }
 
    @Override
    public QuestionIns queryQuestionDataInfo(Integer quesId) {
        return quesClient.getSysQuestionBuId(quesId);
    }
 
    @Override
    public List<String> queryCustomerDetails() {
        return noClient.queryCustomerTel();
    }
 
    @Override
    public List<StoreInfo> queryIndexOfExplores(LonLatRequest llrequest) {
        GetAllNearbyStoreList getAllNearbyStoreList = new GetAllNearbyStoreList();
        getAllNearbyStoreList.setLongitude(llrequest.getLongitude());
        getAllNearbyStoreList.setLatitude(llrequest.getLatitude());
        return storeClient.getAllNearbyStoreList(getAllNearbyStoreList);
    }
 
    @Override
    public List<StuListVo> switchStudentActions(Integer appUserId, Integer stuId) {
        List<StuListVo> stuListVos = new ArrayList<>();
        List<TStudent> tStudents = this.baseMapper.selectList(new QueryWrapper<TStudent>()
                .eq("appUserId", appUserId)
                .eq("state",1));
        if (tStudents.size() > 0) {
            tStudents.forEach(sts -> {
                if (Objects.equals(sts.getId(), stuId)) {
                    sts.setIsDefault(1);
                } else {
                    sts.setIsDefault(2);
                }
                this.baseMapper.updateById(sts);
 
                StuListVo vo = new StuListVo();
                vo.setStuId(sts.getId());
                SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
                vo.setBirthday(simpleDateFormat.format(sts.getBirthday()));
                vo.setStuName(sts.getName());
                vo.setStuAge(DateUtil.age(sts.getBirthday()));
                vo.setStuHeight(sts.getHeight());
                vo.setStuWeight(sts.getWeight());
                vo.setIsNot(sts.getIsDefault());
                stuListVos.add(vo);
            });
        }
        return stuListVos;
    }
 
 
    public static List<PurchaseRecordVo> dealDataOfTime(List<PurchaseRecordVo> purchaseRecords) {
        Collections.sort(purchaseRecords, new Comparator<PurchaseRecordVo>() {
            @Override
            public int compare(PurchaseRecordVo record1, PurchaseRecordVo record2) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("MM-dd HH:mm");
                Date date1 = null;
                Date date2 = null;
                try {
                    date1 = dateFormat.parse(record1.getPurchaseTime());
                    date2 = dateFormat.parse(record2.getPurchaseTime());
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                // 倒序排序
                return date2.compareTo(date1);
            }
        });
        return purchaseRecords;
    }
 
    @Override
    public ResultUtil renewClassPayment(Integer userIdFormRedis, ClasspaymentRequest request) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);
 
        TCoursePackagePayment packagePayment = new TCoursePackagePayment();
        packagePayment.setCode(code);
        packagePayment.setAppUserId(userIdFormRedis);
        packagePayment.setStudentId(request.getStuId());
        packagePayment.setCoursePackageId(request.getLessonId());
        packagePayment.setPayType(request.getPayType());
        packagePayment.setAbsencesNumber(0);
        packagePayment.setPayUserType(1);
        packagePayment.setPayStatus(1);
        packagePayment.setPayUserId(userIdFormRedis);
        packagePayment.setStatus(1);
        packagePayment.setState(1);
        packagePayment.setInsertTime(new Date());
        couPayClient.savePaymentCoursePackage(packagePayment);
 
        try {
            switch (request.getPayType()) {
                case 1:
                    return WeChatPayment(code,request.getPayAmount());
                case 2:
                    return AlipayPayment(code,request.getPayAmount());
                case 3:
                    int i = PlaypaiGoldPayment(code,request);
                    switch (i){
                        case 1:
                            return ResultUtil.success();
                        case 2:
                            return ResultUtil.error("用户未登录!");
                        case 3:
                            return ResultUtil.error("续课失败,玩湃币不足,请充值");
                        case 4:
                            return ResultUtil.error("续课失败,请联系管理员");
                    }
                default:
                    break;
            }
        }catch (Exception e){
            ResultUtil.runErr();
        }
        return ResultUtil.success();
    }
 
 
    public ResultUtil WeChatPayment(String code,BigDecimal amount) throws Exception {
        ResultUtil weixinpay = payMoneyUtil.weixinpay("课包续费", "", code, amount.toString(),
                "/base/coursePackage/wechatPaymentCallback", "APP", "");
        if(weixinpay.getCode() == 200){
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        int num = 1;
                        int wait = 0;
                        while (num <= 10){
                            int min = 5000;
                            wait += (min * num);
                            Thread.sleep(wait);
                            TCoursePackagePayment coursePackagePayment = couPayClient.getCoursePackagePaymentByCode(code);
                            if(coursePackagePayment.getPayStatus() == 2){
                                break;
                            }
                            ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryWXOrder(code, "");
                            if(resultUtil.getCode() == 200 && coursePackagePayment.getPayStatus() == 1){
                                /**
                                 * SUCCESS—支付成功,
                                 * REFUND—转入退款,
                                 * NOTPAY—未支付,
                                 * CLOSED—已关闭,
                                 * REVOKED—已撤销(刷卡支付),
                                 * USERPAYING--用户支付中,
                                 * PAYERROR--支付失败(其他原因,如银行返回失败)
                                 */
                                Map<String, String> data1 = resultUtil.getData();
                                String s = data1.get("trade_state");
                                String transaction_id = data1.get("transaction_id");
                                if("REFUND".equals(s) || "NOTPAY".equals(s) || "CLOSED".equals(s) || "REVOKED".equals(s) || "PAYERROR".equals(s) || num == 10){
                                    coursePackagePayment.setState(3);
                                    couPayClient.delPaymentCoursePackage(coursePackagePayment.getId());
                                    break;
                                }
                                if("SUCCESS".equals(s)){
                                    coursePackagePayment.setPayStatus(2);
                                    coursePackagePayment.setOrderNumber(transaction_id);
                                    couPayClient.updatePaymentCoursePackage(coursePackagePayment);
                                    break;
                                }
                                if("USERPAYING".equals(s)){
                                    num++;
                                }
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }).start();
        }
        return weixinpay;
    }
 
    public ResultUtil AlipayPayment(String code,BigDecimal amount){
        ResultUtil alipay = payMoneyUtil.alipay("课包续费", "课包续费", "", code, amount.toString(),
                "/base/coursePackage/alipayPaymentCallback");
        if(alipay.getCode() == 200){
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        int num = 1;
                        int wait = 0;
                        while (num <= 10){
                            int min = 5000;
                            wait += (min * num);
                            Thread.sleep(wait);
                            TCoursePackagePayment coursePackagePayment = couPayClient.getCoursePackagePaymentByCode(code);
                            if(coursePackagePayment.getPayStatus() == 2){
                                break;
                            }
                            ResultUtil<Map<String, String>> resultUtil = payMoneyUtil.queryALIOrder(code);
                            if(resultUtil.getCode() == 200 && coursePackagePayment.getPayStatus() == 1){
                                /**
                                 * WAIT_BUYER_PAY(交易创建,等待买家付款)、
                                 * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款)、
                                 * TRADE_SUCCESS(交易支付成功)、
                                 * TRADE_FINISHED(交易结束,不可退款)
                                 */
                                Map<String, String> data1 = resultUtil.getData();
                                String s = data1.get("tradeStatus");
                                String tradeNo = data1.get("tradeNo");
                                if("TRADE_CLOSED".equals(s) || "TRADE_FINISHED".equals(s) || num == 10){
                                    coursePackagePayment.setState(3);
                                    couPayClient.delPaymentCoursePackage(coursePackagePayment.getId());
                                    break;
                                }
                                if("TRADE_SUCCESS".equals(s)){
                                    coursePackagePayment.setPayStatus(2);
                                    coursePackagePayment.setOrderNumber(tradeNo);
                                    couPayClient.updatePaymentCoursePackage(coursePackagePayment);
                                    break;
                                }
                                if("WAIT_BUYER_PAY".equals(s)){
                                    num++;
                                }
                            }
                        }
                    }catch (Exception e){
                        e.printStackTrace();
                    }
                }
            }).start();
        }
        return alipay;
    }
 
    public int PlaypaiGoldPayment(String code,ClasspaymentRequest request){
        PlayPaiGoldCoursePackage paiGoldCoursePackage = new PlayPaiGoldCoursePackage();
        paiGoldCoursePackage.setCoursePackageId(request.getLessonId());
        paiGoldCoursePackage.setStuId(request.getStuId());
        paiGoldCoursePackage.setCoursePayConfigId(request.getCourseConfigId());
        paiGoldCoursePackage.setCode(code);
        return couPayClient.paymentWanpaiRenewCourse(paiGoldCoursePackage);
    }
 
 
    @Override
    public ResultUtil insertVipPaymentCallback(String code, String orderNumber) {
        TCoursePackagePayment coursePackagePayment = couPayClient.getCoursePackagePaymentByCode(code);
        if(coursePackagePayment.getPayStatus() != 1){
            return ResultUtil.success();
        }
        coursePackagePayment.setPayStatus(2);
        coursePackagePayment.setOrderNumber(orderNumber);
        couPayClient.updatePaymentCoursePackage(coursePackagePayment);
        return ResultUtil.success();
    }
 
    @Override
    public AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId) {
        AppointmentRecordVo recordVo = new AppointmentRecordVo();
        TStudent tStudent = this.baseMapper.selectOne(new QueryWrapper<TStudent>()
                .eq("id",stuId )
                .eq("appUserId",appUserId));
        if (ToolUtil.isNotEmpty(tStudent)){
            recordVo.setStuId(tStudent.getId());
            recordVo.setStuName(tStudent.getName());
            recordVo.setAppointList(couPayClient.obtainStudentClassDetailsData(stuId));
        }
        return recordVo;
    }
 
    @Override
    public ResultUtil cancelReservationOfCourse(Integer courseStuRecordId) {
        Integer integer = crClient.cancelCourseRecordClass(courseStuRecordId);
        switch (integer){
            case 1:
                ResultUtil.success();
                break;
            case 2:
                ResultUtil.error("开课前三小时不能取消!");
                break;
            default:
                ResultUtil.runErr();
                break;
        }
        return null;
    }
 
    @Override
    public List<StoreDetailList> queryStoreList(Integer space,String cityCode,String latitude,String longitude) {
        StoreOfCitycodeResp citycodeResp = new StoreOfCitycodeResp();
        citycodeResp.setSpace(space);
        citycodeResp.setCityCode(cityCode);
        citycodeResp.setLongitude(latitude);
        citycodeResp.setLatitude(longitude);
        return storeClient.getQueryStoreList(citycodeResp);
    }
 
    @Override
    public StoreDetailsVo getStoreDetail(Integer storeId) {
        Store store = storeClient.queryStoreById(storeId);
        StoreDetailsVo detailsVo = new StoreDetailsVo();
        String realPicture = store.getRealPicture();
        String[] split = realPicture.split(",");
        detailsVo.setImages(Arrays.asList(split));
        detailsVo.setStoreId(store.getId());
        detailsVo.setStoreName(store.getName());
        detailsVo.setStoreAddress(store.getAddress());
        detailsVo.setStoreTime(store.getStartTime() + "至" +store.getEndTime());
        detailsVo.setStoreInfo(store.getIntroduce());
        detailsVo.setLon(store.getLon());
        detailsVo.setLat(store.getLat());
        detailsVo.setPhone(store.getPhone());
        detailsVo.setVenueList(steClient.getAppUserSiteList());
        detailsVo.setCourseVoList(culisClient.getStoreOfCourseList(storeId));
        return detailsVo;
    }
 
 
}