过滤 已参团的

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

@@ -57,11 +57,11 @@ public class UGbOrderController {
}
/**
* 拼团订单详情
* 拼团商品详情
*/
@GetMapping("/ware/detail")
public CzgResult<GbWareVO> getWareDetail(@RequestParam Long shopId, @RequestParam Long wareId) {
return CzgResult.success(orderService.getWareDetail(shopId, wareId));
return CzgResult.success(orderService.getWareDetail(shopId, wareId, StpKit.USER.getLoginIdAsLong()));
}

View File

@@ -79,7 +79,7 @@ public class GbWare implements Serializable {
private BigDecimal groupPrice;
/**
* 拼团库存
* 拼团累计数
*/
private Integer groupedNum;

View File

@@ -25,4 +25,7 @@ public interface GbWareService extends IService<GbWare> {
//删除 下架状态可删除
boolean deleteGbWare(Long id);
// 累计拼团数+1
void upGbWareGroupedNum(Long id);
}

View File

@@ -29,7 +29,7 @@ public interface GbOrderService extends IService<GbOrder> {
GbOrderDetailVO getGoodsRecordDetail(Long shopId, Long detailId);
//商品详情
GbWareVO getWareDetail(Long shopId, Long wareId);
GbWareVO getWareDetail(Long shopId, Long wareId, Long userId);
//成团/参团 支付
CzgResult<Map<String, Object>> groupJoin(GroupJoinDTO param);

View File

@@ -78,6 +78,16 @@ public class GbWareServiceImpl extends ServiceImpl<GbWareMapper, GbWare> impleme
return remove(query().eq(GbWare::getId, id).eq(GbWare::getShopId, StpKit.USER.getShopId()));
}
@Override
public void upGbWareGroupedNum(Long id) {
GbWare ware = getById(id);
if (ware != null) {
GbWare upWare = new GbWare();
upWare.setGroupedNum(ware.getGroupedNum() == null ? 1 : ware.getGroupedNum() + 1);
update(upWare, query().eq(GbWare::getId, id));
}
}
private void checkStatus(Long id) {
GbWare ware = getById(id);
AssertUtil.isNotEqual(ware.getOnlineStatus(), 0, "操作失败,请下架后,重试");

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())