Преглед изворни кода

[卡券投放][修改]:避免,同一个券多次投放

release_toaliyun_real
masterspirit пре 7 година
родитељ
комит
8327d5fe0a
2 измењених фајлова са 27 додато и 9 уклоњено
  1. +18
    -0
      mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java
  2. +9
    -9
      mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java

+ 18
- 0
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.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;


import java.util.List;




@RestController @RestController
@@ -51,6 +52,23 @@ public class WxCouponChannelController extends BaseController
@PostMapping("update") @PostMapping("update")
public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) { public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) {
wxCouponChannel.setTenantId(getUser().getTenantId()); 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<WxCouponChannel> list = wxCouponChannelService.listAsPage(query,1,1).getList();
if(list!=null&&list.size()>0){
//不能修改
return new ResultData(Result.ERROR,"不允许同一个券,多个投放");
}
}

}
wxCouponChannelService.saveOrUpdate(wxCouponChannel); wxCouponChannelService.saveOrUpdate(wxCouponChannel);
return new ResultData(); return new ResultData();
} }


+ 9
- 9
mallinkService/src/main/java/com/simple/service/impl/WxCouponServiceImpl.java Прегледај датотеку

@@ -22,13 +22,13 @@ 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
@Autowired
WxCouponChannelService wxCouponChannelService; WxCouponChannelService wxCouponChannelService;


@Autowired
@Autowired
WxCouponSendService wxCouponSendService; WxCouponSendService wxCouponSendService;




@@ -57,7 +57,7 @@ public class WxCouponServiceImpl implements WxCouponService {
if (record.getId() == null) { if (record.getId() == null) {
//record.setId(UUID.randomUUID().toString().replaceAll("-", "")); //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
final IdWorker idWorker = IdWorker.get(); final IdWorker idWorker = IdWorker.get();
record.setId(idWorker.nextId());
record.setId(idWorker.nextId());
wxCouponMapper.insertSelective(record); wxCouponMapper.insertSelective(record);
} else { } else {
wxCouponMapper.updateByPrimaryKeySelective(record); wxCouponMapper.updateByPrimaryKeySelective(record);
@@ -84,11 +84,11 @@ public class WxCouponServiceImpl implements WxCouponService {
@Transactional @Transactional
public ResultData updateCoupon(WxCoupon wxCoupon) { public ResultData updateCoupon(WxCoupon wxCoupon) {
WxCoupon query = wxCouponMapper.selectByPrimaryKey(wxCoupon.getId()); 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)); return new ResultData(saveOrUpdate(wxCoupon));


Loading…
Откажи
Сачувај