From 5dc97ef9fe9f142696773f37b6846a4081329488 Mon Sep 17 00:00:00 2001 From: masterspirit Date: Mon, 27 Aug 2018 19:01:04 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8D=A1=E5=88=B8=E4=BF=AE=E6=94=B9][?= =?UTF-8?q?=E4=BF=AE=E6=94=B9]:=E7=8A=B6=E6=80=81=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simple/controller/WxCouponController.java | 11 +------ .../controller/WxCouponSendController.java | 8 +++++ .../simple/mapper/WxCouponChannelMapper.java | 2 ++ .../com/simple/mapper/WxCouponSendMapper.java | 2 ++ .../service/WxCouponChannelService.java | 2 ++ .../simple/service/WxCouponSendService.java | 2 ++ .../com/simple/service/WxCouponService.java | 3 ++ .../service/impl/CouponInjectServiceImpl.java | 4 +++ .../impl/WxCouponChannelServiceImpl.java | 8 +++++ .../service/impl/WxCouponSendServiceImpl.java | 9 ++++++ .../service/impl/WxCouponServiceImpl.java | 29 +++++++++++++++++++ .../mapper/WxCouponChannelMapper.xml | 5 ++++ .../resources/mapper/WxCouponSendMapper.xml | 4 +++ 13 files changed, 79 insertions(+), 10 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java index 7e341e8bc..4e47f2e65 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponController.java @@ -133,20 +133,11 @@ public class WxCouponController extends BaseController if(wxCoupon.getId()==null) { return new ResultData(ResultData.ERROR,"缺少id"); } - if(wxCoupon.getStatus()!=null){ - if(wxCoupon.getStatus()==3){ //已作废 - WxCoupon temp = wxCouponService.getById(wxCoupon.getId()); - if(temp.getStatus()==1){ - return new ResultData(Result.ERROR,"生效的卡券,不能修改"); - } - } - } if(StringUtils.isNotBlank(wxCoupon.getBusiness())) { String[] arys = wxCoupon.getBusiness().split(","); wxCoupon.setBusiness(JSON.toJSONString(arys)); } - Long id = wxCouponService.saveOrUpdate(wxCoupon); - return new ResultData(id); + return wxCouponService.updateCoupon(wxCoupon); } @ApiOperation("根据id删除接口") diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java index dbf30bd28..b2b0dc92f 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponSendController.java @@ -46,11 +46,19 @@ public class WxCouponSendController extends BaseController @ApiOperation("新增接口") @PostMapping("add") public ResultData add(@RequestBody WxCouponSend wxCouponSend) { + if (null == wxCouponSend){ + return new ResultData(Result.ERROR,"参数不对"); + } + wxCouponSend.setTenantId(getTenantId()); + wxCouponSend.setStatus(0); List wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend,1,1).getList(); if(wxCouponSendList!=null&&!wxCouponSendList.isEmpty()){ return new ResultData(Result.ERROR,"已经添加过该券"); } WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); + if(wxCoupon.getStatus()!=0||wxCoupon.getSendType()!=2){ + return new ResultData(Result.ERROR,"该券的状态有问题"); + } wxCouponSend.setMerchantId(wxCoupon.getMerchantId()); wxCouponSend.setType(wxCoupon.getType()); diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java index b5bd20448..613e9dd7f 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponChannelMapper.java @@ -11,6 +11,8 @@ public interface WxCouponChannelMapper extends CommonMapper findList(WxCouponChannel wxCouponChannel); List findVoList(WxCouponChannel wxCouponChannel); + + void updateStatusByCouponId(WxCouponChannel wxCouponChannel); diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCouponSendMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCouponSendMapper.java index a24aea6e4..50695b42f 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCouponSendMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCouponSendMapper.java @@ -8,6 +8,8 @@ import com.simple.domain.po.WxCouponSend; public interface WxCouponSendMapper extends CommonMapper { List findList(WxCouponSend wxCouponSend); + + void updateStatusByCouponId(WxCouponSend wxCouponSend); diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java index 1b1d1a985..c1093fd49 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java @@ -43,6 +43,8 @@ public interface WxCouponChannelService { void deleteById(Long id); void addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime,Date endTime); + + void updateStatusByCouponId(Long couponId,String tenantId,int status); diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponSendService.java b/mallinkService/src/main/java/com/simple/service/WxCouponSendService.java index d388aa9c6..ce289abdd 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponSendService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponSendService.java @@ -45,6 +45,8 @@ public interface WxCouponSendService { * @param type 2:停车发券 3:核销发券 */ void sendCouponToUser(String tenantId,Long cUserId,int type); + + void updateStatusByCouponId(Long couponId,String tenantId,int status); diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponService.java b/mallinkService/src/main/java/com/simple/service/WxCouponService.java index ea3aa7a7a..6dc34f35e 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponService.java @@ -2,6 +2,7 @@ package com.simple.service; import java.util.*; import com.github.pagehelper.PageInfo; +import com.simple.common.ResultData; import com.simple.domain.po.WxCoupon; import com.simple.domain.po.WxCouponChannel; import com.simple.domain.vo.WxCouponCVo; @@ -64,4 +65,6 @@ public interface WxCouponService { WxCouponCVo selectDetailForCUser(WxCouponChannel record); + ResultData updateCoupon(WxCoupon wxCoupon); + } diff --git a/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java index bcedd2a97..9cf7b022a 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/CouponInjectServiceImpl.java @@ -72,6 +72,10 @@ public class CouponInjectServiceImpl implements CouponInjectService { return new ResultData(Result.ERROR,"已过期"); } } + if(wxCoupon.getStatus()!=0||wxCoupon.getSendType()!=1){ + return new ResultData(Result.ERROR,"券状态有问题,不能投放"); + } + //解析前台tags,并转换json String[] arys = record.getTags().split(","); List tagids = new ArrayList<>(); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java index 7065d41c9..1de28ed00 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java @@ -74,6 +74,14 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } + @Override + public void updateStatusByCouponId(Long couponId, String tenantId, int status) { + WxCouponChannel wxCouponChannel = new WxCouponChannel(); + wxCouponChannel.setTenantId(tenantId); + wxCouponChannel.setStatus(status); + wxCouponChannel.setCouponId(couponId); + } + @Transactional public void addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java index 6aea7694a..5f131c8d1 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponSendServiceImpl.java @@ -99,5 +99,14 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { } + @Override + public void updateStatusByCouponId(Long couponId, String tenantId, int status) { + WxCouponSend wxCouponSend = new WxCouponSend(); + wxCouponSend.setTenantId(tenantId); + wxCouponSend.setCouponId(couponId); + wxCouponSend.setStatus(status); + wxCouponSendMapper.updateStatusByCouponId(wxCouponSend); + } + } 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 16abf5c23..727572056 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java @@ -3,20 +3,33 @@ package com.simple.service.impl; import java.util.*; 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.po.WxCouponSend; import com.simple.domain.vo.WxCouponCVo; +import com.simple.mapper.WxCouponChannelMapper; import com.simple.mapper.WxCouponMapper; +import com.simple.service.WxCampaignService; +import com.simple.service.WxCouponChannelService; +import com.simple.service.WxCouponSendService; import com.simple.service.WxCouponService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.simple.common.IdWorker; +import org.springframework.transaction.annotation.Transactional; @Service public class WxCouponServiceImpl implements WxCouponService { @Autowired WxCouponMapper wxCouponMapper; + @Autowired + WxCouponChannelService wxCouponChannelService; + + @Autowired + WxCouponSendService wxCouponSendService; @Override @@ -67,4 +80,20 @@ public class WxCouponServiceImpl implements WxCouponService { return wxCouponMapper.selectDetailForCUser(record); } + @Override + @Transactional + public ResultData updateCoupon(WxCoupon wxCoupon) { + WxCoupon query = wxCouponMapper.selectByPrimaryKey(wxCoupon.getId()); + if(wxCoupon.getStatus()!=null){ + if(wxCoupon.getStatus()==1){ //已作废 + //作废所有投放频道 + wxCouponChannelService.updateStatusByCouponId(wxCoupon.getId(),query.getTenantId(),1); + wxCouponSendService.updateStatusByCouponId(query.getId(),query.getTenantId(),1); + } + } + return new ResultData(saveOrUpdate(wxCoupon)); + + } + + } diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index 2ce097744..b6193895e 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -121,6 +121,11 @@ + + update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} + + + diff --git a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml index bfc8a822e..27a4be553 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml @@ -100,6 +100,10 @@ + + update wx_coupon_send set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} + +