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

[卡券投放][修改]:标记是否成功

release_toaliyun_real
masterspirit 7 лет назад
Родитель
Сommit
489154fdd2
3 измененных файлов: 22 добавлений и 10 удалений
  1. +1
    -2
      mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java
  2. +2
    -1
      mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java
  3. +19
    -7
      mallinkService/src/main/java/com/simple/service/impl/WxCouponChannelServiceImpl.java

+ 1
- 2
mallinkAdmin/src/main/java/com/simple/controller/WxCouponChannelController.java Просмотреть файл

@@ -76,8 +76,7 @@ public class WxCouponChannelController extends BaseController
String[] ids = wxCouponChannelDto.getCouponIds().split(",");
String[] channelId = wxCouponChannelDto.getChannelId().split(",");
MallUserInfo user = getUser();
wxCouponChannelService.addBatch(ids,channelId,user.getTenantId(),wxCouponChannelDto.getBeginTime(),wxCouponChannelDto.getEndTime());
return new ResultData();
return wxCouponChannelService.addBatch(ids,channelId,user.getTenantId(),wxCouponChannelDto.getBeginTime(),wxCouponChannelDto.getEndTime());
}



+ 2
- 1
mallinkService/src/main/java/com/simple/service/WxCouponChannelService.java Просмотреть файл

@@ -1,6 +1,7 @@
package com.simple.service;

import com.github.pagehelper.PageInfo;
import com.simple.common.ResultData;
import com.simple.domain.po.WxCouponChannel;
import com.simple.domain.vo.WxCouponChannelVo;

@@ -42,7 +43,7 @@ public interface WxCouponChannelService {
*/
void deleteById(Long id);

void addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime,Date endTime);
ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime);

void updateStatusByCouponId(Long couponId,String tenantId,int status);


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

@@ -5,6 +5,8 @@ import java.util.stream.Collectors;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.simple.common.Result;
import com.simple.common.ResultData;
import com.simple.domain.po.WxCoupon;
import com.simple.domain.po.WxCouponChannel;
import com.simple.domain.vo.WxCouponChannelVo;
@@ -62,14 +64,23 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
}

@Override
public void addBatch(String[] ids,String[] channelId,String tanantId,Date beginTime,Date endTime) {
public ResultData addBatch(String[] ids, String[] channelId, String tanantId, Date beginTime, Date endTime) {
boolean result = false;
for (String targetIdstr:channelId) {
Integer targetId = Integer.parseInt(targetIdstr);
for (String couponidstr:ids) {
Long couponid = Long.parseLong(couponidstr);
addCuponChannel(couponid,targetId,tanantId,beginTime,endTime);
boolean addResult = addCuponChannel(couponid,targetId,tanantId,beginTime,endTime);
if(addResult){
result = true;
}
}
}
if(result) {
return new ResultData();
}else {
return new ResultData(Result.ERROR,"请确认券状态,及有效期");
}


}
@@ -82,8 +93,8 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
wxCouponChannel.setCouponId(couponId);
}

@Transactional
public void addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){
public boolean addCuponChannel(Long couponid,Integer channelId,String tanantId,Date beginTime,Date endTime){

WxCouponChannel wxCouponChannelQuery = new WxCouponChannel();
wxCouponChannelQuery.setTenantId(tanantId);
@@ -93,18 +104,18 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
List<WxCouponChannel> wxCouponChannels = wxCouponChannelMapper.findList(wxCouponChannelQuery);
if(wxCouponChannels.size()>0){
logger.debug(couponid+"已经投放过了");
return;
return false;
}

WxCoupon wxCoupon = wxCouponService.getById(couponid);
if(wxCoupon.getStatus()!=0) {
logger.debug(wxCoupon.getId()+"状态不对");
return;
return false;
}

if(wxCoupon.getValidEndDate().before(endTime)){
logger.debug(wxCoupon.getId()+"发放时间不能晚于使用时间");
return;
return false;
}
WxCouponChannel wxCouponChannel = new WxCouponChannel();
wxCouponChannel.setEndTime(endTime);
@@ -119,6 +130,7 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
wxCouponChannel.setBusiness(wxCoupon.getBusiness());
wxCouponChannel.setTitle(wxCoupon.getTitle());
saveOrUpdate(wxCouponChannel);
return true;
}

/**


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