feat(柜机格口): 添加获取格口最新订单信息功能
新增CabinetCellLatestOrderDTO类用于存储格口最新订单信息 在CabinetCellService中新增selectLatestOrderInfoByCell方法查询格口最新订单 修改CabinetCellWithOrderCountDTO添加订单相关字段 优化CabinetCellApplicationService.getCabinetCellList方法合并订单信息
This commit is contained in:
parent
2c7a336ae9
commit
2bf2494383
|
@ -157,8 +157,7 @@ public class QywxMessageJob {
|
||||||
String totag = "";
|
String totag = "";
|
||||||
List<NewsArticle> articles = new ArrayList<>();
|
List<NewsArticle> articles = new ArrayList<>();
|
||||||
NewsArticle article = new NewsArticle();
|
NewsArticle article = new NewsArticle();
|
||||||
article.setTitle("耗材领用申请通知");
|
article.setTitle("逾期未归还通知");
|
||||||
article.setDescription("领用商品:" + record.getGoodsName());
|
|
||||||
article.setDescription("你借用的 【" + record.getGoodsName() + "】 已逾期未归还,请及时归还");
|
article.setDescription("你借用的 【" + record.getGoodsName() + "】 已逾期未归还,请及时归还");
|
||||||
article.setPicurl(record.getCoverImg());
|
article.setPicurl(record.getCoverImg());
|
||||||
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth/home");
|
article.setUrl("http://wxshop.ab98.cn/shop-api/api/shop/qy/wechatAuth/home");
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class Ab98UserEntity extends BaseEntity<Ab98UserEntity> {
|
||||||
private String userid;
|
private String userid;
|
||||||
|
|
||||||
@ApiModelProperty("真实姓名")
|
@ApiModelProperty("真实姓名")
|
||||||
@TableField("`name`")
|
@TableField("name")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiModelProperty("手机号码")
|
@ApiModelProperty("手机号码")
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.agileboot.domain.cabinet.cell;
|
||||||
|
|
||||||
import com.agileboot.common.core.page.PageDTO;
|
import com.agileboot.common.core.page.PageDTO;
|
||||||
import com.agileboot.domain.cabinet.cell.db.CabinetCellDO;
|
import com.agileboot.domain.cabinet.cell.db.CabinetCellDO;
|
||||||
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellLatestOrderDTO;
|
||||||
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
||||||
import com.agileboot.domain.cabinet.cell.query.SearchCabinetCellWithOrdersQuery;
|
import com.agileboot.domain.cabinet.cell.query.SearchCabinetCellWithOrdersQuery;
|
||||||
import com.agileboot.domain.common.command.BulkOperationCommand;
|
import com.agileboot.domain.common.command.BulkOperationCommand;
|
||||||
|
@ -20,6 +21,7 @@ import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
@ -33,7 +35,25 @@ public class CabinetCellApplicationService {
|
||||||
|
|
||||||
public PageDTO<CabinetCellWithOrderCountDTO> getCabinetCellList(SearchCabinetCellWithOrdersQuery<CabinetCellEntity> query) {
|
public PageDTO<CabinetCellWithOrderCountDTO> getCabinetCellList(SearchCabinetCellWithOrdersQuery<CabinetCellEntity> query) {
|
||||||
Page<CabinetCellWithOrderCountDTO> page = cabinetCellService.getCellListWithOrders(query);
|
Page<CabinetCellWithOrderCountDTO> page = cabinetCellService.getCellListWithOrders(query);
|
||||||
return new PageDTO<>(page.getRecords(), page.getTotal());
|
List<CabinetCellWithOrderCountDTO> list = page.getRecords();
|
||||||
|
|
||||||
|
List<CabinetCellWithOrderCountDTO> rentingCells = list.stream()
|
||||||
|
.filter(cell -> cell.getIsRented().equals(1))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
List<CabinetCellLatestOrderDTO> cellLatestOrderDTOS = cabinetCellService.selectLatestOrderInfoByCell(rentingCells.stream()
|
||||||
|
.map(CabinetCellWithOrderCountDTO::getCellId).collect(Collectors.toList()));
|
||||||
|
|
||||||
|
for (CabinetCellWithOrderCountDTO cell : rentingCells) {
|
||||||
|
cellLatestOrderDTOS.stream()
|
||||||
|
.filter(order -> order.getCellId().equals(cell.getCellId()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(order -> {
|
||||||
|
BeanUtils.copyProperties(order, cell);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new PageDTO<>(list, page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCabinetCell(AddCabinetCellCommand command) {
|
public void addCabinetCell(AddCabinetCellCommand command) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.agileboot.domain.cabinet.cell.db;
|
package com.agileboot.domain.cabinet.cell.db;
|
||||||
|
|
||||||
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellLatestOrderDTO;
|
||||||
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetDO;
|
import com.agileboot.domain.cabinet.smartCabinet.db.SmartCabinetDO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
@ -74,4 +75,40 @@ public interface CabinetCellMapper extends BaseMapper<CabinetCellEntity> {
|
||||||
"WHERE cabinet_id = #{cabinetId} AND deleted = 0 " +
|
"WHERE cabinet_id = #{cabinetId} AND deleted = 0 " +
|
||||||
"ORDER BY cell_id ASC")
|
"ORDER BY cell_id ASC")
|
||||||
List<CabinetCellDO> selectCabinetCellDOList(@Param("cabinetId") Long cabinetId);
|
List<CabinetCellDO> selectCabinetCellDOList(@Param("cabinetId") Long cabinetId);
|
||||||
|
|
||||||
|
@Select("SELECT " +
|
||||||
|
" cc.cell_id, " +
|
||||||
|
" sog.order_goods_id, " +
|
||||||
|
" so.order_id, " +
|
||||||
|
" so.name, " +
|
||||||
|
" so.mobile, " +
|
||||||
|
" au.face_img, " +
|
||||||
|
" au.ab98_user_id " +
|
||||||
|
"FROM " +
|
||||||
|
" cabinet_cell cc " +
|
||||||
|
"INNER JOIN ( " +
|
||||||
|
" SELECT " +
|
||||||
|
" sog_inner.order_goods_id, " +
|
||||||
|
" sog_inner.order_id, " +
|
||||||
|
" sog_inner.status, " +
|
||||||
|
" sog_inner.cell_id " +
|
||||||
|
" FROM ( " +
|
||||||
|
" SELECT " +
|
||||||
|
" sog.*, " +
|
||||||
|
" ROW_NUMBER() OVER ( " +
|
||||||
|
" PARTITION BY sog.cell_id " +
|
||||||
|
" ORDER BY sog.create_time DESC, sog.order_goods_id DESC " +
|
||||||
|
" ) AS rn " +
|
||||||
|
" FROM shop_order_goods sog " +
|
||||||
|
" WHERE " +
|
||||||
|
" sog.deleted = 0 " +
|
||||||
|
" AND sog.status = 1 " +
|
||||||
|
" AND sog.cell_id IS NOT NULL " +
|
||||||
|
" ) sog_inner " +
|
||||||
|
" WHERE sog_inner.rn = 1 " +
|
||||||
|
") sog ON cc.cell_id = sog.cell_id " +
|
||||||
|
"INNER JOIN shop_order so ON sog.order_id = so.order_id " +
|
||||||
|
"LEFT JOIN ab98_user au ON so.name = au.name AND so.mobile = au.tel AND au.deleted = 0 " +
|
||||||
|
"${ew.customSqlSegment} ")
|
||||||
|
List<CabinetCellLatestOrderDTO> selectLatestOrderInfoByCell(@Param(Constants.WRAPPER) Wrapper<?> queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.agileboot.domain.cabinet.cell.db;
|
package com.agileboot.domain.cabinet.cell.db;
|
||||||
|
|
||||||
import com.agileboot.common.core.page.AbstractPageQuery;
|
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||||
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellLatestOrderDTO;
|
||||||
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
|
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
@ -37,4 +38,6 @@ public interface CabinetCellService extends IService<CabinetCellEntity> {
|
||||||
Long countLinkedRecord();
|
Long countLinkedRecord();
|
||||||
|
|
||||||
List<CabinetCellDO> selectCabinetCellDOList(Long cabinetId);
|
List<CabinetCellDO> selectCabinetCellDOList(Long cabinetId);
|
||||||
|
|
||||||
|
List<CabinetCellLatestOrderDTO> selectLatestOrderInfoByCell(List<Long> cellIds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package com.agileboot.domain.cabinet.cell.db;
|
package com.agileboot.domain.cabinet.cell.db;
|
||||||
|
|
||||||
import com.agileboot.common.core.page.AbstractPageQuery;
|
import com.agileboot.common.core.page.AbstractPageQuery;
|
||||||
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellLatestOrderDTO;
|
||||||
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
import com.agileboot.domain.cabinet.cell.dto.CabinetCellWithOrderCountDTO;
|
||||||
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
|
import com.agileboot.domain.cabinet.smartCabinet.dto.CabinetDetailDTO;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -61,4 +63,17 @@ public class CabinetCellServiceImpl extends ServiceImpl<CabinetCellMapper, Cabin
|
||||||
public List<CabinetCellDO> selectCabinetCellDOList(Long cabinetId) {
|
public List<CabinetCellDO> selectCabinetCellDOList(Long cabinetId) {
|
||||||
return baseMapper.selectCabinetCellDOList(cabinetId);
|
return baseMapper.selectCabinetCellDOList(cabinetId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CabinetCellLatestOrderDTO> selectLatestOrderInfoByCell(List<Long> cellIds) {
|
||||||
|
QueryWrapper<CabinetCellEntity> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("cc.is_rented", 1)
|
||||||
|
.eq("cc.deleted", 0)
|
||||||
|
.eq("so.deleted", 0)
|
||||||
|
.eq("so.status", 2)
|
||||||
|
.eq("so.pay_status", 2)
|
||||||
|
.eq("sog.status", 1)
|
||||||
|
.in("cc.cell_id", cellIds);
|
||||||
|
return baseMapper.selectLatestOrderInfoByCell(queryWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.agileboot.domain.cabinet.cell.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 柜机格口最新订单信息DTO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CabinetCellLatestOrderDTO {
|
||||||
|
/**
|
||||||
|
* 格口ID
|
||||||
|
*/
|
||||||
|
private Long cellId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单商品ID
|
||||||
|
*/
|
||||||
|
private Long orderGoodsId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单ID
|
||||||
|
*/
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户姓名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户手机号
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人脸照片地址
|
||||||
|
*/
|
||||||
|
private String faceImg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇邦云用户ID
|
||||||
|
*/
|
||||||
|
private Long ab98UserId;
|
||||||
|
}
|
|
@ -25,4 +25,38 @@ public class CabinetCellWithOrderCountDTO extends CabinetCellEntity {
|
||||||
@ApiModelProperty("关联商品图片")
|
@ApiModelProperty("关联商品图片")
|
||||||
@TableField("cover_img")
|
@TableField("cover_img")
|
||||||
private String coverImg;
|
private String coverImg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单商品ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("订单商品ID")
|
||||||
|
private Long orderGoodsId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("订单ID")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户姓名
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("客户姓名")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户手机号
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("客户手机号")
|
||||||
|
private String mobile;
|
||||||
|
/**
|
||||||
|
* 人脸照片地址
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("人脸照片地址")
|
||||||
|
private String faceImg;
|
||||||
|
/**
|
||||||
|
* 汇邦云用户ID
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("汇邦云用户ID")
|
||||||
|
private Long ab98UserId;
|
||||||
}
|
}
|
Loading…
Reference in New Issue