|
|
|
@@ -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<WxCouponChannelAddVo> 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<WxCouponChannelAddVo> 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); |
|
|
|
|