| @@ -171,4 +171,5 @@ public interface WxMerchantService { | |||
| ResultData markup(WxMerchant wxMerchant); | |||
| ResultData addttMerchant(WxMerchant wxMerchant, Long userId); | |||
| } | |||
| @@ -102,6 +102,9 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| @Autowired | |||
| WxPropertyContractService wxPropertyContractService; | |||
| @Autowired | |||
| WxMallService wxMallService; | |||
| @Autowired | |||
| TtUserFollowMapper ttUserFollowMapper; | |||
| @@ -1032,4 +1035,54 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||
| return new ResultData(Result.SUCCESS, "操作成功"); | |||
| } | |||
| @Override | |||
| public ResultData addttMerchant(WxMerchant wxMerchant, Long userId) { | |||
| try { | |||
| WxMall mall = wxMallService.getByTenantId(wxMerchant.getTenantId()); | |||
| if(mall == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到组织"); | |||
| } | |||
| wxMerchant.updateTenantInfo(mall.getTenantInfo()); | |||
| if (hasMerchant(wxMerchant)) { | |||
| return new ResultData(ErrorCode.MERCHANT_NAME_IS_FOUND,"名称已存在"); | |||
| } | |||
| if (hasMerchantEncode(wxMerchant)) { | |||
| return new ResultData(ErrorCode.MERCHANT_CODE_IS_FOUND,"编码已存在"); | |||
| } | |||
| if (StringUtils.isNotBlank(wxMerchant.getCoverPicture())) { | |||
| List<String> coverPicture = JSONArray.parseArray(wxMerchant.getCoverPicture(), String.class); | |||
| if (!coverPicture.isEmpty()) { | |||
| wxMerchant.setImgUrl(coverPicture.get(0)); | |||
| } | |||
| } else { | |||
| if (StringUtils.isNotBlank(wxMerchant.getImgUrl())) { | |||
| List<String> strList = new ArrayList<String>(); | |||
| strList.add(wxMerchant.getImgUrl()); | |||
| wxMerchant.setCoverPicture(JSONArray.toJSONString(strList)); | |||
| } | |||
| } | |||
| Date date = new Date(); | |||
| if(wxMerchant.getId() == null){ | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMerchant.setId(idWorker.nextId()); | |||
| wxMerchant.setStatus(EnumMerchantStatus.VALID.getCode()); | |||
| if(wxMerchant.getIsAdmin() == null) { | |||
| wxMerchant.setIsAdmin(EnumYesOrNo.NO.getCode()); | |||
| } | |||
| wxMerchant.setUpdateDate(date); | |||
| wxMerchant.setCreateDate(date); | |||
| wxMerchantMapper.insert(wxMerchant); | |||
| }else{ | |||
| wxMerchant.setUpdateDate(date); | |||
| wxMerchantMapper.updateById(wxMerchant); | |||
| } | |||
| return new ResultData(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| logger.error("db failed:, e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -152,8 +152,8 @@ public class ShiroConfig { | |||
| //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||
| filterChainDefinitionMap.put("/logout", "authc"); | |||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| // filterChainDefinitionMap.put("/**", "anon"); | |||
| // filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| filterChainDefinitionMap.put("/**", "anon"); | |||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
| @@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| @@ -21,6 +22,7 @@ import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -368,4 +370,16 @@ public class WxMerchantController extends BaseController { | |||
| return wxMerchantService.markup(wxMerchant); | |||
| } | |||
| @ApiOperation("新增作者") | |||
| @PostMapping("addttMerchant") | |||
| @SystemControllerLog(description = "商户-新增") | |||
| public ResultData addttMerchant(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant"); | |||
| if(StringUtils.isBlank(wxMerchant.getTenantId())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"未选择组织"); | |||
| } | |||
| ResultData resultData = wxMerchantService.addttMerchant(wxMerchant, getUserId()); | |||
| return resultData; | |||
| } | |||
| } | |||
| @@ -2,9 +2,9 @@ package com.iformall.schedule; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.enums.EnumAppType; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| @@ -5,11 +5,13 @@ import java.io.InputStream; | |||
| import java.util.List; | |||
| import java.util.UUID; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse; | |||
| import com.aliyuncs.vod.model.v20170321.GetPlayInfoResponse; | |||
| import com.baomidou.mybatisplus.core.toolkit.IdWorker; | |||
| import org.apache.commons.io.FileUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| @@ -109,31 +111,42 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||
| @Override | |||
| public VideUploadResult getVideoDetail(String videoId) { | |||
| VideUploadResult result = new VideUploadResult(); | |||
| result.setVideoId(videoId); | |||
| try { | |||
| GetPlayInfoResponse response = AliyunVedioServer.getPlayInfoResponse(config, videoId); | |||
| if(response != null){ | |||
| List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList(); | |||
| //播放地址 | |||
| for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) { | |||
| result.setVideoUrl(playInfo.getPlayURL()); | |||
| break; | |||
| VideUploadResult videoDetail = UploadCacheHelper.getVideoDetail(redisTemplate, videoId); | |||
| if(videoDetail != null){ | |||
| return videoDetail; | |||
| }else{ | |||
| VideUploadResult result = new VideUploadResult(); | |||
| result.setVideoId(videoId); | |||
| try { | |||
| GetPlayInfoResponse response = AliyunVedioServer.getPlayInfoResponse(config, videoId); | |||
| log.info("shipin---Detail{}"+JSON.toJSONString(response)); | |||
| if(response != null){ | |||
| List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList(); | |||
| //播放地址 | |||
| for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) { | |||
| result.setVideoUrl(playInfo.getPlayURL()); | |||
| break; | |||
| } | |||
| GetPlayInfoResponse.VideoBase videoBase = response.getVideoBase(); | |||
| result.setDuration(videoBase.getDuration()); | |||
| result.setCoverURL(videoBase.getCoverURL()); | |||
| result.setTitle(videoBase.getTitle()); | |||
| result.setSuccess(true); | |||
| if(StringUtils.isNotBlank(result.getCoverURL()) | |||
| && StringUtils.isNotBlank(result.getDuration()) | |||
| && !"0.0".equals(result.getDuration())){ | |||
| UploadCacheHelper.cacheVideoDetail(redisTemplate, videoId,result); | |||
| } | |||
| }else{ | |||
| result.setSuccess(false); | |||
| result.setMsg("未获取到视频"); | |||
| } | |||
| GetPlayInfoResponse.VideoBase videoBase = response.getVideoBase(); | |||
| result.setDuration(videoBase.getDuration()); | |||
| result.setCoverURL(videoBase.getCoverURL()); | |||
| result.setTitle(videoBase.getTitle()); | |||
| result.setSuccess(true); | |||
| }else{ | |||
| } catch (ClientException e) { | |||
| result.setSuccess(false); | |||
| result.setMsg("未获取到视频"); | |||
| result.setMsg("获取视频请求异常"); | |||
| } | |||
| } catch (ClientException e) { | |||
| result.setSuccess(false); | |||
| result.setMsg("获取视频请求异常"); | |||
| return result; | |||
| } | |||
| return result; | |||
| } | |||
| @Override | |||
| @@ -2,12 +2,15 @@ package com.iformall.video.aliyun.sdk.server; | |||
| import java.util.concurrent.TimeUnit; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.iformall.video.entity.VideUploadResult; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.data.redis.core.ValueOperations; | |||
| public class UploadCacheHelper { | |||
| private static String PRE = "video:upload:aliyun:progress:"; | |||
| private static String DETAIL = "video:upload:aliyun:detail:"; | |||
| public static void cacheStart(RedisTemplate<String, Object> template,String videoId) { | |||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||
| @@ -55,5 +58,26 @@ public class UploadCacheHelper { | |||
| } | |||
| return null; | |||
| } | |||
| public static void cacheVideoDetail(RedisTemplate<String, Object> template,String videoId, Object value) { | |||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||
| operations.set(DETAIL+videoId, value, 24,TimeUnit.DAYS); | |||
| } | |||
| public static VideUploadResult getVideoDetail(RedisTemplate<String, Object> template, String videoId) { | |||
| String key = DETAIL+videoId; | |||
| if (template.hasKey(key)) { | |||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||
| Object o = operations.get(key); | |||
| if (o instanceof VideUploadResult) { | |||
| return (VideUploadResult)o; | |||
| }else if(o instanceof String){ | |||
| JSON.parseObject((String)o,VideUploadResult.class); | |||
| }else{ | |||
| JSON.parseObject(JSON.toJSONString(o),VideUploadResult.class); | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| } | |||