| | |
| | | public static final Integer SEVEN = 7; |
| | | |
| | | /** |
| | | * 数字10 |
| | | */ |
| | | public static final Integer TEN = 10; |
| | | |
| | | |
| | | |
| | | /** |
| | | * -1 |
| | | */ |
| | | public static final Integer BURDEN_ONE = -1; |
| | |
| | | @PostMapping("/addGoods") |
| | | @ApiOperation(value = "添加", tags = {"后台-商品管理"}) |
| | | public R addGoods(@RequestBody TGoods dto) { |
| | | if (dto.getTotal()!=null){ |
| | | if (dto.getTotal() != null) { |
| | | dto.setSurplus(dto.getTotal()); |
| | | }else{ |
| | | } else { |
| | | dto.setSurplus(0); |
| | | } |
| | | goodsService.save(dto); |
| | |
| | | @PostMapping("/updateGoods") |
| | | @ApiOperation(value = "修改", tags = {"后台-商品管理"}) |
| | | public R updateGoods(@RequestBody TGoods dto) { |
| | | if (dto.getTotal()!=null){ |
| | | if (dto.getTotal() != null) { |
| | | dto.setSurplus(dto.getTotal()); |
| | | }else{ |
| | | } else { |
| | | dto.setSurplus(0); |
| | | } |
| | | goodsService.updateById(dto); |
| | |
| | | number += goods.getBasicCount(); |
| | | } |
| | | number += orderService.getGoodBuyNumber(goods.getId()); |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number)); |
| | | // 剩余兑换数量 |
| | | Integer residueNumber = null; |
| | | if (null != goods.getTotal()) { |
| | | // 计算剩余兑换数量 |
| | | List<TOrder> orderList = orderService.lambdaQuery().eq(TOrder::getGoodsId, goodId) |
| | | .eq(TOrder::getDisabled, 0).list(); |
| | | Integer item = 0; |
| | | for (TOrder order : orderList) { |
| | | item += order.getCount(); |
| | | } |
| | | residueNumber = goods.getTotal() - item; |
| | | } |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number, residueNumber)); |
| | | } |
| | | |
| | | /** |
| | |
| | | number += goods.getBasicCount(); |
| | | } |
| | | number += orderService.getGoodBuyNumber(goods.getId()); |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number)); |
| | | // 剩余兑换数量 |
| | | Integer residueNumber = null; |
| | | if (null != goods.getTotal()) { |
| | | // 计算剩余兑换数量 |
| | | List<TOrder> orderList = orderService.lambdaQuery().eq(TOrder::getGoodsId, goodId) |
| | | .eq(TOrder::getDisabled, 0).list(); |
| | | Integer item = 0; |
| | | for (TOrder order : orderList) { |
| | | item += order.getCount(); |
| | | } |
| | | residueNumber = goods.getTotal() - item; |
| | | } |
| | | return R.ok(new GoodDetailVO(goods, goodsTypes, number, residueNumber)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiModelProperty(value = "收货人地址") |
| | | private String consigneeAddress; |
| | | |
| | | @ApiModelProperty(value = "订单备注") |
| | | @TableField("remark") |
| | | private String remark; |
| | | |
| | | |
| | | public Integer getId() { |
| | | return id; |
| | |
| | | @Override |
| | | public String toString() { |
| | | return "TOrder{" + |
| | | ", id=" + id + |
| | | ", orderNumber=" + orderNumber + |
| | | ", userId=" + userId + |
| | | ", insertTime=" + insertTime + |
| | | ", goodsId=" + goodsId + |
| | | ", count=" + count + |
| | | ", state=" + state + |
| | | ", express=" + express + |
| | | ", expressNumber=" + expressNumber + |
| | | ", expressTime=" + expressTime + |
| | | ", integral=" + integral + |
| | | "}"; |
| | | ", id=" + id + |
| | | ", orderNumber=" + orderNumber + |
| | | ", userId=" + userId + |
| | | ", insertTime=" + insertTime + |
| | | ", goodsId=" + goodsId + |
| | | ", count=" + count + |
| | | ", state=" + state + |
| | | ", express=" + express + |
| | | ", expressNumber=" + expressNumber + |
| | | ", expressTime=" + expressTime + |
| | | ", integral=" + integral + |
| | | "}"; |
| | | } |
| | | } |
| | |
| | | order.setGoodsId(goodId); |
| | | order.setCount(number); |
| | | order.setState(1); |
| | | order.setRemark(goodExchange.getRemark()); |
| | | order.setIntegral(needIntegral); |
| | | order.setConsigneeName(recipient.getRecipient()); |
| | | order.setConsigneePhone(recipient.getRecipientPhone()); |
| | |
| | | order.setGoodsId(goodId); |
| | | order.setCount(number); |
| | | order.setState(1); |
| | | order.setRemark(goodExchange.getRemark()); |
| | | order.setIntegral(needIntegral); |
| | | order.setConsigneeName(recipient.getRecipient()); |
| | | order.setConsigneePhone(recipient.getRecipientPhone()); |
| | |
| | | private List<TGoodsType> goodTypes; |
| | | |
| | | /** |
| | | * 商品剩余数量 |
| | | */ |
| | | @ApiModelProperty("商品剩余数量") |
| | | private Integer residueNumber; |
| | | |
| | | /** |
| | | * 已兑换人数 |
| | | */ |
| | | @ApiModelProperty("已兑换人数") |
| | | private Integer exchangeNumber; |
| | | |
| | | /** |
| | | * 已兑换人数 |
| | | * 订单编号 |
| | | */ |
| | | @ApiModelProperty("订单编号") |
| | | private String orderNumber; |
| | |
| | | @ApiModelProperty("用户默认收货地址(为:null则调用获取收货地址接口)") |
| | | private Recipient recipient; |
| | | |
| | | public GoodDetailVO(TGoods good, List<TGoodsType> goodTypes, Integer exchangeNumber) { |
| | | public GoodDetailVO(TGoods good, List<TGoodsType> goodTypes, Integer exchangeNumber, Integer residueNumber) { |
| | | this.good = good; |
| | | this.goodTypes = goodTypes; |
| | | this.exchangeNumber = exchangeNumber; |
| | | this.residueNumber = residueNumber; |
| | | } |
| | | |
| | | public GoodDetailVO(TGoods good, Recipient recipient) { |
| | |
| | | private IUserStudyRecordService studyRecordService; |
| | | @Resource |
| | | private ManagementClient managementClient; |
| | | @Resource |
| | | private ITUserPresentRecordService userPresentRecordService; |
| | | |
| | | @PostMapping("/storyList") |
| | | // @ApiOperation(value = "配置学习类型选择故事", tags = {"题目管理"}) |
| | |
| | | if (null == loginUserStudy) { |
| | | return R.tokenError("登录失效!"); |
| | | } |
| | | List<StudyWeekDTO> result = studyService.weekList(type, quarter,loginUserStudy.getUserid()); |
| | | List<StudyWeekDTO> result = studyService.weekList(type, quarter, loginUserStudy.getUserid()); |
| | | return R.ok(result); |
| | | } |
| | | |
| | |
| | | throw new GlobalException("获取在线时间赠送积分信息失败!"); |
| | | } |
| | | String integral = sysSet.getIntegral(); |
| | | // 计算时间间隔 |
| | | TUserPresentRecord record = userPresentRecordService.lambdaQuery() |
| | | .eq(TUserPresentRecord::getUserId, loginStudy.getUserid()) |
| | | .orderByDesc(TUserPresentRecord::getPresentTime) |
| | | .eq(TUserPresentRecord::getIsDelete, 0).last("limit 1").one(); |
| | | boolean result = true; |
| | | TUser user = userService.lambdaQuery().eq(TUser::getId, loginStudy.getUserid()) |
| | | .eq(TUser::getDisabled, 0).one(); |
| | | boolean update = userService.lambdaUpdate().set(TUser::getIntegral, user.getIntegral() + Integer.parseInt(integral)) |
| | | .eq(TUser::getId, loginStudy.getUserid()).update(); |
| | | return R.ok(update); |
| | | if (null == record) { |
| | | // 赠送积分 |
| | | result = userService.lambdaUpdate().set(TUser::getIntegral, user.getIntegral() + Integer.parseInt(integral)) |
| | | .eq(TUser::getId, loginStudy.getUserid()).update(); |
| | | // 添加赠送积分记录 |
| | | TUserPresentRecord data = new TUserPresentRecord(); |
| | | data.setUserId(loginStudy.getUserid()); |
| | | data.setPresentTime(new Date()); |
| | | data.setIsDelete(0); |
| | | result = result && userPresentRecordService.save(data); |
| | | } else { |
| | | if (System.currentTimeMillis() - record.getPresentTime().getTime() >= 10 * 60) { |
| | | // 赠送积分 |
| | | result = userService.lambdaUpdate() |
| | | .set(TUser::getIntegral, user.getIntegral() + Integer.parseInt(integral)) |
| | | .eq(TUser::getId, loginStudy.getUserid()).update(); |
| | | // 添加赠送积分记录 |
| | | TUserPresentRecord data = new TUserPresentRecord(); |
| | | data.setUserId(loginStudy.getUserid()); |
| | | data.setPresentTime(new Date()); |
| | | data.setIsDelete(0); |
| | | result = result && userPresentRecordService.save(data); |
| | | } |
| | | } |
| | | return R.ok(result); |
| | | } |
| | | |
| | | /** |
| | |
| | | .eq(TUserStudyRecord::getWeek, completeStudy.getWeek()) |
| | | .eq(TUserStudyRecord::getDay, completeStudy.getDay()) |
| | | .eq(TUserStudyRecord::getType, 0) |
| | | .eq(TUserStudyRecord::getStudyType, completeStudy.getType()) |
| | | .eq(TUserStudyRecord::getUserId, userId).list(); |
| | | if (list.isEmpty()) { |
| | | obtainedIntegral = 0; |
New file |
| | |
| | | package com.ruoyi.study.domain; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户赠送积分记录表 |
| | | * </p> |
| | | * |
| | | * @author hjl |
| | | * @since 2024-06-20 |
| | | */ |
| | | @Data |
| | | @TableName("t_user_present_record") |
| | | public class TUserPresentRecord { |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | /** |
| | | * 用户id |
| | | */ |
| | | @ApiModelProperty("用户id") |
| | | @TableField("user_id") |
| | | private Integer userId; |
| | | |
| | | /** |
| | | * 赠送时间 |
| | | */ |
| | | @ApiModelProperty("赠送时间") |
| | | @TableField("present_time") |
| | | private Date presentTime; |
| | | |
| | | /** |
| | | * 是否软删除 |
| | | */ |
| | | @ApiModelProperty("是否软删除(0:未删除;1:已删除)") |
| | | @TableField("is_delete") |
| | | private Integer isDelete; |
| | | |
| | | } |
| | |
| | | private Integer type; |
| | | |
| | | /** |
| | | * 题目类型(1:听音选图;2:看图选音;3:归纳排除;4:有问有答;5:音图相配) |
| | | */ |
| | | @ApiModelProperty("题目类型(1:听音选图;2:看图选音;3:归纳排除;4:有问有答;5:音图相配)") |
| | | @TableField("study_type") |
| | | private Integer studyType; |
| | | |
| | | /** |
| | | * 自主故事id |
| | | */ |
| | | @ApiModelProperty("自主故事id") |
New file |
| | |
| | | package com.ruoyi.study.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.study.domain.TUserPresentRecord; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户赠送积分记录表 Mapper 接口 |
| | | * </p> |
| | | * |
| | | * @author 无关风月 |
| | | * @since 2024-04-26 |
| | | */ |
| | | public interface TUserPresentRecordMapper extends BaseMapper<TUserPresentRecord> { |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.study.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.study.domain.TUserPresentRecord; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户赠送积分记录表 服务类 |
| | | * </p> |
| | | * |
| | | * @author 无关风月 |
| | | * @since 2024-04-26 |
| | | */ |
| | | public interface ITUserPresentRecordService extends IService<TUserPresentRecord> { |
| | | |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.utils.bean.BeanUtils; |
| | | import com.ruoyi.study.domain.*; |
| | | import com.ruoyi.study.dto.StudyWeekDTO; |
| | | import com.ruoyi.study.mapper.TStudyMapper; |
| | |
| | | for (TStudyInduction data : inductionList) { |
| | | List<String> subjectIds = Arrays.stream(data.getSubject().split(",")).collect(Collectors.toList()); |
| | | List<TSubject> subjectLists = new ArrayList<>(); |
| | | for (String id : subjectIds) { |
| | | if (id.startsWith("-")) { |
| | | id = id.replace("-", ""); |
| | | // 第一组题 固定下标为0,1,2的题 |
| | | for (int i = 0; i < Constants.THREE; i++) { |
| | | String id = subjectIds.get(i); |
| | | if (!id.startsWith("-")) { |
| | | subjectLists.add(subjectService.getById(id)); |
| | | } |
| | | subjectLists.add(subjectService.getById(id)); |
| | | } |
| | | for (int i = 0; i < Constants.THREE; i++) { |
| | | String id = subjectIds.get(i); |
| | | if (id.startsWith("-")) { |
| | | id = id.replace("-",""); |
| | | subjectLists.add(subjectService.getById(id)); |
| | | } |
| | | } |
| | | // 第二组题,固定下标为3,4的题 |
| | | for (int i = Constants.THREE; i < Constants.FIVE; i++) { |
| | | String id = subjectIds.get(i); |
| | | if (!id.startsWith("-")) { |
| | | subjectLists.add(subjectService.getById(id)); |
| | | } |
| | | } |
| | | for (int i = Constants.THREE; i < Constants.FIVE; i++) { |
| | | String id = subjectIds.get(i); |
| | | if (id.startsWith("-")) { |
| | | id = id.replace("-",""); |
| | | subjectLists.add(subjectService.getById(id)); |
| | | } |
| | | } |
| | | subjectLists.add(subjectService.getById(subjectIds.get(subjectIds.size() - 1).replace("-",""))); |
| | | subjectList.add(subjectLists); |
| | | } |
| | | return new StudyInductionResultVO(learnStudy, subjectList); |
| | |
| | | QuestionsAnswersSubjectVO oneVO = new QuestionsAnswersSubjectVO(); |
| | | TSubject one1 = subjectService.lambdaQuery().eq(TSubject::getId, subject) |
| | | .eq(TSubject::getDisabled, 0).one(); |
| | | BeanUtils.copyProperties(one1, oneVO); |
| | | copyProperties(one1, oneVO); |
| | | // 回答题目信息 |
| | | QuestionsAnswersSubjectVO twoVO = new QuestionsAnswersSubjectVO(); |
| | | TSubject two1 = subjectService.lambdaQuery().eq(TSubject::getId, answerSubject) |
| | | .eq(TSubject::getDisabled, 0).one(); |
| | | BeanUtils.copyProperties(two1, twoVO); |
| | | copyProperties(two1, twoVO); |
| | | // 判断第一组题目的问题题目及回答题目,哪个是答案 |
| | | if (Constants.ZERO.equals(one.getIsAnswer())) { |
| | | oneVO.setIsQuestion(0); |
| | |
| | | voList.add(twoVO); |
| | | } |
| | | |
| | | private void copyProperties(TSubject subject, QuestionsAnswersSubjectVO vo) { |
| | | vo.setId(subject.getId()); |
| | | vo.setName(subject.getName()); |
| | | vo.setEnglish(subject.getEnglish()); |
| | | vo.setType(subject.getType()); |
| | | vo.setState(subject.getState()); |
| | | vo.setImg(subject.getImg()); |
| | | vo.setCorrect(subject.getCorrect()); |
| | | vo.setError(subject.getError()); |
| | | vo.setSort(subject.getSort()); |
| | | } |
| | | |
| | | @Override |
| | | public StudyPairResultVO pictureMateVoice(Integer week, Integer day, List<TStudyPair> pair) { |
| | | if (pair.isEmpty()) { |
New file |
| | |
| | | package com.ruoyi.study.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.study.domain.TUserPresentRecord; |
| | | import com.ruoyi.study.mapper.TUserPresentRecordMapper; |
| | | import com.ruoyi.study.service.ITUserPresentRecordService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * <p> |
| | | * 用户赠送积分记录表 服务实现类 |
| | | * </p> |
| | | * |
| | | * @author 无关风月 |
| | | * @since 2024-04-26 |
| | | */ |
| | | @Service |
| | | public class TUserPresentRecordServiceImpl extends ServiceImpl<TUserPresentRecordMapper, TUserPresentRecord> implements ITUserPresentRecordService { |
| | | |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.study.mapper.TUserPresentRecordMapper"> |
| | | </mapper> |