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(); } + }