| @@ -90,8 +90,7 @@ public class VideoController extends BaseController { | |||||
| */ | */ | ||||
| @PostMapping(value = "/upload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | @PostMapping(value = "/upload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | ||||
| @ApiOperation("上传视频") | @ApiOperation("上传视频") | ||||
| @SystemControllerLog(description = "文件上传") | |||||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq,@RequestParam Map<String, String> param) { | |||||
| public ResultData upload(@RequestParam("file") MultipartFile multiReq,@RequestParam Map<String, String> param) { | |||||
| try { | try { | ||||
| String title = param.get("title"); | String title = param.get("title"); | ||||
| VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo(title, multiReq.getInputStream()); | VideUploadResult result = videoFactory.getExcutor(videoType).uploadLocalVideo(title, multiReq.getInputStream()); | ||||
| @@ -101,5 +100,26 @@ public class VideoController extends BaseController { | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 上传视频 | |||||
| * | |||||
| * @param multiReq | |||||
| * @return | |||||
| * @throws Exception | |||||
| */ | |||||
| @GetMapping(value = "/uploadProgress") | |||||
| @ApiOperation("上传视频进度") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name = "videoId", value = "视频编号", dataType = "String", paramType = "query", required = true)}) | |||||
| public ResultData uploadProgress(String videoId) { | |||||
| try { | |||||
| String result = videoFactory.getExcutor(videoType).getVedioUploadProgress(videoId); | |||||
| return new ResultData(result); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -44,24 +44,6 @@ public class BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmOpen; | |||||
| @Autowired | |||||
| private WxAppinfoService wxAppinfoService; | |||||
| @Autowired | |||||
| private FmOpenService openService; | |||||
| @Autowired | |||||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||||
| @Autowired | |||||
| private WxCUserBasicChildService wxCUserBasicChildService; | |||||
| @Autowired | |||||
| private CUserTokenService cUserTokenService; | |||||
| @Autowired | @Autowired | ||||
| @Qualifier("objectCommonRedisTemplate") | @Qualifier("objectCommonRedisTemplate") | ||||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | RedisTemplate<String, Object> objectCommonRedisTemplate; | ||||
| @@ -74,7 +56,7 @@ public class BaseController { | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | ||||
| } catch (ParseException e) { | } catch (ParseException e) { | ||||
| try { | try { | ||||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||||
| setValue(new SimpleDateFormat("yyyy-MM-dd").parse(value)); | |||||
| } catch (ParseException e1) { | } catch (ParseException e1) { | ||||
| setValue(null); | setValue(null); | ||||
| } | } | ||||
| @@ -88,202 +70,7 @@ public class BaseController { | |||||
| }); | }); | ||||
| } | } | ||||
| @Deprecated | |||||
| public String getTenantId() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String tenantId = (String) request.getAttribute(Constant.TENANT_ID); | |||||
| return tenantId; | |||||
| } | |||||
| public TenantEntity getTenantInfo() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String tenantId = (String) request.getAttribute(Constant.TENANT_ID); | |||||
| String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID); | |||||
| TenantEntity tenantEntity = new TenantEntity() ; | |||||
| tenantEntity.setTenantId(tenantId); | |||||
| tenantEntity.setParentTenantId(parentTenantId); | |||||
| return tenantEntity; | |||||
| } | |||||
| public String getFinalTenantId() { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| return tenantEntity.getFinalTenantId(); | |||||
| } | |||||
| public Long getMemberId() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| Long memberId = (Long) request.getAttribute(Constant.LOGIN_MEMBER_KEY); | |||||
| if(memberId == null){ | |||||
| throw new MallinkException(ErrorCode.USER_IS_NOT_MEMBER); | |||||
| } | |||||
| return memberId; | |||||
| } | |||||
| /** | |||||
| * 微信端获取当前用户 wx_c_user,非会员 | |||||
| * 请尽量多用getTenantId, getUserId | |||||
| */ | |||||
| public WxCUser getWxCUser() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY); | |||||
| if (baseuser == null) { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (baseuser.getRealUser() == null) { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| WxCUser user = RedisCacheUtils.getFieldObject(baseuser, "realUser", WxCUser.class); | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| if (user.getTenantId() == null) { | |||||
| user.setTenantId(tenantEntity.getTenantId()); | |||||
| } | |||||
| if (user.getParentTenantId() == null) { | |||||
| user.setParentTenantId(tenantEntity.getParentTenantId()); | |||||
| } | |||||
| return user; | |||||
| } | |||||
| public void removeCacheCUser() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY); | |||||
| cUserTokenService.removeTokenCache(baseuser.getToken()); | |||||
| } | |||||
| public void updateCacheCUser(String token,Object cuser) { | |||||
| cUserTokenService.updateTokenCache(token, cuser); | |||||
| } | |||||
| private WxCUserBasicInfo getCacheMember(Long memberId,String finalTenantId,String key,long seconds) throws MallinkException { | |||||
| // 缓存 | |||||
| WxCUserBasicInfo member = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, key, WxCUserBasicInfo.class); | |||||
| if(null == member) { | |||||
| member = wxCUserBasicInfoService.getById(memberId,finalTenantId); | |||||
| if (member == null) { | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| setCUserBasicChild(member); | |||||
| RedisCacheUtils.cache(objectCommonRedisTemplate, key, member, seconds); | |||||
| } | |||||
| return member; | |||||
| } | |||||
| public WxCUserBasicInfo getCacheMember() throws MallinkException { | |||||
| Long memberId = getMemberId(); | |||||
| String key = "webapp:member:"+memberId; | |||||
| return getCacheMember(memberId,getFinalTenantId(), key, 3600*24*3); | |||||
| } | |||||
| /*此处缓存短暂时间,因为积分、成长值记录*/ | |||||
| public WxCUserBasicInfo getShortCacheMember(Long memberId,String finalTenantId) throws Exception { | |||||
| String key = "webapp:short:member:"+memberId; | |||||
| return getCacheMember(memberId,finalTenantId, key, 100); | |||||
| } | |||||
| public void removeCacheMember(Long memberId) { | |||||
| String key = "webapp:member:"+memberId; | |||||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, key); | |||||
| String shortKey = "webapp:short:member:"+memberId; | |||||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, shortKey); | |||||
| } | |||||
| public WxAppinfo getAppInfo(String appId) { | |||||
| return wxAppinfoService.getByAppId(appId); | |||||
| } | |||||
| public WxMaService getWeappService(String appId) { | |||||
| if(isFmOpen) { | |||||
| return openService.getWxOpenComponentService().getWxMaServiceByAppid(appId); | |||||
| } else { | |||||
| WxAppinfo appinfo = wxAppinfoService.getByAppId(appId); | |||||
| if (appinfo == null) { | |||||
| return null; | |||||
| } | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| } | |||||
| public WxMaService getWeappServiceByAppInfo(WxAppinfo appinfo) { | |||||
| if(!isFmOpen) { | |||||
| WxMaService service = MaUtil.getWeappService(appinfo); | |||||
| return service; | |||||
| } | |||||
| return null; | |||||
| } | |||||
| public Long saveToBasicInfoByCUser(String userPhone,String userName,String avatarUrl,Integer sex,Long userId) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| if (StringUtils.isBlank(userPhone)) | |||||
| return null; | |||||
| WxCUserBasicInfo byId = null; | |||||
| if (null != userId) { | |||||
| byId = wxCUserBasicInfoService.getById(userId,getFinalTenantId()); | |||||
| } | |||||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(tenantEntity, userPhone); | |||||
| if (basicInfo != null) { | |||||
| if (byId != null) { | |||||
| if (!byId.getId().equals(basicInfo.getId())) { | |||||
| //数据库存在此手机号的会员,并且当前微信存在另一手机号会员 | |||||
| logger.error("会员" + userId + "更换手机号时,当前手机号会员表已存在:" + userPhone); | |||||
| return Long.valueOf(-1); | |||||
| } | |||||
| } | |||||
| if (!basicInfo.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { | |||||
| basicInfo.setTenantId(basicInfo.getTenantId() + tenantEntity.getTenantId() + ","); | |||||
| } | |||||
| basicInfo.setNickName(userName); | |||||
| basicInfo.setAvatarUrl(avatarUrl); | |||||
| basicInfo.setSex(sex); | |||||
| wxCUserBasicInfoService.update(basicInfo); | |||||
| removeCacheMember(basicInfo.getId()); | |||||
| return basicInfo.getId(); | |||||
| } else { | |||||
| if (byId != null) { | |||||
| if (!byId.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { | |||||
| byId.setTenantId(byId.getTenantId() + tenantEntity.getTenantId() + ","); | |||||
| } | |||||
| byId.setPhone(userPhone); | |||||
| byId.setNickName(userName); | |||||
| byId.setAvatarUrl(avatarUrl); | |||||
| byId.setSex(sex); | |||||
| wxCUserBasicInfoService.update(byId); | |||||
| removeCacheMember(basicInfo.getId()); | |||||
| return byId.getId(); | |||||
| } else { | |||||
| basicInfo = new WxCUserBasicInfo(); | |||||
| basicInfo.setTenantId("," + tenantEntity.getTenantId() + ","); | |||||
| basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||||
| basicInfo.setPhone(userPhone); | |||||
| basicInfo.setNickName(userName); | |||||
| basicInfo.setAvatarUrl(avatarUrl); | |||||
| basicInfo.setSex(sex); | |||||
| wxCUserBasicInfoService.save(basicInfo); | |||||
| removeCacheMember(basicInfo.getId()); | |||||
| return basicInfo.getId(); | |||||
| } | |||||
| } | |||||
| } | |||||
| public String getIpAddr() { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String ipaddress = IPUtil.getIpAddr(request); | |||||
| return ipaddress; | |||||
| } | |||||
| private void setCUserBasicChild(WxCUserBasicInfo basicInfo){ | |||||
| WxCUserBasicChild child = new WxCUserBasicChild(); | |||||
| child.setCUserId(basicInfo.getId()); | |||||
| child.setTenantId(basicInfo.getFinalTenantId()); | |||||
| List<WxCUserBasicChild> list = wxCUserBasicChildService.findList(child); | |||||
| basicInfo.setChildrenList(list); | |||||
| } | |||||
| } | } | ||||
| @@ -6,6 +6,8 @@ import com.iformall.common.ResultData; | |||||
| import com.iformall.domain.po.NeuPosOrderMasterExt; | import com.iformall.domain.po.NeuPosOrderMasterExt; | ||||
| import com.iformall.domain.po.WxActivity; | import com.iformall.domain.po.WxActivity; | ||||
| import com.iformall.service.NeuPosOrderService; | import com.iformall.service.NeuPosOrderService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -66,6 +68,12 @@ public class NeuPosAdminController extends BaseController { | |||||
| return new ResultData(maplist); | return new ResultData(maplist); | ||||
| } | } | ||||
| private void setDate(NeuPosOrderMasterExt example) { | |||||
| if (null != example.getCreateEnd()) { | |||||
| example.setCreateEnd(DateUtils.stringToDate(DateUtils.date2String(example.getCreateEnd(), "yyyy-MM-dd") +" 23:59:59","yyyy-MM-dd HH:mm:ss")); | |||||
| } | |||||
| } | |||||
| @ApiOperation("集团类型流水") | @ApiOperation("集团类型流水") | ||||
| @GetMapping("payTypeOrderlist") | @GetMapping("payTypeOrderlist") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -76,6 +84,7 @@ public class NeuPosAdminController extends BaseController { | |||||
| if (!tenantValid(tenantId)) { | if (!tenantValid(tenantId)) { | ||||
| return new ResultData(Result.ERROR,"未安装POS系统"); | return new ResultData(Result.ERROR,"未安装POS系统"); | ||||
| } | } | ||||
| setDate(example); | |||||
| example.setOrgId(24); | example.setOrgId(24); | ||||
| PageInfo<Map> maplist = neuPosOrderService.queryShopPayOrderList(example,pageNum,pageSize); | PageInfo<Map> maplist = neuPosOrderService.queryShopPayOrderList(example,pageNum,pageSize); | ||||
| return new ResultData(maplist); | return new ResultData(maplist); | ||||
| @@ -89,6 +98,7 @@ public class NeuPosAdminController extends BaseController { | |||||
| if (!tenantValid(tenantId)) { | if (!tenantValid(tenantId)) { | ||||
| return new ResultData(Result.ERROR,"未安装POS系统"); | return new ResultData(Result.ERROR,"未安装POS系统"); | ||||
| } | } | ||||
| setDate(example); | |||||
| example.setOrgId(24); | example.setOrgId(24); | ||||
| List<Map> maplist = neuPosOrderService.queryShopPayOrderSum(example); | List<Map> maplist = neuPosOrderService.queryShopPayOrderSum(example); | ||||
| return new ResultData(maplist); | return new ResultData(maplist); | ||||
| @@ -104,6 +114,7 @@ public class NeuPosAdminController extends BaseController { | |||||
| if (!tenantValid(tenantId)) { | if (!tenantValid(tenantId)) { | ||||
| return new ResultData(Result.ERROR,"未安装POS系统"); | return new ResultData(Result.ERROR,"未安装POS系统"); | ||||
| } | } | ||||
| setDate(example); | |||||
| example.setOrgId(24); | example.setOrgId(24); | ||||
| PageInfo<Map> maplist = neuPosOrderService.queryShopPayTypeTradeList(example,pageNum,pageSize); | PageInfo<Map> maplist = neuPosOrderService.queryShopPayTypeTradeList(example,pageNum,pageSize); | ||||
| return new ResultData(maplist); | return new ResultData(maplist); | ||||
| @@ -119,6 +130,7 @@ public class NeuPosAdminController extends BaseController { | |||||
| if (!tenantValid(tenantId)) { | if (!tenantValid(tenantId)) { | ||||
| return new ResultData(Result.ERROR,"未安装POS系统"); | return new ResultData(Result.ERROR,"未安装POS系统"); | ||||
| } | } | ||||
| setDate(example); | |||||
| example.setOrgId(24); | example.setOrgId(24); | ||||
| PageInfo<Map> maplist = neuPosOrderService.queryOrderList(example,pageNum,pageSize); | PageInfo<Map> maplist = neuPosOrderService.queryOrderList(example,pageNum,pageSize); | ||||
| return new ResultData(maplist); | return new ResultData(maplist); | ||||
| @@ -1,13 +1,7 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import java.io.Serializable; | |||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.BaseEntity; | import com.iformall.domain.po.base.BaseEntity; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| @@ -16,10 +10,9 @@ import lombok.ToString; | |||||
| @ToString(callSuper = true) | @ToString(callSuper = true) | ||||
| @EqualsAndHashCode(callSuper = true) | @EqualsAndHashCode(callSuper = true) | ||||
| public class NeuPosOrderMasterExt extends BaseEntity{ | public class NeuPosOrderMasterExt extends BaseEntity{ | ||||
| private Integer orgId; | |||||
| private static final long serialVersionUID = 6080005017786775288L; | |||||
| private Integer orgId; | |||||
| private Integer shopId; | private Integer shopId; | ||||
| @TableField(exist = false) | |||||
| private Date createBegin; | private Date createBegin; | ||||
| @TableField(exist = false) | |||||
| private Date createEnd; | private Date createEnd; | ||||
| } | } | ||||
| @@ -6,8 +6,8 @@ | |||||
| SELECT shop_id as shopId, | SELECT shop_id as shopId, | ||||
| sum(real_pay_amount) as payAmount, | sum(real_pay_amount) as payAmount, | ||||
| count(0) as payCount | count(0) as payCount | ||||
| from order_master | |||||
| where order_status = 2 and order_type != '3' | |||||
| from order_master_v2 | |||||
| where order_status = 4 and order_type != '3' | |||||
| <if test=" orgId != null"> | <if test=" orgId != null"> | ||||
| and org_id = #{orgId} | and org_id = #{orgId} | ||||
| </if> | </if> | ||||
| @@ -32,8 +32,8 @@ | |||||
| count(if(order_status=4,true,null)) refundCount, | count(if(order_status=4,true,null)) refundCount, | ||||
| ifnull(sum(if(order_status=2,real_pay_amount,0)),0) as amount, | ifnull(sum(if(order_status=2,real_pay_amount,0)),0) as amount, | ||||
| pay_type as payType | pay_type as payType | ||||
| from order_master | |||||
| where pay_status = 2 and order_type != '3' | |||||
| from order_master_v2 | |||||
| where pay_status = 4 and order_type != '3' | |||||
| <if test=" orgId != null"> | <if test=" orgId != null"> | ||||
| and org_id = #{orgId} | and org_id = #{orgId} | ||||
| </if> | </if> | ||||
| @@ -50,27 +50,75 @@ | |||||
| </select> | </select> | ||||
| <select id="queryShopPayOrderSum" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map"> | <select id="queryShopPayOrderSum" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map"> | ||||
| select ifnull(sum(order_amount),0) as payAmount, | |||||
| ifnull(sum(discount_amount),0) as discountAmount, | |||||
| count(order_amount) as payCount, | |||||
| ifnull(sum(if(order_status=4,real_pay_amount,0)),0) refundAmount, | |||||
| count(if(order_status=4,true,null)) refundCount, | |||||
| ifnull(sum(if(order_status=2,real_pay_amount,0)),0) as amount, | |||||
| pay_type as payType | |||||
| from order_master | |||||
| where pay_status = 2 and order_type != '3' | |||||
| <if test=" orgId != null"> | |||||
| and org_id = #{orgId} | |||||
| </if> | |||||
| <if test=" shopId != null"> | |||||
| and shop_id = #{shopId} | |||||
| </if> | |||||
| <if test=" createBegin != null"> | |||||
| and created_at >= #{createBegin} | |||||
| </if> | |||||
| <if test=" createEnd != null"> | |||||
| and created_at <= #{createEnd} | |||||
| </if> | |||||
| select _temp.payType as payType, sum(_temp.payAmount) as payAmount, sum(_temp.payCount) as payCount from | |||||
| ( | |||||
| SELECT | |||||
| ifnull( refund.shop_id, paid.shop_id ) AS shopId, | |||||
| pay_type_dict_v2.pay_type AS payType, | |||||
| ifnull( payAmount, 0 ) - ifnull( refundAmount, 0 ) AS payAmount, | |||||
| ifnull( payCount, 0 ) + ifnull( refundCount, 0 ) AS payCount | |||||
| FROM | |||||
| pay_type_dict_v2 | |||||
| LEFT JOIN ( | |||||
| SELECT | |||||
| shop_id, | |||||
| pay_type AS payType, | |||||
| ifnull( sum( pay_order_v2.pay_amount ) / 100, 0 ) AS payAmount, | |||||
| count( 0 ) AS payCount, | |||||
| 0 AS discountAmount | |||||
| FROM | |||||
| pay_order_v2 | |||||
| LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number | |||||
| <if test=" orgId != null"> | |||||
| and order_master_v2.org_id = #{orgId} | |||||
| </if> | |||||
| <if test=" shopId != null"> | |||||
| and order_master_v2.shop_id = #{shopId} | |||||
| </if> | |||||
| <if test=" createBegin != null"> | |||||
| and order_master_v2.created_at >= #{createBegin} | |||||
| </if> | |||||
| <if test=" createEnd != null"> | |||||
| and order_master_v2.created_at <= #{createEnd} | |||||
| </if> | |||||
| AND ( pay_order_v2.pay_status = 2 OR pay_order_v2.pay_status = 5 OR pay_order_v2.pay_status = 4 ) | |||||
| GROUP BY | |||||
| pay_type, | |||||
| shop_id | |||||
| ) AS paid ON pay_type_dict_v2.pay_type = paid.payType | |||||
| LEFT JOIN ( | |||||
| SELECT | |||||
| shop_id, | |||||
| pay_type AS payType, | |||||
| ifnull( sum( refunded_amount ) / 100, 0 ) refundAmount, | |||||
| count( 0 ) refundCount | |||||
| FROM | |||||
| pay_refund_order_v2 AS pay_order_v2 | |||||
| LEFT JOIN order_master_v2 ON pay_order_v2.m_order_number = order_master_v2.order_number | |||||
| <if test=" orgId != null"> | |||||
| and order_master_v2.org_id = #{orgId} | |||||
| </if> | |||||
| <if test=" shopId != null"> | |||||
| and order_master_v2.shop_id = #{shopId} | |||||
| </if> | |||||
| <if test=" createBegin != null"> | |||||
| and order_master_v2.created_at >= #{createBegin} | |||||
| </if> | |||||
| <if test=" createEnd != null"> | |||||
| and order_master_v2.created_at <= #{createEnd} | |||||
| </if> | |||||
| AND refund_status = 2 | |||||
| GROUP BY | |||||
| pay_type, | |||||
| shop_id | |||||
| ) AS refund ON pay_type_dict_v2.pay_type = refund.payType | |||||
| AND paid.shop_id = refund.shop_id | |||||
| ORDER BY | |||||
| payType, | |||||
| shopId ASC | |||||
| ) as _temp | |||||
| where _temp.payType in (select pay_type from trade_mch_pay_channel where org_id = #{orgId}) | |||||
| group by _temp.payType | |||||
| </select> | </select> | ||||
| <select id="selectShopList" parameterType="Integer" resultType="java.util.Map"> | <select id="selectShopList" parameterType="Integer" resultType="java.util.Map"> | ||||
| @@ -88,8 +136,8 @@ | |||||
| <select id="queryOrderList" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map"> | <select id="queryOrderList" parameterType="com.iformall.domain.po.NeuPosOrderMasterExt" resultType="java.util.Map"> | ||||
| SELECT order_number as orderNumber, serial_no as serialNo, order_amount as orderAmount,real_pay_amount as realPayAmount, | SELECT order_number as orderNumber, serial_no as serialNo, order_amount as orderAmount,real_pay_amount as realPayAmount, | ||||
| discount_amount as discountAmount, pay_type as payType,paid_time as paidTime,order_status as orderStatus | discount_amount as discountAmount, pay_type as payType,paid_time as paidTime,order_status as orderStatus | ||||
| from order_master | |||||
| where order_status = 2 and order_type != '3' | |||||
| from order_master_v2 | |||||
| where order_status = 4 and order_type != '3' | |||||
| <if test=" orgId != null"> | <if test=" orgId != null"> | ||||
| and org_id = #{orgId} | and org_id = #{orgId} | ||||
| </if> | </if> | ||||
| @@ -17,4 +17,6 @@ public interface VideoExcutor { | |||||
| //ext,后缀名 | //ext,后缀名 | ||||
| public VideUploadResult uploadNetVideo(String title,String url,String ext); | public VideUploadResult uploadNetVideo(String title,String url,String ext); | ||||
| public String getVedioUploadProgress(String videoId); | |||||
| } | } | ||||
| @@ -4,6 +4,8 @@ import java.util.Map; | |||||
| import java.util.concurrent.ConcurrentHashMap; | import java.util.concurrent.ConcurrentHashMap; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.iformall.video.aliyun.AliyunVideoExcutor; | import com.iformall.video.aliyun.AliyunVideoExcutor; | ||||
| @@ -7,6 +7,8 @@ import java.io.IOException; | |||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.beans.factory.annotation.Qualifier; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import com.aliyun.vod.upload.resp.UploadStreamResponse; | import com.aliyun.vod.upload.resp.UploadStreamResponse; | ||||
| @@ -28,6 +30,10 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||||
| @Autowired | @Autowired | ||||
| AliyunVideoConfig config; | AliyunVideoConfig config; | ||||
| @Autowired | |||||
| @Qualifier("objectCommonRedisTemplate") | |||||
| RedisTemplate<String, Object> redisTemplate; | |||||
| private String getUrlByVeidoId(String videoId) { | private String getUrlByVeidoId(String videoId) { | ||||
| try { | try { | ||||
| return AliyunVedioServer.getVedioUrl(config, videoId); | return AliyunVedioServer.getVedioUrl(config, videoId); | ||||
| @@ -41,7 +47,7 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||||
| public VideUploadResult uploadLocalVideo(String title,String localFile) { | public VideUploadResult uploadLocalVideo(String title,String localFile) { | ||||
| VideUploadResult result = new VideUploadResult(); | VideUploadResult result = new VideUploadResult(); | ||||
| try { | try { | ||||
| UploadVideoResponse response =AliyunVedioUpload.uploadVideo(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, localFile); | |||||
| UploadVideoResponse response =AliyunVedioUpload.uploadVideo(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, localFile,redisTemplate); | |||||
| if (response.isSuccess()) { | if (response.isSuccess()) { | ||||
| result.setVideoId(response.getVideoId()); | result.setVideoId(response.getVideoId()); | ||||
| result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); | result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); | ||||
| @@ -64,7 +70,7 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||||
| VideUploadResult result = new VideUploadResult(); | VideUploadResult result = new VideUploadResult(); | ||||
| UploadStreamResponse response; | UploadStreamResponse response; | ||||
| try { | try { | ||||
| response = AliyunVedioUpload.uploadStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, "", inputStream); | |||||
| response = AliyunVedioUpload.uploadStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, "", inputStream,redisTemplate); | |||||
| if (response.isSuccess()) { | if (response.isSuccess()) { | ||||
| result.setVideoId(response.getVideoId()); | result.setVideoId(response.getVideoId()); | ||||
| result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); | result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); | ||||
| @@ -91,7 +97,7 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||||
| @Override | @Override | ||||
| public VideUploadResult uploadNetVideo(String title,String url,String ext) { | public VideUploadResult uploadNetVideo(String title,String url,String ext) { | ||||
| VideUploadResult result = new VideUploadResult(); | VideUploadResult result = new VideUploadResult(); | ||||
| UploadURLStreamResponse response = AliyunVedioUpload.uploadURLStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, url, ext); | |||||
| UploadURLStreamResponse response = AliyunVedioUpload.uploadURLStream(config.getAccessKeyId(), config.getAccessKeySecret(),config.getRegionId(), title, url, ext,redisTemplate); | |||||
| if (response.isSuccess()) { | if (response.isSuccess()) { | ||||
| result.setVideoId(response.getVideoId()); | result.setVideoId(response.getVideoId()); | ||||
| result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); | result.setVideoUrl(getUrlByVeidoId(response.getVideoId())); | ||||
| @@ -103,4 +109,9 @@ public class AliyunVideoExcutor implements VideoExcutor { | |||||
| } | } | ||||
| return result; | return result; | ||||
| } | } | ||||
| @Override | |||||
| public String getVedioUploadProgress(String videoId) { | |||||
| return AliyunVedioUpload.getUploadProgress(redisTemplate, videoId); | |||||
| } | |||||
| } | } | ||||
| @@ -6,6 +6,8 @@ import java.io.IOException; | |||||
| import java.io.InputStream; | import java.io.InputStream; | ||||
| import java.net.URL; | import java.net.URL; | ||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import com.aliyun.vod.upload.impl.UploadAttachedMediaImpl; | import com.aliyun.vod.upload.impl.UploadAttachedMediaImpl; | ||||
| import com.aliyun.vod.upload.impl.UploadImageImpl; | import com.aliyun.vod.upload.impl.UploadImageImpl; | ||||
| import com.aliyun.vod.upload.impl.UploadM3u8FileImpl; | import com.aliyun.vod.upload.impl.UploadM3u8FileImpl; | ||||
| @@ -103,7 +105,7 @@ public class AliyunVedioUpload { | |||||
| // 任何上传方式文件名必须包含扩展名 | // 任何上传方式文件名必须包含扩展名 | ||||
| String fileName = "/Users/test/video/test.mp4"; | String fileName = "/Users/test/video/test.mp4"; | ||||
| // 本地文件上传 | // 本地文件上传 | ||||
| uploadVideo(accessKeyId, accessKeySecret,"cn-beijing", title, fileName); | |||||
| uploadVideo(accessKeyId, accessKeySecret,"cn-beijing", title, fileName,null); | |||||
| // 待上传视频的网络流地址 | // 待上传视频的网络流地址 | ||||
| String url = "http://test.aliyun.com/video/test.mp4"; | String url = "http://test.aliyun.com/video/test.mp4"; | ||||
| @@ -111,7 +113,7 @@ public class AliyunVedioUpload { | |||||
| // 2.网络流上传 | // 2.网络流上传 | ||||
| // 文件扩展名,当url中不包含扩展名时,需要设置该参数 | // 文件扩展名,当url中不包含扩展名时,需要设置该参数 | ||||
| String fileExtension = "mp4"; | String fileExtension = "mp4"; | ||||
| uploadURLStream(accessKeyId, accessKeySecret, "cn-beijing",title, url, fileExtension); | |||||
| uploadURLStream(accessKeyId, accessKeySecret, "cn-beijing",title, url, fileExtension,null); | |||||
| // 3.文件流上传 | // 3.文件流上传 | ||||
| // testUploadFileStream(accessKeyId, accessKeySecret, title, fileName); | // testUploadFileStream(accessKeyId, accessKeySecret, title, fileName); | ||||
| @@ -130,7 +132,7 @@ public class AliyunVedioUpload { | |||||
| } catch (IOException e) { | } catch (IOException e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| uploadStream(accessKeyId, accessKeySecret, "cn-beijing",title, fileName, inputStream); | |||||
| uploadStream(accessKeyId, accessKeySecret, "cn-beijing",title, fileName, inputStream,null); | |||||
| // 二、图片上传 | // 二、图片上传 | ||||
| @@ -161,7 +163,8 @@ public class AliyunVedioUpload { | |||||
| * @param title | * @param title | ||||
| * @param fileName | * @param fileName | ||||
| */ | */ | ||||
| public static UploadVideoResponse uploadVideo(String accessKeyId, String accessKeySecret,String regionId, String title, String fileName) { | |||||
| public static UploadVideoResponse uploadVideo(String accessKeyId, String accessKeySecret,String regionId, String title, String fileName, | |||||
| RedisTemplate<String, Object> redisTemplate) { | |||||
| UploadVideoRequest request = new UploadVideoRequest(accessKeyId, accessKeySecret, title, fileName); | UploadVideoRequest request = new UploadVideoRequest(accessKeyId, accessKeySecret, title, fileName); | ||||
| /* 可指定分片上传时每个分片的大小,默认为2M字节 */ | /* 可指定分片上传时每个分片的大小,默认为2M字节 */ | ||||
| request.setPartSize(2 * 1024 * 1024L); | request.setPartSize(2 * 1024 * 1024L); | ||||
| @@ -219,7 +222,8 @@ public class AliyunVedioUpload { | |||||
| * @param fileName | * @param fileName | ||||
| * @param url | * @param url | ||||
| */ | */ | ||||
| public static UploadURLStreamResponse uploadURLStream(String accessKeyId, String accessKeySecret,String regionId, String title, String url, String fileExtension) { | |||||
| public static UploadURLStreamResponse uploadURLStream(String accessKeyId, String accessKeySecret,String regionId, String title, | |||||
| String url, String fileExtension,RedisTemplate<String, Object> redisTemplate) { | |||||
| UploadURLStreamRequest request = new UploadURLStreamRequest(accessKeyId, accessKeySecret, title, url); | UploadURLStreamRequest request = new UploadURLStreamRequest(accessKeyId, accessKeySecret, title, url); | ||||
| /* 文件扩展名*/ | /* 文件扩展名*/ | ||||
| @@ -271,7 +275,8 @@ public class AliyunVedioUpload { | |||||
| * @param title | * @param title | ||||
| * @param fileName | * @param fileName | ||||
| */ | */ | ||||
| private static void uploadFileStream(String accessKeyId, String accessKeySecret,String regionId, String title, String fileName) { | |||||
| private static void uploadFileStream(String accessKeyId, String accessKeySecret,String regionId, String title, String fileName, | |||||
| RedisTemplate<String, Object> redisTemplate) { | |||||
| UploadFileStreamRequest request = new UploadFileStreamRequest(accessKeyId, accessKeySecret, title, fileName); | UploadFileStreamRequest request = new UploadFileStreamRequest(accessKeyId, accessKeySecret, title, fileName); | ||||
| /* 是否使用默认水印(可选),指定模板组ID时,根据模板组配置确定是否使用默认水印*/ | /* 是否使用默认水印(可选),指定模板组ID时,根据模板组配置确定是否使用默认水印*/ | ||||
| //request.setShowWaterMark(true); | //request.setShowWaterMark(true); | ||||
| @@ -323,7 +328,8 @@ public class AliyunVedioUpload { | |||||
| * @param fileName | * @param fileName | ||||
| * @param inputStream | * @param inputStream | ||||
| */ | */ | ||||
| public static UploadStreamResponse uploadStream(String accessKeyId, String accessKeySecret,String regionId, String title, String fileName, InputStream inputStream) { | |||||
| public static UploadStreamResponse uploadStream(String accessKeyId, String accessKeySecret,String regionId, String title, | |||||
| String fileName, InputStream inputStream,RedisTemplate<String, Object> redisTemplate) { | |||||
| UploadStreamRequest request = new UploadStreamRequest(accessKeyId, accessKeySecret, title, fileName, inputStream); | UploadStreamRequest request = new UploadStreamRequest(accessKeyId, accessKeySecret, title, fileName, inputStream); | ||||
| /* 是否使用默认水印(可选),指定模板组ID时,根据模板组配置确定是否使用默认水印*/ | /* 是否使用默认水印(可选),指定模板组ID时,根据模板组配置确定是否使用默认水印*/ | ||||
| //request.setShowWaterMark(true); | //request.setShowWaterMark(true); | ||||
| @@ -365,7 +371,7 @@ public class AliyunVedioUpload { | |||||
| * @param accessKeyId | * @param accessKeyId | ||||
| * @param accessKeySecret | * @param accessKeySecret | ||||
| */ | */ | ||||
| public static void uploadImageLocalFile(String accessKeyId, String accessKeySecret,String regionId) { | |||||
| public static void uploadImageLocalFile(String accessKeyId, String accessKeySecret,String regionId,RedisTemplate<String, Object> redisTemplate) { | |||||
| /* 图片类型(必选)取值范围:default(默认),cover(封面),watermark(水印)*/ | /* 图片类型(必选)取值范围:default(默认),cover(封面),watermark(水印)*/ | ||||
| String imageType = "cover"; | String imageType = "cover"; | ||||
| UploadImageRequest request = new UploadImageRequest(accessKeyId, accessKeySecret, imageType); | UploadImageRequest request = new UploadImageRequest(accessKeyId, accessKeySecret, imageType); | ||||
| @@ -409,7 +415,7 @@ public class AliyunVedioUpload { | |||||
| * @param accessKeyId | * @param accessKeyId | ||||
| * @param accessKeySecret | * @param accessKeySecret | ||||
| */ | */ | ||||
| public static void uploadImageStream(String accessKeyId, String accessKeySecret,String regionId) { | |||||
| public static void uploadImageStream(String accessKeyId, String accessKeySecret,String regionId,RedisTemplate<String, Object> redisTemplate) { | |||||
| /* 图片类型(必选)取值范围:default(默认),cover(封面),watermark(水印)*/ | /* 图片类型(必选)取值范围:default(默认),cover(封面),watermark(水印)*/ | ||||
| String imageType = "cover"; | String imageType = "cover"; | ||||
| UploadImageRequest request = new UploadImageRequest(accessKeyId, accessKeySecret, imageType); | UploadImageRequest request = new UploadImageRequest(accessKeyId, accessKeySecret, imageType); | ||||
| @@ -682,4 +688,8 @@ public class AliyunVedioUpload { | |||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public static String getUploadProgress(RedisTemplate<String, Object> redisTemplate,String videoId) { | |||||
| return UploadCacheHelper.getUploadProgress(redisTemplate, PutObjectProgressListener.PRE_VIDEO_PROGRESS+videoId); | |||||
| } | |||||
| } | } | ||||
| @@ -1,5 +1,7 @@ | |||||
| package com.iformall.video.aliyun.sdk.upload; | package com.iformall.video.aliyun.sdk.upload; | ||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import com.aliyun.oss.event.ProgressEvent; | import com.aliyun.oss.event.ProgressEvent; | ||||
| import com.aliyun.oss.event.ProgressEventType; | import com.aliyun.oss.event.ProgressEventType; | ||||
| import com.aliyun.vod.upload.impl.VoDProgressListener; | import com.aliyun.vod.upload.impl.VoDProgressListener; | ||||
| @@ -33,54 +35,63 @@ public class PutObjectProgressListener implements VoDProgressListener { | |||||
| * 图片ID | * 图片ID | ||||
| */ | */ | ||||
| private String imageId; | private String imageId; | ||||
| public static final String PRE_VIDEO_PROGRESS = "video:progress:"; | |||||
| private RedisTemplate<String, Object> redisTemplate; | |||||
| public void progressChanged(ProgressEvent progressEvent) { | public void progressChanged(ProgressEvent progressEvent) { | ||||
| long bytes = progressEvent.getBytes(); | long bytes = progressEvent.getBytes(); | ||||
| ProgressEventType eventType = progressEvent.getEventType(); | ProgressEventType eventType = progressEvent.getEventType(); | ||||
| switch (eventType) { | switch (eventType) { | ||||
| // 开始上传事件 | // 开始上传事件 | ||||
| case TRANSFER_STARTED_EVENT: | case TRANSFER_STARTED_EVENT: | ||||
| if (videoId != null) { | |||||
| System.out.println("qqqqStart to upload videoId " + videoId + "......"); | |||||
| } | |||||
| if (imageId != null) { | |||||
| System.out.println("aaaStart to upload imageId " + imageId + "......"); | |||||
| } | |||||
| if (null != redisTemplate) { | |||||
| if (videoId != null) { | |||||
| UploadCacheHelper.cacheStart(redisTemplate, PRE_VIDEO_PROGRESS+videoId); | |||||
| //System.out.println("qqqqStart to upload videoId " + videoId + "......"); | |||||
| } | |||||
| if (imageId != null) { | |||||
| //System.out.println("aaaStart to upload imageId " + imageId + "......"); | |||||
| } | |||||
| } | |||||
| break; | break; | ||||
| // 计算待上传文件总大小事件通知,只有调用本地文件方式上传时支持该事件 | // 计算待上传文件总大小事件通知,只有调用本地文件方式上传时支持该事件 | ||||
| case REQUEST_CONTENT_LENGTH_EVENT: | case REQUEST_CONTENT_LENGTH_EVENT: | ||||
| this.totalBytes = bytes; | this.totalBytes = bytes; | ||||
| System.out.println(this.totalBytes + "bytes in total will be uploaded to OSS."); | |||||
| //System.out.println(this.totalBytes + "bytes in total will be uploaded to OSS."); | |||||
| break; | break; | ||||
| // 已经上传成功文件大小事件通知 | // 已经上传成功文件大小事件通知 | ||||
| case REQUEST_BYTE_TRANSFER_EVENT: | case REQUEST_BYTE_TRANSFER_EVENT: | ||||
| this.bytesWritten += bytes; | this.bytesWritten += bytes; | ||||
| if (this.totalBytes != -1) { | if (this.totalBytes != -1) { | ||||
| int percent = (int) (this.bytesWritten * 100.0 / this.totalBytes); | int percent = (int) (this.bytesWritten * 100.0 / this.totalBytes); | ||||
| System.out.println(bytes + " bytes have been written at this time, upload progress: " + | |||||
| percent + "%(" + this.bytesWritten + "/" + this.totalBytes + ")"); | |||||
| //System.out.println(bytes + " bytes have been written at this time, upload progress: " + | |||||
| // percent + "%(" + this.bytesWritten + "/" + this.totalBytes + ")"); | |||||
| } else { | } else { | ||||
| System.out.println(bytes + " bytes have been written at this time, upload sub total : " + | |||||
| "(" + this.bytesWritten + ")"); | |||||
| //System.out.println(bytes + " bytes have been written at this time, upload sub total : " + | |||||
| // "(" + this.bytesWritten + ")"); | |||||
| } | } | ||||
| UploadCacheHelper.cacheProgress(redisTemplate, PRE_VIDEO_PROGRESS+videoId,String.valueOf(this.bytesWritten)); | |||||
| break; | break; | ||||
| // 文件全部上传成功事件通知 | // 文件全部上传成功事件通知 | ||||
| case TRANSFER_COMPLETED_EVENT: | case TRANSFER_COMPLETED_EVENT: | ||||
| this.succeed = true; | this.succeed = true; | ||||
| if (videoId != null) { | if (videoId != null) { | ||||
| System.out.println("Succeed to upload videoId " + videoId + " , " + this.bytesWritten + " bytes have been transferred in total."); | |||||
| UploadCacheHelper.cacheComplete(redisTemplate, PRE_VIDEO_PROGRESS+videoId); | |||||
| //System.out.println("Succeed to upload videoId " + videoId + " , " + this.bytesWritten + " bytes have been transferred in total."); | |||||
| } | } | ||||
| if (imageId != null) { | if (imageId != null) { | ||||
| System.out.println("Succeed to upload imageId " + imageId + " , " + this.bytesWritten + " bytes have been transferred in total."); | |||||
| //System.out.println("Succeed to upload imageId " + imageId + " , " + this.bytesWritten + " bytes have been transferred in total."); | |||||
| } | } | ||||
| break; | break; | ||||
| // 文件上传失败事件通知 | // 文件上传失败事件通知 | ||||
| case TRANSFER_FAILED_EVENT: | case TRANSFER_FAILED_EVENT: | ||||
| if (videoId != null) { | if (videoId != null) { | ||||
| UploadCacheHelper.cacheProgress(redisTemplate, PRE_VIDEO_PROGRESS+videoId,String.valueOf(this.bytesWritten)); | |||||
| System.out.println("Failed to upload videoId " + videoId + " , " + this.bytesWritten + " bytes have been transferred."); | System.out.println("Failed to upload videoId " + videoId + " , " + this.bytesWritten + " bytes have been transferred."); | ||||
| } | } | ||||
| if (imageId != null) { | if (imageId != null) { | ||||
| System.out.println("Failed to upload imageId " + imageId + " , " + this.bytesWritten + " bytes have been transferred."); | |||||
| //System.out.println("Failed to upload imageId " + imageId + " , " + this.bytesWritten + " bytes have been transferred."); | |||||
| } | } | ||||
| break; | break; | ||||
| @@ -0,0 +1,37 @@ | |||||
| package com.iformall.video.aliyun.sdk.upload; | |||||
| import java.util.concurrent.TimeUnit; | |||||
| import org.springframework.data.redis.core.RedisTemplate; | |||||
| import org.springframework.data.redis.core.ValueOperations; | |||||
| public class UploadCacheHelper { | |||||
| public static void cacheStart(RedisTemplate<String, Object> template,String key) { | |||||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||||
| operations.set(key, "begin", 24*3600,TimeUnit.SECONDS); | |||||
| } | |||||
| public static void cacheComplete(RedisTemplate<String, Object> template,String key) { | |||||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||||
| operations.set(key, "complete", 24*3600,TimeUnit.SECONDS); | |||||
| } | |||||
| public static void cacheProgress(RedisTemplate<String, Object> template,String key,String bytes) { | |||||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||||
| operations.set(key, bytes, 24*3600,TimeUnit.SECONDS); | |||||
| } | |||||
| public static String getUploadProgress(RedisTemplate<String, Object> template,String key) { | |||||
| if (template.hasKey(key)) { | |||||
| ValueOperations<String, Object> operations = template.opsForValue(); | |||||
| Object o = operations.get(key); | |||||
| if (o instanceof String) { | |||||
| return (String)o; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| } | |||||