Commit 2feb3817 by 吕明尚

优化订单查询接口

parent 8187d59e
......@@ -43,7 +43,10 @@ public class SOrderController extends BaseController
@GetMapping("/list")
public TableDataInfoVo list(SOrder sOrder)
{
return sOrderService.pageList(sOrder);
startPage();
List<SOrder> list = sOrderService.selectSOrderList(sOrder);
TableDataInfo dataTable = getDataTable(list);
return sOrderService.pageList(dataTable, sOrder);
}
@GetMapping("/queryList")
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value=" /Users/liwenjun/logs/share" />
<property name="log.path" value="/var/gxpt/logs/admin"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
......@@ -27,7 +27,7 @@
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<level>DEBUG</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/home/gxpt/logs" />
<property name="log.path" value="/var/gxpt/logs/front"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
......@@ -27,7 +27,7 @@
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<level>DEBUG</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
......
......@@ -73,4 +73,6 @@ public interface SConsumerCouponMapper extends BaseMapper<SConsumerCoupon>
List<SConsumerCoupon> queryList();
int removeByIdList(@Param("couponIds") List<Long> expiredCoupons);
SConsumerCoupon sumPayPrice(@Param("couponIds") List<Long> ids);
}
......@@ -3,6 +3,7 @@ package share.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SOrder;
import java.util.HashMap;
import java.util.List;
/**
......@@ -70,4 +71,8 @@ public interface SOrderMapper extends BaseMapper<SOrder>
List<SOrder> selectSOrderByMaxTime(SOrder order);
List<SOrder> selectSOrderByStoreIdAndMaxTime(SOrder order);
HashMap<String, Object> sumPrice(SOrder sOrder);
List<Long> couponIds(SOrder sOrder);
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SPack;
import java.util.List;
/**
* 套餐Service接口
*
......@@ -65,4 +65,6 @@ public interface IPackService extends IService<SPack> {
Long addPack(SPack sPack);
List<SPack> pageList(SPack sPack);
List<SPack> packNameByIds(List<Long> longs);
}
......@@ -89,4 +89,8 @@ public interface ISConsumerCouponService extends IService<SConsumerCoupon>
int removeByIdList(List<Long> expiredCoupons);
SConsumerCoupon selectSConsumerCouponByCode(String code);
SConsumerCoupon sumPayPrice(List<Long> couponIds);
List<SConsumerCoupon> couponNameByIds(List<Long> longs);
}
......@@ -194,7 +194,7 @@ public interface ISOrderService extends IService<SOrder>
int modifyOrder(SOrderDto sOrderDto);
TableDataInfoVo pageList(SOrder sOrder);
TableDataInfoVo pageList(TableDataInfo dataTable, SOrder sOrder);
/**
* 订单退款(人工退款)
......
......@@ -108,4 +108,6 @@ public interface ISRoomService extends IService<SRoom>
List<SRoom> selectByStoreIds(List<Long> storeIds);
List<SRoomVo> convertDoListToVoList(List<SRoom> roomList);
List<SRoom> roomNameByIds(List<Long> longs);
}
......@@ -112,4 +112,6 @@ public interface ISStoreService extends IService<SStore>
int updateStoreConsumers(SStoreConsumerVo storeConsumer);
SConsumerVo queryBySStoreConsumer(SStoreConsumerVo dto);
List<SStore> storeNameByIds(List<Long> longs);
}
package share.system.service.impl;
import java.util.*;
import java.util.Arrays;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
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.mapper.PackMapper;
import share.system.domain.SPack;
import share.system.mapper.PackMapper;
import share.system.service.IPackService;
import share.system.service.ISOrderService;
import share.system.service.SConsumerService;
import java.util.*;
import java.util.stream.Collectors;
/**
* 套餐Service业务层处理
*
......@@ -158,4 +157,14 @@ public class PackServiceImpl extends ServiceImpl<PackMapper, SPack> implements I
public List<SPack> pageList(SPack sPack) {
return baseMapper.selectPackList(sPack);
}
@Override
public List<SPack> packNameByIds(List<Long> longs) {
LambdaQueryWrapper<SPack> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(SPack::getId, SPack::getName);
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(longs)) {
queryWrapper.in(SPack::getId, longs);
}
return this.list(queryWrapper);
}
}
......@@ -574,6 +574,22 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
return baseMapper.selectOne(new LambdaQueryWrapper<>(SConsumerCoupon.class).eq(SConsumerCoupon::getCouponCode, code));
}
@Override
public SConsumerCoupon sumPayPrice(List<Long> couponIds) {
return baseMapper.sumPayPrice(couponIds);
}
@Override
public List<SConsumerCoupon> couponNameByIds(List<Long> longs) {
LambdaQueryWrapper<SConsumerCoupon> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(SConsumerCoupon::getId, SConsumerCoupon::getName, SConsumerCoupon::getCouponPayPrice,
SConsumerCoupon::getPlatformType, SConsumerCoupon::getDealgroupId, SConsumerCoupon::getTiktokSkuId);
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(longs)) {
queryWrapper.in(SConsumerCoupon::getId, longs);
}
return this.list(queryWrapper);
}
private void extracted(SConsumerCoupon item, BigDecimal bigDecimal, SRoom byId, BigDecimal subtract, SStore sStore) {
//计算价格
BigDecimal multiply = bigDecimal.multiply(byId.getPrice());
......
......@@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import share.common.constant.Constants;
import share.common.constant.HttpStatus;
import share.common.core.page.PageDomain;
import share.common.core.page.TableDataInfo;
import share.common.core.page.TableSupport;
......@@ -47,6 +48,7 @@ import share.system.service.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -309,60 +311,49 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return baseMapper.updateSOrder(sOrder);
}
@Override
public TableDataInfoVo pageList(SOrder sOrder) {
List<SOrder> sOrders = selectSOrderList(sOrder);
List<SOrderVo> sOrderVos = convertDosToVos(sOrders);
BigDecimal totalAmount = new BigDecimal("0.00");
BigDecimal amount = new BigDecimal("0.00");
//优惠卷售卖总金额
final BigDecimal[] totalSalesAmount = {new BigDecimal("0.00")};
//申请退款总金额
BigDecimal totalRefundAmount = new BigDecimal("0.00");
//实际退款总金额
BigDecimal totalRealRefundAmount = new BigDecimal("0.00");
List<SConsumerCoupon> sConsumerCoupons = consumerCouponService.queryList();
public TableDataInfoVo pageList(TableDataInfo dataTable, SOrder sOrder) {
List<SOrder> list = (List<SOrder>) dataTable.getRows();
TableDataInfoVo tableDataInfo = new TableDataInfoVo();
tableDataInfo.setCode(HttpStatus.SUCCESS);
tableDataInfo.setMsg("查询成功");
tableDataInfo.setTotal(dataTable.getTotal());
List<SOrderVo> sOrderVos = convertDosToVos(list);
HashMap<String, Object> summedPrice = baseMapper.sumPrice(sOrder);
Map<Long, SConsumerCoupon> couponMap = consumerCouponService.listByIds(sOrderVos.stream().map(SOrderVo::getCouponId).collect(Collectors.toList()))
.stream().collect(Collectors.toMap(SConsumerCoupon::getId, s -> s));
List<Long> couponIds = couponIds(sOrder);
SConsumerCoupon sConsumerCoupon = consumerCouponService.sumPayPrice(couponIds);
if (CollectionUtils.isNotEmpty(sOrderVos)) {
for (SOrderVo item : sOrderVos) {
totalAmount = totalAmount.add(item.getTotalPrice());
amount = amount.add(item.getPayPrice());
sConsumerCoupons.stream().filter(sConsumerCoupon -> sConsumerCoupon.getId().equals(item.getCouponId())).findFirst().ifPresent(sConsumerCoupon -> {
item.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
item.setPlatformType(sConsumerCoupon.getPlatformType());
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
item.setCouponSkuId(String.valueOf(sConsumerCoupon.getDealgroupId()));
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
item.setCouponSkuId(String.valueOf(sConsumerCoupon.getTiktokSkuId()));
sOrderVos.stream().forEach(item -> {
if (Objects.nonNull(item.getCouponId())) {
SConsumerCoupon userCoupon = couponMap.get(item.getCouponId());
if (userCoupon != null) {
item.setCouponPayPrice(userCoupon.getCouponPayPrice());
item.setPlatformType(userCoupon.getPlatformType());
if (userCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
item.setCouponSkuId(String.valueOf(userCoupon.getDealgroupId()));
} else if (userCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
item.setCouponSkuId(String.valueOf(userCoupon.getTiktokSkuId()));
}
}
totalSalesAmount[0] = totalSalesAmount[0].add(ObjectUtil.isEmpty(sConsumerCoupon.getCouponPayPrice()) ? new BigDecimal("0.00") : sConsumerCoupon.getCouponPayPrice());
});
if (item.getPayStatus().equals(YesNoEnum.yes.getIndex()) && item.getRefundStatus().equals(RefundStatusEnum.REFUNDED.getCode())) {
totalRefundAmount = totalRefundAmount.add(ObjectUtil.isEmpty(item.getPayPrice()) ? new BigDecimal("0.00") : item.getPayPrice());
totalRealRefundAmount = totalRealRefundAmount.add(ObjectUtil.isEmpty(item.getRefundPrice()) ? new BigDecimal("0.00") : item.getRefundPrice());
}
}
});
}
sOrderVos.sort(Comparator.comparing(SOrderVo::getCreateTime).reversed());
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
int start = (pageNum - 1) * pageSize;
int end = Math.min(start + pageSize, sOrderVos.size());
List<SOrderVo> pagedList = sOrderVos.subList(start, end);
TableDataInfoVo tableDataInfo = new TableDataInfoVo();
tableDataInfo.setRows(pagedList);
tableDataInfo.setTotal(sOrderVos.size());
tableDataInfo.setCode(200);
tableDataInfo.setMsg("查询成功");
tableDataInfo.setTotalAmount(totalAmount);
tableDataInfo.setAmount(amount);
tableDataInfo.setTotalSalesAmount(totalSalesAmount[0]);
tableDataInfo.setTotalRefundAmount(totalRefundAmount);
tableDataInfo.setTotalRealRefundAmount(totalRealRefundAmount);
tableDataInfo.setRows(sOrderVos);
tableDataInfo.setTotalAmount((BigDecimal) summedPrice.get("totalPrice"));
tableDataInfo.setAmount((BigDecimal) summedPrice.get("payPrice"));
tableDataInfo.setTotalSalesAmount(sConsumerCoupon.getCouponPayPrice());
tableDataInfo.setTotalRefundAmount((BigDecimal) summedPrice.get("totalRealRefundAmount"));
tableDataInfo.setTotalRealRefundAmount((BigDecimal) summedPrice.get("refundPrice"));
return tableDataInfo;
}
private List<Long> couponIds(SOrder sOrder) {
return baseMapper.couponIds(sOrder);
}
/**
* 订单退款(管理系统人工退款)
* @param request 请求参数
......@@ -680,36 +671,41 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
List<SOrder> sOrders = selectSOrderList(sOrder);
List<SOrderVo> sOrderVos = convertDosToVos(sOrders);
List<SaobeiApiLog> saobeiApiLogs = saobeiApiLogService.list();
//list转HashMap
List<SConsumerCoupon> sConsumerCoupons = consumerCouponService.queryList();
Map<Long, SConsumerCoupon> map = sConsumerCoupons.stream().collect(Collectors.toMap(SConsumerCoupon::getId, Function.identity()));
List<SCoupon> list = sCouponService.list();
Map<Long, SCoupon> sCouponMap = list.stream().collect(Collectors.toMap(SCoupon::getId, Function.identity()));
if (CollectionUtils.isNotEmpty(sOrderVos)) {
for (SOrderVo item : sOrderVos) {
sConsumerCoupons.stream().filter(sConsumerCoupon -> sConsumerCoupon.getId().equals(item.getCouponId())).findFirst().ifPresent(sConsumerCoupon -> {
item.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
item.setPlatformType(sConsumerCoupon.getPlatformType());
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getDealgroupId())) {
item.setCouponSkuId(String.valueOf(sConsumerCoupon.getDealgroupId()));
} else {
list.stream().filter(sCoupon -> sCoupon.getId().equals(sConsumerCoupon.getCouponId())).findFirst().ifPresent(sConsumer -> {
item.setCouponSkuId(String.valueOf(sConsumer.getDealgroupId()));
});
}
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getTiktokSkuId())) {
item.setCouponSkuId(sConsumerCoupon.getTiktokSkuId());
} else {
list.stream().filter(sCoupon -> sCoupon.getId().equals(sConsumerCoupon.getCouponId())).findFirst().ifPresent(sConsumer -> {
item.setCouponSkuId(sConsumer.getTiktokSkuId());
});
sOrderVos.stream().forEach(item -> {
if (ObjectUtil.isNotEmpty(item.getCouponId())) {
SConsumerCoupon sConsumerCoupon = map.get(item.getCouponId());
if (ObjectUtil.isNotEmpty(sConsumerCoupon)) {
item.setCouponPayPrice(sConsumerCoupon.getCouponPayPrice());
item.setPlatformType(sConsumerCoupon.getPlatformType());
if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.MEITUAN.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getDealgroupId())) {
item.setCouponSkuId(String.valueOf(sConsumerCoupon.getDealgroupId()));
} else {
item.setCouponSkuId(String.valueOf(sCouponMap.get(sConsumerCoupon.getCouponId()).getDealgroupId()));
}
} else if (sConsumerCoupon.getPlatformType().equals(PlatformTypeEnum.TIKTOK.getCode())) {
if (!ObjectUtils.isEmpty(sConsumerCoupon.getTiktokSkuId())) {
item.setCouponSkuId(sConsumerCoupon.getTiktokSkuId());
} else {
item.setCouponSkuId(sCouponMap.get(sConsumerCoupon.getCouponId()).getTiktokSkuId());
}
}
}
});
}
if (StringUtils.isNoneEmpty(item.getOutTradeNo())) {
item.setOutTradeNo(saobeiApiLogs.stream().filter(s -> s.getTerminalTrace().equals(item.getOutTradeNo())).findFirst().orElse(null).getOutTradeNo());
item.setOutTradeNo(
// saobeiApiLogMap.get(item.getOutTradeNo()).getOutTradeNo()
saobeiApiLogs.stream().filter(saobeiApiLog ->
saobeiApiLog.getTerminalTrace().equals(item.getOutTradeNo())).findFirst().orElse(null).getOutTradeNo()
);
}
}
});
}
sOrderVos.sort(Comparator.comparing(SOrderVo::getCreateTime).reversed());
return sOrderVos;
......@@ -1599,51 +1595,83 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
private List<SOrderVo> convertDosToVos(List<SOrder> orderList) {
List<SOrderVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(orderList)) {
// 使用Map缓存查询结果,减少重复查询
Map<Long, SStore> storeMap = storeService.listByIds(orderList.stream().map(SOrder::getStoreId).collect(Collectors.toSet()))
.stream().collect(Collectors.toMap(SStore::getId, s -> s));
Map<Long, SRoom> roomMap = roomService.listByIds(orderList.stream().map(SOrder::getRoomId).collect(Collectors.toSet()))
.stream().collect(Collectors.toMap(SRoom::getId, s -> s));
Map<Long, SConsumerCoupon> couponMap = consumerCouponService.queryByIds(orderList.stream().map(SOrder::getCouponId).distinct().collect(Collectors.toList()))
.stream().collect(Collectors.toMap(SConsumerCoupon::getId, s -> s));
Map<Long, SPack> packMap = packService.listByIds(orderList.stream().map(SOrder::getPackId).distinct().collect(Collectors.toList()))
.stream().collect(Collectors.toMap(SPack::getId, s -> s));
orderList.forEach(o -> {
SOrderVo vo = new SOrderVo();
BeanUtils.copyProperties(o, vo);
SStore store = storeMap.get(vo.getStoreId());
if (store != null) {
vo.setStoreName(store.getName());
vo.setAddress(store.getAddress());
try {
// 使用Map缓存查询结果,减少重复查询
// 合并查询逻辑以减少N+1查询问题
Set<Long> storeIds = orderList.stream().map(SOrder::getStoreId).collect(Collectors.toSet());
Set<Long> roomIds = orderList.stream().map(SOrder::getRoomId).distinct().collect(Collectors.toSet());
Set<Long> couponIds = orderList.stream().map(SOrder::getCouponId).distinct().collect(Collectors.toSet());
Set<Long> packIds = orderList.stream().map(SOrder::getPackId).distinct().collect(Collectors.toSet());
Map<Long, SStore> storeMap;
if (!storeIds.isEmpty()) {
List<SStore> stores = storeService.storeNameByIds(new ArrayList<>(storeIds));
storeMap = stores.stream().collect(Collectors.toMap(SStore::getId, s -> s));
} else {
storeMap = new HashMap<>();
}
SRoom room = roomMap.get(vo.getRoomId());
if (room != null) {
vo.setRoomName(room.getName());
vo.setRoomImages(room.getImages());
vo.setRoomType(room.getRoomType());
vo.setRoomTypeName(RoomType.getNameByCode(room.getRoomType()));
Map<Long, SRoom> roomMap;
if (!roomIds.isEmpty()) {
List<SRoom> rooms = roomService.roomNameByIds(new ArrayList<>(roomIds));
roomMap = rooms.stream().collect(Collectors.toMap(SRoom::getId, s -> s));
} else {
roomMap = new HashMap<>();
}
if (Objects.nonNull(vo.getCouponId())) {
SConsumerCoupon userCoupon = couponMap.get(vo.getCouponId());
if (userCoupon != null) {
// 判断是否可以退款
vo.setIsRefund(isRefund(vo, userCoupon));
vo.setCouponName(userCoupon.getName());
} else {
// 如果优惠券为空,则调用isRefund方法时需要传入null
vo.setIsRefund(isRefund(vo, null));
}
Map<Long, SConsumerCoupon> couponMap;
if (!couponIds.isEmpty()) {
List<SConsumerCoupon> coupons = consumerCouponService.couponNameByIds(new ArrayList<>(couponIds));
couponMap = coupons.stream().collect(Collectors.toMap(SConsumerCoupon::getId, s -> s));
} else {
// 判断是否可以退款
vo.setIsRefund(isRefund(vo, null));
couponMap = new HashMap<>();
}
SPack pack = packMap.get(vo.getPackId());
if (pack != null) {
vo.setPackName(pack.getName());
Map<Long, SPack> packMap;
if (!packIds.isEmpty()) {
List<SPack> packs = packService.packNameByIds(new ArrayList<>(packIds));
packMap = packs.stream().collect(Collectors.toMap(SPack::getId, s -> s));
} else {
packMap = new HashMap<>();
}
voList.add(vo);
});
orderList.forEach(o -> {
SOrderVo vo = new SOrderVo();
BeanUtils.copyProperties(o, vo);
SStore store = storeMap.get(vo.getStoreId());
if (store != null) {
vo.setStoreName(store.getName());
vo.setAddress(store.getAddress());
}
SRoom room = roomMap.get(vo.getRoomId());
if (room != null) {
vo.setRoomName(room.getName());
vo.setRoomImages(room.getImages());
vo.setRoomType(room.getRoomType());
vo.setRoomTypeName(RoomType.getNameByCode(room.getRoomType()));
}
if (Objects.nonNull(vo.getCouponId())) {
SConsumerCoupon userCoupon = couponMap.get(vo.getCouponId());
if (userCoupon != null) {
vo.setIsRefund(isRefund(vo, userCoupon));
vo.setCouponName(userCoupon.getName());
} else {
vo.setIsRefund(isRefund(vo, null));
}
} else {
vo.setIsRefund(isRefund(vo, null));
}
SPack pack = packMap.get(vo.getPackId());
if (pack != null) {
vo.setPackName(pack.getName());
}
voList.add(vo);
});
} catch (Exception e) {
// 记录日志并处理异常,例如返回错误信息或执行其他错误处理逻辑
// log.error("订单数据转换异常", e);
throw new RuntimeException("订单数据转换异常", e);
}
}
return voList;
}
......
......@@ -475,4 +475,14 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
return voList;
}
@Override
public List<SRoom> roomNameByIds(List<Long> longs) {
LambdaQueryWrapper<SRoom> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(SRoom::getId, SRoom::getName, SRoom::getImages, SRoom::getRoomType);
if (CollectionUtils.isNotEmpty(longs)) {
queryWrapper.in(SRoom::getId, longs);
}
return this.list(queryWrapper);
}
}
......@@ -366,6 +366,16 @@ public class SStoreServiceImpl extends ServiceImpl<SStoreMapper, SStore> impleme
return storeConsumerMapper.queryBySStoreConsumer(dto);
}
@Override
public List<SStore> storeNameByIds(List<Long> ids) {
LambdaQueryWrapper<SStore> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(SStore::getId, SStore::getName, SStore::getAddress);
if (CollectionUtils.isNotEmpty(ids)) {
queryWrapper.in(SStore::getId, ids);
}
return this.list(queryWrapper);
}
/**
* 门店DO集合转换VO集合,按距离排序
*
......
......@@ -164,6 +164,14 @@
<select id="queryList" resultType="share.system.domain.SConsumerCoupon">
<include refid="selectSConsumerCouponVo"/>
</select>
<select id="sumPayPrice" resultType="share.system.domain.SConsumerCoupon">
select sum(ifnull(coupon_pay_price,0)) AS couponPayPrice
from s_consumer_coupon
where id in
<foreach item="id" collection="couponIds" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<insert id="insertSConsumerCoupon" parameterType="SConsumerCoupon" useGeneratedKeys="true" keyProperty="id">
insert into s_consumer_coupon
......
......@@ -250,6 +250,136 @@
and create_time >= #{createTime}
group by store_id) t on t.id = s.id
</select>
<select id="sumPrice" resultType="java.util.HashMap">
select sum(ifnull(total_price,0)) as totalPrice,
sum(ifnull(pay_price,0)) as payPrice ,
SUM( CASE WHEN
pay_status=1 AND refund_status = 3
THEN ifnull( pay_price,0) ELSE 0 END
) AS totalRealRefundAmount,
SUM( CASE WHEN
pay_status=1 AND refund_status = 3
THEN ifnull(refund_price,0) ELSE 0 END
) AS refundPrice
from s_order
where pay_status = 1
and is_delete = 0
<if test="orderNo != null and orderNo != ''">and order_no = #{orderNo}</if>
<if test="historicalOrderNo != null and historicalOrderNo != ''">and historical_order_no =
#{historicalOrderNo}
</if>
<if test="outTradeNo != null and outTradeNo != ''">and out_trade_no = #{outTradeNo}</if>
<if test="orderType != null and orderType != ''">and order_type = #{orderType}</if>
<if test="payType != null and payType != ''">and pay_type = #{payType}</if>
<!-- <if test="payStatus != null and payStatus != ''">and pay_status = #{payStatus}</if>-->
<if test="storeId != null and storeId != ''">and store_id = #{storeId}</if>
<if test="roomId != null and roomId != ''">and room_id = #{roomId}</if>
<if test="consumerId != null and consumerId != ''">and consumer_id = #{consumerId}</if>
<if test="consumerName != null and consumerName != ''">and consumer_name = #{consumerName}</if>
<if test="consumerPhone != null and consumerPhone != ''">and consumer_phone = #{consumerPhone}</if>
<if test="packId != null and packId != ''">and pack_id = #{packId}</if>
<if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if>
<if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if>
<if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if>
<if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if>
<if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if>
<if test="startPayTime != null">
and DATE_FORMAT(pay_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startPayTime}, '%Y-%m-%d')
</if>
<if test="endPayTime != null">
and DATE_FORMAT(pay_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endPayTime}, '%Y-%m-%d')
</if>
<if test="payTime != null and payTime != ''">and pay_time = #{payTime}</if>
<if test="timeLong != null and timeLong != ''">and time_long = #{timeLong}</if>
<if test="preStartDate != null">
and DATE_FORMAT(pre_start_date, '%Y-%m-%d') &gt;= DATE_FORMAT(#{preStartDate}, '%Y-%m-%d')
</if>
<if test="preEndDate != null">
and DATE_FORMAT(pre_end_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{preEndDate}, '%Y-%m-%d')
</if>
<if test="startDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</if>
<if test="status != null and status != '' or status==0">and status = #{status}</if>
<if test="refundStatus != null and refundStatus != ''">and refund_status = #{refundStatus}</if>
<if test="refundReason != null and refundReason != ''">and refund_reason = #{refundReason}</if>
<if test="refundReasonTime != null">and refund_reason_time =
#{refundReasonTime}
</if>
<if test="refundPrice != null and refundPrice != ''">and refund_price = #{refundPrice}</if>
<if test="isDelete != null and isDelete != ''">and is_delete = #{isDelete}</if>
<if test="createBy != null and createBy != ''">and create_by = #{createBy}</if>
<if test="createTime != null and createTime != ''">and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''">and update_by = #{updateBy}</if>
<if test="updateTime != null and updateTime != ''">and update_time = #{updateTime}</if>
<if test="arrivalTime != null and arrivalTime != ''">and arrival_time = #{arrivalTime}</if>
<if test="remark != null and remark != ''">and remark = #{remark}</if>
</select>
<select id="couponIds" resultType="java.lang.Long">
select consumer_id
from s_order
where pay_status = 1
and is_delete = 0
<if test="orderNo != null and orderNo != ''">and order_no = #{orderNo}</if>
<if test="historicalOrderNo != null and historicalOrderNo != ''">and historical_order_no =
#{historicalOrderNo}
</if>
<if test="outTradeNo != null and outTradeNo != ''">and out_trade_no = #{outTradeNo}</if>
<if test="orderType != null and orderType != ''">and order_type = #{orderType}</if>
<if test="payType != null and payType != ''">and pay_type = #{payType}</if>
<!-- <if test="payStatus != null and payStatus != ''">and pay_status = #{payStatus}</if>-->
<if test="storeId != null and storeId != ''">and store_id = #{storeId}</if>
<if test="roomId != null and roomId != ''">and room_id = #{roomId}</if>
<if test="consumerId != null and consumerId != ''">and consumer_id = #{consumerId}</if>
<if test="consumerName != null and consumerName != ''">and consumer_name = #{consumerName}</if>
<if test="consumerPhone != null and consumerPhone != ''">and consumer_phone = #{consumerPhone}</if>
<if test="packId != null and packId != ''">and pack_id = #{packId}</if>
<if test="packPrice != null and packPrice != ''">and pack_price = #{packPrice}</if>
<if test="couponId != null and couponId != ''">and coupon_id = #{couponId}</if>
<if test="couponPrice != null and couponPrice != ''">and coupon_price = #{couponPrice}</if>
<if test="totalPrice != null and totalPrice != ''">and total_price = #{totalPrice}</if>
<if test="payPrice != null and payPrice != ''">and pay_price = #{payPrice}</if>
<if test="startPayTime != null">
and DATE_FORMAT(pay_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startPayTime}, '%Y-%m-%d')
</if>
<if test="endPayTime != null">
and DATE_FORMAT(pay_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endPayTime}, '%Y-%m-%d')
</if>
<if test="payTime != null and payTime != ''">and pay_time = #{payTime}</if>
<if test="timeLong != null and timeLong != ''">and time_long = #{timeLong}</if>
<if test="preStartDate != null">
and DATE_FORMAT(pre_start_date, '%Y-%m-%d') &gt;= DATE_FORMAT(#{preStartDate}, '%Y-%m-%d')
</if>
<if test="preEndDate != null">
and DATE_FORMAT(pre_end_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{preEndDate}, '%Y-%m-%d')
</if>
<if test="startDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate}, '%Y-%m-%d')
</if>
<if test="endDate != null">
and DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate}, '%Y-%m-%d')
</if>
<if test="status != null and status != '' or status==0">and status = #{status}</if>
<if test="refundStatus != null and refundStatus != ''">and refund_status = #{refundStatus}</if>
<if test="refundReason != null and refundReason != ''">and refund_reason = #{refundReason}</if>
<if test="refundReasonTime != null">and refund_reason_time =
#{refundReasonTime}
</if>
<if test="refundPrice != null and refundPrice != ''">and refund_price = #{refundPrice}</if>
<if test="isDelete != null and isDelete != ''">and is_delete = #{isDelete}</if>
<if test="createBy != null and createBy != ''">and create_by = #{createBy}</if>
<if test="createTime != null and createTime != ''">and create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''">and update_by = #{updateBy}</if>
<if test="updateTime != null and updateTime != ''">and update_time = #{updateTime}</if>
<if test="arrivalTime != null and arrivalTime != ''">and arrival_time = #{arrivalTime}</if>
<if test="remark != null and remark != ''">and remark = #{remark}</if>
</select>
<insert id="insertSOrder" parameterType="SOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_order
......
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