| @@ -13,6 +13,8 @@ public class TtUserCollectFollow extends TenantEntity { | |||||
| protected Long id; | protected Long id; | ||||
| private Long userId; | |||||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | ||||
| private Date createDate; | private Date createDate; | ||||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | ||||
| @@ -2,7 +2,9 @@ package com.iformall.service.tt; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.tt.TtCoupon; | import com.iformall.domain.po.tt.TtCoupon; | ||||
| import org.springframework.scheduling.annotation.Async; | |||||
| public interface TtCouponService { | public interface TtCouponService { | ||||
| @@ -43,4 +45,7 @@ public interface TtCouponService { | |||||
| ResultData puton(Long id); | ResultData puton(Long id); | ||||
| ResultData putoff(Long id); | ResultData putoff(Long id); | ||||
| @Async | |||||
| void collectCoupon(TenantEntity tenantEntity,Long memberId, Long id); | |||||
| } | } | ||||
| @@ -1,12 +1,18 @@ | |||||
| package com.iformall.service.tt.impl; | package com.iformall.service.tt.impl; | ||||
| import com.alibaba.fastjson.JSONArray; | import com.alibaba.fastjson.JSONArray; | ||||
| import com.baomidou.mybatisplus.core.conditions.Wrapper; | |||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||||
| import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.base.TenantEntity; | |||||
| import com.iformall.domain.po.tt.TtCoupon; | import com.iformall.domain.po.tt.TtCoupon; | ||||
| import com.iformall.domain.po.tt.TtUserCollect; | |||||
| import com.iformall.enums.EnumTtCouponStatus; | import com.iformall.enums.EnumTtCouponStatus; | ||||
| import com.iformall.enums.EnumTtCouponType; | import com.iformall.enums.EnumTtCouponType; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| @@ -33,6 +39,9 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| @Autowired | @Autowired | ||||
| WxMerchantService wxMerchantService; | WxMerchantService wxMerchantService; | ||||
| @Autowired | |||||
| TtUserCollectMapper ttUserCollectMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<TtCoupon> listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { | public PageInfo<TtCoupon> listAsPage(TtCoupon record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -80,6 +89,10 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| if(record.getType().equals(EnumTtCouponType.COUPON_COLUMN.getCode()) | if(record.getType().equals(EnumTtCouponType.COUPON_COLUMN.getCode()) | ||||
| && record.getColumnCoupons() != null && record.getColumnCoupons().size() > 0){ | && record.getColumnCoupons() != null && record.getColumnCoupons().size() > 0){ | ||||
| TtCoupon couponD = new TtCoupon(); | |||||
| couponD.setColumnId(record.getId()); | |||||
| couponD.setType(EnumTtCouponType.COUPON_MORE.getCode()); | |||||
| ttCouponMapper.delete(new QueryWrapper<TtCoupon>(couponD)); | |||||
| for (TtCoupon ttc:record.getColumnCoupons()) { | for (TtCoupon ttc:record.getColumnCoupons()) { | ||||
| ttc.updateTenantInfo(record); | ttc.updateTenantInfo(record); | ||||
| ttc.setType(EnumTtCouponType.COUPON_MORE.getCode()); | ttc.setType(EnumTtCouponType.COUPON_MORE.getCode()); | ||||
| @@ -140,4 +153,21 @@ public class TtCouponServiceImpl implements TtCouponService { | |||||
| ttCouponMapper.updateById(byId); | ttCouponMapper.updateById(byId); | ||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| @Override | |||||
| public void collectCoupon(TenantEntity tenantEntity,Long memberId, Long id) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| TtUserCollect userCollect = new TtUserCollect(); | |||||
| userCollect.setId(idWorker.nextId()); | |||||
| userCollect.updateTenantInfo(tenantEntity); | |||||
| userCollect.setUserId(memberId); | |||||
| userCollect.setCouponId(id); | |||||
| userCollect.setCreateDate(new Date()); | |||||
| userCollect.setUpdateDate(new Date()); | |||||
| try { | |||||
| ttUserCollectMapper.insert(userCollect); | |||||
| } catch (Exception e) { | |||||
| // e.printStackTrace(); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -68,6 +68,7 @@ public class TtCouponController extends BaseController { | |||||
| public ResultData list(@ModelAttribute TtCoupon record, Integer pageNum, Integer pageSize, Integer dataType) { | public ResultData list(@ModelAttribute TtCoupon record, Integer pageNum, Integer pageSize, Integer dataType) { | ||||
| logger.debug("[" + getIpAddr() + "] TtCouponController::list"); | logger.debug("[" + getIpAddr() + "] TtCouponController::list"); | ||||
| if (record == null) record = new TtCoupon(); | if (record == null) record = new TtCoupon(); | ||||
| record.updateTenantInfo(getTenantInfo()); | |||||
| return new ResultData(ttCouponService.listAsPage(record, pageNum, pageSize)); | return new ResultData(ttCouponService.listAsPage(record, pageNum, pageSize)); | ||||
| } | } | ||||
| @@ -97,26 +98,56 @@ public class TtCouponController extends BaseController { | |||||
| if(record.getBusinessId() == null){ | if(record.getBusinessId() == null){ | ||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未选择分类"); | return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未选择分类"); | ||||
| } | } | ||||
| if(StringUtils.isBlank(record.getVideoId())){ | |||||
| // return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"未上传视频"); | |||||
| }else{ | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(record.getVideoId()); | |||||
| if(result.isSuccess()){ | |||||
| record.setVideoTime(result.getDuration()); | |||||
| TtVideoLibrary video = new TtVideoLibrary(); | |||||
| video.updateTenantInfo(tenantEntity); | |||||
| video.setVideoId(record.getVideoId()); | |||||
| video.setVideoUrl(result.getVideoUrl()); | |||||
| video.setPreview(result.getCoverURL()); | |||||
| video.setDuration(result.getDuration()); | |||||
| ttVideoLibraryService.saveOrUpdate(video); | |||||
| if(record.getType() == null){ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"type为空"); | |||||
| } | |||||
| if(record.getType().equals(EnumTtCouponType.COUPON_SINGLE.getCode())){ | |||||
| if(StringUtils.isBlank(record.getVideoId())){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"未上传视频"); | |||||
| }else{ | }else{ | ||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(record.getVideoId()); | |||||
| if(result.isSuccess()){ | |||||
| record.setVideoTime(result.getDuration()); | |||||
| TtVideoLibrary video = new TtVideoLibrary(); | |||||
| video.updateTenantInfo(tenantEntity); | |||||
| video.setVideoId(record.getVideoId()); | |||||
| video.setVideoUrl(result.getVideoUrl()); | |||||
| video.setPreview(result.getCoverURL()); | |||||
| video.setDuration(result.getDuration()); | |||||
| ttVideoLibraryService.saveOrUpdate(video); | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||||
| } | |||||
| } | } | ||||
| }else if(record.getType().equals(EnumTtCouponType.COUPON_COLUMN.getCode())){ | |||||
| if(record.getColumnCoupons() != null && record.getColumnCoupons().size() > 0){ | |||||
| for (TtCoupon ttc:record.getColumnCoupons()) { | |||||
| if(StringUtils.isBlank(ttc.getVideoId())) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "部分未上传视频"); | |||||
| } | |||||
| VideUploadResult result = videoFactory.getExcutor(videoType).getVideoDetail(ttc.getVideoId()); | |||||
| if(result.isSuccess()){ | |||||
| ttc.setVideoTime(result.getDuration()); | |||||
| TtVideoLibrary video = new TtVideoLibrary(); | |||||
| video.updateTenantInfo(tenantEntity); | |||||
| video.setVideoId(record.getVideoId()); | |||||
| video.setVideoUrl(result.getVideoUrl()); | |||||
| video.setPreview(result.getCoverURL()); | |||||
| video.setDuration(result.getDuration()); | |||||
| ttVideoLibraryService.saveOrUpdate(video); | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,result.getMsg()); | |||||
| } | |||||
| } | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL, "未上传视频"); | |||||
| } | |||||
| }else{ | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR,"未识别type类型"); | |||||
| } | } | ||||
| record.setType(EnumTtCouponType.COUPON_SINGLE.getCode()); | |||||
| // record.setType(EnumTtCouponType.COUPON_SINGLE.getCode()); | |||||
| ResultData resultData = ttCouponService.saveOrUpdate(record); | ResultData resultData = ttCouponService.saveOrUpdate(record); | ||||
| if (resultData.code != 200) { | if (resultData.code != 200) { | ||||
| return resultData; | return resultData; | ||||
| @@ -76,7 +76,7 @@ public class VideoController extends BaseController { | |||||
| /** | /** | ||||
| * 上传视频 | * 上传视频 | ||||
| * | * | ||||
| * @param multiReq | |||||
| * @param | |||||
| * @return | * @return | ||||
| * @throws Exception | * @throws Exception | ||||
| */ | */ | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.iformall.controller; | package com.iformall.controller; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.tt.TtCoupon; | import com.iformall.domain.po.tt.TtCoupon; | ||||
| import com.iformall.exception.MallinkException; | |||||
| import com.iformall.service.tt.TtCouponService; | import com.iformall.service.tt.TtCouponService; | ||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| @@ -28,7 +30,7 @@ public class TtCouponController extends BaseController { | |||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| public ResultData list(@ModelAttribute TtCoupon record, Integer pageNum, Integer pageSize, Integer dataType) { | public ResultData list(@ModelAttribute TtCoupon record, Integer pageNum, Integer pageSize, Integer dataType) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | |||||
| logger.debug("[" + getIpAddr() + "] TtCouponController::list"); | |||||
| if (record == null) record = new TtCoupon(); | if (record == null) record = new TtCoupon(); | ||||
| return new ResultData(ttCouponService.listAsPage(record, pageNum, pageSize)); | return new ResultData(ttCouponService.listAsPage(record, pageNum, pageSize)); | ||||
| } | } | ||||
| @@ -37,8 +39,33 @@ public class TtCouponController extends BaseController { | |||||
| @GetMapping("/findById") | @GetMapping("/findById") | ||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | ||||
| public ResultData findById(@RequestParam Long id) { | public ResultData findById(@RequestParam Long id) { | ||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::findById"); | |||||
| return new ResultData(ttCouponService.getById(id)); | |||||
| logger.debug("[" + getIpAddr() + "] TtCouponController::findById"); | |||||
| if (id == null) { | |||||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||||
| } | |||||
| return new ResultData(ttCouponService.detail(id)); | |||||
| } | |||||
| @ApiOperation("收藏") | |||||
| @GetMapping("/collectCoupon") | |||||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||||
| public ResultData collectCoupon(@RequestParam Long id) { | |||||
| logger.debug("[" + getIpAddr() + "] TtCouponController::findById"); | |||||
| if (id == null) { | |||||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||||
| } | |||||
| TtCoupon byId = ttCouponService.getById(id); | |||||
| if(byId == null){ | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"找不到课程"); | |||||
| } | |||||
| Long memberId; | |||||
| try { | |||||
| memberId = getMemberId(); | |||||
| } catch (MallinkException e) { | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| } | |||||
| ttCouponService.collectCoupon(getTenantInfo(),memberId,byId.getId()); | |||||
| return new ResultData(); | |||||
| } | } | ||||
| } | } | ||||