2 Commits eff8d2d623 ... 07ec0bce41

Autore SHA1 Messaggio Data
  yfh 07ec0bce41 Merge remote-tracking branch 'origin/Payment-Configuration' into Payment-Configuration 3 settimane fa
  yfh 82bbb934cb 设置天降红包配置迁移 3 settimane fa

+ 19 - 0
fs-company/src/main/java/com/fs/company/controller/course/FsUserCourseVideoController.java

@@ -8,6 +8,8 @@ import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.ServletUtils;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.course.param.FsCourseAnswerRewardParam;
+import com.fs.course.vo.FsCourseAnswerRewardVO;
 import com.fs.course.domain.FsUserCourseVideo;
 import com.fs.course.mapper.FsUserCourseVideoMapper;
 import com.fs.course.param.FsUserCourseVideoParam;
@@ -19,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.util.List;
 
 /**
@@ -138,4 +141,20 @@ public class FsUserCourseVideoController extends BaseController
 
         return R.ok().put("data",fsUserCourseVideoService.selectCourseVideoSort(courseId));
     }
+
+
+    @GetMapping("/getAnswerRewardConfig/{videoId}")
+    public R getAnswerRewardConfig(@PathVariable Long videoId) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        FsCourseAnswerRewardVO vo = fsUserCourseVideoService.getAnswerRewardConfig(videoId, loginUser.getCompany().getCompanyId());
+        return R.ok().put("data", vo);
+    }
+
+    @PreAuthorize("@ss.hasPermi('course:userCourseVideo:changeRewardConfig')")
+    @PostMapping("/changeAnswerRewardConfig")
+    public R changeAnswerRewardConfig(@Valid @RequestBody FsCourseAnswerRewardParam param) {
+        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
+        fsUserCourseVideoService.changeAnswerRewardConfig(param, loginUser.getCompany().getCompanyId());
+        return R.ok();
+    }
 }

+ 2 - 0
fs-service/src/main/java/com/fs/course/config/CourseConfig.java

@@ -42,6 +42,8 @@ public class CourseConfig implements Serializable {
     private Integer delayEnd;
     private Integer isNegative;//是否为负数 0、不允许,1、允许
 
+    // 默认转盘奖励
+    private Long defaultSpinReward;
     private Integer isOpen;
     /**
      * 第一个百分比

+ 26 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseAnswerRewardParam.java

@@ -0,0 +1,26 @@
+package com.fs.course.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+public class FsCourseAnswerRewardParam {
+
+    @NotNull(message = "视频ID不能为空")
+    @ApiModelProperty("视频小节ID")
+    private Long videoId;
+
+    @ApiModelProperty("红包配置")
+    private Long redPacketRuleId;
+
+    @ApiModelProperty("积分配置")
+    private Long pointRuleId;
+
+    @ApiModelProperty("转盘配置")
+    private Long turntableRuleId;
+
+    @ApiModelProperty("保底转盘配置")
+    private Long turntableGuaranteeRuleId;
+}

+ 29 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseRewardRuleParam.java

@@ -0,0 +1,29 @@
+package com.fs.course.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class FsCourseRewardRuleParam {
+
+    @NotNull(message = "奖励类型不能为空")
+    @ApiModelProperty("奖励类型 3:转盘 4:保底转盘")
+    private Integer type;  // 3:转盘 4:保底转盘
+
+    @NotNull(message = "视频ID不能为空")
+    @ApiModelProperty("视频ID")
+    private Long videoId;
+
+    @NotBlank(message = "公司ID不能为空")
+    @ApiModelProperty("公司ID")
+    private Long companyId;
+
+    @ApiModelProperty("用户ID")
+    private Long userId;
+
+    @ApiModelProperty("来源类型 1:H5 2:小程序 3:APP")
+    private Integer source = 1;
+}

+ 25 - 0
fs-service/src/main/java/com/fs/course/param/FsCourseRewardTypeParam.java

@@ -0,0 +1,25 @@
+package com.fs.course.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
+@Data
+public class FsCourseRewardTypeParam {
+
+    @NotNull(message = "视频ID不能为空")
+    @ApiModelProperty("视频ID")
+    private Long videoId;
+
+    @NotBlank(message = "公司ID不能为空")
+    @ApiModelProperty("公司ID")
+    private Long companyId;
+
+    @ApiModelProperty("用户ID")
+    private Long userId;
+
+    @ApiModelProperty("来源类型 1:H5 2:小程序 3:APP")
+    private Integer source = 1;
+}

+ 14 - 2
fs-service/src/main/java/com/fs/course/service/IFsUserCourseVideoService.java

@@ -1,5 +1,6 @@
 package com.fs.course.service;
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
@@ -18,8 +19,6 @@ import com.fs.course.vo.newfs.FsUserVideoListVO;
 import com.fs.his.domain.FsUser;
 import com.fs.his.vo.OptionsVO;
 import com.fs.qw.param.FsUserCourseRedPageParam;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
 import java.util.Map;
@@ -286,4 +285,17 @@ public interface IFsUserCourseVideoService extends IService<FsUserCourseVideo> {
     R registerQwFsUserFinish(FsUserCourseVideoAddKfUParam param);
 
     R withdrawal(FsCourseSendRewardUParam param);
+
+
+    /**
+     * 查询【公司-视频】答题奖励配置
+     */
+    FsCourseAnswerRewardVO getAnswerRewardConfig(Long videoId, Long companyId);
+
+    /**
+     * 修改【公司-视频】答题奖励配置
+     */
+    void changeAnswerRewardConfig(FsCourseAnswerRewardParam param, Long companyId);
+
+
 }

+ 62 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -4900,6 +4900,68 @@ public class FsUserCourseVideoServiceImpl extends ServiceImpl<FsUserCourseVideoM
 
     }
 
+    /**
+     * 查询【公司-视频】答题奖励配置
+     */
+    @Override
+    public FsCourseAnswerRewardVO getAnswerRewardConfig(Long videoId, Long companyId) {
+        String json = configService.selectConfigByKey("course.config");
+        CourseConfig config = JSONUtil.toBean(json, CourseConfig.class);
+
+        FsCourseAnswerRewardVO vo = new FsCourseAnswerRewardVO();
+        vo.setRedPacketRuleId(videoRelationMapper.getRewardIdByCompanyIdAndVideoIdAndType(companyId, videoId, 2));
+        vo.setPointRuleId(videoRelationMapper.getRewardIdByCompanyIdAndVideoIdAndType(companyId, videoId, 3));
+        vo.setTurntableRuleId(videoRelationMapper.getRewardIdByCompanyIdAndVideoIdAndType(companyId, videoId, 4));
+        vo.setTurntableGuaranteeRuleId(videoRelationMapper.getRewardIdByCompanyIdAndVideoIdAndType(companyId, videoId, 5));
+        vo.setDefaultRedPacketAmount(config.getRedPackageMoney());
+        vo.setDefaultPointNum(config.getAnswerIntegral());
+        vo.setDefaultAppPointNum(config.getAppAnswerIntegral());
+        vo.setDefaultTurntableRuleId(config.getDefaultSpinReward());
+        return vo;
+    }
+
+    /**
+     * 修改【公司-视频】答题奖励配置
+     */
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void changeAnswerRewardConfig(FsCourseAnswerRewardParam param, Long companyId) {
+        videoRelationMapper.deleteByTypes(param.getVideoId(), companyId, Arrays.asList(2,3,4,5));
+
+        if (Objects.nonNull(param.getRedPacketRuleId())) {
+            FsCourseRewardVideoRelation relation = new FsCourseRewardVideoRelation();
+            relation.setVideoSectionId(param.getVideoId());
+            relation.setRewardId(param.getRedPacketRuleId());
+            relation.setCompanyId(companyId);
+            videoRelationMapper.insertFsCourseRewardVideoRelation(relation);
+        }
+
+        if (Objects.nonNull(param.getPointRuleId())) {
+            FsCourseRewardVideoRelation relation = new FsCourseRewardVideoRelation();
+            relation.setVideoSectionId(param.getVideoId());
+            relation.setRewardId(param.getPointRuleId());
+            relation.setCompanyId(companyId);
+            videoRelationMapper.insertFsCourseRewardVideoRelation(relation);
+        }
+
+        if (Objects.nonNull(param.getTurntableRuleId())) {
+            FsCourseRewardVideoRelation relation = new FsCourseRewardVideoRelation();
+            relation.setVideoSectionId(param.getVideoId());
+            relation.setRewardId(param.getTurntableRuleId());
+            relation.setCompanyId(companyId);
+            videoRelationMapper.insertFsCourseRewardVideoRelation(relation);
+        }
+
+        if (Objects.nonNull(param.getTurntableGuaranteeRuleId())) {
+            FsCourseRewardVideoRelation relation = new FsCourseRewardVideoRelation();
+            relation.setVideoSectionId(param.getVideoId());
+            relation.setRewardId(param.getTurntableGuaranteeRuleId());
+            relation.setCompanyId(companyId);
+            videoRelationMapper.insertFsCourseRewardVideoRelation(relation);
+        }
+    }
+
+
 
     private R executeWithdrawal(FsCourseSendRewardUParam param){
         log.info("进入用户判断");

+ 34 - 0
fs-service/src/main/java/com/fs/course/vo/FsCourseAnswerRewardVO.java

@@ -0,0 +1,34 @@
+package com.fs.course.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class FsCourseAnswerRewardVO {
+
+    @ApiModelProperty("红包配置")
+    private Long redPacketRuleId;
+
+    @ApiModelProperty("积分配置")
+    private Long pointRuleId;
+
+    @ApiModelProperty("转盘配置")
+    private Long turntableRuleId;
+
+    @ApiModelProperty("保底转盘配置")
+    private Long turntableGuaranteeRuleId;
+
+    @ApiModelProperty("默认红包金额")
+    private BigDecimal defaultRedPacketAmount;
+
+    @ApiModelProperty("默认积分数量")
+    private Integer defaultPointNum;
+
+    @ApiModelProperty("默认App积分数量")
+    private Integer defaultAppPointNum;
+
+    @ApiModelProperty("默认转盘")
+    private Long defaultTurntableRuleId;
+}

+ 15 - 0
fs-service/src/main/java/com/fs/course/vo/FsCourseRewardTypeVO.java

@@ -0,0 +1,15 @@
+package com.fs.course.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+@AllArgsConstructor
+public class FsCourseRewardTypeVO {
+    private String name;
+    private Integer value;
+    private BigDecimal expectedValue;
+    private String text;
+}