@@ -146,6 +146,7 @@ public class PhotoSpeakVideoController extends BaseController { | |||
return photoSpeakVideoService.saveOrUpdate(record); | |||
} | |||
@AuthIgnore | |||
@ApiOperation("生成视频") | |||
@PostMapping("createVideo") | |||
public ResultData create(@RequestBody PhotoSpeakVideo record) { | |||
@@ -157,9 +158,9 @@ public class PhotoSpeakVideoController extends BaseController { | |||
logger.info("TEST--"+ JSONObject.toJSONString(mouldVideo)); | |||
if(mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())){ | |||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到用户数据"); | |||
} | |||
// if(mouldVideo == null || !mouldVideo.getUserId().equals(getMemberId())){ | |||
// return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到用户数据"); | |||
// } | |||
if(EnumVideoStatus.ing.getCode().equals(mouldVideo.getVideoStatus()) | |||
|| EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) | |||
@@ -12,6 +12,7 @@ import com.iformall.service.*; | |||
import com.iformall.service.cuser.CUserServiceFactory; | |||
import com.iformall.service.sm.InviteCodeInfoService; | |||
import com.iformall.service.sm.InviteCodeService; | |||
import com.iformall.service.sm.UserConsumptionPackageService; | |||
import com.iformall.service.sm.UserCreateVideoNumService; | |||
import com.iformall.utils.Constant; | |||
import com.iformall.utils.PasswordHelper; | |||
@@ -95,6 +96,9 @@ public class WxUserGrantController extends BaseController { | |||
@Autowired | |||
private InviteCodeInfoService inviteCodeInfoService; | |||
@Autowired | |||
private UserConsumptionPackageService userConsumptionPackageService; | |||
@AuthIgnore | |||
@ApiOperation("验证码") | |||
@GetMapping("/captcha.jpg") | |||
@@ -709,4 +713,12 @@ public class WxUserGrantController extends BaseController { | |||
return new ResultData(userBasicInfo); | |||
} | |||
@AuthIgnore | |||
@ApiOperation("套餐档次查询") | |||
@GetMapping("/getPackageInfo") | |||
public ResultData getPackageInfo() { | |||
logger.debug("[" + getIpAddr() + "] WxUserGrantController::getPackageInfo"); | |||
return new ResultData(userConsumptionPackageService.getPackageInfo()); | |||
} | |||
} |
@@ -109,29 +109,4 @@ public class PhotoSpeakSchedule { | |||
} | |||
} | |||
} | |||
/** | |||
* 统计用户创建视频成功的时长 | |||
*/ | |||
@Scheduled(cron = "0 */30 * * * *?") // 每半小时检查一次 | |||
public void userCreateVideoTimeSchedule() { | |||
List<PhotoSpeakVideo> videos = photoSpeakVideoService.getUploadSuccessList(); | |||
if (videos != null && videos.size() > 0) { | |||
HashMap<Long, Long> map = new HashMap<>(); | |||
for (PhotoSpeakVideo video : videos) { | |||
try { | |||
if (map.get(video.getUserId()) == null) { | |||
map.put(video.getUserId(), Long.parseLong(video.getVideoTime())); | |||
} else { | |||
Long time = map.get(video.getUserId()); | |||
map.put(video.getUserId(), Long.parseLong(video.getVideoTime()) + time); | |||
} | |||
} catch (Exception e) { | |||
logger.error("TtCouponVideoSchedule error.couponVideoSchedule:" + video.getId(), e); | |||
} | |||
} | |||
userCreateVideoNumService.uploadUserCreateVideoNum(map); | |||
} | |||
} | |||
} |
@@ -215,6 +215,10 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||
@io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") | |||
private Long operatorId; | |||
@TableField(exist = false) | |||
@io.swagger.annotations.ApiModelProperty(value="套餐类型(1、基础版,2、专业版,3、加强版)",name="packageType") | |||
private Integer packageType; | |||
public void protectInfos() { | |||
if(StringUtils.isNotBlank(this.password)) { | |||
setPassword("保密"); | |||
@@ -0,0 +1,112 @@ | |||
package com.iformall.domain.po.sm; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.util.Date; | |||
import java.io.Serializable; | |||
import lombok.Data; | |||
import java.math.BigDecimal; | |||
import java.util.List; | |||
/** | |||
* @Description | |||
* @Author LRH | |||
* @Date 2023-06-15 | |||
*/ | |||
@Data | |||
@TableName("user_consumption_package" ) | |||
public class UserConsumptionPackage implements Serializable { | |||
private static final long serialVersionUID = 7987400196899039170L; | |||
/** | |||
* 主键ID | |||
*/ | |||
@TableId | |||
private Integer id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 父租户ID | |||
*/ | |||
private String parentTenantId; | |||
/** | |||
* 套餐类型(1、基础版,2、专业版,3、加强版) | |||
*/ | |||
private Integer type; | |||
@TableField(exist = false) | |||
private String typeDesc; | |||
/** | |||
* 美元 | |||
*/ | |||
private BigDecimal dollar; | |||
/** | |||
* 人民币 | |||
*/ | |||
private BigDecimal rmb; | |||
/** | |||
* 积分 | |||
*/ | |||
private Integer credit; | |||
/** | |||
* 有效期时长(天) | |||
*/ | |||
private Integer validityDuration; | |||
/** | |||
* 邀请用户送的积分 | |||
*/ | |||
private Integer inviteUserCredit; | |||
/** | |||
* 照片说话单价(积分) | |||
*/ | |||
private Integer videoPrice; | |||
/** | |||
* ai生成照片单价(积分) | |||
*/ | |||
private Integer photoPrice; | |||
/** | |||
* 口播的单价(积分) | |||
*/ | |||
private Integer talkPrice; | |||
/** | |||
* 照片说话单价、口播的单价收费时长 | |||
*/ | |||
private Integer chargeTime; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private Date createDate; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date updateDate; | |||
/** | |||
* 是否删除1是0否 | |||
*/ | |||
private Integer isDel; | |||
/** | |||
* 详细配置信息 | |||
*/ | |||
@TableField(exist = false) | |||
List<UserPackageDetail> userPackageDetails; | |||
} |
@@ -1,77 +1,126 @@ | |||
package com.iformall.domain.po.sm; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.util.Date; | |||
import java.io.Serializable; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* @author LRH | |||
* @date Wed Jun 07 17:06:17 CST 2023 | |||
* @describe 用户创建视频时间表 | |||
* @Description | |||
* @Author LRH | |||
* @Date 2023-06-15 | |||
*/ | |||
@Data | |||
@TableName("user_create_video_num") | |||
@TableName("user_create_video_num" ) | |||
public class UserCreateVideoNum implements Serializable { | |||
private static final long serialVersionUID = 6845742086152117203L; | |||
/** | |||
* 主键ID | |||
*/ | |||
private static final long serialVersionUID = 4995993777308528646L; | |||
/** | |||
* 主键ID | |||
*/ | |||
@TableId | |||
private Long id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 父租户ID | |||
*/ | |||
private String parentTenantId; | |||
/** | |||
* 用户id(wx_c_user_basic_info.id) | |||
*/ | |||
private Long userId; | |||
/** | |||
* 剩余条数 | |||
*/ | |||
private Integer residueNum; | |||
/** | |||
* 总条数 | |||
*/ | |||
private Integer residueTotal; | |||
/** | |||
* 用户生成视频的个数 | |||
*/ | |||
private Integer createNum; | |||
/** | |||
* 用户生成视频的总时长(s) | |||
*/ | |||
private Long createAllTime; | |||
/** | |||
* 总时长(单位:s) | |||
*/ | |||
private Long totalTime; | |||
/** | |||
* 剩余时长(单位:s) | |||
*/ | |||
private Long residueTime; | |||
/** | |||
* 有效期 | |||
*/ | |||
private Date effectiveDate; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private Date createDate; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date updateDate; | |||
/** | |||
* 是否删除1是0否 | |||
*/ | |||
private long isDel; | |||
private Long id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 父租户ID | |||
*/ | |||
private String parentTenantId; | |||
/** | |||
* 用户id(wx_c_user_basic_info.id) | |||
*/ | |||
private Long userId; | |||
/** | |||
* 套餐id(user_consumption_package.id) | |||
*/ | |||
private Integer packageId; | |||
/** | |||
* 剩余条数 | |||
*/ | |||
private Integer residueNum; | |||
/** | |||
* 总条数 | |||
*/ | |||
private Integer residueTotal; | |||
/** | |||
* 用户生成视频的个数 | |||
*/ | |||
private Integer createNum; | |||
/** | |||
* 用户生成视频的总时长(s) | |||
*/ | |||
private float createAllTime; | |||
/** | |||
* 用户拥有总时长(单位:s) | |||
*/ | |||
private Long totalTime; | |||
/** | |||
* 用户剩余时长(单位:s) | |||
*/ | |||
private Long residueTime; | |||
/** | |||
* 有效期 | |||
*/ | |||
private Date effectiveDate; | |||
/** | |||
* 用户总积分 | |||
*/ | |||
private Integer userCredits; | |||
/** | |||
* 用户剩余积分 | |||
*/ | |||
private Integer residueCredits; | |||
/** | |||
* 邀请人送的基础积分(暂时默认每个档次都是10积分) | |||
*/ | |||
private Integer inviteBaseCredits; | |||
/** | |||
* 照片说话的单价/min | |||
*/ | |||
private Integer videoPrice; | |||
/** | |||
* ai生成照片的单价/min | |||
*/ | |||
private Integer photoPrice; | |||
/** | |||
* 生成口播的单价/min | |||
*/ | |||
private Integer talkPrice; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private Date createDate; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date updateDate; | |||
/** | |||
* 是否删除1是0否 | |||
*/ | |||
private Integer isDel; | |||
} |
@@ -0,0 +1,82 @@ | |||
package com.iformall.domain.po.sm; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.util.Date; | |||
import java.io.Serializable; | |||
import lombok.Data; | |||
/** | |||
* @Description | |||
* @Author LRH | |||
* @Date 2023-06-15 | |||
*/ | |||
@Data | |||
@TableName("user_credit_log" ) | |||
public class UserCreditLog implements Serializable { | |||
private static final long serialVersionUID = 8595480777599856051L; | |||
/** | |||
* 主键ID | |||
*/ | |||
@TableId | |||
private Long id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 父租户ID | |||
*/ | |||
private String parentTenantId; | |||
/** | |||
* 用户id(wx_c_user_basic_info.id) | |||
*/ | |||
private Long userId; | |||
/** | |||
* 视频id 或者 图片id 或者 口播id | |||
*/ | |||
private Integer videoOrPhotoOrTalkId; | |||
/** | |||
* 订单id | |||
*/ | |||
private Integer orderId; | |||
/** | |||
* 类型(1、注册,2、邀请新用户,3、套餐增加,4、照片说话,5、AI生成照片,6、口播) | |||
*/ | |||
private Integer type; | |||
/** | |||
* 积分加减情况 | |||
*/ | |||
private float credits; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remark; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private Date createDate; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date updateDate; | |||
/** | |||
* 是否删除1是0否 | |||
*/ | |||
private Integer isDel; | |||
} |
@@ -0,0 +1,124 @@ | |||
package com.iformall.domain.po.sm; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import java.util.Date; | |||
import java.io.Serializable; | |||
import lombok.Data; | |||
/** | |||
* @Description | |||
* @Author LRH | |||
* @Date 2023-06-16 | |||
*/ | |||
@Data | |||
@TableName("user_package_detail" ) | |||
public class UserPackageDetail implements Serializable { | |||
private static final long serialVersionUID = 8868339443558940187L; | |||
/** | |||
* 主键ID | |||
*/ | |||
@TableId | |||
private Integer id; | |||
/** | |||
* 租户ID | |||
*/ | |||
private String tenantId; | |||
/** | |||
* 父租户ID | |||
*/ | |||
private String parentTenantId; | |||
/** | |||
* 套餐类型(1、图片说话,2、口播) | |||
*/ | |||
private Integer detailType; | |||
@TableField(exist = false) | |||
private String detailTypeDesc; | |||
/** | |||
* 套餐id(user_consumption_package.id) | |||
*/ | |||
private Integer packageId; | |||
/** | |||
* 是否有水印(1-是,2-否) | |||
*/ | |||
private Integer watermark; | |||
@TableField(exist = false) | |||
private String watermarkDesc; | |||
/** | |||
* 语言(1:50+语言) | |||
*/ | |||
private Integer language; | |||
@TableField(exist = false) | |||
private String languageDesc; | |||
/** | |||
* 声音(1:400+声音) | |||
*/ | |||
private Integer sound; | |||
@TableField(exist = false) | |||
private String soundDesc; | |||
/** | |||
* 单个视频时长(s) | |||
*/ | |||
private Integer videoTime; | |||
/** | |||
* AI生成人像(1-是、2-否) | |||
*/ | |||
private Integer aiPortrait; | |||
@TableField(exist = false) | |||
private String aiPortraitDesc; | |||
/** | |||
* 照片唱歌(1-是、2-否) | |||
*/ | |||
private Integer photoSing; | |||
@TableField(exist = false) | |||
private String photoSingDesc; | |||
/** | |||
* AI生成脚本次数 | |||
*/ | |||
private Integer aiCreateTime; | |||
/** | |||
* 视频分辨率(1:720p、2:1080p) | |||
*/ | |||
private Integer resolutionRatio; | |||
@TableField(exist = false) | |||
private String resolutionRatioDesc; | |||
/** | |||
* 数字人模板(1-免费,2-VIP) | |||
*/ | |||
private Integer humanTemplate; | |||
@TableField(exist = false) | |||
private String humanTemplateDesc; | |||
/** | |||
* 创建时间 | |||
*/ | |||
private Date createDate; | |||
/** | |||
* 更新时间 | |||
*/ | |||
private Date updateDate; | |||
/** | |||
* 是否删除1是0否 | |||
*/ | |||
private Integer isDel; | |||
} |
@@ -1,14 +1,14 @@ | |||
package com.iformall.enums.sm; | |||
public enum EnumSmUserType { | |||
REGISTER(0, "注册用户"), | |||
INVITE(1, "邀请的用户"), | |||
PAY(2, "充钱用户"), | |||
VIP(3, "VIP用户"), | |||
; | |||
/** | |||
* 数字人模板 | |||
*/ | |||
public enum EnumHumanTemplateType { | |||
FREE(1, "免费"), | |||
VIP(2, "VIP"); | |||
public static EnumSmUserType getEnum(Integer code) { | |||
for (EnumSmUserType value : values()) { | |||
public static EnumHumanTemplateType getEnum(Integer code) { | |||
for (EnumHumanTemplateType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
@@ -19,7 +19,7 @@ public enum EnumSmUserType { | |||
private Integer code; | |||
private String message; | |||
EnumSmUserType(Integer code, String message) { | |||
EnumHumanTemplateType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.iformall.enums.sm; | |||
/** | |||
* 语言 | |||
*/ | |||
public enum EnumLanguageType { | |||
LANGUAGE(1, "50+语言"); | |||
public static EnumLanguageType getEnum(Integer code) { | |||
for (EnumLanguageType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
} | |||
return null; | |||
} | |||
private Integer code; | |||
private String message; | |||
EnumLanguageType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.iformall.enums.sm; | |||
/** | |||
* 日志类型 | |||
*/ | |||
public enum EnumLogType { | |||
REGISTER_USER(1, "注册"), | |||
INVITE_USER(2, "邀请新用户"), | |||
BUY_PACKAGE(3, "套餐增加"), | |||
PHOTO_SPEAK(4, "照片说话"), | |||
AI_PHOTO(5, "AI生成照片"), | |||
TALK(6, "口播"); | |||
public static EnumLogType getEnum(Integer code) { | |||
for (EnumLogType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
} | |||
return null; | |||
} | |||
private Integer code; | |||
private String message; | |||
EnumLogType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
package com.iformall.enums.sm; | |||
/** | |||
* 套餐详细类型 | |||
*/ | |||
public enum EnumPackageDetailType { | |||
PHOTO_SPEAK(1, "照片说话"), | |||
TALK(2, "口播"); | |||
public static EnumPackageDetailType getEnum(Integer code) { | |||
for (EnumPackageDetailType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
} | |||
return null; | |||
} | |||
private Integer code; | |||
private String message; | |||
EnumPackageDetailType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
package com.iformall.enums.sm; | |||
/** | |||
* 分辨率 | |||
*/ | |||
public enum EnumResolutionRatioType { | |||
RESOLUTION_RATIO_720P(1, "720p"), | |||
RESOLUTION_RATIO_1080P(2, "1080p"); | |||
public static EnumResolutionRatioType getEnum(Integer code) { | |||
for (EnumResolutionRatioType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
} | |||
return null; | |||
} | |||
private Integer code; | |||
private String message; | |||
EnumResolutionRatioType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
} |
@@ -0,0 +1,33 @@ | |||
package com.iformall.enums.sm; | |||
/** | |||
* 声音 | |||
*/ | |||
public enum EnumSoundType { | |||
SOUND(1, "400+声音"); | |||
public static EnumSoundType getEnum(Integer code) { | |||
for (EnumSoundType value : values()) { | |||
if (value.getCode().equals(code)) { | |||
return value; | |||
} | |||
} | |||
return null; | |||
} | |||
private Integer code; | |||
private String message; | |||
EnumSoundType(Integer code, String message) { | |||
this.code = code; | |||
this.message = message; | |||
} | |||
public Integer getCode() { | |||
return code; | |||
} | |||
public String getMessage() { | |||
return message; | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
package com.iformall.mapper; | |||
import com.iformall.common.CommonMapper; | |||
import com.iformall.domain.po.sm.UserConsumptionPackage; | |||
public interface UserConsumptionPackageMapper extends CommonMapper<UserConsumptionPackage, Long> { | |||
} |
@@ -7,5 +7,5 @@ import org.apache.ibatis.annotations.Param; | |||
public interface UserCreateVideoNumMapper extends CommonMapper<UserCreateVideoNum, String> { | |||
Boolean addOrSubtractNumberOfTimes(@Param("type") Integer type,@Param("createVideoNum") UserCreateVideoNum createVideoNum); | |||
Boolean addOrSubtractNumberOfTimes(@Param("type") Integer type, @Param("createVideoNum") UserCreateVideoNum createVideoNum, @Param("useCredit") Double useCredit, @Param("time") Double videoTime); | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.iformall.mapper; | |||
import com.iformall.common.CommonMapper; | |||
import com.iformall.domain.po.sm.UserConsumptionPackage; | |||
import com.iformall.domain.po.sm.UserCreditLog; | |||
public interface UserCreditLogMapper extends CommonMapper<UserCreditLog, Long> { | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.iformall.mapper; | |||
import com.iformall.common.CommonMapper; | |||
import com.iformall.domain.po.sm.UserCreditLog; | |||
import com.iformall.domain.po.sm.UserPackageDetail; | |||
public interface UserPackageDetailMapper extends CommonMapper<UserPackageDetail, Long> { | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.iformall.service.sm; | |||
import com.iformall.domain.po.sm.UserConsumptionPackage; | |||
import java.util.List; | |||
public interface UserConsumptionPackageService { | |||
UserConsumptionPackage getPackageInfoByType(Integer enumPackageType); | |||
List<UserConsumptionPackage> getPackageInfo(); | |||
UserConsumptionPackage getPackageInfoById(Integer id); | |||
} |
@@ -11,7 +11,7 @@ public interface UserCreateVideoNumService { | |||
Boolean initializationUserCreateVideoNum(Long id); | |||
Boolean addOrSubtractNumberOfTimes(Integer type, UserCreateVideoNum createVideoNum); | |||
Boolean addOrSubtractNumberOfTimes(Integer type, UserCreateVideoNum createVideoNum,Double useCredit,Double videoTime); | |||
UserCreateVideoNum queryInfoByUserId(Long userId); | |||
@@ -0,0 +1,8 @@ | |||
package com.iformall.service.sm; | |||
import com.iformall.domain.po.sm.UserCreditLog; | |||
public interface UserCreditLogService { | |||
void insertLog(UserCreditLog log); | |||
} |
@@ -0,0 +1,11 @@ | |||
package com.iformall.service.sm; | |||
import com.iformall.domain.po.sm.UserPackageDetail; | |||
import java.util.List; | |||
public interface UserPackageDetailService { | |||
List<UserPackageDetail> getDetailInfo(); | |||
} |
@@ -1,8 +0,0 @@ | |||
package com.iformall.service.sm; | |||
import com.iformall.domain.po.sm.UserTimeConfig; | |||
import io.swagger.models.auth.In; | |||
public interface UserTimeConfigService { | |||
UserTimeConfig getInfoByUerType(Integer i); | |||
} |
@@ -8,11 +8,15 @@ import com.iformall.common.ResultData; | |||
import com.iformall.domain.po.WxCUserBasicInfo; | |||
import com.iformall.domain.po.sm.InviteCode; | |||
import com.iformall.domain.po.sm.InviteCodeInfo; | |||
import com.iformall.domain.po.sm.UserCreateVideoNum; | |||
import com.iformall.domain.po.sm.UserCreditLog; | |||
import com.iformall.enums.sm.EnumLogType; | |||
import com.iformall.mapper.InviteCodeInfoMapper; | |||
import com.iformall.service.WxCUserBasicInfoService; | |||
import com.iformall.service.sm.InviteCodeInfoService; | |||
import com.iformall.service.sm.InviteCodeService; | |||
import com.iformall.service.sm.UserCreateVideoNumService; | |||
import com.iformall.service.sm.UserCreditLogService; | |||
import lombok.Data; | |||
import org.checkerframework.checker.units.qual.A; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -38,6 +42,9 @@ public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { | |||
@Autowired | |||
private UserCreateVideoNumService userCreateVideoNumService; | |||
@Autowired | |||
private UserCreditLogService userCreditLogService; | |||
/** | |||
* 使用邀请码 | |||
* | |||
@@ -73,7 +80,18 @@ public class InviteCodeInfoServiceImpl implements InviteCodeInfoService { | |||
//邀请码最多使用10次 | |||
if (info.getTotal() < 10){ | |||
inviteCodeService.addUseTotal(info.getId(), info.getTotal()); | |||
userCreateVideoNumService.inviteUserAddCreatTime(cUser.getId()); | |||
userCreateVideoNumService.inviteUserAddCreatTime(info.getId()); | |||
//根据用户id获取邀请的时候送多少积分 | |||
UserCreateVideoNum videoNum = userCreateVideoNumService.queryInfoByUserId(cUser.getId()); | |||
//插入日志信息 | |||
UserCreditLog log = new UserCreditLog(); | |||
log.setId(IdWorker.get().nextId()); | |||
log.setUserId(cUser.getId()); | |||
log.setCredits(videoNum.getInviteBaseCredits()); | |||
log.setType(EnumLogType.INVITE_USER.getCode()); | |||
log.setRemark(EnumLogType.INVITE_USER.getMessage()); | |||
userCreditLogService.insertLog(log); | |||
} | |||
return new ResultData(); | |||
} else { | |||
@@ -9,10 +9,13 @@ import com.iformall.common.IdWorker; | |||
import com.iformall.common.ResultData; | |||
import com.iformall.domain.po.sm.*; | |||
import com.iformall.enums.*; | |||
import com.iformall.enums.sm.EnumLogType; | |||
import com.iformall.enums.sm.EnumPackageType; | |||
import com.iformall.mapper.PhotoSpeakVideoMapper; | |||
import com.iformall.service.sm.*; | |||
import com.iformall.sm.*; | |||
import com.iformall.utils.Base64Util; | |||
import com.iformall.utils.DateUtils; | |||
import com.iformall.video.VideoFactory; | |||
import com.iformall.video.entity.VideUploadResult; | |||
import org.apache.commons.lang3.StringUtils; | |||
@@ -66,6 +69,12 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
@Autowired | |||
private MusicInfoService musicInfoService; | |||
@Autowired | |||
private UserConsumptionPackageService userConsumptionPackageService; | |||
@Autowired | |||
private UserCreditLogService userCreditLogService; | |||
private final static String str = "\uD83D\uDD57"; | |||
@Override | |||
@@ -181,20 +190,20 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
msg = "未查询到人物照片"; | |||
} else { | |||
personPhotoUrl = photoSpeakVideo.getPersonPhotoUrl(); | |||
PersonPhoto personPhotoInfo = personPhotoService.getById(photoSpeakVideo.getPersonPhotoId()); | |||
//如果是上传图片就去检验合法 | |||
if (EnumMouldSendType.build.getCode().equals(personPhotoInfo.getSendType())) { | |||
//校验图片是否合法 | |||
AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||
param.setImg(Base64Util.imageUrlToBase64(personPhotoUrl)); | |||
AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | |||
if (result.getCode() != 2000) { | |||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
videoUpd.setVideoMsg("图片质量审核失败:" + result.getMsg()); | |||
this.saveOrUpdate(videoUpd); | |||
return new AsyncResult<>(0); | |||
} | |||
} | |||
// PersonPhoto personPhotoInfo = personPhotoService.getById(photoSpeakVideo.getPersonPhotoId()); | |||
// //如果是上传图片就去检验合法 | |||
// if (EnumMouldSendType.build.getCode().equals(personPhotoInfo.getSendType())) { | |||
// //校验图片是否合法 | |||
// AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||
// param.setImg(Base64Util.imageUrlToBase64(personPhotoUrl)); | |||
// AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | |||
// if (result.getCode() != 2000) { | |||
// videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
// videoUpd.setVideoMsg("图片质量审核失败:" + result.getMsg()); | |||
// this.saveOrUpdate(videoUpd); | |||
// return new AsyncResult<>(0); | |||
// } | |||
// } | |||
} | |||
if(StringUtils.isBlank(personPhotoUrl)){ | |||
@@ -208,13 +217,23 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
String voiceMouldSmId = null; | |||
String voiceType = "default";//默认 | |||
Integer sex = 1; | |||
Long residueTime = 0L; | |||
Double videoTime = null;//用户创建视频的时长 | |||
UserCreateVideoNum videoNum = userCreateVideoNumService.queryInfoByUserId(photoSpeakVideo.getUserId()); | |||
if (videoNum == null) { | |||
msg = "没有创建视频时长"; | |||
}else { | |||
residueTime = videoNum.getResidueTime(); | |||
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)){ | |||
try{ | |||
@@ -233,6 +252,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
if(StringUtils.isBlank(voiceMouldSmId)){ | |||
msg = "参数错误,未找到声音模板数据"; | |||
} | |||
//判断用户时长是否够创建该视频 | |||
AiPreviewParam param = new AiPreviewParam(); | |||
if (StringUtils.isBlank(photoSpeakVideo.getPaperwork())){ | |||
@@ -244,9 +264,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
param.setVoice_style(voiceType); | |||
AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||
if (result.isSuccess()) { | |||
if (residueTime < result.getTime()) { | |||
msg = "创建视频时长不足,请充值"; | |||
} | |||
videoTime = result.getTime(); | |||
} | |||
}else if(EnumVoiceFrom.FROM_UPD.getCode().equals(voiceFrom)){ | |||
voiceMaterialUrl = photoSpeakVideo.getVoiceMaterialUrl(); | |||
@@ -259,31 +277,52 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
if(StringUtils.isBlank(voiceMaterialUrl)){ | |||
msg = "未找到上传声音文件"; | |||
} | |||
//判断用户时长是否够创建该视频 | |||
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(photoSpeakVideo.getVideoId()); | |||
if (videoDetail.isSuccess() && StringUtils.isNotBlank(videoDetail.getDuration()) && !"0.0".equals(videoDetail.getDuration())) { | |||
String duration = videoDetail.getDuration(); | |||
if (residueTime < Long.parseLong(duration)) { | |||
msg = "创建视频时长余额不足,请充值"; | |||
} | |||
videoTime = Double.valueOf(duration); | |||
} | |||
} else if (EnumVoiceFrom.MUSIC.getCode().equals(voiceFrom)) { | |||
Long musicId = photoSpeakVideo.getMusicId(); | |||
MusicInfo musicInfo = musicInfoService.getById(musicId); | |||
if (ObjectUtils.isEmpty(musicInfo)){ | |||
if (ObjectUtils.isEmpty(musicInfo)) { | |||
msg = "未找到音乐文件"; | |||
} | |||
voiceMaterialUrl = musicInfo.getUrl(); | |||
if (StringUtils.isBlank(voiceMaterialUrl)) { | |||
msg = "音乐文件错误"; | |||
} | |||
if (residueTime < musicInfo.getTime()) { | |||
msg ="创建视频时长余额不足,请充值"; | |||
} | |||
videoTime = Double.valueOf(musicInfo.getTime()); | |||
} else { | |||
msg = "声音数据异常"; | |||
} | |||
//判断获取创建的视频时长 | |||
if (videoTime == null){ | |||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
videoUpd.setVideoMsg("获取创建的视频时长失败"); | |||
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)){ | |||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
videoUpd.setVideoMsg(msg); | |||
@@ -299,25 +338,24 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
return new AsyncResult<>(0); | |||
} | |||
UserCreateVideoNum createVideoNum = new UserCreateVideoNum(); | |||
double useCredit = 0; | |||
//修改用户创建视频时间表 | |||
if (flag) { | |||
//修改用户生成视频次数 | |||
createVideoNum = userCreateVideoNumService.queryInfoByUserId(photoSpeakVideo.getUserId()); | |||
if (ObjectUtils.isEmpty(createVideoNum)) { | |||
return new AsyncResult<>("生成视频"); | |||
} else { | |||
//剩余条数 | |||
Integer residueNum = createVideoNum.getResidueNum(); | |||
if (residueNum.intValue() <= 0) { | |||
return new AsyncResult<>("剩余生成视频次数不足"); | |||
} else { | |||
//减去生成视频次数 | |||
Boolean times = userCreateVideoNumService.addOrSubtractNumberOfTimes(1, createVideoNum); | |||
if (!times) { | |||
return new AsyncResult<>("剩余生成视频次数不足"); | |||
} | |||
} | |||
//每秒消耗的积分 | |||
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); | |||
} | |||
try { | |||
@@ -359,6 +397,15 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
this.saveOrUpdate(videoUpd); | |||
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()); | |||
userCreditLogService.insertLog(log); | |||
this.uploadVideo(videoUpd); | |||
return new AsyncResult<>(1); | |||
@@ -368,16 +415,16 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||
this.saveOrUpdate(videoUpd); | |||
if (flag) { | |||
//如果生成视频失败了,就把创建视频的次数加回去 | |||
userCreateVideoNumService.addOrSubtractNumberOfTimes(2, createVideoNum); | |||
//如果生成视频失败了,就把创建视频积分加回去 | |||
userCreateVideoNumService.addOrSubtractNumberOfTimes(2, videoNum, useCredit, videoTime); | |||
} | |||
return new AsyncResult<>(0); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
if (flag) { | |||
//如果生成视频失败了,就把创建视频的次数加回去 | |||
userCreateVideoNumService.addOrSubtractNumberOfTimes(2, createVideoNum); | |||
//如果生成视频失败了,就把创建视频积分加回去 | |||
userCreateVideoNumService.addOrSubtractNumberOfTimes(2, videoNum, useCredit, videoTime); | |||
} | |||
videoUpd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||
videoUpd.setVideoMsg("请求异常"); | |||
@@ -0,0 +1,78 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.iformall.domain.po.sm.UserConsumptionPackage; | |||
import com.iformall.domain.po.sm.UserPackageDetail; | |||
import com.iformall.enums.EnumLanguages; | |||
import com.iformall.enums.EnumYesOrNo; | |||
import com.iformall.enums.sm.*; | |||
import com.iformall.mapper.UserConsumptionPackageMapper; | |||
import com.iformall.service.sm.UserConsumptionPackageService; | |||
import com.iformall.service.sm.UserPackageDetailService; | |||
import org.apache.commons.collections.CollectionUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@Service | |||
public class UserConsumptionPackageImpl implements UserConsumptionPackageService { | |||
@Autowired | |||
private UserConsumptionPackageMapper userConsumptionPackageMapper; | |||
@Autowired | |||
private UserPackageDetailService userPackageDetailService; | |||
@Override | |||
public UserConsumptionPackage getPackageInfoByType(Integer packageType) { | |||
return userConsumptionPackageMapper | |||
.selectOne(new LambdaQueryWrapper<UserConsumptionPackage>() | |||
.eq(UserConsumptionPackage::getIsDel, 0) | |||
.eq(UserConsumptionPackage::getType, packageType)); | |||
} | |||
@Override | |||
public UserConsumptionPackage getPackageInfoById(Integer id) { | |||
return userConsumptionPackageMapper | |||
.selectOne(new LambdaQueryWrapper<UserConsumptionPackage>() | |||
.eq(UserConsumptionPackage::getIsDel, 0) | |||
.eq(UserConsumptionPackage::getId, id)); | |||
} | |||
@Override | |||
public List<UserConsumptionPackage> getPackageInfo() { | |||
List<UserConsumptionPackage> consumptionPackages = userConsumptionPackageMapper.selectList(new LambdaQueryWrapper<UserConsumptionPackage>().eq(UserConsumptionPackage::getIsDel, 0)); | |||
List<UserPackageDetail> detailInfo = userPackageDetailService.getDetailInfo(); | |||
if (CollectionUtils.isEmpty(consumptionPackages) || CollectionUtils.isEmpty(detailInfo)) { | |||
return consumptionPackages; | |||
} | |||
for (UserConsumptionPackage consumptionPackage : consumptionPackages) { | |||
consumptionPackage.setTypeDesc(EnumPackageType.getEnum(consumptionPackage.getType()).getMessage()); | |||
List<UserPackageDetail> list = new ArrayList<>(); | |||
for (UserPackageDetail detail : detailInfo) { | |||
if (consumptionPackage.getId().equals(detail.getPackageId())) { | |||
detail.setDetailTypeDesc(EnumPackageDetailType.getEnum(detail.getDetailType()).getMessage()); | |||
detail.setWatermarkDesc(EnumYesOrNo.getEnum(detail.getWatermark()).getMessage()); | |||
detail.setLanguageDesc(EnumLanguageType.getEnum(detail.getLanguage()).getMessage()); | |||
detail.setSoundDesc(EnumSoundType.getEnum(detail.getSound()).getMessage()); | |||
detail.setResolutionRatioDesc(EnumResolutionRatioType.getEnum(detail.getResolutionRatio()).getMessage()); | |||
if (detail.getDetailType().equals(EnumPackageDetailType.PHOTO_SPEAK.getCode())) { | |||
detail.setAiPortraitDesc(EnumYesOrNo.getEnum(detail.getAiPortrait()).getMessage()); | |||
detail.setPhotoSingDesc(EnumYesOrNo.getEnum(detail.getPhotoSing()).getMessage()); | |||
} | |||
if (detail.getDetailType().equals(EnumPackageDetailType.TALK.getCode())) { | |||
detail.setHumanTemplateDesc(EnumHumanTemplateType.getEnum(detail.getHumanTemplate()).getMessage()); | |||
} | |||
list.add(detail); | |||
} | |||
} | |||
consumptionPackage.setUserPackageDetails(list); | |||
} | |||
return consumptionPackages; | |||
} | |||
} |
@@ -4,12 +4,16 @@ package com.iformall.service.sm.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
import com.iformall.common.IdWorker; | |||
import com.iformall.domain.po.sm.UserConsumptionPackage; | |||
import com.iformall.domain.po.sm.UserCreateVideoNum; | |||
import com.iformall.domain.po.sm.UserTimeConfig; | |||
import com.iformall.enums.sm.EnumSmUserType; | |||
import com.iformall.domain.po.sm.UserCreditLog; | |||
import com.iformall.enums.sm.EnumLogType; | |||
import com.iformall.enums.sm.EnumPackageType; | |||
import com.iformall.mapper.UserCreateVideoNumMapper; | |||
import com.iformall.service.sm.UserConsumptionPackageService; | |||
import com.iformall.service.sm.UserCreateVideoNumService; | |||
import com.iformall.service.sm.UserTimeConfigService; | |||
import com.iformall.service.sm.UserCreditLogService; | |||
import com.iformall.utils.DateUtils; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -28,7 +32,10 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
private UserCreateVideoNumMapper userCreateVideoNumMapper; | |||
@Autowired | |||
private UserTimeConfigService userTimeConfigService; | |||
private UserConsumptionPackageService userConsumptionPackageService; | |||
@Autowired | |||
private UserCreditLogService userCreditLogService; | |||
/** | |||
* 初始化注册用户创建视频的时长 | |||
@@ -39,30 +46,55 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
* @date: 2023/6/8 10:23 | |||
*/ | |||
public Boolean initializationUserCreateVideoNum(Long id) { | |||
UserTimeConfig uerType = userTimeConfigService.getInfoByUerType(EnumSmUserType.REGISTER.getCode()); | |||
//注册即送最基础版的积分 | |||
UserConsumptionPackage packageInfo = userConsumptionPackageService.getPackageInfoByType(EnumPackageType.BASIC.getCode()); | |||
UserCreateVideoNum createVideoNum = new UserCreateVideoNum(); | |||
if (!ObjectUtils.isEmpty(uerType)){ | |||
if (!ObjectUtils.isEmpty(packageInfo)) { | |||
createVideoNum.setId(IdWorker.get().nextId()); | |||
createVideoNum.setUserId(id); | |||
createVideoNum.setTotalTime(uerType.getTime());//用户拥有总时长(单位:s) | |||
createVideoNum.setResidueTime(uerType.getTime());//用户剩余时长(单位:s) | |||
// createVideoNum.setEffectiveDate();//TODO 有效期 | |||
//有效期 | |||
createVideoNum.setEffectiveDate(DateUtils.getTimeAfterDays(packageInfo.getValidityDuration(), new Date())); | |||
//积分 | |||
createVideoNum.setUserCredits(packageInfo.getCredit()); | |||
createVideoNum.setResidueCredits(packageInfo.getCredit()); | |||
createVideoNum.setInviteBaseCredits(packageInfo.getInviteUserCredit()); | |||
createVideoNum.setVideoPrice(packageInfo.getVideoPrice()); | |||
createVideoNum.setPhotoPrice(packageInfo.getPhotoPrice()); | |||
createVideoNum.setTalkPrice(packageInfo.getTalkPrice()); | |||
//插入类型 | |||
createVideoNum.setPackageId(packageInfo.getId()); | |||
Date date = new Date(); | |||
createVideoNum.setCreateDate(date); | |||
createVideoNum.setUpdateDate(date); | |||
createVideoNum.setIsDel(0); | |||
//插入日志信息 | |||
UserCreditLog log = new UserCreditLog(); | |||
log.setId(IdWorker.get().nextId()); | |||
log.setUserId(id); | |||
log.setCredits(packageInfo.getCredit()); | |||
log.setType(EnumLogType.REGISTER_USER.getCode()); | |||
log.setRemark(EnumLogType.REGISTER_USER.getMessage()); | |||
userCreditLogService.insertLog(log); | |||
return userCreateVideoNumMapper.insert(createVideoNum) > 0; | |||
} | |||
return userCreateVideoNumMapper.insert(createVideoNum) > 0; | |||
return false; | |||
} | |||
@Override | |||
public Boolean addOrSubtractNumberOfTimes(Integer type, UserCreateVideoNum createVideoNum) { | |||
return userCreateVideoNumMapper.addOrSubtractNumberOfTimes(type,createVideoNum); | |||
public Boolean addOrSubtractNumberOfTimes(Integer type, UserCreateVideoNum createVideoNum, Double useCredit, Double videoTime) { | |||
return userCreateVideoNumMapper.addOrSubtractNumberOfTimes(type, createVideoNum, useCredit, videoTime); | |||
} | |||
@Override | |||
public UserCreateVideoNum queryInfoByUserId(Long userId) { | |||
return userCreateVideoNumMapper.selectOne(new LambdaQueryWrapper<UserCreateVideoNum>().eq(UserCreateVideoNum::getIsDel,0).eq(UserCreateVideoNum::getUserId, userId)); | |||
return userCreateVideoNumMapper | |||
.selectOne(new LambdaQueryWrapper<UserCreateVideoNum>() | |||
.eq(UserCreateVideoNum::getIsDel, 0) | |||
.eq(UserCreateVideoNum::getUserId, userId)); | |||
} | |||
@Override | |||
@@ -73,8 +105,8 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
videoNum.setCreateAllTime(entry.getValue()); | |||
userCreateVideoNumMapper.update(videoNum, | |||
new LambdaUpdateWrapper<UserCreateVideoNum>() | |||
.eq(UserCreateVideoNum::getIsDel, 0) | |||
.eq(UserCreateVideoNum::getUserId, entry.getKey())); | |||
.eq(UserCreateVideoNum::getIsDel, 0) | |||
.eq(UserCreateVideoNum::getUserId, entry.getKey())); | |||
} | |||
} | |||
@@ -84,11 +116,9 @@ public class UserCreateVideoNumServiceImpl implements UserCreateVideoNumService | |||
@Override | |||
public void inviteUserAddCreatTime(Long id) { | |||
UserCreateVideoNum videoNum = queryInfoByUserId(id); | |||
UserTimeConfig uerType = userTimeConfigService.getInfoByUerType(EnumSmUserType.REGISTER.getCode()); | |||
if (!ObjectUtils.isEmpty(uerType)){ | |||
videoNum.setTotalTime(videoNum.getTotalTime() + uerType.getTime()); | |||
if (!ObjectUtils.isEmpty(videoNum)) { | |||
videoNum.setUserCredits(videoNum.getUserCredits() + videoNum.getInviteBaseCredits()); | |||
userCreateVideoNumMapper.updateById(videoNum); | |||
} | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.iformall.domain.po.sm.UserCreditLog; | |||
import com.iformall.mapper.UserCreditLogMapper; | |||
import com.iformall.service.sm.UserCreditLogService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Service | |||
public class UserCreditLogServiceImpl implements UserCreditLogService { | |||
@Autowired | |||
private UserCreditLogMapper userCreditLogMapper; | |||
@Override | |||
public void insertLog(UserCreditLog log) { | |||
userCreditLogMapper.insert(log); | |||
} | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.iformall.domain.po.sm.UserPackageDetail; | |||
import com.iformall.mapper.UserPackageDetailMapper; | |||
import com.iformall.service.sm.UserPackageDetailService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
@Service | |||
public class UserPackageDetailServiceImpl implements UserPackageDetailService { | |||
@Autowired | |||
private UserPackageDetailMapper userPackageDetailMapper; | |||
@Override | |||
public List<UserPackageDetail> getDetailInfo() { | |||
return userPackageDetailMapper.selectList(new LambdaQueryWrapper<UserPackageDetail>().eq(UserPackageDetail::getIsDel, 0)); | |||
} | |||
} |
@@ -1,21 +0,0 @@ | |||
package com.iformall.service.sm.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.iformall.domain.po.sm.UserTimeConfig; | |||
import com.iformall.mapper.UserTimeConfigServiceMapper; | |||
import com.iformall.service.sm.UserTimeConfigService; | |||
import io.swagger.models.auth.In; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@Service | |||
public class UserTimeConfigServiceImpl implements UserTimeConfigService { | |||
@Autowired | |||
private UserTimeConfigServiceMapper userTimeConfigServiceMapper; | |||
@Override | |||
public UserTimeConfig getInfoByUerType(Integer i) { | |||
return userTimeConfigServiceMapper.selectOne(new LambdaQueryWrapper<UserTimeConfig>().eq(UserTimeConfig::getIsDel, 0).eq(UserTimeConfig::getUserType, i)); | |||
} | |||
} |
@@ -10,7 +10,7 @@ public class AiPreviewResult { | |||
private Integer code; | |||
private String msg; | |||
private String url; | |||
private Long time; | |||
private Double time; | |||
public String getMsgInfo(Integer code, String msg) { | |||
if (code == 3000 && msg.equals("success")) { | |||
@@ -178,10 +178,11 @@ public class AiVideoHelper { | |||
result.setMsg("TTS音色预览失败,请稍后重试"); | |||
return result; | |||
} | |||
//TODO 从json里面获取音频时长且返回 | |||
JSONObject jsonObject = JSON.parseObject(response); | |||
JSONObject status = jsonObject.getJSONObject("status"); | |||
JSONObject data = jsonObject.getJSONObject("data"); | |||
String strURL = data.getString("url"); | |||
String time = data.getString("time"); | |||
Integer code = status.getInteger("code"); | |||
String msg = status.getString("msg"); | |||
if (code == null) { | |||
@@ -192,7 +193,8 @@ public class AiVideoHelper { | |||
if (code.intValue() == 3000) { | |||
result.setCode(200); | |||
result.setSuccess(true); | |||
result.setUrl(url + data.getString("url")); | |||
result.setUrl(url + strURL); | |||
result.setTime(Double.valueOf(time)); | |||
String resultMsg = result.getMsgInfo(code, msg); | |||
result.setMsg(resultMsg); | |||
} else { | |||
@@ -226,28 +228,28 @@ public class AiVideoHelper { | |||
// AiVideoResult video = AiVideoHelper.createVideo(videoParam); | |||
// | |||
AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | |||
param.setGen_txt("人多泰达股份冲冠怒发代发"); | |||
param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/digitalperson/16760216806604820_cSHoijDX_matting.png")); | |||
param.setGender("male"); | |||
param.setVoice_id("zh-CN-YunxiNeural"); | |||
param.setVoice_style("sad"); | |||
param.setUrl("None"); | |||
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||
// | |||
// AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | |||
// param.setGen_txt("人多泰达股份冲冠怒发代发"); | |||
// param.setImg(Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/digitalperson/16760216806604820_cSHoijDX_matting.png")); | |||
// param.setGender("male"); | |||
// param.setVoice_id("zh-CN-YunxiNeural"); | |||
// param.setVoice_style("sad"); | |||
// param.setUrl("None"); | |||
// AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||
// AiCheckPhotoParam param = new AiCheckPhotoParam(); | |||
// String img = Base64Util.imageUrlToBase64("https://suimang.oss-accelerate.aliyuncs.com/builtin/personmould/16760216806604820_cSHoijDX_grace_1080.jpg"); | |||
// param.setImg(img); | |||
// AiCheckPhotoResult result = AiVideoHelper.checkPhoto(param); | |||
// System.out.println(result); | |||
// | |||
// AiPreviewParam param = new AiPreviewParam(); | |||
// param.setGen_txt("今天是个好日子"); | |||
// param.setVoice_id("zh-CN-YunyangNeural"); | |||
// param.setVoice_style("default"); | |||
// param.setGender("male"); | |||
// AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||
AiPreviewParam param = new AiPreviewParam(); | |||
param.setGen_txt("今天是个好日子"); | |||
param.setVoice_id("zh-CN-YunyangNeural"); | |||
param.setVoice_style("default"); | |||
param.setGender("male"); | |||
AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||
System.out.println(result); | |||
} | |||
@@ -7,10 +7,14 @@ | |||
UPDATE user_create_video_num | |||
<set> | |||
<if test="type == 1"> | |||
residue_num = #{createVideoNum.residueNum} - 1,create_num = #{createVideoNum.createNum} + 1 | |||
residue_credits = #{createVideoNum.residueCredits} - #{useCredit}, | |||
create_num = #{createVideoNum.createNum} + 1, | |||
create_all_time = #{createVideoNum.createAllTime} + #{time} | |||
</if> | |||
<if test="type == 2"> | |||
residue_num = #{createVideoNum.residueNum} + 1,create_num = #{createVideoNum.createNum} - 1 | |||
residue_credits = #{createVideoNum.residueCredits} + #{useCredit}, | |||
create_num = #{createVideoNum.createNum} - 1, | |||
create_all_time = #{createVideoNum.createAllTime} - #{time} | |||
</if> | |||
</set> | |||
WHERE user_id = #{createVideoNum.userId} | |||