|
|
|
@@ -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<WxCouponChannel> 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; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|