过滤 已参团的

This commit is contained in:
2025-12-17 11:49:07 +08:00
parent 8a7d63911e
commit ec51a38f51
6 changed files with 40 additions and 10 deletions

View File

@@ -49,6 +49,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -108,7 +109,7 @@ public class GbOrderServiceImpl extends ServiceImpl<GbOrderMapper, GbOrder> impl
}
@Override
public GbWareVO getWareDetail(Long shopId, Long wareId) {
public GbWareVO getWareDetail(Long shopId, Long wareId, Long userId) {
GbWareVO ware = wareService.getOneAs(query().eq(GbWare::getId, wareId), GbWareVO.class);
AssertUtil.isNull(ware, "商品不存在");
if (ware.getIsDel() || ware.getOnlineStatus() == 0) {
@@ -119,18 +120,32 @@ public class GbOrderServiceImpl extends ServiceImpl<GbOrderMapper, GbOrder> impl
ware.setShopName(shopInfo.getShopName());
ware.setShopAddress(shopInfo.getAddress());
}
List<GbWareOrderVO> orderIngResult = new ArrayList<>();
List<GbWareOrderVO> orderIng = listAs(query().eq(GbOrder::getId, wareId)
.eq(GbOrder::getShopId, shopId)
.eq(GbOrder::getStatus, "ing")
.orderBy(GbOrder::getGroupEndTime).desc()
, GbWareOrderVO.class);
orderIng.forEach(ing -> {
for (GbWareOrderVO ing : orderIng) {
QueryWrapper queryWrapper1 = query();
queryWrapper1.eq(GbOrderDetail::getIsDel, 0)
.and(q -> {
q.eq(GbOrderDetail::getStatus, "待成团").or(GbOrderDetail::getStatus).eq("退款中");
});
queryWrapper1.eq(GbOrderDetail::getGroupOrderNo, ing.getGroupOrderNo());
queryWrapper1.eq(GbOrderDetail::getUserId, userId);
boolean exists = detailService.exists(queryWrapper1);
if (exists) {
continue;
}
QueryWrapper queryWrapper = QueryWrapper.create();
queryWrapper.eq(GbOrderDetail::getIsDel, 0)
.and(q -> {
q.eq(GbOrderDetail::getStatus, "待成团").or(GbOrderDetail::getStatus).eq("退款中");
})
.orderBy(GbOrderDetail::getPayTime);
});
queryWrapper.eq(GbOrderDetail::getGroupOrderNo, ing.getGroupOrderNo());
queryWrapper.orderBy(GbOrderDetail::getPayTime).asc();
GbOrderDetail detail = detailService.getOne(queryWrapper);
if (detail != null) {
ShopUser userInfo = shopUserService.getUserInfo(detail.getShopId(), detail.getUserId());
@@ -139,8 +154,9 @@ public class GbOrderServiceImpl extends ServiceImpl<GbOrderMapper, GbOrder> impl
ing.setNickName(userInfo.getNickName());
}
}
});
ware.setGbOrderList(orderIng);
orderIngResult.add(ing);
}
ware.setGbOrderList(orderIngResult);
return ware;
}
@@ -270,6 +286,7 @@ public class GbOrderServiceImpl extends ServiceImpl<GbOrderMapper, GbOrder> impl
order.setGroupEndTime(LocalDateTime.now());
GbOrderDetail upRecord = new GbOrderDetail();
upRecord.setStatus("待核销");
wareService.upGbWareGroupedNum(order.getWareId());
detailService.update(upRecord, query()
.eq(GbOrderDetail::getGroupOrderNo, order.getGroupOrderNo())
.eq(GbOrderDetail::getShopId, order.getShopId())