| @@ -133,20 +133,11 @@ public class WxCouponController extends BaseController | |||||
| if(wxCoupon.getId()==null) { | if(wxCoupon.getId()==null) { | ||||
| return new ResultData(ResultData.ERROR,"缺少id"); | 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())) { | if(StringUtils.isNotBlank(wxCoupon.getBusiness())) { | ||||
| String[] arys = wxCoupon.getBusiness().split(","); | String[] arys = wxCoupon.getBusiness().split(","); | ||||
| wxCoupon.setBusiness(JSON.toJSONString(arys)); | wxCoupon.setBusiness(JSON.toJSONString(arys)); | ||||
| } | } | ||||
| Long id = wxCouponService.saveOrUpdate(wxCoupon); | |||||
| return new ResultData(id); | |||||
| return wxCouponService.updateCoupon(wxCoupon); | |||||
| } | } | ||||
| @ApiOperation("根据id删除接口") | @ApiOperation("根据id删除接口") | ||||
| @@ -46,11 +46,19 @@ public class WxCouponSendController extends BaseController | |||||
| @ApiOperation("新增接口") | @ApiOperation("新增接口") | ||||
| @PostMapping("add") | @PostMapping("add") | ||||
| public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | public ResultData add(@RequestBody WxCouponSend wxCouponSend) { | ||||
| if (null == wxCouponSend){ | |||||
| return new ResultData(Result.ERROR,"参数不对"); | |||||
| } | |||||
| wxCouponSend.setTenantId(getTenantId()); | |||||
| wxCouponSend.setStatus(0); | |||||
| List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend,1,1).getList(); | List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend,1,1).getList(); | ||||
| if(wxCouponSendList!=null&&!wxCouponSendList.isEmpty()){ | if(wxCouponSendList!=null&&!wxCouponSendList.isEmpty()){ | ||||
| return new ResultData(Result.ERROR,"已经添加过该券"); | return new ResultData(Result.ERROR,"已经添加过该券"); | ||||
| } | } | ||||
| WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); | WxCoupon wxCoupon = wxCouponService.getById(wxCouponSend.getCouponId()); | ||||
| if(wxCoupon.getStatus()!=0||wxCoupon.getSendType()!=2){ | |||||
| return new ResultData(Result.ERROR,"该券的状态有问题"); | |||||
| } | |||||
| wxCouponSend.setMerchantId(wxCoupon.getMerchantId()); | wxCouponSend.setMerchantId(wxCoupon.getMerchantId()); | ||||
| wxCouponSend.setType(wxCoupon.getType()); | wxCouponSend.setType(wxCoupon.getType()); | ||||
| @@ -11,6 +11,8 @@ public interface WxCouponChannelMapper extends CommonMapper<WxCouponChannel, Str | |||||
| List<WxCouponChannel> findList(WxCouponChannel wxCouponChannel); | List<WxCouponChannel> findList(WxCouponChannel wxCouponChannel); | ||||
| List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | List<WxCouponChannelVo> findVoList(WxCouponChannel wxCouponChannel); | ||||
| void updateStatusByCouponId(WxCouponChannel wxCouponChannel); | |||||
| @@ -8,6 +8,8 @@ import com.simple.domain.po.WxCouponSend; | |||||
| public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> { | public interface WxCouponSendMapper extends CommonMapper<WxCouponSend, String> { | ||||
| List<WxCouponSend> findList(WxCouponSend wxCouponSend); | List<WxCouponSend> findList(WxCouponSend wxCouponSend); | ||||
| void updateStatusByCouponId(WxCouponSend wxCouponSend); | |||||
| @@ -43,6 +43,8 @@ public interface WxCouponChannelService { | |||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| void addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime,Date endTime); | void addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime,Date endTime); | ||||
| void updateStatusByCouponId(Long couponId,String tenantId,int status); | |||||
| @@ -45,6 +45,8 @@ public interface WxCouponSendService { | |||||
| * @param type 2:停车发券 3:核销发券 | * @param type 2:停车发券 3:核销发券 | ||||
| */ | */ | ||||
| void sendCouponToUser(String tenantId,Long cUserId,int type); | void sendCouponToUser(String tenantId,Long cUserId,int type); | ||||
| void updateStatusByCouponId(Long couponId,String tenantId,int status); | |||||
| @@ -2,6 +2,7 @@ package com.simple.service; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxCoupon; | import com.simple.domain.po.WxCoupon; | ||||
| import com.simple.domain.po.WxCouponChannel; | import com.simple.domain.po.WxCouponChannel; | ||||
| import com.simple.domain.vo.WxCouponCVo; | import com.simple.domain.vo.WxCouponCVo; | ||||
| @@ -64,4 +65,6 @@ public interface WxCouponService { | |||||
| WxCouponCVo selectDetailForCUser(WxCouponChannel record); | WxCouponCVo selectDetailForCUser(WxCouponChannel record); | ||||
| ResultData updateCoupon(WxCoupon wxCoupon); | |||||
| } | } | ||||
| @@ -72,6 +72,10 @@ public class CouponInjectServiceImpl implements CouponInjectService { | |||||
| return new ResultData(Result.ERROR,"已过期"); | return new ResultData(Result.ERROR,"已过期"); | ||||
| } | } | ||||
| } | } | ||||
| if(wxCoupon.getStatus()!=0||wxCoupon.getSendType()!=1){ | |||||
| return new ResultData(Result.ERROR,"券状态有问题,不能投放"); | |||||
| } | |||||
| //解析前台tags,并转换json | //解析前台tags,并转换json | ||||
| String[] arys = record.getTags().split(","); | String[] arys = record.getTags().split(","); | ||||
| List<Long> tagids = new ArrayList<>(); | List<Long> tagids = new ArrayList<>(); | ||||
| @@ -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 | @Transactional | ||||
| public void addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ | public void addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){ | ||||
| @@ -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); | |||||
| } | |||||
| } | } | ||||
| @@ -3,20 +3,33 @@ package com.simple.service.impl; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | 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.WxCoupon; | ||||
| import com.simple.domain.po.WxCouponChannel; | import com.simple.domain.po.WxCouponChannel; | ||||
| import com.simple.domain.po.WxCouponSend; | |||||
| import com.simple.domain.vo.WxCouponCVo; | import com.simple.domain.vo.WxCouponCVo; | ||||
| import com.simple.mapper.WxCouponChannelMapper; | |||||
| import com.simple.mapper.WxCouponMapper; | 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 com.simple.service.WxCouponService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| @Service | @Service | ||||
| public class WxCouponServiceImpl implements WxCouponService { | public class WxCouponServiceImpl implements WxCouponService { | ||||
| @Autowired | @Autowired | ||||
| WxCouponMapper wxCouponMapper; | WxCouponMapper wxCouponMapper; | ||||
| @Autowired | |||||
| WxCouponChannelService wxCouponChannelService; | |||||
| @Autowired | |||||
| WxCouponSendService wxCouponSendService; | |||||
| @Override | @Override | ||||
| @@ -67,4 +80,20 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| return wxCouponMapper.selectDetailForCUser(record); | 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)); | |||||
| } | |||||
| } | } | ||||
| @@ -121,6 +121,11 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <update id="updateStatusByCouponId" parameterType="com.simple.domain.po.WxCouponChannel"> | |||||
| update wx_coupon_channel set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} | |||||
| </update> | |||||
| <resultMap id="CouponChannelVoMap" type="com.simple.domain.vo.WxCouponChannelVo"> | <resultMap id="CouponChannelVoMap" type="com.simple.domain.vo.WxCouponChannelVo"> | ||||
| <id column="id" jdbcType="BIGINT" property="id" /> | <id column="id" jdbcType="BIGINT" property="id" /> | ||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | ||||
| @@ -100,6 +100,10 @@ | |||||
| <include refid="dynamicWhereConditions" /> | <include refid="dynamicWhereConditions" /> | ||||
| </select> | </select> | ||||
| <update id="updateStatusByCouponId" parameterType="com.simple.domain.po.WxCouponChannel"> | |||||
| update wx_coupon_send set status=#{status} where tenant_id=#{tenantId} and coupon_id=#{couponId} | |||||
| </update> | |||||