Просмотр исходного кода

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

release_toaliyun_real
masterspirit 7 лет назад
Родитель
Сommit
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.ApiOperation;

import java.util.List;


@RestController
@@ -51,6 +52,23 @@ public class WxCouponChannelController extends BaseController
@PostMapping("update")
public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) {
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);
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
public class WxCouponServiceImpl implements WxCouponService {
@Autowired
@Autowired
WxCouponMapper wxCouponMapper;
@Autowired
@Autowired
WxCouponChannelService wxCouponChannelService;

@Autowired
@Autowired
WxCouponSendService wxCouponSendService;


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


Загрузка…
Отмена
Сохранить