From 124555700f40015fdf7992639dc89e2a404897d0 Mon Sep 17 00:00:00 2001 From: masterspirit Date: Thu, 6 Sep 2018 17:49:41 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8A=95=E6=94=BE]?= =?UTF-8?q?[=E4=BF=AE=E6=94=B9]=20=E8=BF=94=E5=9B=9E=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/vo/WxCouponChannelAddVo.java | 58 +++++++++++++++++++ .../impl/WxCouponChannelServiceImpl.java | 28 ++++++--- 2 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelAddVo.java diff --git a/mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelAddVo.java b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelAddVo.java new file mode 100644 index 000000000..c19e7125f --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelAddVo.java @@ -0,0 +1,58 @@ +package com.simple.domain.vo; + +import com.simple.domain.po.WxCoupon; + +import java.io.Serializable; +import java.util.Date; + +/** + * Created by syf on 2018/9/6. + * 返回投放错误列表使用 + */ +public class WxCouponChannelAddVo implements Serializable { + private static final long serialVersionUID = 1L; + private Long couponId; + private String title; + private Integer channelId; + private Date validEndDate; + + public WxCouponChannelAddVo toCouponChannnelVo(WxCoupon wxCoupon,Integer channelId){ + this.couponId = wxCoupon.getId(); + this.title = wxCoupon.getTitle(); + this.validEndDate = wxCoupon.getValidEndDate(); + return this; + } + + + public Long getCouponId() { + return couponId; + } + + public void setCouponId(Long couponId) { + this.couponId = couponId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Integer getChannelId() { + return channelId; + } + + public void setChannelId(Integer channelId) { + this.channelId = channelId; + } + + public Date getValidEndDate() { + return validEndDate; + } + + public void setValidEndDate(Date validEndDate) { + this.validEndDate = validEndDate; + } +} 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 516d3930d..6cac84d3b 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java @@ -10,6 +10,7 @@ import com.simple.common.ResultData; import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.po.WxMerchant; +import com.simple.domain.vo.WxCouponChannelAddVo; import com.simple.domain.vo.WxCouponChannelVo; import com.simple.mapper.WxCouponChannelMapper; import com.simple.mapper.WxMerchantMapper; @@ -70,20 +71,21 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { @Override public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) { boolean result = false; + List errorList = new ArrayList<>(); for (String targetIdstr:channelId) { Integer targetId = Integer.parseInt(targetIdstr); for (String couponidstr:ids) { Long couponid = Long.parseLong(couponidstr); - boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime); + boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime,errorList); if(addResult){ result = true; } } } if(result) { - return new ResultData(); + return new ResultData(errorList); }else { - return new ResultData(Result.ERROR,"请检查券的有效期以及投放截止时间"); + return new ResultData(Result.ERROR,"请检查券的有效期以及投放截止时间",errorList); } @@ -95,10 +97,11 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { wxCouponChannel.setTenantId(tenantId); wxCouponChannel.setStatus(status); wxCouponChannel.setCouponId(couponId); + wxCouponChannelMapper.updateStatusByCouponId(wxCouponChannel); } - public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ + public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime,List errorList){ WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); wxCouponChannelQuery.setTenantId(tanantId); @@ -121,10 +124,21 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { return false; } - if(wxCoupon.getValidEndDate()!=null&&wxCoupon.getValidEndDate().before(endTime)){ - logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间"); - return false; + if(channelId==1){ //列表默认投放结束时间为有效时间之后 + beginTime = new Date(); + endTime = wxCoupon.getValidEndDate(); + } + + if(channelId==2){ + if(wxCoupon.getValidEndDate()!=null&&wxCoupon.getValidEndDate().before(endTime)){ + logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间"); + WxCouponChannelAddVo vo = new WxCouponChannelAddVo(); + errorList.add(vo.toCouponChannnelVo(wxCoupon,channelId)); + return false; + } } + + WxCouponChannel wxCouponChannel = new WxCouponChannel(); wxCouponChannel.setEndTime(endTime); wxCouponChannel.setStatus(0);