无关风月
2025-03-05 99f8118b288bd6dbe05adc146ab707ddec3971af
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
package com.xinquan.user.controller.client;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinquan.common.core.domain.R;
import com.xinquan.common.core.utils.page.PageDTO;
import com.xinquan.common.core.web.domain.BaseModel;
import com.xinquan.common.security.service.TokenService;
import com.xinquan.common.security.utils.SecurityUtils;
import com.xinquan.course.api.domain.Course;
import com.xinquan.course.api.domain.CourseChapter;
import com.xinquan.course.api.domain.OrderCourseVO;
import com.xinquan.course.api.feign.RemoteCourseService;
import com.xinquan.meditation.api.domain.Meditation;
import com.xinquan.meditation.api.feign.RemoteMeditationService;
import com.xinquan.system.api.domain.*;
import com.xinquan.system.api.domain.vo.AppUserVO;
import com.xinquan.system.api.model.LoginUser;
import com.xinquan.user.api.feign.RemoteAppUserService;
import com.xinquan.user.service.AppUserEnergyRecordService;
import com.xinquan.user.service.AppUserService;
import com.xinquan.user.service.AppUserTreeService;
import com.xinquan.user.service.AppUserViewingHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 用户观看历史 前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-09-06
 */
@Api(tags = {"用户端-观看历史相关接口"})
@RestController
@RequiredArgsConstructor
@RequestMapping("/user/app-user-viewing-history")
public class ClientAppUserViewingHistoryController {
 
    private final AppUserViewingHistoryService appUserViewingHistoryService;
    @Resource
    private TokenService tokenService;
    @Resource
    private AppUserTreeService appUserTreeService;
    @Resource
    private AppUserService appUserService;
    @Resource
    private RemoteMeditationService remoteMeditationService;
    @Resource
    private RemoteCourseService courseUserFavoriteService;
    @Resource
    private RemoteCourseService remoteCourseService;
    private final RemoteAppUserService remoteAppUserService;
 
    /**
     * 远程调用 根据章节id和用户id查询是否观看完毕
     *
     * @param id
     * @return
     */
    @PostMapping("/getCourseChapterHistoryState/{id}/{chapterId}")
    public R<Integer> getCourseChapterHistoryState(@PathVariable("id") Long id, @PathVariable("chapterId") Long chapterId) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getChapterId, chapterId)
                .eq(AppUserViewingHistory::getAppUserId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .list();
        for (AppUserViewingHistory appUserViewingHistory : list) {
            if (appUserViewingHistory.getIsOver() != null && appUserViewingHistory.getIsOver() == 1) {
                return R.ok(1);
            }
        }
        return R.ok(2);
    }
 
    /**
     * 远程调用查询用户观看了哪些课程
     *
     * @return
     */
    @PostMapping("/getCourseHistoryByUserId/{id}")
    public R<List<Long>> getCourseHistoryByUserId(@PathVariable("id") Long id) {
        List<Long> one = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getAppUserId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .list().stream().map(AppUserViewingHistory::getBizId)
                .collect(Collectors.toList());
        return R.ok(one);
    }
 
    @PostMapping("/getMeditationHistoryCount/{id}")
    public R<Long> getMeditationHistoryCount(@PathVariable("id") Long id) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getBizId, id)
                .eq(AppUserViewingHistory::getViewingType, 1)
                .groupBy(AppUserViewingHistory::getAppUserId)
                .list();
        return R.ok(Long.valueOf(list.size()));
    }
 
    @PostMapping("/getCourseHistoryCount/{id}")
    public R<Long> getCourseHistoryCount(@PathVariable("id") Long id) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getBizId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .list();
        return R.ok(Long.valueOf(list.size()));
    }
 
    @PostMapping("/getCourseChapterHistoryCount/{id}")
    public R<Long> getCourseChapterHistoryCount(@PathVariable("id") Long id) {
        List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getChapterId, id)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .groupBy(AppUserViewingHistory::getAppUserId)
                .list();
        return R.ok(Long.valueOf(list.size()));
    }
 
    @PostMapping("/lookHistory")
    @ApiOperation(value = "观看历史")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "state", value = "1冥想 2课程", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageCurr", value = "分页参数,当前页码", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageSize", value = "分页参数,每页数量", dataType = "Integer", required = true)
    })
    public R<List<OrderCourseVO>> lookHistory(Integer state, Integer pageCurr, Integer pageSize) {
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser == null) {
            return R.tokenError("登录失效");
        }
        Long userId = loginUser.getUserid();
        List<OrderCourseVO> orderCourseVOS = new ArrayList<>();
 
        switch (state) {
            case 1:
                List<Long> collect1 = appUserViewingHistoryService.lambdaQuery()
                        .eq(AppUserViewingHistory::getAppUserId, userId)
                        .eq(AppUserViewingHistory::getViewingType, 1).list()
                        .stream().map(AppUserViewingHistory::getBizId).collect(Collectors.toList());
                List<Long> collect2 = collect1.stream().distinct().collect(Collectors.toList());
                StringBuilder temp = new StringBuilder();
                if (collect1.isEmpty()) {
                    temp = temp.append("-1");
                } else {
                    for (Long l : collect2) {
                        temp.append(l).append(",");
                    }
                    temp.deleteCharAt(temp.length() - 1);
                }
                Page<Meditation> data = remoteMeditationService.getMeditationByIds(pageCurr, pageSize, temp.toString()).getData();
 
                for (Meditation meditation : data.getRecords()) {
                    OrderCourseVO orderCourseVO = new OrderCourseVO();
                    orderCourseVO.setBusinessId(meditation.getId());
                    orderCourseVO.setCourseTitle(meditation.getMeditationTitle());
                    orderCourseVO.setDescription(meditation.getDetailDescription());
                    orderCourseVO.setChargeType(meditation.getChargeType());
                    orderCourseVO.setGeneralPrice(meditation.getGeneralPrice());
                    orderCourseVO.setIosPrice(meditation.getIosPrice());
                    orderCourseVO.setCoverUrl(meditation.getCoverUrl());
                    orderCourseVO.setCount(meditation.getRealLearnedNum() + meditation.getVirtualLearnedNum());
                    orderCourseVO.setCoverDescription(meditation.getCoverDescription());
                    orderCourseVOS.add(orderCourseVO);
                }
                break;
            case 2:
                List<Long> collect3 = appUserViewingHistoryService.lambdaQuery()
                        .eq(AppUserViewingHistory::getAppUserId, userId)
                        .eq(AppUserViewingHistory::getViewingType, 2).list()
                        .stream().map(AppUserViewingHistory::getBizId).collect(Collectors.toList());
                List<Long> collect4 = collect3.stream().distinct().collect(Collectors.toList());
                StringBuilder temp1 = new StringBuilder();
                if (collect4.isEmpty()) {
                    temp1 = temp1.append("-1");
                } else {
                    for (Long l : collect4) {
                        temp1.append(l).append(",");
                    }
                    temp1.deleteCharAt(temp1.length() - 1);
                }
                Page<Course> data2 = remoteCourseService.getCourseByIds(pageCurr, pageSize, temp1.toString()).getData();
                for (Course record : data2.getRecords()) {
                    OrderCourseVO orderCourseVO = new OrderCourseVO();
                    orderCourseVO.setBusinessId(record.getId());
                    orderCourseVO.setCourseTitle(record.getCourseTitle());
                    orderCourseVO.setDescription(record.getDescription());
                    orderCourseVO.setChargeType(record.getChargeType());
                    orderCourseVO.setGeneralPrice(record.getGeneralPrice());
                    orderCourseVO.setIosPrice(record.getIosPrice());
                    orderCourseVO.setCoverUrl(record.getCoverUrl());
                    List<CourseChapter> data1 = remoteCourseService.getChapterByCourseId(orderCourseVO.getBusinessId() + "").getData();
                    int a = 0;
                    int b = 0;
                    for (CourseChapter courseChapter : data1) {
                        a += courseChapter.getVirtualLearnedNum();
                        Long data9 = remoteAppUserService.getCourseChapterHistoryCount(courseChapter.getId()).getData();
                        b += data9;
                    }
                    orderCourseVO.setCount(a + b);
                    orderCourseVOS.add(orderCourseVO);
                }
                break;
        }
        return R.ok(orderCourseVOS);
    }
 
    /**
     * 记录用户观看记录
     */
    @PostMapping("/saveViewingHistory")
    @ApiOperation(value = "记录用户观看冥想记录", tags = {"用户端-用户相关接口"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "冥想id", dataType = "Long", required = true),
            @ApiImplicitParam(name = "timeLook", value = "播放时长单位秒", dataType = "Integer", required = true)
    })
    public R<?> saveViewingRecord(@RequestParam("id") Long id,
                                  @RequestParam("timeLook") Integer timeLook
    ) {
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser == null) {
            return R.tokenError("登录失效");
        }
        Long userId = loginUser.getUserid();
        AppUserViewingHistory appUserViewingHistory = new AppUserViewingHistory();
        appUserViewingHistory.setAppUserId(userId);
        appUserViewingHistory.setBizId(id);
        appUserViewingHistory.setViewingType(1);
        appUserViewingHistory.setTimeLook(timeLook);
        appUserViewingHistory.setCreateTime(LocalDateTime.now());
        appUserViewingHistoryService.save(appUserViewingHistory);
        AppUser byId = appUserService.getById(userId);
        appUserService.updateById(byId);
        // 查询用户今日观看疗愈多少秒
        LocalDateTime now = LocalDateTime.now();
        LocalDateTime startOfDay = now.toLocalDate().atStartOfDay();
        LocalDateTime endOfDay = now.toLocalDate().atTime(LocalTime.MAX);
        List<AppUserViewingHistory> list = appUserViewingHistoryService
                .lambdaQuery().eq(AppUserViewingHistory::getAppUserId, userId)
                .eq(AppUserViewingHistory::getViewingType, 1)
                .eq(BaseModel::getDelFlag, 0)
                .between(AppUserViewingHistory::getCreateTime, startOfDay, endOfDay).list();
        int temp = 0;
        for (AppUserViewingHistory appUserViewingHistory1 : list) {
            if (appUserViewingHistory1.getTimeLook() != null) {
                temp += appUserViewingHistory1.getTimeLook();
 
            }
        }
        AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, userId)
                .eq(AppUserTree::getSowAgain, 2).one();
        if (one == null) {
            AppUserTree appUserTree = new AppUserTree();
            appUserTree.setTime(LocalDateTime.now());
            appUserTree.setAppUserId(userId);
            appUserTree.setTreeLevelType(1);
            appUserTree.setGrowthValue(0);
            appUserTree.setSowAgain(2);
            appUserTree.setCreateTime(LocalDateTime.now());
            // 如果用户的签到时间是今天 那么修改为已签到
            if (byId.getSignTime() != null && byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())) {
                appUserTree.setIsSign(1);
            } else {
                appUserTree.setIsSign(2);
            }
            if (temp >= 3600) {
                if (appUserTree.getTaskOne() == 2) {
                    AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord();
                    appUserEnergyRecord.setAppUserId(userId);
                    appUserEnergyRecord.setChangeType(1);
                    appUserEnergyRecord.setEnergyValue(10);
                    appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务");
                    appUserEnergyRecordService.save(appUserEnergyRecord);
                    byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10);
                    byId.setEnergyValue(byId.getEnergyValue() + 10);
 
                }
                if (appUserTree.getTaskTwo() == 2) {
                    AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord();
                    appUserEnergyRecord.setAppUserId(userId);
                    appUserEnergyRecord.setChangeType(1);
                    appUserEnergyRecord.setEnergyValue(20);
                    appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务");
                    appUserEnergyRecordService.save(appUserEnergyRecord);
                    byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 20);
                    byId.setEnergyValue(byId.getEnergyValue() + 20);
 
                }
                appUserTree.setTaskOne(1);
                appUserTree.setTaskTwo(1);
            } else if (temp >= 1800) {
                if (appUserTree.getTaskOne() == 2) {
                    AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord();
                    appUserEnergyRecord.setAppUserId(userId);
                    appUserEnergyRecord.setChangeType(1);
                    appUserEnergyRecord.setEnergyValue(10);
                    appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务");
                    appUserEnergyRecordService.save(appUserEnergyRecord);
                    byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10);
                    byId.setEnergyValue(byId.getEnergyValue() + 10);
                }
                appUserTree.setTaskOne(2);
                appUserTree.setTaskTwo(1);
            } else {
                appUserTree.setTaskOne(2);
                appUserTree.setTaskTwo(2);
            }
            appUserTree.setEnergyValue(byId.getEnergyValue());
            appUserTree.setNextLevel(1000);
            appUserTreeService.save(appUserTree);
            appUserTree.setTotalEnergyValue(byId.getTotalEnergyValue());
            return R.ok(appUserTree);
        } else {
            if (temp >= 3600) {
                if (one.getTaskOne() == 2) {
                    AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord();
                    appUserEnergyRecord.setAppUserId(userId);
                    appUserEnergyRecord.setChangeType(1);
                    appUserEnergyRecord.setEnergyValue(10);
                    appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务");
                    appUserEnergyRecordService.save(appUserEnergyRecord);
                    byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10);
                    one.setTaskOne(1);
                    byId.setEnergyValue(byId.getEnergyValue() + 10);
 
                }
                if (one.getTaskTwo() == 2) {
                    AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord();
                    appUserEnergyRecord.setAppUserId(userId);
                    appUserEnergyRecord.setChangeType(1);
                    appUserEnergyRecord.setEnergyValue(20);
                    appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务");
                    appUserEnergyRecordService.save(appUserEnergyRecord);
                    byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 20);
                    one.setTaskTwo(1);
                    byId.setEnergyValue(byId.getEnergyValue() + 20);
 
                }
 
            } else if (temp >= 1800) {
                if (one.getTaskOne() == 2) {
                    AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord();
                    appUserEnergyRecord.setAppUserId(userId);
                    appUserEnergyRecord.setChangeType(1);
                    appUserEnergyRecord.setEnergyValue(10);
                    appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务");
                    appUserEnergyRecordService.save(appUserEnergyRecord);
                    byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10);
                    one.setTaskOne(1);
                    byId.setEnergyValue(byId.getEnergyValue() + 10);
                }
            } else {
                one.setTaskOne(2);
                one.setTaskTwo(2);
            }
            appUserTreeService.updateById(one);
            appUserService.updateById(byId);
            return R.ok();
        }
    }
 
    @Resource
    private AppUserEnergyRecordService appUserEnergyRecordService;
 
    @PostMapping("/saveCourseStudyHistory")
    @ApiOperation(value = "记录用户观看课程记录", tags = {"用户端-用户相关接口"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "chapterId", value = "章节id", dataType = "Long", required = true),
            @ApiImplicitParam(name = "isOver", value = "是否观看完成 1是2否", dataType = "int", required = true),
            @ApiImplicitParam(name = "minuteLook", value = "观看到xx分钟", dataType = "int", required = true),
            @ApiImplicitParam(name = "secondLook", value = "观看到xx秒", dataType = "int", required = true),
    })
    public R<?> saveCourseStudyHistory(@RequestParam("chapterId") Long chapterId,
                                       @RequestParam("minuteLook") Integer minuteLook,
                                       @RequestParam("secondLook") Integer secondLook,
                                       @RequestParam("isOver") Integer isOver
    ) {
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser == null) {
            return R.tokenError("登录失效");
        }
        Long userId = loginUser.getUserid();
        AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getAppUserId, userId)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .eq(AppUserViewingHistory::getChapterId, chapterId).one();
        if (one != null) {
            if (one.getIsOver() == 1) {
                // 如果已经看完了 那么不更新状态 只更新观看时间
                one.setMinuteLook(minuteLook);
                one.setSecondLook(secondLook);
                one.setTimeLook(secondLook);
            } else {
                one.setIsOver(isOver);
            }
            appUserViewingHistoryService.updateById(one);
        } else {
            AppUserViewingHistory appUserViewingHistory = new AppUserViewingHistory();
            appUserViewingHistory.setAppUserId(userId);
            appUserViewingHistory.setBizId(chapterId);
            appUserViewingHistory.setViewingType(2);
            appUserViewingHistory.setMinuteLook(minuteLook);
            appUserViewingHistory.setSecondLook(secondLook);
            appUserViewingHistory.setChapterId(chapterId);
            appUserViewingHistory.setIsOver(isOver);
            appUserViewingHistory.setTimeLook(secondLook);
 
            appUserViewingHistoryService.save(appUserViewingHistory);
        }
        return R.ok();
    }
 
    @PostMapping("/getCourseStudyHistory")
    public R<AppUserViewingHistory> getCourseStudyHistory(@RequestParam("chapterId") Long chapterId) {
        LoginUser loginUser = tokenService.getLoginUser();
        if (loginUser == null) {
            return R.tokenError("登录失效");
        }
        Long userId = loginUser.getUserid();
        AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery()
                .eq(AppUserViewingHistory::getAppUserId, userId)
                .eq(AppUserViewingHistory::getViewingType, 2)
                .eq(AppUserViewingHistory::getChapterId, chapterId).one();
        if (one == null) {
            AppUserViewingHistory appUserViewingHistory = new AppUserViewingHistory();
            appUserViewingHistory.setAppUserId(userId);
            appUserViewingHistory.setBizId(chapterId);
            appUserViewingHistory.setViewingType(2);
            appUserViewingHistory.setMinuteLook(0);
            appUserViewingHistory.setSecondLook(0);
            appUserViewingHistory.setChapterId(chapterId);
            appUserViewingHistory.setIsOver(2);
            appUserViewingHistoryService.save(appUserViewingHistory);
            return R.ok(appUserViewingHistory);
        }
        return R.ok(one);
    }
 
//    @PostMapping("/studyRecord")
//    @ApiOperation(value = "学习页面记录观看到xx分钟xx秒")
//    @ApiImplicitParams({
//            @ApiImplicitParam(value = "章节id", name = "chapterId", required = true, dataType = "String"),
//            @ApiImplicitParam(value = "上次观看到xx分钟", name = "minuteLook", required = true, dataType = "Integer"),
//            @ApiImplicitParam(value = "上次观看到xx秒", name = "secondLook", required = true, dataType = "Integer"),
//            @ApiImplicitParam(value = "是否观看完成", name = "isOver", required = true, dataType = "Integer"),
//    })
//    public R studyRecord(@RequestParam(value = "chapterId")Long chapterId,
//                                                 @RequestParam(value = "minuteLook") Integer minuteLook,
//                                                 @RequestParam(value = "secondLook") Integer secondLook,
//                                                 @RequestParam(value = "isOver") Integer isOver
//    ) {
//        Long userId = tokenService.getLoginUser().getUserid();
//        if(userId ==null || userId == 0)return R.tokenError("登录失效");
//        AppUserViewingHistory one = appUserViewingHistoryService.lambdaQuery()
//                .eq(AppUserViewingHistory::getAppUserId, userId)
//                .eq(AppUserViewingHistory::getViewingType, 2)
//                .eq(AppUserViewingHistory::getChapterId, chapterId).one();
//        if (one!=null){
//            if (one.getIsOver() == 1){
//                // 如果已经看完了 那么不更新状态 只更新观看时间
//                one.setMinuteLook(minuteLook);
//                one.setSecondLook(secondLook);
//            }else{
//                one.setIsOver(isOver);
//            }
//            appUserViewingHistoryService.updateById(one);
//        }else{
//            AppUserViewingHistory appUserViewingHistory = new AppUserViewingHistory();
//            appUserViewingHistory.setAppUserId(userId);
//            appUserViewingHistory.setBizId(chapterId);
//            appUserViewingHistory.setViewingType(2);
//            appUserViewingHistory.setMinuteLook(minuteLook);
//            appUserViewingHistory.setSecondLook(secondLook);
//            appUserViewingHistory.setChapterId(chapterId);
//            appUserViewingHistory.setIsOver(isOver);
//            appUserViewingHistoryService.save(appUserViewingHistory);
//        }
//        return R.ok();
//    }
}