|
|
@@ -5,6 +5,7 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
|
import com.iformall.common.ErrorCode; |
|
|
import com.iformall.common.Result; |
|
|
import com.iformall.common.Result; |
|
|
import com.iformall.common.ResultData; |
|
|
import com.iformall.common.ResultData; |
|
|
import com.iformall.domain.po.WxCoupon; |
|
|
import com.iformall.domain.po.WxCoupon; |
|
|
@@ -12,6 +13,10 @@ import com.iformall.domain.po.WxCouponChannel; |
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
import com.iformall.domain.po.WxMerchant; |
|
|
import com.iformall.domain.vo.WxCouponChannelAddVo; |
|
|
import com.iformall.domain.vo.WxCouponChannelAddVo; |
|
|
import com.iformall.domain.vo.WxCouponChannelVo; |
|
|
import com.iformall.domain.vo.WxCouponChannelVo; |
|
|
|
|
|
import com.iformall.enums.EnumCouponChannelStatus; |
|
|
|
|
|
import com.iformall.enums.EnumCouponChannelType; |
|
|
|
|
|
import com.iformall.enums.EnumCouponStatus; |
|
|
|
|
|
import com.iformall.enums.EnumMerchantStatus; |
|
|
import com.iformall.mapper.WxCouponChannelMapper; |
|
|
import com.iformall.mapper.WxCouponChannelMapper; |
|
|
import com.iformall.mapper.WxMerchantMapper; |
|
|
import com.iformall.mapper.WxMerchantMapper; |
|
|
import com.iformall.service.WxCouponChannelService; |
|
|
import com.iformall.service.WxCouponChannelService; |
|
|
@@ -69,25 +74,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ResultData 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; |
|
|
|
|
|
|
|
|
|
|
|
List<WxCouponChannelAddVo> errorList = new ArrayList<>(); |
|
|
List<WxCouponChannelAddVo> errorList = new ArrayList<>(); |
|
|
for (String targetIdstr:channelId) { |
|
|
for (String targetIdstr:channelId) { |
|
|
Integer targetId = Integer.parseInt(targetIdstr); |
|
|
Integer targetId = Integer.parseInt(targetIdstr); |
|
|
for (String couponidstr:ids) { |
|
|
for (String couponidstr:ids) { |
|
|
Long couponid = Long.parseLong(couponidstr); |
|
|
Long couponid = Long.parseLong(couponidstr); |
|
|
boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime,errorList); |
|
|
|
|
|
if(addResult){ |
|
|
|
|
|
result = true; |
|
|
|
|
|
|
|
|
WxCouponChannelAddVo vo = addCouponChannel(couponid,targetId,tanantId,beginTime,endTime); |
|
|
|
|
|
if(vo != null){ |
|
|
|
|
|
errorList.add(vo); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if(result) { |
|
|
|
|
|
|
|
|
if(errorList.size()>0) { |
|
|
return new ResultData(errorList); |
|
|
return new ResultData(errorList); |
|
|
}else { |
|
|
}else { |
|
|
return new ResultData(Result.SUCCESS,"请检查券的有效期以及投放截止时间",errorList); |
|
|
|
|
|
|
|
|
return new ResultData(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@@ -100,40 +103,67 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime,List<WxCouponChannelAddVo> errorList){ |
|
|
|
|
|
|
|
|
public WxCouponChannelAddVo addCouponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ |
|
|
|
|
|
|
|
|
|
|
|
WxCouponChannelAddVo vo = new WxCouponChannelAddVo(); |
|
|
|
|
|
|
|
|
|
|
|
WxCoupon wxCoupon = wxCouponService.getById(couponid); |
|
|
|
|
|
if(wxCoupon==null){ |
|
|
|
|
|
logger.debug(couponid+ErrorCode.COUPON_IS_EMPTY.getMessage()); |
|
|
|
|
|
vo.toCouponChannnelVo(null,channelId); |
|
|
|
|
|
vo.setErrorMsg(ErrorCode.COUPON_IS_EMPTY.getMessage()); |
|
|
|
|
|
return vo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); |
|
|
WxCouponChannel wxCouponChannelQuery = new WxCouponChannel(); |
|
|
wxCouponChannelQuery.setTenantId(tanantId); |
|
|
wxCouponChannelQuery.setTenantId(tanantId); |
|
|
wxCouponChannelQuery.setCouponId(couponid); |
|
|
wxCouponChannelQuery.setCouponId(couponid); |
|
|
wxCouponChannelQuery.setTargetAd(channelId); |
|
|
wxCouponChannelQuery.setTargetAd(channelId); |
|
|
wxCouponChannelQuery.setStatus(0); |
|
|
|
|
|
|
|
|
wxCouponChannelQuery.setStatus(EnumCouponChannelStatus.STATUS_THROW_IN.getCode()); |
|
|
List<WxCouponChannel> wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); |
|
|
List<WxCouponChannel> wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery); |
|
|
if(wxCouponChannels.size()>0){ |
|
|
if(wxCouponChannels.size()>0){ |
|
|
logger.debug(couponid+"已经投放过了"); |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
logger.debug(couponid+ErrorCode.COUPON_CHANNEL_IS_EXISTED.getMessage()); |
|
|
|
|
|
vo.toCouponChannnelVo(wxCoupon,channelId); |
|
|
|
|
|
vo.setErrorMsg(ErrorCode.COUPON_CHANNEL_IS_EXISTED.getMessage()); |
|
|
|
|
|
return vo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
WxCoupon wxCoupon = wxCouponService.getById(couponid); |
|
|
|
|
|
if(wxCoupon==null){ |
|
|
|
|
|
logger.debug(couponid+"没有查到对应的券信息"); |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
return vo; |
|
|
} |
|
|
} |
|
|
if(wxCoupon.getStatus()!=0) { |
|
|
|
|
|
logger.debug(wxCoupon.getId()+"状态不对"); |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WxMerchant wxMerchant = new WxMerchant(); |
|
|
|
|
|
wxMerchant.setId(wxCoupon.getMerchantId()); |
|
|
|
|
|
List <WxMerchant> merchants = wxMerchantMapper.findList(wxMerchant); |
|
|
|
|
|
if(merchants.size() <= 0) { |
|
|
|
|
|
logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); |
|
|
|
|
|
vo.toCouponChannnelVo(wxCoupon,channelId); |
|
|
|
|
|
vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage()); |
|
|
|
|
|
return vo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(merchants.get(0).getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { |
|
|
|
|
|
logger.debug(wxCoupon.getId()+couponid+ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage()); |
|
|
|
|
|
vo.toCouponChannnelVo(wxCoupon,channelId); |
|
|
|
|
|
vo.setErrorMsg(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage()); |
|
|
|
|
|
return vo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(channelId==1){ //列表默认投放结束时间为有效时间之后 |
|
|
|
|
|
|
|
|
if(channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_LIST.getCode())){ //列表默认投放结束时间为有效时间之后 |
|
|
beginTime = new Date(); |
|
|
beginTime = new Date(); |
|
|
endTime = wxCoupon.getValidEndDate(); |
|
|
endTime = wxCoupon.getValidEndDate(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(channelId==2){ |
|
|
|
|
|
|
|
|
if(channelId.equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())){ |
|
|
if(wxCoupon.getValidEndDate()!=null&&wxCoupon.getValidEndDate().before(endTime)){ |
|
|
if(wxCoupon.getValidEndDate()!=null&&wxCoupon.getValidEndDate().before(endTime)){ |
|
|
logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间"); |
|
|
|
|
|
WxCouponChannelAddVo vo = new WxCouponChannelAddVo(); |
|
|
|
|
|
errorList.add(vo.toCouponChannnelVo(wxCoupon,channelId)); |
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
logger.debug(wxCoupon.getId()+ErrorCode.COUPON_SEND_IS_INVALID_TIME.getMessage()); |
|
|
|
|
|
vo.toCouponChannnelVo(wxCoupon,channelId); |
|
|
|
|
|
vo.setErrorMsg(ErrorCode.COUPON_SEND_IS_INVALID_TIME.getMessage()); |
|
|
|
|
|
return vo; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@@ -151,7 +181,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { |
|
|
wxCouponChannel.setBusiness(wxCoupon.getBusiness()); |
|
|
wxCouponChannel.setBusiness(wxCoupon.getBusiness()); |
|
|
wxCouponChannel.setTitle(wxCoupon.getTitle()); |
|
|
wxCouponChannel.setTitle(wxCoupon.getTitle()); |
|
|
saveOrUpdate(wxCouponChannel); |
|
|
saveOrUpdate(wxCouponChannel); |
|
|
return true; |
|
|
|
|
|
|
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
|