diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java index 0b8960b43..a44e51727 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java @@ -17,6 +17,7 @@ import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import java.util.List; @RestController @@ -51,6 +52,23 @@ public class WxCouponChannelController extends BaseController @PostMapping("update") public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) { wxCouponChannel.setTenantId(getUser().getTenantId()); + if(wxCouponChannel.getCouponId()!=null&&wxCouponChannel.getStatus()!=null){ + WxCouponChannel orignal = wxCouponChannelService.getById(wxCouponChannel.getId()); + if(orignal.getStatus()==1&&wxCouponChannel.getStatus()==0){ + //查找是否该券 在该频道有其他上架 + WxCouponChannel query = new WxCouponChannel(); + query.setTenantId(orignal.getTenantId()); + query.setCouponId(orignal.getCouponId()); + query.setStatus(0);//已上架 + query.setTargetAd(orignal.getTargetAd()); + List list = wxCouponChannelService.listAsPage(query,1,1).getList(); + if(list!=null&&list.size()>0){ + //不能修改 + return new ResultData(Result.ERROR,"不允许同一个券,多个投放"); + } + } + + } wxCouponChannelService.saveOrUpdate(wxCouponChannel); return new ResultData(); } diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java index 727572056..4a66b6fdd 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java @@ -22,13 +22,13 @@ import org.springframework.transaction.annotation.Transactional; @Service public class WxCouponServiceImpl implements WxCouponService { - - @Autowired + + @Autowired WxCouponMapper wxCouponMapper; - @Autowired + @Autowired WxCouponChannelService wxCouponChannelService; - @Autowired + @Autowired WxCouponSendService wxCouponSendService; @@ -57,7 +57,7 @@ public class WxCouponServiceImpl implements WxCouponService { if (record.getId() == null) { //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); final IdWorker idWorker = IdWorker.get(); - record.setId(idWorker.nextId()); + record.setId(idWorker.nextId()); wxCouponMapper.insertSelective(record); } else { wxCouponMapper.updateByPrimaryKeySelective(record); @@ -84,11 +84,11 @@ public class WxCouponServiceImpl implements WxCouponService { @Transactional public ResultData updateCoupon(WxCoupon wxCoupon) { WxCoupon query = wxCouponMapper.selectByPrimaryKey(wxCoupon.getId()); - if(wxCoupon.getStatus()!=null){ - if(wxCoupon.getStatus()==1){ //已作废 + if (wxCoupon.getStatus() != null) { + if (query.getStatus() == 0 && wxCoupon.getStatus() == 1) { //作废所有投放频道 - wxCouponChannelService.updateStatusByCouponId(wxCoupon.getId(),query.getTenantId(),1); - wxCouponSendService.updateStatusByCouponId(query.getId(),query.getTenantId(),1); + wxCouponChannelService.updateStatusByCouponId(wxCoupon.getId(), query.getTenantId(), 1); + wxCouponSendService.updateStatusByCouponId(query.getId(), query.getTenantId(), 1); } } return new ResultData(saveOrUpdate(wxCoupon));