Merge branch 'feature-course' into dev

This commit is contained in:
2025-06-30 16:04:30 +08:00
33 changed files with 171 additions and 1204 deletions

View File

@ -1,145 +0,0 @@
package com.greenorange.promotion.controller.course;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.CommonRequest;
import com.greenorange.promotion.model.dto.courseChapter.CourseChapterAddRequest;
import com.greenorange.promotion.model.dto.courseChapter.CourseChapterQueryRequest;
import com.greenorange.promotion.model.dto.courseChapter.CourseChapterUpdateRequest;
import com.greenorange.promotion.model.entity.CourseChapter;
import com.greenorange.promotion.model.vo.courseChapter.CourseChapterVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.course.CourseChapterService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 课程章节 控制器
*/
@RestController
@RequestMapping("courseChapter")
@Slf4j
@Tag(name = "课程章节模块")
public class CourseChapterController {
@Resource
private CourseChapterService courseChapterService;
@Resource
private CommonService commonService;
/**
* web端管理员添加课程章节
* @param courseChapterAddRequest 课程章节添加请求体
* @return 是否添加成功
*/
@PostMapping("add")
@Operation(summary = "web端管理员添加课程章节", description = "参数课程章节添加请求体权限管理员方法名addCourseChapter")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "课程章节管理", content = "web端管理员添加课程章节")
public BaseResponse<Long> addCourseChapter(@Valid @RequestBody CourseChapterAddRequest courseChapterAddRequest) {
CourseChapter courseChapter = commonService.copyProperties(courseChapterAddRequest, CourseChapter.class);
courseChapterService.save(courseChapter);
return ResultUtils.success(courseChapter.getId());
}
/**
* web端管理员根据id修改课程章节信息
* @param courseChapterUpdateRequest 课程章节更新请求体
* @return 是否更新成功
*/
@PostMapping("update")
@Operation(summary = "web端管理员根据id修改课程章节", description = "参数课程章节更新请求体权限管理员方法名updateCourseChapter")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "课程章节管理", content = "web端管理员根据id修改课程章节信息")
public BaseResponse<Boolean> updateCourseChapter(@Valid @RequestBody CourseChapterUpdateRequest courseChapterUpdateRequest) {
CourseChapter courseChapter = commonService.copyProperties(courseChapterUpdateRequest, CourseChapter.class);
courseChapterService.updateById(courseChapter);
return ResultUtils.success(true);
}
/**
* web端管理员根据id删除课程章节
* @param commonRequest 课程章节删除请求体
* @return 是否删除成功
*/
@PostMapping("delete")
@Operation(summary = "web端管理员根据id删除课程章节", description = "参数课程章节删除请求体权限管理员方法名delCourseChapter")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "课程章节管理", content = "web端管理员根据id删除课程章节")
public BaseResponse<Boolean> delCourseChapter(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
courseChapterService.removeById(id);
return ResultUtils.success(true);
}
/**
* web端管理员批量删除课程章节
* @param commonBatchRequest 课程章节批量删除请求体
* @return 是否删除成功
*/
@PostMapping("delBatch")
@Operation(summary = "web端管理员批量删除课程章节", description = "参数课程章节批量删除请求体权限管理员方法名delBatchCourseChapter")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "课程章节管理", content = "web端管理员批量删除课程章节")
public BaseResponse<Boolean> delBatchCourseChapter(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
List<Long> ids = commonBatchRequest.getIds();
courseChapterService.removeByIds(ids);
return ResultUtils.success(true);
}
/**
* web端管理员根据id查询课程章节
* @param commonRequest 课程章节查询请求体
* @return 课程章节信息
*/
@PostMapping("queryById")
@Operation(summary = "web端管理员根据id查询课程章节", description = "参数课程章节查询请求体权限管理员方法名queryCourseChapterById")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "课程章节管理", content = "web端管理员根据id查询课程章节")
public BaseResponse<CourseChapterVO> queryCourseChapterById(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
CourseChapter courseChapter = courseChapterService.getById(id);
CourseChapterVO courseChapterVO = commonService.copyProperties(courseChapter, CourseChapterVO.class);
return ResultUtils.success(courseChapterVO);
}
/**
* Web端管理员根据课程id分页查询课程章节
* @param courseChapterQueryRequest 课程章节查询请求体
* @return 课程章节列表
*/
@PostMapping("page")
@Operation(summary = "Web端管理员根据课程id分页查询课程章节", description = "参数课程章节查询请求体权限管理员方法名listCourseChapterByPageByCourseId")
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "课程章节管理", content = "Web端管理员根据课程id分页查询课程章节")
public BaseResponse<Page<CourseChapterVO>> listCourseChapterByPageByCourseId(@Valid @RequestBody CourseChapterQueryRequest courseChapterQueryRequest) {
long current = courseChapterQueryRequest.getCurrent();
long pageSize = courseChapterQueryRequest.getPageSize();
QueryWrapper<CourseChapter> queryWrapper = courseChapterService.getQueryWrapper(courseChapterQueryRequest);
Page<CourseChapter> page = courseChapterService.page(new Page<>(current, pageSize), queryWrapper);
List<CourseChapter> courseChapterList = page.getRecords();
List<CourseChapterVO> courseChapterVOList = commonService.convertList(courseChapterList, CourseChapterVO.class);
Page<CourseChapterVO> voPage = new Page<>(current, pageSize);
voPage.setRecords(courseChapterVOList);
voPage.setPages(page.getPages());
voPage.setTotal(page.getTotal());
return ResultUtils.success(voPage);
}
}

View File

@ -10,7 +10,6 @@ import com.greenorange.promotion.common.BaseResponse;
import com.greenorange.promotion.common.ErrorCode;
import com.greenorange.promotion.common.ResultUtils;
import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.BusinessException;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.CommonBatchRequest;
import com.greenorange.promotion.model.dto.CommonRequest;
@ -19,16 +18,10 @@ import com.greenorange.promotion.model.dto.course.CourseAddRequest;
import com.greenorange.promotion.model.dto.course.CourseQueryRequest;
import com.greenorange.promotion.model.dto.course.CourseUpdateRequest;
import com.greenorange.promotion.model.entity.Course;
import com.greenorange.promotion.model.entity.CourseChapter;
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
import com.greenorange.promotion.model.entity.ProjectCommission;
import com.greenorange.promotion.model.vo.course.CourseCardVO;
import com.greenorange.promotion.model.vo.course.CourseDetailVO;
import com.greenorange.promotion.model.vo.course.CourseVO;
import com.greenorange.promotion.model.vo.courseChapter.CourseChapterVO;
import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.course.CourseChapterService;
import com.greenorange.promotion.service.course.CourseQrcodeApplyService;
import com.greenorange.promotion.service.course.CourseService;
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
import io.swagger.v3.oas.annotations.Operation;
@ -63,16 +56,9 @@ public class CourseController {
@Resource
private CommonService commonService;
@Resource
private CourseChapterService courseChapterService;
@Resource
private WechatGetQrcodeService wechatGetQrcodeService;
@Resource
private CourseQrcodeApplyService courseQrcodeApplyService;
/**
* 小程序端用户查看热门课程列表
@ -124,29 +110,10 @@ public class CourseController {
Long id = commonRequest.getId();
Course course = courseService.getById(id);
CourseDetailVO courseDetailVO = commonService.copyProperties(course, CourseDetailVO.class);
LambdaQueryWrapper<CourseChapter> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CourseChapter::getCourseId, id);
List<CourseChapter> courseChapterList = courseChapterService.list(lambdaQueryWrapper);
List<CourseChapterVO> courseChapterVOS = commonService.convertList(courseChapterList, CourseChapterVO.class);
courseDetailVO.setCourseChapters(courseChapterVOS);
return ResultUtils.success(courseDetailVO);
}
/**
* 小程序端用户生成课程推广码
* @param commonRequest 课程id
* @return 课程信息列表
*/
@PostMapping("generate/qrcode")
@Operation(summary = "小程序端用户生成课程推广码", description = "参数课程id权限管理员方法名miniGenerateQrcode")
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
@SysLog(title = "课程管理", content = "小程序端用户生成课程推广码")
public BaseResponse<String> miniGenerateQrcode(@Valid @RequestBody CommonRequest commonRequest, HttpServletRequest request) throws Exception {
String videoView = wechatGetQrcodeService.getWxCourseQrCode(commonRequest, request);
return ResultUtils.success(videoView);
}
/**
* 小程序端用户根据id查看课程基本信息
@ -165,24 +132,6 @@ public class CourseController {
}
/**
* 小程序端用户查看当前课程推广码
* @param commonRequest 课程id
* @return 课程推广码(view值)
*/
@PostMapping("verify")
@Operation(summary = "小程序端用户查看当前课程推广码", description = "参数课程id权限管理员方法名verifyIsApplyCourseQrcode")
@RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
@SysLog(title = "课程管理", content = "小程序端用户查看当前课程推广码")
public BaseResponse<String> verifyIsApplyCourseQrcode(@Valid @RequestBody CommonRequest commonRequest, HttpServletRequest request) {
Long userId = (Long) request.getAttribute("userId");
Long courseId = commonRequest.getId();
LambdaQueryWrapper<CourseQrcodeApply> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CourseQrcodeApply::getUserId, userId).eq(CourseQrcodeApply::getCourseId, courseId);
CourseQrcodeApply courseQrcodeApply = courseQrcodeApplyService.getOne(lambdaQueryWrapper);
ThrowUtils.throwIf(courseQrcodeApply == null, ErrorCode.OPERATION_ERROR, "当前用户尚未申请该课程的推广码");
return ResultUtils.success(courseQrcodeApply.getCourseQrcode());
}
@ -200,9 +149,6 @@ public class CourseController {
@RequiresPermission(mustRole = UserConstant.ADMIN_ROLE)
@SysLog(title = "课程管理", content = "web端管理员添加课程")
public BaseResponse<Long> addCourse(@Valid @RequestBody CourseAddRequest courseAddRequest) {
BigDecimal firstLevelRate = courseAddRequest.getFirstLevelRate();
BigDecimal secondLevelRate = courseAddRequest.getSecondLevelRate();
ThrowUtils.throwIf(firstLevelRate.compareTo(secondLevelRate) < 0, ErrorCode.PARAMS_ERROR, "一级佣金比例不能小于二级佣金比例");
Course course = commonService.copyProperties(courseAddRequest, Course.class);
courseService.save(course);
return ResultUtils.success(course.getId());
@ -235,9 +181,6 @@ public class CourseController {
public BaseResponse<Boolean> delCourse(@Valid @RequestBody CommonRequest commonRequest) {
Long id = commonRequest.getId();
courseService.removeById(id);
// 删除课程下的所有章节
LambdaQueryWrapper<CourseChapter> lambdaQueryWrapper = commonService.buildQueryWrapperByField(CourseChapter::getCourseId, id, courseChapterService);
courseChapterService.remove(lambdaQueryWrapper);
return ResultUtils.success(true);
}
@ -253,10 +196,6 @@ public class CourseController {
public BaseResponse<Boolean> delBatchCourse(@Valid @RequestBody CommonBatchRequest commonBatchRequest) {
List<Long> ids = commonBatchRequest.getIds();
courseService.removeByIds(ids);
// 批量删除课程下的所有章节
LambdaQueryWrapper<CourseChapter> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.in(CourseChapter::getCourseId, ids);
courseChapterService.remove(lambdaQueryWrapper);
return ResultUtils.success(true);
}

View File

@ -2,6 +2,7 @@ package com.greenorange.promotion.controller.projectSettlement;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.greenorange.promotion.annotation.RequiresPermission;
import com.greenorange.promotion.annotation.SysLog;
import com.greenorange.promotion.common.BaseResponse;
@ -11,7 +12,10 @@ import com.greenorange.promotion.constant.UserConstant;
import com.greenorange.promotion.exception.ThrowUtils;
import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyAddRequest;
import com.greenorange.promotion.model.dto.withdrawalApply.WithdrawalApplyQueryRequest;
import com.greenorange.promotion.model.entity.*;
import com.greenorange.promotion.model.entity.FundsChange;
import com.greenorange.promotion.model.entity.UserAccount;
import com.greenorange.promotion.model.entity.UserMainInfo;
import com.greenorange.promotion.model.entity.WithdrawalApply;
import com.greenorange.promotion.model.vo.fundsChange.FundsChangeVO;
import com.greenorange.promotion.model.vo.fundsChange.FundsItemVO;
import com.greenorange.promotion.model.vo.userAccount.UserAccountConditionVO;
@ -20,17 +24,15 @@ import com.greenorange.promotion.service.common.CommonService;
import com.greenorange.promotion.service.settle.FundsChangeService;
import com.greenorange.promotion.service.settle.UserAccountService;
import com.greenorange.promotion.service.settle.WithdrawalApplyService;
import com.greenorange.promotion.service.userInfo.UserInfoService;
import com.greenorange.promotion.service.userInfo.UserMainInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

View File

@ -65,19 +65,19 @@ public class WechatGetQrcodeController {
}
/**
* 微信小程序获取课程码
* @return
* @throws IOException
*/
@Hidden
@PostMapping("/get/course/qrcode")
@Operation(summary = "微信小程序获取课程码", description = "参数:无, 权限:所有人, 方法名getCourseQrcode")
// @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
public BaseResponse<String> getCourseQrcode(@Valid @RequestBody CommonRequest commonRequest, HttpServletRequest request) throws Exception {
String view = wechatGetQrcodeService.getWxCourseQrCode(commonRequest, request);
return ResultUtils.success(view);
}
// /**
// * 微信小程序获取课程码
// * @return
// * @throws IOException
// */
// @Hidden
// @PostMapping("/get/course/qrcode")
// @Operation(summary = "微信小程序获取课程码", description = "参数:无, 权限:所有人, 方法名getCourseQrcode")
//// @RequiresPermission(mustRole = UserConstant.DEFAULT_ROLE)
// public BaseResponse<String> getCourseQrcode(@Valid @RequestBody CommonRequest commonRequest, HttpServletRequest request) throws Exception {
// String view = wechatGetQrcodeService.getWxCourseQrCode(commonRequest, request);
// return ResultUtils.success(view);
// }

View File

@ -1,18 +0,0 @@
package com.greenorange.promotion.mapper;
import com.greenorange.promotion.model.entity.CourseChapter;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 35880
* @description 针对表【course_chapter(课程章节表)】的数据库操作Mapper
* @createDate 2025-06-23 18:30:28
* @Entity com.greenorange.promotion.model.entity.CourseChapter
*/
public interface CourseChapterMapper extends BaseMapper<CourseChapter> {
}

View File

@ -1,18 +0,0 @@
package com.greenorange.promotion.mapper;
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 35880
* @description 针对表【course_qrcode_apply(课程推广码申请表)】的数据库操作Mapper
* @createDate 2025-06-24 22:10:39
* @Entity com.greenorange.promotion.model.entity.CourseQrcodeApply
*/
public interface CourseQrcodeApplyMapper extends BaseMapper<CourseQrcodeApply> {
}

View File

@ -1,18 +0,0 @@
package com.greenorange.promotion.mapper;
import com.greenorange.promotion.model.entity.PromoRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author 35880
* @description 针对表【promo_record(推广记录表)】的数据库操作Mapper
* @createDate 2025-06-23 18:31:45
* @Entity com.greenorange.promotion.model.entity.PromoRecord
*/
public interface PromoRecordMapper extends BaseMapper<PromoRecord> {
}

View File

@ -19,12 +19,9 @@ import java.io.Serializable;
"name",
"type",
"detail",
"promoCodeDesc",
"image",
"originPrice",
"discountPrice",
"firstLevelRate",
"secondLevelRate",
"discountPrice"
})
public class CourseAddRequest implements Serializable {
@ -36,11 +33,11 @@ public class CourseAddRequest implements Serializable {
private String name;
/**
* 课程类别[考公考研,自媒体,财经]
* 课程类别[考公,财经]
*/
@NotBlank(message = "课程类别不能为空")
@EnumValue(enumClass = CourseTypeEnum.class)
@Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体")
@Schema(description = "课程类别[考公,财经]", example = "自媒体")
private String type;
/**
@ -50,13 +47,6 @@ public class CourseAddRequest implements Serializable {
@Schema(description = "课程概述(富文本)", example = "富文本")
private String detail;
/**
* 推广码说明(富文本)
*/
@NotBlank(message = "推广码说明(富文本)不能为空")
@Schema(description = "推广码说明(富文本)", example = "富文本")
private String promoCodeDesc;
/**
* 课程图片URL
*/
@ -78,20 +68,6 @@ public class CourseAddRequest implements Serializable {
@Schema(description = "折扣价格", example = "2499")
private BigDecimal discountPrice;
/**
* 一级佣金比例(%
*/
@DecimalMin(value = "0", message = "一级佣金比例不能小于0")
@Schema(description = "一级佣金比例(%", example = "10")
private BigDecimal firstLevelRate;
/**
* 二级佣金比例(%
*/
@DecimalMin(value = "0", message = "二级佣金比例不能小于0")
@Schema(description = "二级佣金比例(%", example = "5")
private BigDecimal secondLevelRate;
@Serial
private static final long serialVersionUID = 1L;

View File

@ -28,10 +28,10 @@ public class CourseQueryRequest extends PageRequest implements Serializable {
private String name;
/**
* 课程类别[考公考研,自媒体,财经]
* 课程类别[考公,财经]
*/
@EnumValue(enumClass = CourseTypeEnum.class)
@Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体")
@Schema(description = "课程类别[考公,财经]", example = "自媒体")
private String type;

View File

@ -22,13 +22,10 @@ import java.io.Serializable;
"name",
"type",
"detail",
"promoCodeDesc",
"image",
"originPrice",
"discountPrice",
"orderCount",
"firstLevelRate",
"secondLevelRate",
"orderCount"
})
public class CourseUpdateRequest implements Serializable {
@ -47,11 +44,11 @@ public class CourseUpdateRequest implements Serializable {
private String name;
/**
* 课程类别[考公考研,自媒体,财经]
* 课程类别[考公,财经]
*/
@NotBlank(message = "课程类别不能为空")
@EnumValue(enumClass = CourseTypeEnum.class)
@Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体")
@Schema(description = "课程类别[考公,财经]", example = "自媒体")
private String type;
/**
@ -61,13 +58,6 @@ public class CourseUpdateRequest implements Serializable {
@Schema(description = "课程概述(富文本)", example = "富文本")
private String detail;
/**
* 推广码说明(富文本)
*/
@NotBlank(message = "推广码说明(富文本)不能为空")
@Schema(description = "推广码说明(富文本)", example = "富文本")
private String promoCodeDesc;
/**
* 课程图片URL
*/
@ -95,20 +85,6 @@ public class CourseUpdateRequest implements Serializable {
@Schema(description = "已下单人数", example = "100")
private Integer orderCount;
/**
* 一级佣金比例(%
*/
@DecimalMin(value = "0.0", message = "一级佣金比例不能小于0")
@Schema(description = "一级佣金比例(%", example = "10")
private BigDecimal firstLevelRate;
/**
* 二级佣金比例(%
*/
@DecimalMin(value = "0.0", message = "二级佣金比例不能小于0")
@Schema(description = "二级佣金比例(%", example = "5")
private BigDecimal secondLevelRate;
@Serial
private static final long serialVersionUID = 1L;

View File

@ -1,67 +0,0 @@
package com.greenorange.promotion.model.dto.courseChapter;
import com.greenorange.promotion.annotation.EnumValue;
import com.greenorange.promotion.model.enums.PreviewPermissionEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.math.BigDecimal;
import java.io.Serial;
import java.io.Serializable;
/**
* 课程章节添加请求体
*/
@Data
@Schema(description = "课程章节添加请求体", requiredProperties = {
"name",
"duration",
"permissions",
"videoView",
"courseId",
})
public class CourseChapterAddRequest implements Serializable {
/**
* 章节名称
*/
@NotBlank(message = "章节名称不能为空")
@Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?")
private String name;
/**
* 章节时长(单位:秒)
*/
@Min(value = 0L, message = "章节时长不能小于0")
@Schema(description = "章节时长", example = "600")
private Long duration;
/**
* 试看权限[全集试看,部分试看,关闭,开启]
*/
@NotBlank(message = "试看权限不能为空")
@EnumValue(enumClass = PreviewPermissionEnum.class)
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
private String permissions;
/**
* 视频文件 view 值
*/
@NotBlank(message = "视频文件 view 值不能为空")
@Schema(description = "视频文件 view 值", example = "3E29KDS9")
private String videoView;
/**
* 所属课程ID
*/
@Min(value = 1L, message = "所属课程ID ID不能小于1")
@Schema(description = "所属课程ID", example = "1")
private Long courseId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -1,48 +0,0 @@
package com.greenorange.promotion.model.dto.courseChapter;
import com.greenorange.promotion.annotation.EnumValue;
import com.greenorange.promotion.model.enums.PreviewPermissionEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.math.BigDecimal;
import java.io.Serial;
import java.io.Serializable;
import com.greenorange.promotion.common.PageRequest;
/**
* 课程章节查询请求体,继承自分页请求 PageRequest
*/
@Data
@Schema(description = "课程章节查询请求体", requiredProperties = {"current", "pageSize"})
public class CourseChapterQueryRequest extends PageRequest implements Serializable {
/**
* 章节名称
*/
@Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?")
private String name;
/**
* 试看权限[全集试看,部分试看,关闭,开启]
*/
@EnumValue(enumClass = PreviewPermissionEnum.class)
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
private String permissions;
/**
* 课程id
*/
@NotNull(message = "课程id不能为null")
@Min(value = 1, message = "课程id不能小于1")
@Schema(description = "课程id", example = "1")
private Long courseId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -1,74 +0,0 @@
package com.greenorange.promotion.model.dto.courseChapter;
import com.greenorange.promotion.annotation.EnumValue;
import com.greenorange.promotion.model.enums.PreviewPermissionEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Min;
import lombok.Data;
import java.math.BigDecimal;
import java.io.Serial;
import java.io.Serializable;
/**
* 课程章节更新请求体
*/
@Data
@Schema(description = "课程章节更新请求体", requiredProperties = {
"id",
"name",
"duration",
"permissions",
"videoView",
"courseId",
})
public class CourseChapterUpdateRequest implements Serializable {
/**
* 章节ID
*/
@Min(value = 1L, message = "章节ID ID不能小于1")
@Schema(description = "章节ID", example = "1")
private Long id;
/**
* 章节名称
*/
@NotBlank(message = "章节名称不能为空")
@Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?")
private String name;
/**
* 章节时长(单位:秒)
*/
@Min(value = 0L, message = "章节时长不能小于0")
@Schema(description = "章节时长", example = "600")
private Long duration;
/**
* 试看权限[全集试看,部分试看,关闭,开启]
*/
@NotBlank(message = "试看权限不能为空")
@EnumValue(enumClass = PreviewPermissionEnum.class)
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
private String permissions;
/**
* 视频文件 view 值
*/
@NotBlank(message = "视频文件 view 值不能为空")
@Schema(description = "视频文件 view 值", example = "3E29KDS9")
private String videoView;
/**
* 所属课程ID
*/
@Min(value = 1L, message = "所属课程ID ID不能小于1")
@Schema(description = "所属课程ID", example = "1")
private Long courseId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -28,7 +28,7 @@ public class Course implements Serializable {
private String name;
/**
* 课程类别[考公考研,自媒体,财经]
* 课程类别[考公,财经]
*/
private String type;
@ -37,11 +37,6 @@ public class Course implements Serializable {
*/
private String detail;
/**
* 推广码说明(富文本)
*/
private String promoCodeDesc;
/**
* 课程图片URL
*/
@ -62,16 +57,6 @@ public class Course implements Serializable {
*/
private Integer orderCount;
/**
* 一级佣金比例(%
*/
private BigDecimal firstLevelRate;
/**
* 二级佣金比例(%
*/
private BigDecimal secondLevelRate;
/**
* 是否上架(true:上架false:下架)
*/

View File

@ -1,69 +0,0 @@
package com.greenorange.promotion.model.entity;
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 java.io.Serial;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 课程章节表
* @TableName course_chapter
*/
@TableName(value ="course_chapter")
@Data
public class CourseChapter implements Serializable {
/**
* 章节ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 章节名称
*/
private String name;
/**
* 章节时长(格式可自定义,如"00:10:00"
*/
private Long duration;
/**
* 试看权限[全集试看,部分试看,关闭,开启]
*/
private String permissions;
/**
* 视频文件 view 值
*/
private String videoView;
/**
* 所属课程ID
*/
private Long courseId;
/**
* 是否删除
*/
private Integer isDelete;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@Serial
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -1,63 +0,0 @@
package com.greenorange.promotion.model.entity;
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 java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 课程推广码申请表
* @TableName course_qrcode_apply
*/
@TableName(value ="course_qrcode_apply")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class CourseQrcodeApply implements Serializable {
/**
* 课程推广码申请id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 用户id
*/
private Long userId;
/**
* 课程id
*/
private Long courseId;
/**
* 课程推广码(view值)
*/
private String courseQrcode;
/**
* 是否删除
*/
private Integer isDelete;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -1,82 +0,0 @@
package com.greenorange.promotion.model.entity;
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 java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.Data;
/**
* 推广记录表
* @TableName promo_record
*/
@TableName(value ="promo_record")
@Data
public class PromoRecord implements Serializable {
/**
* 推广记录ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 被推广课程ID
*/
private Long courseId;
/**
* 下级用户ID
*/
private Long subUserId;
/**
* 下级用户昵称
*/
private String nickName;
/**
* 下级用户手机号
*/
private String phone;
/**
* 下级带给上级的收益
*/
private BigDecimal benefits;
/**
* 绑定时间(字符串格式)
*/
private String bindTime;
/**
* 推广类型
*/
private Object promoType;
/**
* 推广人上级用户ID
*/
private Long userId;
/**
* 是否删除
*/
private Integer isDelete;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

View File

@ -14,8 +14,7 @@ import java.util.stream.Collectors;
@Getter
public enum CourseTypeEnum implements BaseEnum {
KAOGONGKAOYAN("考公考研"),
ZIMEITI("自媒体"),
KAOGONG("考公"),
CAIJING("财经");
private final String value;

View File

@ -24,9 +24,9 @@ public class CourseCardVO implements Serializable {
private String name;
/**
* 课程类别[考公考研,自媒体,财经]
* 课程类别[考公,财经]
*/
@Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体")
@Schema(description = "课程类别[考公,财经]", example = "自媒体")
private String type;
/**

View File

@ -1,13 +1,11 @@
package com.greenorange.promotion.model.vo.course;
import com.greenorange.promotion.model.vo.courseChapter.CourseChapterVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
@Data
@ -27,9 +25,9 @@ public class CourseDetailVO implements Serializable {
private String name;
/**
* 课程类别[考公考研,自媒体,财经]
* 课程类别[考公,财经]
*/
@Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体")
@Schema(description = "课程类别[考公,财经]", example = "自媒体")
private String type;
/**
@ -38,12 +36,6 @@ public class CourseDetailVO implements Serializable {
@Schema(description = "课程概述(富文本)", example = "富文本")
private String detail;
/**
* 推广码说明(富文本)
*/
@Schema(description = "推广码说明(富文本)", example = "富文本")
private String promoCodeDesc;
/**
* 课程图片URL
*/
@ -62,12 +54,6 @@ public class CourseDetailVO implements Serializable {
@Schema(description = "折扣价格", example = "2499")
private BigDecimal discountPrice;
/**
* 课程章节
*/
@Schema(description = "课程章节")
private List<CourseChapterVO> courseChapters;
@Serial
private static final long serialVersionUID = 1L;

View File

@ -27,9 +27,9 @@ public class CourseVO implements Serializable {
private String name;
/**
* 课程类别[考公考研,自媒体,财经]
* 课程类别[考公,财经]
*/
@Schema(description = "课程类别[考公考研,自媒体,财经]", example = "自媒体")
@Schema(description = "课程类别[考公,财经]", example = "自媒体")
private String type;
/**
@ -38,12 +38,6 @@ public class CourseVO implements Serializable {
@Schema(description = "课程概述(富文本)", example = "富文本")
private String detail;
/**
* 推广码说明(富文本)
*/
@Schema(description = "推广码说明(富文本)", example = "富文本")
private String promoCodeDesc;
/**
* 课程图片URL
*/
@ -68,18 +62,6 @@ public class CourseVO implements Serializable {
@Schema(description = "已下单人数", example = "100")
private Integer orderCount;
/**
* 一级佣金比例(%
*/
@Schema(description = "一级佣金比例(%", example = "10")
private BigDecimal firstLevelRate;
/**
* 二级佣金比例(%
*/
@Schema(description = "二级佣金比例(%", example = "5")
private BigDecimal secondLevelRate;
/**
* 是否上架(true:上架false:下架)
*/

View File

@ -1,58 +0,0 @@
package com.greenorange.promotion.model.vo.courseChapter;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 课程章节 视图对象
*/
@Data
@Schema(description = "课程章节 视图对象")
public class CourseChapterVO implements Serializable {
/**
* 课程章节ID
*/
@Schema(description = "课程章节ID", example = "1")
private Long id;
/**
* 章节名称
*/
@Schema(description = "章节名称", example = "企业经营管理者为什么必须懂财务?")
private String name;
/**
* 章节时长(单位:秒)
*/
@Schema(description = "章节时长", example = "600")
private Long duration;
/**
* 试看权限[全集试看,部分试看,关闭,开启]
*/
@Schema(description = "试看权限[全集试看,部分试看,关闭,开启]", example = "全集试看")
private String permissions;
/**
* 视频文件 view 值
*/
@Schema(description = "视频文件 view 值", example = "3E29KDS9")
private String videoView;
/**
* 所属课程ID
*/
@Schema(description = "所属课程ID", example = "所属课程ID ID不能小于1")
private Long courseId;
@Serial
private static final long serialVersionUID = 1L;
}

View File

@ -1,20 +0,0 @@
package com.greenorange.promotion.service.course;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.greenorange.promotion.model.dto.courseChapter.CourseChapterQueryRequest;
import com.greenorange.promotion.model.entity.CourseChapter;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 35880
* @description 针对表【course_chapter(课程章节表)】的数据库操作Service
* @createDate 2025-06-23 18:30:28
*/
public interface CourseChapterService extends IService<CourseChapter> {
/**
* 获取查询条件
*/
QueryWrapper<CourseChapter> getQueryWrapper(CourseChapterQueryRequest courseChapterQueryRequest);
}

View File

@ -1,13 +0,0 @@
package com.greenorange.promotion.service.course;
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 35880
* @description 针对表【course_qrcode_apply(课程推广码申请表)】的数据库操作Service
* @createDate 2025-06-24 22:10:39
*/
public interface CourseQrcodeApplyService extends IService<CourseQrcodeApply> {
}

View File

@ -1,13 +0,0 @@
package com.greenorange.promotion.service.course;
import com.greenorange.promotion.model.entity.PromoRecord;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author 35880
* @description 针对表【promo_record(推广记录表)】的数据库操作Service
* @createDate 2025-06-23 18:31:45
*/
public interface PromoRecordService extends IService<PromoRecord> {
}

View File

@ -1,44 +0,0 @@
package com.greenorange.promotion.service.course.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.constant.CommonConstant;
import com.greenorange.promotion.model.dto.courseChapter.CourseChapterQueryRequest;
import com.greenorange.promotion.model.entity.CourseChapter;
import com.greenorange.promotion.service.course.CourseChapterService;
import com.greenorange.promotion.mapper.CourseChapterMapper;
import com.greenorange.promotion.utils.SqlUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
/**
* @author 35880
* @description 针对表【course_chapter(课程章节表)】的数据库操作Service实现
* @createDate 2025-06-23 18:30:28
*/
@Service
public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, CourseChapter>
implements CourseChapterService{
/**
* 获取查询条件
*/
@Override
public QueryWrapper<CourseChapter> getQueryWrapper(CourseChapterQueryRequest courseChapterQueryRequest) {
Long courseId = courseChapterQueryRequest.getCourseId();
String name = courseChapterQueryRequest.getName();
String permissions = courseChapterQueryRequest.getPermissions();
String sortField = courseChapterQueryRequest.getSortField();
String sortOrder = courseChapterQueryRequest.getSortOrder();
QueryWrapper<CourseChapter> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("courseId", courseId);
queryWrapper.eq(StringUtils.isNotBlank(name), "name", name);
queryWrapper.eq(StringUtils.isNotBlank(permissions), "permissions", permissions);
queryWrapper.orderBy(SqlUtils.validSortField(sortField), sortOrder.equals(CommonConstant.SORT_ORDER_ASC), sortField);
return queryWrapper;
}
}

View File

@ -1,22 +0,0 @@
package com.greenorange.promotion.service.course.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
import com.greenorange.promotion.service.course.CourseQrcodeApplyService;
import com.greenorange.promotion.mapper.CourseQrcodeApplyMapper;
import org.springframework.stereotype.Service;
/**
* @author 35880
* @description 针对表【course_qrcode_apply(课程推广码申请表)】的数据库操作Service实现
* @createDate 2025-06-24 22:10:39
*/
@Service
public class CourseQrcodeApplyServiceImpl extends ServiceImpl<CourseQrcodeApplyMapper, CourseQrcodeApply>
implements CourseQrcodeApplyService{
}

View File

@ -1,22 +0,0 @@
package com.greenorange.promotion.service.course.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.greenorange.promotion.model.entity.PromoRecord;
import com.greenorange.promotion.service.course.PromoRecordService;
import com.greenorange.promotion.mapper.PromoRecordMapper;
import org.springframework.stereotype.Service;
/**
* @author 35880
* @description 针对表【promo_record(推广记录表)】的数据库操作Service实现
* @createDate 2025-06-23 18:31:45
*/
@Service
public class PromoRecordServiceImpl extends ServiceImpl<PromoRecordMapper, PromoRecord>
implements PromoRecordService{
}

View File

@ -26,8 +26,8 @@ public interface WechatGetQrcodeService {
String getWxQrCode(String inviteCode) throws IOException;
/**
* 微信小程序获取课程码
*/
String getWxCourseQrCode(CommonRequest courseQrcodeAddRequest, HttpServletRequest request) throws Exception;
// /**
// * 微信小程序获取课程码
// */
// String getWxCourseQrCode(CommonRequest courseQrcodeAddRequest, HttpServletRequest request) throws Exception;
}

View File

@ -17,13 +17,10 @@ import com.greenorange.promotion.exception.BusinessException;
import com.greenorange.promotion.mapper.UserInfoMapper;
import com.greenorange.promotion.model.dto.CommonRequest;
import com.greenorange.promotion.model.entity.Course;
import com.greenorange.promotion.model.entity.CourseQrcodeApply;
import com.greenorange.promotion.model.entity.FileInfo;
import com.greenorange.promotion.model.entity.UserInfo;
import com.greenorange.promotion.service.course.CourseQrcodeApplyService;
import com.greenorange.promotion.service.course.CourseService;
import com.greenorange.promotion.service.file.FileInfoService;
import com.greenorange.promotion.service.userInfo.UserInfoService;
import com.greenorange.promotion.service.wechat.WechatGetQrcodeService;
import com.greenorange.promotion.utils.QRCodeUtil;
import io.swagger.v3.oas.annotations.media.Schema;
@ -74,15 +71,6 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
@Resource
private FileInfoService fileInfoService;
@Resource
private UserInfoMapper userInfoMapper;
@Resource
private CourseService courseService;
@Resource
private CourseQrcodeApplyService courseQrcodeApplyService;
/**
* 获取接口调用凭据
@ -207,138 +195,138 @@ public class WechatGetQrcodeServiceImpl implements WechatGetQrcodeService {
/**
* 微信小程序获取课程码
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String getWxCourseQrCode(CommonRequest commonRequest, HttpServletRequest request) throws Exception {
String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
if (accessToken == null) {
accessToken = this.getAccessToken().getAccess_token();
}
// 获取用户邀请码
Long userId = (Long) request.getAttribute("userId");
UserInfo userInfo = userInfoMapper.selectById(userId);
String invitationCode = userInfo.getInvitationCode();
// 获取课程信息
Long courseId = commonRequest.getId();
Course course = courseService.getById(courseId);
String courseTitle = course.getName();
String originalPrice = String.valueOf(course.getOriginPrice());
String discountPrice = String.valueOf(course.getDiscountPrice());
String discountText = "元券后价";
Map<String, Object> param = new HashMap<>();
param.put("page", "pages/loginModule/register/register");
param.put("scene", "invitationCode=" + invitationCode + "&courseId=" + courseId);
param.put("width", 430);
param.put("check_path", false);
param.put("env_version", "develop");
String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
String jsonParams = JSONUtil.toJsonStr(param);
byte[] responseBytes = HttpUtil.createPost(url)
.header("Content-Type", "application/json")
.body(jsonParams)
.execute()
.bodyBytes();
String FontType = "Microsoft YaHei UI";
int FontStyle = Font.PLAIN;
// 加载一张空白图像
String blankUrl = "https://img.picui.cn/free/2025/06/21/6856a072e9eea.png";
ImageCombiner combiner = new ImageCombiner(blankUrl, 341, 391, ZoomMode.WidthHeight, OutputFormat.PNG);
// 加载课程图片
String courseUrl = SystemConstant.FILE_COMMON_PREFIX + course.getImage();
BufferedImage courseImage = ImageIO.read(new URL(courseUrl));
// 将二维码数据转换为 BufferedImage
BufferedImage qrImage = ImageIO.read(new ByteArrayInputStream(responseBytes));
// 缩放图片(不失真)
Image scaledImage = qrImage.getScaledInstance(134, 134, Image.SCALE_SMOOTH);
BufferedImage resizedImage = new BufferedImage(134, 134, BufferedImage.TYPE_INT_RGB);
resizedImage.getGraphics().drawImage(scaledImage, 0, 0, null);
combiner.setQuality(1f);
// 将课程图片合并到组合器中
combiner.addImageElement(courseImage, 18, 16, 306, 158, ZoomMode.WidthHeight).setRoundCorner(5).setCenter(true);
// 将二维码图片合并到组合器中
combiner.addImageElement(resizedImage, 190, 240);
// 绘制文本
TextElement courseTitleElement = new TextElement(courseTitle, FontType, FontStyle, 18, 20, 186);
courseTitleElement.setColor(Color.decode("#323232"))
.setCenter(true)
.setAutoBreakLine(306);
combiner.addElement(courseTitleElement);
TextElement originalPriceElement = new TextElement(originalPrice, FontType, FontStyle, 24, 56, 275);
originalPriceElement.setColor(Color.decode("#8C8C8C")).setStrikeThrough(true);
combiner.addElement(originalPriceElement);
TextElement discountedPriceElement = new TextElement(discountPrice, FontType, Font.BOLD, 28, 31, 343);
discountedPriceElement.setColor(Color.decode("#F84947")).setBaseLine(BaseLine.Base).setSpace(0.01f);
combiner.addElement(discountedPriceElement);
TextElement discountedTextElement = new TextElement(discountText, FontType, FontStyle, 16, discountedPriceElement.getX() + discountedPriceElement.getWidth(), 341);
discountedTextElement.setColor(Color.decode("#F84947")).setBaseLine(BaseLine.Base);
combiner.addElement(discountedTextElement);
combiner.combine();
InputStream resultStream = combiner.getCombinedImageStream();
byte[] resultBytes = resultStream.readAllBytes();
// 创建上传目录,如果不存在
String biz = "default";
String fileName = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + "." + "png";
// 获取文件类型
String fileType = FileUtil.getSuffix(fileName);
// 获取view值
String view = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
File file = new File(uploadDir + fileName);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();// 如果路径不存在则创建
}
// 将文件上传到目标位置
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE)) {
bos.write(resultBytes);
} catch (IOException e) {
throw new BusinessException(ErrorCode.OPERATION_ERROR, "文件上传失败,失败原因:" + e.getMessage());
}
// 获取文件大小
Double fileSize = file.length() / 1024.0;
fileSize = Double.valueOf(String.format("%.2f", fileSize));
// 获取文件哈希值
InputStream inputStream = new FileInputStream(file);
String hashValue = DigestUtils.sha256Hex(inputStream);
// 保存文件
FileInfo fileInfo = FileInfo.builder()
.name(fileName)
.type(fileType)
.size(fileSize)
.fileView(view)
.biz(biz)
.hashValue(hashValue)
.build();
fileInfoService.save(fileInfo);
String viewValue = biz + "-" + view;
// 保存课程推广码申请记录
CourseQrcodeApply courseQrcodeApply = CourseQrcodeApply.builder()
.userId(userId)
.courseId(courseId)
.courseQrcode(viewValue)
.build();
courseQrcodeApplyService.save(courseQrcodeApply);
return viewValue;
}
//
// /**
// * 微信小程序获取课程码
// */
// @Override
// @Transactional(rollbackFor = Exception.class)
// public String getWxCourseQrCode(CommonRequest commonRequest, HttpServletRequest request) throws Exception {
// String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN_KEY);
// if (accessToken == null) {
// accessToken = this.getAccessToken().getAccess_token();
// }
// // 获取用户邀请码
// Long userId = (Long) request.getAttribute("userId");
// UserInfo userInfo = userInfoMapper.selectById(userId);
// String invitationCode = userInfo.getInvitationCode();
// // 获取课程信息
// Long courseId = commonRequest.getId();
// Course course = courseService.getById(courseId);
// String courseTitle = course.getName();
// String originalPrice = String.valueOf(course.getOriginPrice());
// String discountPrice = String.valueOf(course.getDiscountPrice());
// String discountText = "元券后价";
//
//
// Map<String, Object> param = new HashMap<>();
// param.put("page", "pages/loginModule/register/register");
// param.put("scene", "invitationCode=" + invitationCode + "&courseId=" + courseId);
// param.put("width", 430);
// param.put("check_path", false);
// param.put("env_version", "develop");
// String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken;
// String jsonParams = JSONUtil.toJsonStr(param);
// byte[] responseBytes = HttpUtil.createPost(url)
// .header("Content-Type", "application/json")
// .body(jsonParams)
// .execute()
// .bodyBytes();
//
// String FontType = "Microsoft YaHei UI";
// int FontStyle = Font.PLAIN;
//
// // 加载一张空白图像
// String blankUrl = "https://img.picui.cn/free/2025/06/21/6856a072e9eea.png";
// ImageCombiner combiner = new ImageCombiner(blankUrl, 341, 391, ZoomMode.WidthHeight, OutputFormat.PNG);
//
// // 加载课程图片
// String courseUrl = SystemConstant.FILE_COMMON_PREFIX + course.getImage();
// BufferedImage courseImage = ImageIO.read(new URL(courseUrl));
//
// // 将二维码数据转换为 BufferedImage
// BufferedImage qrImage = ImageIO.read(new ByteArrayInputStream(responseBytes));
//
// // 缩放图片(不失真)
// Image scaledImage = qrImage.getScaledInstance(134, 134, Image.SCALE_SMOOTH);
// BufferedImage resizedImage = new BufferedImage(134, 134, BufferedImage.TYPE_INT_RGB);
// resizedImage.getGraphics().drawImage(scaledImage, 0, 0, null);
//
// combiner.setQuality(1f);
//
// // 将课程图片合并到组合器中
// combiner.addImageElement(courseImage, 18, 16, 306, 158, ZoomMode.WidthHeight).setRoundCorner(5).setCenter(true);
// // 将二维码图片合并到组合器中
// combiner.addImageElement(resizedImage, 190, 240);
//
// // 绘制文本
// TextElement courseTitleElement = new TextElement(courseTitle, FontType, FontStyle, 18, 20, 186);
// courseTitleElement.setColor(Color.decode("#323232"))
// .setCenter(true)
// .setAutoBreakLine(306);
// combiner.addElement(courseTitleElement);
//
// TextElement originalPriceElement = new TextElement(originalPrice, FontType, FontStyle, 24, 56, 275);
// originalPriceElement.setColor(Color.decode("#8C8C8C")).setStrikeThrough(true);
// combiner.addElement(originalPriceElement);
//
// TextElement discountedPriceElement = new TextElement(discountPrice, FontType, Font.BOLD, 28, 31, 343);
// discountedPriceElement.setColor(Color.decode("#F84947")).setBaseLine(BaseLine.Base).setSpace(0.01f);
// combiner.addElement(discountedPriceElement);
//
// TextElement discountedTextElement = new TextElement(discountText, FontType, FontStyle, 16, discountedPriceElement.getX() + discountedPriceElement.getWidth(), 341);
// discountedTextElement.setColor(Color.decode("#F84947")).setBaseLine(BaseLine.Base);
// combiner.addElement(discountedTextElement);
//
// combiner.combine();
//
// InputStream resultStream = combiner.getCombinedImageStream();
// byte[] resultBytes = resultStream.readAllBytes();
// // 创建上传目录,如果不存在
// String biz = "default";
// String fileName = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789") + "." + "png";
// // 获取文件类型
// String fileType = FileUtil.getSuffix(fileName);
// // 获取view值
// String view = RandomStringUtils.random(8, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
// File file = new File(uploadDir + fileName);
// if (!file.getParentFile().exists()) {
// file.getParentFile().mkdirs();// 如果路径不存在则创建
// }
// // 将文件上传到目标位置
// try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE)) {
// bos.write(resultBytes);
// } catch (IOException e) {
// throw new BusinessException(ErrorCode.OPERATION_ERROR, "文件上传失败,失败原因:" + e.getMessage());
// }
//
// // 获取文件大小
// Double fileSize = file.length() / 1024.0;
// fileSize = Double.valueOf(String.format("%.2f", fileSize));
// // 获取文件哈希值
// InputStream inputStream = new FileInputStream(file);
// String hashValue = DigestUtils.sha256Hex(inputStream);
// // 保存文件
// FileInfo fileInfo = FileInfo.builder()
// .name(fileName)
// .type(fileType)
// .size(fileSize)
// .fileView(view)
// .biz(biz)
// .hashValue(hashValue)
// .build();
// fileInfoService.save(fileInfo);
//
// String viewValue = biz + "-" + view;
// // 保存课程推广码申请记录
// CourseQrcodeApply courseQrcodeApply = CourseQrcodeApply.builder()
// .userId(userId)
// .courseId(courseId)
// .courseQrcode(viewValue)
// .build();
// courseQrcodeApplyService.save(courseQrcodeApply);
// return viewValue;
// }

View File

@ -1,24 +0,0 @@
<?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.greenorange.promotion.mapper.CourseChapterMapper">
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.CourseChapter">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="duration" column="duration" jdbcType="VARCHAR"/>
<result property="permissions" column="permissions" jdbcType="OTHER"/>
<result property="videoView" column="videoView" jdbcType="VARCHAR"/>
<result property="courseId" column="courseId" jdbcType="BIGINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,name,duration,
permissions,videoView,courseId,
isDelete,createTime,updateTime
</sql>
</mapper>

View File

@ -1,20 +0,0 @@
<?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.greenorange.promotion.mapper.CourseQrcodeApplyMapper">
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.CourseQrcodeApply">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="userId" column="userId" jdbcType="BIGINT"/>
<result property="courseId" column="courseId" jdbcType="BIGINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,userId,courseId,
isDelete,createTime,updateTime
</sql>
</mapper>

View File

@ -1,28 +0,0 @@
<?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.greenorange.promotion.mapper.PromoRecordMapper">
<resultMap id="BaseResultMap" type="com.greenorange.promotion.model.entity.PromoRecord">
<id property="id" column="id" jdbcType="BIGINT"/>
<result property="courseId" column="courseId" jdbcType="BIGINT"/>
<result property="subUserId" column="subUserId" jdbcType="BIGINT"/>
<result property="nickName" column="nickName" jdbcType="VARCHAR"/>
<result property="phone" column="phone" jdbcType="VARCHAR"/>
<result property="benefits" column="benefits" jdbcType="DECIMAL"/>
<result property="bindTime" column="bindTime" jdbcType="VARCHAR"/>
<result property="promoType" column="promoType" jdbcType="OTHER"/>
<result property="userId" column="userId" jdbcType="BIGINT"/>
<result property="isDelete" column="isDelete" jdbcType="TINYINT"/>
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,courseId,subUserId,
nickName,phone,benefits,
bindTime,promoType,userId,
isDelete,createTime,updateTime
</sql>
</mapper>