Commit 4c299850 by YG8999

Merge remote-tracking branch 'origin/main'

parents 9520f7e5 fd872aff
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.SConsumptionRecords;
@Data
public class SConsumptionRecordsVo extends SConsumptionRecords {
private String orderNo;
private String nickName;
private String phone;
}
package share.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.BeanUtils;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.domain.SConsumer;
import share.system.domain.SOrder;
import share.system.domain.vo.SConsumptionRecordsVo;
import share.system.mapper.SConsumerMapper;
import share.system.mapper.SConsumptionRecordsMapper;
import share.system.domain.SConsumptionRecords;
import share.system.mapper.SOrderMapper;
import share.system.service.ISConsumptionRecordsService;
import share.system.service.SConsumerService;
/**
* 消费记录Service业务层处理
......@@ -20,6 +30,12 @@ public class SConsumptionRecordsServiceImpl implements ISConsumptionRecordsServi
@Autowired
private SConsumptionRecordsMapper sConsumptionRecordsMapper;
@Autowired
private SConsumerMapper sConsumerMapper;
@Autowired
private SOrderMapper sOrderMapper;
/**
* 查询消费记录
*
......@@ -41,7 +57,29 @@ public class SConsumptionRecordsServiceImpl implements ISConsumptionRecordsServi
@Override
public List<SConsumptionRecords> selectSConsumptionRecordsList(SConsumptionRecords sConsumptionRecords)
{
return sConsumptionRecordsMapper.selectSConsumptionRecordsList(sConsumptionRecords);
List<SConsumptionRecords> sConsumptionRecordsList = sConsumptionRecordsMapper.selectSConsumptionRecordsList(sConsumptionRecords);
//获取消费记录的用户id集合
List<Long> collect = sConsumptionRecordsList.stream().map(SConsumptionRecords::getConsumerId).collect(Collectors.toList());
//获取用户id集合的用户信息
List<SConsumer> sConsumers = sConsumerMapper.selectBatchIds(collect);
List<Long> oredrIds = sConsumptionRecordsList.stream().map(SConsumptionRecords::getOrderId).collect(Collectors.toList());
List<SOrder> sOrders = sOrderMapper.selectBatchIds(oredrIds);
List<SConsumptionRecordsVo> sConsumptionRecordsVoList = new ArrayList<>();
BeanUtils.copyProperties(sConsumptionRecordsList, sConsumptionRecordsVoList);
sConsumptionRecordsVoList.stream().forEach(item -> {
sConsumers.stream().forEach(vo -> {
if (item.getConsumerId().equals(vo.getId())) {
item.setNickName(vo.getNickName());
item.setPhone(vo.getPhone());
}
});
sOrders.stream().forEach(vo -> {
if (item.getOrderId().equals(vo.getId())) {
item.setOrderNo(vo.getOrderNo());
}
});
});
return sConsumptionRecordsList;
}
/**
......
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