From 6d5a27dfa47893569da2b1f5bb04bf65768a8f9b Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Sun, 8 Aug 2021 16:06:23 +0800 Subject: [PATCH] 1 --- .../HighDiscountAgentRelController.java | 28 +++++++++++++++++++ .../HighDiscountAgentCodeServiceImpl.java | 4 +++ 2 files changed, 32 insertions(+) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java index 3b2d2237..5da85c8b 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighDiscountAgentRelController.java @@ -1,6 +1,7 @@ package com.bweb.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.bweb.config.SysConst; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -202,4 +203,31 @@ public class HighDiscountAgentRelController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value="/getDiscountStatus",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "修改状态") + public ResponseData getDiscountStatus(@RequestBody JSONObject jsonObject) { + try { + + Integer status = jsonObject.getInteger("status"); + Long minNumber = jsonObject.getLong("minNumber"); + Long maxNumber = jsonObject.getLong("maxNumber"); + + for (Long i = minNumber; i <= maxNumber; i++) { + HighDiscountAgentCode highDiscountAgentCode = highDiscountAgentCodeService.getCodeById(i); + if (highDiscountAgentCode.getStatus() == 1 || highDiscountAgentCode.getStatus() == 4 ) { + highDiscountAgentCode.setStatus(status); + highDiscountAgentCodeService.updateCode(highDiscountAgentCode); + } + } + + return ResponseMsgUtil.success("成功"); + + } catch (Exception e) { + log.error("HighDiscountController -> getDiscountCodeById() error!",e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java index bb278771..e90665f5 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighDiscountAgentCodeServiceImpl.java @@ -5,6 +5,8 @@ import com.hai.entity.*; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.List; @@ -50,6 +52,7 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe } @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) public void updateCode(HighDiscountAgentCode highDiscountAgentCode) { highDiscountAgentCodeMapper.updateByPrimaryKey(highDiscountAgentCode); } @@ -104,4 +107,5 @@ public class HighDiscountAgentCodeServiceImpl implements HighDiscountAgentCodeSe example.createCriteria().andDiscountAgentIdEqualTo(discountAgentId).andStatusNotEqualTo(1); return highDiscountAgentCodeMapper.selectByExample(example).size(); } + }