From 489154fdd21f5922355e4f4d26bac3d055a5d9fc Mon Sep 17 00:00:00 2001 From: masterspirit Date: Tue, 28 Aug 2018 00:33:54 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8D=A1=E5=88=B8=E6=8A=95=E6=94=BE][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:=E6=A0=87=E8=AE=B0=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCouponChannelController.java | 3 +-- .../service/WxCouponChannelService.java | 3 ++- .../impl/WxCouponChannelServiceImpl.java | 26 ++++++++++++++----- 3 files changed, 22 insertions(+), 10 deletions(-) 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; } /**