Commit b53f572c by 吕明尚

更改查询接口

parent b249c833
package share.web.controller.system;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
......@@ -7,6 +8,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
......@@ -21,10 +23,12 @@ import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.common.enums.RoomType;
import share.common.enums.StoreType;
import share.system.domain.SConsumer;
import share.system.domain.SConsumerCoupon;
import share.system.service.ISConsumerCouponService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
import share.system.service.SConsumerService;
/**
* 优惠券领取记录Controller
......@@ -39,6 +43,9 @@ public class SConsumerCouponController extends BaseController
@Autowired
private ISConsumerCouponService sConsumerCouponService;
@Autowired
private SConsumerService sConsumerService;
/**
* 查询优惠券领取记录列表
*/
......@@ -47,8 +54,25 @@ public class SConsumerCouponController extends BaseController
public TableDataInfo list(SConsumerCoupon sConsumerCoupon)
{
startPage();
List<SConsumerCoupon> list = sConsumerCouponService.selectSConsumerCouponList(sConsumerCoupon);
return getDataTable(list);
List<SConsumer> list = sConsumerService.list();
if (share.common.utils.StringUtils.isNotBlank(sConsumerCoupon.getPhone())) {
SConsumer sConsumer = list.stream().filter(obj -> obj.getPhone().equals(sConsumerCoupon.getPhone())).findFirst().orElse(null);
if (!ObjectUtils.isEmpty(sConsumer)) {
sConsumerCoupon.setConsumerId(sConsumer.getId());
} else {
return getDataTable(new ArrayList<>());
}
}
if (share.common.utils.StringUtils.isNotBlank(sConsumerCoupon.getNickName())) {
SConsumer sConsumer = list.stream().filter(obj -> share.common.utils.StringUtils.isNotBlank(obj.getNickName()) && obj.getNickName().equals(sConsumerCoupon.getNickName())).findFirst().orElse(null);
if (!ObjectUtils.isEmpty(sConsumer)) {
sConsumerCoupon.setConsumerId(sConsumer.getId());
} else {
return getDataTable(new ArrayList<>());
}
}
List<SConsumerCoupon> sConsumerCoupons = sConsumerCouponService.selectSConsumerCouponList(sConsumerCoupon);
return getDataTable(sConsumerCoupons);
}
......
......@@ -48,6 +48,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
@Autowired
private SConsumerService sConsumerService;
private static final Integer ZERO = 0;
/**
......@@ -69,23 +70,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
*/
@Override
public List<SConsumerCoupon> selectSConsumerCouponList(SConsumerCoupon sConsumerCoupon) {
List<SConsumer> list = sConsumerService.list();
if (StringUtils.isNotBlank(sConsumerCoupon.getPhone())) {
SConsumer sConsumer = list.stream().filter(obj -> obj.getPhone().equals(sConsumerCoupon.getPhone())).findFirst().orElse(null);
if (!ObjectUtils.isEmpty(sConsumer)) {
sConsumerCoupon.setConsumerId(sConsumer.getId());
} else {
return new ArrayList<>();
}
}
if (StringUtils.isNotBlank(sConsumerCoupon.getNickName())) {
SConsumer sConsumer = list.stream().filter(obj -> StringUtils.isNotBlank(obj.getNickName()) && obj.getNickName().equals(sConsumerCoupon.getNickName())).findFirst().orElse(null);
if (!ObjectUtils.isEmpty(sConsumer)) {
sConsumerCoupon.setConsumerId(sConsumer.getId());
} else {
return new ArrayList<>();
}
}
List<SConsumerCoupon> sConsumerCoupons = baseMapper.selectSConsumerCouponList(sConsumerCoupon);
sConsumerCoupons.forEach(item -> {
if (item.getUseStatus().equals(UserStatusEnum.UNUSED.getCode())) {
......@@ -94,6 +79,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
baseMapper.updateSConsumerCoupon(item);
}
}
List<SConsumer> list = sConsumerService.list();
if (list.stream().filter(obj -> obj.getId().equals(item.getConsumerId())).findFirst().isPresent()) {
item.setPhone(list.stream().filter(obj -> obj.getId().equals(item.getConsumerId())).findFirst().get().getPhone());
if (StringUtils.isNotBlank(list.stream().filter(obj -> obj.getId().equals(item.getConsumerId())).findFirst().get().getNickName())) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment