ソースを参照

注释掉用户扣积分相关逻辑、新增音乐上传接口和查询接口

private_deployment
lrh 1年前
コミット
98629f03e4
9個のファイルの変更173行の追加83行の削除
  1. +29
    -6
      suimangCApi/src/main/java/com/iformall/controller/PhotoSpeakVideoController.java
  2. +12
    -8
      suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java
  3. +13
    -10
      suimangService/src/main/java/com/iformall/domain/po/sm/MusicInfo.java
  4. +4
    -0
      suimangService/src/main/java/com/iformall/mapper/MusicInfoServiceMapper.java
  5. +5
    -3
      suimangService/src/main/java/com/iformall/service/sm/MusicInfoService.java
  6. +40
    -5
      suimangService/src/main/java/com/iformall/service/sm/impl/MusicInfoServiceImpl.java
  7. +52
    -49
      suimangService/src/main/java/com/iformall/service/sm/impl/PhotoSpeakVideoServiceImpl.java
  8. +16
    -0
      suimangService/src/main/resources/mapper/MusicServiceMapper.xml
  9. +2
    -2
      suimangService/src/main/resources/mapper/UserCreateVideoNumMapper.xml

+ 29
- 6
suimangCApi/src/main/java/com/iformall/controller/PhotoSpeakVideoController.java ファイルの表示

@@ -6,11 +6,10 @@ import com.iformall.annotation.AuthIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
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.EnumaMouldPatchStatus;
import com.iformall.exception.MallinkException;
import com.iformall.service.sm.*;
import com.iformall.video.VideoFactory;
@@ -301,10 +300,34 @@ public class PhotoSpeakVideoController extends BaseController {

@AuthIgnore
@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("获取默认音乐")
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);
}

@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);
}

}

+ 12
- 8
suimangCApi/src/main/java/com/iformall/controller/WxUserGrantController.java ファイルの表示

@@ -365,10 +365,12 @@ public class WxUserGrantController extends BaseController {
// }
// if(isValidCode) {
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();
// } else {
// return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND);
@@ -413,10 +415,12 @@ public class WxUserGrantController extends BaseController {
// }
// if(isValidCode) {
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();
// } else {
// return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND);


+ 13
- 10
suimangService/src/main/java/com/iformall/domain/po/sm/MusicInfo.java ファイルの表示

@@ -4,31 +4,32 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
import java.io.Serializable;

import com.iformall.domain.po.base.TenantEntity;
import lombok.Data;


/**
* @Description
* @Author LRH
* @Date 2023-06-13
*/
@Data
@TableName("music_info" )
public class MusicInfo implements Serializable {

private static final long serialVersionUID = 6934358084213154592L;
public class MusicInfo extends TenantEntity {

/**
* 主键ID
*/
@TableId
private Integer id;
private Long id;

/**
* 音乐名称
*/
private String name;

private Long userId;

/**
* 类型(1、系统音乐,2、用户上传)
*/
private Integer type;

/**
* 音乐链接
*/
@@ -59,4 +60,6 @@ public class MusicInfo implements Serializable {
*/
private Integer isDel;

private String title;

}

+ 4
- 0
suimangService/src/main/java/com/iformall/mapper/MusicInfoServiceMapper.java ファイルの表示

@@ -3,6 +3,10 @@ package com.iformall.mapper;
import com.iformall.common.CommonMapper;
import com.iformall.domain.po.MallPermission;
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> {
List<MusicInfo> findList(MusicInfo record);
}

+ 5
- 3
suimangService/src/main/java/com/iformall/service/sm/MusicInfoService.java ファイルの表示

@@ -1,13 +1,15 @@
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.VoiceMaterial;

import java.util.List;

public interface MusicInfoService {

List<MusicInfo> music();

MusicInfo getById(Long voiceMaterialId);

PageInfo<MusicInfo> music(Integer pageNum, Integer pageSize, MusicInfo record);
ResultData saveOrUpdate(MusicInfo record);
}

+ 40
- 5
suimangService/src/main/java/com/iformall/service/sm/impl/MusicInfoServiceImpl.java ファイルの表示

@@ -1,15 +1,23 @@
package com.iformall.service.sm.impl;

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.VoiceMaterial;
import com.iformall.enums.EnumaMouldPatchStatus;
import com.iformall.mapper.MusicInfoServiceMapper;
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.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
@@ -19,13 +27,40 @@ public class MusicInfoServiceImpl implements MusicInfoService {
@Autowired
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
public MusicInfo getById(Long 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);
}
}

+ 52
- 49
suimangService/src/main/java/com/iformall/service/sm/impl/PhotoSpeakVideoServiceImpl.java ファイルの表示

@@ -219,20 +219,21 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService {
Integer sex = 1;
Double videoTime = null;//用户创建视频的时长

//TODO 关闭用户相关流程
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;
if(EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)){
@@ -253,7 +254,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService {
msg = "参数错误,未找到声音模板数据";
}

//判断用户时长是否够创建该视频
//获取视频时长
AiPreviewParam param = new AiPreviewParam();
if (StringUtils.isBlank(photoSpeakVideo.getPaperwork())){
msg = "未填写视频文案数据";
@@ -306,21 +307,23 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService {
this.saveOrUpdate(videoUpd);
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));

if(StringUtils.isBlank(voiceMouldSmId) && StringUtils.isBlank(voiceMaterialUrl)){
@@ -341,19 +344,19 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService {
double useCredit = 0;
//修改用户创建视频时间表
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);
}
@@ -398,14 +401,14 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService {

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);



+ 16
- 0
suimangService/src/main/resources/mapper/MusicServiceMapper.xml ファイルの表示

@@ -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>

+ 2
- 2
suimangService/src/main/resources/mapper/UserCreateVideoNumMapper.xml ファイルの表示

@@ -7,12 +7,12 @@
UPDATE user_create_video_num
<set>
<if test="type == 1">
residue_credits = #{createVideoNum.residueCredits} - #{useCredit},
-- residue_credits = #{createVideoNum.residueCredits} - #{useCredit},
create_num = #{createVideoNum.createNum} + 1,
create_all_time = #{createVideoNum.createAllTime} + #{time}
</if>
<if test="type == 2">
residue_credits = #{createVideoNum.residueCredits} + #{useCredit},
-- residue_credits = #{createVideoNum.residueCredits} + #{useCredit},
create_num = #{createVideoNum.createNum} - 1,
create_all_time = #{createVideoNum.createAllTime} - #{time}
</if>


読み込み中…
キャンセル
保存