16 changed files with 273 additions and 14 deletions
@ -0,0 +1,106 @@ |
|||||
|
package cc.hiver.mall.controller; |
||||
|
|
||||
|
import cc.hiver.core.common.utils.ResultUtil; |
||||
|
import cc.hiver.core.common.vo.Result; |
||||
|
import cc.hiver.mall.entity.MallOrder; |
||||
|
import cc.hiver.mall.entity.MallOrderGroup; |
||||
|
import cc.hiver.mall.service.mybatis.MallOrderGroupService; |
||||
|
import cc.hiver.mall.service.mybatis.MallOrderService; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import lombok.Data; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.Arrays; |
||||
|
import java.util.List; |
||||
|
|
||||
|
@Slf4j |
||||
|
@RestController |
||||
|
@Api(tags = "后台管理系统拼团数据接口") |
||||
|
@RequestMapping("/hiver/mall/admin/orderGroup") |
||||
|
public class AdminMallOrderGroupController { |
||||
|
|
||||
|
@Autowired |
||||
|
private MallOrderGroupService mallOrderGroupService; |
||||
|
|
||||
|
@Autowired |
||||
|
private MallOrderService mallOrderService; |
||||
|
|
||||
|
@Data |
||||
|
public static class OrderGroupQuery { |
||||
|
private String shopId; |
||||
|
private String headUserId; |
||||
|
private Integer status; |
||||
|
private String productName; |
||||
|
private Integer isFace; |
||||
|
private int pageNumber = 1; |
||||
|
private int pageSize = 10; |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/page") |
||||
|
@ApiOperation(value = "分页查询拼团列表") |
||||
|
public Result<Page<MallOrderGroup>> page(@RequestBody OrderGroupQuery query) { |
||||
|
LambdaQueryWrapper<MallOrderGroup> qw = new LambdaQueryWrapper<>(); |
||||
|
if (StringUtils.isNotBlank(query.getShopId())) { |
||||
|
qw.eq(MallOrderGroup::getShopId, query.getShopId()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(query.getHeadUserId())) { |
||||
|
qw.eq(MallOrderGroup::getHeadUserId, query.getHeadUserId()); |
||||
|
} |
||||
|
if (query.getStatus() != null) { |
||||
|
qw.eq(MallOrderGroup::getStatus, query.getStatus()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(query.getProductName())) { |
||||
|
qw.like(MallOrderGroup::getProductName, query.getProductName()); |
||||
|
} |
||||
|
if (query.getIsFace() != null) { |
||||
|
qw.eq(MallOrderGroup::getIsFace, query.getIsFace()); |
||||
|
} |
||||
|
qw.orderByDesc(MallOrderGroup::getCreateTime); |
||||
|
|
||||
|
Page<MallOrderGroup> page = new Page<>(query.getPageNumber(), query.getPageSize()); |
||||
|
Page<MallOrderGroup> result = mallOrderGroupService.page(page, qw); |
||||
|
return new ResultUtil<Page<MallOrderGroup>>().setData(result); |
||||
|
} |
||||
|
|
||||
|
@Data |
||||
|
public static class OrderGroupDetailVo { |
||||
|
private MallOrderGroup group; |
||||
|
private List<MallOrder> childOrders; |
||||
|
} |
||||
|
|
||||
|
@GetMapping("/detail/{id}") |
||||
|
@ApiOperation(value = "获取拼团详情") |
||||
|
public Result<OrderGroupDetailVo> detail(@PathVariable("id") String id) { |
||||
|
MallOrderGroup group = mallOrderGroupService.getById(id); |
||||
|
if (group == null) { |
||||
|
return ResultUtil.error("拼团不存在"); |
||||
|
} |
||||
|
|
||||
|
OrderGroupDetailVo vo = new OrderGroupDetailVo(); |
||||
|
vo.setGroup(group); |
||||
|
|
||||
|
// 获取拼团的子订单
|
||||
|
if (StringUtils.isNotBlank(group.getGroupOrderIds())) { |
||||
|
List<String> orderIds = Arrays.asList(group.getGroupOrderIds().split(",")); |
||||
|
if (!orderIds.isEmpty()) { |
||||
|
LambdaQueryWrapper<MallOrder> oqw = new LambdaQueryWrapper<>(); |
||||
|
oqw.in(MallOrder::getId, orderIds); |
||||
|
List<MallOrder> childOrders = mallOrderService.list(oqw); |
||||
|
vo.setChildOrders(childOrders); |
||||
|
} else { |
||||
|
vo.setChildOrders(new ArrayList<>()); |
||||
|
} |
||||
|
} else { |
||||
|
vo.setChildOrders(new ArrayList<>()); |
||||
|
} |
||||
|
|
||||
|
return new ResultUtil<OrderGroupDetailVo>().setData(vo); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue