diff --git a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java index 8fc0cb347..2dcf012fe 100644 --- a/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java +++ b/mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java @@ -75,9 +75,10 @@ public class WxCouponChannelController extends BaseController @PostMapping("/addbatch") public ResultData findById(@RequestBody WxCouponChannelDto wxCouponChannelDto) { String[] ids = wxCouponChannelDto.getCouponIds().split(","); + String[] channelId = wxCouponChannelDto.getChannelId().split(","); List list = new ArrayList<>(); MallUserInfo user = getUser(); - wxCouponChannelService.addBatch(ids,wxCouponChannelDto.getChannelId(),user.getTenantId()); + wxCouponChannelService.addBatch(ids,channelId,user.getTenantId()); return new ResultData(); } diff --git a/mallinkService/src/main/java/com/simple/domain/dto/WxCouponChannelDto.java b/mallinkService/src/main/java/com/simple/domain/dto/WxCouponChannelDto.java index 544dfc0a9..99d4452de 100644 --- a/mallinkService/src/main/java/com/simple/domain/dto/WxCouponChannelDto.java +++ b/mallinkService/src/main/java/com/simple/domain/dto/WxCouponChannelDto.java @@ -7,15 +7,15 @@ public class WxCouponChannelDto implements Serializable { private static final long serialVersionUID = 1L; private Long couponId; private String couponIds; - private Integer channelId; + private String channelId; - public Integer getChannelId() { + public String getChannelId() { return channelId; } - public void setChannelId(Integer channelId) { + public void setChannelId(String channelId) { this.channelId = channelId; } diff --git a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java index 115a719bf..66db5d5ba 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java @@ -38,7 +38,7 @@ public interface WxCouponChannelService { */ void deleteById(Long id); - void addBatch(String[] ids,Integer channelId,String tanantId); + void addBatch(String[] ids,String[] channelId,String tanantId); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java index 5b43e0ee5..3f7b22749 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java @@ -11,6 +11,7 @@ import com.simple.service.WxCouponService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.simple.common.IdWorker; +import org.springframework.transaction.annotation.Transactional; @Service public class WxCouponChannelServiceImpl implements WxCouponChannelService { @@ -49,29 +50,31 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService { } @Override - public void addBatch(String[] ids,Integer channelId,String tanantId) { - for (String couponidstr:ids) { - Long couponid = Long.parseLong(couponidstr); - addCuponChannel(couponid,channelId,tanantId); + @Transactional + public void addBatch(String[] ids,String[] channelId,String tanantId) { + + for (String targetIdstr:channelId) { + Integer targetId = Integer.parseInt(targetIdstr); + for (String couponidstr:ids) { + Long couponid = Long.parseLong(couponidstr); + addCuponChannel(couponid,targetId,tanantId); + } } - } - private void addCuponChannel(Long couponid,Integer channelId,String tanantId){ + } + public void addCuponChannel(Long couponid,Integer channelId,String tanantId){ WxCoupon wxCouponUP = new WxCoupon(); wxCouponUP.setId(couponid); wxCouponUP.setStatus(1); wxCouponService.saveOrUpdate(wxCouponUP); - WxCouponChannel wxCouponChannel = new WxCouponChannel(); wxCouponChannel.setCouponId(couponid); wxCouponChannel.setCouponStatus(1); wxCouponChannel.setTargetAd(channelId); wxCouponChannel.setTenantId(tanantId); saveOrUpdate(wxCouponChannel); - - }