@@ -1,8 +1,14 @@ | |||||
package com.iformall.controller; | package com.iformall.controller; | ||||
import com.alibaba.fastjson.JSONObject; | import com.alibaba.fastjson.JSONObject; | ||||
import com.github.binarywang.wxpay.v3.util.AesUtils; | |||||
import com.iformall.annotation.AuthIgnore; | import com.iformall.annotation.AuthIgnore; | ||||
import com.iformall.domain.po.WxAppinfo; | |||||
import com.iformall.domain.po.WxPayAccount; | |||||
import com.iformall.enums.EnumAppPlat; | |||||
import com.iformall.service.ProductOrderService; | import com.iformall.service.ProductOrderService; | ||||
import com.iformall.service.WxAppinfoService; | |||||
import com.iformall.service.WxPayAccountService; | |||||
import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
import org.jdom2.JDOMException; | import org.jdom2.JDOMException; | ||||
@@ -14,6 +20,7 @@ import org.springframework.web.bind.annotation.*; | |||||
import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.HashMap; | |||||
import java.util.Map; | import java.util.Map; | ||||
@@ -23,19 +30,70 @@ import java.util.Map; | |||||
public class CallbackPayController extends BaseController { | public class CallbackPayController extends BaseController { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
@Autowired | |||||
private WxAppinfoService wxAppinfoService; | |||||
@Autowired | |||||
private WxPayAccountService wxPayAccountService; | |||||
@Autowired | @Autowired | ||||
private ProductOrderService productOrderService; | private ProductOrderService productOrderService; | ||||
@AuthIgnore | @AuthIgnore | ||||
@ApiOperation("支付回调") | @ApiOperation("支付回调") | ||||
@PostMapping(value = "/pay/v3") | |||||
public void _payV3Notify(@RequestBody Map<String, Object> paranMap, HttpServletRequest request, HttpServletResponse response) throws IOException, JDOMException { | |||||
logger.debug("[" + getIpAddr() + "] CallbackPayController::photoSpeak"); | |||||
logger.info("支付回调结果通知{}"+JSONObject.toJSONString(paranMap)); | |||||
@PostMapping(value = "{project}/pay/v3") | |||||
public void _payV3Notify(@PathVariable Integer projectType,@RequestBody Map<String, Object> paranMap, HttpServletResponse response) { | |||||
logger.debug("[" + getIpAddr() + "] CallbackPayController::_payV3Notify"); | |||||
logger.info("微信支付回调结果通知{}"+JSONObject.toJSONString(paranMap)); | |||||
/** | /** | ||||
* {"id":"4330b030-788f-5067-8c8a-69ee373d43ad","create_time":"2023-08-28T18:44:56+08:00","resource_type":"encrypt-resource","event_type":"TRANSACTION.SUCCESS","summary":"支付成功","resource":{"original_type":"transaction","algorithm":"AEAD_AES_256_GCM","ciphertext":"PneNTwSVDoirBNQsJstB/yX1dNMupj7uKQVEVfLOoyMSCqKh+KMwIdanidbcs6OnSy1Xmx4MploMaQ5rSg66sFDQ9nDuSVc4S/I3OVflu1l7z9vR+FJiztpTqhr/ekeNz9VivtqPPtn6N3dCyZb6iCEwnXT+TEB8SBZe4bPSPFGhB/MB9w1ZpqP14OvMDUnzKM15mdex6wmAJH6qIbd1aH3jrW/Lv7KeyfXEYrRDljq2Za6476UQxeAcsR3JA6QpWwrhYxpKFQEHuGMdiVC1KvQsP3+JUWOKSiQQ1r5upTACPI8n5B/kOeXJA8MnTgY/7lZiA6ys2dt8jqxzL8IlDracnlwvsiRAuXjRjcX6pYCz4q0HwIYb1nHXE+iRcSGm8h+xFFsnhGgxrhEVz6ARhK6ZtKtibCv7Ll/a/d090FBKtVXzCWB6cLMMmfrIwLQFqiFUtb6zsV/zusAJdwHZt3LmtgGahoV3+UPTnbztEAp5IJGz2imGPTsk7QpvKWQknf5FM/Z1fhr/vb+pZV5NGBZ+6l/mI8isA4HtljzNHU/PuKCGO8uWu6QFevgAftGGww==","associated_data":"transaction","nonce":"Hrcahgdp1eO6"}} | * {"id":"4330b030-788f-5067-8c8a-69ee373d43ad","create_time":"2023-08-28T18:44:56+08:00","resource_type":"encrypt-resource","event_type":"TRANSACTION.SUCCESS","summary":"支付成功","resource":{"original_type":"transaction","algorithm":"AEAD_AES_256_GCM","ciphertext":"PneNTwSVDoirBNQsJstB/yX1dNMupj7uKQVEVfLOoyMSCqKh+KMwIdanidbcs6OnSy1Xmx4MploMaQ5rSg66sFDQ9nDuSVc4S/I3OVflu1l7z9vR+FJiztpTqhr/ekeNz9VivtqPPtn6N3dCyZb6iCEwnXT+TEB8SBZe4bPSPFGhB/MB9w1ZpqP14OvMDUnzKM15mdex6wmAJH6qIbd1aH3jrW/Lv7KeyfXEYrRDljq2Za6476UQxeAcsR3JA6QpWwrhYxpKFQEHuGMdiVC1KvQsP3+JUWOKSiQQ1r5upTACPI8n5B/kOeXJA8MnTgY/7lZiA6ys2dt8jqxzL8IlDracnlwvsiRAuXjRjcX6pYCz4q0HwIYb1nHXE+iRcSGm8h+xFFsnhGgxrhEVz6ARhK6ZtKtibCv7Ll/a/d090FBKtVXzCWB6cLMMmfrIwLQFqiFUtb6zsV/zusAJdwHZt3LmtgGahoV3+UPTnbztEAp5IJGz2imGPTsk7QpvKWQknf5FM/Z1fhr/vb+pZV5NGBZ+6l/mI8isA4HtljzNHU/PuKCGO8uWu6QFevgAftGGww==","associated_data":"transaction","nonce":"Hrcahgdp1eO6"}} | ||||
*/ | */ | ||||
WxAppinfo appInfo = wxAppinfoService.getProjectCAppInfoFromRedis(projectType, EnumAppPlat.WX.getCode()); | |||||
WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId()); | |||||
try{ | |||||
Map<String, String> resource = (Map<String, String>) paranMap.get("resource"); | |||||
String associatedData = resource.get("associated_data"); | |||||
String nonce = resource.get("nonce"); | |||||
String ciphertext = resource.get("ciphertext"); | |||||
//todo 解密回调数据 | |||||
String decryptString = AesUtils.decryptToString(associatedData, nonce, ciphertext, payAccount.getMerchantApiv3Key()); | |||||
JSONObject jsonObject = JSONObject.parseObject(decryptString); | |||||
String out_order_no = jsonObject.getString("out_trade_no"); | |||||
//todo 处理支付数据 | |||||
}catch(Exception e){ | |||||
} | |||||
response.setStatus(200); | response.setStatus(200); | ||||
} | } | ||||
@AuthIgnore | |||||
@ApiOperation("支付回调") | |||||
@PostMapping(value = "/ttNotify") | |||||
public Map<String,Object> _ttNotify(@RequestBody Map<String, Object> paranMap, HttpServletRequest request, HttpServletResponse response) { | |||||
logger.debug("[" + getIpAddr() + "] CallbackPayController::_ttNotify"); | |||||
Map<String,Object> resultMap = new HashMap<>(); | |||||
logger.info("抖音支付回调结果通知{}"+JSONObject.toJSONString(paranMap)); | |||||
/** | |||||
* ----效验数据来源合法 | |||||
*/ | |||||
try{ | |||||
String msg = (String) paranMap.get("msg"); | |||||
String type = (String) paranMap.get("type"); | |||||
Map<String, Object> pMap = JSONObject.parseObject(msg, Map.class); | |||||
String appid = (String) pMap.get("app_id"); | |||||
if("payment".equals(type)){ | |||||
String out_order_no = (String)pMap.get("cp_orderno"); | |||||
//todo 处理订单支付状态 | |||||
} | |||||
}catch(Exception e){ | |||||
} | |||||
return resultMap; | |||||
} | |||||
} | } |
@@ -28,6 +28,9 @@ import java.util.*; | |||||
public class CallbackSmController extends BaseController { | public class CallbackSmController extends BaseController { | ||||
private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
@Autowired | |||||
private UserMouldVideoService userMouldVideoService; | |||||
@Autowired | @Autowired | ||||
private PhotoSpeakVideoService photoSpeakVideoService; | private PhotoSpeakVideoService photoSpeakVideoService; | ||||
@@ -39,6 +42,50 @@ public class CallbackSmController extends BaseController { | |||||
@AuthIgnore | @AuthIgnore | ||||
@ApiOperation("视频回调") | @ApiOperation("视频回调") | ||||
@PostMapping(value = "/oral/broadcasting") | |||||
public ResultData oralBroadcasting(@RequestBody Map<String, Object> paranMap) { | |||||
logger.debug("[" + getIpAddr() + "] CallbackSmController::oralBroadcasting"); | |||||
logger.info("口播生成视频结果通知{}"+JSONObject.toJSONString(paranMap)); | |||||
Long task_id = (Long) paranMap.get("task_id");//任务ID | |||||
String code = (String) paranMap.get("code");//code | |||||
String msg = (String) paranMap.get("msg"); | |||||
if (task_id == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"任务ID不能为空"); | |||||
} | |||||
UserMouldVideo userMouldVideo = userMouldVideoService.getById(task_id); | |||||
if (userMouldVideo == null){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到任务数据"); | |||||
} | |||||
UserMouldVideo videoUnd = new UserMouldVideo(); | |||||
videoUnd.setId(userMouldVideo.getId()); | |||||
if("1000".equals(code)){ | |||||
Map<String,Object> data = (Map<String, Object>) paranMap.get("data"); | |||||
Map<String,Object> video = (Map<String, Object>) data.get("video"); | |||||
String url = (String) video.get("url"); | |||||
String duration = (String) video.get("duration"); | |||||
videoUnd.setVideoStatus(EnumVideoStatus.success.getCode()); | |||||
videoUnd.setVideoMsg("success"); | |||||
videoUnd.setVideoPath(url); | |||||
videoUnd.setVideoTime(duration); | |||||
videoUnd.setUpdateDate(new Date()); | |||||
userMouldVideoService.updateById(videoUnd); | |||||
}else{ | |||||
videoUnd.setVideoStatus(EnumVideoStatus.fail.getCode()); | |||||
videoUnd.setVideoMsg(msg); | |||||
videoUnd.setUpdateDate(new Date()); | |||||
userMouldVideoService.updateById(videoUnd); | |||||
} | |||||
userMouldVideoService.uploadVideo(videoUnd); | |||||
return new ResultData(); | |||||
} | |||||
@AuthIgnore | |||||
@ApiOperation("照片说话 视频回调") | |||||
@PostMapping(value = "/photo/speak") | @PostMapping(value = "/photo/speak") | ||||
public ResultData photoSpeak(@RequestBody Map<String, Object> paranMap) { | public ResultData photoSpeak(@RequestBody Map<String, Object> paranMap) { | ||||
logger.debug("[" + getIpAddr() + "] CallbackSmController::photoSpeak"); | logger.debug("[" + getIpAddr() + "] CallbackSmController::photoSpeak"); | ||||
@@ -51,7 +98,7 @@ public class CallbackSmController extends BaseController { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"任务ID不能为空"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"任务ID不能为空"); | ||||
} | } | ||||
PhotoSpeakVideo photoSpeakVideo = photoSpeakVideoService.getById(Long.valueOf(task_id)); | |||||
PhotoSpeakVideo photoSpeakVideo = photoSpeakVideoService.getById(task_id); | |||||
if (photoSpeakVideo == null){ | if (photoSpeakVideo == null){ | ||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到任务数据"); | return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到任务数据"); | ||||
} | } | ||||
@@ -13,6 +13,7 @@ import com.iformall.domain.po.sm.InviteCodeInfo; | |||||
import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
import com.iformall.service.*; | import com.iformall.service.*; | ||||
import com.iformall.service.cuser.CUserServiceApapter; | |||||
import com.iformall.service.cuser.CUserServiceFactory; | import com.iformall.service.cuser.CUserServiceFactory; | ||||
import com.iformall.service.sm.InviteCodeInfoService; | import com.iformall.service.sm.InviteCodeInfoService; | ||||
import com.iformall.service.sm.InviteCodeService; | import com.iformall.service.sm.InviteCodeService; | ||||
@@ -57,10 +58,6 @@ public class MiniAppUserController extends BaseController { | |||||
@Autowired | @Autowired | ||||
private CUserServiceFactory cuserFactory; | private CUserServiceFactory cuserFactory; | ||||
@Autowired | |||||
@Qualifier("objectCommonRedisTemplate") | |||||
RedisTemplate<String, Object> redisTemplate; | |||||
@Autowired | @Autowired | ||||
private WxCUserBasicInfoService wxCUserBasicInfoService; | private WxCUserBasicInfoService wxCUserBasicInfoService; | ||||
@@ -68,7 +65,14 @@ public class MiniAppUserController extends BaseController { | |||||
private UserBasicQrcodeService userBasicQrcodeService; | private UserBasicQrcodeService userBasicQrcodeService; | ||||
@Autowired | @Autowired | ||||
WxAppinfoService wxAppinfoService; | |||||
private WxAppinfoService wxAppinfoService; | |||||
@Autowired | |||||
private WxMsgValidationcodeService wxMsgValidationcodeService; | |||||
@Autowired | |||||
@Qualifier("objectCommonRedisTemplate") | |||||
RedisTemplate<String, Object> redisTemplate; | |||||
/** | /** | ||||
@@ -82,8 +86,11 @@ public class MiniAppUserController extends BaseController { | |||||
@TenantIgnore | @TenantIgnore | ||||
@PostMapping("/login") | @PostMapping("/login") | ||||
@ApiOperation(value = "用户登录", notes = "{\"appId\":\"string\",\"code\":\"string\",\"scene\":\"string\",\"sceneAddress\":\"string\",\"latitude\":\"string\",\"longitude\":\"string\",\"systemInfo\":\"string\"}") | @ApiOperation(value = "用户登录", notes = "{\"appId\":\"string\",\"code\":\"string\",\"scene\":\"string\",\"sceneAddress\":\"string\",\"latitude\":\"string\",\"longitude\":\"string\",\"systemInfo\":\"string\"}") | ||||
public ResultData userLogin(@RequestBody Map<String, String> map) { | |||||
logger.info("dologin >>>>>>>>>>>>>>>>>"+map.toString()); | |||||
public ResultData login(@RequestBody Map<String, String> map) { | |||||
String ipaddress = getIpAddr(); | |||||
logger.debug("[" + ipaddress + "] MiniAppUserController::login"); | |||||
logger.info("login >>>>>>>>>>>>>>>>>"+map.toString()); | |||||
Map resultMap = new HashMap(); | Map resultMap = new HashMap(); | ||||
@@ -135,7 +142,6 @@ public class MiniAppUserController extends BaseController { | |||||
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
// request.setAttribute(Constant.TENANT_ID, wxMall.getTenantId()); | // request.setAttribute(Constant.TENANT_ID, wxMall.getTenantId()); | ||||
// request.setAttribute(Constant.PARENT_TENANT_ID, wxMall.getParentTenantId()); | // request.setAttribute(Constant.PARENT_TENANT_ID, wxMall.getParentTenantId()); | ||||
String ipaddress = IPUtil.getIpAddr(request); | |||||
CUser cUser = new CUser(); | CUser cUser = new CUser(); | ||||
cUser.setAppId(appId); | cUser.setAppId(appId); | ||||
@@ -167,8 +173,11 @@ public class MiniAppUserController extends BaseController { | |||||
@AuthIgnore | @AuthIgnore | ||||
@PostMapping("/loginPhone") | @PostMapping("/loginPhone") | ||||
@ApiOperation(value = "授权后获取用户的手机号", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | @ApiOperation(value = "授权后获取用户的手机号", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | ||||
public ResultData getUserPhone(@RequestBody Map<String, String> map) { | |||||
logger.info(map.toString()); | |||||
public ResultData loginPhone(@RequestBody Map<String, String> map) { | |||||
String ipaddress = getIpAddr(); | |||||
logger.debug("[" + ipaddress + "] MiniAppUserController::loginPhone"); | |||||
logger.info("loginPhone >>>>>>>>>>>>>>>>>"+map.toString()); | |||||
String appId = map.get("appId"); | String appId = map.get("appId"); | ||||
String openId = map.get("openId"); | String openId = map.get("openId"); | ||||
String encryptedData = map.get("encryptedData"); | String encryptedData = map.get("encryptedData"); | ||||
@@ -205,7 +214,7 @@ public class MiniAppUserController extends BaseController { | |||||
UserBasicFrom from = new UserBasicFrom(); | UserBasicFrom from = new UserBasicFrom(); | ||||
from.setPlat(appPlat.getCode()); | from.setPlat(appPlat.getCode()); | ||||
from.setFromProject(EnumProject.PROJECT_5.getCode()); | |||||
from.setFromProject(wxAppinfo.getProjectType()); | |||||
if(StringUtils.isNotBlank(uid)){ | if(StringUtils.isNotBlank(uid)){ | ||||
try { | try { | ||||
from.setFromUserId(Long.parseLong(uid)); | from.setFromUserId(Long.parseLong(uid)); | ||||
@@ -237,6 +246,85 @@ public class MiniAppUserController extends BaseController { | |||||
return new ResultData(resultMap); | return new ResultData(resultMap); | ||||
} | } | ||||
@AuthIgnore | |||||
@ApiOperation(value = "手机验证码授权登录", notes = "{\"phone\",\"string\",\"code\",\"string\"}") | |||||
@PostMapping("/loginPhoneCode") | |||||
public ResultData loginPhoneCode(@RequestBody Map<String, String> map, HttpServletResponse response) { | |||||
String ipaddress = getIpAddr(); | |||||
logger.debug("[" + ipaddress + "] MiniAppUserController::loginPhoneCode"); | |||||
logger.info("loginPhoneCode >>>>>>>>>>>>>>>>>"+map.toString()); | |||||
// String phone,String code,String pwd | |||||
String appId = map.get("appId"); | |||||
String openId = map.get("openId"); | |||||
String phone = map.get("phone"); | |||||
String code = map.get("code"); | |||||
if(StringUtils.isBlank(appId)){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); | |||||
} | |||||
if(StringUtils.isBlank(openId)){ | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "openId 不能为空"); | |||||
} | |||||
WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); | |||||
if(wxAppinfo == null){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||||
} | |||||
if(!wxAppinfo.getEnable().equals(EnumEnableType.Enable.getCode())){ | |||||
return new ResultData(ErrorCode.APP_ID_NOT_ENABLE); | |||||
} | |||||
EnumAppPlat appPlat = EnumAppPlat.getByCode(wxAppinfo.getPlat()); | |||||
if(appPlat == null){ | |||||
return new ResultData(ErrorCode.APP_PLAT_ERROR); | |||||
} | |||||
if (StringUtils.isBlank(phone)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "手机号不能为空"); | |||||
} | |||||
if (StringUtils.isBlank(code)) { | |||||
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); | |||||
} | |||||
// check 验证码正确 | |||||
boolean isValidCode = false; | |||||
try { | |||||
isValidCode = wxMsgValidationcodeService.checkCodeValid(phone, code); | |||||
} catch (Exception e) { | |||||
return new ResultData(Result.ERROR, e.getMessage()); | |||||
} | |||||
if (isValidCode) { | |||||
String uid = map.get("uid"); | |||||
UserBasicFrom from = new UserBasicFrom(); | |||||
from.setPlat(appPlat.getCode()); | |||||
from.setFromProject(wxAppinfo.getProjectType()); | |||||
if(StringUtils.isNotBlank(uid)){ | |||||
try { | |||||
from.setFromUserId(Long.parseLong(uid)); | |||||
from.setFromType(EnumUserBasicFrom.FROM_3.getCode()); | |||||
}catch(Exception e){} | |||||
} | |||||
CUserServiceApapter cUserService = cuserFactory.getCUserService(appPlat); | |||||
CUser user = cUserService.getByOpenId(openId, getTenantInfo().getTenantId()); | |||||
if (user == null) { | |||||
return new ResultData(ErrorCode.USER_IS_EMPTY); | |||||
} | |||||
WxCUserBasicInfo basicInfo = cUserService.savePhoneToBasicInfo(user, phone,from); | |||||
wxCUserBasicInfoService.handleLoginUser(basicInfo); | |||||
Map resultMap = new HashMap(); | |||||
// resultMap.put("phone", basicInfo.getPhone()); | |||||
resultMap.put("token", basicInfo.getToken()); | |||||
return new ResultData(resultMap); | |||||
} else { | |||||
return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | |||||
} | |||||
} | |||||
/** | /** | ||||
* 获取二维码 | * 获取二维码 | ||||
* | * | ||||
@@ -188,10 +188,10 @@ logging: | |||||
com.iformall: debug | com.iformall: debug | ||||
path: ./logs/c | path: ./logs/c | ||||
photo: | |||||
url: http://111.198.0.15:22299 | |||||
hy_url: http://111.198.0.15:22288 | |||||
talk: http://nas.pucao.cn:2001 | |||||
suimang: | |||||
oral_broadcasting: http://nas.pucao.cn:2001 | |||||
photo_speak: http://111.198.0.15:22299 | |||||
photo_speak_hy: http://111.198.0.15:22288 | |||||
digital_avatar: http://111.198.0.15:22200 | digital_avatar: http://111.198.0.15:22200 | ||||
digital_avatar_hy: http://nas.pucao.cn:2003 | digital_avatar_hy: http://nas.pucao.cn:2003 | ||||
callbackUrl: https://phototest.metavatar.cc/C | |||||
callbackUrl: https://test.metavatar.cc/C |
@@ -143,10 +143,10 @@ logging: | |||||
com.iformall: debug | com.iformall: debug | ||||
path: ./logs/c | path: ./logs/c | ||||
photo: | |||||
url: http://111.198.0.15:22299 | |||||
hy_url: http://111.198.0.15:22288 | |||||
talk: http://111.198.0.15:22266 | |||||
suimang: | |||||
oral_broadcasting: http://111.198.0.15:22266 | |||||
photo_speak: http://111.198.0.15:22299 | |||||
photo_speak_hy: http://111.198.0.15:22288 | |||||
digital_avatar: http://111.198.0.15:22200 | digital_avatar: http://111.198.0.15:22200 | ||||
digital_avatar_hy: http://nas.pucao.cn:2003 | digital_avatar_hy: http://nas.pucao.cn:2003 | ||||
callbackUrl: https://photo.metavatar.cc/C | |||||
callbackUrl: https://metavatar.cc/C |
@@ -191,10 +191,10 @@ logging: | |||||
com.iformall.mapper: debug | com.iformall.mapper: debug | ||||
path: ./logs/s | path: ./logs/s | ||||
photo: | |||||
url: http://111.198.0.15:22299 | |||||
hy_url: http://111.198.0.15:22288 | |||||
talk: http://nas.pucao.cn:2001 | |||||
suimang: | |||||
oral_broadcasting: http://nas.pucao.cn:2001 | |||||
photo_speak: http://111.198.0.15:22299 | |||||
photo_speak_hy: http://111.198.0.15:22288 | |||||
digital_avatar: http://111.198.0.15:22200 | digital_avatar: http://111.198.0.15:22200 | ||||
digital_avatar_hy: http://nas.pucao.cn:2003 | digital_avatar_hy: http://nas.pucao.cn:2003 | ||||
callbackUrl: https://phototest.metavatar.cc/C | |||||
callbackUrl: https://test.metavatar.cc/C |
@@ -147,10 +147,10 @@ logging: | |||||
path: ./logs/s | path: ./logs/s | ||||
photo: | |||||
url: http://111.198.0.15:22299 | |||||
hy_url: http://111.198.0.15:22288 | |||||
talk: http://111.198.0.15:22266 | |||||
suimang: | |||||
oral_broadcasting: http://111.198.0.15:22266 | |||||
photo_speak: http://111.198.0.15:22299 | |||||
photo_speak_hy: http://111.198.0.15:22288 | |||||
digital_avatar: http://111.198.0.15:22200 | digital_avatar: http://111.198.0.15:22200 | ||||
digital_avatar_hy: http://nas.pucao.cn:2003 | digital_avatar_hy: http://nas.pucao.cn:2003 | ||||
callbackUrl: https://photo.metavatar.cc/C | |||||
callbackUrl: https://metavatar.cc/C |
@@ -5,11 +5,11 @@ package com.iformall.enums; | |||||
*/ | */ | ||||
public enum EnumProductOrderPayVendor { | public enum EnumProductOrderPayVendor { | ||||
PAY_WAY_WECHAT(1, "微信小程序",EnumAppPlat.WX.getCode(),EnumProfitSharing.PROFIT_SHARING.getCode()), | |||||
PAY_WAY_WECHAT(1, "微信小程序",EnumAppPlat.WX.getCode(),EnumProfitSharing.PROFIT_SHARING_NO.getCode()), | |||||
PAY_WAY_WECHAT_WAP(2, "微信H5",null,null), | PAY_WAY_WECHAT_WAP(2, "微信H5",null,null), | ||||
PAY_WAY_ALIPAY(3, "支付宝小程序",null,null), | PAY_WAY_ALIPAY(3, "支付宝小程序",null,null), | ||||
PAY_WAY_ALIPAY_WAP(4, "支付宝H5",null,null), | PAY_WAY_ALIPAY_WAP(4, "支付宝H5",null,null), | ||||
PAY_WAY_TT(5, "抖音小程序",EnumAppPlat.TOUTIAO.getCode(),EnumProfitSharing.PROFIT_SHARING_MAST.getCode()), | |||||
PAY_WAY_TT(5, "抖音小程序",EnumAppPlat.TOUTIAO.getCode(),EnumProfitSharing.PROFIT_SHARING_NO.getCode()), | |||||
; | ; | ||||
public static EnumProductOrderPayVendor getEnum(Integer code) { | public static EnumProductOrderPayVendor getEnum(Integer code) { | ||||
for (EnumProductOrderPayVendor value : values()) { | for (EnumProductOrderPayVendor value : values()) { | ||||
@@ -4,7 +4,7 @@ package com.iformall.enums; | |||||
* Created by Stormeye on 2018/08/09. | * Created by Stormeye on 2018/08/09. | ||||
*/ | */ | ||||
public enum EnumProfitSharing { | public enum EnumProfitSharing { | ||||
PROFIT_SHARING(0, "无需分账"), | |||||
PROFIT_SHARING_NO(0, "无需分账"), | |||||
PROFIT_SHARING_MAST(1, "需要分账"), | PROFIT_SHARING_MAST(1, "需要分账"), | ||||
PROFIT_SHARING_FINISH(2, "已经分账"), | PROFIT_SHARING_FINISH(2, "已经分账"), | ||||
; | ; | ||||
@@ -26,7 +26,7 @@ public interface CUserServiceApapter { | |||||
WxCUserBasicInfo decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen, UserBasicFrom from); | WxCUserBasicInfo decryptPhoneNoInfo(String encryptedData, String iv, CUser cuser, WxAppinfo wxAppinfo, boolean isFmOpen, UserBasicFrom from); | ||||
void savePhoneToBasicInfo(CUser user, String phone); | |||||
WxCUserBasicInfo savePhoneToBasicInfo(CUser user, String phone, UserBasicFrom from); | |||||
CUser handleLoginUser(CUser cUser); | CUser handleLoginUser(CUser cUser); | ||||
@@ -179,20 +179,21 @@ public class TtCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
} | } | ||||
@Override | @Override | ||||
public void savePhoneToBasicInfo(CUser user, String phone) { | |||||
public WxCUserBasicInfo savePhoneToBasicInfo(CUser user, String phone, UserBasicFrom from) { | |||||
TtCUser updateUser = new TtCUser(); | TtCUser updateUser = new TtCUser(); | ||||
updateUser.setId(user.getId()); | updateUser.setId(user.getId()); | ||||
updateUser.updateTenantInfo(user); | updateUser.updateTenantInfo(user); | ||||
updateUser.setPhone(phone); | updateUser.setPhone(phone); | ||||
// 更新到basicinfo | // 更新到basicinfo | ||||
WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,null); | |||||
WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,from); | |||||
updateUser.setUserId(basicInfo.getId()); | updateUser.setUserId(basicInfo.getId()); | ||||
updateUser.setUpdateDate(new Date()); | updateUser.setUpdateDate(new Date()); | ||||
ttCUserMapper.updateById(updateUser); | ttCUserMapper.updateById(updateUser); | ||||
ttCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); | ttCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); | ||||
return basicInfo; | |||||
} | } | ||||
@Override | @Override | ||||
@@ -192,19 +192,20 @@ public class WxCUserServiceAdapter extends BasicCUserService implements CUserSer | |||||
} | } | ||||
@Override | @Override | ||||
public void savePhoneToBasicInfo(CUser user, String phone) { | |||||
public WxCUserBasicInfo savePhoneToBasicInfo(CUser user, String phone, UserBasicFrom from) { | |||||
WxCUser updateUser = new WxCUser(); | WxCUser updateUser = new WxCUser(); | ||||
updateUser.setId(user.getId()); | updateUser.setId(user.getId()); | ||||
updateUser.updateTenantInfo(user); | updateUser.updateTenantInfo(user); | ||||
updateUser.setPhone(phone); | updateUser.setPhone(phone); | ||||
WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,null); | |||||
WxCUserBasicInfo basicInfo = saveToBasicInfoByCUser(updateUser,from); | |||||
updateUser.setUserId(basicInfo.getId()); | updateUser.setUserId(basicInfo.getId()); | ||||
updateUser.setUpdateDate(new Date()); | updateUser.setUpdateDate(new Date()); | ||||
wxCUserMapper.updateById(updateUser); | wxCUserMapper.updateById(updateUser); | ||||
wxCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); | wxCUserMapper.delForUserIdOnly(updateUser.getId(),updateUser.getUserId(),updateUser.getTenantId()); | ||||
return basicInfo; | |||||
} | } | ||||
@Override | @Override | ||||
@@ -11,12 +11,14 @@ import com.iformall.domain.po.sm.VoiceInfo; | |||||
import com.iformall.domain.vo.VoiceInfoVo; | import com.iformall.domain.vo.VoiceInfoVo; | ||||
import com.iformall.enums.EnumClassType; | import com.iformall.enums.EnumClassType; | ||||
import com.iformall.enums.EnumSpeakType; | import com.iformall.enums.EnumSpeakType; | ||||
import com.iformall.file.aliyun.bean.AliyunOSSConfig; | |||||
import com.iformall.mapper.VoiceMapper; | import com.iformall.mapper.VoiceMapper; | ||||
import com.iformall.mapper.WxCVoiceMapper; | import com.iformall.mapper.WxCVoiceMapper; | ||||
import com.iformall.service.WxCVoiceService; | import com.iformall.service.WxCVoiceService; | ||||
import com.iformall.sm.AiPreviewParam; | import com.iformall.sm.AiPreviewParam; | ||||
import com.iformall.sm.AiPreviewResult; | import com.iformall.sm.AiPreviewResult; | ||||
import com.iformall.sm.AiVideoHelper; | import com.iformall.sm.AiVideoHelper; | ||||
import com.iformall.utils.Constant; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
@@ -33,9 +35,11 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
@Autowired | @Autowired | ||||
VoiceMapper voiceMapper; | VoiceMapper voiceMapper; | ||||
private final static String str = "\uD83D\uDD57"; | |||||
private final static String url = "https://suimang.oss-accelerate.aliyuncs.com/builtin/tts_all_sample/"; | |||||
private final static String end = ".wav"; | |||||
@Autowired | |||||
private AliyunOSSConfig aliyunOSSConfig; | |||||
private final String demoDirectory = "/builtin/tts_all_sample/"; | |||||
private final String demoSuffix = ".wav"; | |||||
@Override | @Override | ||||
@@ -68,7 +72,7 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
HashMap<String, Object> style = new HashMap<>(); | HashMap<String, Object> style = new HashMap<>(); | ||||
style.put("stylename", y); | style.put("stylename", y); | ||||
style.put("displayname", EnumSpeakType.getEnum(y).getMessage()); | style.put("displayname", EnumSpeakType.getEnum(y).getMessage()); | ||||
style.put("styledemo", url + wxCVoiceTable.getMouldSmId() + "_" + y + end); | |||||
style.put("styledemo", aliyunOSSConfig.getFiledomain() + demoDirectory + wxCVoiceTable.getMouldSmId() + "_" + y + demoSuffix); | |||||
styleList.add(style); | styleList.add(style); | ||||
} | } | ||||
voice.put("styleList", styleList); | voice.put("styleList", styleList); | ||||
@@ -95,7 +99,7 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
return status; | return status; | ||||
} | } | ||||
AiPreviewParam param = new AiPreviewParam(); | AiPreviewParam param = new AiPreviewParam(); | ||||
param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(str, "[*]")); | |||||
param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(Constant.text_pause, "[*]")); | |||||
param.setVoice_id(voiceInfo.getMouldSmId()); | param.setVoice_id(voiceInfo.getMouldSmId()); | ||||
param.setVoice_style(StringUtils.isBlank(aiPreviewParam.getVoice_style()) ? EnumSpeakType.default_0.getMessage() : aiPreviewParam.getVoice_style()); | param.setVoice_style(StringUtils.isBlank(aiPreviewParam.getVoice_style()) ? EnumSpeakType.default_0.getMessage() : aiPreviewParam.getVoice_style()); | ||||
param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | ||||
@@ -123,12 +127,12 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
VoiceInfoVo infoVo = new VoiceInfoVo(); | VoiceInfoVo infoVo = new VoiceInfoVo(); | ||||
infoVo.setName(EnumSpeakType.getEnum(y).getMessage()); | infoVo.setName(EnumSpeakType.getEnum(y).getMessage()); | ||||
infoVo.setEngName(y); | infoVo.setEngName(y); | ||||
infoVo.setUrl(url + x.getMouldSmId() + "_" + y + end); | |||||
infoVo.setUrl(aliyunOSSConfig.getFiledomain() + demoDirectory + x.getMouldSmId() + "_" + y + demoSuffix); | |||||
list.add(infoVo); | list.add(infoVo); | ||||
}); | }); | ||||
VoiceInfoVo infoVo = new VoiceInfoVo(); | VoiceInfoVo infoVo = new VoiceInfoVo(); | ||||
infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | ||||
infoVo.setUrl(url + x.getMouldSmId() + "_" + "default" + end); | |||||
infoVo.setUrl(aliyunOSSConfig.getFiledomain() + demoDirectory + x.getMouldSmId() + "_" + "default" + demoSuffix); | |||||
infoVo.setEngName("default"); | infoVo.setEngName("default"); | ||||
list.add(infoVo); | list.add(infoVo); | ||||
x.setStyle(list); | x.setStyle(list); | ||||
@@ -137,7 +141,7 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||||
VoiceInfoVo infoVo = new VoiceInfoVo(); | VoiceInfoVo infoVo = new VoiceInfoVo(); | ||||
infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | ||||
infoVo.setEngName("default"); | infoVo.setEngName("default"); | ||||
infoVo.setUrl(url + x.getMouldSmId() + "_" + "default" + end); | |||||
infoVo.setUrl(aliyunOSSConfig.getFiledomain() + demoDirectory + x.getMouldSmId() + "_" + "default" + demoSuffix); | |||||
list.add(infoVo); | list.add(infoVo); | ||||
x.setStyle(list); | x.setStyle(list); | ||||
} | } | ||||
@@ -229,7 +229,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
DouYinCreatePreOrder preOrder = new DouYinCreatePreOrder(); | DouYinCreatePreOrder preOrder = new DouYinCreatePreOrder(); | ||||
preOrder.setAppId(appInfo.getAppId()); | preOrder.setAppId(appInfo.getAppId()); | ||||
preOrder.setSercrect(appInfo.getSecret()); | preOrder.setSercrect(appInfo.getSecret()); | ||||
preOrder.setSalt(payAccount.getApiKey()); | |||||
preOrder.setSalt(payAccount.getMerchantApiKey()); | |||||
preOrder.setOutOrderNo(order.getOrderNumber()); | preOrder.setOutOrderNo(order.getOrderNumber()); | ||||
preOrder.setTotalAmount(order.getOrderPrice()); | preOrder.setTotalAmount(order.getOrderPrice()); | ||||
preOrder.setSubject(appInfo.getName()+"-"+order.getProductTitle()); | preOrder.setSubject(appInfo.getName()+"-"+order.getProductTitle()); | ||||
@@ -256,7 +256,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
@Override | @Override | ||||
public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { | public PayQueryAdapterResult queryPayStatus(ProductOrder order, WxAppinfo appInfo, WxPayAccount payAccount) throws Exception { | ||||
OrderQueryResult orderQueryResult = DouYinPayHelper.orderQuery(appInfo.getAppId(), payAccount.getApiKey(), order.getOrderNumber(), null); | |||||
OrderQueryResult orderQueryResult = DouYinPayHelper.orderQuery(appInfo.getAppId(), payAccount.getMerchantApiKey(), order.getOrderNumber(), null); | |||||
int code = DouYinPayHelper.getPayStatusFromOrderQueryResult(orderQueryResult,order.getOrderNumber()); | int code = DouYinPayHelper.getPayStatusFromOrderQueryResult(orderQueryResult,order.getOrderNumber()); | ||||
PayQueryAdapterResult result = new PayQueryAdapterResult(); | PayQueryAdapterResult result = new PayQueryAdapterResult(); | ||||
result.setCode(code); | result.setCode(code); | ||||
@@ -225,7 +225,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
@Override | @Override | ||||
public PayShareQueryResult shareQuery(WxAppinfo appInfo, WxPayAccount payAccount, ProductOrderSharing record) throws MallinkException { | public PayShareQueryResult shareQuery(WxAppinfo appInfo, WxPayAccount payAccount, ProductOrderSharing record) throws MallinkException { | ||||
QuerySettleResult querySettleResult = DouYinPayHelper.settleQuery(appInfo.getAppId(), payAccount.getApiKey(), record.getOutSettleNo(), null); | |||||
QuerySettleResult querySettleResult = DouYinPayHelper.settleQuery(appInfo.getAppId(), payAccount.getMerchantApiKey(), record.getOutSettleNo(), null); | |||||
if(querySettleResult == null){ | if(querySettleResult == null){ | ||||
throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), "分账查询异常"); | throw new MallinkException(ErrorCode.PROFIT_SHARING_QUERY_REQUEST_FAILED.getCode(), "分账查询异常"); | ||||
} | } | ||||
@@ -362,7 +362,7 @@ public class TtPayShareService extends PayShareBaseAdapterService{ | |||||
Settle settle = new Settle(); | Settle settle = new Settle(); | ||||
settle.setAppId(appInfo.getAppId()); | settle.setAppId(appInfo.getAppId()); | ||||
settle.setSalt(payAccount.getApiKey()); | |||||
settle.setSalt(payAccount.getMerchantApiKey()); | |||||
settle.setOutSettleNo(record.getOutSettleNo()); | settle.setOutSettleNo(record.getOutSettleNo()); | ||||
settle.setOutOrderNo(record.getOutOrderId()); | settle.setOutOrderNo(record.getOutOrderId()); | ||||
settle.setSettleDesc(record.getSettleDesc()); | settle.setSettleDesc(record.getSettleDesc()); | ||||
@@ -16,6 +16,7 @@ import com.iformall.mapper.PhotoSpeakVideoMapper; | |||||
import com.iformall.service.sm.*; | import com.iformall.service.sm.*; | ||||
import com.iformall.sm.*; | import com.iformall.sm.*; | ||||
import com.iformall.utils.Base64Util; | import com.iformall.utils.Base64Util; | ||||
import com.iformall.utils.Constant; | |||||
import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
import com.iformall.video.VideoFactory; | import com.iformall.video.VideoFactory; | ||||
import com.iformall.video.entity.VideUploadResult; | import com.iformall.video.entity.VideUploadResult; | ||||
@@ -82,19 +83,6 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
@Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
RedisTemplate<String, Object> redisTemplate; | RedisTemplate<String, Object> redisTemplate; | ||||
@Value("${photo.url}") | |||||
private String url; | |||||
@Value("${photo.hy_url}") | |||||
private String hy_url; | |||||
@Value("${photo.talk}") | |||||
private String talk_url; | |||||
//停顿符 | |||||
private final static String str = "\uD83D\uDD57"; | |||||
@Value("${photo.callbackUrl}") | |||||
private String callbackUrl; | |||||
@Override | @Override | ||||
public PageInfo<PhotoSpeakVideo> listAsPage(PhotoSpeakVideo record, Integer pageIndex, Integer pageSize) { | public PageInfo<PhotoSpeakVideo> listAsPage(PhotoSpeakVideo record, Integer pageIndex, Integer pageSize) { | ||||
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> photoSpeakVideoMapper.findList(record)); | return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> photoSpeakVideoMapper.findList(record)); | ||||
@@ -202,8 +190,6 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
speakVideoUpd.setId(photoSpeakVideo.getId()); | speakVideoUpd.setId(photoSpeakVideo.getId()); | ||||
try { | try { | ||||
AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | AiPhotoSpeakParam param = new AiPhotoSpeakParam(); | ||||
param.setTask_id(photoSpeakVideo.getId()); | |||||
param.setCallback_url(callbackUrl + "/callback/photo/speak"); | |||||
param.setImg(Base64Util.imageUrlToBase64(photoSpeakVideo.getPersonPhotoUrl())); | param.setImg(Base64Util.imageUrlToBase64(photoSpeakVideo.getPersonPhotoUrl())); | ||||
Map<String,Object> subtitleMap = new HashMap<>(); | Map<String,Object> subtitleMap = new HashMap<>(); | ||||
if(photoSpeakVideo.getSubtitleEnabled() == null){ | if(photoSpeakVideo.getSubtitleEnabled() == null){ | ||||
@@ -237,7 +223,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
Integer voiceFrom = photoSpeakVideo.getVoiceFrom(); | Integer voiceFrom = photoSpeakVideo.getVoiceFrom(); | ||||
String voiceMaterialUrl = photoSpeakVideo.getVoiceMaterialUrl(); | String voiceMaterialUrl = photoSpeakVideo.getVoiceMaterialUrl(); | ||||
if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | if (EnumVoiceFrom.FROM_MOULD.getCode().equals(voiceFrom)) { | ||||
param.setGen_txt(photoSpeakVideo.getPaperwork().replaceAll(str, "[*]")); | |||||
param.setGen_txt(photoSpeakVideo.getPaperwork().replaceAll(Constant.text_pause, "[*]")); | |||||
if (sex == 1){ | if (sex == 1){ | ||||
param.setGender("male"); | param.setGender("male"); | ||||
}else if (sex == 2){ | }else if (sex == 2){ | ||||
@@ -257,7 +243,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
} | } | ||||
try { | try { | ||||
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param); | |||||
AiPhotoSpeakResult video = AiVideoHelper.createPhotoSpeakVideo(param,photoSpeakVideo.getId()); | |||||
if (video.isSuccess()) { | if (video.isSuccess()) { | ||||
// speakVideoUpd.setSaveDir(video.getSaveDir()); | // speakVideoUpd.setSaveDir(video.getSaveDir()); | ||||
// speakVideoUpd.setAudioPath(video.getAudioPath()); | // speakVideoUpd.setAudioPath(video.getAudioPath()); | ||||
@@ -289,7 +275,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
@Override | @Override | ||||
public void uploadVideo(PhotoSpeakVideo mouldVideo){ | public void uploadVideo(PhotoSpeakVideo mouldVideo){ | ||||
if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus())){ | if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus())){ | ||||
String url1 = url + mouldVideo.getVideoPath(); | |||||
String url1 = AiVideoHelper.photo_speak + mouldVideo.getVideoPath(); | |||||
VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url1); | VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url1); | ||||
if(result.isSuccess()){ | if(result.isSuccess()){ | ||||
PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | ||||
@@ -378,10 +364,9 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
AiVideoHqParam param = new AiVideoHqParam(); | AiVideoHqParam param = new AiVideoHqParam(); | ||||
param.setSave_dir(speakVideo.getSaveDir()); | param.setSave_dir(speakVideo.getSaveDir()); | ||||
param.setAudio_path(speakVideo.getAudioPath()); | param.setAudio_path(speakVideo.getAudioPath()); | ||||
param.setTask_id(speakVideo.getId()); | |||||
param.setCallback_url(callbackUrl + "/callback/photo/speak"); | |||||
try { | try { | ||||
AiVideoHqResult result = AiVideoHelper.videoHq(param); | |||||
AiVideoHqResult result = AiVideoHelper.videoHq(param,speakVideo.getId()); | |||||
if (result.isSuccess()) { | if (result.isSuccess()) { | ||||
// speakVideoUpd.setVideoStatus(EnumVideoStatus.hy_success.getCode()); | // speakVideoUpd.setVideoStatus(EnumVideoStatus.hy_success.getCode()); | ||||
// speakVideoUpd.setVideoMsg("超分视频生成成功"); | // speakVideoUpd.setVideoMsg("超分视频生成成功"); | ||||
@@ -416,7 +401,7 @@ public class PhotoSpeakVideoServiceImpl implements PhotoSpeakVideoService { | |||||
@Override | @Override | ||||
public void uploadHyVideo(PhotoSpeakVideo mouldVideo){ | public void uploadHyVideo(PhotoSpeakVideo mouldVideo){ | ||||
if(EnumVideoStatus.hy_success.getCode().equals(mouldVideo.getVideoStatus())){ | if(EnumVideoStatus.hy_success.getCode().equals(mouldVideo.getVideoStatus())){ | ||||
String url = hy_url + mouldVideo.getVideoPath(); | |||||
String url = AiVideoHelper.photo_speak_hy + mouldVideo.getVideoPath(); | |||||
VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | ||||
if(result.isSuccess()){ | if(result.isSuccess()){ | ||||
PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | PhotoSpeakVideo videoUpd = new PhotoSpeakVideo(); | ||||
@@ -16,6 +16,8 @@ import com.iformall.sm.AiVideoHelper; | |||||
import com.iformall.sm.AiVideoParam; | import com.iformall.sm.AiVideoParam; | ||||
import com.iformall.sm.AiVideoResult; | import com.iformall.sm.AiVideoResult; | ||||
import com.iformall.utils.Base64Util; | import com.iformall.utils.Base64Util; | ||||
import com.iformall.utils.Constant; | |||||
import com.iformall.utils.RedisLock; | |||||
import com.iformall.video.VideoFactory; | import com.iformall.video.VideoFactory; | ||||
import com.iformall.video.entity.VideUploadResult; | import com.iformall.video.entity.VideUploadResult; | ||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
@@ -26,6 +28,8 @@ import org.springframework.beans.factory.annotation.Value; | |||||
import org.springframework.scheduling.annotation.Async; | import org.springframework.scheduling.annotation.Async; | ||||
import org.springframework.scheduling.annotation.AsyncResult; | import org.springframework.scheduling.annotation.AsyncResult; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import org.springframework.transaction.annotation.Propagation; | |||||
import org.springframework.transaction.annotation.Transactional; | |||||
import java.net.URL; | import java.net.URL; | ||||
import java.util.*; | import java.util.*; | ||||
@@ -57,15 +61,8 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
@Autowired | @Autowired | ||||
String videoType; | String videoType; | ||||
@Value("${photo.url}") | |||||
private String url; | |||||
@Value("${photo.hy_url}") | |||||
private String hy_url; | |||||
@Value("${photo.talk}") | |||||
private String talk_url; | |||||
//停顿符 | |||||
private final static String str = "\uD83D\uDD57"; | |||||
@Autowired | |||||
RedisLock redisLock; | |||||
@Override | @Override | ||||
public PageInfo<UserMouldVideo> listAsPage(UserMouldVideo record, Integer pageIndex, Integer pageSize) { | public PageInfo<UserMouldVideo> listAsPage(UserMouldVideo record, Integer pageIndex, Integer pageSize) { | ||||
@@ -352,7 +349,7 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
try{ | try{ | ||||
AiVideoParam videoParam = new AiVideoParam(); | AiVideoParam videoParam = new AiVideoParam(); | ||||
videoParam.setGen_txt(paperwork.replaceAll(str, "[*]")); | |||||
videoParam.setGen_txt(paperwork.replaceAll(Constant.text_pause, "[*]")); | |||||
videoParam.setVideo_template_id(personMouldSmId); | videoParam.setVideo_template_id(personMouldSmId); | ||||
videoParam.setSubtitle(subtitleMap); | videoParam.setSubtitle(subtitleMap); | ||||
videoParam.setVoice_id(voiceMouldSmId); | videoParam.setVoice_id(voiceMouldSmId); | ||||
@@ -394,7 +391,7 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
} | } | ||||
videoParam.setVideo_files(videoFiles); | videoParam.setVideo_files(videoFiles); | ||||
AiVideoResult video = AiVideoHelper.createVideo(videoParam); | |||||
AiVideoResult video = AiVideoHelper.createVideo(videoParam,mouldVideo.getId()); | |||||
if(video.isSuccess()){ | if(video.isSuccess()){ | ||||
videoUpd.setVideoPath(video.getUrl()); | videoUpd.setVideoPath(video.getUrl()); | ||||
// videoUpd.setVideoTime(video.getDuration()+""); | // videoUpd.setVideoTime(video.getDuration()+""); | ||||
@@ -423,19 +420,60 @@ public class UserMouldVideoServiceImpl implements UserMouldVideoService { | |||||
} | } | ||||
@Async | |||||
@Override | @Override | ||||
public void uploadVideo(UserMouldVideo mouldVideo){ | public void uploadVideo(UserMouldVideo mouldVideo){ | ||||
if(EnumVideoStatus.success.getCode().equals(mouldVideo.getVideoStatus()) | |||||
|| EnumVideoStatus.upload_fail.getCode().equals(mouldVideo.getVideoStatus())){ | |||||
String url = talk_url + mouldVideo.getVideoPath(); | |||||
VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | |||||
if(result.isSuccess()){ | |||||
UserMouldVideo videoUpd = new UserMouldVideo(); | |||||
videoUpd.setId(mouldVideo.getId()); | |||||
videoUpd.setVideoId(result.getVideoId()); | |||||
videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
this.saveOrUpdate(videoUpd); | |||||
String lockKey = "oralBroadcasting:handleVideo:"+mouldVideo.getId(); | |||||
long time = System.currentTimeMillis() + 30000; | |||||
String timeStr = String.valueOf(time); | |||||
if(!redisLock.lock2(lockKey, timeStr)){ | |||||
return; | |||||
} | |||||
try{ | |||||
UserMouldVideo userMouldVideo = this.getById(mouldVideo.getId()); | |||||
if(EnumVideoStatus.success.getCode().equals(userMouldVideo.getVideoStatus()) | |||||
|| EnumVideoStatus.upload_fail.getCode().equals(userMouldVideo.getVideoStatus())){ | |||||
String url = AiVideoHelper.oral_broadcasting + mouldVideo.getVideoPath(); | |||||
VideUploadResult result = videoFactory.getExcutor(videoType).uploadVideoPath(mouldVideo.getTitle(), url); | |||||
if(result.isSuccess()){ | |||||
UserMouldVideo videoUpd = new UserMouldVideo(); | |||||
videoUpd.setId(userMouldVideo.getId()); | |||||
videoUpd.setVideoId(result.getVideoId()); | |||||
videoUpd.setVideoStatus(EnumVideoStatus.upload_ing.getCode()); | |||||
this.saveOrUpdate(videoUpd); | |||||
//实时判断上传状态 | |||||
for (int i = 0;i <= 30; i++){ | |||||
try { | |||||
Thread.sleep(1000); | |||||
} catch (InterruptedException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
String progress = videoFactory.getExcutor(videoType).getVedioUploadProgress(result.getVideoId()); | |||||
if (progress.equals("complete")) { | |||||
VideUploadResult videoDetail = videoFactory.getExcutor(videoType).getVideoDetailWithCache(result.getVideoId(),true); | |||||
if (videoDetail.isSuccess()){ | |||||
videoUpd = new UserMouldVideo(); | |||||
videoUpd.setId(userMouldVideo.getId()); | |||||
videoUpd.setCoverImg(videoDetail.getCoverURL()); | |||||
videoUpd.setVideoPlayUrl(videoDetail.getVideoUrl()); | |||||
videoUpd.setVideoTime(videoDetail.getDuration()); | |||||
videoUpd.setVideoSize(videoDetail.getSize()); | |||||
videoUpd.setVideoStatus(EnumVideoStatus.upload_success.getCode()); | |||||
videoUpd.setVideoMsg("视频上传成功"); | |||||
videoUpd.setUpdateDate(new Date()); | |||||
this.updateById(videoUpd); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
}catch(Exception e){ | |||||
}finally{ | |||||
redisLock.unlock(lockKey, timeStr); | |||||
} | } | ||||
} | } | ||||
@@ -11,9 +11,11 @@ import com.iformall.domain.po.sm.VoiceInfo; | |||||
import com.iformall.domain.vo.VoiceInfoVo; | import com.iformall.domain.vo.VoiceInfoVo; | ||||
import com.iformall.enums.EnumSex; | import com.iformall.enums.EnumSex; | ||||
import com.iformall.enums.EnumSpeakType; | import com.iformall.enums.EnumSpeakType; | ||||
import com.iformall.file.aliyun.bean.AliyunOSSConfig; | |||||
import com.iformall.mapper.VoiceMapper; | import com.iformall.mapper.VoiceMapper; | ||||
import com.iformall.service.sm.VoiceInfoService; | import com.iformall.service.sm.VoiceInfoService; | ||||
import com.iformall.sm.*; | import com.iformall.sm.*; | ||||
import com.iformall.utils.Constant; | |||||
import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
@@ -28,9 +30,11 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
@Autowired | @Autowired | ||||
private VoiceMapper voiceMapper; | private VoiceMapper voiceMapper; | ||||
private final static String str = "\uD83D\uDD57"; | |||||
private final static String url = "https://suimang.oss-accelerate.aliyuncs.com/builtin/tts_all_sample/"; | |||||
private final static String end = ".wav"; | |||||
@Autowired | |||||
private AliyunOSSConfig aliyunOSSConfig; | |||||
private final String demoDirectory = "/builtin/tts_all_sample/"; | |||||
private final String demoSuffix = ".wav"; | |||||
@Override | @Override | ||||
public List<VoiceInfo> chooseType(Long id) { | public List<VoiceInfo> chooseType(Long id) { | ||||
@@ -44,13 +48,13 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
VoiceInfoVo infoVo = new VoiceInfoVo(); | VoiceInfoVo infoVo = new VoiceInfoVo(); | ||||
infoVo.setName(EnumSpeakType.getEnum(y).getMessage()); | infoVo.setName(EnumSpeakType.getEnum(y).getMessage()); | ||||
infoVo.setEngName(y); | infoVo.setEngName(y); | ||||
infoVo.setUrl(url + x.getMouldSmId() + "_" + y + end); | |||||
infoVo.setUrl(aliyunOSSConfig.getFiledomain() + demoDirectory + x.getMouldSmId() + "_" + y + demoSuffix); | |||||
list.add(infoVo); | list.add(infoVo); | ||||
}); | }); | ||||
VoiceInfoVo infoVo = new VoiceInfoVo(); | VoiceInfoVo infoVo = new VoiceInfoVo(); | ||||
infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | ||||
infoVo.setUrl(url + x.getMouldSmId() + "_" + "default" + end); | |||||
infoVo.setUrl(aliyunOSSConfig.getFiledomain() + demoDirectory + x.getMouldSmId() + "_" + "default" + demoSuffix); | |||||
infoVo.setEngName("default"); | infoVo.setEngName("default"); | ||||
list.add(infoVo); | list.add(infoVo); | ||||
x.setStyle(list); | x.setStyle(list); | ||||
@@ -59,7 +63,7 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
VoiceInfoVo infoVo = new VoiceInfoVo(); | VoiceInfoVo infoVo = new VoiceInfoVo(); | ||||
infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | infoVo.setName(EnumSpeakType.getEnum(0).getMessage()); | ||||
infoVo.setEngName("default"); | infoVo.setEngName("default"); | ||||
infoVo.setUrl(url + x.getMouldSmId() + "_" + "default" + end); | |||||
infoVo.setUrl(aliyunOSSConfig.getFiledomain() + demoDirectory + x.getMouldSmId() + "_" + "default" + demoSuffix); | |||||
list.add(infoVo); | list.add(infoVo); | ||||
x.setStyle(list); | x.setStyle(list); | ||||
} | } | ||||
@@ -79,7 +83,7 @@ public class VoiceInfoServiceImpl implements VoiceInfoService { | |||||
return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "声音信息不存在"); | return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "声音信息不存在"); | ||||
} | } | ||||
AiPreviewParam param = new AiPreviewParam(); | AiPreviewParam param = new AiPreviewParam(); | ||||
param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(str,"[*]")); | |||||
param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(Constant.text_pause,"[*]")); | |||||
param.setVoice_id(voiceInfo.getMouldSmId()); | param.setVoice_id(voiceInfo.getMouldSmId()); | ||||
param.setVoice_style(StringUtils.isBlank(aiPreviewParam.getVoice_style()) ? EnumSpeakType.default_0.getMessage() : aiPreviewParam.getVoice_style()); | param.setVoice_style(StringUtils.isBlank(aiPreviewParam.getVoice_style()) ? EnumSpeakType.default_0.getMessage() : aiPreviewParam.getVoice_style()); | ||||
param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | ||||
@@ -19,20 +19,20 @@ import java.util.List; | |||||
@Component | @Component | ||||
public class AiDigitalAvatarHelper { | public class AiDigitalAvatarHelper { | ||||
private static String digital_avatar; | |||||
@Value("${photo.digital_avatar}") | |||||
public static String digital_avatar; | |||||
@Value("${suimang.digital_avatar}") | |||||
public void setDigitalAvatar(String digital_avatar){ | public void setDigitalAvatar(String digital_avatar){ | ||||
this.digital_avatar = digital_avatar; | this.digital_avatar = digital_avatar; | ||||
} | } | ||||
private static String digital_avatar_hy; | |||||
@Value("${photo.digital_avatar_hy}") | |||||
public static String digital_avatar_hy; | |||||
@Value("${suimang.digital_avatar_hy}") | |||||
public void setDigitalAvatarHy(String digital_avatar_hy){ | public void setDigitalAvatarHy(String digital_avatar_hy){ | ||||
this.digital_avatar_hy = digital_avatar_hy; | this.digital_avatar_hy = digital_avatar_hy; | ||||
} | } | ||||
private static String callbackUrl; | |||||
@Value("${photo.callbackUrl}") | |||||
public static String callbackUrl; | |||||
@Value("${suimang.callbackUrl}") | |||||
public void setCallbackUrl(String callbackUrl){ | public void setCallbackUrl(String callbackUrl){ | ||||
this.callbackUrl = callbackUrl; | this.callbackUrl = callbackUrl; | ||||
} | } | ||||
@@ -31,39 +31,43 @@ import java.util.*; | |||||
@Component | @Component | ||||
public class AiVideoHelper { | public class AiVideoHelper { | ||||
private static String url; | |||||
@Value("${photo.url}") | |||||
public void setUrl(String url){ | |||||
this.url = url; | |||||
public static String oral_broadcasting; | |||||
@Value("${suimang.oral_broadcasting}") | |||||
public void setOralBroadcasting(String oral_broadcasting){ | |||||
this.oral_broadcasting = oral_broadcasting; | |||||
} | } | ||||
private static String hy_url; | |||||
@Value("${photo.hy_url}") | |||||
public void setHyUrl(String hyUrl){ | |||||
this.hy_url = hyUrl; | |||||
public static String photo_speak; | |||||
@Value("${suimang.photo_speak}") | |||||
public void setPhotoSpeak(String photo_speak){ | |||||
this.photo_speak = photo_speak; | |||||
} | } | ||||
private static String talk_url; | |||||
@Value("${photo.talk}") | |||||
public void setTalkUrl(String talkUrl){ | |||||
this.talk_url = talkUrl; | |||||
public static String photo_speak_hy; | |||||
@Value("${suimang.photo_speak_hy}") | |||||
public void setPhotoSpeakHy(String photo_speak_hy){ | |||||
this.photo_speak_hy = photo_speak_hy; | |||||
} | } | ||||
public static String callbackUrl; | |||||
@Value("${suimang.callbackUrl}") | |||||
public void setCallbackUrl(String callbackUrl){ | |||||
this.callbackUrl = callbackUrl; | |||||
} | |||||
public static String photo_speak_suffix = "/img_talking"; | |||||
public static String image_quality_suffix = "/image_qualit"; | |||||
public static String voice_preview = "/tts_wav"; | |||||
public static String video_hq = "/video_hq"; | |||||
public static String doPost(String url, String params) { | public static String doPost(String url, String params) { | ||||
return HttpUtil.doAiVideoPost(url,params); | return HttpUtil.doAiVideoPost(url,params); | ||||
} | } | ||||
public static AiVideoResult createVideo(AiVideoParam videoParam) { | |||||
public static AiVideoResult createVideo(AiVideoParam videoParam,Long taskId) { | |||||
videoParam.setTask_id(taskId); | |||||
videoParam.setCallback_url(callbackUrl + "/callback/oral/broadcasting"); | |||||
log.info("生成视频start request:" + videoParam.neglectImgString()); | log.info("生成视频start request:" + videoParam.neglectImgString()); | ||||
String response = doPost(talk_url+"/gen_dh_video", JSONObject.toJSONString(videoParam)); | |||||
String response = doPost(oral_broadcasting+"/gen_dh_video", JSONObject.toJSONString(videoParam)); | |||||
log.info("生成视频end response:"+response); | log.info("生成视频end response:"+response); | ||||
AiVideoResult result = new AiVideoResult(); | AiVideoResult result = new AiVideoResult(); | ||||
@@ -119,53 +123,11 @@ public class AiVideoHelper { | |||||
// return result; | // return result; | ||||
// } | // } | ||||
} | } | ||||
public static AiPhotoSpeakResult createPhotoSpeakVideo(AiPhotoSpeakParam videoParam) { | |||||
log.info("生成视频start request:" + videoParam.neglectImgString()); | |||||
String response = doPost(url + photo_speak_suffix, JSONObject.toJSONString(videoParam)); | |||||
log.info("生成视频end response:" + response); | |||||
AiPhotoSpeakResult result = new AiPhotoSpeakResult(); | |||||
if (StringUtils.isBlank(response)) { | |||||
result.setSuccess(false); | |||||
result.setMsg("(MetaService empty)服务被Avatar攻击..."); | |||||
return result; | |||||
} | |||||
JSONObject jsonObject = JSON.parseObject(response); | |||||
JSONObject status = jsonObject.getJSONObject("status"); | |||||
Integer code = status.getInteger("code"); | |||||
String msg = status.getString("msg"); | |||||
if (code == null) { | |||||
result.setSuccess(false); | |||||
result.setMsg("(MetaService code empty)服务被Avatar攻击..."); | |||||
return result; | |||||
} | |||||
if (code.intValue() == 4000) { | |||||
JSONObject data = jsonObject.getJSONObject("data"); | |||||
String videoUrl = data.getString("url"); | |||||
String saveDir = data.getString("save_dir"); | |||||
String audioPath = data.getString("audio_path"); | |||||
result.setSuccess(true); | |||||
result.setUrl(videoUrl); | |||||
result.setSaveDir(saveDir); | |||||
result.setCode(code); | |||||
result.setAudioPath(audioPath); | |||||
String resultMsg = result.getMsgInfo(code, msg); | |||||
result.setMsg(resultMsg); | |||||
} else { | |||||
result.setSuccess(false); | |||||
result.setCode(code); | |||||
String resultMsg = result.getMsgInfo(code, msg); | |||||
result.setMsg(resultMsg); | |||||
} | |||||
return result; | |||||
} | |||||
public static AiCheckPhotoResult checkPhoto(AiCheckPhotoParam param) { | public static AiCheckPhotoResult checkPhoto(AiCheckPhotoParam param) { | ||||
// String response = doPost("http://111.198.0.15:22299" + image_quality_suffix, JSONObject.toJSONString(param)); | |||||
String response = doPost(url + image_quality_suffix, JSONObject.toJSONString(param)); | |||||
// String response = doPost("http://111.198.0.15:22299" + "/image_qualit", JSONObject.toJSONString(param)); | |||||
String response = doPost(photo_speak + "/image_qualit", JSONObject.toJSONString(param)); | |||||
log.info("图片质量审核 end response:" + response); | log.info("图片质量审核 end response:" + response); | ||||
log.info("图片质量审核 IP:" + url + image_quality_suffix); | |||||
AiCheckPhotoResult result = new AiCheckPhotoResult(); | AiCheckPhotoResult result = new AiCheckPhotoResult(); | ||||
if (StringUtils.isBlank(response)) { | if (StringUtils.isBlank(response)) { | ||||
@@ -197,9 +159,8 @@ public class AiVideoHelper { | |||||
} | } | ||||
public static AiPreviewResult voicePreview(AiPreviewParam param) { | public static AiPreviewResult voicePreview(AiPreviewParam param) { | ||||
String response = doPost(url + voice_preview, JSONObject.toJSONString(param)); | |||||
String response = doPost(photo_speak + "/tts_wav", JSONObject.toJSONString(param)); | |||||
log.info("TTS音色预览 end response:" + response); | log.info("TTS音色预览 end response:" + response); | ||||
log.info("TTS音色预览 IP:" + url + voice_preview); | |||||
AiPreviewResult result = new AiPreviewResult(); | AiPreviewResult result = new AiPreviewResult(); | ||||
if (StringUtils.isBlank(response)) { | if (StringUtils.isBlank(response)) { | ||||
@@ -227,7 +188,7 @@ public class AiVideoHelper { | |||||
if (code.intValue() == 3000) { | if (code.intValue() == 3000) { | ||||
result.setCode(200); | result.setCode(200); | ||||
result.setSuccess(true); | result.setSuccess(true); | ||||
result.setUrl(url + strURL); | |||||
result.setUrl(photo_speak + strURL); | |||||
result.setTime(Double.valueOf(time)); | result.setTime(Double.valueOf(time)); | ||||
String resultMsg = result.getMsgInfo(code, msg); | String resultMsg = result.getMsgInfo(code, msg); | ||||
result.setMsg(resultMsg); | result.setMsg(resultMsg); | ||||
@@ -240,10 +201,59 @@ public class AiVideoHelper { | |||||
return result; | return result; | ||||
} | } | ||||
public static AiVideoHqResult videoHq(AiVideoHqParam param) { | |||||
String response = doPost(hy_url + video_hq, JSONObject.toJSONString(param)); | |||||
public static AiPhotoSpeakResult createPhotoSpeakVideo(AiPhotoSpeakParam videoParam,Long taskId) { | |||||
videoParam.setTask_id(taskId); | |||||
videoParam.setCallback_url(callbackUrl + "/callback/photo/speak"); | |||||
log.info("生成视频start request:" + videoParam.neglectImgString()); | |||||
String response = doPost(photo_speak + "/img_talking", JSONObject.toJSONString(videoParam)); | |||||
log.info("生成视频end response:" + response); | |||||
AiPhotoSpeakResult result = new AiPhotoSpeakResult(); | |||||
if (StringUtils.isBlank(response)) { | |||||
result.setSuccess(false); | |||||
result.setMsg("(MetaService empty)服务被Avatar攻击..."); | |||||
return result; | |||||
} | |||||
JSONObject jsonObject = JSON.parseObject(response); | |||||
JSONObject status = jsonObject.getJSONObject("status"); | |||||
Integer code = status.getInteger("code"); | |||||
String msg = status.getString("msg"); | |||||
if (code == null) { | |||||
result.setSuccess(false); | |||||
result.setMsg("(MetaService code empty)服务被Avatar攻击..."); | |||||
return result; | |||||
} | |||||
if (code.intValue() == 4000) { | |||||
JSONObject data = jsonObject.getJSONObject("data"); | |||||
String videoUrl = data.getString("url"); | |||||
String saveDir = data.getString("save_dir"); | |||||
String audioPath = data.getString("audio_path"); | |||||
result.setSuccess(true); | |||||
result.setUrl(videoUrl); | |||||
result.setSaveDir(saveDir); | |||||
result.setCode(code); | |||||
result.setAudioPath(audioPath); | |||||
String resultMsg = result.getMsgInfo(code, msg); | |||||
result.setMsg(resultMsg); | |||||
} else { | |||||
result.setSuccess(false); | |||||
result.setCode(code); | |||||
String resultMsg = result.getMsgInfo(code, msg); | |||||
result.setMsg(resultMsg); | |||||
} | |||||
return result; | |||||
} | |||||
public static AiVideoHqResult videoHq(AiVideoHqParam param,Long taskId) { | |||||
param.setTask_id(taskId); | |||||
param.setCallback_url(callbackUrl + "/callback/photo/speak"); | |||||
String response = doPost(photo_speak_hy + "/video_hq", JSONObject.toJSONString(param)); | |||||
log.info("视频超分 end response:" + response); | log.info("视频超分 end response:" + response); | ||||
log.info("视频超分 IP:" + hy_url + video_hq); | |||||
AiVideoHqResult result = new AiVideoHqResult(); | AiVideoHqResult result = new AiVideoHqResult(); | ||||
if (StringUtils.isBlank(response)) { | if (StringUtils.isBlank(response)) { | ||||
@@ -269,7 +279,7 @@ public class AiVideoHelper { | |||||
if (code.intValue() == 5000) { | if (code.intValue() == 5000) { | ||||
result.setCode(200); | result.setCode(200); | ||||
result.setSuccess(true); | result.setSuccess(true); | ||||
result.setUrl(url + strURL); | |||||
result.setUrl(strURL); | |||||
String resultMsg = result.getMsgInfo(code, msg); | String resultMsg = result.getMsgInfo(code, msg); | ||||
result.setMsg(resultMsg); | result.setMsg(resultMsg); | ||||
} else { | } else { | ||||
@@ -32,6 +32,9 @@ public class AiVideoParam { | |||||
* | +++ ratio | 是 | float32 | 相对于原素材图片大小的缩放比例,如0.5表示宽高均变为原来的一半 | | * | +++ ratio | 是 | float32 | 相对于原素材图片大小的缩放比例,如0.5表示宽高均变为原来的一半 | | ||||
*/ | */ | ||||
private Long task_id; | |||||
private String callback_url; | |||||
private String gen_txt; | private String gen_txt; | ||||
private String video_template_id; | private String video_template_id; | ||||
private String voice_id; | private String voice_id; | ||||
@@ -118,4 +118,6 @@ public class Constant { | |||||
public static final Integer wiwideOldPlat = 0;//老平台 | public static final Integer wiwideOldPlat = 0;//老平台 | ||||
public static final Integer wiwideNewPlat = 1;//新平台 | public static final Integer wiwideNewPlat = 1;//新平台 | ||||
public static final String text_pause = "\uD83D\uDD57"; | |||||
} | } |