@@ -6,11 +6,10 @@ import com.iformall.annotation.AuthIgnore; | |||||
import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
import com.iformall.domain.po.sm.MusicInfo; | |||||
import com.iformall.domain.po.sm.PhotoSpeakVideo; | |||||
import com.iformall.domain.po.sm.UserMouldVideo; | |||||
import com.iformall.domain.po.sm.VoiceInfo; | |||||
import com.iformall.domain.po.sm.*; | |||||
import com.iformall.enums.EnumMouldSendType; | |||||
import com.iformall.enums.EnumVideoStatus; | import com.iformall.enums.EnumVideoStatus; | ||||
import com.iformall.enums.EnumaMouldPatchStatus; | |||||
import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
import com.iformall.service.sm.*; | import com.iformall.service.sm.*; | ||||
import com.iformall.video.VideoFactory; | import com.iformall.video.VideoFactory; | ||||
@@ -301,10 +300,34 @@ public class PhotoSpeakVideoController extends BaseController { | |||||
@AuthIgnore | @AuthIgnore | ||||
@GetMapping(value = "/music") | @GetMapping(value = "/music") | ||||
@ApiImplicitParams({ | |||||
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||||
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||||
@ApiOperation("获取默认音乐") | @ApiOperation("获取默认音乐") | ||||
public ResultData music() { | |||||
List<MusicInfo> music = musicInfoService.music(); | |||||
public ResultData music(@ModelAttribute MusicInfo record, Integer pageNum, Integer pageSize) { | |||||
logger.debug("[" + getIpAddr() + "] UserMouldVideoController::userList"); | |||||
if (record == null) record = new MusicInfo(); | |||||
record.setUserId(getMemberId()); | |||||
record.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||||
PageInfo<MusicInfo> music = musicInfoService.music(pageNum, pageSize, record); | |||||
return new ResultData(music); | return new ResultData(music); | ||||
} | } | ||||
@ApiOperation("新增接口") | |||||
@PostMapping("save") | |||||
public ResultData save(@RequestBody MusicInfo record) { | |||||
logger.debug("[" + getIpAddr() + "] UserMouldVideoController::save"); | |||||
if (record == null) record = new MusicInfo(); | |||||
record.setType(EnumMouldSendType.build.getCode()); | |||||
record.setUserId(getMemberId()); | |||||
record.setUrl(record.getUrl()); | |||||
if (StringUtils.isBlank(record.getUrl())) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "素材为空"); | |||||
} | |||||
if (record.getTitle() == null) { | |||||
record.setTitle("用户自建"); | |||||
} | |||||
return musicInfoService.saveOrUpdate(record); | |||||
} | |||||
} | } |
@@ -365,10 +365,12 @@ public class WxUserGrantController extends BaseController { | |||||
// } | // } | ||||
// if(isValidCode) { | // if(isValidCode) { | ||||
basicInfo = wxCUserBasicInfoService.register(getTenantInfo(),phone,password); | basicInfo = wxCUserBasicInfoService.register(getTenantInfo(),phone,password); | ||||
Boolean aBoolean = userCreateVideoNumService.initializationUserCreateVideoNum(basicInfo.getId()); | |||||
if (!aBoolean){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "初始化创建视频时间表失败"); | |||||
} | |||||
//TODO 用户 | |||||
// Boolean aBoolean = userCreateVideoNumService.initializationUserCreateVideoNum(basicInfo.getId()); | |||||
// if (!aBoolean){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "初始化创建视频时间表失败"); | |||||
// } | |||||
return new ResultData(); | return new ResultData(); | ||||
// } else { | // } else { | ||||
// return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | // return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | ||||
@@ -413,10 +415,12 @@ public class WxUserGrantController extends BaseController { | |||||
// } | // } | ||||
// if(isValidCode) { | // if(isValidCode) { | ||||
basicInfo = wxCUserBasicInfoService.registerEmail(getTenantInfo(),email,password); | basicInfo = wxCUserBasicInfoService.registerEmail(getTenantInfo(),email,password); | ||||
Boolean aBoolean = userCreateVideoNumService.initializationUserCreateVideoNum(basicInfo.getId()); | |||||
if (!aBoolean){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "初始化创建视频时间表失败"); | |||||
} | |||||
//TODO 用户 | |||||
// Boolean aBoolean = userCreateVideoNumService.initializationUserCreateVideoNum(basicInfo.getId()); | |||||
// if (!aBoolean){ | |||||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "初始化创建视频时间表失败"); | |||||
// } | |||||
return new ResultData(); | return new ResultData(); | ||||
// } else { | // } else { | ||||
// return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | // return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | ||||
@@ -4,31 +4,32 @@ import com.baomidou.mybatisplus.annotation.TableId; | |||||
import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
import java.util.Date; | import java.util.Date; | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
import com.iformall.domain.po.base.TenantEntity; | |||||
import lombok.Data; | import lombok.Data; | ||||
/** | |||||
* @Description | |||||
* @Author LRH | |||||
* @Date 2023-06-13 | |||||
*/ | |||||
@Data | @Data | ||||
@TableName("music_info" ) | @TableName("music_info" ) | ||||
public class MusicInfo implements Serializable { | |||||
private static final long serialVersionUID = 6934358084213154592L; | |||||
public class MusicInfo extends TenantEntity { | |||||
/** | /** | ||||
* 主键ID | * 主键ID | ||||
*/ | */ | ||||
@TableId | |||||
private Integer id; | |||||
private Long id; | |||||
/** | /** | ||||
* 音乐名称 | * 音乐名称 | ||||
*/ | */ | ||||
private String name; | private String name; | ||||
private Long userId; | |||||
/** | |||||
* 类型(1、系统音乐,2、用户上传) | |||||
*/ | |||||
private Integer type; | |||||
/** | /** | ||||
* 音乐链接 | * 音乐链接 | ||||
*/ | */ | ||||
@@ -59,4 +60,6 @@ public class MusicInfo implements Serializable { | |||||
*/ | */ | ||||
private Integer isDel; | private Integer isDel; | ||||
private String title; | |||||
} | } |
@@ -3,6 +3,10 @@ package com.iformall.mapper; | |||||
import com.iformall.common.CommonMapper; | import com.iformall.common.CommonMapper; | ||||
import com.iformall.domain.po.MallPermission; | import com.iformall.domain.po.MallPermission; | ||||
import com.iformall.domain.po.sm.MusicInfo; | import com.iformall.domain.po.sm.MusicInfo; | ||||
import com.iformall.domain.po.sm.PersonPhoto; | |||||
import java.util.List; | |||||
public interface MusicInfoServiceMapper extends CommonMapper<MusicInfo, String> { | public interface MusicInfoServiceMapper extends CommonMapper<MusicInfo, String> { | ||||
List<MusicInfo> findList(MusicInfo record); | |||||
} | } |
@@ -1,13 +1,15 @@ | |||||
package com.iformall.service.sm; | package com.iformall.service.sm; | ||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.sm.MusicInfo; | import com.iformall.domain.po.sm.MusicInfo; | ||||
import com.iformall.domain.po.sm.VoiceMaterial; | |||||
import java.util.List; | import java.util.List; | ||||
public interface MusicInfoService { | public interface MusicInfoService { | ||||
List<MusicInfo> music(); | |||||
MusicInfo getById(Long voiceMaterialId); | MusicInfo getById(Long voiceMaterialId); | ||||
PageInfo<MusicInfo> music(Integer pageNum, Integer pageSize, MusicInfo record); | |||||
ResultData saveOrUpdate(MusicInfo record); | |||||
} | } |
@@ -1,15 +1,23 @@ | |||||
package com.iformall.service.sm.impl; | package com.iformall.service.sm.impl; | ||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
import com.github.pagehelper.PageHelper; | |||||
import com.github.pagehelper.PageInfo; | |||||
import com.iformall.common.IdWorker; | |||||
import com.iformall.common.ResultData; | |||||
import com.iformall.domain.po.sm.MusicInfo; | import com.iformall.domain.po.sm.MusicInfo; | ||||
import com.iformall.domain.po.sm.VoiceMaterial; | |||||
import com.iformall.enums.EnumaMouldPatchStatus; | |||||
import com.iformall.mapper.MusicInfoServiceMapper; | import com.iformall.mapper.MusicInfoServiceMapper; | ||||
import com.iformall.service.sm.MusicInfoService; | import com.iformall.service.sm.MusicInfoService; | ||||
import com.iformall.video.VideoFactory; | |||||
import com.iformall.video.entity.VideUploadResult; | |||||
import org.apache.commons.lang3.StringUtils; | |||||
import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.util.Date; | |||||
import java.util.List; | import java.util.List; | ||||
@Service | @Service | ||||
@@ -19,13 +27,40 @@ public class MusicInfoServiceImpl implements MusicInfoService { | |||||
@Autowired | @Autowired | ||||
private MusicInfoServiceMapper musicInfoServiceMapper; | private MusicInfoServiceMapper musicInfoServiceMapper; | ||||
@Override | |||||
public List<MusicInfo> music() { | |||||
return musicInfoServiceMapper.selectList(new LambdaQueryWrapper<MusicInfo>().eq(MusicInfo::getIsDel, 0)); | |||||
} | |||||
@Autowired | |||||
VideoFactory videoFactory; | |||||
@Autowired | |||||
String videoType; | |||||
@Override | @Override | ||||
public MusicInfo getById(Long voiceMaterialId) { | public MusicInfo getById(Long voiceMaterialId) { | ||||
return musicInfoServiceMapper.selectById(voiceMaterialId); | return musicInfoServiceMapper.selectById(voiceMaterialId); | ||||
} | } | ||||
@Override | |||||
public PageInfo<MusicInfo> music(Integer pageNum, Integer pageSize, MusicInfo record) { | |||||
return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> musicInfoServiceMapper.findList(record)); | |||||
} | |||||
@Override | |||||
public ResultData saveOrUpdate(MusicInfo record) { | |||||
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(record.getUrl()); | |||||
if (videoDetail.isSuccess() && StringUtils.isNotBlank(videoDetail.getDuration()) && !"0.0".equals(videoDetail.getDuration())) { | |||||
record.setTime(Long.valueOf(videoDetail.getDuration())); | |||||
record.setSize(videoDetail.getSize()); | |||||
} | |||||
Date now = new Date(); | |||||
if (record.getId() == null) { | |||||
record.setId(IdWorker.get().nextId()); | |||||
record.setCreateDate(now); | |||||
record.setUpdateDate(now); | |||||
musicInfoServiceMapper.insert(record); | |||||
} else { | |||||
record.setUpdateDate(now); | |||||
musicInfoServiceMapper.updateById(record); | |||||
} | |||||
return new ResultData(record); | |||||
} | |||||
} | } |
@@ -219,20 +219,21 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
Integer sex = 1; | Integer sex = 1; | ||||
Double videoTime = null;//用户创建视频的时长 | Double videoTime = null;//用户创建视频的时长 | ||||
//TODO 关闭用户相关流程 | |||||
UserCreateVideoNum videoNum = userCreateVideoNumService.queryInfoByUserId(photoSpeakVideo.getUserId()); | UserCreateVideoNum videoNum = userCreateVideoNumService.queryInfoByUserId(photoSpeakVideo.getUserId()); | ||||
if (videoNum == null) { | |||||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
videoUpd.setVideoMsg("用户没有创建视频时长"); | |||||
this.saveOrUpdate(videoUpd); | |||||
return new AsyncResult<>(0); | |||||
} else { | |||||
if (DateUtils.isDateAfter(String.valueOf(videoNum.getEffectiveDate()))) { | |||||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
videoUpd.setVideoMsg("有效期已到期"); | |||||
this.saveOrUpdate(videoUpd); | |||||
return new AsyncResult<>(0); | |||||
} | |||||
} | |||||
// if (videoNum == null) { | |||||
// videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
// videoUpd.setVideoMsg("用户没有创建视频时长"); | |||||
// this.saveOrUpdate(videoUpd); | |||||
// return new AsyncResult<>(0); | |||||
// } else { | |||||
// if (DateUtils.isDateAfter(String.valueOf(videoNum.getEffectiveDate()))) { | |||||
// videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
// videoUpd.setVideoMsg("有效期已到期"); | |||||
// this.saveOrUpdate(videoUpd); | |||||
// return new AsyncResult<>(0); | |||||
// } | |||||
// } | |||||
String voiceMaterialUrl = null; | String voiceMaterialUrl = null; | ||||
if(EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)){ | if(EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)){ | ||||
@@ -253,7 +254,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
msg = "参数错误,未找到声音模板数据"; | msg = "参数错误,未找到声音模板数据"; | ||||
} | } | ||||
//判断用户时长是否够创建该视频 | |||||
//获取视频时长 | |||||
AiPreviewParam param = new AiPreviewParam(); | AiPreviewParam param = new AiPreviewParam(); | ||||
if (StringUtils.isBlank(photoSpeakVideo.getPaperwork())){ | if (StringUtils.isBlank(photoSpeakVideo.getPaperwork())){ | ||||
msg = "未填写视频文案数据"; | msg = "未填写视频文案数据"; | ||||
@@ -306,21 +307,23 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
this.saveOrUpdate(videoUpd); | this.saveOrUpdate(videoUpd); | ||||
return new AsyncResult<>(0); | return new AsyncResult<>(0); | ||||
} | } | ||||
//TODO 关闭用户相关流程 | |||||
//获取套餐信息 | //获取套餐信息 | ||||
UserConsumptionPackage infoById = userConsumptionPackageService.getPackageInfoById(videoNum.getPackageId()); | |||||
if (infoById == null){ | |||||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
videoUpd.setVideoMsg("套餐信息不存在"); | |||||
this.saveOrUpdate(videoUpd); | |||||
return new AsyncResult<>(0); | |||||
} | |||||
//生成视频时长不能超过对应套餐的时长 | |||||
if (infoById.getChargeTime() < videoTime) { | |||||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
videoUpd.setVideoMsg("视频时长不能超过" + infoById.getChargeTime() + "s"); | |||||
this.saveOrUpdate(videoUpd); | |||||
return new AsyncResult<>(0); | |||||
} | |||||
// UserConsumptionPackage infoById = userConsumptionPackageService.getPackageInfoById(videoNum.getPackageId()); | |||||
// if (infoById == null){ | |||||
// videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
// videoUpd.setVideoMsg("套餐信息不存在"); | |||||
// this.saveOrUpdate(videoUpd); | |||||
// return new AsyncResult<>(0); | |||||
// } | |||||
// //生成视频时长不能超过对应套餐的时长 | |||||
// if (infoById.getChargeTime() < videoTime) { | |||||
// videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
// videoUpd.setVideoMsg("视频时长不能超过" + infoById.getChargeTime() + "s"); | |||||
// this.saveOrUpdate(videoUpd); | |||||
// return new AsyncResult<>(0); | |||||
// } | |||||
videoUpd.setVideoTime(String.valueOf(videoTime)); | videoUpd.setVideoTime(String.valueOf(videoTime)); | ||||
if(StringUtils.isBlank(voiceMouldSmId) && StringUtils.isBlank(voiceMaterialUrl)){ | if(StringUtils.isBlank(voiceMouldSmId) && StringUtils.isBlank(voiceMaterialUrl)){ | ||||
@@ -341,19 +344,19 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
double useCredit = 0; | double useCredit = 0; | ||||
//修改用户创建视频时间表 | //修改用户创建视频时间表 | ||||
if (flag) { | if (flag) { | ||||
//每秒消耗的积分 | |||||
double i = (double)( videoNum.getVideoPrice() / 60); | |||||
i = i < 1 ? 1.0 : i; //如果小于1 就直接取1 | |||||
//用户创建视频需要时积分 | |||||
useCredit = (videoTime * i); | |||||
//判断用户积分是否足够 | |||||
if (videoNum.getResidueCredits() < useCredit) { | |||||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
videoUpd.setVideoMsg("创建视频时长不足,请充值"); | |||||
this.saveOrUpdate(videoUpd); | |||||
return new AsyncResult<>(0); | |||||
} | |||||
useCredit = Math.round(useCredit); | |||||
// //每秒消耗的积分 | |||||
// double i = (double)( videoNum.getVideoPrice() / 60); | |||||
// i = i < 1 ? 1.0 : i; //如果小于1 就直接取1 | |||||
// //用户创建视频需要时积分 | |||||
// useCredit = (videoTime * i); | |||||
// //判断用户积分是否足够 | |||||
// if (videoNum.getResidueCredits() < useCredit) { | |||||
// videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
// videoUpd.setVideoMsg("创建视频时长不足,请充值"); | |||||
// this.saveOrUpdate(videoUpd); | |||||
// return new AsyncResult<>(0); | |||||
// } | |||||
// useCredit = Math.round(useCredit); | |||||
//如果时间够,就去减去相对应的数据 | //如果时间够,就去减去相对应的数据 | ||||
userCreateVideoNumService.addOrSubtractNumberOfTimes(1, videoNum, useCredit, videoTime); | userCreateVideoNumService.addOrSubtractNumberOfTimes(1, videoNum, useCredit, videoTime); | ||||
} | } | ||||
@@ -398,14 +401,14 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
videoUpd.setTitle(photoSpeakVideo.getTitle()); | videoUpd.setTitle(photoSpeakVideo.getTitle()); | ||||
UserCreditLog log = new UserCreditLog(); | |||||
log.setId(IdWorker.get().nextId()); | |||||
log.setUserId(photoSpeakVideo.getUserId()); | |||||
log.setCredits(-(float)useCredit); | |||||
log.setType(EnumLogType.PHOTO_SPEAK.getCode()); | |||||
log.setRemark(EnumLogType.PHOTO_SPEAK.getMessage()); | |||||
log.setVideoOrPhotoOrTalkId(videoUpd.getId()); | |||||
userCreditLogService.insertLog(log); | |||||
// UserCreditLog log = new UserCreditLog(); | |||||
// log.setId(IdWorker.get().nextId()); | |||||
// log.setUserId(photoSpeakVideo.getUserId()); | |||||
// log.setCredits(-(float)useCredit); | |||||
// log.setType(EnumLogType.PHOTO_SPEAK.getCode()); | |||||
// log.setRemark(EnumLogType.PHOTO_SPEAK.getMessage()); | |||||
// log.setVideoOrPhotoOrTalkId(videoUpd.getId()); | |||||
// userCreditLogService.insertLog(log); | |||||
this.uploadVideo(videoUpd); | this.uploadVideo(videoUpd); | ||||
@@ -0,0 +1,16 @@ | |||||
<?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.iformall.mapper.MusicInfoServiceMapper"> | |||||
<select id="findList" resultType="com.iformall.domain.po.sm.MusicInfo"> | |||||
SELECT id, update_date, size, name, time, is_del, url, create_date, user_id, type | |||||
FROM music_info | |||||
WHERE is_del = 0 | |||||
<if test="type == 1"> | |||||
and type = #{type} and userId = 0 | |||||
</if> | |||||
<if test="type == 2"> | |||||
and type = #{type} userId = #{userId} | |||||
</if> | |||||
</select> | |||||
</mapper> |
@@ -7,12 +7,12 @@ | |||||
UPDATE user_create_video_num | UPDATE user_create_video_num | ||||
<set> | <set> | ||||
<if test="type == 1"> | <if test="type == 1"> | ||||
residue_credits = #{createVideoNum.residueCredits} - #{useCredit}, | |||||
-- residue_credits = #{createVideoNum.residueCredits} - #{useCredit}, | |||||
create_num = #{createVideoNum.createNum} + 1, | create_num = #{createVideoNum.createNum} + 1, | ||||
create_all_time = #{createVideoNum.createAllTime} + #{time} | create_all_time = #{createVideoNum.createAllTime} + #{time} | ||||
</if> | </if> | ||||
<if test="type == 2"> | <if test="type == 2"> | ||||
residue_credits = #{createVideoNum.residueCredits} + #{useCredit}, | |||||
-- residue_credits = #{createVideoNum.residueCredits} + #{useCredit}, | |||||
create_num = #{createVideoNum.createNum} - 1, | create_num = #{createVideoNum.createNum} - 1, | ||||
create_all_time = #{createVideoNum.createAllTime} - #{time} | create_all_time = #{createVideoNum.createAllTime} - #{time} | ||||
</if> | </if> | ||||