diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java index b86ea8ad5..0b8960b43 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java @@ -76,8 +76,7 @@ public class WxCouponChannelController extends BaseController String[] ids = wxCouponChannelDto.getCouponIds().split(","); String[] channelId = wxCouponChannelDto.getChannelId().split(","); MallUserInfo user = getUser(); - wxCouponChannelService.addBatch(ids,channelId,user.getTenantId(),wxCouponChannelDto.getBeginTime(),wxCouponChannelDto.getEndTime()); - return new ResultData(); + return wxCouponChannelService.addBatch(ids,channelId,user.getTenantId(),wxCouponChannelDto.getBeginTime(),wxCouponChannelDto.getEndTime()); } diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java index c1093fd49..5adaca338 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java @@ -1,6 +1,7 @@ package com.simple.service; import com.github.pagehelper.PageInfo; +import com.simple.common.ResultData; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.vo.WxCouponChannelVo; @@ -42,7 +43,7 @@ public interface WxCouponChannelService { */ void deleteById(Long id); - void addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime,Date endTime); + ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime); void updateStatusByCouponId(Long couponId,String tenantId,int status); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java index 1de28ed00..51174ffd0 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java @@ -5,6 +5,8 @@ import java.util.stream.Collectors; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import com.simple.common.Result; +import com.simple.common.ResultData; import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.vo.WxCouponChannelVo; @@ -62,14 +64,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } @Override - public void addBatch(String[] ids,String[] channelId,String tanantId,Date beginTime,Date endTime) { + public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { + boolean result = false; for (String targetIdstr:channelId) { Integer targetId = Integer.parseInt(targetIdstr); for (String couponidstr:ids) { Long couponid = Long.parseLong(couponidstr); - addCuponChannel(couponid,targetId,tanantId,beginTime,endTime); + boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime); + if(addResult){ + result = true; + } } } + if(result) { + return new ResultData(); + }else { + return new ResultData(Result.ERROR,"请确认券状态,及有效期"); + } } @@ -82,8 +93,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setCouponId(couponId); } - @Transactional - public void addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ + + public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); wxCouponChannelQuery.setTenantId(tanantId); @@ -93,18 +104,18 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { List wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); if(wxCouponChannels.size()>0){ logger.debug(couponid+"已经投放过了"); - return; + return false; } WxCoupon wxCoupon = wxCouponService.getById(couponid); if(wxCoupon.getStatus()!=0) { logger.debug(wxCoupon.getId()+"状态不对"); - return; + return false; } if(wxCoupon.getValidEndDate().before(endTime)){ logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间"); - return; + return false; } WxCouponChannel wxCouponChannel = new WxCouponChannel(); wxCouponChannel.setEndTime(endTime); @@ -119,6 +130,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setBusiness(wxCoupon.getBusiness()); wxCouponChannel.setTitle(wxCoupon.getTitle()); saveOrUpdate(wxCouponChannel); + return true; } /**