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

[小程序投放][修改] 返回错误列表

release_toaliyun_real
masterspirit 7 лет назад
committed by Stormeye.Wu
Родитель
Сommit
124555700f
2 измененных файлов: 79 добавлений и 7 удалений
  1. +58
    -0
      mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelAddVo.java
  2. +21
    -7
      mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java

+ 58
- 0
mallinkService/src/main/java/com/simple/domain/vo/WxCouponChannelAddVo.java Просмотреть файл

@@ -0,0 +1,58 @@
package com.simple.domain.vo;

import com.simple.domain.po.WxCoupon;

import java.io.Serializable;
import java.util.Date;

/**
* Created by syf on 2018/9/6.
* 返回投放错误列表使用
*/
public class WxCouponChannelAddVo implements Serializable {
private static final long serialVersionUID = 1L;
private Long couponId;
private String title;
private Integer channelId;
private Date validEndDate;

public WxCouponChannelAddVo toCouponChannnelVo(WxCoupon wxCoupon,Integer channelId){
this.couponId = wxCoupon.getId();
this.title = wxCoupon.getTitle();
this.validEndDate = wxCoupon.getValidEndDate();
return this;
}


public Long getCouponId() {
return couponId;
}

public void setCouponId(Long couponId) {
this.couponId = couponId;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public Integer getChannelId() {
return channelId;
}

public void setChannelId(Integer channelId) {
this.channelId = channelId;
}

public Date getValidEndDate() {
return validEndDate;
}

public void setValidEndDate(Date validEndDate) {
this.validEndDate = validEndDate;
}
}

+ 21
- 7
mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java Просмотреть файл

@@ -10,6 +10,7 @@ import com.simple.common.ResultData;
import com.simple.domain.po.WxCoupon;
import com.simple.domain.po.WxCouponChannel;
import com.simple.domain.po.WxMerchant;
import com.simple.domain.vo.WxCouponChannelAddVo;
import com.simple.domain.vo.WxCouponChannelVo;
import com.simple.mapper.WxCouponChannelMapper;
import com.simple.mapper.WxMerchantMapper;
@@ -70,20 +71,21 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
@Override
public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) {
boolean result = false;
List<WxCouponChannelAddVo> errorList = new ArrayList<>();
for (String targetIdstr:channelId) {
Integer targetId = Integer.parseInt(targetIdstr);
for (String couponidstr:ids) {
Long couponid = Long.parseLong(couponidstr);
boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime);
boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime,errorList);
if(addResult){
result = true;
}
}
}
if(result) {
return new ResultData();
return new ResultData(errorList);
}else {
return new ResultData(Result.ERROR,"请检查券的有效期以及投放截止时间");
return new ResultData(Result.ERROR,"请检查券的有效期以及投放截止时间",errorList);
}


@@ -95,10 +97,11 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
wxCouponChannel.setTenantId(tenantId);
wxCouponChannel.setStatus(status);
wxCouponChannel.setCouponId(couponId);
wxCouponChannelMapper.updateStatusByCouponId(wxCouponChannel);
}


public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){
public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime,List<WxCouponChannelAddVo> errorList){

WxCouponChannel wxCouponChannelQuery = new WxCouponChannel();
wxCouponChannelQuery.setTenantId(tanantId);
@@ -121,10 +124,21 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
return false;
}

if(wxCoupon.getValidEndDate()!=null&&wxCoupon.getValidEndDate().before(endTime)){
logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间");
return false;
if(channelId==1){ //列表默认投放结束时间为有效时间之后
beginTime = new Date();
endTime = wxCoupon.getValidEndDate();
}

if(channelId==2){
if(wxCoupon.getValidEndDate()!=null&&wxCoupon.getValidEndDate().before(endTime)){
logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间");
WxCouponChannelAddVo vo = new WxCouponChannelAddVo();
errorList.add(vo.toCouponChannnelVo(wxCoupon,channelId));
return false;
}
}


WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.setEndTime(endTime);
wxCouponChannel.setStatus(0);


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