From 8327d5fe0ae6fd0dfb0dfa6f115260d0592778b2 Mon Sep 17 00:00:00 2001 From: masterspirit Date: Tue, 28 Aug 2018 01:03:22 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8D=A1=E5=88=B8=E6=8A=95=E6=94=BE][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:=E9=81=BF=E5=85=8D=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E5=88=B8=E5=A4=9A=E6=AC=A1=E6=8A=95=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCouponChannelController.java | 18 ++++++++++++++++++ .../service/impl/WxCouponServiceImpl.java | 18 +++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) 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));