| @@ -11,6 +11,7 @@ import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxActivityMapper; | |||
| import com.iformall.mapper.WxCampaignMapper; | |||
| import com.iformall.mapper.WxCouponChannelMapper; | |||
| @@ -88,8 +89,8 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| return wxCampaign; | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| public ResultData saveOrUpdate(WxCampaign wxCampaign) { | |||
| if(wxCampaign.getType().equals(EnumCampaignType.STABLE.getCode())) { | |||
| if (StringUtils.isEmpty(wxCampaign.getCoverImg())) { | |||
| @@ -180,8 +181,8 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| return new ResultData(Result.SUCCESS,"操作成功"); | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| public ResultData updateStatus(WxCampaign wxCampaign) { | |||
| wxCampaignMapper.updateById(wxCampaign); | |||
| if (wxCampaign.getType().equals(EnumCampaignType.PAGEPATH.getCode())) { | |||
| @@ -279,34 +280,54 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| } | |||
| public void saveOrUpdateCouponChannel(Long couponId, Map<Long, WxCouponChannel> wxCouponChannelsMap, WxCampaign record){ | |||
| Date showBeginTime = new Date(); | |||
| Date beginTime = null; | |||
| Date endTime = null; | |||
| WxCoupon wxCoupon = wxCouponService.getById(couponId,record.getTenantId()); | |||
| if (wxCoupon == null) { | |||
| return; | |||
| } | |||
| if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { | |||
| return; | |||
| throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"["+wxCoupon.getTitle()+"]已作废"); | |||
| } | |||
| if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(new Date())) { | |||
| return; | |||
| if(showBeginTime == null){ | |||
| showBeginTime = new Date(); | |||
| } | |||
| Date beginTime = null; | |||
| Date endTime = null; | |||
| if(wxCoupon.getSoldStartTime() != null && wxCoupon.getSoldEndTime() != null){ | |||
| beginTime = wxCoupon.getSoldStartTime(); | |||
| endTime = wxCoupon.getSoldEndTime(); | |||
| }else{ | |||
| beginTime = new Date(); | |||
| endTime = wxCoupon.getValidEndDate(); | |||
| if(showBeginTime.after(wxCoupon.getSoldEndTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]上架时间不得晚于售卖结束时间"); | |||
| } | |||
| if(beginTime == null){ | |||
| beginTime = wxCoupon.getSoldStartTime(); | |||
| } | |||
| if(beginTime.before(wxCoupon.getSoldStartTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动开始时间不得早于售卖开始时间"); | |||
| } | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getSoldEndTime(); | |||
| } | |||
| if(endTime.after(wxCoupon.getSoldEndTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动结束时间不得晚于售卖结束时间"); | |||
| } | |||
| } | |||
| if(beginTime == null){ | |||
| beginTime = showBeginTime; | |||
| } | |||
| if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(wxCoupon.getValidType())){ | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getValidEndDate(); | |||
| } | |||
| if(endTime.after(wxCoupon.getValidEndDate())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动结束时间不得晚于有效期结束时间"); | |||
| } | |||
| } | |||
| // 已有的couponChannel, 更新 | |||
| WxCouponChannel wxCouponChannel = wxCouponChannelsMap.get(couponId); | |||
| if (wxCouponChannel != null) { | |||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| wxCouponChannel.setShowBeginTime(beginTime); | |||
| wxCouponChannel.setShowBeginTime(showBeginTime); | |||
| wxCouponChannel.setBeginTime(beginTime); | |||
| wxCouponChannel.setEndTime(endTime); | |||
| wxCouponChannel.setUpdateDate(new Date()); | |||
| @@ -324,7 +345,9 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| // if(voList != null && voList.size() > 0){ | |||
| // wxCouponChannel.setShowBeginTime(voList.get(0).getShowBeginTime()); | |||
| // } | |||
| wxCouponChannel.setShowBeginTime(beginTime); | |||
| wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.updateTenantInfo(wxCoupon); | |||
| wxCouponChannel.setShowBeginTime(showBeginTime); | |||
| wxCouponChannel.setBeginTime(beginTime); | |||
| wxCouponChannel.setEndTime(endTime); | |||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| @@ -332,7 +355,6 @@ public class WxCampaignServiceImpl implements WxCampaignService { | |||
| wxCouponChannel.setMakeMerchantId(wxCoupon.getMakeMerchantId()); | |||
| wxCouponChannel.setType(wxCoupon.getType()); | |||
| wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_CAMPAIN.getCode()); | |||
| wxCouponChannel.updateTenantInfo(wxCoupon); | |||
| wxCouponChannel.setBusiness(wxCoupon.getBusiness()); | |||
| wxCouponChannel.setSubBusiness(wxCoupon.getSubBusiness()); | |||
| wxCouponChannel.setTitle(wxCoupon.getTitle()); | |||
| @@ -622,44 +622,59 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| return vo; | |||
| } | |||
| if(null != channelPrice) { | |||
| if (wxCoupon.getSalePrice() <= 0 && channelPrice > 0) { | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("券为免费券,不能设置渠道价格"); | |||
| return vo; | |||
| } | |||
| } | |||
| if (null != channelStock && channelStock > wxCoupon.getRemainInventory()) { | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("渠道库存不能超过券剩余总库存。"); | |||
| return vo; | |||
| } | |||
| if(showBeginTime == null){ | |||
| showBeginTime = new Date(); | |||
| } | |||
| if(wxCoupon.getSoldStartTime() != null && wxCoupon.getSoldEndTime() != null){ | |||
| if(showBeginTime != null && showBeginTime.after(wxCoupon.getSoldEndTime())){ | |||
| if(showBeginTime.after(wxCoupon.getSoldEndTime())){ | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("上架时间不得晚于售卖结束时间"); | |||
| return vo; | |||
| } | |||
| if(beginTime != null && beginTime.before(wxCoupon.getSoldStartTime())){ | |||
| if(beginTime == null){ | |||
| beginTime = wxCoupon.getSoldStartTime(); | |||
| } | |||
| if(beginTime.before(wxCoupon.getSoldStartTime())){ | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("活动开始时间不得早于售卖开始时间"); | |||
| return vo; | |||
| } | |||
| if(endTime != null && endTime.after(wxCoupon.getSoldEndTime())){ | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getSoldEndTime(); | |||
| } | |||
| if(endTime.after(wxCoupon.getSoldEndTime())){ | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("活动结束时间不得晚于售卖结束时间"); | |||
| return vo; | |||
| } | |||
| } | |||
| if(beginTime == null){ | |||
| beginTime = showBeginTime; | |||
| } | |||
| if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(wxCoupon.getValidType())){ | |||
| if(endTime != null && endTime.after(wxCoupon.getValidEndDate())){ | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getValidEndDate(); | |||
| } | |||
| if(endTime.after(wxCoupon.getValidEndDate())){ | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("活动结束时间不得晚于有效期结束时间"); | |||
| return vo; | |||
| } | |||
| } | |||
| if(null != channelPrice) { | |||
| if (wxCoupon.getSalePrice() <= 0 && channelPrice > 0) { | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("券为免费券,不能设置渠道价格"); | |||
| return vo; | |||
| } | |||
| } | |||
| if (null != channelStock && channelStock > wxCoupon.getRemainInventory()) { | |||
| vo.toCouponChannnelVo(null,channelId); | |||
| vo.setErrorMsg("渠道库存不能超过券剩余总库存。"); | |||
| return vo; | |||
| } | |||
| WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); | |||
| wxCouponChannelQuery.updateTenantInfo(tenantEntity); | |||
| @@ -674,7 +689,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| return vo; | |||
| } | |||
| if(wxCoupon.getStatus()!=EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { | |||
| if(wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { | |||
| logger.debug(wxCoupon.getId()+couponid+ErrorCode.COUPON_IS_TAKE_OFF.getMessage()); | |||
| vo.toCouponChannnelVo(wxCoupon,channelId); | |||
| vo.setErrorMsg(ErrorCode.COUPON_IS_TAKE_OFF.getMessage()); | |||
| @@ -690,23 +705,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| } | |||
| // 投放渠道 | |||
| if(channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode()) || // 列表 | |||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CARD.getCode()) || // 卡频道 | |||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()) || // 砍价 | |||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()) || // 拼团 | |||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CREDIT.getCode()) || // 积分商城 | |||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()) || | |||
| channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_WXLIVE_LIST.getCode()) //微信直播列表 | |||
| ){ | |||
| // 默认投放结束时间为有效时间之后 | |||
| if(wxCoupon.getSoldStartTime() != null && wxCoupon.getSoldEndTime() != null){ | |||
| beginTime = wxCoupon.getSoldStartTime(); | |||
| endTime = wxCoupon.getSoldEndTime(); | |||
| }else{ | |||
| beginTime = new Date(); | |||
| endTime = wxCoupon.getValidEndDate(); | |||
| } | |||
| } | |||
| // if(channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode()) || // 列表 | |||
| // channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CARD.getCode()) || // 卡频道 | |||
| // channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_PRESS.getCode()) || // 砍价 | |||
| // channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_ORDER_GROUP.getCode()) || // 拼团 | |||
| // channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_CREDIT.getCode()) || // 积分商城 | |||
| // channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_DOUYIN_LIST.getCode()) || | |||
| // channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_WXLIVE_LIST.getCode()) //微信直播列表 | |||
| // ){ | |||
| // // 默认投放结束时间为有效时间之后 | |||
| // if(wxCoupon.getSoldStartTime() != null && wxCoupon.getSoldEndTime() != null){ | |||
| // beginTime = wxCoupon.getSoldStartTime(); | |||
| // endTime = wxCoupon.getSoldEndTime(); | |||
| // }else{ | |||
| // beginTime = new Date(); | |||
| // endTime = wxCoupon.getValidEndDate(); | |||
| // } | |||
| // } | |||
| // if(channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())){ // 限时抢购 | |||
| // if(wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(endTime)){ | |||
| @@ -720,17 +735,12 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { | |||
| if(channelStock != null && channelStock.intValue() > 0){ | |||
| int num = wxCouponMapper.reduceInventory(wxCoupon.getId(),tenantEntity.getTenantId(), channelStock); | |||
| if (num == 0) { | |||
| throw new MallinkException(ErrorCode.ORDER_SAVE_ERR); | |||
| throw new MallinkException(ErrorCode.REMAIN_IS_EMPTY); | |||
| } | |||
| } | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| if(showBeginTime == null){ | |||
| wxCouponChannel.setShowBeginTime(new Date()); | |||
| }else { | |||
| wxCouponChannel.setShowBeginTime(showBeginTime); | |||
| } | |||
| wxCouponChannel.setShowBeginTime(showBeginTime); | |||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| wxCouponChannel.setBeginTime(beginTime); | |||
| wxCouponChannel.setEndTime(endTime); | |||
| @@ -287,8 +287,8 @@ public class WxGameServiceImpl implements WxGameService { | |||
| return game; | |||
| } | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| public void saveOrUpdate(WxGame record) { | |||
| if (record.getId() == null) { | |||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||
| @@ -364,38 +364,71 @@ public class WxGameServiceImpl implements WxGameService { | |||
| } | |||
| public void saveOrUpdateCouponChannel(Long couponId, Map<Long, WxCouponChannel> wxCouponChannelsMap, WxGame record){ | |||
| Date showBeginTime = new Date(); | |||
| Date beginTime = record.getValidStartDate(); | |||
| Date endTime = record.getValidEndDate(); | |||
| WxCoupon wxCoupon = wxCouponService.getById(couponId,record.getTenantId()); | |||
| if (wxCoupon == null) { | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||
| return; | |||
| } | |||
| if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { | |||
| throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"["+wxCoupon.getTitle()+"]已作废"); | |||
| } | |||
| if (wxCoupon.getValidEndDate() != null && wxCoupon.getValidEndDate().before(new Date())) { | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED); | |||
| if(showBeginTime == null){ | |||
| showBeginTime = new Date(); | |||
| } | |||
| if(wxCoupon.getSoldStartTime() != null && wxCoupon.getSoldEndTime() != null){ | |||
| if(showBeginTime.after(wxCoupon.getSoldEndTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]上架时间不得晚于售卖结束时间"); | |||
| } | |||
| if(beginTime == null){ | |||
| beginTime = wxCoupon.getSoldStartTime(); | |||
| } | |||
| if(beginTime.before(wxCoupon.getSoldStartTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动开始时间不得早于售卖开始时间"); | |||
| } | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getSoldEndTime(); | |||
| } | |||
| if(endTime.after(wxCoupon.getSoldEndTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动结束时间不得晚于售卖结束时间"); | |||
| } | |||
| } | |||
| if(beginTime == null){ | |||
| beginTime = showBeginTime; | |||
| } | |||
| if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(wxCoupon.getValidType())){ | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getValidEndDate(); | |||
| } | |||
| if(endTime.after(wxCoupon.getValidEndDate())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动结束时间不得晚于有效期结束时间"); | |||
| } | |||
| } | |||
| // 更新已有的couponChannel | |||
| WxCouponChannel wxCouponChannel = wxCouponChannelsMap.get(couponId); | |||
| if (wxCouponChannel != null) { | |||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| wxCouponChannel.setBeginTime(record.getValidStartDate()); | |||
| wxCouponChannel.setEndTime(record.getValidEndDate()); | |||
| wxCouponChannel.setShowBeginTime(showBeginTime); | |||
| wxCouponChannel.setBeginTime(beginTime); | |||
| wxCouponChannel.setEndTime(endTime); | |||
| wxCouponChannel.setUpdateDate(new Date()); | |||
| wxCouponChannelMapper.updateById(wxCouponChannel); | |||
| wxCouponChannelsMap.remove(couponId); | |||
| } else { | |||
| // 不存在的新增 | |||
| wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.setBeginTime(record.getValidStartDate()); | |||
| wxCouponChannel.setEndTime(record.getValidEndDate()); | |||
| wxCouponChannel.updateTenantInfo(wxCoupon); | |||
| wxCouponChannel.setShowBeginTime(showBeginTime); | |||
| wxCouponChannel.setBeginTime(beginTime); | |||
| wxCouponChannel.setEndTime(endTime); | |||
| wxCouponChannel.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); | |||
| wxCouponChannel.setCouponId(couponId); | |||
| wxCouponChannel.setMakeMerchantId(wxCoupon.getMakeMerchantId()); | |||
| wxCouponChannel.setType(wxCoupon.getType()); | |||
| wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_GAME.getCode()); | |||
| wxCouponChannel.updateTenantInfo(wxCoupon); | |||
| wxCouponChannel.setBusiness(wxCoupon.getBusiness()); | |||
| wxCouponChannel.setSubBusiness(wxCoupon.getSubBusiness()); | |||
| wxCouponChannel.setTitle(wxCoupon.getTitle()); | |||
| @@ -12,6 +12,7 @@ import com.iformall.domain.po.WxTopic; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxCouponChannelMapper; | |||
| import com.iformall.mapper.WxCouponMapper; | |||
| import com.iformall.mapper.WxTopicMapper; | |||
| @@ -25,6 +26,9 @@ import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import com.iformall.common.ResultData; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @@ -91,6 +95,7 @@ public class WxTopicServiceImpl implements WxTopicService { | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||
| public ResultData saveOrUpdate(WxTopic record) { | |||
| //验证是否存在已发放的专题 | |||
| // if(record.getStatus().equals(EnumWxTopicStatus.VAILD.getCode())) { | |||
| @@ -148,19 +153,63 @@ public class WxTopicServiceImpl implements WxTopicService { | |||
| } | |||
| private void addCouponTopic(WxTopic record){ | |||
| Date showBeginTime = record.getBeginTime(); | |||
| Date beginTime = record.getBeginTime(); | |||
| Date endTime = record.getEndTime(); | |||
| for (String couponId:JSONArray.parseArray(record.getCouponIds(), String.class)) { | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| String[] couponArray = couponId.split("-"); | |||
| //保存coupon_channel | |||
| WxCoupon wxCoupon = wxCouponMapper.selectById(Long.parseLong(couponArray[1]),record.getTenantId()); | |||
| if (wxCoupon == null) { | |||
| return; | |||
| } | |||
| if (wxCoupon.getStatus() != EnumCouponStatus.COUPON_STATUS_THROW_IN.getCode()) { | |||
| throw new MallinkException(ErrorCode.COUPON_IS_TAKE_OFF.getCode(),"["+wxCoupon.getTitle()+"]已作废"); | |||
| } | |||
| if(showBeginTime == null){ | |||
| showBeginTime = new Date(); | |||
| } | |||
| if(wxCoupon.getSoldStartTime() != null && wxCoupon.getSoldEndTime() != null){ | |||
| if(showBeginTime.after(wxCoupon.getSoldEndTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]上架时间不得晚于售卖结束时间"); | |||
| } | |||
| if(beginTime == null){ | |||
| beginTime = wxCoupon.getSoldStartTime(); | |||
| } | |||
| if(beginTime.before(wxCoupon.getSoldStartTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动开始时间不得早于售卖开始时间"); | |||
| } | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getSoldEndTime(); | |||
| } | |||
| if(endTime.after(wxCoupon.getSoldEndTime())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动结束时间不得晚于售卖结束时间"); | |||
| } | |||
| } | |||
| if(beginTime == null){ | |||
| beginTime = showBeginTime; | |||
| } | |||
| if(EnumCouponValidType.BETWEEN_TWO_TIME.getCode().equals(wxCoupon.getValidType())){ | |||
| if(endTime == null){ | |||
| endTime = wxCoupon.getValidEndDate(); | |||
| } | |||
| if(endTime.after(wxCoupon.getValidEndDate())){ | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED.getCode(),"["+wxCoupon.getTitle()+"]活动结束时间不得晚于有效期结束时间"); | |||
| } | |||
| } | |||
| WxCouponChannel wxCouponChannel = new WxCouponChannel(); | |||
| wxCouponChannel.updateTenantInfo(record); | |||
| wxCouponChannel.setId(idWorker.nextId()); | |||
| wxCouponChannel.setBeginTime(record.getBeginTime()); | |||
| wxCouponChannel.setEndTime(record.getEndTime()); | |||
| wxCouponChannel.setShowBeginTime(beginTime); | |||
| wxCouponChannel.setBeginTime(beginTime); | |||
| wxCouponChannel.setEndTime(endTime); | |||
| wxCouponChannel.setCouponId(wxCoupon.getId()); | |||
| wxCouponChannel.setMakeMerchantId(wxCoupon.getMakeMerchantId()); | |||
| wxCouponChannel.setSubTargetId(record.getId()); | |||
| wxCouponChannel.updateTenantInfo(record); | |||
| wxCouponChannel.setTitle(wxCoupon.getTitle()); | |||
| wxCouponChannel.setTargetAd(EnumCouponChannelType.COUPON_CHANNEL_ID_TOPIC.getCode()); | |||
| wxCouponChannel.setType(wxCoupon.getType()); | |||